Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
GrDrawingManager Class Reference

#include <GrDrawingManager.h>

Public Types

using PathRenderer = skgpu::ganesh::PathRenderer
 
using PathRendererChain = skgpu::ganesh::PathRendererChain
 

Public Member Functions

 ~GrDrawingManager ()
 
void freeGpuResources ()
 
sk_sp< skgpu::ganesh::OpsTasknewOpsTask (GrSurfaceProxyView, sk_sp< GrArenas > arenas)
 
void addAtlasTask (sk_sp< GrRenderTask > atlasTask, GrRenderTask *previousAtlasTask)
 
GrTextureResolveRenderTasknewTextureResolveRenderTaskBefore (const GrCaps &)
 
void newTextureResolveRenderTask (sk_sp< GrSurfaceProxy > proxy, GrSurfaceProxy::ResolveFlags, const GrCaps &)
 
void newWaitRenderTask (const sk_sp< GrSurfaceProxy > &proxy, std::unique_ptr< std::unique_ptr< GrSemaphore >[]>, int numSemaphores)
 
void newTransferFromRenderTask (const sk_sp< GrSurfaceProxy > &srcProxy, const SkIRect &srcRect, GrColorType surfaceColorType, GrColorType dstColorType, sk_sp< GrGpuBuffer > dstBuffer, size_t dstOffset)
 
sk_sp< GrRenderTasknewCopyRenderTask (sk_sp< GrSurfaceProxy > dst, SkIRect dstRect, const sk_sp< GrSurfaceProxy > &src, SkIRect srcRect, GrSamplerState::Filter filter, GrSurfaceOrigin)
 
void newBufferTransferTask (sk_sp< GrGpuBuffer > src, size_t srcOffset, sk_sp< GrGpuBuffer > dst, size_t dstOffset, size_t size)
 
void newBufferUpdateTask (sk_sp< SkData > src, sk_sp< GrGpuBuffer > dst, size_t dstOffset)
 
bool newWritePixelsTask (sk_sp< GrSurfaceProxy > dst, SkIRect rect, GrColorType srcColorType, GrColorType dstColorType, const GrMipLevel[], int levelCount)
 
GrRecordingContextgetContext ()
 
PathRenderergetPathRenderer (const PathRenderer::CanDrawPathArgs &, bool allowSW, PathRendererChain::DrawType, PathRenderer::StencilSupport *=nullptr)
 
PathRenderergetSoftwarePathRenderer ()
 
skgpu::ganesh::AtlasPathRenderergetAtlasPathRenderer ()
 
PathRenderergetTessellationPathRenderer ()
 
void flushIfNecessary ()
 
GrSemaphoresSubmitted flushSurfaces (SkSpan< GrSurfaceProxy * >, SkSurfaces::BackendSurfaceAccess, const GrFlushInfo &, const skgpu::MutableTextureState *newState)
 
void addOnFlushCallbackObject (GrOnFlushCallbackObject *)
 
GrRenderTaskgetLastRenderTask (const GrSurfaceProxy *) const
 
skgpu::ganesh::OpsTaskgetLastOpsTask (const GrSurfaceProxy *) const
 
void setLastRenderTask (const GrSurfaceProxy *, GrRenderTask *)
 
void moveRenderTasksToDDL (GrDeferredDisplayList *ddl)
 
void createDDLTask (sk_sp< const GrDeferredDisplayList >, sk_sp< GrRenderTargetProxy > newDest)
 
bool flush (SkSpan< GrSurfaceProxy * > proxies, SkSurfaces::BackendSurfaceAccess access, const GrFlushInfo &, const skgpu::MutableTextureState *newState)
 

Static Public Member Functions

static bool ProgramUnitTest (GrDirectContext *, int maxStages, int maxLevels)
 

Friends

class GrOnFlushResourceProvider
 
class GrRecordingContext
 

Detailed Description

Definition at line 46 of file GrDrawingManager.h.

Member Typedef Documentation

◆ PathRenderer

Definition at line 137 of file GrDrawingManager.h.

◆ PathRendererChain

Definition at line 138 of file GrDrawingManager.h.

Constructor & Destructor Documentation

◆ ~GrDrawingManager()

GrDrawingManager::~GrDrawingManager ( )

Definition at line 64 of file GrDrawingManager.cpp.

64 {
65 this->closeAllTasks();
66 this->removeRenderTasks();
67}

Member Function Documentation

◆ addAtlasTask()

void GrDrawingManager::addAtlasTask ( sk_sp< GrRenderTask atlasTask,
GrRenderTask previousAtlasTask 
)

Definition at line 701 of file GrDrawingManager.cpp.

