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

#include <PathStencilCoverOp.h>

Inheritance diagram for skgpu::ganesh::PathStencilCoverOp:
GrDrawOp GrOp SkNoncopyable

Private Member Functions

const char * name () const override
 
void visitProxies (const GrVisitProxyFunc &) const override
 
FixedFunctionFlags fixedFunctionFlags () const override
 
GrProcessorSet::Analysis finalize (const GrCaps &, const GrAppliedClip *, GrClampType) override
 
void onPrePrepare (GrRecordingContext *, const GrSurfaceProxyView &, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags, GrLoadOp colorLoadOp) override
 
void onPrepare (GrOpFlushState *) override
 
void onExecute (GrOpFlushState *, const SkRect &chainBounds) override
 

Friends

class GrOp
 

Additional Inherited Members

- Public Types inherited from GrDrawOp
enum class  ClipResult { kFail , kClippedGeometrically , kClippedInShader , kClippedOut }
 
- Public Types inherited from GrOp
enum class  CombineResult { kMerged , kMayChain , kCannotCombine }
 
enum class  HasAABloat : bool { kNo = false , kYes = true }
 
enum class  IsHairline : bool { kNo = false , kYes = true }
 
using Owner = std::unique_ptr< GrOp >
 
- Public Member Functions inherited from GrDrawOp
 GrDrawOp (uint32_t classID)
 
virtual bool usesMSAA () const
 
virtual ClipResult clipToShape (skgpu::ganesh::SurfaceDrawContext *, SkClipOp, const SkMatrix &, const GrShape &, GrAA)
 
virtual bool usesStencil () const
 
- Public Member Functions inherited from GrOp
virtual ~GrOp ()=default
 
CombineResult combineIfPossible (GrOp *that, SkArenaAlloc *alloc, const GrCaps &caps)
 
const SkRectbounds () const
 
void setClippedBounds (const SkRect &clippedBounds)
 
bool hasAABloat () const
 
bool hasZeroArea () const
 
void operator delete (void *p)
 
template<typename T >
const Tcast () const
 
template<typename T >
Tcast ()
 
uint32_t classID () const
 
uint32_t uniqueID () const
 
