Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | List of all members
skgpu::ganesh::AtlasRenderTask Class Referencefinal

#include <AtlasRenderTask.h>

Inheritance diagram for skgpu::ganesh::AtlasRenderTask:
skgpu::ganesh::OpsTask GrRenderTask SkRefCnt SkRefCntBase

Public Member Functions

 AtlasRenderTask (GrRecordingContext *, sk_sp< GrArenas >, std::unique_ptr< GrDynamicAtlas >)
 
const GrTextureProxyatlasProxy () const
 
GrSurfaceProxyView readView (const GrCaps &caps) const
 
bool addPath (const SkMatrix &, const SkPath &, SkIPoint pathDevTopLeft, int widthInAtlas, int heightInAtlas, bool transposedInAtlas, SkIPoint16 *locationInAtlas)
 
bool instantiate (GrOnFlushResourceProvider *onFlushRP, sk_sp< GrTexture > backingTexture=nullptr)
 
- Public Member Functions inherited from skgpu::ganesh::OpsTask
 OpsTask (GrDrawingManager *, GrSurfaceProxyView, GrAuditTrail *, sk_sp< GrArenas >)
 
 ~OpsTask () override
 
OpsTaskasOpsTask () override
 
bool isEmpty () const
 
bool usesMSAASurface () const
 
GrXferBarrierFlags renderPassXferBarriers () const
 
void endFlush (GrDrawingManager *) override
 
void onPrePrepare (GrRecordingContext *) override
 
void onPrepare (GrOpFlushState *flushState) override
 
bool onExecute (GrOpFlushState *flushState) override
 
void addSampledTexture (GrSurfaceProxy *proxy)
 
void addOp (GrDrawingManager *, GrOp::Owner, GrTextureResolveManager, const GrCaps &)
 
void addDrawOp (GrDrawingManager *, GrOp::Owner, bool usesMSAA, const GrProcessorSet::Analysis &, GrAppliedClip &&, const GrDstProxyView &, GrTextureResolveManager, const GrCaps &)
 
void discard ()
 
bool resetForFullscreenClear (CanDiscardPreviousOps)
 
void setColorLoadOp (GrLoadOp op, std::array< float, 4 > color={0, 0, 0, 0})
 
bool canMerge (const OpsTask *) const
 
int mergeFrom (SkSpan< const sk_sp< GrRenderTask > > tasks)
 
- Public Member Functions inherited from GrRenderTask
 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 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
 
bool isUsed (GrSurfaceProxy *proxy) const
 
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
 

Private Member Functions

ExpectedOutcome onMakeClosed (GrRecordingContext *, SkIRect *targetUpdateBounds) override
 
bool onExecute (GrOpFlushState *flushState) override
 

Additional Inherited Members

- Public Types inherited from skgpu::ganesh::OpsTask
enum class  CanDiscardPreviousOps : bool { kYes = true , kNo = false }
 
- Protected Types inherited from skgpu::ganesh::OpsTask
enum class  StencilContent { kDontCare , kUserBitsCleared , kPreserved }
 
- Protected Types inherited from GrRenderTask
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 inherited from skgpu::ganesh::OpsTask
void setInitialStencilContent (StencilContent initialContent)
 
void recordOp (GrOp::Owner, bool usesMSAA, GrProcessorSet::Analysis, GrAppliedClip *, const GrDstProxyView *, const GrCaps &)
 
ExpectedOutcome onMakeClosed (GrRecordingContext *, SkIRect *targetUpdateBounds) override
 