702 {
703 SkDEBUGCODE(this->validate());
704 SkASSERT(fContext);
705
706 if (previousAtlasTask) {
707 previousAtlasTask->makeClosed(fContext);
708 for (GrRenderTask* previousAtlasUser : previousAtlasTask->dependents()) {
709 // Make the new atlas depend on everybody who used the old atlas, and close their tasks.
710 // This guarantees that the previous atlas is totally out of service before we render
711 // the next one, meaning there is only ever one atlas active at a time and that they can
712 // all share the same texture.
713 atlasTask->addDependency(previousAtlasUser);
714 previousAtlasUser->makeClosed(fContext);
715 if (previousAtlasUser == fActiveOpsTask) {
716 fActiveOpsTask = nullptr;
717 }
718 }
719 }
720
722 this->insertTaskBeforeLast(std::move(atlasTask));
723
724 SkDEBUGCODE(this->validate());
725}
#define SkASSERT(cond)
Definition: SkAssert.h:116
void setFlag(uint32_t flag)
Definition: GrRenderTask.h:200
void addDependency(GrDrawingManager *, GrSurfaceProxy *dependedOn, skgpu::Mipmapped, GrTextureResolveManager, const GrCaps &caps)
SkSpan< GrRenderTask * > dependents()
Definition: GrRenderTask.h:91
@ kAtlas_Flag
This task is atlas.
Definition: GrRenderTask.h:193

◆ addOnFlushCallbackObject()

void GrDrawingManager::addOnFlushCallbackObject ( GrOnFlushCallbackObject onFlushCBObject)

Definition at line 534 of file GrDrawingManager.cpp.

534 {
535 fOnFlushCBObjects.push_back(onFlushCBObject);
536}

◆ createDDLTask()

void GrDrawingManager::createDDLTask ( sk_sp< const GrDeferredDisplayList ddl,
sk_sp< GrRenderTargetProxy newDest 
)

Definition at line 596 of file GrDrawingManager.cpp.

597 {
598 SkDEBUGCODE(this->validate());
599
600 if (fActiveOpsTask) {
601 // This is a temporary fix for the partial-MDB world. In that world we're not
602 // reordering so ops that (in the single opsTask world) would've just glommed onto the
603 // end of the single opsTask but referred to a far earlier RT need to appear in their
604 // own opsTask.
605 fActiveOpsTask->makeClosed(fContext);
606 fActiveOpsTask = nullptr;
607 }
608
609 // Propagate the DDL proxy's state information to the replay target.
610 if (ddl->priv().targetProxy()->isMSAADirty()) {
611 auto nativeRect = GrNativeRect::MakeIRectRelativeTo(
612 ddl->characterization().origin(),
614 ddl->priv().targetProxy()->msaaDirtyRect());
615 newDest->markMSAADirty(nativeRect);
616 }
617 GrTextureProxy* newTextureProxy = newDest->asTextureProxy();
618 if (newTextureProxy && skgpu::Mipmapped::kYes == newTextureProxy->mipmapped()) {
619 newTextureProxy->markMipmapsDirty();
620 }
621
622 // Here we jam the proxy that backs the current replay SkSurface into the LazyProxyData.
623 // The lazy proxy that references it (in the DDL opsTasks) will then steal its GrTexture.
624 ddl->fLazyProxyData->fReplayDest = newDest.get();
625
626 // Add a task to handle drawing and lifetime management of the DDL.
627 SkDEBUGCODE(auto ddlTask =) this->appendTask(sk_make_sp<GrDDLTask>(this,
628 std::move(newDest),
629 std::move(ddl)));
630 SkASSERT(ddlTask->isClosed());
631
632 SkDEBUGCODE(this->validate());
633}
sk_sp< T > sk_make_sp(Args &&... args)
Definition: SkRefCnt.h:371
GrRenderTargetProxy * targetProxy() const
GrDeferredDisplayListPriv priv()
SK_API const GrSurfaceCharacterization & characterization() const
void markMSAADirty(SkIRect dirtyRect)
const SkIRect & msaaDirtyRect() const
SkISize backingStoreDimensions() const
virtual GrTextureProxy * asTextureProxy()
void markMipmapsDirty()
skgpu::Mipmapped mipmapped() const
T * get() const
Definition: SkRefCnt.h:303
Definition: ref_ptr.h:256
static SkIRect MakeIRectRelativeTo(GrSurfaceOrigin origin, int rtHeight, SkIRect devRect)
Definition: GrNativeRect.h:31
constexpr int32_t height() const
Definition: SkSize.h:37

◆ flush()

bool GrDrawingManager::flush ( SkSpan< GrSurfaceProxy * >  proxies,
SkSurfaces::BackendSurfaceAccess  access,
const GrFlushInfo info,
const skgpu::MutableTextureState newState 
)

Definition at line 87 of file GrDrawingManager.cpp.

