Rename files, macros, types, and functions related to GrDrawOp testing.
authorBrian Salomon <bsalomon@google.com>
Tue, 20 Dec 2016 20:34:05 +0000 (15:34 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Tue, 20 Dec 2016 21:10:56 +0000 (21:10 +0000)
Make the test factories use sk_sp.

Change-Id: Idba630b84deb2848f2203a80fd72e1efa5fc6acf
Reviewed-on: https://skia-review.googlesource.com/6342
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>

27 files changed:
gn/gpu.gni
src/gpu/GrBatchTest.cpp [deleted file]
src/gpu/GrBatchTest.h [deleted file]
src/gpu/GrDrawOpTest.cpp [new file with mode: 0644]
src/gpu/GrDrawOpTest.h [new file with mode: 0644]
src/gpu/GrRenderTargetContext.cpp
src/gpu/ops/GrAAConvexPathRenderer.cpp
src/gpu/ops/GrAADistanceFieldPathRenderer.cpp
src/gpu/ops/GrAAFillRectOp.cpp
src/gpu/ops/GrAAHairLinePathRenderer.cpp
src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
src/gpu/ops/GrAAStrokeRectOp.cpp
src/gpu/ops/GrAnalyticRectOp.cpp
src/gpu/ops/GrDashOp.cpp
src/gpu/ops/GrDefaultPathRenderer.cpp
src/gpu/ops/GrDrawAtlasOp.cpp
src/gpu/ops/GrDrawVerticesOp.cpp
src/gpu/ops/GrNonAAFillRectOp.cpp
src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp
src/gpu/ops/GrNonAAStrokeRectOp.cpp
src/gpu/ops/GrOvalOpFactory.cpp
src/gpu/ops/GrPLSPathRenderer.cpp
src/gpu/ops/GrShadowRRectOp.cpp
src/gpu/ops/GrTessellatingPathRenderer.cpp
src/gpu/text/GrAtlasTextContext.cpp
src/gpu/text/GrAtlasTextContext.h
tests/GLProgramsTest.cpp

index 73fb4d6..eee9003 100644 (file)
@@ -73,8 +73,6 @@ skia_gpu_sources = [
   "$_src/gpu/GrAuditTrail.cpp",
   "$_src/gpu/GrAutoLocaleSetter.h",
   "$_src/gpu/GrAllocator.h",
-  "$_src/gpu/GrBatchTest.cpp",
-  "$_src/gpu/GrBatchTest.h",
   "$_src/gpu/GrBitmapTextureMaker.cpp",
   "$_src/gpu/GrBitmapTextureMaker.h",
   "$_src/gpu/GrBlend.cpp",
@@ -96,6 +94,8 @@ skia_gpu_sources = [
   "$_src/gpu/GrDrawingManager.h",
   "$_src/gpu/GrDrawOpAtlas.cpp",
   "$_src/gpu/GrDrawOpAtlas.h",
+  "$_src/gpu/GrDrawOpTest.cpp",
+  "$_src/gpu/GrDrawOpTest.h",
   "$_src/gpu/GrFixedClip.cpp",
   "$_src/gpu/GrFixedClip.h",
   "$_src/gpu/GrFragmentProcessor.cpp",
diff --git a/src/gpu/GrBatchTest.cpp b/src/gpu/GrBatchTest.cpp
deleted file mode 100644 (file)
index 562c569..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrBatchTest.h"
-#include "SkRandom.h"
-#include "SkTypes.h"
-
-#ifdef GR_TEST_UTILS
-
-DRAW_BATCH_TEST_EXTERN(AAConvexPathOp);
-DRAW_BATCH_TEST_EXTERN(AADistanceFieldPathOp);
-DRAW_BATCH_TEST_EXTERN(AAFillRectOp);
-DRAW_BATCH_TEST_EXTERN(AAFillRectOpLocalMatrix);
-DRAW_BATCH_TEST_EXTERN(AAFlatteningConvexPathOp)
-DRAW_BATCH_TEST_EXTERN(AAHairlineOp);
-DRAW_BATCH_TEST_EXTERN(AAStrokeRectOp);
-DRAW_BATCH_TEST_EXTERN(AnalyticRectOp);
-DRAW_BATCH_TEST_EXTERN(DashOp);
-DRAW_BATCH_TEST_EXTERN(DefaultPathOp);
-DRAW_BATCH_TEST_EXTERN(CircleOp);
-DRAW_BATCH_TEST_EXTERN(DIEllipseOp);
-DRAW_BATCH_TEST_EXTERN(EllipseOp);
-DRAW_BATCH_TEST_EXTERN(GrDrawAtlasOp);
-DRAW_BATCH_TEST_EXTERN(NonAAStrokeRectOp);
-DRAW_BATCH_TEST_EXTERN(PLSPathOp);
-DRAW_BATCH_TEST_EXTERN(RRectOp);
-DRAW_BATCH_TEST_EXTERN(TesselatingPathOp);
-DRAW_BATCH_TEST_EXTERN(TextBlobBatch);
-DRAW_BATCH_TEST_EXTERN(VerticesOp);
-
-static BatchTestFunc gTestBatches[] = {
-    DRAW_BATCH_TEST_ENTRY(AAConvexPathOp),
-    DRAW_BATCH_TEST_ENTRY(AADistanceFieldPathOp),
-    DRAW_BATCH_TEST_ENTRY(AAFillRectOp),
-    DRAW_BATCH_TEST_ENTRY(AAFillRectOpLocalMatrix),
-    DRAW_BATCH_TEST_ENTRY(AAFlatteningConvexPathOp),
-    DRAW_BATCH_TEST_ENTRY(AAHairlineOp),
-    DRAW_BATCH_TEST_ENTRY(AAStrokeRectOp),
-    DRAW_BATCH_TEST_ENTRY(AnalyticRectOp),
-    DRAW_BATCH_TEST_ENTRY(DashOp),
-    DRAW_BATCH_TEST_ENTRY(DefaultPathOp),
-    DRAW_BATCH_TEST_ENTRY(CircleOp),
-    DRAW_BATCH_TEST_ENTRY(DIEllipseOp),
-    DRAW_BATCH_TEST_ENTRY(EllipseOp),
-    DRAW_BATCH_TEST_ENTRY(GrDrawAtlasOp),
-    DRAW_BATCH_TEST_ENTRY(NonAAStrokeRectOp),
-    // This currently hits an assert when the GrDisableColorXPFactory is randomly selected.
-    // DRAW_BATCH_TEST_ENTRY(PLSPathOp),
-    DRAW_BATCH_TEST_ENTRY(RRectOp),
-    DRAW_BATCH_TEST_ENTRY(TesselatingPathOp),
-    DRAW_BATCH_TEST_ENTRY(TextBlobBatch),
-    DRAW_BATCH_TEST_ENTRY(VerticesOp)
-};
-
-GrDrawOp* GrRandomDrawBatch(SkRandom* random, GrContext* context) {
-    uint32_t index = random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gTestBatches)));
-    BatchTestFunc func = gTestBatches[index];
-    return (*func)(random, context);
-}
-#endif
diff --git a/src/gpu/GrBatchTest.h b/src/gpu/GrBatchTest.h
deleted file mode 100644 (file)
index 5d7fa63..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrBatchTest_DEFINED
-#define GrBatchTest_DEFINED
-
-#include "GrTestUtils.h"
-
-#ifdef GR_TEST_UTILS
-
-class GrDrawOp;
-class GrContext;
-class SkRandom;
-
-/*
- * This file defines some macros for testing batches, and also declares functions / objects which
- * are generally useful for GrOp testing
- */
-
-// Batches should define test functions using DRAW_BATCH_TEST_DEFINE.  The other macros defined
-// below are used exclusively by the test harness.
-typedef GrDrawOp* (*BatchTestFunc)(SkRandom* random, GrContext* context);
-#define DRAW_BATCH_TEST_DEFINE(Batch) \
-    GrDrawOp* Batch##__Test(SkRandom* random, GrContext* context)
-#define DRAW_BATCH_TEST_EXTERN(Batch) \
-    extern GrDrawOp* Batch##__Test(SkRandom*, GrContext* context);
-#define DRAW_BATCH_TEST_ENTRY(Batch) \
-    Batch##__Test
-#define DRAW_BATCH_TEST_FRIEND(Batch) \
-    friend GrDrawOp* Batch##__Test(SkRandom* random, GrContext* context);
-
-GrDrawOp* GrRandomDrawBatch(SkRandom*, GrContext*);
-
-#endif
-#endif
diff --git a/src/gpu/GrDrawOpTest.cpp b/src/gpu/GrDrawOpTest.cpp
new file mode 100644 (file)
index 0000000..bb26acc
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrDrawOpTest.h"
+#include "ops/GrDrawOp.h"
+#include "SkRandom.h"
+#include "SkTypes.h"
+
+#ifdef GR_TEST_UTILS
+
+#define DRAW_OP_TEST_EXTERN(Op) extern sk_sp<GrDrawOp> Op##__Test(SkRandom*, GrContext* context);
+
+#define DRAW_OP_TEST_ENTRY(Op) Op##__Test
+
+DRAW_OP_TEST_EXTERN(AAConvexPathOp);
+DRAW_OP_TEST_EXTERN(AADistanceFieldPathOp);
+DRAW_OP_TEST_EXTERN(AAFillRectOp);
+DRAW_OP_TEST_EXTERN(AAFillRectOpLocalMatrix);
+DRAW_OP_TEST_EXTERN(AAFlatteningConvexPathOp)
+DRAW_OP_TEST_EXTERN(AAHairlineOp);
+DRAW_OP_TEST_EXTERN(AAStrokeRectOp);
+DRAW_OP_TEST_EXTERN(AnalyticRectOp);
+DRAW_OP_TEST_EXTERN(DashOp);
+DRAW_OP_TEST_EXTERN(DefaultPathOp);
+DRAW_OP_TEST_EXTERN(CircleOp);
+DRAW_OP_TEST_EXTERN(DIEllipseOp);
+DRAW_OP_TEST_EXTERN(EllipseOp);
+DRAW_OP_TEST_EXTERN(GrDrawAtlasOp);
+DRAW_OP_TEST_EXTERN(NonAAStrokeRectOp);
+DRAW_OP_TEST_EXTERN(PLSPathOp);
+DRAW_OP_TEST_EXTERN(RRectOp);
+DRAW_OP_TEST_EXTERN(TesselatingPathOp);
+DRAW_OP_TEST_EXTERN(TextBlobOp);
+DRAW_OP_TEST_EXTERN(VerticesOp);
+
+sk_sp<GrDrawOp> GrRandomDrawOp(SkRandom* random, GrContext* context) {
+    using MakeTestDrawOpFn = sk_sp<GrDrawOp>(SkRandom* random, GrContext* context);
+    static constexpr MakeTestDrawOpFn* gFactories[] = {
+        DRAW_OP_TEST_ENTRY(AAConvexPathOp),
+        DRAW_OP_TEST_ENTRY(AADistanceFieldPathOp),
+        DRAW_OP_TEST_ENTRY(AAFillRectOp),
+        DRAW_OP_TEST_ENTRY(AAFillRectOpLocalMatrix),
+        DRAW_OP_TEST_ENTRY(AAFlatteningConvexPathOp),
+        DRAW_OP_TEST_ENTRY(AAHairlineOp),
+        DRAW_OP_TEST_ENTRY(AAStrokeRectOp),
+        DRAW_OP_TEST_ENTRY(AnalyticRectOp),
+        DRAW_OP_TEST_ENTRY(DashOp),
+        DRAW_OP_TEST_ENTRY(DefaultPathOp),
+        DRAW_OP_TEST_ENTRY(CircleOp),
+        DRAW_OP_TEST_ENTRY(DIEllipseOp),
+        DRAW_OP_TEST_ENTRY(EllipseOp),
+        DRAW_OP_TEST_ENTRY(GrDrawAtlasOp),
+        DRAW_OP_TEST_ENTRY(NonAAStrokeRectOp),
+        // This currently hits an assert when the GrDisableColorXPFactory is randomly selected.
+        // DRAW_OP_TEST_ENTRY(PLSPathOp),
+        DRAW_OP_TEST_ENTRY(RRectOp),
+        DRAW_OP_TEST_ENTRY(TesselatingPathOp),
+        DRAW_OP_TEST_ENTRY(TextBlobOp),
+        DRAW_OP_TEST_ENTRY(VerticesOp)
+    };
+
+    uint32_t index = random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gFactories)));
+    return gFactories[index](random, context);
+}
+#endif
diff --git a/src/gpu/GrDrawOpTest.h b/src/gpu/GrDrawOpTest.h
new file mode 100644 (file)
index 0000000..0d88a40
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrDrawOpTest_DEFINED
+#define GrDrawOpTest_DEFINED
+
+#include "GrTestUtils.h"
+#include "SkRefCnt.h"
+
+#ifdef GR_TEST_UTILS
+
+class GrDrawOp;
+class GrContext;
+class SkRandom;
+
+/**  This function returns a randomly configured GrDrawOp for testing purposes. */
+sk_sp<GrDrawOp> GrRandomDrawOp(SkRandom*, GrContext*);
+
+/** GrDrawOp subclasses should define test factory functions using this macro. */
+#define DRAW_OP_TEST_DEFINE(Op) sk_sp<GrDrawOp> Op##__Test(SkRandom* random, GrContext* context)
+
+/** This macro may be used if the test factory function must be made a friend of a class. */
+#define DRAW_OP_TEST_FRIEND(Op) \
+    friend sk_sp<GrDrawOp> Op##__Test(SkRandom* random, GrContext* context);
+
+#endif
+#endif
index 60a213f..10881de 100644 (file)
@@ -5,16 +5,16 @@
  * found in the LICENSE file.
  */
 
