Flutter Engine
The Flutter Engine
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;
57 GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip*, GrClampType) override;
58 bool usesStencil() const override { return !fStencil->isUnused(); }
59 CombineResult onCombineIfPossible(GrOp*, SkArenaAlloc*, const GrCaps&) override;
60 void onPrePrepare(GrRecordingContext*, const GrSurfaceProxyView&, GrAppliedClip*,
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
Definition: GrTypesPriv.h:228
std::function< void(GrSurfaceProxy *, skgpu::Mipmapped)> GrVisitProxyFunc
Definition: GrTypesPriv.h:943
GrAAType
Definition: GrTypesPriv.h:200
GrLoadOp
Definition: GrTypesPriv.h:155
GrXferBarrierFlags
#define SkASSERT(cond)
Definition: SkAssert.h:116
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
Definition: GrCaps.h:57
GrDrawOp(uint32_t classID)
Definition: GrDrawOp.h:31
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))
Definition: SkArenaAlloc.h:120
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
Definition: SkPath.h:59
tess::PatchAttribs PatchAttribs
const Paint & paint
Definition: color_source.cc:38
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