90 {
91 GR_CREATE_TRACE_MARKER_CONTEXT("GrDrawingManager", "flush", fContext);
92
93 if (fFlushing || this->wasAbandoned()) {
94 if (info.fSubmittedProc) {
95 info.fSubmittedProc(info.fSubmittedContext, false);
96 }
97 if (info.fFinishedProc) {
98 info.fFinishedProc(info.fFinishedContext);
99 }
100 return false;
101 }
102
103 SkDEBUGCODE(this->validate());
104
105 // As of now we only short-circuit if we got an explicit list of surfaces to flush.
106 if (!proxies.empty() && !info.fNumSemaphores && !info.fFinishedProc &&
107 access == SkSurfaces::BackendSurfaceAccess::kNoAccess && !newState) {
108 bool allUnused = std::all_of(proxies.begin(), proxies.end(), [&](GrSurfaceProxy* proxy) {
109 bool used = std::any_of(fDAG.begin(), fDAG.end(), [&](auto& task) {
110 return task && task->isUsed(proxy);
111 });
112 return !used;
113 });
114 if (allUnused) {
115 if (info.fSubmittedProc) {
116 info.fSubmittedProc(info.fSubmittedContext, true);
117 }
118 return false;
119 }
120 }
121
122 auto dContext = fContext->asDirectContext();
123 SkASSERT(dContext);
124 dContext->priv().clientMappedBufferManager()->process();
125
126 GrGpu* gpu = dContext->priv().getGpu();
127 // We have a non abandoned and direct GrContext. It must have a GrGpu.
128 SkASSERT(gpu);
129
130 fFlushing = true;
131
132 auto resourceProvider = dContext->priv().resourceProvider();
133 auto resourceCache = dContext->priv().getResourceCache();
134
135 // Semi-usually the GrRenderTasks are already closed at this point, but sometimes Ganesh needs
136 // to flush mid-draw. In that case, the SkGpuDevice's opsTasks won't be closed but need to be
137 // flushed anyway. Closing such opsTasks here will mean new ones will be created to replace them
138 // if the SkGpuDevice(s) write to them again.
139 this->closeAllTasks();
140 fActiveOpsTask = nullptr;
141
142 this->sortTasks();
143
144 if (!fCpuBufferCache) {
145 // We cache more buffers when the backend is using client side arrays. Otherwise, we
146 // expect each pool will use a CPU buffer as a staging buffer before uploading to a GPU
147 // buffer object. Each pool only requires one staging buffer at a time.
148 int maxCachedBuffers = fContext->priv().caps()->preferClientSideDynamicBuffers() ? 2 : 6;
149 fCpuBufferCache = GrBufferAllocPool::CpuBufferCache::Make(maxCachedBuffers);
150 }
151
152 GrOpFlushState flushState(gpu, resourceProvider, &fTokenTracker, fCpuBufferCache);
153
154 GrOnFlushResourceProvider onFlushProvider(this);
155
156 // Prepare any onFlush op lists (e.g. atlases).
157 bool preFlushSuccessful = true;
158 for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) {
159 preFlushSuccessful &= onFlushCBObject->preFlush(&onFlushProvider);
160 }
161
162 bool cachePurgeNeeded = false;
163
164 if (preFlushSuccessful) {
165 bool usingReorderedDAG = false;
166 GrResourceAllocator resourceAllocator(dContext);
167 if (fReduceOpsTaskSplitting) {
168 usingReorderedDAG = this->reorderTasks(&resourceAllocator);
169 if (!usingReorderedDAG) {
170 resourceAllocator.reset();
171 }
172 }
173
174#if 0
175 // Enable this to print out verbose GrOp information
176 SkDEBUGCODE(SkDebugf("RenderTasks (%d):\n", fDAG.count()));
177 for (const auto& task : fDAG) {
178 SkDEBUGCODE(task->dump(/* printDependencies */ true);)
179 }
180#endif
181
182 if (!resourceAllocator.failedInstantiation()) {
183 if (!usingReorderedDAG) {
184 for (const auto& task : fDAG) {
185 SkASSERT(task);
186 task->gatherProxyIntervals(&resourceAllocator);
187 }
188 resourceAllocator.planAssignment();
189 }
190 resourceAllocator.assign();
191 }
192
193 cachePurgeNeeded = !resourceAllocator.failedInstantiation() &&
194 this->executeRenderTasks(&flushState);
195 }
196 this->removeRenderTasks();
197
198 gpu->executeFlushInfo(proxies, access, info, newState);
199
200 // Give the cache a chance to purge resources that become purgeable due to flushing.
201 if (cachePurgeNeeded) {
202 resourceCache->purgeAsNeeded();
203 cachePurgeNeeded = false;
204 }
205 for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) {
206 onFlushCBObject->postFlush(fTokenTracker.nextFlushToken());
207 cachePurgeNeeded = true;
208 }
209 if (cachePurgeNeeded) {
210 resourceCache->purgeAsNeeded();
211 }
212 fFlushing = false;
213
214 return true;
215}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define GR_CREATE_TRACE_MARKER_CONTEXT(classname, op, context)
Definition: GrTracing.h:18
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
const GrCaps * caps() const
static sk_sp< CpuBufferCache > Make(int maxBuffersToCache)
bool preferClientSideDynamicBuffers() const
Definition: GrCaps.h:114
virtual GrDirectContext * asDirectContext()
Definition: GrGpu.h:62
void executeFlushInfo(SkSpan< GrSurfaceProxy * >, SkSurfaces::BackendSurfaceAccess access, const GrFlushInfo &, const skgpu::MutableTextureState *newState)
Definition: GrGpu.cpp:682
GrRecordingContextPriv priv()
constexpr T * begin() const
Definition: SkSpan_impl.h:90
constexpr T * end() const
Definition: SkSpan_impl.h:91
constexpr bool empty() const
Definition: SkSpan_impl.h:96
AtlasToken nextFlushToken() const
Definition: AtlasTypes.h:207
@ kNoAccess
back-end surface will not be used by client

