diff options
author | Brian Salomon <bsalomon@google.com> | 2016-12-20 15:34:05 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-12-20 21:10:56 +0000 |
commit | 5ec9def2dd7bba572398ff2aa9361fbbb3b478ed (patch) | |
tree | 8e6105038fca868682ddf3a8306dce11b2e075ae /src/gpu | |
parent | 8c5bad35f5d98040f2db2ffd3ba9a924c7436784 (diff) |
Rename files, macros, types, and functions related to GrDrawOp testing.
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>
Diffstat (limited to 'src/gpu')
25 files changed, 180 insertions, 199 deletions
diff --git a/src/gpu/GrBatchTest.cpp b/src/gpu/GrBatchTest.cpp deleted file mode 100644 index 562c56990d..0000000000 --- a/src/gpu/GrBatchTest.cpp +++ /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 index 5d7fa634b5..0000000000 --- a/src/gpu/GrBatchTest.h +++ /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 index 0000000000..bb26acc696 --- /dev/null +++ b/src/gpu/GrDrawOpTest.cpp @@ -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 index 0000000000..0d88a40bf1 --- /dev/null +++ b/src/gpu/GrDrawOpTest.h @@ -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 diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 60a213fd47..10881de087 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -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" diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp index 40f4284b31..fd4083bf80 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp @@ -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 diff --git a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp index 678c920867..00d3ed7b97 100644 --- a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp @@ -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 diff --git a/src/gpu/ops/GrAAFillRectOp.cpp b/src/gpu/ops/GrAAFillRectOp.cpp index 9f7b0e0205..d45954ca72 100644 --- a/src/gpu/ops/GrAAFillRectOp.cpp +++ b/src/gpu/ops/GrAAFillRectOp.cpp @@ -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 diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp index 7707afa6e2..b5a797859e 100644 --- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp @@ -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 diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp index c2473535f7..8f2ab86a8b 100644 --- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp @@ -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 diff --git a/src/gpu/ops/GrAAStrokeRectOp.cpp b/src/gpu/ops/GrAAStrokeRectOp.cpp index 252889240c..56606795f2 100644 --- a/src/gpu/ops/GrAAStrokeRectOp.cpp +++ b/src/gpu/ops/GrAAStrokeRectOp.cpp @@ -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 diff --git a/src/gpu/ops/GrAnalyticRectOp.cpp b/src/gpu/ops/GrAnalyticRectOp.cpp index 63e15482b2..9c4e66cc84 100644 --- a/src/gpu/ops/GrAnalyticRectOp.cpp +++ b/src/gpu/ops/GrAnalyticRectOp.cpp @@ -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 diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp index 92184825ac..8052795ead 100644 --- a/src/gpu/ops/GrDashOp.cpp +++ b/src/gpu/ops/GrDashOp.cpp @@ -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 diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp index b979d9171d..4803c0da4e 100644 --- a/src/gpu/ops/GrDefaultPathRenderer.cpp +++ b/src/gpu/ops/GrDefaultPathRenderer.cpp @@ -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 diff --git a/src/gpu/ops/GrDrawAtlasOp.cpp b/src/gpu/ops/GrDrawAtlasOp.cpp index 3dafbda732..e01ad73671 100644 --- a/src/gpu/ops/GrDrawAtlasOp.cpp +++ b/src/gpu/ops/GrDrawAtlasOp.cpp @@ -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 diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp index 37be6d0d17..c6ae1c1efa 100644 --- a/src/gpu/ops/GrDrawVerticesOp.cpp +++ b/src/gpu/ops/GrDrawVerticesOp.cpp @@ -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 diff --git a/src/gpu/ops/GrNonAAFillRectOp.cpp b/src/gpu/ops/GrNonAAFillRectOp.cpp index de000e2ce7..e672985507 100644 --- a/src/gpu/ops/GrNonAAFillRectOp.cpp +++ b/src/gpu/ops/GrNonAAFillRectOp.cpp @@ -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 diff --git a/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp b/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp index 443c511ec4..fde4328abf 100644 --- a/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp +++ b/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp @@ -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 diff --git a/src/gpu/ops/GrNonAAStrokeRectOp.cpp b/src/gpu/ops/GrNonAAStrokeRectOp.cpp index b74cd502c8..065f08a9ee 100644 --- a/src/gpu/ops/GrNonAAStrokeRectOp.cpp +++ b/src/gpu/ops/GrNonAAStrokeRectOp.cpp @@ -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 diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp index 7a53ca6655..10fc37572a 100644 --- a/src/gpu/ops/GrOvalOpFactory.cpp +++ b/src/gpu/ops/GrOvalOpFactory.cpp @@ -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 diff --git a/src/gpu/ops/GrPLSPathRenderer.cpp b/src/gpu/ops/GrPLSPathRenderer.cpp index 38b3075698..e4d11de3b1 100644 --- a/src/gpu/ops/GrPLSPathRenderer.cpp +++ b/src/gpu/ops/GrPLSPathRenderer.cpp @@ -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 diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp index e099edb000..302f1741e3 100755 --- a/src/gpu/ops/GrShadowRRectOp.cpp +++ b/src/gpu/ops/GrShadowRRectOp.cpp @@ -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 diff --git a/src/gpu/ops/GrTessellatingPathRenderer.cpp b/src/gpu/ops/GrTessellatingPathRenderer.cpp index 5f6eb581e3..1de24da1c1 100644 --- a/src/gpu/ops/GrTessellatingPathRenderer.cpp +++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp @@ -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 diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp index 032a9839d6..e1a3675d40 100644 --- a/src/gpu/text/GrAtlasTextContext.cpp +++ b/src/gpu/text/GrAtlasTextContext.cpp @@ -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 diff --git a/src/gpu/text/GrAtlasTextContext.h b/src/gpu/text/GrAtlasTextContext.h index 471d9d2014..0417935ea7 100644 --- a/src/gpu/text/GrAtlasTextContext.h +++ b/src/gpu/text/GrAtlasTextContext.h @@ -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 }; |