| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrDefaultPathRenderer.h" | 8 #include "GrDefaultPathRenderer.h" |
| 9 | 9 |
| 10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 DefaultPathBatch(GrColor color, const SkPath& path, SkScalar tolerance, | 100 DefaultPathBatch(GrColor color, const SkPath& path, SkScalar tolerance, |
| 101 uint8_t coverage, const SkMatrix& viewMatrix, bool isHairli
ne, | 101 uint8_t coverage, const SkMatrix& viewMatrix, bool isHairli
ne, |
| 102 const SkRect& devBounds) | 102 const SkRect& devBounds) |
| 103 : INHERITED(ClassID()) { | 103 : INHERITED(ClassID()) { |
| 104 fBatch.fCoverage = coverage; | 104 fBatch.fCoverage = coverage; |
| 105 fBatch.fIsHairline = isHairline; | 105 fBatch.fIsHairline = isHairline; |
| 106 fBatch.fViewMatrix = viewMatrix; | 106 fBatch.fViewMatrix = viewMatrix; |
| 107 fGeoData.emplace_back(Geometry{color, path, tolerance}); | 107 fGeoData.emplace_back(Geometry{color, path, tolerance}); |
| 108 | 108 |
| 109 this->setBounds(devBounds); | 109 this->setBounds(devBounds, HasAABloat::kNo, |
| 110 | 110 isHairline ? IsZeroArea::kYes : IsZeroArea::kNo); |
| 111 // This is b.c. hairlines are notionally infinitely thin so without expa
nsion | |
| 112 // two overlapping lines could be reordered even though they hit the sam
e pixels. | |
| 113 if (isHairline) { | |
| 114 fBounds.outset(0.5f, 0.5f); | |
| 115 } | |
| 116 } | 111 } |
| 117 | 112 |
| 118 const char* name() const override { return "DefaultPathBatch"; } | 113 const char* name() const override { return "DefaultPathBatch"; } |
| 119 | 114 |
| 120 void computePipelineOptimizations(GrInitInvariantOutput* color, | 115 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 121 GrInitInvariantOutput* coverage, | 116 GrInitInvariantOutput* coverage, |
| 122 GrBatchToXPOverrides* overrides) const ove
rride { | 117 GrBatchToXPOverrides* overrides) const ove
rride { |
| 123 // When this is called on a batch, there is only one geometry bundle | 118 // When this is called on a batch, there is only one geometry bundle |
| 124 color->setKnownFourComponents(fGeoData[0].fColor); | 119 color->setKnownFourComponents(fGeoData[0].fColor); |
| 125 coverage->setKnownSingleComponent(this->coverage()); | 120 coverage->setKnownSingleComponent(this->coverage()); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 274 |
| 280 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { | 275 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { |
| 281 return false; | 276 return false; |
| 282 } | 277 } |
| 283 | 278 |
| 284 if (this->isHairline() != that->isHairline()) { | 279 if (this->isHairline() != that->isHairline()) { |
| 285 return false; | 280 return false; |
| 286 } | 281 } |
| 287 | 282 |
| 288 fGeoData.push_back_n(that->fGeoData.count(), that->fGeoData.begin()); | 283 fGeoData.push_back_n(that->fGeoData.count(), that->fGeoData.begin()); |
| 289 this->joinBounds(that->bounds()); | 284 this->joinBounds(*that); |
| 290 return true; | 285 return true; |
| 291 } | 286 } |
| 292 | 287 |
| 293 bool createGeom(void* vertices, | 288 bool createGeom(void* vertices, |
| 294 size_t vertexOffset, | 289 size_t vertexOffset, |
| 295 void* indices, | 290 void* indices, |
| 296 size_t indexOffset, | 291 size_t indexOffset, |
| 297 int* vertexCnt, | 292 int* vertexCnt, |
| 298 int* indexCnt, | 293 int* indexCnt, |
| 299 const SkPath& path, | 294 const SkPath& path, |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 SkRect bounds = path.getBounds(); | 635 SkRect bounds = path.getBounds(); |
| 641 SkScalar tol = GrPathUtils::kDefaultTolerance; | 636 SkScalar tol = GrPathUtils::kDefaultTolerance; |
| 642 SkScalar srcSpaceTol = GrPathUtils::scaleToleranceToSrc(tol, viewMatrix, bou
nds); | 637 SkScalar srcSpaceTol = GrPathUtils::scaleToleranceToSrc(tol, viewMatrix, bou
nds); |
| 643 | 638 |
| 644 viewMatrix.mapRect(&bounds); | 639 viewMatrix.mapRect(&bounds); |
| 645 uint8_t coverage = GrRandomCoverage(random); | 640 uint8_t coverage = GrRandomCoverage(random); |
| 646 return new DefaultPathBatch(color, path, srcSpaceTol, coverage, viewMatrix,
true, bounds); | 641 return new DefaultPathBatch(color, path, srcSpaceTol, coverage, viewMatrix,
true, bounds); |
| 647 } | 642 } |
| 648 | 643 |
| 649 #endif | 644 #endif |
| OLD | NEW |