| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 "GrAADistanceFieldPathRenderer.h" | 9 #include "GrAADistanceFieldPathRenderer.h" |
| 10 | 10 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 bool fAntiAlias; | 136 bool fAntiAlias; |
| 137 PathData* fPathData; | 137 PathData* fPathData; |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 static GrBatch* Create(const Geometry& geometry, GrColor color, const SkMatr
ix& viewMatrix, | 140 static GrBatch* Create(const Geometry& geometry, GrColor color, const SkMatr
ix& viewMatrix, |
| 141 GrBatchAtlas* atlas, PathCache* pathCache, PathDataLi
st* pathList) { | 141 GrBatchAtlas* atlas, PathCache* pathCache, PathDataLi
st* pathList) { |
| 142 return SkNEW_ARGS(AADistanceFieldPathBatch, (geometry, color, viewMatrix
, | 142 return SkNEW_ARGS(AADistanceFieldPathBatch, (geometry, color, viewMatrix
, |
| 143 atlas, pathCache, pathList)
); | 143 atlas, pathCache, pathList)
); |
| 144 } | 144 } |
| 145 | 145 |
| 146 const char* name() const SK_OVERRIDE { return "AADistanceFieldPathBatch"; } | 146 const char* name() const override { return "AADistanceFieldPathBatch"; } |
| 147 | 147 |
| 148 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { | 148 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 149 out->setKnownFourComponents(fBatch.fColor); | 149 out->setKnownFourComponents(fBatch.fColor); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID
E { | 152 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 153 out->setUnknownSingleComponent(); | 153 out->setUnknownSingleComponent(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { | 156 void initBatchTracker(const GrPipelineInfo& init) override { |
| 157 // Handle any color overrides | 157 // Handle any color overrides |
| 158 if (init.fColorIgnored) { | 158 if (init.fColorIgnored) { |
| 159 fBatch.fColor = GrColor_ILLEGAL; | 159 fBatch.fColor = GrColor_ILLEGAL; |
| 160 } else if (GrColor_ILLEGAL != init.fOverrideColor) { | 160 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
| 161 fBatch.fColor = init.fOverrideColor; | 161 fBatch.fColor = init.fOverrideColor; |
| 162 } | 162 } |
| 163 | 163 |
| 164 // setup batch properties | 164 // setup batch properties |
| 165 fBatch.fColorIgnored = init.fColorIgnored; | 165 fBatch.fColorIgnored = init.fColorIgnored; |
| 166 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; | 166 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
| 167 fBatch.fCoverageIgnored = init.fCoverageIgnored; | 167 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
| 168 } | 168 } |
| 169 | 169 |
| 170 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 170 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
| 171 int instanceCount = fGeoData.count(); | 171 int instanceCount = fGeoData.count(); |
| 172 | 172 |
| 173 SkMatrix invert; | 173 SkMatrix invert; |
| 174 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { | 174 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { |
| 175 SkDebugf("Could not invert viewmatrix\n"); | 175 SkDebugf("Could not invert viewmatrix\n"); |
| 176 return; | 176 return; |
| 177 } | 177 } |
| 178 | 178 |
| 179 uint32_t flags = 0; | 179 uint32_t flags = 0; |
| 180 flags |= this->viewMatrix().isSimilarity() ? kSimilarity_DistanceFieldEf
fectFlag : 0; | 180 flags |= this->viewMatrix().isSimilarity() ? kSimilarity_DistanceFieldEf
fectFlag : 0; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 530 |
| 531 drawInfo->setStartVertex(drawInfo->startVertex() + drawInfo->vertexC
ount()); | 531 drawInfo->setStartVertex(drawInfo->startVertex() + drawInfo->vertexC
ount()); |
| 532 instanceCount -= drawInfo->instanceCount(); | 532 instanceCount -= drawInfo->instanceCount(); |
| 533 } | 533 } |
| 534 } | 534 } |
| 535 | 535 |
| 536 GrColor color() const { return fBatch.fColor; } | 536 GrColor color() const { return fBatch.fColor; } |
| 537 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } | 537 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } |
| 538 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 538 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
| 539 | 539 |
| 540 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { | 540 bool onCombineIfPossible(GrBatch* t) override { |
| 541 AADistanceFieldPathBatch* that = t->cast<AADistanceFieldPathBatch>(); | 541 AADistanceFieldPathBatch* that = t->cast<AADistanceFieldPathBatch>(); |
| 542 | 542 |
| 543 // TODO we could actually probably do a bunch of this work on the CPU, i
e map viewMatrix, | 543 // TODO we could actually probably do a bunch of this work on the CPU, i
e map viewMatrix, |
| 544 // maybe upload color via attribute | 544 // maybe upload color via attribute |
| 545 if (this->color() != that->color()) { | 545 if (this->color() != that->color()) { |
| 546 return false; | 546 return false; |
| 547 } | 547 } |
| 548 | 548 |
| 549 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { | 549 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { |
| 550 return false; | 550 return false; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 SkAutoTUnref<GrBatch> batch(AADistanceFieldPathBatch::Create(geometry, color
, viewMatrix, | 611 SkAutoTUnref<GrBatch> batch(AADistanceFieldPathBatch::Create(geometry, color
, viewMatrix, |
| 612 fAtlas, &fPathC
ache, &fPathList)); | 612 fAtlas, &fPathC
ache, &fPathList)); |
| 613 | 613 |
| 614 SkRect bounds = path.getBounds(); | 614 SkRect bounds = path.getBounds(); |
| 615 viewMatrix.mapRect(&bounds); | 615 viewMatrix.mapRect(&bounds); |
| 616 target->drawBatch(pipelineBuilder, batch, &bounds); | 616 target->drawBatch(pipelineBuilder, batch, &bounds); |
| 617 | 617 |
| 618 return true; | 618 return true; |
| 619 } | 619 } |
| 620 | 620 |
| OLD | NEW |