| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 GrColor color() const { return fBatch.fColor; } | 170 GrColor color() const { return fBatch.fColor; } |
| 171 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 171 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
| 172 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover
age; } | 172 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover
age; } |
| 173 bool colorIgnored() const { return fBatch.fColorIgnored; } | 173 bool colorIgnored() const { return fBatch.fColorIgnored; } |
| 174 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 174 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
| 175 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } | 175 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } |
| 176 | 176 |
| 177 bool onCombineIfPossible(GrBatch* t) override { | 177 bool onCombineIfPossible(GrBatch* t) override { |
| 178 if (!this->pipeline()->isEqual(*t->pipeline())) { |
| 179 return false; |
| 180 } |
| 181 |
| 178 AAFillRectBatch* that = t->cast<AAFillRectBatch>(); | 182 AAFillRectBatch* that = t->cast<AAFillRectBatch>(); |
| 179 | 183 |
| 180 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 184 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
| 181 // We apply the viewmatrix to the rect points on the cpu. However, if t
he pipeline uses | 185 // We apply the viewmatrix to the rect points on the cpu. However, if t
he pipeline uses |
| 182 // local coords then we won't be able to batch. We could actually uploa
d the viewmatrix | 186 // local coords then we won't be able to batch. We could actually uploa
d the viewmatrix |
| 183 // using vertex attributes in these cases, but haven't investigated that | 187 // using vertex attributes in these cases, but haven't investigated that |
| 184 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { | 188 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { |
| 185 return false; | 189 return false; |
| 186 } | 190 } |
| 187 | 191 |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 | 614 |
| 611 GrColor color() const { return fBatch.fColor; } | 615 GrColor color() const { return fBatch.fColor; } |
| 612 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 616 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
| 613 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover
age; } | 617 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover
age; } |
| 614 bool colorIgnored() const { return fBatch.fColorIgnored; } | 618 bool colorIgnored() const { return fBatch.fColorIgnored; } |
| 615 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } | 619 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } |
| 616 bool miterStroke() const { return fBatch.fMiterStroke; } | 620 bool miterStroke() const { return fBatch.fMiterStroke; } |
| 617 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } | 621 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } |
| 618 | 622 |
| 619 bool onCombineIfPossible(GrBatch* t) override { | 623 bool onCombineIfPossible(GrBatch* t) override { |
| 624 if (!this->pipeline()->isEqual(*t->pipeline())) { |
| 625 return false; |
| 626 } |
| 627 |
| 620 AAStrokeRectBatch* that = t->cast<AAStrokeRectBatch>(); | 628 AAStrokeRectBatch* that = t->cast<AAStrokeRectBatch>(); |
| 621 | 629 |
| 622 // TODO batch across miterstroke changes | 630 // TODO batch across miterstroke changes |
| 623 if (this->miterStroke() != that->miterStroke()) { | 631 if (this->miterStroke() != that->miterStroke()) { |
| 624 return false; | 632 return false; |
| 625 } | 633 } |
| 626 | 634 |
| 627 // We apply the viewmatrix to the rect points on the cpu. However, if t
he pipeline uses | 635 // We apply the viewmatrix to the rect points on the cpu. However, if t
he pipeline uses |
| 628 // local coords then we won't be able to batch. We could actually uploa
d the viewmatrix | 636 // local coords then we won't be able to batch. We could actually uploa
d the viewmatrix |
| 629 // using vertex attributes in these cases, but haven't investigated that | 637 // using vertex attributes in these cases, but haven't investigated that |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 geo.fColor = GrRandomColor(random); | 849 geo.fColor = GrRandomColor(random); |
| 842 geo.fDevOutside = outside; | 850 geo.fDevOutside = outside; |
| 843 geo.fDevOutsideAssist = outsideAssist; | 851 geo.fDevOutsideAssist = outsideAssist; |
| 844 geo.fDevInside = inside; | 852 geo.fDevInside = inside; |
| 845 geo.fMiterStroke = miterStroke; | 853 geo.fMiterStroke = miterStroke; |
| 846 | 854 |
| 847 return AAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random)); | 855 return AAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random)); |
| 848 } | 856 } |
| 849 | 857 |
| 850 #endif | 858 #endif |
| OLD | NEW |