- Protected Member Functions inherited from GrRenderTask
 SkDEBUGCODE (bool deferredProxiesAreInstantiated() const ;) void addTarget(GrDrawingManager *
 
void addTarget (GrDrawingManager *dm, const GrSurfaceProxyView &view)
 
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 inherited from GrRenderTask
 sk_sp< GrSurfaceProxy >
 
skia_private::STArray< 1, sk_sp< GrSurfaceProxy > > fTargets
 
skia_private::TArray< GrTextureProxy *, true > fDeferredProxies
 

Detailed Description

Definition at line 28 of file AtlasRenderTask.h.

Constructor & Destructor Documentation

◆ AtlasRenderTask()

skgpu::ganesh::AtlasRenderTask::AtlasRenderTask ( GrRecordingContext rContext,
sk_sp< GrArenas arenas,
std::unique_ptr< GrDynamicAtlas dynamicAtlas 
)

Definition at line 24 of file AtlasRenderTask.cpp.

27 : OpsTask(rContext->priv().drawingManager(),
28 dynamicAtlas->writeView(*rContext->priv().caps()),
29 rContext->priv().auditTrail(),
30 std::move(arenas))
31 , fDynamicAtlas(std::move(dynamicAtlas)) {
32}
const GrCaps * caps() const
GrDrawingManager * drawingManager()
GrRecordingContextPriv priv()
OpsTask(GrDrawingManager *, GrSurfaceProxyView, GrAuditTrail *, sk_sp< GrArenas >)
Definition OpsTask.cpp:392

Member Function Documentation

◆ addPath()

bool skgpu::ganesh::AtlasRenderTask::addPath ( const SkMatrix viewMatrix,
const SkPath path,
SkIPoint  pathDevTopLeft,
int  widthInAtlas,
int  heightInAtlas,
bool  transposedInAtlas,
SkIPoint16 locationInAtlas 
)

Definition at line 34 of file AtlasRenderTask.cpp.

36 {
37 SkASSERT(!this->isClosed());
38 SkASSERT(this->isEmpty());
39 SkASSERT(!fDynamicAtlas->isInstantiated()); // Paths can't be added after instantiate().
40
41 if (!fDynamicAtlas->addRect(widthInAtlas, heightInAtlas, locationInAtlas)) {
42 return false;
43 }
44
45 SkMatrix pathToAtlasMatrix = viewMatrix;
46 if (transposedInAtlas) {
47 std::swap(pathToAtlasMatrix[0], pathToAtlasMatrix[3]);
48 std::swap(pathToAtlasMatrix[1], pathToAtlasMatrix[4]);
49 float tx=pathToAtlasMatrix.getTranslateX(), ty=pathToAtlasMatrix.getTranslateY();
50 pathToAtlasMatrix.setTranslateX(ty - pathDevTopLeft.y() + locationInAtlas->x());
51 pathToAtlasMatrix.setTranslateY(tx - pathDevTopLeft.x() + locationInAtlas->y());
52 } else {
53 pathToAtlasMatrix.postTranslate(locationInAtlas->x() - pathDevTopLeft.x(),
54 locationInAtlas->y() - pathDevTopLeft.y());
55 }
56
58 fWindingPathList.add(&fPathDrawAllocator, pathToAtlasMatrix, path);
59 } else {
60 fEvenOddPathList.add(&fPathDrawAllocator, pathToAtlasMatrix, path);
61 }
62 return true;
63}
GrFillRule GrFillRuleForSkPath(const SkPath &path)
#define SkASSERT(cond)
Definition SkAssert.h:116
bool isClosed() const
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:281
SkMatrix & setTranslateY(SkScalar v)
Definition SkMatrix.h:530
SkScalar getTranslateY() const
Definition SkMatrix.h:452
SkMatrix & setTranslateX(SkScalar v)
Definition SkMatrix.h:524
SkScalar getTranslateX() const
Definition SkMatrix.h:445
bool isEmpty() const
Definition OpsTask.h:50
int16_t y() const
Definition SkIPoint16.h:43
int16_t x() const
Definition SkIPoint16.h:37
constexpr int32_t y() const
constexpr int32_t x() const

◆ atlasProxy()

const GrTextureProxy * skgpu::ganesh::AtlasRenderTask::atlasProxy ( ) const
inline

Definition at line 34 of file AtlasRenderTask.h.

34{ return fDynamicAtlas->textureProxy(); }

◆ instantiate()

bool skgpu::ganesh::AtlasRenderTask::instantiate ( GrOnFlushResourceProvider onFlushRP,
sk_sp< GrTexture backingTexture = nullptr 
)
inline

Definition at line 45 of file AtlasRenderTask.h.

46 {
47 SkASSERT(this->isClosed());
48 return fDynamicAtlas->instantiate(onFlushRP, std::move(backingTexture));
49 }

◆ onExecute()

bool skgpu::ganesh::AtlasRenderTask::onExecute ( GrOpFlushState flushState)
overrideprivatevirtual

Implements GrRenderTask.

Definition at line 180 of file AtlasRenderTask.cpp.

180 {
181 if (!this->OpsTask::onExecute(flushState)) {
182 return false;
183 }
184 if (this->target(0)->requiresManualMSAAResolve()) {
185 // Since atlases don't get closed until they are done being built, the drawingManager
186 // doesn't detect that they need an MSAA resolve. Do it here manually.
187 auto nativeRect = GrNativeRect::MakeIRectRelativeTo(
189 this->target(0)->backingStoreDimensions().height(),
190 SkIRect::MakeSize(fDynamicAtlas->drawBounds()));
191 flushState->gpu()->resolveRenderTarget(this->target(0)->peekRenderTarget(), nativeRect);
192 }
193 return true;
194}
static constexpr GrSurfaceOrigin kTextureOrigin
void resolveRenderTarget(GrRenderTarget *, const SkIRect &resolveRect)
Definition GrGpu.cpp:659
bool onExecute(GrOpFlushState *flushState) override
Definition OpsTask.cpp:540
uint32_t * target
int32_t height
static SkIRect MakeIRectRelativeTo(GrSurfaceOrigin origin, int rtHeight, SkIRect devRect)
static constexpr SkIRect MakeSize(const SkISize &size)
Definition SkRect.h:66

