OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrBWFillRectBatch.h" | 8 #include "GrBWFillRectBatch.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 38 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
39 // When this is called on a batch, there is only one geometry bundle | 39 // When this is called on a batch, there is only one geometry bundle |
40 out->setKnownFourComponents(fGeoData[0].fColor); | 40 out->setKnownFourComponents(fGeoData[0].fColor); |
41 } | 41 } |
42 | 42 |
43 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 43 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
44 out->setKnownSingleComponent(0xff); | 44 out->setKnownSingleComponent(0xff); |
45 } | 45 } |
46 | 46 |
| 47 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 48 |
| 49 private: |
| 50 BWFillRectBatch(const Geometry& geometry) { |
| 51 this->initClassID<BWFillRectBatch>(); |
| 52 fGeoData.push_back(geometry); |
| 53 |
| 54 fBounds = geometry.fRect; |
| 55 geometry.fViewMatrix.mapRect(&fBounds); |
| 56 } |
| 57 |
| 58 GrColor color() const { return fBatch.fColor; } |
| 59 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
| 60 bool colorIgnored() const { return fBatch.fColorIgnored; } |
| 61 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
| 62 const SkMatrix& localMatrix() const { return fGeoData[0].fLocalMatrix; } |
| 63 bool hasLocalRect() const { return fGeoData[0].fHasLocalRect; } |
| 64 bool hasLocalMatrix() const { return fGeoData[0].fHasLocalMatrix; } |
| 65 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } |
| 66 |
47 void initBatchTracker(const GrPipelineOptimizations& init) override { | 67 void initBatchTracker(const GrPipelineOptimizations& init) override { |
48 // Handle any color overrides | 68 // Handle any color overrides |
49 if (!init.readsColor()) { | 69 if (!init.readsColor()) { |
50 fGeoData[0].fColor = GrColor_ILLEGAL; | 70 fGeoData[0].fColor = GrColor_ILLEGAL; |
51 } | 71 } |
52 init.getOverrideColorIfSet(&fGeoData[0].fColor); | 72 init.getOverrideColorIfSet(&fGeoData[0].fColor); |
53 | 73 |
54 // setup batch properties | 74 // setup batch properties |
55 fBatch.fColorIgnored = !init.readsColor(); | 75 fBatch.fColorIgnored = !init.readsColor(); |
56 fBatch.fColor = fGeoData[0].fColor; | 76 fBatch.fColor = fGeoData[0].fColor; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 GrColor* vertColor = reinterpret_cast<GrColor*>(offset + kColorOffse
t); | 126 GrColor* vertColor = reinterpret_cast<GrColor*>(offset + kColorOffse
t); |
107 for (int j = 0; j < 4; ++j) { | 127 for (int j = 0; j < 4; ++j) { |
108 *vertColor = geom.fColor; | 128 *vertColor = geom.fColor; |
109 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride); | 129 vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride); |
110 } | 130 } |
111 } | 131 } |
112 | 132 |
113 helper.recordDraw(target); | 133 helper.recordDraw(target); |
114 } | 134 } |
115 | 135 |
116 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | |
117 | |
118 private: | |
119 BWFillRectBatch(const Geometry& geometry) { | |
120 this->initClassID<BWFillRectBatch>(); | |
121 fGeoData.push_back(geometry); | |
122 | |
123 fBounds = geometry.fRect; | |
124 geometry.fViewMatrix.mapRect(&fBounds); | |
125 } | |
126 | |
127 GrColor color() const { return fBatch.fColor; } | |
128 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | |
129 bool colorIgnored() const { return fBatch.fColorIgnored; } | |
130 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | |
131 const SkMatrix& localMatrix() const { return fGeoData[0].fLocalMatrix; } | |
132 bool hasLocalRect() const { return fGeoData[0].fHasLocalRect; } | |
133 bool hasLocalMatrix() const { return fGeoData[0].fHasLocalMatrix; } | |
134 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } | |
135 | |
136 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 136 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
137 BWFillRectBatch* that = t->cast<BWFillRectBatch>(); | 137 BWFillRectBatch* that = t->cast<BWFillRectBatch>(); |
138 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), | 138 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
139 that->bounds(), caps)) { | 139 that->bounds(), caps)) { |
140 return false; | 140 return false; |
141 } | 141 } |
142 | 142 |
143 if (this->hasLocalRect() != that->hasLocalRect()) { | 143 if (this->hasLocalRect() != that->hasLocalRect()) { |
144 return false; | 144 return false; |
145 } | 145 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 geometry.fHasLocalMatrix = random->nextBool(); | 260 geometry.fHasLocalMatrix = random->nextBool(); |
261 if (geometry.fHasLocalMatrix) { | 261 if (geometry.fHasLocalMatrix) { |
262 geometry.fLocalMatrix = GrTest::TestMatrix(random); | 262 geometry.fLocalMatrix = GrTest::TestMatrix(random); |
263 } | 263 } |
264 | 264 |
265 return BWFillRectBatch::Create(geometry); | 265 return BWFillRectBatch::Create(geometry); |
266 } | 266 } |
267 | 267 |
268 #endif | 268 #endif |
OLD | NEW |