◆ flushIfNecessary()

void GrDrawingManager::flushIfNecessary ( )

Definition at line 1055 of file GrDrawingManager.cpp.

1055 {
1056 auto direct = fContext->asDirectContext();
1057 if (!direct) {
1058 return;
1059 }
1060
1061 auto resourceCache = direct->priv().getResourceCache();
1062 if (resourceCache && resourceCache->requestsFlush()) {
1064 this->submitToGpu(GrSyncCpu::kNo);
1065 }
1066 resourceCache->purgeAsNeeded();
1067 }
1068}
GrResourceCache * getResourceCache()
GrDirectContextPriv priv()
bool flush(SkSpan< GrSurfaceProxy * > proxies, SkSurfaces::BackendSurfaceAccess access, const GrFlushInfo &, const skgpu::MutableTextureState *newState)

◆ flushSurfaces()

GrSemaphoresSubmitted GrDrawingManager::flushSurfaces ( SkSpan< GrSurfaceProxy * >  proxies,
SkSurfaces::BackendSurfaceAccess  access,
const GrFlushInfo info,
const skgpu::MutableTextureState newState 
)

Definition at line 497 of file GrDrawingManager.cpp.

500 {
501 if (this->wasAbandoned()) {
502 if (info.fSubmittedProc) {
503 info.fSubmittedProc(info.fSubmittedContext, false);
504 }
505 if (info.fFinishedProc) {
506 info.fFinishedProc(info.fFinishedContext);
507 }
509 }
510 SkDEBUGCODE(this->validate());
511
512 auto direct = fContext->asDirectContext();
513 SkASSERT(direct);
514 GrGpu* gpu = direct->priv().getGpu();
515 // We have a non abandoned and direct GrContext. It must have a GrGpu.
516 SkASSERT(gpu);
517
518 // TODO: It is important to upgrade the drawingmanager to just flushing the
519 // portion of the DAG required by 'proxies' in order to restore some of the
520 // semantics of this method.
521 bool didFlush = this->flush(proxies, access, info, newState);
522 for (GrSurfaceProxy* proxy : proxies) {
523 resolve_and_mipmap(gpu, proxy);
524 }
525
526 SkDEBUGCODE(this->validate());
527
528 if (!didFlush || (!direct->priv().caps()->backendSemaphoreSupport() && info.fNumSemaphores)) {
530 }
532}
static void resolve_and_mipmap(GrGpu *gpu, GrSurfaceProxy *proxy)

◆ freeGpuResources()

void GrDrawingManager::freeGpuResources ( )

Definition at line 73 of file GrDrawingManager.cpp.

73 {
74 for (int i = fOnFlushCBObjects.size() - 1; i >= 0; --i) {
75 if (!fOnFlushCBObjects[i]->retainOnFreeGpuResources()) {
76 // it's safe to just do this because we're iterating in reverse
77 fOnFlushCBObjects.removeShuffle(i);
78 }
79 }
80
81 // a path renderer may be holding onto resources
82 fPathRendererChain = nullptr;
83 fSoftwarePathRenderer = nullptr;
84}
void removeShuffle(int n)
Definition: SkTArray.h:188
int size() const
Definition: SkTArray.h:421

◆ getAtlasPathRenderer()

skgpu::ganesh::AtlasPathRenderer * GrDrawingManager::getAtlasPathRenderer ( )

Definition at line 1039 of file GrDrawingManager.cpp.

1039 {
1040 if (!fPathRendererChain) {
1041 fPathRendererChain = std::make_unique<PathRendererChain>(fContext,
1042 fOptionsForPathRendererChain);
1043 }
1044 return fPathRendererChain->getAtlasPathRenderer();
1045}

◆ getContext()

GrRecordingContext * GrDrawingManager::getContext ( )
inline

Definition at line 135 of file GrDrawingManager.h.

135{ return fContext; }

◆ getLastOpsTask()

skgpu::ganesh::OpsTask * GrDrawingManager::getLastOpsTask ( const GrSurfaceProxy proxy) const

Definition at line 566 of file GrDrawingManager.cpp.

566 {
567 GrRenderTask* task = this->getLastRenderTask(proxy);
568 return task ? task->asOpsTask() : nullptr;
569}
GrRenderTask * getLastRenderTask(const GrSurfaceProxy *) const
virtual skgpu::ganesh::OpsTask * asOpsTask()
Definition: GrRenderTask.h:109