◆ onMakeClosed()

GrRenderTask::ExpectedOutcome skgpu::ganesh::AtlasRenderTask::onMakeClosed ( GrRecordingContext rContext,
SkIRect targetUpdateBounds 
)
overrideprivatevirtual

Implements GrRenderTask.

Definition at line 65 of file AtlasRenderTask.cpp.

66 {
67 // We don't add our ops until now, at which point we know the atlas is done being built.
68 SkASSERT(this->isEmpty());
69 SkASSERT(!fDynamicAtlas->isInstantiated()); // Instantiation happens after makeClosed().
70
71 const GrCaps& caps = *rContext->priv().caps();
72
73 // Set our dimensions now. OpsTask will need them when we add our ops.
74 this->target(0)->priv().setLazyDimensions(fDynamicAtlas->drawBounds());
75 this->target(0)->asRenderTargetProxy()->setNeedsStencil();
76 SkRect drawRect = target(0)->getBoundsRect();
77
78 // Clear the atlas.
82
83 constexpr static GrUserStencilSettings kClearStencil(
85 0x0000,
87 0xffff,
90 0xffff>());
91
92 this->stencilAtlasRect(rContext, drawRect, SK_PMColor4fTRANSPARENT, &kClearStencil);
93 } else {
96 }
97
98 // Add ops to stencil the atlas paths.
99 for (const auto* pathList : {&fWindingPathList, &fEvenOddPathList}) {
100 if (pathList->pathCount() > 0) {
101 auto op = GrOp::Make<PathStencilCoverOp>(
102 rContext,
103 pathList->pathDrawList(),
104 pathList->totalCombinedPathVerbCnt(),
105 pathList->pathCount(),
106 GrPaint(),
109 drawRect);
110 this->addAtlasDrawOp(std::move(op), caps);
111 }
112 }
113
114 // Finally, draw a fullscreen rect to cover our stencilled paths.
115 const GrUserStencilSettings* stencil;
117 constexpr static GrUserStencilSettings kTestStencil(
119 0x0000,
121 0xffff,
124 0xffff>());
125
126 // This is the final op in the task. Since Ganesh is planning to discard the stencil values
127 // anyway, there is no need to reset the stencil values back to 0.
128 stencil = &kTestStencil;
129 } else {
132 0x0000,
134 0xffff,
137 0xffff>());
138
139 // Outset the cover rect to make extra sure we clear every stencil value touched by the
140 // atlas.
141 drawRect.outset(1, 1);
142 stencil = &kTestAndResetStencil;
143 }
144 this->stencilAtlasRect(rContext, drawRect, SK_PMColor4fWHITE, stencil);
145
146 this->OpsTask::onMakeClosed(rContext, targetUpdateBounds);
147
148 // Don't mark msaa dirty. Since this op defers being closed, the drawing manager's dirty
149 // tracking doesn't work anyway. We will just resolve msaa manually during onExecute.
151}
constexpr SkPMColor4f SK_PMColor4fWHITE
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
bool discardStencilValuesAfterRenderPass() const
Definition GrCaps.h:122
bool performColorClearsAsDraws() const
Definition GrCaps.h:431
bool performStencilClearsAsDraws() const
Definition GrCaps.h:438
void setColorLoadOp(GrLoadOp op, std::array< float, 4 > color={0, 0, 0, 0})
Definition OpsTask.cpp:659
void setInitialStencilContent(StencilContent initialContent)
Definition OpsTask.h:136
ExpectedOutcome onMakeClosed(GrRecordingContext *, SkIRect *targetUpdateBounds) override
Definition OpsTask.cpp:1057
static constexpr GrUserStencilSettings kTestAndResetStencil(GrUserStencilSettings::StaticInit< 0x0000, GrUserStencilTest::kLessIfInClip, 0x0001, GrUserStencilOp::kZero, GrUserStencilOp::kReplace, 0xffff >())
static constexpr Init< Ref, Test, TestMask, PassOp, FailOp, WriteMask > StaticInit()
void outset(float dx, float dy)
Definition SkRect.h:1077

◆ readView()

GrSurfaceProxyView skgpu::ganesh::AtlasRenderTask::readView ( const GrCaps caps) const
inline

Definition at line 35 of file AtlasRenderTask.h.

35{ return fDynamicAtlas->readView(caps); }

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