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

#include <StrokeTessellateOp.h>

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

Public Member Functions

 StrokeTessellateOp (GrAAType, const SkMatrix &, const SkPath &, const SkStrokeRec &, GrPaint &&)
 
- Public Member Functions inherited from GrDrawOp
 GrDrawOp (uint32_t classID)
 
virtual ClipResult clipToShape (skgpu::ganesh::SurfaceDrawContext *, SkClipOp, const SkMatrix &, const GrShape &, GrAA)
 
- 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)
 

Private Member Functions

const char * name () const override
 
void visitProxies (const GrVisitProxyFunc &) const override
 
bool usesMSAA () const override
 
GrProcessorSet::Analysis finalize (const GrCaps &, const GrAppliedClip *, GrClampType) override
 
bool usesStencil () const override
 
CombineResult onCombineIfPossible (GrOp *, SkArenaAlloc *, const GrCaps &) override
 
void onPrePrepare (GrRecordingContext *, const GrSurfaceProxyView &, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags, GrLoadOp colorLoadOp) override
 
void onPrepare (GrOpFlushState *) override
 
void onExecute (GrOpFlushState *, const SkRect &chainBounds) override
 

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 >
 
- 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)
 
virtual FixedFunctionFlags fixedFunctionFlags () const
 

Detailed Description

Definition at line 23 of file StrokeTessellateOp.h.

Constructor & Destructor Documentation

◆ StrokeTessellateOp()

skgpu::ganesh::StrokeTessellateOp::StrokeTessellateOp ( GrAAType  aaType,
const SkMatrix viewMatrix,
const SkPath path,
const SkStrokeRec stroke,
GrPaint &&  paint 
)

Definition at line 20 of file StrokeTessellateOp.cpp.

23 : GrDrawOp(ClassID())
24 , fAAType(aaType)
25 , fViewMatrix(viewMatrix)
26 , fPathStrokeList(path, stroke, paint.getColor4f())
27 , fTotalCombinedVerbCnt(path.countVerbs())
28 , fProcessors(std::move(paint)) {
29 if (!this->headColor().fitsInBytes()) {
30 fPatchAttribs |= PatchAttribs::kWideColorIfEnabled;
31 }
32 SkRect devBounds = path.getBounds();
33 if (!this->headStroke().isHairlineStyle()) {
34 // Non-hairlines inflate in local path space (pre-transform).
35 float r = stroke.getInflationRadius();
36 devBounds.outset(r, r);
37 }
38 viewMatrix.mapRect(&devBounds, devBounds);
39 if (this->headStroke().isHairlineStyle()) {
40 // Hairlines inflate in device space (post-transform).
41 float r = SkStrokeRec::GetInflationRadius(stroke.getJoin(), stroke.getMiter(),
42 stroke.getCap(), 1);
43 devBounds.outset(r, r);
44 }
45 this->setBounds(devBounds, HasAABloat::kNo, IsHairline::kNo);
46}
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
Definition GrOp.h:279
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
static SkScalar GetInflationRadius(const SkPaint &, SkPaint::Style)
SkScalar getInflationRadius() const
SkPaint::Join getJoin() const
Definition SkStrokeRec.h:45
SkPaint::Cap getCap() const
Definition SkStrokeRec.h:44
SkScalar getMiter() const
Definition SkStrokeRec.h:43
const Paint & paint
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
void outset(float dx, float dy)
Definition SkRect.h:1077

Member Function Documentation

◆ finalize()

GrProcessorSet::Analysis skgpu::ganesh::StrokeTessellateOp::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 58 of file StrokeTessellateOp.cpp.

60 {
61 // Make sure the finalize happens before combining. We might change fNeedsStencil here.
62 SkASSERT(fPathStrokeList.fNext == nullptr);
63 if (!caps.shaderCaps()->fInfinitySupport) {
64 // The GPU can't infer curve type based in infinity, so we need to send in an attrib
65 // explicitly stating the curve type.
66 fPatchAttribs |= PatchAttribs::kExplicitCurveType;
67 }
68 const GrProcessorSet::Analysis& analysis = fProcessors.finalize(
69 this->headColor(), GrProcessorAnalysisCoverage::kNone, clip,
70 &GrUserStencilSettings::kUnused, caps, clampType, &this->headColor());
71 fNeedsStencil = !analysis.unaffectedByDstValue();
72 return analysis;
73}
#define SkASSERT(cond)
Definition SkAssert.h:116
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
bool unaffectedByDstValue() const
Analysis finalize(const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage, const GrAppliedClip *, const GrUserStencilSettings *, const GrCaps &, GrClampType, SkPMColor4f *inputColorOverride)
static const GrUserStencilSettings & kUnused

