Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
GrRenderTask Class Referenceabstract

#include <GrRenderTask.h>

Inheritance diagram for GrRenderTask:
SkRefCnt SkRefCntBase GrBufferTransferRenderTask GrBufferUpdateRenderTask GrCopyRenderTask GrDDLTask GrMockRenderTask GrTextureResolveRenderTask GrTransferFromRenderTask GrWaitRenderTask GrWritePixelsTask skgpu::ganesh::OpsTask

Public Member Functions

 GrRenderTask ()
 
 SkDEBUGCODE (~GrRenderTask() override;) void makeClosed(GrRecordingContext *)
 
void prePrepare (GrRecordingContext *context)
 
void prepare (GrOpFlushState *flushState)
 
bool execute (GrOpFlushState *flushState)
 
virtual bool requiresExplicitCleanup () const
 
virtual void endFlush (GrDrawingManager *)
 
virtual void disown (GrDrawingManager *)
 
bool isClosed () const
 
void makeSkippable ()
 
bool isSkippable () const
 
bool blocksReordering () const
 
void addDependency (GrDrawingManager *, GrSurfaceProxy *dependedOn, skgpu::Mipmapped, GrTextureResolveManager, const GrCaps &caps)
 
void addDependenciesFromOtherTask (GrRenderTask *otherTask)
 
SkSpan< GrRenderTask * > dependencies ()
 
SkSpan< GrRenderTask * > dependents ()
 
void replaceDependency (const GrRenderTask *toReplace, GrRenderTask *replaceWith)
 
void replaceDependent (const GrRenderTask *toReplace, GrRenderTask *replaceWith)
 
bool dependsOn (const GrRenderTask *dependedOn) const
 
uint32_t uniqueID () const
 
int numTargets () const
 
GrSurfaceProxytarget (int i) const
 
virtual skgpu::ganesh::OpsTaskasOpsTask ()
 
bool isUsed (GrSurfaceProxy *proxy) const
 
virtual void gatherProxyIntervals (GrResourceAllocator *) const =0
 
bool isInstantiated () const
 
 SK_DECLARE_INTERNAL_LLIST_INTERFACE (GrRenderTask)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Types

enum class  ExpectedOutcome : bool { kTargetUnchanged , kTargetDirty }
 
enum  Flags {
  kClosed_Flag = 0x01 , kDisowned_Flag = 0x02 , kSkippable_Flag = 0x04 , kAtlas_Flag = 0x08 ,
  kBlocksReordering_Flag = 0x10 , kWasOutput_Flag = 0x20 , kTempMark_Flag = 0x40
}
 