-#include "GrBatchTest.h"
-#include "GrColor.h"
 #include "GrRenderTargetContext.h"
-#include "GrRenderTargetContextPriv.h"
+#include "GrColor.h"
+#include "GrDrawOpTest.h"
 #include "GrDrawingManager.h"
 #include "GrFixedClip.h"
 #include "GrGpuResourcePriv.h"
 #include "GrPathRenderer.h"
 #include "GrPipelineBuilder.h"
 #include "GrRenderTarget.h"
+#include "GrRenderTargetContextPriv.h"
 #include "GrRenderTargetPriv.h"
 #include "GrResourceProvider.h"
 #include "SkSurfacePriv.h"
index 40f4284..fd4083b 100644 (file)
@@ -8,10 +8,10 @@
 #include "GrAAConvexPathRenderer.h"
 
 #include "GrAAConvexTessellator.h"
-#include "GrBatchTest.h"
 #include "GrCaps.h"
 #include "GrContext.h"
 #include "GrDefaultGeoProcFactory.h"
+#include "GrDrawOpTest.h"
 #include "GrGeometryProcessor.h"
 #include "GrInvariantOutput.h"
 #include "GrOpFlushState.h"
@@ -1007,12 +1007,12 @@ bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(AAConvexPathOp) {
+DRAW_OP_TEST_DEFINE(AAConvexPathOp) {
     GrColor color = GrRandomColor(random);
     SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
     SkPath path = GrTest::TestPathConvex(random);
 
-    return AAConvexPathOp::Make(color, viewMatrix, path).release();
+    return AAConvexPathOp::Make(color, viewMatrix, path);
 }
 
 #endif
index 678c920..00d3ed7 100644 (file)
@@ -7,9 +7,9 @@
 
 #include "GrAADistanceFieldPathRenderer.h"
 
-#include "GrBatchTest.h"
 #include "GrBuffer.h"
 #include "GrContext.h"
+#include "GrDrawOpTest.h"
 #include "GrOpFlushState.h"
 #include "GrPipelineBuilder.h"
 #include "GrResourceProvider.h"
@@ -581,7 +581,7 @@ struct PathTestStruct {
     ShapeDataList fShapeList;
 };
 
-DRAW_BATCH_TEST_DEFINE(AADistanceFieldPathOp) {
+DRAW_OP_TEST_DEFINE(AADistanceFieldPathOp) {
     static PathTestStruct gTestStruct;
 
     if (context->uniqueID() != gTestStruct.fContextID) {
@@ -608,8 +608,7 @@ DRAW_BATCH_TEST_DEFINE(AADistanceFieldPathOp) {
                                        gTestStruct.fAtlas.get(),
                                        &gTestStruct.fShapeCache,
                                        &gTestStruct.fShapeList,
-                                       gammaCorrect)
-            .release();
+                                       gammaCorrect);
 }
 
 #endif
index 9f7b0e0..d45954c 100644 (file)
@@ -386,23 +386,23 @@ sk_sp<GrDrawOp> MakeWithLocalRect(GrColor color,
 
 #ifdef GR_TEST_UTILS
 
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
 
-DRAW_BATCH_TEST_DEFINE(AAFillRectOp) {
+DRAW_OP_TEST_DEFINE(AAFillRectOp) {
     GrColor color = GrRandomColor(random);
     SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
     SkRect rect = GrTest::TestRect(random);
     SkRect devRect = GrTest::TestRect(random);
-    return GrAAFillRectOp::Make(color, viewMatrix, rect, devRect).release();
+    return GrAAFillRectOp::Make(color, viewMatrix, rect, devRect);
 }
 
-DRAW_BATCH_TEST_DEFINE(AAFillRectOpLocalMatrix) {
+DRAW_OP_TEST_DEFINE(AAFillRectOpLocalMatrix) {
     GrColor color = GrRandomColor(random);
     SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
     SkMatrix localMatrix = GrTest::TestMatrix(random);
     SkRect rect = GrTest::TestRect(random);
     SkRect devRect = GrTest::TestRect(random);
-    return GrAAFillRectOp::Make(color, viewMatrix, localMatrix, rect, devRect).release();
+    return GrAAFillRectOp::Make(color, viewMatrix, localMatrix, rect, devRect);
 }
 
 #endif
index 7707afa..b5a7978 100644 (file)
@@ -7,11 +7,11 @@
 
 #include "GrAAHairLinePathRenderer.h"
 
-#include "GrBatchTest.h"
 #include "GrBuffer.h"
 #include "GrCaps.h"
 #include "GrContext.h"
 #include "GrDefaultGeoProcFactory.h"
+#include "GrDrawOpTest.h"
 #include "GrOpFlushState.h"
 #include "GrPathUtils.h"
 #include "GrPipelineBuilder.h"
@@ -972,14 +972,13 @@ bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(AAHairlineOp) {
+DRAW_OP_TEST_DEFINE(AAHairlineOp) {
     GrColor color = GrRandomColor(random);
     SkMatrix viewMatrix = GrTest::TestMatrix(random);
     SkPath path = GrTest::TestPath(random);
     SkIRect devClipBounds;
     devClipBounds.setEmpty();
-    return AAHairlineOp::Make(color, viewMatrix, path, GrStyle::SimpleHairline(), devClipBounds)
-            .release();
+    return AAHairlineOp::Make(color, viewMatrix, path, GrStyle::SimpleHairline(), devClipBounds);
 }
 
 #endif
index c247353..8f2ab86 100644 (file)
@@ -8,9 +8,9 @@
 #include "GrAALinearizingConvexPathRenderer.h"
 
 #include "GrAAConvexTessellator.h"
-#include "GrBatchTest.h"
 #include "GrContext.h"
 #include "GrDefaultGeoProcFactory.h"
+#include "GrDrawOpTest.h"
 #include "GrGeometryProcessor.h"
 #include "GrInvariantOutput.h"
 #include "GrOpFlushState.h"
@@ -374,7 +374,7 @@ bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathOp) {
+DRAW_OP_TEST_DEFINE(AAFlatteningConvexPathOp) {
     GrColor color = GrRandomColor(random);
     SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
     SkPath path = GrTest::TestPathConvex(random);
@@ -400,8 +400,7 @@ DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathOp) {
     }
 
     return AAFlatteningConvexPathOp::Make(color, viewMatrix, path, strokeWidth, style, join,
-                                          miterLimit)
-            .release();
+                                          miterLimit);
 }
 
 #endif
index 2528892..5660679 100644 (file)
@@ -587,9 +587,9 @@ sk_sp<GrDrawOp> Make(GrColor color,
 
 #ifdef GR_TEST_UTILS
 
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
 
-DRAW_BATCH_TEST_DEFINE(AAStrokeRectOp) {
+DRAW_OP_TEST_DEFINE(AAStrokeRectOp) {
     bool miterStroke = random->nextBool();
 
     // Create either a empty rect or a non-empty rect.
@@ -605,7 +605,7 @@ DRAW_BATCH_TEST_DEFINE(AAStrokeRectOp) {
     rec.setStrokeParams(SkPaint::kButt_Cap,
                         miterStroke ? SkPaint::kMiter_Join : SkPaint::kBevel_Join, 1.f);
     SkMatrix matrix = GrTest::TestMatrixRectStaysRect(random);
-    return GrAAStrokeRectOp::Make(color, matrix, rect, rec).release();
+    return GrAAStrokeRectOp::Make(color, matrix, rect, rec);
 }
 
 #endif
index 63e1548..9c4e66c 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "GrAnalyticRectOp.h"
 
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
 #include "GrGeometryProcessor.h"
 #include "GrInvariantOutput.h"
 #include "GrOpFlushState.h"
@@ -390,13 +390,13 @@ sk_sp<GrDrawOp> GrAnalyticRectOp::Make(GrColor color,
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(AnalyticRectOp) {
+DRAW_OP_TEST_DEFINE(AnalyticRectOp) {
     SkMatrix viewMatrix = GrTest::TestMatrix(random);
     GrColor color = GrRandomColor(random);
     SkRect rect = GrTest::TestSquare(random);
     SkRect croppedRect = GrTest::TestSquare(random);
     SkRect bounds = GrTest::TestSquare(random);
-    return new AnalyticRectOp(color, viewMatrix, rect, croppedRect, bounds);
+    return sk_sp<GrDrawOp>(new AnalyticRectOp(color, viewMatrix, rect, croppedRect, bounds));
 }
 
 #endif
index 9218482..8052795 100644 (file)
@@ -7,11 +7,11 @@
 
 #include "GrDashOp.h"
 
-#include "GrBatchTest.h"
 #include "GrCaps.h"
 #include "GrContext.h"
 #include "GrCoordTransform.h"
 #include "GrDefaultGeoProcFactory.h"
+#include "GrDrawOpTest.h"
 #include "GrGeometryProcessor.h"
 #include "GrInvariantOutput.h"
 #include "GrOpFlushState.h"
@@ -1210,7 +1210,7 @@ static sk_sp<GrGeometryProcessor> make_dash_gp(GrColor color,
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(DashOp) {
+DRAW_OP_TEST_DEFINE(DashOp) {
     GrColor color = GrRandomColor(random);
     SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
     AAMode aaMode = static_cast<AAMode>(random->nextULessThan(GrDashOp::kAAModeCnt));
@@ -1275,7 +1275,7 @@ DRAW_BATCH_TEST_DEFINE(DashOp) {
 
     GrStyle style(p);
 
-    return GrDashOp::MakeDashLineOp(color, viewMatrix, pts, aaMode, style).release();
+    return GrDashOp::MakeDashLineOp(color, viewMatrix, pts, aaMode, style);
 }
 
 #endif
index b979d91..4803c0d 100644 (file)
@@ -7,9 +7,9 @@
 
 #include "GrDefaultPathRenderer.h"
 
-#include "GrBatchTest.h"
 #include "GrContext.h"
 #include "GrDefaultGeoProcFactory.h"
+#include "GrDrawOpTest.h"
 #include "GrFixedClip.h"
 #include "GrMesh.h"
 #include "GrOpFlushState.h"
@@ -618,7 +618,7 @@ void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) {
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(DefaultPathOp) {
+DRAW_OP_TEST_DEFINE(DefaultPathOp) {
     GrColor color = GrRandomColor(random);
     SkMatrix viewMatrix = GrTest::TestMatrix(random);
 
@@ -634,8 +634,7 @@ DRAW_BATCH_TEST_DEFINE(DefaultPathOp) {
 
     viewMatrix.mapRect(&bounds);
     uint8_t coverage = GrRandomCoverage(random);
-    return DefaultPathOp::Make(color, path, srcSpaceTol, coverage, viewMatrix, true, bounds)
-            .release();
+    return DefaultPathOp::Make(color, path, srcSpaceTol, coverage, viewMatrix, true, bounds);
 }
 
 #endif
index 3dafbda..e01ad73 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #include "GrDrawAtlasOp.h"
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
 #include "GrOpFlushState.h"
 #include "SkGr.h"
 #include "SkRSXform.h"
@@ -235,7 +235,7 @@ static void randomize_params(uint32_t count, SkRandom* random, SkTArray<SkRSXfor
     }
 }
 
-DRAW_BATCH_TEST_DEFINE(GrDrawAtlasOp) {
+DRAW_OP_TEST_DEFINE(GrDrawAtlasOp) {
     uint32_t spriteCount = random->nextRangeU(1, 100);
 
     SkTArray<SkRSXform> xforms(spriteCount);
@@ -250,8 +250,7 @@ DRAW_BATCH_TEST_DEFINE(GrDrawAtlasOp) {
 
     GrColor color = GrRandomColor(random);
     return GrDrawAtlasOp::Make(color, viewMatrix, spriteCount, xforms.begin(), texRects.begin(),
-                               hasColors ? colors.begin() : nullptr)
-            .release();
+                               hasColors ? colors.begin() : nullptr);
 }
 
 #endif
index 37be6d0..c6ae1c1 100644 (file)
@@ -213,7 +213,7 @@ bool GrDrawVerticesOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
 
 #ifdef GR_TEST_UTILS
 
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
 
 static uint32_t seed_vertices(GrPrimitiveType type) {
     switch (type) {
@@ -274,7 +274,7 @@ static void randomize_params(size_t count, size_t maxVertex, SkScalar min, SkSca
     }
 }
 
-DRAW_BATCH_TEST_DEFINE(VerticesOp) {
+DRAW_OP_TEST_DEFINE(VerticesOp) {
     GrPrimitiveType type = GrPrimitiveType(random->nextULessThan(kLast_GrPrimitiveType + 1));
     uint32_t primitiveCount = random->nextRangeU(1, 100);
 
@@ -312,8 +312,7 @@ DRAW_BATCH_TEST_DEFINE(VerticesOp) {
     GrColor color = GrRandomColor(random);
     return GrDrawVerticesOp::Make(color, type, viewMatrix, positions.begin(), vertexCount,
                                   indices.begin(), hasIndices ? vertexCount : 0, colors.begin(),
-                                  texCoords.begin(), bounds)
-            .release();
+                                  texCoords.begin(), bounds);
 }
 
 #endif
index de000e2..e672985 100644 (file)
@@ -203,9 +203,9 @@ sk_sp<GrDrawOp> Make(GrColor color,
 
 #ifdef GR_TEST_UTILS
 
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
 
-DRAW_BATCH_TEST_DEFINE(NonAAFillRectOp) {
+DRAW_OP_TEST_DEFINE(NonAAFillRectOp) {
     GrColor color = GrRandomColor(random);
     SkRect rect = GrTest::TestRect(random);
     SkRect localRect = GrTest::TestRect(random);
@@ -218,8 +218,7 @@ DRAW_BATCH_TEST_DEFINE(NonAAFillRectOp) {
                                    viewMatrix,
                                    rect,
                                    hasLocalRect ? &localRect : nullptr,
-                                   hasLocalMatrix ? &localMatrix : nullptr)
-            .release();
+                                   hasLocalMatrix ? &localMatrix : nullptr);
 }
 
 #endif
index 443c511..fde4328 100644 (file)
@@ -246,9 +246,9 @@ sk_sp<GrDrawOp> MakeWithPerspective(GrColor color,
 
 #ifdef GR_TEST_UTILS
 
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
 
-DRAW_BATCH_TEST_DEFINE(NonAAFillRectPerspectiveOp) {
+DRAW_OP_TEST_DEFINE(NonAAFillRectPerspectiveOp) {
     GrColor color = GrRandomColor(random);
     SkRect rect = GrTest::TestRect(random);
     SkRect localRect = GrTest::TestRect(random);
@@ -263,8 +263,7 @@ DRAW_BATCH_TEST_DEFINE(NonAAFillRectPerspectiveOp) {
     bool hasLocalRect = random->nextBool();
     return GrNonAAFillRectOp::MakeWithPerspective(color, viewMatrix, rect,
                                                   hasLocalRect ? &localRect : nullptr,
-                                                  hasLocalMatrix ? &localMatrix : nullptr)
-            .release();
+                                                  hasLocalMatrix ? &localMatrix : nullptr);
 }
 
 #endif
index b74cd50..065f08a 100644 (file)
@@ -7,9 +7,9 @@
 
 #include "GrNonAAStrokeRectOp.h"
 
-#include "GrBatchTest.h"
 #include "GrColor.h"
 #include "GrDefaultGeoProcFactory.h"
+#include "GrDrawOpTest.h"
 #include "GrMeshDrawOp.h"
 #include "GrOpFlushState.h"
 #include "SkRandom.h"
@@ -198,7 +198,7 @@ sk_sp<GrDrawOp> Make(GrColor color,
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectOp) {
+DRAW_OP_TEST_DEFINE(NonAAStrokeRectOp) {
     SkMatrix viewMatrix = GrTest::TestMatrix(random);
     GrColor color = GrRandomColor(random);
     SkRect rect = GrTest::TestRect(random);
@@ -208,8 +208,7 @@ DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectOp) {
     paint.setStyle(SkPaint::kStroke_Style);
     paint.setStrokeJoin(SkPaint::kMiter_Join);
     SkStrokeRec strokeRec(paint);
-    return GrNonAAStrokeRectOp::Make(color, viewMatrix, rect, strokeRec, random->nextBool())
-            .release();
+    return GrNonAAStrokeRectOp::Make(color, viewMatrix, rect, strokeRec, random->nextBool());
 }
 
 #endif
index 7a53ca6..10fc375 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "GrOvalOpFactory.h"
 
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
 #include "GrGeometryProcessor.h"
 #include "GrInvariantOutput.h"
 #include "GrOpFlushState.h"
@@ -2425,7 +2425,7 @@ sk_sp<GrDrawOp> GrOvalOpFactory::MakeArcOp(GrColor color, const SkMatrix& viewMa
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(CircleOp) {
+DRAW_OP_TEST_DEFINE(CircleOp) {
     do {
         SkScalar rotate = random->nextSScalar1() * 360.f;
         SkScalar translateX = random->nextSScalar1() * 1000.f;
@@ -2451,32 +2451,31 @@ DRAW_BATCH_TEST_DEFINE(CircleOp) {
         sk_sp<GrDrawOp> op = CircleOp::Make(color, viewMatrix, center, radius,
                                             GrStyle(stroke, nullptr), arcParams);
         if (op) {
-            return op.release();
+            return op;
         }
     } while (true);
 }
 
-DRAW_BATCH_TEST_DEFINE(EllipseOp) {
+DRAW_OP_TEST_DEFINE(EllipseOp) {
     SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
     GrColor color = GrRandomColor(random);
     SkRect ellipse = GrTest::TestSquare(random);
-    return EllipseOp::Make(color, viewMatrix, ellipse, GrTest::TestStrokeRec(random)).release();
+    return EllipseOp::Make(color, viewMatrix, ellipse, GrTest::TestStrokeRec(random));
 }
 
-DRAW_BATCH_TEST_DEFINE(DIEllipseOp) {
+DRAW_OP_TEST_DEFINE(DIEllipseOp) {
     SkMatrix viewMatrix = GrTest::TestMatrix(random);
     GrColor color = GrRandomColor(random);
     SkRect ellipse = GrTest::TestSquare(random);
-    return DIEllipseOp::Make(color, viewMatrix, ellipse, GrTest::TestStrokeRec(random)).release();
+    return DIEllipseOp::Make(color, viewMatrix, ellipse, GrTest::TestStrokeRec(random));
 }
 
-DRAW_BATCH_TEST_DEFINE(RRectOp) {
+DRAW_OP_TEST_DEFINE(RRectOp) {
     SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
     GrColor color = GrRandomColor(random);
     const SkRRect& rrect = GrTest::TestRRectSimple(random);
     bool needsDistance = random->nextBool();
-    return make_rrect_op(color, needsDistance, viewMatrix, rrect, GrTest::TestStrokeRec(random))
-            .release();
+    return make_rrect_op(color, needsDistance, viewMatrix, rrect, GrTest::TestStrokeRec(random));
 }
 
 #endif
index 38b3075..e4d11de 100644 (file)
@@ -7,10 +7,10 @@
 
 #include "GrPLSPathRenderer.h"
 
-#include "GrBatchTest.h"
 #include "GrCaps.h"
 #include "GrContext.h"
 #include "GrDefaultGeoProcFactory.h"
+#include "GrDrawOpTest.h"
 #include "GrInvariantOutput.h"
 #include "GrOpFlushState.h"
 #include "GrPLSGeometryProcessor.h"
@@ -948,12 +948,12 @@ bool GrPLSPathRenderer::onDrawPath(const DrawPathArgs& args) {
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(PLSPathOp) {
+DRAW_OP_TEST_DEFINE(PLSPathOp) {
     GrColor color = GrRandomColor(random);
     SkMatrix vm = GrTest::TestMatrixInvertible(random);
     SkPath path = GrTest::TestPathConvex(random);
 
-    return PLSPathOp::Make(color, path, vm).release();
+    return PLSPathOp::Make(color, path, vm);
 }
 
 #endif
index e099edb..302f174 100755 (executable)
@@ -7,7 +7,7 @@
 
 #include "GrShadowRRectOp.h"
 
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
 #include "GrOpFlushState.h"
 #include "GrResourceProvider.h"
 #include "GrStyle.h"
@@ -931,7 +931,7 @@ sk_sp<GrDrawOp> Make(GrColor color,
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(ShadowCircleOp) {
+DRAW_OP_TEST_DEFINE(ShadowCircleOp) {
     do {
         SkScalar rotate = random->nextSScalar1() * 360.f;
         SkScalar translateX = random->nextSScalar1() * 1000.f;
@@ -950,19 +950,18 @@ DRAW_BATCH_TEST_DEFINE(ShadowCircleOp) {
         sk_sp<GrDrawOp> op = ShadowCircleOp::Make(color, viewMatrix, center, radius, blurRadius,
                                                   GrStyle(stroke, nullptr));
         if (op) {
-            return op.release();
+            return op;
         }
     } while (true);
 }
 
-DRAW_BATCH_TEST_DEFINE(ShadowRRectOp) {
+DRAW_OP_TEST_DEFINE(ShadowRRectOp) {
     SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
     GrColor color = GrRandomColor(random);
     const SkRRect& rrect = GrTest::TestRRectSimple(random);
     SkScalar blurRadius = random->nextSScalar1() * 72.f;
     return make_shadow_rrect_batch(color, viewMatrix, rrect, blurRadius,
-                                   GrTest::TestStrokeRec(random))
-            .release();
+                                   GrTest::TestStrokeRec(random));
 }
 
 #endif
index 5f6eb58..1de24da 100644 (file)
@@ -8,9 +8,9 @@
 #include "GrTessellatingPathRenderer.h"
 
 #include "GrAuditTrail.h"
-#include "GrBatchTest.h"
 #include "GrClip.h"
 #include "GrDefaultGeoProcFactory.h"
+#include "GrDrawOpTest.h"
 #include "GrMesh.h"
 #include "GrOpFlushState.h"
 #include "GrPathUtils.h"
@@ -376,7 +376,7 @@ bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(TesselatingPathOp) {
+DRAW_OP_TEST_DEFINE(TesselatingPathOp) {
     GrColor color = GrRandomColor(random);
     SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
     SkPath path = GrTest::TestPath(random);
@@ -389,7 +389,7 @@ DRAW_BATCH_TEST_DEFINE(TesselatingPathOp) {
         GrTest::TestStyle(random, &style);
     } while (!style.isSimpleFill());
     GrShape shape(path, style);
-    return TessellatingPathOp::Make(color, shape, viewMatrix, devClipBounds, antiAlias).release();
+    return TessellatingPathOp::Make(color, shape, viewMatrix, devClipBounds, antiAlias);
 }
 
 #endif
index 032a983..e1a3675 100644 (file)
@@ -376,7 +376,7 @@ void GrAtlasTextContext::drawPosText(GrContext* context,
 
 #ifdef GR_TEST_UTILS
 
-DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
+DRAW_OP_TEST_DEFINE(TextBlobOp) {
     static uint32_t gContextID = SK_InvalidGenID;
     static GrAtlasTextContext* gTextContext = nullptr;
     static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
@@ -419,19 +419,14 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
 
     // right now we don't handle textblobs, nor do we handle drawPosText.  Since we only
     // intend to test the batch with this unit test, that is okay.
-    sk_sp<GrAtlasTextBlob> blob(
-        GrAtlasTextContext::CreateDrawTextBlob(context->getTextBlobCache(),
-                                               context->getAtlasGlyphCache(),
-                                               *context->caps()->shaderCaps(), grPaint, skPaint,
-                                               GrAtlasTextContext::kTextBlobBatchScalerContextFlags,
-                                               viewMatrix,
-                                               gSurfaceProps, text,
-                                               static_cast<size_t>(textLen), x, y));
-
-    return blob
-            ->test_makeOp(textLen, 0, 0, viewMatrix, x, y, color, skPaint, gSurfaceProps,
-                          gTextContext->dfAdjustTable(), context->getAtlasGlyphCache())
-            .release();
+    sk_sp<GrAtlasTextBlob> blob(GrAtlasTextContext::CreateDrawTextBlob(
+            context->getTextBlobCache(), context->getAtlasGlyphCache(),
+            *context->caps()->shaderCaps(), grPaint, skPaint,
+            GrAtlasTextContext::kTextBlobOpScalerContextFlags, viewMatrix, gSurfaceProps, text,
+            static_cast<size_t>(textLen), x, y));
+
+    return blob->test_makeOp(textLen, 0, 0, viewMatrix, x, y, color, skPaint, gSurfaceProps,
+                             gTextContext->dfAdjustTable(), context->getAtlasGlyphCache());
 }
 
 #endif
index 471d9d2..0417935 100644 (file)
@@ -14,7 +14,7 @@
 #include "SkTextBlobRunIterator.h"
 
 #ifdef GR_TEST_UTILS
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
 #endif
 
 class GrDrawOp;
@@ -89,9 +89,9 @@ private:
     sk_sp<const GrDistanceFieldAdjustTable> fDistanceAdjustTable;
 
 #ifdef GR_TEST_UTILS
-    static const uint32_t kTextBlobBatchScalerContextFlags =
-        SkPaint::kFakeGammaAndBoostContrast_ScalerContextFlags;
-    DRAW_BATCH_TEST_FRIEND(TextBlobBatch);
+    static const uint32_t kTextBlobOpScalerContextFlags =
+            SkPaint::kFakeGammaAndBoostContrast_ScalerContextFlags;
+    DRAW_OP_TEST_FRIEND(TextBlobOp);
 #endif
 };
 
index 3e47dd7..f981793 100644 (file)
 #if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
 
 #include "GrAutoLocaleSetter.h"
-#include "GrBatchTest.h"
 #include "GrContextFactory.h"
 #include "GrContextPriv.h"
-#include "GrRenderTargetContextPriv.h"
+#include "GrDrawOpTest.h"
 #include "GrDrawingManager.h"
 #include "GrInvariantOutput.h"
 #include "GrPipeline.h"
+#include "GrRenderTargetContextPriv.h"
 #include "GrResourceProvider.h"
 #include "GrTest.h"
 #include "GrXferProcessor.h"
@@ -327,7 +327,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
 
         GrPaint grPaint;
 
-        sk_sp<GrDrawOp> op(GrRandomDrawBatch(&random, context));
+        sk_sp<GrDrawOp> op(GrRandomDrawOp(&random, context));
         SkASSERT(op);
 
         GrProcessorTestData ptd(&random, context, context->caps(),
@@ -363,7 +363,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
     for (int i = 0; i < fpFactoryCnt; ++i) {
         // Since FP factories internally randomize, call each 10 times.
         for (int j = 0; j < 10; ++j) {
-            sk_sp<GrDrawOp> op(GrRandomDrawBatch(&random, context));
+            sk_sp<GrDrawOp> op(GrRandomDrawOp(&random, context));
             SkASSERT(op);
             GrProcessorTestData ptd(&random, context, context->caps(),
                                     renderTargetContext.get(), dummyTextures);