OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrAALinearizingConvexPathRenderer.h" | 9 #include "GrAALinearizingConvexPathRenderer.h" |
10 | 10 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 sk_free(indices); | 257 sk_free(indices); |
258 } | 258 } |
259 | 259 |
260 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 260 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
261 | 261 |
262 AAFlatteningConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID())
{ | 262 AAFlatteningConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID())
{ |
263 fGeoData.push_back(geometry); | 263 fGeoData.push_back(geometry); |
264 | 264 |
265 // compute bounds | 265 // compute bounds |
266 fBounds = geometry.fPath.getBounds(); | 266 fBounds = geometry.fPath.getBounds(); |
| 267 SkScalar w = geometry.fStrokeWidth; |
| 268 if (w > 0) { |
| 269 w /= 2; |
| 270 // If the miter limit is < 1 then we effectively fallback to bevel j
oins. |
| 271 if (SkPaint::kMiter_Join == geometry.fJoin && w > 1.f) { |
| 272 w *= geometry.fMiterLimit; |
| 273 } |
| 274 fBounds.outset(w, w); |
| 275 } |
267 geometry.fViewMatrix.mapRect(&fBounds); | 276 geometry.fViewMatrix.mapRect(&fBounds); |
268 } | 277 } |
269 | 278 |
270 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 279 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
271 AAFlatteningConvexPathBatch* that = t->cast<AAFlatteningConvexPathBatch>
(); | 280 AAFlatteningConvexPathBatch* that = t->cast<AAFlatteningConvexPathBatch>
(); |
272 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), | 281 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
273 that->bounds(), caps)) { | 282 that->bounds(), caps)) { |
274 return false; | 283 return false; |
275 } | 284 } |
276 | 285 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { | 347 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { |
339 AAFlatteningConvexPathBatch::Geometry geometry; | 348 AAFlatteningConvexPathBatch::Geometry geometry; |
340 geometry.fColor = GrRandomColor(random); | 349 geometry.fColor = GrRandomColor(random); |
341 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 350 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
342 geometry.fPath = GrTest::TestPathConvex(random); | 351 geometry.fPath = GrTest::TestPathConvex(random); |
343 | 352 |
344 return AAFlatteningConvexPathBatch::Create(geometry); | 353 return AAFlatteningConvexPathBatch::Create(geometry); |
345 } | 354 } |
346 | 355 |
347 #endif | 356 #endif |
OLD | NEW |