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 "GrColor.h" | 10 #include "GrColor.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 public: | 210 public: |
211 struct Geometry { | 211 struct Geometry { |
212 SkMatrix fViewMatrix; | 212 SkMatrix fViewMatrix; |
213 SkRect fRect; | 213 SkRect fRect; |
214 SkRect fDevRect; | 214 SkRect fDevRect; |
215 GrColor fColor; | 215 GrColor fColor; |
216 }; | 216 }; |
217 | 217 |
218 static const char* Name() { return "AAFillRectBatchNoLocalMatrix"; } | 218 static const char* Name() { return "AAFillRectBatchNoLocalMatrix"; } |
219 | 219 |
| 220 static SkString DumpInfo(const Geometry& geo) { |
| 221 SkString str; |
| 222 str.appendf("Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n"
, |
| 223 geo.fColor, |
| 224 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect
.fBottom); |
| 225 return str; |
| 226 } |
| 227 |
220 static bool CanCombine(const Geometry& mine, const Geometry& theirs, | 228 static bool CanCombine(const Geometry& mine, const Geometry& theirs, |
221 const GrPipelineOptimizations& opts) { | 229 const GrPipelineOptimizations& opts) { |
222 // We apply the viewmatrix to the rect points on the cpu. However, if t
he pipeline uses | 230 // We apply the viewmatrix to the rect points on the cpu. However, if t
he pipeline uses |
223 // local coords then we won't be able to batch. We could actually uploa
d the viewmatrix | 231 // local coords then we won't be able to batch. We could actually uploa
d the viewmatrix |
224 // using vertex attributes in these cases, but haven't investigated that | 232 // using vertex attributes in these cases, but haven't investigated that |
225 return !opts.readsLocalCoords() || mine.fViewMatrix.cheapEqualTo(theirs.
fViewMatrix); | 233 return !opts.readsLocalCoords() || mine.fViewMatrix.cheapEqualTo(theirs.
fViewMatrix); |
226 } | 234 } |
227 | 235 |
228 static const GrGeometryProcessor* CreateGP(const Geometry& geo, | 236 static const GrGeometryProcessor* CreateGP(const Geometry& geo, |
229 const GrPipelineOptimizations& op
ts) { | 237 const GrPipelineOptimizations& op
ts) { |
(...skipping 21 matching lines...) Expand all Loading... |
251 struct Geometry { | 259 struct Geometry { |
252 SkMatrix fViewMatrix; | 260 SkMatrix fViewMatrix; |
253 SkMatrix fLocalMatrix; | 261 SkMatrix fLocalMatrix; |
254 SkRect fRect; | 262 SkRect fRect; |
255 SkRect fDevRect; | 263 SkRect fDevRect; |
256 GrColor fColor; | 264 GrColor fColor; |
257 }; | 265 }; |
258 | 266 |
259 static const char* Name() { return "AAFillRectBatchLocalMatrix"; } | 267 static const char* Name() { return "AAFillRectBatchLocalMatrix"; } |
260 | 268 |
| 269 static SkString DumpInfo(const Geometry& geo) { |
| 270 SkString str; |
| 271 str.appendf("Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n"
, |
| 272 geo.fColor, |
| 273 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect
.fBottom); |
| 274 return str; |
| 275 } |
| 276 |
261 static bool CanCombine(const Geometry& mine, const Geometry& theirs, | 277 static bool CanCombine(const Geometry& mine, const Geometry& theirs, |
262 const GrPipelineOptimizations&) { | 278 const GrPipelineOptimizations&) { |
263 return true; | 279 return true; |
264 } | 280 } |
265 | 281 |
266 static const GrGeometryProcessor* CreateGP(const Geometry& geo, | 282 static const GrGeometryProcessor* CreateGP(const Geometry& geo, |
267 const GrPipelineOptimizations& op
ts) { | 283 const GrPipelineOptimizations& op
ts) { |
268 const GrGeometryProcessor* gp = | 284 const GrGeometryProcessor* gp = |
269 create_fill_rect_gp(geo.fViewMatrix, opts, | 285 create_fill_rect_gp(geo.fViewMatrix, opts, |
270 GrDefaultGeoProcFactory::LocalCoords::kHasEx
plicit_Type); | 286 GrDefaultGeoProcFactory::LocalCoords::kHasEx
plicit_Type); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) { | 410 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) { |
395 GrColor color = GrRandomColor(random); | 411 GrColor color = GrRandomColor(random); |
396 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 412 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
397 SkMatrix localMatrix = GrTest::TestMatrix(random); | 413 SkMatrix localMatrix = GrTest::TestMatrix(random); |
398 SkRect rect = GrTest::TestRect(random); | 414 SkRect rect = GrTest::TestRect(random); |
399 SkRect devRect = GrTest::TestRect(random); | 415 SkRect devRect = GrTest::TestRect(random); |
400 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe
ct); | 416 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe
ct); |
401 } | 417 } |
402 | 418 |
403 #endif | 419 #endif |
OLD | NEW |