Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PathTessellateOp.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google LLC.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef PathTessellateOp_DEFINED
9#define PathTessellateOp_DEFINED
10
15
16namespace skgpu::ganesh {
17
18// Tessellates a path directly to the color buffer, using one single render pass. This currently
19// only works for convex paths.
20class PathTessellateOp final : public GrDrawOp {
21private:
23
26
28 GrAAType aaType,
29 const GrUserStencilSettings* stencil,
30 const SkMatrix& viewMatrix,
31 const SkPath& path,
32 GrPaint&& paint,
33 const SkRect& drawBounds)
34 : GrDrawOp(ClassID())
35 , fAAType(aaType)
36 , fStencil(stencil)
37 , fTotalCombinedPathVerbCnt(path.countVerbs())
38 , fPathDrawList(arena->make<PathDrawList>(SkMatrix::I(), path, paint.getColor4f()))
39 , fPathDrawTail(&fPathDrawList->fNext)
40 , fProcessors(std::move(paint))
41 , fShaderMatrix(viewMatrix) {
42 SkASSERT(!path.isInverseFillType());
43 if (!this->headDraw().fColor.fitsInBytes()) {
44 fPatchAttribs |= PatchAttribs::kWideColorIfEnabled;
45 }
46 this->setBounds(drawBounds, HasAABloat::kNo, IsHairline::kNo);
47 }
48
49 PathDrawList& headDraw() { return *fPathDrawList; }
50
51 void prepareTessellator(const GrTessellationShader::ProgramArgs&, GrAppliedClip&& clip);
52
53 // GrDrawOp overrides.
54 const char* name() const override { return "PathTessellateOp"; }
55 bool usesMSAA() const override { return fAAType == GrAAType::kMSAA; }
56 void visitProxies(const GrVisitProxyFunc&) const override;
58 bool usesStencil() const override { return !fStencil->isUnused(); }
61 const GrDstProxyView&, GrXferBarrierFlags, GrLoadOp colorLoadOp) override;
62 void onPrepare(GrOpFlushState*) override;
63 void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
64
65 const GrAAType fAAType;
66 const GrUserStencilSettings* const fStencil;
67 int fTotalCombinedPathVerbCnt;
68 PatchAttribs fPatchAttribs = PatchAttribs::kNone;
69 PathDrawList* const fPathDrawList;
70 PathDrawList** fPathDrawTail;
71 GrProcessorSet fProcessors;
72 SkMatrix fShaderMatrix;
73
74 // Decided during prepareTessellator.
75 PathTessellator* fTessellator = nullptr;
76 const GrProgramInfo* fTessellationProgram = nullptr;
77
78 friend class GrOp; // For ctor.
79};
80
81} // namespace skgpu::ganesh
82
83#endif // PathTessellateOp_DEFINED
#define DEFINE_OP_CLASS_ID
Definition GrOp.h:64
GrClampType
std::function< void(GrSurfaceProxy *, skgpu::Mipmapped)> GrVisitProxyFunc
GrAAType
GrLoadOp
GrXferBarrierFlags
#define SkASSERT(cond)
Definition SkAssert.h:116
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
Definition GrOp.h:70
CombineResult
Definition GrOp.h:99
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
Definition GrOp.h:279
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
static const SkMatrix & I()
void onExecute(GrOpFlushState *, const SkRect &chainBounds) override
GrProcessorSet::Analysis finalize(const GrCaps &, const GrAppliedClip *, GrClampType) override
CombineResult onCombineIfPossible(GrOp *, SkArenaAlloc *, const GrCaps &) override
void visitProxies(const GrVisitProxyFunc &) const override
const char * name() const override
void onPrePrepare(GrRecordingContext *, const GrSurfaceProxyView &, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags, GrLoadOp colorLoadOp) override
bool usesStencil() const override
void onPrepare(GrOpFlushState *) override
const Paint & paint