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 "GrAALinearizingConvexPathRenderer.h" | 8 #include "GrAALinearizingConvexPathRenderer.h" |
9 | 9 |
10 #include "GrAAConvexTessellator.h" | 10 #include "GrAAConvexTessellator.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 | 124 |
125 AAFlatteningConvexPathBatch(GrColor color, | 125 AAFlatteningConvexPathBatch(GrColor color, |
126 const SkMatrix& viewMatrix, | 126 const SkMatrix& viewMatrix, |
127 const SkPath& path, | 127 const SkPath& path, |
128 SkScalar strokeWidth, | 128 SkScalar strokeWidth, |
129 SkPaint::Join join, | 129 SkPaint::Join join, |
130 SkScalar miterLimit) : INHERITED(ClassID()) { | 130 SkScalar miterLimit) : INHERITED(ClassID()) { |
131 fGeoData.emplace_back(Geometry{color, viewMatrix, path, strokeWidth, joi n, miterLimit}); | 131 fGeoData.emplace_back(Geometry{color, viewMatrix, path, strokeWidth, joi n, miterLimit}); |
132 | 132 |
133 // compute bounds | 133 // compute bounds |
134 fBounds = path.getBounds(); | 134 SkRect bounds = path.getBounds(); |
135 SkScalar w = strokeWidth; | 135 SkScalar w = strokeWidth; |
136 if (w > 0) { | 136 if (w > 0) { |
137 w /= 2; | 137 w /= 2; |
138 // If the half stroke width is < 1 then we effectively fallback to b evel joins. | 138 // If the half stroke width is < 1 then we effectively fallback to b evel joins. |
139 if (SkPaint::kMiter_Join == join && w > 1.f) { | 139 if (SkPaint::kMiter_Join == join && w > 1.f) { |
140 w *= miterLimit; | 140 w *= miterLimit; |
141 } | 141 } |
142 fBounds.outset(w, w); | 142 bounds.outset(w, w); |
143 } | 143 } |
robertphillips
2016/07/07 20:26:42
Why no AABloat here ?
bsalomon
2016/07/07 23:40:57
Done.
| |
144 viewMatrix.mapRect(&fBounds); | 144 this->setTransformedBounds(bounds, viewMatrix, HasAABloat::kNo, IsZeroAr ea::kNo); |
145 } | 145 } |
146 | 146 |
147 const char* name() const override { return "AAConvexBatch"; } | 147 const char* name() const override { return "AAConvexBatch"; } |
148 | 148 |
149 void computePipelineOptimizations(GrInitInvariantOutput* color, | 149 void computePipelineOptimizations(GrInitInvariantOutput* color, |
150 GrInitInvariantOutput* coverage, | 150 GrInitInvariantOutput* coverage, |
151 GrBatchToXPOverrides* overrides) const ove rride { | 151 GrBatchToXPOverrides* overrides) const ove rride { |
152 // When this is called on a batch, there is only one geometry bundle | 152 // When this is called on a batch, there is only one geometry bundle |
153 color->setKnownFourComponents(fGeoData[0].fColor); | 153 color->setKnownFourComponents(fGeoData[0].fColor); |
154 coverage->setUnknownSingleComponent(); | 154 coverage->setUnknownSingleComponent(); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 return false; | 277 return false; |
278 } | 278 } |
279 | 279 |
280 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to | 280 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to |
281 // not tweaking | 281 // not tweaking |
282 if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage() ) { | 282 if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage() ) { |
283 fBatch.fCanTweakAlphaForCoverage = false; | 283 fBatch.fCanTweakAlphaForCoverage = false; |
284 } | 284 } |
285 | 285 |
286 fGeoData.push_back_n(that->fGeoData.count(), that->fGeoData.begin()); | 286 fGeoData.push_back_n(that->fGeoData.count(), that->fGeoData.begin()); |
287 this->joinBounds(that->bounds()); | 287 this->joinBounds(*that); |
288 return true; | 288 return true; |
289 } | 289 } |
290 | 290 |
291 GrColor color() const { return fBatch.fColor; } | 291 GrColor color() const { return fBatch.fColor; } |
292 bool linesOnly() const { return fBatch.fLinesOnly; } | 292 bool linesOnly() const { return fBatch.fLinesOnly; } |
293 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 293 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
294 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; } | 294 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; } |
295 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 295 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
296 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } | 296 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } |
297 | 297 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 GrColor color = GrRandomColor(random); | 354 GrColor color = GrRandomColor(random); |
355 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 355 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
356 SkPath path = GrTest::TestPathConvex(random); | 356 SkPath path = GrTest::TestPathConvex(random); |
357 SkScalar strokeWidth = random->nextBool() ? -1.f : 2.f; | 357 SkScalar strokeWidth = random->nextBool() ? -1.f : 2.f; |
358 SkPaint::Join join = SkPaint::kMiter_Join; | 358 SkPaint::Join join = SkPaint::kMiter_Join; |
359 SkScalar miterLimit = 0.5f; | 359 SkScalar miterLimit = 0.5f; |
360 return new AAFlatteningConvexPathBatch(color, viewMatrix, path, strokeWidth, join, miterLimit); | 360 return new AAFlatteningConvexPathBatch(color, viewMatrix, path, strokeWidth, join, miterLimit); |
361 } | 361 } |
362 | 362 |
363 #endif | 363 #endif |
OLD | NEW |