◆ getLastRenderTask()

GrRenderTask * GrDrawingManager::getLastRenderTask ( const GrSurfaceProxy proxy) const

Definition at line 561 of file GrDrawingManager.cpp.

561 {
562 auto entry = fLastRenderTasks.find(proxy->uniqueID().asUInt());
563 return entry ? *entry : nullptr;
564}
const V * find(const K &key) const
uint32_t asUInt() const
UniqueID uniqueID() const

◆ getPathRenderer()

skgpu::ganesh::PathRenderer * GrDrawingManager::getPathRenderer ( const PathRenderer::CanDrawPathArgs args,
bool  allowSW,
PathRendererChain::DrawType  drawType,
PathRenderer::StencilSupport stencilSupport = nullptr 
)

Definition at line 1003 of file GrDrawingManager.cpp.

1007 {
1008 if (!fPathRendererChain) {
1009 fPathRendererChain =
1010 std::make_unique<PathRendererChain>(fContext, fOptionsForPathRendererChain);
1011 }
1012
1013 auto pr = fPathRendererChain->getPathRenderer(args, drawType, stencilSupport);
1014 if (!pr && allowSW) {
1015 auto swPR = this->getSoftwarePathRenderer();
1016 if (PathRenderer::CanDrawPath::kNo != swPR->canDrawPath(args)) {
1017 pr = swPR;
1018 }
1019 }
1020
1021#if GR_PATH_RENDERER_SPEW
1022 if (pr) {
1023 SkDebugf("getPathRenderer: %s\n", pr->name());
1024 }
1025#endif
1026
1027 return pr;
1028}
PathRenderer * getSoftwarePathRenderer()
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ getSoftwarePathRenderer()

skgpu::ganesh::PathRenderer * GrDrawingManager::getSoftwarePathRenderer ( )

Definition at line 1030 of file GrDrawingManager.cpp.

1030 {
1031 if (!fSoftwarePathRenderer) {
1032 fSoftwarePathRenderer.reset(new skgpu::ganesh::SoftwarePathRenderer(
1033 fContext->priv().proxyProvider(),
1034 fOptionsForPathRendererChain.fAllowPathMaskCaching));
1035 }
1036 return fSoftwarePathRenderer.get();
1037}
GrProxyProvider * proxyProvider()
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310

◆ getTessellationPathRenderer()

skgpu::ganesh::PathRenderer * GrDrawingManager::getTessellationPathRenderer ( )

Definition at line 1047 of file GrDrawingManager.cpp.

1047 {
1048 if (!fPathRendererChain) {
1049 fPathRendererChain = std::make_unique<PathRendererChain>(fContext,
1050 fOptionsForPathRendererChain);
1051 }
1052 return fPathRendererChain->getTessellationPathRenderer();
1053}

◆ moveRenderTasksToDDL()

void GrDrawingManager::moveRenderTasksToDDL ( GrDeferredDisplayList ddl)

Definition at line 571 of file GrDrawingManager.cpp.

571 {
572 SkDEBUGCODE(this->validate());
573
574 // no renderTask should receive a new command after this
575 this->closeAllTasks();
576 fActiveOpsTask = nullptr;
577
578 this->sortTasks();
579
580 fDAG.swap(ddl->fRenderTasks);
581 SkASSERT(fDAG.empty());
582 fReorderBlockerTaskIndices.clear();
583
584 for (auto& renderTask : ddl->fRenderTasks) {
585 renderTask->disown(this);
586 renderTask->prePrepare(fContext);
587 }
588
589 ddl->fArenas = std::move(fContext->priv().detachArenas());
590
591 fContext->priv().detachProgramData(&ddl->fProgramData);
592
593 SkDEBUGCODE(this->validate());
594}
GrRecordingContext::OwnedArenas && detachArenas()
void detachProgramData(skia_private::TArray< GrRecordingContext::ProgramData > *dst)
bool empty() const
Definition: SkTArray.h:199
void swap(TArray &that)
Definition: SkTArray.h:358

◆ newBufferTransferTask()

void GrDrawingManager::newBufferTransferTask ( sk_sp< GrGpuBuffer src,
size_t  srcOffset,
sk_sp< GrGpuBuffer dst,
size_t  dstOffset,
size_t  size 
)

Definition at line 847 of file GrDrawingManager.cpp.