void prePrepare (GrRecordingContext *context, const GrSurfaceProxyView &dstView, GrAppliedClip *clip, const GrDstProxyView &dstProxyView, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
 
void prepare (GrOpFlushState *state)
 
void execute (GrOpFlushState *state, const SkRect &chainBounds)
 
void chainConcat (GrOp::Owner)
 
bool isChainHead () const
 
bool isChainTail () const
 
GrOpnextInChain () const
 
GrOpprevInChain () const
 
GrOp::Owner cutChain ()
 
void setBounds (const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
 
void setTransformedBounds (const SkRect &srcBounds, const SkMatrix &m, HasAABloat aabloat, IsHairline zeroArea)
 
void makeFullScreen (GrSurfaceProxy *proxy)
 
- Static Public Member Functions inherited from GrOp
template<typename Op , typename... Args>
static Owner Make (GrRecordingContext *context, Args &&... args)
 
template<typename Op , typename... Args>
static Owner MakeWithProcessorSet (GrRecordingContext *context, const SkPMColor4f &color, GrPaint &&paint, Args &&... args)
 
template<typename Op , typename... Args>
static Owner MakeWithExtraMemory (GrRecordingContext *context, size_t extraSize, Args &&... args)
 
static uint32_t GenOpClassID ()
 
- Protected Types inherited from GrDrawOp
enum class  FixedFunctionFlags : uint32_t { kNone = 0x0 , kUsesHWAA = 0x1 , kUsesStencil = 0x2 }
 
- Protected Member Functions inherited from GrDrawOp
 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (FixedFunctionFlags)
 

Detailed Description

Definition at line 21 of file PathStencilCoverOp.h.

Member Function Documentation

◆ finalize()

GrProcessorSet::Analysis skgpu::ganesh::PathStencilCoverOp::finalize ( const GrCaps ,
const GrAppliedClip ,
GrClampType   
)
overrideprivatevirtual

This is called after the GrAppliedClip has been computed and just prior to recording the op or combining it with a previously recorded op. The op should convert any proxies or resources it owns to "pending io" status so that resource allocation can be more optimal. Additionally, at this time the op must report whether a copy of the destination (or destination texture itself) needs to be provided to the GrXferProcessor when this op executes.

Implements GrDrawOp.

Definition at line 125 of file PathStencilCoverOp.cpp.

127 {
128 return fProcessors.finalize(fColor, GrProcessorAnalysisCoverage::kNone, clip, nullptr, caps,
129 clampType, &fColor);
130}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
Analysis finalize(const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage, const GrAppliedClip *, const GrUserStencilSettings *, const GrCaps &, GrClampType, SkPMColor4f *inputColorOverride)

◆ fixedFunctionFlags()

GrDrawOp::FixedFunctionFlags skgpu::ganesh::PathStencilCoverOp::fixedFunctionFlags ( ) const
overrideprivatevirtual

Reimplemented from GrDrawOp.

Definition at line 117 of file PathStencilCoverOp.cpp.

117 {
119 if (fAAType != GrAAType::kNone) {
121 }
122 return flags;
123}
FlutterSemanticsFlag flags

◆ name()

const char * skgpu::ganesh::PathStencilCoverOp::name ( ) const
inlineoverrideprivatevirtual

Implements GrOp.

Definition at line 70 of file PathStencilCoverOp.h.

70{ return "PathStencilCoverOp"; }

◆ onExecute()

void skgpu::ganesh::PathStencilCoverOp::onExecute ( GrOpFlushState flushState,
const SkRect chainBounds 
)
overrideprivatevirtual

Implements GrOp.

Definition at line 318 of file PathStencilCoverOp.cpp.

318 {
319 if (!fTessellator) {
320 return;
321 }
322
323 if (fCoverBBoxProgram &&
324 fCoverBBoxProgram->geomProc().hasVertexAttributes() &&
325 !fBBoxVertexBufferIfNoIDSupport) {
326 return;
327 }
328
329 // Stencil the inner fan, if any.
330 if (fFanVertexCount > 0) {
331 SkASSERT(fStencilFanProgram);
332 SkASSERT(fFanBuffer);
333 flushState->bindPipelineAndScissorClip(*fStencilFanProgram, this->bounds());
334 flushState->bindBuffers(nullptr, nullptr, fFanBuffer);
335 flushState->draw(fFanVertexCount, fFanBaseVertex);
336 }
337
338 // Stencil the rest of the path.
339 SkASSERT(fStencilPathProgram);
340 flushState->bindPipelineAndScissorClip(*fStencilPathProgram, this->bounds());
341 fTessellator->draw(flushState);
342
343 // Fill in the bounding box (if not in stencil-only mode).
344 if (fCoverBBoxProgram) {
345 flushState->bindPipelineAndScissorClip(*fCoverBBoxProgram, this->bounds());
346 flushState->bindTextures(fCoverBBoxProgram->geomProc(), nullptr,
347 fCoverBBoxProgram->pipeline());
348 flushState->bindBuffers(nullptr, fBBoxBuffer, fBBoxVertexBufferIfNoIDSupport);
349 flushState->drawInstanced(fPathCount, fBBoxBaseInstance, 4, 0);
350 }
351}
#define SkASSERT(cond)
Definition SkAssert.h:116
void bindPipelineAndScissorClip(const GrProgramInfo &programInfo, const SkRect &drawBounds)
void bindBuffers(sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart primitiveRestart=GrPrimitiveRestart::kNo)
void drawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex)
void bindTextures(const GrGeometryProcessor &geomProc, const GrSurfaceProxy &singleGeomProcTexture, const GrPipeline &pipeline)
void draw(int vertexCount, int baseVertex)
const SkRect & bounds() const
Definition GrOp.h:122
const GrPipeline & pipeline() const
const GrGeometryProcessor & geomProc() const

◆ onPrepare()

void skgpu::ganesh::PathStencilCoverOp::onPrepare ( GrOpFlushState flushState)
overrideprivatevirtual

Implements GrOp.

Definition at line 224 of file PathStencilCoverOp.cpp.

224 {
225 if (!fTessellator) {
226 this->prePreparePrograms({flushState->allocator(), flushState->writeView(),
227 flushState->usesMSAASurface(), &flushState->dstProxyView(),
228 flushState->renderPassBarriers(), flushState->colorLoadOp(),
229 &flushState->caps()}, flushState->detachAppliedClip());
230 if (!fTessellator) {
231 return;
232 }
233 }
234
235 if (fStencilFanProgram) {
236 // The inner fan isn't built into the tessellator. Generate a standard Redbook fan with a
237 // middle-out topology.
238 GrEagerDynamicVertexAllocator vertexAlloc(flushState, &fFanBuffer, &fFanBaseVertex);
239 // Path fans might have an extra edge from an implicit kClose at the end, but they also
240 // always begin with kMove. So the max possible number of edges in a single path is equal to
241 // the number of verbs. Therefore, the max number of combined fan edges in a path list is
242 // the number of combined verbs from the paths in the list.
243 // A single n-sided polygon is fanned by n-2 triangles. Multiple polygons with a combined
244 // edge count of n are fanned by strictly fewer triangles.
245 int maxTrianglesInFans = std::max(fTotalCombinedPathVerbCnt - 2, 0);
246 int fanTriangleCount = 0;
247 if (VertexWriter triangleVertexWriter =
248 vertexAlloc.lockWriter(sizeof(SkPoint), maxTrianglesInFans * 3)) {
249 for (auto [pathMatrix, path, color] : *fPathDrawList) {
250 tess::AffineMatrix m(pathMatrix);
251 for (tess::PathMiddleOutFanIter it(path); !it.done();) {
252 for (auto [p0, p1, p2] : it.nextStack()) {
253 triangleVertexWriter << m.map2Points(p0, p1) << m.mapPoint(p2);
254 ++fanTriangleCount;
255 }
256 }
257 }
258
259
260 SkASSERT(fanTriangleCount <= maxTrianglesInFans);
261 fFanVertexCount = fanTriangleCount * 3;
262 vertexAlloc.unlock(fFanVertexCount);
263 }
264 }
265
266 auto tessShader = &fStencilPathProgram->geomProc().cast<GrPathTessellationShader>();
267 fTessellator->prepare(flushState,
268 tessShader->viewMatrix(),
269 *fPathDrawList,
270 fTotalCombinedPathVerbCnt);
271
272 if (fCoverBBoxProgram) {
273 size_t instanceStride = fCoverBBoxProgram->geomProc().instanceStride();
274 VertexWriter vertexWriter = flushState->makeVertexWriter(instanceStride,
275 fPathCount,
276 &fBBoxBuffer,
277 &fBBoxBaseInstance);
278 SkDEBUGCODE(int pathCount = 0;)
279 for (auto [pathMatrix, path, color] : *fPathDrawList) {
280 SkDEBUGCODE(auto end = vertexWriter.mark(instanceStride));
281 vertexWriter << pathMatrix.getScaleX()
282 << pathMatrix.getSkewY()
283 << pathMatrix.getSkewX()
284 << pathMatrix.getScaleY()
285 << pathMatrix.getTranslateX()
286 << pathMatrix.getTranslateY();
287 if (path.isInverseFillType()) {
288 // Fill the entire backing store to make sure we clear every stencil value back to
289 // 0. If there is a scissor it will have already clipped the stencil draw.
290 auto rtBounds =
292 SkASSERT(rtBounds == fOriginalDrawBounds);
293 SkRect pathSpaceRTBounds;
294 if (SkMatrixPriv::InverseMapRect(pathMatrix, &pathSpaceRTBounds, rtBounds)) {
295 vertexWriter << pathSpaceRTBounds;
296 } else {
297 vertexWriter << path.getBounds();
298 }
299 } else {
300 vertexWriter << path.getBounds();
301 }
302 SkASSERT(vertexWriter.mark() == end);
303 SkDEBUGCODE(++pathCount;)
304 }
305 SkASSERT(pathCount == fPathCount);
306 }
307
308 if (!flushState->caps().shaderCaps()->fVertexIDSupport) {
309 constexpr static SkPoint kUnitQuad[4] = {{0,0}, {0,1}, {1,0}, {1,1}};
310
311 SKGPU_DEFINE_STATIC_UNIQUE_KEY(gUnitQuadBufferKey);
312
313 fBBoxVertexBufferIfNoIDSupport = flushState->resourceProvider()->findOrMakeStaticBuffer(
314 GrGpuBufferType::kVertex, sizeof(kUnitQuad), kUnitQuad, gUnitQuadBufferKey);
315 }
316}
SkColor4f color
#define SKGPU_DEFINE_STATIC_UNIQUE_KEY(name)
const GrShaderCaps * shaderCaps() const
Definition GrCaps.h:63
size_t instanceStride() const
skgpu::VertexWriter makeVertexWriter(size_t vertexSize, int vertexCount, sk_sp< const GrBuffer > *, int *startVertex)
GrLoadOp colorLoadOp() const final
const GrDstProxyView & dstProxyView() const final
GrXferBarrierFlags renderPassBarriers() const final
SkArenaAlloc * allocator() override
const GrSurfaceProxyView & writeView() const final
GrResourceProvider * resourceProvider() const final
GrAppliedClip detachAppliedClip() final
const GrCaps & caps() const final
bool usesMSAASurface() const final
const T & cast() const
sk_sp< const GrGpuBuffer > findOrMakeStaticBuffer(GrGpuBufferType intendedType, size_t size, const skgpu::UniqueKey &key, InitializeBufferFn)
GrRenderTargetProxy * asRenderTargetProxy() const
SkRect backingStoreBoundsRect() const
static bool InverseMapRect(const SkMatrix &mx, SkRect *dst, const SkRect &src)
glong glong end
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57
bool fVertexIDSupport

◆ onPrePrepare()

void skgpu::ganesh::PathStencilCoverOp::onPrePrepare ( GrRecordingContext context,
const GrSurfaceProxyView writeView,
GrAppliedClip clip,
const GrDstProxyView dstProxyView,
GrXferBarrierFlags  renderPassXferBarriers,
GrLoadOp  colorLoadOp 
)
overrideprivatevirtual

Implements GrOp.

Definition at line 200 of file PathStencilCoverOp.cpp.

204 {
205 // DMSAA is not supported on DDL.
206 bool usesMSAASurface = writeView.asRenderTargetProxy()->numSamples() > 1;
207 this->prePreparePrograms({context->priv().recordTimeAllocator(), writeView, usesMSAASurface,
208 &dstProxyView, renderPassXferBarriers, colorLoadOp,
209 context->priv().caps()},
210 (clip) ? std::move(*clip) : GrAppliedClip::Disabled());
211 if (fStencilFanProgram) {
212 context->priv().recordProgramInfo(fStencilFanProgram);
213 }
214 if (fStencilPathProgram) {
215 context->priv().recordProgramInfo(fStencilPathProgram);
216 }
217 if (fCoverBBoxProgram) {
218 context->priv().recordProgramInfo(fCoverBBoxProgram);
219 }
220}
static GrAppliedClip Disabled()
const GrCaps * caps() const
void recordProgramInfo(const GrProgramInfo *programInfo)
GrRecordingContextPriv priv()

◆ visitProxies()

void skgpu::ganesh::PathStencilCoverOp::visitProxies ( const GrVisitProxyFunc func) const
overrideprivatevirtual

Reimplemented from GrOp.

Definition at line 109 of file PathStencilCoverOp.cpp.

109 {
110 if (fCoverBBoxProgram) {
111 fCoverBBoxProgram->pipeline().visitProxies(func);
112 } else {
113 fProcessors.visitProxies(func);
114 }
115}
void visitProxies(const GrVisitProxyFunc &) const
void visitProxies(const GrVisitProxyFunc &) const

Friends And Related Symbol Documentation

◆ GrOp

friend class GrOp
friend

Definition at line 115 of file PathStencilCoverOp.h.


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