• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 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 tessellate_StrokeHardwareTessellator_DEFINED
9 #define tessellate_StrokeHardwareTessellator_DEFINED
10 
11 #include "src/gpu/tessellate/StrokeTessellator.h"
12 
13 namespace skgpu {
14 
15 // Renders opaque, constant-color strokes by decomposing them into standalone tessellation patches.
16 // Each patch is either a "cubic" (single stroked bezier curve with butt caps) or a "join". Requires
17 // MSAA if antialiasing is desired.
18 class StrokeHardwareTessellator final : public StrokeTessellator {
19 public:
StrokeHardwareTessellator(PatchAttribs attribs,int maxTessellationSegments)20     StrokeHardwareTessellator(PatchAttribs attribs, int maxTessellationSegments)
21             : StrokeTessellator(attribs), fMaxTessellationSegments(maxTessellationSegments) {}
22 
23     int patchPreallocCount(int totalCombinedStrokeVerbCnt) const final;
24 
25     int writePatches(PatchWriter&,
26                      const SkMatrix& shaderMatrix,
27                      std::array<float,2> matrixMinMaxScales,
28                      PathStrokeList*) final;
29 
30 #if SK_GPU_V1
31     int prepare(GrMeshDrawTarget*,
32                 const SkMatrix& shaderMatrix,
33                 std::array<float,2> matrixMinMaxScales,
34                 PathStrokeList*,
35                 int totalCombinedStrokeVerbCnt) final;
36 
37     void draw(GrOpFlushState*) const final;
38 #endif
39 
40 private:
41     const int fMaxTessellationSegments;
42 };
43 
44 }  // namespace skgpu
45 
46 #endif  // tessellate_StrokeHardwareTessellator_DEFINED
47