◆ name()

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

Implements GrOp.

Definition at line 48 of file StrokeTessellateOp.h.

48{ return "StrokeTessellateOp"; }

◆ onCombineIfPossible()

GrOp::CombineResult skgpu::ganesh::StrokeTessellateOp::onCombineIfPossible ( GrOp grOp,
SkArenaAlloc alloc,
const GrCaps caps 
)
overrideprivatevirtual

Reimplemented from GrOp.

Definition at line 75 of file StrokeTessellateOp.cpp.

76 {
77 SkASSERT(grOp->classID() == this->classID());
78 auto* op = static_cast<StrokeTessellateOp*>(grOp);
79
80 // This must be called after finalize(). fNeedsStencil can change in finalize().
81 SkASSERT(fProcessors.isFinalized());
82 SkASSERT(op->fProcessors.isFinalized());
83
84 if (fNeedsStencil ||
85 op->fNeedsStencil ||
86 fViewMatrix != op->fViewMatrix ||
87 fAAType != op->fAAType ||
88 fProcessors != op->fProcessors ||
89 this->headStroke().isHairlineStyle() != op->headStroke().isHairlineStyle()) {
91 }
92
93 auto combinedAttribs = fPatchAttribs | op->fPatchAttribs;
94 if (!(combinedAttribs & PatchAttribs::kStrokeParams) &&
95 !tess::StrokesHaveEqualParams(this->headStroke(), op->headStroke())) {
96 // The paths have different stroke properties. We will need to enable dynamic stroke if we
97 // still decide to combine them.
98 if (this->headStroke().isHairlineStyle()) {
99 return CombineResult::kCannotCombine; // Dynamic hairlines aren't supported.
100 }
101 combinedAttribs |= PatchAttribs::kStrokeParams;
102 }
103 if (!(combinedAttribs & PatchAttribs::kColor) && this->headColor() != op->headColor()) {
104 // The paths have different colors. We will need to enable dynamic color if we still decide
105 // to combine them.
106 combinedAttribs |= PatchAttribs::kColor;
107 }
108
109 // Don't actually enable new dynamic state on ops that already have lots of verbs.
110 constexpr static GrTFlagsMask<PatchAttribs> kDynamicStatesMask(PatchAttribs::kStrokeParams |
111 PatchAttribs::kColor);
112 PatchAttribs neededDynamicStates = combinedAttribs & kDynamicStatesMask;
113 if (neededDynamicStates != PatchAttribs::kNone) {
114 if (!this->shouldUseDynamicStates(neededDynamicStates) ||
115 !op->shouldUseDynamicStates(neededDynamicStates)) {
117 }
118 }
119
120 fPatchAttribs = combinedAttribs;
121
122 // Concat the op's PathStrokeList. Since the head element is allocated inside the op, we need to
123 // copy it.
124 auto* headCopy = alloc->make<PathStrokeList>(std::move(op->fPathStrokeList));
125 *fPathStrokeTail = headCopy;
126 fPathStrokeTail = (op->fPathStrokeTail == &op->fPathStrokeList.fNext) ? &headCopy->fNext
127 : op->fPathStrokeTail;
128
129 fTotalCombinedVerbCnt += op->fTotalCombinedVerbCnt;
131}
uint32_t classID() const
Definition GrOp.h:158
bool isFinalized() const
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
StrokeTessellateOp(GrAAType, const SkMatrix &, const SkPath &, const SkStrokeRec &, GrPaint &&)
bool StrokesHaveEqualParams(const SkStrokeRec &a, const SkStrokeRec &b)

◆ onExecute()

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

Implements GrOp.

Definition at line 228 of file StrokeTessellateOp.cpp.