851 {
852 SkASSERT(src);
853 SkASSERT(dst);
854 SkASSERT(srcOffset + size <= src->size());
855 SkASSERT(dstOffset + size <= dst->size());
856 SkASSERT(src->intendedType() == GrGpuBufferType::kXferCpuToGpu);
857 SkASSERT(dst->intendedType() != GrGpuBufferType::kXferCpuToGpu);
858
859 SkDEBUGCODE(this->validate());
860 SkASSERT(fContext);
861
862 this->closeActiveOpsTask();
863
865 srcOffset,
866 std::move(dst),
867 dstOffset,
868 size);
869 SkASSERT(task);
870
871 this->appendTask(task);
872 task->makeClosed(fContext);
873
874 // We have closed the previous active oplist but since a new oplist isn't being added there
875 // shouldn't be an active one.
876 SkASSERT(!fActiveOpsTask);
877 SkDEBUGCODE(this->validate());
878}
static sk_sp< GrRenderTask > Make(sk_sp< GrGpuBuffer > src, size_t srcOffset, sk_sp< GrGpuBuffer > dst, size_t dstOffset, size_t size)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
dst
Definition: cp.py:12

◆ newBufferUpdateTask()

void GrDrawingManager::newBufferUpdateTask ( sk_sp< SkData src,
sk_sp< GrGpuBuffer dst,
size_t  dstOffset 
)

Definition at line 880 of file GrDrawingManager.cpp.

882 {
883 SkASSERT(src);
884 SkASSERT(dst);
885 SkASSERT(dstOffset + src->size() <= dst->size());
886 SkASSERT(dst->intendedType() != GrGpuBufferType::kXferCpuToGpu);
887 SkASSERT(!dst->isMapped());
888
889 SkDEBUGCODE(this->validate());
890 SkASSERT(fContext);
891
892 this->closeActiveOpsTask();
893
895 std::move(dst),
896 dstOffset);
897 SkASSERT(task);
898
899 this->appendTask(task);
900 task->makeClosed(fContext);
901
902 // We have closed the previous active oplist but since a new oplist isn't being added there
903 // shouldn't be an active one.
904 SkASSERT(!fActiveOpsTask);
905 SkDEBUGCODE(this->validate());
906}
static sk_sp< GrRenderTask > Make(sk_sp< SkData > src, sk_sp< GrGpuBuffer > dst, size_t dstOffset)

◆ newCopyRenderTask()

sk_sp< GrRenderTask > GrDrawingManager::newCopyRenderTask ( sk_sp< GrSurfaceProxy dst,
SkIRect  dstRect,
const sk_sp< GrSurfaceProxy > &  src,
SkIRect  srcRect,
GrSamplerState::Filter  filter,
GrSurfaceOrigin  origin 
)

Definition at line 908 of file GrDrawingManager.cpp.

913 {
914 SkDEBUGCODE(this->validate());
915 SkASSERT(fContext);
916
917 // It'd be nicer to check this in GrCopyRenderTask::Make. This gets complicated because of
918 // "active ops task" tracking. dst will be the target of our copy task but it might also be the
919 // target of the active ops task. We currently require the active ops task to be closed before
920 // making a new task that targets the same proxy. However, if we first close the active ops
921 // task, then fail to make a copy task, the next active ops task may target the same proxy. This
922 // will trip an assert related to unnecessary ops task splitting.
923 if (src->framebufferOnly()) {
924 return nullptr;
925 }
926
927 this->closeActiveOpsTask();
928
930 std::move(dst),
931 dstRect,
932 src,
933 srcRect,
934 filter,
935 origin);
936 if (!task) {
937 return nullptr;
938 }
939
940 this->appendTask(task);
941
942 const GrCaps& caps = *fContext->priv().caps();
943 // We always say skgpu::Mipmapped::kNo here since we are always just copying from the base layer
944 // to another base layer. We don't need to make sure the whole mip map chain is valid.
945 task->addDependency(
946 this, src.get(), skgpu::Mipmapped::kNo, GrTextureResolveManager(this), caps);
947 task->makeClosed(fContext);
948
949 // We have closed the previous active oplist but since a new oplist isn't being added there
950 // shouldn't be an active one.
951 SkASSERT(!fActiveOpsTask);
952 SkDEBUGCODE(this->validate());
953 return task;
954}
Definition: GrCaps.h:57
static sk_sp< GrRenderTask > Make(GrDrawingManager *, sk_sp< GrSurfaceProxy > dst, SkIRect dstRect, sk_sp< GrSurfaceProxy > src, SkIRect srcRect, GrSamplerState::Filter filter, GrSurfaceOrigin)

◆ newOpsTask()

sk_sp< skgpu::ganesh::OpsTask > GrDrawingManager::newOpsTask ( GrSurfaceProxyView  surfaceView,
sk_sp< GrArenas arenas 
)

Definition at line 681 of file GrDrawingManager.cpp.

682 {
683 SkDEBUGCODE(this->validate());
684 SkASSERT(fContext);
685
686 this->closeActiveOpsTask();
687
689 this, std::move(surfaceView), fContext->priv().auditTrail(), std::move(arenas)));
690
691 SkASSERT(this->getLastRenderTask(opsTask->target(0)) == opsTask.get());
692
693 this->appendTask(opsTask);
694
695 fActiveOpsTask = opsTask.get();
696
697 SkDEBUGCODE(this->validate());
698 return opsTask;
699}

◆ newTextureResolveRenderTask()

