Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Unified Diff: src/gpu/GrRectBatch.cpp

Issue 1135513002: adding rect batch unit test (Closed) Base URL: https://skia.googlesource.com/skia.git@randbatch6
Patch Set: tidy Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrRectBatch.cpp
diff --git a/src/gpu/GrRectBatch.cpp b/src/gpu/GrRectBatch.cpp
index ba63db1e0f38649d41058906fca1a17db2a95665..65bfb35dde9f96beb9be16975f612c7afa0a8b10 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);
+
+ SkRect rect = GrTest::TestRect(random);
+ SkRect localRect;
+ bool hasLocalRect = random->nextBool();
+ bool hasLocalMatrix = random->nextBool();
+
+ SkMatrix viewMatrix;
+ SkMatrix localMatrix;
+ 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698