Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
skgpu::graphite::CopyTextureToTextureTask Class Referencefinal

#include <CopyTask.h>

Inheritance diagram for skgpu::graphite::CopyTextureToTextureTask:
skgpu::graphite::Task SkRefCnt SkRefCntBase

Public Member Functions

 ~CopyTextureToTextureTask () override
 
Status prepareResources (ResourceProvider *, ScratchResourceManager *, const RuntimeEffectDictionary *) override
 
Status addCommands (Context *, CommandBuffer *, ReplayTargetData) override
 
virtual Status prepareResources (ResourceProvider *, ScratchResourceManager *, const RuntimeEffectDictionary *)=0
 
virtual Status addCommands (Context *, CommandBuffer *, ReplayTargetData)=0
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< CopyTextureToTextureTaskMake (sk_sp< TextureProxy > srcProxy, SkIRect srcRect, sk_sp< TextureProxy > dstProxy, SkIPoint dstPoint, int dstLevel=0)
 

Additional Inherited Members

- Public Types inherited from skgpu::graphite::Task
enum class  Status { kSuccess , kDiscard , kFail }
 

Detailed Description

Definition at line 84 of file CopyTask.h.

Constructor & Destructor Documentation

◆ ~CopyTextureToTextureTask()

skgpu::graphite::CopyTextureToTextureTask::~CopyTextureToTextureTask ( )
override

Definition at line 149 of file CopyTask.cpp.

149{}

Member Function Documentation

◆ addCommands()

Task::Status skgpu::graphite::CopyTextureToTextureTask::addCommands ( Context ,
CommandBuffer commandBuffer,
ReplayTargetData   
)
overridevirtual

Implements skgpu::graphite::Task.

Definition at line 180 of file CopyTask.cpp.

182 {
183 // prepareResources() doesn't instantiate the source assuming that a prior task will have do so
184 // as part of initializing the texture contents.
185 SkASSERT(fSrcProxy->isInstantiated());
186 if (commandBuffer->copyTextureToTexture(fSrcProxy->refTexture(),
187 fSrcRect,
188 fDstProxy->refTexture(),
189 fDstPoint,
190 fDstLevel)) {
191 // TODO(b/332681367): The calling context should be able to specify whether or not this copy
192 // is a repeatable operation (e.g. dst readback copy for blending) or one time (e.g. client
193 // asked for a copy of an image or surface).
194 return Status::kSuccess;
195 } else {
196 return Status::kFail;
197 }
198}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ Make()

sk_sp< CopyTextureToTextureTask > skgpu::graphite::CopyTextureToTextureTask::Make ( sk_sp< TextureProxy srcProxy,
SkIRect  srcRect,
sk_sp< TextureProxy dstProxy,
SkIPoint  dstPoint,
int  dstLevel = 0 
)
static

Definition at line 123 of file CopyTask.cpp.

127 {
128 if (!srcProxy || !dstProxy) {
129 return nullptr;
130 }
131 return sk_sp<CopyTextureToTextureTask>(new CopyTextureToTextureTask(std::move(srcProxy),
132 srcRect,
133 std::move(dstProxy),
134 dstPoint,
135 dstLevel));
136}

◆ prepareResources()

Task::Status skgpu::graphite::CopyTextureToTextureTask::prepareResources ( ResourceProvider resourceProvider,
ScratchResourceManager ,
const RuntimeEffectDictionary  
)
overridevirtual

Implements skgpu::graphite::Task.

Definition at line 151 of file CopyTask.cpp.

153 {
154 // Do not instantiate the src proxy. If the source texture hasn't been instantiated yet, it
155 // means there was no prior task that could have initialized its contents so propagating the
156 // undefined contents to the dst does not make sense.
157 // TODO(b/333729316): Assert that fSrcProxy is instantiated or lazy; right now it may not be
158 // instantatiated if this is a dst readback copy for a scratch Device. In that case, a
159 // RenderPassTask will immediately follow this copy task and instantiate the source proxy so
160 // that addCommands() has a texture to operate on. That said, the texture's contents will be
161 // undefined when the copy is executed ideally it just shouldn't happen.
162
163 // TODO: The copy is also a consumer of the source, so it should participate in returning
164 // scratch resources like RenderPassTask does. For now, though, all copy tasks side step reuse
165 // entirely and they cannot participate until they've been moved into scoping tasks like
166 // DrawTask first. In particular, for texture-to-texture copies, they should be scoped to not
167 // invoke pending listeners for a subsequent RenderPassTask.
168
169 // TODO: Use the scratch resource manager to instantiate fDstProxy, although the details of when
170 // that texture can be returned need to be worked out. While brittle, all current use cases
171 // of scratch texture-to-texture copies have the dst used immediately by the next task, so it
172 // could just add a pending listener that returns the texture w/o any read counting.
173 if (!TextureProxy::InstantiateIfNotLazy(resourceProvider, fDstProxy.get())) {
174 SKGPU_LOG_E("Could not instantiate dst texture proxy for CopyTextureToTextureTask!");
175 return Status::kFail;
176 }
177 return Status::kSuccess;
178}
#define SKGPU_LOG_E(fmt,...)
Definition: Log.h:38
static bool InstantiateIfNotLazy(ResourceProvider *, TextureProxy *)

The documentation for this class was generated from the following files: