diff options
author | robertphillips <robertphillips@google.com> | 2016-04-27 10:47:51 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-27 10:47:51 -0700 |
commit | 6c7e325236b7fbb9c9b14ebb4715f88a59718695 (patch) | |
tree | 892db20f12b2f02968a3d67b54719aca3a84a8df /tests | |
parent | b4bb7d825566042ed64697be49457dbac060e6c4 (diff) |
Bring sk_sp to GrDrawContext
This is split out of: https://codereview.chromium.org/1914883002/ (Refactor drawContext/RenderTarget creation)
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1918003003
Review-Url: https://codereview.chromium.org/1918003003
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ClearTest.cpp | 56 | ||||
-rw-r--r-- | tests/GLProgramsTest.cpp | 14 | ||||
-rw-r--r-- | tests/PrimitiveProcessorTest.cpp | 2 | ||||
-rw-r--r-- | tests/RectangleTextureTest.cpp | 3 |
4 files changed, 38 insertions, 37 deletions
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp index 56f2fe17be..1065d940ba 100644 --- a/tests/ClearTest.cpp +++ b/tests/ClearTest.cpp @@ -39,7 +39,7 @@ static bool check_rect(GrDrawContext* dc, const SkIRect& rect, uint32_t expected // We only really need the DC, but currently the DC doesn't own the RT so we also ref it, but that // could be dropped when DC is a proper owner of its RT. -static bool reset_dc(SkAutoTUnref<GrDrawContext>* dc, SkAutoTUnref<GrSurface>* rtKeepAlive, +static bool reset_dc(sk_sp<GrDrawContext>* dc, SkAutoTUnref<GrSurface>* rtKeepAlive, GrContext* context, int w, int h) { SkDEBUGCODE(uint32_t oldID = 0;) if (*dc) { @@ -61,7 +61,7 @@ static bool reset_dc(SkAutoTUnref<GrDrawContext>* dc, SkAutoTUnref<GrSurface>* r } GrRenderTarget* rt = (*rtKeepAlive)->asRenderTarget(); SkASSERT(rt->getUniqueID() != oldID); - dc->reset(context->drawContext(rt)); + *dc = context->drawContext(sk_ref_sp(rt)); return *dc != nullptr; } @@ -71,7 +71,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { static const int kH = 10; SkIRect fullRect = SkIRect::MakeWH(kW, kH); - SkAutoTUnref<GrDrawContext> drawContext; + sk_sp<GrDrawContext> drawContext; SkAutoTUnref<GrSurface> rtKeepAlive; // A rectangle that is inset by one on all sides and the 1-pixel wide rectangles that surround @@ -102,7 +102,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { } // Check a full clear drawContext->clear(&fullRect, kColor1, false); - if (!check_rect(drawContext, fullRect, kColor1, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } @@ -114,7 +114,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { // Check two full clears, same color drawContext->clear(&fullRect, kColor1, false); drawContext->clear(&fullRect, kColor1, false); - if (!check_rect(drawContext, fullRect, kColor1, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } @@ -126,7 +126,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { // Check two full clears, different colors drawContext->clear(&fullRect, kColor1, false); drawContext->clear(&fullRect, kColor2, false); - if (!check_rect(drawContext, fullRect, kColor2, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), fullRect, kColor2, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, failX, failY); } @@ -138,7 +138,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { // Test a full clear followed by a same color inset clear drawContext->clear(&fullRect, kColor1, false); drawContext->clear(&mid1Rect, kColor1, false); - if (!check_rect(drawContext, fullRect, kColor1, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } @@ -150,7 +150,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { // Test a inset clear followed by same color full clear drawContext->clear(&mid1Rect, kColor1, false); drawContext->clear(&fullRect, kColor1, false); - if (!check_rect(drawContext, fullRect, kColor1, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } @@ -162,14 +162,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { // Test a full clear followed by a different color inset clear drawContext->clear(&fullRect, kColor1, false); drawContext->clear(&mid1Rect, kColor2, false); - if (!check_rect(drawContext, mid1Rect, kColor2, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, failX, failY); } - if (!check_rect(drawContext, outerLeftEdge, kColor1, &actualValue, &failX, &failY) || - !check_rect(drawContext, outerTopEdge, kColor1, &actualValue, &failX, &failY) || - !check_rect(drawContext, outerRightEdge, kColor1, &actualValue, &failX, &failY) || - !check_rect(drawContext, outerBottomEdge, kColor1, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } @@ -181,7 +181,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { // Test a inset clear followed by a different full clear drawContext->clear(&mid1Rect, kColor2, false); drawContext->clear(&fullRect, kColor1, false); - if (!check_rect(drawContext, fullRect, kColor1, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } @@ -195,21 +195,21 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { drawContext->clear(&fullRect, kColor1, false); drawContext->clear(&mid1Rect, kColor2, false); drawContext->clear(&mid2Rect, kColor1, false); - if (!check_rect(drawContext, mid2Rect, kColor1, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), mid2Rect, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } - if (!check_rect(drawContext, innerLeftEdge, kColor2, &actualValue, &failX, &failY) || - !check_rect(drawContext, innerTopEdge, kColor2, &actualValue, &failX, &failY) || - !check_rect(drawContext, innerRightEdge, kColor2, &actualValue, &failX, &failY) || - !check_rect(drawContext, innerBottomEdge, kColor2, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), innerLeftEdge, kColor2, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), innerTopEdge, kColor2, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), innerRightEdge, kColor2, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), innerBottomEdge, kColor2, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, failX, failY); } - if (!check_rect(drawContext, outerLeftEdge, kColor1, &actualValue, &failX, &failY) || - !check_rect(drawContext, outerTopEdge, kColor1, &actualValue, &failX, &failY) || - !check_rect(drawContext, outerRightEdge, kColor1, &actualValue, &failX, &failY) || - !check_rect(drawContext, outerBottomEdge, kColor1, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } @@ -222,14 +222,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { drawContext->clear(&fullRect, kColor1, false); drawContext->clear(&mid2Rect, kColor1, false); drawContext->clear(&mid1Rect, kColor2, false); - if (!check_rect(drawContext, mid1Rect, kColor2, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, failX, failY); } - if (!check_rect(drawContext, outerLeftEdge, kColor1, &actualValue, &failX, &failY) || - !check_rect(drawContext, outerTopEdge, kColor1, &actualValue, &failX, &failY) || - !check_rect(drawContext, outerRightEdge, kColor1, &actualValue, &failX, &failY) || - !check_rect(drawContext, outerBottomEdge, kColor1, &actualValue, &failX, &failY)) { + if (!check_rect(drawContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(drawContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 8e7d800814..0d825c6551 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -334,7 +334,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { static const int NUM_TESTS = 1024; for (int t = 0; t < NUM_TESTS; t++) { // setup random render target(can fail) - SkAutoTUnref<GrRenderTarget> rt(random_render_target( + sk_sp<GrRenderTarget> rt(random_render_target( context->textureProvider(), &random, context->caps())); if (!rt.get()) { SkDebugf("Could not allocate render target"); @@ -348,13 +348,13 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); SkASSERT(batch); - GrProcessorTestData ptd(&random, context, context->caps(), rt, dummyTextures); + GrProcessorTestData ptd(&random, context, context->caps(), rt.get(), dummyTextures); set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages); set_random_xpf(&pipelineBuilder, &ptd); set_random_state(&pipelineBuilder, &random); set_random_stencil(&pipelineBuilder, &random); - SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(rt)); + sk_sp<GrDrawContext> drawContext(context->drawContext(rt)); if (!drawContext) { SkDebugf("Could not allocate drawContext"); return false; @@ -371,7 +371,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { rtDesc.fHeight = kRenderTargetHeight; rtDesc.fFlags = kRenderTarget_GrSurfaceFlag; rtDesc.fConfig = kRGBA_8888_GrPixelConfig; - SkAutoTUnref<GrRenderTarget> rt( + sk_sp<GrRenderTarget> rt( context->textureProvider()->createTexture(rtDesc, SkBudgeted::kNo)->asRenderTarget()); int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count(); for (int i = 0; i < fpFactoryCnt; ++i) { @@ -379,10 +379,10 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { for (int j = 0; j < 10; ++j) { SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); SkASSERT(batch); - GrProcessorTestData ptd(&random, context, context->caps(), rt, dummyTextures); + GrProcessorTestData ptd(&random, context, context->caps(), rt.get(), dummyTextures); GrPipelineBuilder builder; builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref(); - builder.setRenderTarget(rt); + builder.setRenderTarget(rt.get()); builder.setClip(clip); SkAutoTUnref<const GrFragmentProcessor> fp( @@ -391,7 +391,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { BlockInputFragmentProcessor::Create(fp)); builder.addColorFragmentProcessor(blockFP); - SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(rt)); + sk_sp<GrDrawContext> drawContext(context->drawContext(rt)); if (!drawContext) { SkDebugf("Could not allocate a drawcontext"); return false; diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index f8c19e3171..6d4ede1ce9 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -114,7 +114,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { ERRORF(reporter, "Could not create render target."); return; } - SkAutoTUnref<GrDrawContext> dc(context->drawContext(target->asRenderTarget())); + sk_sp<GrDrawContext> dc(context->drawContext(sk_ref_sp(target->asRenderTarget()))); if (!dc) { ERRORF(reporter, "Could not create draw context."); return; diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp index 3c2a50d630..8c3bdd6a4a 100644 --- a/tests/RectangleTextureTest.cpp +++ b/tests/RectangleTextureTest.cpp @@ -89,7 +89,8 @@ static void test_copy_surface_dst(skiatest::Reporter* reporter, GrContext* conte static void test_clear(skiatest::Reporter* reporter, GrContext* context, GrTexture* rectangleTexture) { if (rectangleTexture->asRenderTarget()) { - SkAutoTUnref<GrDrawContext> dc(context->drawContext(rectangleTexture->asRenderTarget())); + sk_sp<GrDrawContext> dc( + context->drawContext(sk_ref_sp(rectangleTexture->asRenderTarget()))); if (!dc) { ERRORF(reporter, "Could not get GrDrawContext for rectangle texture."); return; |