228 {
229 if (fStencilProgram) {
230 flushState->bindPipelineAndScissorClip(*fStencilProgram, chainBounds);
231 flushState->bindTextures(fStencilProgram->geomProc(), nullptr, fStencilProgram->pipeline());
232 fTessellator->draw(flushState);
233 }
234 if (fFillProgram) {
235 flushState->bindPipelineAndScissorClip(*fFillProgram, chainBounds);
236 flushState->bindTextures(fFillProgram->geomProc(), nullptr, fFillProgram->pipeline());
237 fTessellator->draw(flushState);
238 }
239}
void bindPipelineAndScissorClip(const GrProgramInfo &programInfo, const SkRect &drawBounds)
void bindTextures(const GrGeometryProcessor &geomProc, const GrSurfaceProxy &singleGeomProcTexture, const GrPipeline &pipeline)
const GrPipeline & pipeline() const
const GrGeometryProcessor & geomProc() const
void draw(GrOpFlushState *) const

◆ onPrepare()

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

Implements GrOp.

Definition at line 214 of file StrokeTessellateOp.cpp.

214 {
215 if (!fTessellator) {
216 this->prePrepareTessellator({flushState->allocator(), flushState->writeView(),
217 flushState->usesMSAASurface(), &flushState->dstProxyView(),
218 flushState->renderPassBarriers(), flushState->colorLoadOp(),
219 &flushState->caps()}, flushState->detachAppliedClip());
220 }
221 SkASSERT(fTessellator);
222 fTessellator->prepare(flushState,
223 fViewMatrix,
224 &fPathStrokeList,
225 fTotalCombinedVerbCnt);
226}
GrLoadOp colorLoadOp() const final
const GrDstProxyView & dstProxyView() const final
GrXferBarrierFlags renderPassBarriers() const final
SkArenaAlloc * allocator() override
const GrSurfaceProxyView & writeView() const final
GrAppliedClip detachAppliedClip() final
const GrCaps & caps() const final
bool usesMSAASurface() const final
void prepare(GrMeshDrawTarget *, const SkMatrix &shaderMatrix, PathStrokeList *, int totalCombinedStrokeVerbCnt)

◆ onPrePrepare()

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

Implements GrOp.

Definition at line 195 of file StrokeTessellateOp.cpp.

199 {
200 // DMSAA is not supported on DDL.
201 bool usesMSAASurface = writeView.asRenderTargetProxy()->numSamples() > 1;
202 this->prePrepareTessellator({context->priv().recordTimeAllocator(), writeView, usesMSAASurface,
203 &dstProxyView, renderPassXferBarriers, colorLoadOp,
204 context->priv().caps()},
205 (clip) ? std::move(*clip) : GrAppliedClip::Disabled());
206 if (fStencilProgram) {
207 context->priv().recordProgramInfo(fStencilProgram);
208 }
209 if (fFillProgram) {
210 context->priv().recordProgramInfo(fFillProgram);
211 }
212}
static GrAppliedClip Disabled()
const GrCaps * caps() const
void recordProgramInfo(const GrProgramInfo *programInfo)
GrRecordingContextPriv priv()
GrRenderTargetProxy * asRenderTargetProxy() const

◆ usesMSAA()

bool skgpu::ganesh::StrokeTessellateOp::usesMSAA ( ) const
inlineoverrideprivatevirtual

Called before setting up the GrAppliedClip and before finalize. This information is required to determine how to compute a GrAppliedClip from a GrClip for this op.

Reimplemented from GrDrawOp.

Definition at line 50 of file StrokeTessellateOp.h.

50{ return fAAType == GrAAType::kMSAA; }

◆ usesStencil()

bool skgpu::ganesh::StrokeTessellateOp::usesStencil ( ) const
inlineoverrideprivatevirtual

Called after finalize, at which point every op should know whether it will need stencil.

Reimplemented from GrDrawOp.

Definition at line 52 of file StrokeTessellateOp.h.

52 {
53 // This must be called after finalize(). fNeedsStencil can change in finalize().
54 SkASSERT(fProcessors.isFinalized());
55 return fNeedsStencil;
56 }

◆ visitProxies()

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

Reimplemented from GrOp.

Definition at line 48 of file StrokeTessellateOp.cpp.

48 {
49 if (fFillProgram) {
50 fFillProgram->visitFPProxies(func);
51 } else if (fStencilProgram) {
52 fStencilProgram->visitFPProxies(func);
53 } else {
54 fProcessors.visitProxies(func);
55 }
56}
void visitProxies(const GrVisitProxyFunc &) const
void visitFPProxies(const GrVisitProxyFunc &func) const

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