Protected Member Functions

 SkDEBUGCODE (bool deferredProxiesAreInstantiated() const ;) void addTarget(GrDrawingManager *
 
void addTarget (GrDrawingManager *dm, const GrSurfaceProxyView &view)
 
virtual ExpectedOutcome onMakeClosed (GrRecordingContext *, SkIRect *targetUpdateBounds)=0
 
void setFlag (uint32_t flag)
 
void resetFlag (uint32_t flag)
 
bool isSetFlag (uint32_t flag) const
 
void setIndex (uint32_t index)
 
uint32_t getIndex () const
 

Protected Attributes

 sk_sp< GrSurfaceProxy >
 
skia_private::STArray< 1, sk_sp< GrSurfaceProxy > > fTargets
 
skia_private::TArray< GrTextureProxy *, true > fDeferredProxies
 

Private Member Functions

virtual bool onIsUsed (GrSurfaceProxy *) const =0
 
virtual void onMakeSkippable ()
 
virtual void onPrePrepare (GrRecordingContext *)
 
virtual void onPrepare (GrOpFlushState *)
 
virtual bool onExecute (GrOpFlushState *flushState)=0
 

Friends

class GrDrawingManager
 
class GrMockRenderTask
 

Detailed Description

Definition at line 31 of file GrRenderTask.h.

Member Enumeration Documentation

◆ ExpectedOutcome

enum class GrRenderTask::ExpectedOutcome : bool
strongprotected
Enumerator
kTargetUnchanged 
kTargetDirty 

Definition at line 170 of file GrRenderTask.h.

◆ Flags

enum GrRenderTask::Flags
protected
Enumerator
kClosed_Flag 

This task can't accept any more dependencies.

kDisowned_Flag 

This task is disowned by its GrDrawingManager.

kSkippable_Flag 

This task is skippable.

kAtlas_Flag 

This task is atlas.

kBlocksReordering_Flag 

No task can be reordered with respect to this task.

kWasOutput_Flag 

Flag for topological sorting.

kTempMark_Flag 

Flag for topological sorting.

Definition at line 189 of file GrRenderTask.h.

189 {
190 kClosed_Flag = 0x01, //!< This task can't accept any more dependencies.
191 kDisowned_Flag = 0x02, //!< This task is disowned by its GrDrawingManager.
192 kSkippable_Flag = 0x04, //!< This task is skippable.
193 kAtlas_Flag = 0x08, //!< This task is atlas.
194 kBlocksReordering_Flag = 0x10, //!< No task can be reordered with respect to this task.
195
196 kWasOutput_Flag = 0x20, //!< Flag for topological sorting
197 kTempMark_Flag = 0x40, //!< Flag for topological sorting
198 };
@ kBlocksReordering_Flag
No task can be reordered with respect to this task.
@ kWasOutput_Flag
Flag for topological sorting.
@ kAtlas_Flag
This task is atlas.
@ kSkippable_Flag
This task is skippable.
@ kClosed_Flag
This task can't accept any more dependencies.
@ kDisowned_Flag
This task is disowned by its GrDrawingManager.
@ kTempMark_Flag
Flag for topological sorting.

Constructor & Destructor Documentation

◆ GrRenderTask()

GrRenderTask::GrRenderTask ( )

Definition at line 25 of file GrRenderTask.cpp.

26 : fUniqueID(CreateUniqueID())
27 , fFlags(0) {
28}

Member Function Documentation

◆ addDependenciesFromOtherTask()

void GrRenderTask::addDependenciesFromOtherTask ( GrRenderTask otherTask)

Definition at line 116 of file GrRenderTask.cpp.

116 {
117 SkASSERT(otherTask);
118 for (GrRenderTask* task : otherTask->fDependencies) {
119 // The task should not be adding a dependency to itself.
120 SkASSERT(task != this);
121 if (!this->dependsOn(task)) {
122 this->addDependency(task);
123 }
124 }
125}
#define SkASSERT(cond)
Definition SkAssert.h:116
bool dependsOn(const GrRenderTask *dependedOn) const
void addDependency(GrDrawingManager *, GrSurfaceProxy *dependedOn, skgpu::Mipmapped, GrTextureResolveManager, const GrCaps &caps)

◆ addDependency()

void GrRenderTask::addDependency ( GrDrawingManager drawingMgr,
GrSurfaceProxy dependedOn,
skgpu::Mipmapped  mipmapped,
GrTextureResolveManager  textureResolveManager,
const GrCaps caps 
)

Definition at line 128 of file GrRenderTask.cpp.

132 {
133 // If it is still receiving dependencies, this GrRenderTask shouldn't be closed
134 SkASSERT(!this->isClosed());
135
136 GrRenderTask* dependedOnTask = drawingMgr->getLastRenderTask(dependedOn);
137
138 if (dependedOnTask == this) {
139 // self-read - presumably for dst reads. We don't need to do anything in this case. The
140 // XferProcessor will detect what is happening and insert a texture barrier.
141 SkASSERT(skgpu::Mipmapped::kNo == mipmapped);
142 // We should never attempt a self-read on a surface that has a separate MSAA renderbuffer.
143 SkASSERT(!dependedOn->requiresManualMSAAResolve());
144 SkASSERT(!dependedOn->asTextureProxy() ||
145 !dependedOn->asTextureProxy()->texPriv().isDeferred());
146 return;
147 }
148
149 bool alreadyDependent = false;
150 if (dependedOnTask) {
151 if (this->dependsOn(dependedOnTask) || fTextureResolveTask == dependedOnTask) {
152 alreadyDependent = true;
153 dependedOnTask = nullptr; // don't add duplicate dependencies
154 } else if (!dependedOnTask->isSetFlag(kAtlas_Flag)) {
155 // We are closing 'dependedOnTask' here bc the current contents of it are what 'this'
156 // renderTask depends on. We need a break in 'dependedOnTask' so that the usage of
157 // that state has a chance to execute.
158 dependedOnTask->makeClosed(drawingMgr->getContext());
159 }
160 }
161
162 auto resolveFlags = GrSurfaceProxy::ResolveFlags::kNone;
163
164 if (dependedOn->requiresManualMSAAResolve()) {
165 auto* renderTargetProxy = dependedOn->asRenderTargetProxy();
166 SkASSERT(renderTargetProxy);
167 if (renderTargetProxy->isMSAADirty()) {
169 }
170 }
171
172 GrTextureProxy* textureProxy = dependedOn->asTextureProxy();
173 if (skgpu::Mipmapped::kYes == mipmapped) {
174 SkASSERT(textureProxy);
175 if (skgpu::Mipmapped::kYes != textureProxy->mipmapped()) {
176 // There are some cases where we might be given a non-mipmapped texture with a mipmap
177 // filter. See skbug.com/7094.
178 mipmapped = skgpu::Mipmapped::kNo;
179 } else if (textureProxy->mipmapsAreDirty()) {
181 }
182 }
183
184 // Does this proxy have msaa to resolve and/or mipmaps to regenerate?
185 if (GrSurfaceProxy::ResolveFlags::kNone != resolveFlags) {
186 if (!fTextureResolveTask) {
187 fTextureResolveTask = textureResolveManager.newTextureResolveRenderTask(caps);
188 }
189 fTextureResolveTask->addProxy(drawingMgr, sk_ref_sp(dependedOn), resolveFlags, caps);
190
191 // addProxy() should have closed the texture proxy's previous task.
192 SkASSERT(!dependedOnTask || dependedOnTask->isClosed());
193 SkASSERT(drawingMgr->getLastRenderTask(dependedOn) == fTextureResolveTask);
194
195#ifdef SK_DEBUG
196 // addProxy() should have called addDependency (in this instance, recursively) on
197 // fTextureResolveTask.
198 if (dependedOnTask) {
199 SkASSERT(fTextureResolveTask->dependsOn(dependedOnTask));
200 }
201 if (textureProxy && textureProxy->texPriv().isDeferred()) {
202 SkASSERT(fTextureResolveTask->fDeferredProxies.back() == textureProxy);
203 }
204
205 // The GrTextureResolveRenderTask factory should have also marked the proxy clean, set the
206 // last renderTask on the textureProxy to textureResolveTask, and closed textureResolveTask.
207 if (resolveFlags & GrSurfaceProxy::ResolveFlags::kMSAA) {
208 if (GrRenderTargetProxy* renderTargetProxy = dependedOn->asRenderTargetProxy()) {
209 SkASSERT(!renderTargetProxy->isMSAADirty());
210 }
211 }
212 if (textureProxy && (resolveFlags & GrSurfaceProxy::ResolveFlags::kMipMaps)) {
213 SkASSERT(!textureProxy->mipmapsAreDirty());
214 }
215 SkASSERT(drawingMgr->getLastRenderTask(dependedOn) == fTextureResolveTask);
216#endif
217 return;
218 }
219
220 if (textureProxy && textureProxy->texPriv().isDeferred()) {
221 if (alreadyDependent) {
222 SkASSERT(std::find(fDeferredProxies.begin(), fDeferredProxies.end(), textureProxy) !=
224 } else {
225 fDeferredProxies.push_back(textureProxy);
226 }
227 }
228
229 if (dependedOnTask) {
230 this->addDependency(dependedOnTask);
231 }
232}
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381
GrRecordingContext * getContext()
GrRenderTask * getLastRenderTask(const GrSurfaceProxy *) const
bool isClosed() const
bool isSetFlag(uint32_t flag) const
skia_private::TArray< GrTextureProxy *, true > fDeferredProxies
virtual GrRenderTargetProxy * asRenderTargetProxy()
bool requiresManualMSAAResolve() const
virtual GrTextureProxy * asTextureProxy()
GrTextureProxyPriv texPriv()
skgpu::Mipmapped mipmapped() const
bool mipmapsAreDirty() const
GrTextureResolveRenderTask * newTextureResolveRenderTask(const GrCaps &caps) const
void addProxy(GrDrawingManager *, sk_sp< GrSurfaceProxy > proxy, GrSurfaceProxy::ResolveFlags, const GrCaps &)

◆ addTarget()

void GrRenderTask::addTarget ( GrDrawingManager dm,
const GrSurfaceProxyView view 
)
inlineprotected

Definition at line 166 of file GrRenderTask.h.

166 {
167 this->addTarget(dm, view.refProxy());
168 }
void addTarget(GrDrawingManager *dm, const GrSurfaceProxyView &view)
sk_sp< GrSurfaceProxy > refProxy() const

◆ asOpsTask()

virtual skgpu::ganesh::OpsTask * GrRenderTask::asOpsTask ( )
inlinevirtual

Reimplemented in skgpu::ganesh::OpsTask.

Definition at line 109 of file GrRenderTask.h.

109{ return nullptr; }

◆ blocksReordering()

bool GrRenderTask::blocksReordering ( ) const
inline

If true no other task should be reordered relative to this task.

Definition at line 73 of file GrRenderTask.h.

73{ return this->isSetFlag(kBlocksReordering_Flag); }

◆ dependencies()

SkSpan< GrRenderTask * > GrRenderTask::dependencies ( )
inline

Definition at line 90 of file GrRenderTask.h.

90{ return SkSpan(fDependencies); }

◆ dependents()

SkSpan< GrRenderTask * > GrRenderTask::dependents ( )
inline

Definition at line 91 of file GrRenderTask.h.

91{ return SkSpan(fDependents); }

◆ dependsOn()

bool GrRenderTask::dependsOn ( const GrRenderTask dependedOn) const

Definition at line 254 of file GrRenderTask.cpp.

254 {
255 for (int i = 0; i < fDependencies.size(); ++i) {
256 if (fDependencies[i] == dependedOn) {
257 return true;
258 }
259 }
260
261 return false;
262}
int size() const
Definition SkTArray.h:416

◆ disown()

void GrRenderTask::disown ( GrDrawingManager drawingMgr)
virtual

Reimplemented in GrDDLTask.

Definition at line 30 of file GrRenderTask.cpp.

30 {
31 SkASSERT(!fDrawingMgr || drawingMgr == fDrawingMgr);
32 SkASSERT(this->isClosed());
33 if (this->isSetFlag(kDisowned_Flag)) {
34 return;
35 }
36 SkDEBUGCODE(fDrawingMgr = nullptr);
38
40 if (this == drawingMgr->getLastRenderTask(target.get())) {
41 drawingMgr->setLastRenderTask(target.get(), nullptr);
42 }
43 }
44}
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
void setLastRenderTask(const GrSurfaceProxy *, GrRenderTask *)
void setFlag(uint32_t flag)
skia_private::STArray< 1, sk_sp< GrSurfaceProxy > > fTargets
uint32_t * target

◆ endFlush()

virtual void GrRenderTask::endFlush ( GrDrawingManager )
inlinevirtual

Reimplemented in GrDDLTask, and skgpu::ganesh::OpsTask.

Definition at line 49 of file GrRenderTask.h.

49{}

◆ execute()

bool GrRenderTask::execute ( GrOpFlushState flushState)
inline

Definition at line 42 of file GrRenderTask.h.

42{ return this->onExecute(flushState); }
virtual bool onExecute(GrOpFlushState *flushState)=0

◆ gatherProxyIntervals()

virtual void GrRenderTask::gatherProxyIntervals ( GrResourceAllocator ) const
pure virtual

◆ getIndex()

uint32_t GrRenderTask::getIndex ( ) const
inlineprotected

Definition at line 218 of file GrRenderTask.h.

218 {
220 return fFlags >> 7;
221 }

◆ isClosed()

bool GrRenderTask::isClosed ( ) const
inline

Definition at line 56 of file GrRenderTask.h.

56{ return this->isSetFlag(kClosed_Flag); }

◆ isInstantiated()

bool GrRenderTask::isInstantiated ( ) const

Definition at line 289 of file GrRenderTask.cpp.

289 {
290 for (const sk_sp<GrSurfaceProxy>& target : fTargets) {
291 GrSurfaceProxy* proxy = target.get();
292 if (!proxy->isInstantiated()) {
293 return false;
294 }
295
296 GrSurface* surface = proxy->peekSurface();
297 if (surface->wasDestroyed()) {
298 return false;
299 }
300 }
301
302 return true;
303}
GrSurface * peekSurface() const
bool isInstantiated() const
VkSurfaceKHR surface
Definition main.cc:49

◆ isSetFlag()

bool GrRenderTask::isSetFlag ( uint32_t  flag) const
inlineprotected

Definition at line 208 of file GrRenderTask.h.

208 {
209 return SkToBool(fFlags & flag);
210 }
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
FlutterSemanticsFlag flag

◆ isSkippable()

bool GrRenderTask::isSkippable ( ) const
inline

Definition at line 70 of file GrRenderTask.h.

70{ return this->isSetFlag(kSkippable_Flag); }

◆ isUsed()

bool GrRenderTask::isUsed ( GrSurfaceProxy proxy) const
inline

Definition at line 135 of file GrRenderTask.h.

135 {
136 for (const sk_sp<GrSurfaceProxy>& target : fTargets) {
137 if (target.get() == proxy) {
138 return true;
139 }
140 }
141
142 return this->onIsUsed(proxy);
143 }
virtual bool onIsUsed(GrSurfaceProxy *) const =0

◆ makeSkippable()

void GrRenderTask::makeSkippable ( )

Make this task skippable. This must be used purely for optimization purposes at this point as not all tasks will actually skip their work. It would be better if we could detect tasks that can be skipped automatically. We'd need to support minimal flushes (i.e., only flush that which is required for SkSurfaces/SkImages) and the ability to detect "orphaned tasks" and clean them out from the DAG so they don't indefinitely accumulate. Finally, we'd probably have to track whether a proxy's backing store was imported or ever exported to the client in case the client is doing direct reads outside of Skia and thus may require tasks targeting the proxy to execute even if our DAG contains no reads.

Definition at line 46 of file GrRenderTask.cpp.

46 {
47 SkASSERT(this->isClosed());
48 if (!this->isSkippable()) {
50 this->onMakeSkippable();
51 }
52}
bool isSkippable() const
virtual void onMakeSkippable()

◆ numTargets()

int GrRenderTask::numTargets ( ) const
inline

Definition at line 103 of file GrRenderTask.h.

103{ return fTargets.size(); }

◆ onExecute()

virtual bool GrRenderTask::onExecute ( GrOpFlushState flushState)
privatepure virtual

◆ onIsUsed()

virtual bool GrRenderTask::onIsUsed ( GrSurfaceProxy ) const
privatepure virtual

◆ onMakeClosed()

virtual ExpectedOutcome GrRenderTask::onMakeClosed ( GrRecordingContext ,
SkIRect targetUpdateBounds 
)
protectedpure virtual

◆ onMakeSkippable()

virtual void GrRenderTask::onMakeSkippable ( )
inlineprivatevirtual

Reimplemented in GrCopyRenderTask, and skgpu::ganesh::OpsTask.

Definition at line 267 of file GrRenderTask.h.

267{}

◆ onPrepare()

virtual void GrRenderTask::onPrepare ( GrOpFlushState )
inlineprivatevirtual

Reimplemented in GrDDLTask, and skgpu::ganesh::OpsTask.

Definition at line 269 of file GrRenderTask.h.

269{} // OpsTask and GrDDLTask override this

◆ onPrePrepare()

virtual void GrRenderTask::onPrePrepare ( GrRecordingContext )
inlineprivatevirtual

Reimplemented in GrDDLTask, and skgpu::ganesh::OpsTask.

Definition at line 268 of file GrRenderTask.h.

268{} // Only OpsTask currently overrides this

◆ prepare()

void GrRenderTask::prepare ( GrOpFlushState flushState)

Definition at line 97 of file GrRenderTask.cpp.

97 {
98 for (int i = 0; i < fDeferredProxies.size(); ++i) {
99 fDeferredProxies[i]->texPriv().scheduleUpload(flushState);
100 }
101
102 this->onPrepare(flushState);
103}
virtual void onPrepare(GrOpFlushState *)

◆ prePrepare()

void GrRenderTask::prePrepare ( GrRecordingContext context)
inline

Definition at line 38 of file GrRenderTask.h.

38{ this->onPrePrepare(context); }
virtual void onPrePrepare(GrRecordingContext *)

◆ replaceDependency()

void GrRenderTask::replaceDependency ( const GrRenderTask toReplace,
GrRenderTask replaceWith 
)

Definition at line 234 of file GrRenderTask.cpp.

234 {
235 for (auto& target : fDependencies) {
236 if (target == toReplace) {
237 target = replaceWith;
238 replaceWith->fDependents.push_back(this);
239 break;
240 }
241 }
242}

◆ replaceDependent()

void GrRenderTask::replaceDependent ( const GrRenderTask toReplace,
GrRenderTask replaceWith 
)

Definition at line 244 of file GrRenderTask.cpp.

244 {
245 for (auto& target : fDependents) {
246 if (target == toReplace) {
247 target = replaceWith;
248 replaceWith->fDependencies.push_back(this);
249 break;
250 }
251 }
252}

◆ requiresExplicitCleanup()

virtual bool GrRenderTask::requiresExplicitCleanup ( ) const
inlinevirtual

Reimplemented in GrDDLTask.

Definition at line 44 of file GrRenderTask.h.

44{ return false; }

◆ resetFlag()

void GrRenderTask::resetFlag ( uint32_t  flag)
inlineprotected

Definition at line 204 of file GrRenderTask.h.

204 {
205 fFlags &= ~flag;
206 }

◆ setFlag()

void GrRenderTask::setFlag ( uint32_t  flag)
inlineprotected

Definition at line 200 of file GrRenderTask.h.

200 {
201 fFlags |= flag;
202 }

◆ setIndex()

void GrRenderTask::setIndex ( uint32_t  index)
inlineprotected

Definition at line 212 of file GrRenderTask.h.

212 {
214 SkASSERT(index < (1 << 25));
215 fFlags |= index << 7;
216 }

◆ SK_DECLARE_INTERNAL_LLIST_INTERFACE()

GrRenderTask::SK_DECLARE_INTERNAL_LLIST_INTERFACE ( GrRenderTask  )

◆ SkDEBUGCODE() [1/2]

GrRenderTask::SkDEBUGCODE ( bool deferredProxiesAreInstantiated() const ;  )
protected

◆ SkDEBUGCODE() [2/2]

GrRenderTask::SkDEBUGCODE ( ~GrRenderTask() override;  )

◆ target()

GrSurfaceProxy * GrRenderTask::target ( int  i) const
inline

Definition at line 104 of file GrRenderTask.h.

104{ return fTargets[i].get(); }

◆ uniqueID()

uint32_t GrRenderTask::uniqueID ( ) const
inline

Definition at line 102 of file GrRenderTask.h.

102{ return fUniqueID; }

Friends And Related Symbol Documentation

◆ GrDrawingManager

friend class GrDrawingManager
friend

Definition at line 225 of file GrRenderTask.h.

◆ GrMockRenderTask

friend class GrMockRenderTask
friend

Definition at line 226 of file GrRenderTask.h.

Member Data Documentation

◆ fDeferredProxies

skia_private::TArray<GrTextureProxy*, true> GrRenderTask::fDeferredProxies
protected

Definition at line 187 of file GrRenderTask.h.

◆ fTargets

skia_private::STArray<1, sk_sp<GrSurfaceProxy> > GrRenderTask::fTargets
protected

Definition at line 182 of file GrRenderTask.h.

◆ sk_sp< GrSurfaceProxy >

GrRenderTask::sk_sp< GrSurfaceProxy >
protected

Definition at line 159 of file GrRenderTask.h.


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