| 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 "GrDrawAtlasBatch.h" | 8 #include "GrDrawAtlasBatch.h" |
| 9 #include "GrBatchTest.h" | 9 #include "GrBatchTest.h" |
| 10 #include "SkGr.h" | 10 #include "SkGr.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 currVertex += vertexStride; | 150 currVertex += vertexStride; |
| 151 } | 151 } |
| 152 | 152 |
| 153 viewMatrix.mapRect(&bounds); | 153 viewMatrix.mapRect(&bounds); |
| 154 // Outset for a half pixel in each direction to account for snapping in non-
AA case | 154 // Outset for a half pixel in each direction to account for snapping in non-
AA case |
| 155 bounds.outset(0.5f, 0.5f); | 155 bounds.outset(0.5f, 0.5f); |
| 156 this->setBounds(bounds); | 156 this->setBounds(bounds); |
| 157 } | 157 } |
| 158 | 158 |
| 159 bool GrDrawAtlasBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { | 159 bool GrDrawAtlasBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { |
| 160 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipeline(
), t->bounds(), | 160 GrDrawAtlasBatch* that = t->cast<GrDrawAtlasBatch>(); |
| 161 caps)) { | 161 |
| 162 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeli
ne(), |
| 163 that->bounds(), caps)) { |
| 162 return false; | 164 return false; |
| 163 } | 165 } |
| 164 | 166 |
| 165 GrDrawAtlasBatch* that = t->cast<GrDrawAtlasBatch>(); | |
| 166 | |
| 167 // We currently use a uniform viewmatrix for this batch | 167 // We currently use a uniform viewmatrix for this batch |
| 168 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { | 168 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { |
| 169 return false; | 169 return false; |
| 170 } | 170 } |
| 171 | 171 |
| 172 if (this->hasColors() != that->hasColors()) { | 172 if (this->hasColors() != that->hasColors()) { |
| 173 return false; | 173 return false; |
| 174 } | 174 } |
| 175 | 175 |
| 176 if (!this->hasColors() && this->color() != that->color()) { | 176 if (!this->hasColors() && this->color() != that->color()) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 SkTArray<GrColor>* colors, bool hasColors) { | 224 SkTArray<GrColor>* colors, bool hasColors) { |
| 225 for (uint32_t v = 0; v < count; v++) { | 225 for (uint32_t v = 0; v < count; v++) { |
| 226 xforms->push_back(random_xform(random)); | 226 xforms->push_back(random_xform(random)); |
| 227 texRects->push_back(random_texRect(random)); | 227 texRects->push_back(random_texRect(random)); |
| 228 if (hasColors) { | 228 if (hasColors) { |
| 229 colors->push_back(GrRandomColor(random)); | 229 colors->push_back(GrRandomColor(random)); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 BATCH_TEST_DEFINE(GrDrawAtlasBatch) { | 234 DRAW_BATCH_TEST_DEFINE(GrDrawAtlasBatch) { |
| 235 uint32_t spriteCount = random->nextRangeU(1, 100); | 235 uint32_t spriteCount = random->nextRangeU(1, 100); |
| 236 | 236 |
| 237 SkTArray<SkRSXform> xforms(spriteCount); | 237 SkTArray<SkRSXform> xforms(spriteCount); |
| 238 SkTArray<SkRect> texRects(spriteCount); | 238 SkTArray<SkRect> texRects(spriteCount); |
| 239 SkTArray<GrColor> colors; | 239 SkTArray<GrColor> colors; |
| 240 | 240 |
| 241 bool hasColors = random->nextBool(); | 241 bool hasColors = random->nextBool(); |
| 242 | 242 |
| 243 randomize_params(spriteCount, | 243 randomize_params(spriteCount, |
| 244 random, | 244 random, |
| 245 &xforms, | 245 &xforms, |
| 246 &texRects, | 246 &texRects, |
| 247 &colors, hasColors); | 247 &colors, hasColors); |
| 248 | 248 |
| 249 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 249 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
| 250 | 250 |
| 251 GrDrawAtlasBatch::Geometry geometry; | 251 GrDrawAtlasBatch::Geometry geometry; |
| 252 geometry.fColor = GrRandomColor(random); | 252 geometry.fColor = GrRandomColor(random); |
| 253 return GrDrawAtlasBatch::Create(geometry, viewMatrix, spriteCount, xforms.be
gin(), | 253 return GrDrawAtlasBatch::Create(geometry, viewMatrix, spriteCount, xforms.be
gin(), |
| 254 texRects.begin(), colors.begin()); | 254 texRects.begin(), colors.begin()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 #endif | 257 #endif |
| OLD | NEW |