void GrDrawingManager::newTextureResolveRenderTask ( sk_sp< GrSurfaceProxy proxy,
GrSurfaceProxy::ResolveFlags  flags,
const GrCaps caps 
)

Definition at line 742 of file GrDrawingManager.cpp.

744 {
745 SkDEBUGCODE(this->validate());
746 SkASSERT(fContext);
747
748 if (!proxy->requiresManualMSAAResolve()) {
749 SkDEBUGCODE(this->validate());
750 return;
751 }
752
753 GrRenderTask* lastTask = this->getLastRenderTask(proxy.get());
754 if (!proxy->asRenderTargetProxy()->isMSAADirty() && (!lastTask || lastTask->isClosed())) {
755 SkDEBUGCODE(this->validate());
756 return;
757 }
758
759 this->closeActiveOpsTask();
760
761 auto resolveTask = sk_make_sp<GrTextureResolveRenderTask>();
762 // Add proxy also adds all the needed dependencies we need
763 resolveTask->addProxy(this, std::move(proxy), flags, caps);
764
765 auto task = this->appendTask(std::move(resolveTask));
766 task->makeClosed(fContext);
767
768 // We have closed the previous active oplist but since a new oplist isn't being added there
769 // shouldn't be an active one.
770 SkASSERT(!fActiveOpsTask);
771 SkDEBUGCODE(this->validate());
772}
bool isClosed() const
Definition: GrRenderTask.h:56
virtual GrRenderTargetProxy * asRenderTargetProxy()
bool requiresManualMSAAResolve() const
FlutterSemanticsFlag flags

◆ newTextureResolveRenderTaskBefore()

GrTextureResolveRenderTask * GrDrawingManager::newTextureResolveRenderTaskBefore ( const GrCaps caps)

Definition at line 727 of file GrDrawingManager.cpp.

728 {
729 // Unlike in the "new opsTask" case, we do not want to close the active opsTask, nor (if we are
730 // in sorting and opsTask reduction mode) the render tasks that depend on any proxy's current
731 // state. This is because those opsTasks can still receive new ops and because if they refer to
732 // the mipmapped version of 'proxy', they will then come to depend on the render task being
733 // created here.
734 //
735 // Add the new textureResolveTask before the fActiveOpsTask (if not in
736 // sorting/opsTask-splitting-reduction mode) because it will depend upon this resolve task.
737 // NOTE: Putting it here will also reduce the amount of work required by the topological sort.
738 GrRenderTask* task = this->insertTaskBeforeLast(sk_make_sp<GrTextureResolveRenderTask>());
739 return static_cast<GrTextureResolveRenderTask*>(task);
740}

◆ newTransferFromRenderTask()

void GrDrawingManager::newTransferFromRenderTask ( const sk_sp< GrSurfaceProxy > &  srcProxy,
const SkIRect srcRect,
GrColorType  surfaceColorType,
GrColorType  dstColorType,
sk_sp< GrGpuBuffer dstBuffer,
size_t  dstOffset 
)

Definition at line 819 of file GrDrawingManager.cpp.

824 {
825 SkDEBUGCODE(this->validate());
826 SkASSERT(fContext);
827 this->closeActiveOpsTask();
828
829 GrRenderTask* task = this->appendTask(sk_make_sp<GrTransferFromRenderTask>(
830 srcProxy, srcRect, surfaceColorType, dstColorType,
831 std::move(dstBuffer), dstOffset));
832
833 const GrCaps& caps = *fContext->priv().caps();
834
835 // We always say skgpu::Mipmapped::kNo here since we are always just copying from the base
836 // layer. We don't need to make sure the whole mip map chain is valid.
837 task->addDependency(
838 this, srcProxy.get(), skgpu::Mipmapped::kNo, GrTextureResolveManager(this), caps);
839 task->makeClosed(fContext);
840
841 // We have closed the previous active oplist but since a new oplist isn't being added there
842 // shouldn't be an active one.
843 SkASSERT(!fActiveOpsTask);
844 SkDEBUGCODE(this->validate());
845}

◆ newWaitRenderTask()

void GrDrawingManager::newWaitRenderTask ( const sk_sp< GrSurfaceProxy > &  proxy,
std::unique_ptr< std::unique_ptr< GrSemaphore >[]>  semaphores,
int  numSemaphores 
)

Definition at line 774 of file GrDrawingManager.cpp.

