Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / gpu / ganesh / ops / PathTessellateOp.h
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
11 #include "src/gpu/ganesh/ops/GrDrawOp.h"
12 #include "src/gpu/ganesh/tessellate/GrTessellationShader.h"
13 #include "src/gpu/ganesh/tessellate/PathTessellator.h"
14 #include "src/gpu/tessellate/Tessellation.h"
15
16 namespace skgpu::v1 {
17
18 // Tessellates a path directly to the color buffer, using one single render pass. This currently
19 // only works for convex paths.
20 class PathTessellateOp final : public GrDrawOp {
21 private:
22     DEFINE_OP_CLASS_ID
23
24     using PatchAttribs = PathTessellator::PatchAttribs;
25     using PathDrawList = PathTessellator::PathDrawList;
26
27     PathTessellateOp(SkArenaAlloc* arena,
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::v1
82
83 #endif // PathTessellateOp_DEFINED