Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrAARectRenderer.h" | 8 #include "GrAARectRenderer.h" |
| 9 #include "GrBatch.h" | 9 #include "GrBatch.h" |
| 10 #include "GrBatchTarget.h" | 10 #include "GrBatchTarget.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 182 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 183 | 183 |
| 184 private: | 184 private: |
| 185 AAFillRectBatch(const Geometry& geometry, const GrIndexBuffer* indexBuffer) | 185 AAFillRectBatch(const Geometry& geometry, const GrIndexBuffer* indexBuffer) |
| 186 : fIndexBuffer(indexBuffer) { | 186 : fIndexBuffer(indexBuffer) { |
| 187 this->initClassID<AAFillRectBatch>(); | 187 this->initClassID<AAFillRectBatch>(); |
| 188 fGeoData.push_back(geometry); | 188 fGeoData.push_back(geometry); |
| 189 | |
| 190 this->setBounds(geometry.fDevRect); | |
| 189 } | 191 } |
| 190 | 192 |
| 191 GrColor color() const { return fBatch.fColor; } | 193 GrColor color() const { return fBatch.fColor; } |
| 192 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 194 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
| 193 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; } | 195 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; } |
| 194 bool colorIgnored() const { return fBatch.fColorIgnored; } | 196 bool colorIgnored() const { return fBatch.fColorIgnored; } |
| 195 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 197 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
| 196 | 198 |
| 197 bool onCombineIfPossible(GrBatch* t) override { | 199 bool onCombineIfPossible(GrBatch* t) override { |
| 198 AAFillRectBatch* that = t->cast<AAFillRectBatch>(); | 200 AAFillRectBatch* that = t->cast<AAFillRectBatch>(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 209 fBatch.fColor = GrColor_ILLEGAL; | 211 fBatch.fColor = GrColor_ILLEGAL; |
| 210 } | 212 } |
| 211 | 213 |
| 212 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to | 214 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to |
| 213 // not tweaking | 215 // not tweaking |
| 214 if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage() ) { | 216 if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage() ) { |
| 215 fBatch.fCanTweakAlphaForCoverage = false; | 217 fBatch.fCanTweakAlphaForCoverage = false; |
| 216 } | 218 } |
| 217 | 219 |
| 218 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()) ; | 220 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()) ; |
| 221 this->joinBounds(that->bounds()); | |
| 219 return true; | 222 return true; |
| 220 } | 223 } |
| 221 | 224 |
| 222 void generateAAFillRectGeometry(void* vertices, | 225 void generateAAFillRectGeometry(void* vertices, |
| 223 size_t offset, | 226 size_t offset, |
| 224 size_t vertexStride, | 227 size_t vertexStride, |
| 225 GrColor color, | 228 GrColor color, |
| 226 const SkMatrix& viewMatrix, | 229 const SkMatrix& viewMatrix, |
| 227 const SkRect& rect, | 230 const SkRect& rect, |
| 228 const SkRect& devRect, | 231 const SkRect& devRect, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 return; | 472 return; |
| 470 } | 473 } |
| 471 | 474 |
| 472 AAFillRectBatch::Geometry geometry; | 475 AAFillRectBatch::Geometry geometry; |
| 473 geometry.fRect = rect; | 476 geometry.fRect = rect; |
| 474 geometry.fViewMatrix = viewMatrix; | 477 geometry.fViewMatrix = viewMatrix; |
| 475 geometry.fDevRect = devRect; | 478 geometry.fDevRect = devRect; |
| 476 geometry.fColor = color; | 479 geometry.fColor = color; |
| 477 | 480 |
| 478 SkAutoTUnref<GrBatch> batch(AAFillRectBatch::Create(geometry, fAAFillRectInd exBuffer)); | 481 SkAutoTUnref<GrBatch> batch(AAFillRectBatch::Create(geometry, fAAFillRectInd exBuffer)); |
| 479 target->drawBatch(pipelineBuilder, batch, &devRect); | 482 target->drawBatch(pipelineBuilder, batch); |
| 480 } | 483 } |
| 481 | 484 |
| 482 void GrAARectRenderer::strokeAARect(GrDrawTarget* target, | 485 void GrAARectRenderer::strokeAARect(GrDrawTarget* target, |
| 483 GrPipelineBuilder* pipelineBuilder, | 486 GrPipelineBuilder* pipelineBuilder, |
| 484 GrColor color, | 487 GrColor color, |
| 485 const SkMatrix& viewMatrix, | 488 const SkMatrix& viewMatrix, |
| 486 const SkRect& rect, | 489 const SkRect& rect, |
| 487 const SkRect& devRect, | 490 const SkRect& devRect, |
| 488 const SkStrokeRec& stroke) { | 491 const SkStrokeRec& stroke) { |
| 489 SkVector devStrokeSize; | 492 SkVector devStrokeSize; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 | 689 |
| 687 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 690 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 688 | 691 |
| 689 private: | 692 private: |
| 690 AAStrokeRectBatch(const Geometry& geometry, const SkMatrix& viewMatrix, | 693 AAStrokeRectBatch(const Geometry& geometry, const SkMatrix& viewMatrix, |
| 691 const GrIndexBuffer* indexBuffer) | 694 const GrIndexBuffer* indexBuffer) |
| 692 : fIndexBuffer(indexBuffer) { | 695 : fIndexBuffer(indexBuffer) { |
| 693 this->initClassID<AAStrokeRectBatch>(); | 696 this->initClassID<AAStrokeRectBatch>(); |
| 694 fBatch.fViewMatrix = viewMatrix; | 697 fBatch.fViewMatrix = viewMatrix; |
| 695 fGeoData.push_back(geometry); | 698 fGeoData.push_back(geometry); |
| 699 | |
|
robertphillips
2015/05/01 13:02:59
fDevOutsideAssist joined with fDevOutside ?
| |
| 700 // TODO tighter bounds | |
| 701 this->setBoundsLargest(); | |
| 696 } | 702 } |
| 697 | 703 |
| 698 GrColor color() const { return fBatch.fColor; } | 704 GrColor color() const { return fBatch.fColor; } |
| 699 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 705 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
| 700 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; } | 706 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; } |
| 701 bool colorIgnored() const { return fBatch.fColorIgnored; } | 707 bool colorIgnored() const { return fBatch.fColorIgnored; } |
| 702 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } | 708 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } |
| 703 bool miterStroke() const { return fBatch.fMiterStroke; } | 709 bool miterStroke() const { return fBatch.fMiterStroke; } |
| 704 | 710 |
| 705 bool onCombineIfPossible(GrBatch* t) override { | 711 bool onCombineIfPossible(GrBatch* t) override { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 720 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to | 726 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to |
| 721 // not tweaking | 727 // not tweaking |
| 722 if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage() ) { | 728 if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage() ) { |
| 723 fBatch.fCanTweakAlphaForCoverage = false; | 729 fBatch.fCanTweakAlphaForCoverage = false; |
| 724 } | 730 } |
| 725 | 731 |
| 726 if (this->color() != that->color()) { | 732 if (this->color() != that->color()) { |
| 727 fBatch.fColor = GrColor_ILLEGAL; | 733 fBatch.fColor = GrColor_ILLEGAL; |
| 728 } | 734 } |
| 729 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()) ; | 735 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()) ; |
| 736 this->joinBounds(that->bounds()); | |
| 730 return true; | 737 return true; |
| 731 } | 738 } |
| 732 | 739 |
| 733 void generateAAStrokeRectGeometry(void* vertices, | 740 void generateAAStrokeRectGeometry(void* vertices, |
| 734 size_t offset, | 741 size_t offset, |
| 735 size_t vertexStride, | 742 size_t vertexStride, |
| 736 int outerVertexNum, | 743 int outerVertexNum, |
| 737 int innerVertexNum, | 744 int innerVertexNum, |
| 738 GrColor color, | 745 GrColor color, |
| 739 const SkRect& devOutside, | 746 const SkRect& devOutside, |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 955 geo.fColor = GrRandomColor(random); | 962 geo.fColor = GrRandomColor(random); |
| 956 geo.fDevOutside = outside; | 963 geo.fDevOutside = outside; |
| 957 geo.fDevOutsideAssist = outsideAssist; | 964 geo.fDevOutsideAssist = outsideAssist; |
| 958 geo.fDevInside = inside; | 965 geo.fDevInside = inside; |
| 959 geo.fMiterStroke = miterStroke; | 966 geo.fMiterStroke = miterStroke; |
| 960 | 967 |
| 961 return AAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random), indexBuffe r); | 968 return AAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random), indexBuffe r); |
| 962 } | 969 } |
| 963 | 970 |
| 964 #endif | 971 #endif |
| OLD | NEW |