776 {
777 SkDEBUGCODE(this->validate());
778 SkASSERT(fContext);
779
780 sk_sp<GrWaitRenderTask> waitTask = sk_make_sp<GrWaitRenderTask>(GrSurfaceProxyView(proxy),
781 std::move(semaphores),
782 numSemaphores);
783
784 if (fActiveOpsTask && (fActiveOpsTask->target(0) == proxy.get())) {
785 SkASSERT(this->getLastRenderTask(proxy.get()) == fActiveOpsTask);
786 this->insertTaskBeforeLast(waitTask);
787 // In this case we keep the current renderTask open but just insert the new waitTask
788 // before it in the list. The waitTask will never need to trigger any resolves or mip
789 // map generation which is the main advantage of going through the proxy version.
790 // Additionally we would've had to temporarily set the wait task as the lastRenderTask
791 // on the proxy, add the dependency, and then reset the lastRenderTask to
792 // fActiveOpsTask. Additionally we make the waitTask depend on all of fActiveOpsTask
793 // dependencies so that we don't unnecessarily reorder the waitTask before them.
794 // Note: Any previous Ops already in fActiveOpsTask will get blocked by the wait
795 // semaphore even though they don't need to be for correctness.
796
797 // Make sure we add the dependencies of fActiveOpsTask to waitTask first or else we'll
798 // get a circular self dependency of waitTask on waitTask.
799 waitTask->addDependenciesFromOtherTask(fActiveOpsTask);
800 fActiveOpsTask->addDependency(waitTask.get());
801 } else {
802 // In this case we just close the previous RenderTask and start and append the waitTask
803 // to the DAG. Since it is the last task now we call setLastRenderTask on the proxy. If
804 // there is a lastTask on the proxy we make waitTask depend on that task. This
805 // dependency isn't strictly needed but it does keep the DAG from reordering the
806 // waitTask earlier and blocking more tasks.
807 if (GrRenderTask* lastTask = this->getLastRenderTask(proxy.get())) {
808 waitTask->addDependency(lastTask);
809 }
810 this->setLastRenderTask(proxy.get(), waitTask.get());
811 this->closeActiveOpsTask();
812 this->appendTask(waitTask);
813 }
814 waitTask->makeClosed(fContext);
815
816 SkDEBUGCODE(this->validate());
817}
void setLastRenderTask(const GrSurfaceProxy *, GrRenderTask *)
GrSurfaceProxy * target(int i) const
Definition: GrRenderTask.h:104

◆ newWritePixelsTask()

bool GrDrawingManager::newWritePixelsTask ( sk_sp< GrSurfaceProxy dst,
SkIRect  rect,
GrColorType  srcColorType,
GrColorType  dstColorType,
const GrMipLevel  levels[],
int  levelCount 
)

Definition at line 956 of file GrDrawingManager.cpp.

961 {
962 SkDEBUGCODE(this->validate());
963 SkASSERT(fContext);
964
965 this->closeActiveOpsTask();
966 const GrCaps& caps = *fContext->priv().caps();
967
968 // On platforms that prefer flushes over VRAM use (i.e., ANGLE) we're better off forcing a
969 // complete flush here.
970 if (!caps.preferVRAMUseOverFlushes()) {
973 GrFlushInfo{},
974 nullptr);
975 }
976
977 GrRenderTask* task = this->appendTask(GrWritePixelsTask::Make(this,
978 std::move(dst),
979 rect,
980 srcColorType,
981 dstColorType,
982 levels,
983 levelCount));
984 if (!task) {
985 return false;
986 }
987
988 task->makeClosed(fContext);
989
990 // We have closed the previous active oplist but since a new oplist isn't being added there
991 // shouldn't be an active one.
992 SkASSERT(!fActiveOpsTask);
993 SkDEBUGCODE(this->validate());
994 return true;
995}
bool preferVRAMUseOverFlushes() const
Definition: GrCaps.h:137
GrSemaphoresSubmitted flushSurfaces(SkSpan< GrSurfaceProxy * >, SkSurfaces::BackendSurfaceAccess, const GrFlushInfo &, const skgpu::MutableTextureState *newState)
static sk_sp< GrRenderTask > Make(GrDrawingManager *, sk_sp< GrSurfaceProxy >, SkIRect, GrColorType srcColorType, GrColorType dstColorType, const GrMipLevel[], int levelCount)
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350

◆ ProgramUnitTest()

bool GrDrawingManager::ProgramUnitTest ( GrDirectContext ,
int  maxStages,
int  maxLevels 
)
static

Definition at line 268 of file ProgramsTest.cpp.

268{ return true; }

◆ setLastRenderTask()

void GrDrawingManager::setLastRenderTask ( const GrSurfaceProxy proxy,
GrRenderTask task 
)

Definition at line 547 of file GrDrawingManager.cpp.

547 {
548#ifdef SK_DEBUG
549 if (auto prior = this->getLastRenderTask(proxy)) {
550 SkASSERT(prior->isClosed() || prior == task);
551 }
552#endif
553 uint32_t key = proxy->uniqueID().asUInt();
554 if (task) {
555 fLastRenderTasks.set(key, task);
556 } else if (fLastRenderTasks.find(key)) {
557 fLastRenderTasks.remove(key);
558 }
559}
const V * set(K key, V val)

Friends And Related Function Documentation

◆ GrOnFlushResourceProvider

friend class GrOnFlushResourceProvider
friend

Definition at line 219 of file GrDrawingManager.h.

◆ GrRecordingContext

friend class GrRecordingContext
friend

Definition at line 220 of file GrDrawingManager.h.


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