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 "GrAAFillRectBatch.h" | 8 #include "GrAAFillRectBatch.h" |
9 | 9 |
10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 this->generateAAFillRectGeometry(vertices, | 124 this->generateAAFillRectGeometry(vertices, |
125 i * kVertsPerAAFillRect * vertexStr ide, | 125 i * kVertsPerAAFillRect * vertexStr ide, |
126 vertexStride, | 126 vertexStride, |
127 args.fColor, | 127 args.fColor, |
128 args.fViewMatrix, | 128 args.fViewMatrix, |
129 args.fRect, | 129 args.fRect, |
130 args.fDevRect, | 130 args.fDevRect, |
131 canTweakAlphaForCoverage); | 131 canTweakAlphaForCoverage); |
132 } | 132 } |
133 | 133 |
134 helper.issueDraw(batchTarget); | |
joshualitt
2015/08/12 18:03:17
is this intentional?
bsalomon
2015/08/12 18:09:05
Done.
| |
135 } | 134 } |
136 | 135 |
137 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 136 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
138 | 137 |
139 private: | 138 private: |
140 AAFillRectBatch(GrColor color, const SkMatrix& viewMatrix, const SkRect& rec t, | 139 AAFillRectBatch(GrColor color, const SkMatrix& viewMatrix, const SkRect& rec t, |
141 const SkRect& devRect) { | 140 const SkRect& devRect) { |
142 this->initClassID<AAFillRectBatch>(); | 141 this->initClassID<AAFillRectBatch>(); |
143 Geometry& geometry = fGeoData.push_back(); | 142 Geometry& geometry = fGeoData.push_back(); |
144 geometry.fRect = rect; | 143 geometry.fRect = rect; |
(...skipping 24 matching lines...) Expand all Loading... | |
169 gAAFillRectIndexBufferKey); | 168 gAAFillRectIndexBufferKey); |
170 } | 169 } |
171 | 170 |
172 GrColor color() const { return fBatch.fColor; } | 171 GrColor color() const { return fBatch.fColor; } |
173 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 172 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
174 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; } | 173 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; } |
175 bool colorIgnored() const { return fBatch.fColorIgnored; } | 174 bool colorIgnored() const { return fBatch.fColorIgnored; } |
176 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 175 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
177 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } | 176 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } |
178 | 177 |
179 bool onCombineIfPossible(GrBatch* t) override { | 178 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) { |
180 if (!this->pipeline()->isEqual(*t->pipeline())) { | 179 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipel ine(), t->bounds(), |
180 caps)) { | |
181 return false; | 181 return false; |
182 } | 182 } |
183 | 183 |
184 AAFillRectBatch* that = t->cast<AAFillRectBatch>(); | 184 AAFillRectBatch* that = t->cast<AAFillRectBatch>(); |
185 | 185 |
186 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 186 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
187 // We apply the viewmatrix to the rect points on the cpu. However, if t he pipeline uses | 187 // We apply the viewmatrix to the rect points on the cpu. However, if t he pipeline uses |
188 // local coords then we won't be able to batch. We could actually uploa d the viewmatrix | 188 // local coords then we won't be able to batch. We could actually uploa d the viewmatrix |
189 // using vertex attributes in these cases, but haven't investigated that | 189 // using vertex attributes in these cases, but haven't investigated that |
190 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi ewMatrix())) { | 190 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi ewMatrix())) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 | 330 |
331 BATCH_TEST_DEFINE(AAFillRectBatch) { | 331 BATCH_TEST_DEFINE(AAFillRectBatch) { |
332 GrColor color = GrRandomColor(random); | 332 GrColor color = GrRandomColor(random); |
333 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 333 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
334 SkRect rect = GrTest::TestRect(random); | 334 SkRect rect = GrTest::TestRect(random); |
335 SkRect devRect = GrTest::TestRect(random); | 335 SkRect devRect = GrTest::TestRect(random); |
336 return AAFillRectBatch::Create(color, viewMatrix, rect, devRect); | 336 return AAFillRectBatch::Create(color, viewMatrix, rect, devRect); |
337 } | 337 } |
338 | 338 |
339 #endif | 339 #endif |
OLD | NEW |