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>
"$_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",
"$_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",
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
* 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"
#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"
#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
#include "GrAADistanceFieldPathRenderer.h"
-#include "GrBatchTest.h"
#include "GrBuffer.h"
#include "GrContext.h"
+#include "GrDrawOpTest.h"
#include "GrOpFlushState.h"
#include "GrPipelineBuilder.h"
#include "GrResourceProvider.h"
ShapeDataList fShapeList;
};
-DRAW_BATCH_TEST_DEFINE(AADistanceFieldPathOp) {
+DRAW_OP_TEST_DEFINE(AADistanceFieldPathOp) {
static PathTestStruct gTestStruct;
if (context->uniqueID() != gTestStruct.fContextID) {
gTestStruct.fAtlas.get(),
&gTestStruct.fShapeCache,
&gTestStruct.fShapeList,
- gammaCorrect)
- .release();
+ gammaCorrect);
}
#endif
#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
#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"
#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
#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"
#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);
}
return AAFlatteningConvexPathOp::Make(color, viewMatrix, path, strokeWidth, style, join,
- miterLimit)
- .release();
+ miterLimit);
}
#endif
#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.
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
#include "GrAnalyticRectOp.h"
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
#include "GrGeometryProcessor.h"
#include "GrInvariantOutput.h"
#include "GrOpFlushState.h"
#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
#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"
#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));
GrStyle style(p);
- return GrDashOp::MakeDashLineOp(color, viewMatrix, pts, aaMode, style).release();
+ return GrDashOp::MakeDashLineOp(color, viewMatrix, pts, aaMode, style);
}
#endif
#include "GrDefaultPathRenderer.h"
-#include "GrBatchTest.h"
#include "GrContext.h"
#include "GrDefaultGeoProcFactory.h"
+#include "GrDrawOpTest.h"
#include "GrFixedClip.h"
#include "GrMesh.h"
#include "GrOpFlushState.h"
#ifdef GR_TEST_UTILS
-DRAW_BATCH_TEST_DEFINE(DefaultPathOp) {
+DRAW_OP_TEST_DEFINE(DefaultPathOp) {
GrColor color = GrRandomColor(random);
SkMatrix viewMatrix = GrTest::TestMatrix(random);
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
*/
#include "GrDrawAtlasOp.h"
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
#include "GrOpFlushState.h"
#include "SkGr.h"
#include "SkRSXform.h"
}
}
-DRAW_BATCH_TEST_DEFINE(GrDrawAtlasOp) {
+DRAW_OP_TEST_DEFINE(GrDrawAtlasOp) {
uint32_t spriteCount = random->nextRangeU(1, 100);
SkTArray<SkRSXform> xforms(spriteCount);
GrColor color = GrRandomColor(random);
return GrDrawAtlasOp::Make(color, viewMatrix, spriteCount, xforms.begin(), texRects.begin(),
- hasColors ? colors.begin() : nullptr)
- .release();
+ hasColors ? colors.begin() : nullptr);
}
#endif
#ifdef GR_TEST_UTILS
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
static uint32_t seed_vertices(GrPrimitiveType type) {
switch (type) {
}
}
-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);
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
#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);
viewMatrix,
rect,
hasLocalRect ? &localRect : nullptr,
- hasLocalMatrix ? &localMatrix : nullptr)
- .release();
+ hasLocalMatrix ? &localMatrix : nullptr);
}
#endif
#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);
bool hasLocalRect = random->nextBool();
return GrNonAAFillRectOp::MakeWithPerspective(color, viewMatrix, rect,
hasLocalRect ? &localRect : nullptr,
- hasLocalMatrix ? &localMatrix : nullptr)
- .release();
+ hasLocalMatrix ? &localMatrix : nullptr);
}
#endif
#include "GrNonAAStrokeRectOp.h"
-#include "GrBatchTest.h"
#include "GrColor.h"
#include "GrDefaultGeoProcFactory.h"
+#include "GrDrawOpTest.h"
#include "GrMeshDrawOp.h"
#include "GrOpFlushState.h"
#include "SkRandom.h"
#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);
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
#include "GrOvalOpFactory.h"
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
#include "GrGeometryProcessor.h"
#include "GrInvariantOutput.h"
#include "GrOpFlushState.h"
#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;
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
#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"
#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
#include "GrShadowRRectOp.h"
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
#include "GrOpFlushState.h"
#include "GrResourceProvider.h"
#include "GrStyle.h"
#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;
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
#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"
#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);
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
#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);
// 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
#include "SkTextBlobRunIterator.h"
#ifdef GR_TEST_UTILS
-#include "GrBatchTest.h"
+#include "GrDrawOpTest.h"
#endif
class GrDrawOp;
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
};
#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"
GrPaint grPaint;
- sk_sp<GrDrawOp> op(GrRandomDrawBatch(&random, context));
+ sk_sp<GrDrawOp> op(GrRandomDrawOp(&random, context));
SkASSERT(op);
GrProcessorTestData ptd(&random, context, context->caps(),
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);