OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrTessellatingPathRenderer.h" | 8 #include "GrTessellatingPathRenderer.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
11 #include "GrBatchTest.h" | 11 #include "GrBatchTest.h" |
12 #include "GrDefaultGeoProcFactory.h" | 12 #include "GrDefaultGeoProcFactory.h" |
13 #include "GrMesh.h" | 13 #include "GrMesh.h" |
14 #include "GrPathUtils.h" | 14 #include "GrPathUtils.h" |
15 #include "GrResourceCache.h" | 15 #include "GrResourceCache.h" |
16 #include "GrResourceProvider.h" | 16 #include "GrResourceProvider.h" |
17 #include "GrTessellator.h" | 17 #include "GrTessellator.h" |
18 #include "SkGeometry.h" | 18 #include "SkGeometry.h" |
19 | 19 |
20 #include "batches/GrVertexBatch.h" | 20 #include "batches/GrVertexBatch.h" |
21 | 21 |
22 #include <stdio.h> | 22 #include <stdio.h> |
23 | 23 |
24 /* | 24 /* |
25 * This path renderer tessellates the path into triangles using GrTessellator, u
ploads the triangles | 25 * This path renderer tessellates the path into triangles using GrTessellator, u
ploads the triangles |
26 * to a vertex buffer, and renders them with a single draw call. It does not cur
rently do | 26 * to a vertex buffer, and renders them with a single draw call. It does not cur
rently do |
27 * antialiasing, so it must be used in conjunction with multisampling. | 27 * antialiasing, so it must be used in conjunction with multisampling. |
28 */ | 28 */ |
29 namespace { | 29 namespace { |
30 | 30 |
31 struct TessInfo { | 31 struct TessInfo { |
32 SkScalar fTolerance; | 32 SkScalar fTolerance; |
33 int fCount; | 33 int fCount; |
34 }; | 34 }; |
35 | 35 |
36 // When the SkPathRef genID changes, invalidate a corresponding GrResource descr
ibed by key. | 36 // When the SkPathRef genID changes, invalidate a corresponding GrResource descr
ibed by key. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 static GrDrawBatch* Create(const GrColor& color, | 117 static GrDrawBatch* Create(const GrColor& color, |
118 const SkPath& path, | 118 const SkPath& path, |
119 const GrStrokeInfo& stroke, | 119 const GrStrokeInfo& stroke, |
120 const SkMatrix& viewMatrix, | 120 const SkMatrix& viewMatrix, |
121 SkRect clipBounds) { | 121 SkRect clipBounds) { |
122 return new TessellatingPathBatch(color, path, stroke, viewMatrix, clipBo
unds); | 122 return new TessellatingPathBatch(color, path, stroke, viewMatrix, clipBo
unds); |
123 } | 123 } |
124 | 124 |
125 const char* name() const override { return "TessellatingPathBatch"; } | 125 const char* name() const override { return "TessellatingPathBatch"; } |
126 | 126 |
127 void computePipelineOptimizations(GrInitInvariantOutput* color, | 127 void computePipelineOptimizations(GrInitInvariantOutput* color, |
128 GrInitInvariantOutput* coverage, | 128 GrInitInvariantOutput* coverage, |
129 GrBatchToXPOverrides* overrides) const ove
rride { | 129 GrBatchToXPOverrides* overrides) const ove
rride { |
130 color->setKnownFourComponents(fColor); | 130 color->setKnownFourComponents(fColor); |
131 coverage->setUnknownSingleComponent(); | 131 coverage->setUnknownSingleComponent(); |
132 } | 132 } |
133 | 133 |
134 private: | 134 private: |
135 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 135 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
136 // Handle any color overrides | 136 // Handle any color overrides |
137 if (!overrides.readsColor()) { | 137 if (!overrides.readsColor()) { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 bool result = viewMatrix.invert(&vmi); | 321 bool result = viewMatrix.invert(&vmi); |
322 if (!result) { | 322 if (!result) { |
323 SkFAIL("Cannot invert matrix\n"); | 323 SkFAIL("Cannot invert matrix\n"); |
324 } | 324 } |
325 vmi.mapRect(&clipBounds); | 325 vmi.mapRect(&clipBounds); |
326 GrStrokeInfo strokeInfo = GrTest::TestStrokeInfo(random); | 326 GrStrokeInfo strokeInfo = GrTest::TestStrokeInfo(random); |
327 return TessellatingPathBatch::Create(color, path, strokeInfo, viewMatrix, cl
ipBounds); | 327 return TessellatingPathBatch::Create(color, path, strokeInfo, viewMatrix, cl
ipBounds); |
328 } | 328 } |
329 | 329 |
330 #endif | 330 #endif |
OLD | NEW |