Flutter Engine
The Flutter Engine
GrStrokeTessellationShader.h
Go to the documentation of this file.
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 GrStrokeTessellationShader_DEFINED
9#define GrStrokeTessellationShader_DEFINED
10
12
16
17// Tessellates a batch of stroke patches directly to the canvas. Tessellated stroking works by
18// creating stroke-width, orthogonal edges at set locations along the curve and then connecting them
19// with a quad strip. These orthogonal edges come from two different sets: "parametric edges" and
20// "radial edges". Parametric edges are spaced evenly in the parametric sense, and radial edges
21// divide the curve's _rotation_ into even steps. The tessellation shader evaluates both sets of
22// edges and sorts them into a single quad strip. With this combined set of edges we can stroke any
23// curve, regardless of curvature.
26
27public:
28
29 // 'viewMatrix' is applied to the geometry post tessellation. It cannot have perspective.
31 const SkStrokeRec&, SkPMColor4f);
32
33 PatchAttribs attribs() const { return fPatchAttribs; }
34 bool hasDynamicStroke() const { return fPatchAttribs & PatchAttribs::kStrokeParams; }
35 bool hasDynamicColor() const { return fPatchAttribs & PatchAttribs::kColor; }
36 bool hasExplicitCurveType() const { return fPatchAttribs & PatchAttribs::kExplicitCurveType; }
37 const SkStrokeRec& stroke() const { return fStroke;}
38
39private:
40 const char* name() const override { return "GrStrokeTessellationShader"; }
41 void addToKey(const GrShaderCaps&, skgpu::KeyBuilder*) const override;
42 std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const final;
43
44 const PatchAttribs fPatchAttribs;
45 const SkStrokeRec fStroke;
46
47 constexpr static int kMaxAttribCount = 6;
49
50 class Impl;
51};
52
53#endif
GrStrokeTessellationShader(const GrShaderCaps &, PatchAttribs, const SkMatrix &viewMatrix, const SkStrokeRec &, SkPMColor4f)
const SkStrokeRec & stroke() const
const SkMatrix & viewMatrix() const