Chromium Code Reviews| Index: src/gpu/GrRectBatch.cpp |
| diff --git a/src/gpu/GrRectBatch.cpp b/src/gpu/GrRectBatch.cpp |
| index ba63db1e0f38649d41058906fca1a17db2a95665..02a8540797a3663c51f2cdb4be3758ce5940e954 100644 |
| --- a/src/gpu/GrRectBatch.cpp |
| +++ b/src/gpu/GrRectBatch.cpp |
| @@ -9,6 +9,7 @@ |
| #include "GrBatch.h" |
| #include "GrBatchTarget.h" |
| +#include "GrBatchTest.h" |
| #include "GrDefaultGeoProcFactory.h" |
| #include "GrPrimitiveProcessor.h" |
| #include "GrTemplates.h" |
| @@ -41,13 +42,13 @@ static const GrGeometryProcessor* create_rect_gp(bool hasExplicitLocalCoords, |
| class RectBatch : public GrBatch { |
| public: |
| struct Geometry { |
| - GrColor fColor; |
| SkMatrix fViewMatrix; |
| SkRect fRect; |
| - bool fHasLocalRect; |
| - bool fHasLocalMatrix; |
| SkRect fLocalRect; |
| SkMatrix fLocalMatrix; |
| + GrColor fColor; |
| + bool fHasLocalRect; |
| + bool fHasLocalMatrix; |
| }; |
| static GrBatch* Create(const Geometry& geometry) { |
| @@ -249,3 +250,35 @@ GrBatch* Create(GrColor color, |
| } |
| }; |
| + |
| +/////////////////////////////////////////////////////////////////////////////////////////////////// |
| + |
| +#ifdef GR_TEST_UTILS |
| + |
| +BATCH_TEST_DEFINE(RectBatch) { |
| + GrColor color = GrRandomColor(random); |
| + |
|
robertphillips
2015/05/07 16:33:21
Don't bother initing viewMatrix and/or localMatrix
|
| + SkMatrix viewMatrix = SkMatrix::I(); |
| + SkMatrix localMatrix = SkMatrix::I(); |
| + SkRect rect = GrTest::TestRect(random); |
| + SkRect localRect; |
| + bool hasLocalRect = random->nextBool(); |
| + bool hasLocalMatrix = random->nextBool(); |
| + |
| + if (hasLocalRect) { |
| + viewMatrix = GrTest::TestMatrixInvertible(random); |
| + localRect = GrTest::TestRect(random); |
| + } else { |
| + viewMatrix = GrTest::TestMatrix(random); |
| + } |
| + |
| + if (hasLocalMatrix) { |
| + localMatrix = GrTest::TestMatrix(random); |
| + } |
| + |
| + return GrRectBatch::Create(color, viewMatrix, rect, |
| + hasLocalRect ? &localRect : NULL, |
| + hasLocalMatrix ? &localMatrix : NULL); |
| +} |
| + |
| +#endif |