diff options
author | Brian Osman <brianosman@google.com> | 2016-10-27 14:47:55 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-10-27 19:14:09 +0000 |
commit | 1105224f9701e57ec5ce0354d6a380b664f5c638 (patch) | |
tree | 2b6f3db0bfd99da5e22adabc0da37d9271c8b543 /tests | |
parent | 6e74412a9cf1ffa44271a55b42f18e8a0813a0a2 (diff) |
Rename GrDrawContext to GrRenderTargetContext
This is in preparation for GrTextureContext and GrSurfaceContext
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4030
Change-Id: Ie58c93052e68f3f1f5fe8d15d63760de274a6fbd
Reviewed-on: https://skia-review.googlesource.com/4030
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ClearTest.cpp | 147 | ||||
-rw-r--r-- | tests/DFPathRendererTest.cpp | 23 | ||||
-rw-r--r-- | tests/GLProgramsTest.cpp | 56 | ||||
-rw-r--r-- | tests/PrimitiveProcessorTest.cpp | 19 | ||||
-rw-r--r-- | tests/RectangleTextureTest.cpp | 12 | ||||
-rw-r--r-- | tests/SRGBMipMapTest.cpp | 26 | ||||
-rw-r--r-- | tests/SurfaceTest.cpp | 19 | ||||
-rw-r--r-- | tests/TessellatingPathRendererTests.cpp | 56 |
8 files changed, 184 insertions, 174 deletions
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp index b9ece6bce3..4a6e26c86a 100644 --- a/tests/ClearTest.cpp +++ b/tests/ClearTest.cpp @@ -9,15 +9,15 @@ #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrDrawContext.h" +#include "GrRenderTargetContext.h" #include "GrGpu.h" #include "GrRenderTarget.h" #include "GrTexture.h" #include "GrTextureProvider.h" -static bool check_rect(GrDrawContext* dc, const SkIRect& rect, uint32_t expectedValue, +static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t expectedValue, uint32_t* actualValue, int* failX, int* failY) { - GrRenderTarget* rt = dc->accessRenderTarget(); + GrRenderTarget* rt = rtc->accessRenderTarget(); int w = rect.width(); int h = rect.height(); SkAutoTDeleteArray<uint32_t> pixels(new uint32_t[w * h]); @@ -37,19 +37,20 @@ static bool check_rect(GrDrawContext* dc, const SkIRect& rect, uint32_t expected return true; } -static bool reset_dc(sk_sp<GrDrawContext>* dc, GrContext* context, int w, int h) { +static bool reset_rtc(sk_sp<GrRenderTargetContext>* rtc, GrContext* context, int w, int h) { SkDEBUGCODE(uint32_t oldID = 0;) - if (*dc) { - SkDEBUGCODE(oldID = (*dc)->accessRenderTarget()->uniqueID();) - dc->reset(nullptr); + if (*rtc) { + SkDEBUGCODE(oldID = (*rtc)->accessRenderTarget()->uniqueID();) + rtc->reset(nullptr); } context->freeGpuResources(); - *dc = context->makeDrawContext(SkBackingFit::kExact, w, h, kRGBA_8888_GrPixelConfig, nullptr); + *rtc = context->makeRenderTargetContext(SkBackingFit::kExact, w, h, kRGBA_8888_GrPixelConfig, + nullptr); - SkASSERT((*dc)->accessRenderTarget()->uniqueID() != oldID); + SkASSERT((*rtc)->accessRenderTarget()->uniqueID() != oldID); - return *dc != nullptr; + return *rtc != nullptr; } DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { @@ -58,7 +59,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { static const int kH = 10; SkIRect fullRect = SkIRect::MakeWH(kW, kH); - sk_sp<GrDrawContext> drawContext; + sk_sp<GrRenderTargetContext> rtContext; // A rectangle that is inset by one on all sides and the 1-pixel wide rectangles that surround // it. @@ -82,140 +83,140 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { static const GrColor kColor1 = 0xABCDEF01; static const GrColor kColor2 = ~kColor1; - if (!reset_dc(&drawContext, context, kW, kH)) { - ERRORF(reporter, "Could not create draw context."); + if (!reset_rtc(&rtContext, context, kW, kH)) { + ERRORF(reporter, "Could not create render target context."); return; } // Check a full clear - drawContext->clear(&fullRect, kColor1, false); - if (!check_rect(drawContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { + rtContext->clear(&fullRect, kColor1, false); + if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } - if (!reset_dc(&drawContext, context, kW, kH)) { - ERRORF(reporter, "Could not create draw context."); + if (!reset_rtc(&rtContext, context, kW, kH)) { + ERRORF(reporter, "Could not create render target context."); return; } // Check two full clears, same color - drawContext->clear(&fullRect, kColor1, false); - drawContext->clear(&fullRect, kColor1, false); - if (!check_rect(drawContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { + rtContext->clear(&fullRect, kColor1, false); + rtContext->clear(&fullRect, kColor1, false); + if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } - if (!reset_dc(&drawContext, context, kW, kH)) { - ERRORF(reporter, "Could not create draw context."); + if (!reset_rtc(&rtContext, context, kW, kH)) { + ERRORF(reporter, "Could not create render target context."); return; } // Check two full clears, different colors - drawContext->clear(&fullRect, kColor1, false); - drawContext->clear(&fullRect, kColor2, false); - if (!check_rect(drawContext.get(), fullRect, kColor2, &actualValue, &failX, &failY)) { + rtContext->clear(&fullRect, kColor1, false); + rtContext->clear(&fullRect, kColor2, false); + if (!check_rect(rtContext.get(), fullRect, kColor2, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, failX, failY); } - if (!reset_dc(&drawContext, context, kW, kH)) { - ERRORF(reporter, "Could not create draw context."); + if (!reset_rtc(&rtContext, context, kW, kH)) { + ERRORF(reporter, "Could not create render target context."); return; } // 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.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { + rtContext->clear(&fullRect, kColor1, false); + rtContext->clear(&mid1Rect, kColor1, false); + if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } - if (!reset_dc(&drawContext, context, kW, kH)) { - ERRORF(reporter, "Could not create draw context."); + if (!reset_rtc(&rtContext, context, kW, kH)) { + ERRORF(reporter, "Could not create render target context."); return; } // Test a inset clear followed by same color full clear - drawContext->clear(&mid1Rect, kColor1, false); - drawContext->clear(&fullRect, kColor1, false); - if (!check_rect(drawContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { + rtContext->clear(&mid1Rect, kColor1, false); + rtContext->clear(&fullRect, kColor1, false); + if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } - if (!reset_dc(&drawContext, context, kW, kH)) { - ERRORF(reporter, "Could not create draw context."); + if (!reset_rtc(&rtContext, context, kW, kH)) { + ERRORF(reporter, "Could not create render target context."); return; } // 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.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) { + rtContext->clear(&fullRect, kColor1, false); + rtContext->clear(&mid1Rect, kColor2, false); + if (!check_rect(rtContext.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.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)) { + if (!check_rect(rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(rtContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } - if (!reset_dc(&drawContext, context, kW, kH)) { - ERRORF(reporter, "Could not create draw context."); + if (!reset_rtc(&rtContext, context, kW, kH)) { + ERRORF(reporter, "Could not create render target context."); return; } // Test a inset clear followed by a different full clear - drawContext->clear(&mid1Rect, kColor2, false); - drawContext->clear(&fullRect, kColor1, false); - if (!check_rect(drawContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { + rtContext->clear(&mid1Rect, kColor2, false); + rtContext->clear(&fullRect, kColor1, false); + if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } - if (!reset_dc(&drawContext, context, kW, kH)) { - ERRORF(reporter, "Could not create draw context."); + if (!reset_rtc(&rtContext, context, kW, kH)) { + ERRORF(reporter, "Could not create render target context."); return; } // Check three nested clears from largest to smallest where outermost and innermost are same // color. - drawContext->clear(&fullRect, kColor1, false); - drawContext->clear(&mid1Rect, kColor2, false); - drawContext->clear(&mid2Rect, kColor1, false); - if (!check_rect(drawContext.get(), mid2Rect, kColor1, &actualValue, &failX, &failY)) { + rtContext->clear(&fullRect, kColor1, false); + rtContext->clear(&mid1Rect, kColor2, false); + rtContext->clear(&mid2Rect, kColor1, false); + if (!check_rect(rtContext.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.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)) { + if (!check_rect(rtContext.get(), innerLeftEdge, kColor2, &actualValue, &failX, &failY) || + !check_rect(rtContext.get(), innerTopEdge, kColor2, &actualValue, &failX, &failY) || + !check_rect(rtContext.get(), innerRightEdge, kColor2, &actualValue, &failX, &failY) || + !check_rect(rtContext.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.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)) { + if (!check_rect(rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(rtContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) { ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, failX, failY); } - if (!reset_dc(&drawContext, context, kW, kH)) { - ERRORF(reporter, "Could not create draw context."); + if (!reset_rtc(&rtContext, context, kW, kH)) { + ERRORF(reporter, "Could not create render target context."); return; } // Swap the order of the second two clears in the above test. - drawContext->clear(&fullRect, kColor1, false); - drawContext->clear(&mid2Rect, kColor1, false); - drawContext->clear(&mid1Rect, kColor2, false); - if (!check_rect(drawContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) { + rtContext->clear(&fullRect, kColor1, false); + rtContext->clear(&mid2Rect, kColor1, false); + rtContext->clear(&mid1Rect, kColor2, false); + if (!check_rect(rtContext.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.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)) { + if (!check_rect(rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) || + !check_rect(rtContext.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/DFPathRendererTest.cpp b/tests/DFPathRendererTest.cpp index 30ca17d346..25c8f82839 100644 --- a/tests/DFPathRendererTest.cpp +++ b/tests/DFPathRendererTest.cpp @@ -17,7 +17,7 @@ // Because of inaccuracies in large floating point values this causes the // the path renderer to attempt to add a path DF to its atlas that is larger // than the plot size which used to crash rather than fail gracefully. -static void test_far_from_origin(GrDrawContext* drawContext, GrPathRenderer* pr, +static void test_far_from_origin(GrRenderTargetContext* renderTargetContext, GrPathRenderer* pr, GrResourceProvider* rp) { SkPath path; path.lineTo(49.0255089839f, 0.473541f); @@ -48,7 +48,7 @@ static void test_far_from_origin(GrDrawContext* drawContext, GrPathRenderer* pr, GrPathRenderer::DrawPathArgs args; args.fPaint = &paint; args.fUserStencilSettings = &GrUserStencilSettings::kUnused; - args.fDrawContext = drawContext; + args.fRenderTargetContext = renderTargetContext; args.fClip = &noClip; args.fResourceProvider = rp; args.fViewMatrix = &matrix; @@ -63,22 +63,23 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(AADistanceFieldPathRenderer, reporter, ctxInfo) if (!ctxInfo.grContext()->caps()->shaderCaps()->shaderDerivativeSupport()) { return; } - sk_sp<GrDrawContext> dc(ctxInfo.grContext()->makeDrawContext(SkBackingFit::kApprox, - 800, 800, - kRGBA_8888_GrPixelConfig, - nullptr, - 0, - kTopLeft_GrSurfaceOrigin)); - if (!dc) { + sk_sp<GrRenderTargetContext> rtc(ctxInfo.grContext()->makeRenderTargetContext( + SkBackingFit::kApprox, + 800, 800, + kRGBA_8888_GrPixelConfig, + nullptr, + 0, + kTopLeft_GrSurfaceOrigin)); + if (!rtc) { return; } GrAADistanceFieldPathRenderer dfpr; GrTestTarget tt; - ctxInfo.grContext()->getTestTarget(&tt, dc); + ctxInfo.grContext()->getTestTarget(&tt, rtc); GrResourceProvider* rp = tt.resourceProvider(); - test_far_from_origin(dc.get(), &dfpr, rp); + test_far_from_origin(rtc.get(), &dfpr, rp); ctxInfo.grContext()->flush(); } #endif diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 9e501cb4b5..fc490614c1 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -15,7 +15,7 @@ #include "GrBatchTest.h" #include "GrContextFactory.h" #include "GrContextPriv.h" -#include "GrDrawContextPriv.h" +#include "GrRenderTargetContextPriv.h" #include "GrDrawingManager.h" #include "GrInvariantOutput.h" #include "GrPipeline.h" @@ -148,21 +148,22 @@ private: static const int kRenderTargetHeight = 1; static const int kRenderTargetWidth = 1; -static sk_sp<GrDrawContext> random_draw_context(GrContext* context, - SkRandom* random, - const GrCaps* caps) { +static sk_sp<GrRenderTargetContext> random_render_target_context(GrContext* context, + SkRandom* random, + const GrCaps* caps) { GrSurfaceOrigin origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin; int sampleCnt = random->nextBool() ? SkTMin(4, caps->maxSampleCount()) : 0; - sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kExact, - kRenderTargetWidth, - kRenderTargetHeight, - kRGBA_8888_GrPixelConfig, - nullptr, - sampleCnt, - origin)); - return drawContext; + sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContext( + SkBackingFit::kExact, + kRenderTargetWidth, + kRenderTargetHeight, + kRGBA_8888_GrPixelConfig, + nullptr, + sampleCnt, + origin)); + return renderTargetContext; } static void set_random_xpf(GrPaint* paint, GrProcessorTestData* d) { @@ -320,9 +321,10 @@ 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) - sk_sp<GrDrawContext> drawContext(random_draw_context(context, &random, context->caps())); - if (!drawContext) { - SkDebugf("Could not allocate drawContext"); + sk_sp<GrRenderTargetContext> renderTargetContext(random_render_target_context( + context, &random, context->caps())); + if (!renderTargetContext) { + SkDebugf("Could not allocate renderTargetContext"); return false; } @@ -332,25 +334,27 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { SkASSERT(batch); GrProcessorTestData ptd(&random, context, context->caps(), - drawContext.get(), dummyTextures); + renderTargetContext.get(), dummyTextures); set_random_color_coverage_stages(&grPaint, &ptd, maxStages); set_random_xpf(&grPaint, &ptd); bool snapToCenters = set_random_state(&grPaint, &random); const GrUserStencilSettings* uss = get_random_stencil(&random); - drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch, uss, snapToCenters); + renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, batch, uss, + snapToCenters); } // Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes) drawingManager->flush(); // Validate that GrFPs work correctly without an input. - sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kExact, - kRenderTargetWidth, - kRenderTargetHeight, - kRGBA_8888_GrPixelConfig, - nullptr)); - if (!drawContext) { - SkDebugf("Could not allocate a drawContext"); + sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContext( + SkBackingFit::kExact, + kRenderTargetWidth, + kRenderTargetHeight, + kRGBA_8888_GrPixelConfig, + nullptr)); + if (!renderTargetContext) { + SkDebugf("Could not allocate a renderTargetContext"); return false; } @@ -361,7 +365,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); SkASSERT(batch); GrProcessorTestData ptd(&random, context, context->caps(), - drawContext.get(), dummyTextures); + renderTargetContext.get(), dummyTextures); GrPaint grPaint; grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); @@ -371,7 +375,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { BlockInputFragmentProcessor::Make(std::move(fp))); grPaint.addColorFragmentProcessor(std::move(blockFP)); - drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, batch); drawingManager->flush(); } } diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index aeaa36f3e5..48a7cfd0a5 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -12,8 +12,8 @@ #if SK_SUPPORT_GPU #include "GrBatchFlushState.h" -#include "GrDrawContext.h" -#include "GrDrawContextPriv.h" +#include "GrRenderTargetContext.h" +#include "GrRenderTargetContextPriv.h" #include "GrContext.h" #include "GrGeometryProcessor.h" #include "GrGpu.h" @@ -104,11 +104,12 @@ private: DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); - sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApprox, - 1, 1, kRGBA_8888_GrPixelConfig, - nullptr)); - if (!drawContext) { - ERRORF(reporter, "Could not create draw context."); + sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContext( + SkBackingFit::kApprox, + 1, 1, kRGBA_8888_GrPixelConfig, + nullptr)); + if (!renderTargetContext) { + ERRORF(reporter, "Could not create render target context."); return; } int attribCnt = context->caps()->maxVertexAttributes(); @@ -126,7 +127,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { GrPaint grPaint; // This one should succeed. batch.reset(new Batch(attribCnt)); - drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, batch); context->flush(); #if GR_GPU_STATS REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1); @@ -135,7 +136,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { context->resetGpuStats(); // This one should fail. batch.reset(new Batch(attribCnt+1)); - drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch); + renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, batch); context->flush(); #if GR_GPU_STATS REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp index 1491326236..8bdcbb3013 100644 --- a/tests/RectangleTextureTest.cpp +++ b/tests/RectangleTextureTest.cpp @@ -9,7 +9,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" #include "GrContextPriv.h" -#include "GrDrawContext.h" +#include "GrRenderTargetContext.h" #include "gl/GrGLGpu.h" #include "gl/GrGLUtil.h" #include "gl/GLTestContext.h" @@ -90,17 +90,17 @@ 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()) { - sk_sp<GrDrawContext> dc(context->contextPriv().makeWrappedDrawContext( + sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeWrappedRenderTargetContext( sk_ref_sp(rectangleTexture->asRenderTarget()), nullptr)); - if (!dc) { - ERRORF(reporter, "Could not get GrDrawContext for rectangle texture."); + if (!rtc) { + ERRORF(reporter, "Could not get GrRenderTargetContext for rectangle texture."); return; } // Clear the whole thing. GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD); - dc->clear(nullptr, color0, false); + rtc->clear(nullptr, color0, false); int w = rectangleTexture->width(); int h = rectangleTexture->height(); @@ -121,7 +121,7 @@ static void test_clear(skiatest::Reporter* reporter, GrContext* context, // Clear the the top to a different color. GrColor color1 = GrColorPackRGBA(0x1, 0x2, 0x3, 0x4); SkIRect rect = SkIRect::MakeWH(w, h/2); - dc->clear(&rect, color1, false); + rtc->clear(&rect, color1, false); uint32_t expectedColor1 = 0; uint8_t* expectedBytes1 = SkTCast<uint8_t*>(&expectedColor1); diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp index 8855c3d15f..a7f846cbe5 100644 --- a/tests/SRGBMipMapTest.cpp +++ b/tests/SRGBMipMapTest.cpp @@ -9,7 +9,7 @@ #if SK_SUPPORT_GPU #include "GrCaps.h" #include "GrContext.h" -#include "GrDrawContext.h" +#include "GrRenderTargetContext.h" #include "SkCanvas.h" #include "SkSurface.h" @@ -121,12 +121,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) { // Create two draw contexts (L32 and S32) sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); - sk_sp<GrDrawContext> l32DrawContext = context->makeDrawContext(SkBackingFit::kExact, rtS, rtS, - kRGBA_8888_GrPixelConfig, - nullptr); - sk_sp<GrDrawContext> s32DrawContext = context->makeDrawContext(SkBackingFit::kExact, rtS, rtS, - kSRGBA_8888_GrPixelConfig, - std::move(srgbColorSpace)); + sk_sp<GrRenderTargetContext> l32RenderTargetContext = context->makeRenderTargetContext( + SkBackingFit::kExact, rtS, rtS, kRGBA_8888_GrPixelConfig, nullptr); + sk_sp<GrRenderTargetContext> s32RenderTargetContext = context->makeRenderTargetContext( + SkBackingFit::kExact, rtS, rtS, kSRGBA_8888_GrPixelConfig, std::move(srgbColorSpace)); SkRect rect = SkRect::MakeWH(SkIntToScalar(rtS), SkIntToScalar(rtS)); GrNoClip noClip; @@ -137,20 +135,20 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) { // 1) Draw texture to S32 surface (should generate/use sRGB mips) paint.setGammaCorrect(true); - s32DrawContext->drawRect(noClip, paint, SkMatrix::I(), rect); - read_and_check_pixels(reporter, s32DrawContext->asTexture().get(), expectedSRGB, error, + s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); + read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), expectedSRGB, error, "first render of sRGB"); // 2) Draw texture to L32 surface (should generate/use linear mips) paint.setGammaCorrect(false); - l32DrawContext->drawRect(noClip, paint, SkMatrix::I(), rect); - read_and_check_pixels(reporter, l32DrawContext->asTexture().get(), expectedLinear, error, - "re-render as linear"); + l32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); + read_and_check_pixels(reporter, l32RenderTargetContext->asTexture().get(), expectedLinear, + error, "re-render as linear"); // 3) Go back to sRGB paint.setGammaCorrect(true); - s32DrawContext->drawRect(noClip, paint, SkMatrix::I(), rect); - read_and_check_pixels(reporter, s32DrawContext->asTexture().get(), expectedSRGB, error, + s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); + read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), expectedSRGB, error, "re-render as sRGB"); } #endif diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 0ccf51f040..a12630389e 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -19,7 +19,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrDrawContext.h" +#include "GrRenderTargetContext.h" #include "GrGpu.h" #include "GrResourceProvider.h" #include <vector> @@ -314,8 +314,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, ctxInfo) { }; auto surfaceBackingStore = [reporter](SkSurface* surface) { - GrDrawContext* dc = surface->getCanvas()->internal_private_accessTopLayerDrawContext(); - GrRenderTarget* rt = dc->accessRenderTarget(); + GrRenderTargetContext* rtc = + surface->getCanvas()->internal_private_accessTopLayerRenderTargetContext(); + GrRenderTarget* rt = rtc->accessRenderTarget(); if (!rt) { ERRORF(reporter, "Not render target backed."); return static_cast<intptr_t>(0); @@ -566,7 +567,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, ctxInfo) { static SkBudgeted is_budgeted(const sk_sp<SkSurface>& surf) { SkSurface_Gpu* gsurf = (SkSurface_Gpu*)surf.get(); - return gsurf->getDevice()->accessDrawContext()->accessRenderTarget()->resourcePriv().isBudgeted(); + return gsurf->getDevice()->accessRenderTargetContext() + ->accessRenderTarget()->resourcePriv().isBudgeted(); } static SkBudgeted is_budgeted(SkImage* image) { @@ -793,8 +795,9 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) { std::function<GrSurface*(SkSurface*)> grSurfaceGetters[] = { [] (SkSurface* s){ - GrDrawContext* dc = s->getCanvas()->internal_private_accessTopLayerDrawContext(); - return dc->accessRenderTarget(); }, + GrRenderTargetContext* rtc = + s->getCanvas()->internal_private_accessTopLayerRenderTargetContext(); + return rtc->accessRenderTarget(); }, [] (SkSurface* s){ sk_sp<SkImage> i(s->makeImageSnapshot()); return as_IB(i)->peekTexture(); } }; @@ -903,8 +906,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInf // Validate that we can attach a stencil buffer to an SkSurface created by either of // our surface functions. - GrRenderTarget* rt = surface->getCanvas()->internal_private_accessTopLayerDrawContext() - ->accessRenderTarget(); + GrRenderTarget* rt = surface->getCanvas() + ->internal_private_accessTopLayerRenderTargetContext()->accessRenderTarget(); REPORTER_ASSERT(reporter, ctxInfo.grContext()->resourceProvider()->attachStencilAttachment(rt)); gpu->deleteTestingOnlyBackendTexture(textureObject); diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp index 5160124b2f..324ea4bce5 100644 --- a/tests/TessellatingPathRendererTests.cpp +++ b/tests/TessellatingPathRendererTests.cpp @@ -249,7 +249,8 @@ static SkPath create_path_16() { return path; } -static void test_path(GrDrawContext* drawContext, GrResourceProvider* rp, const SkPath& path) { +static void test_path(GrRenderTargetContext* renderTargetContext, GrResourceProvider* rp, + const SkPath& path) { GrTessellatingPathRenderer tess; GrPaint paint; @@ -260,7 +261,7 @@ static void test_path(GrDrawContext* drawContext, GrResourceProvider* rp, const GrPathRenderer::DrawPathArgs args; args.fPaint = &paint; args.fUserStencilSettings = &GrUserStencilSettings::kUnused; - args.fDrawContext = drawContext; + args.fRenderTargetContext = renderTargetContext; args.fClip = &noClip; args.fResourceProvider = rp; args.fViewMatrix = &SkMatrix::I(); @@ -271,36 +272,37 @@ static void test_path(GrDrawContext* drawContext, GrResourceProvider* rp, const } DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) { - sk_sp<GrDrawContext> dc(ctxInfo.grContext()->makeDrawContext(SkBackingFit::kApprox, - 800, 800, - kRGBA_8888_GrPixelConfig, - nullptr, - 0, - kTopLeft_GrSurfaceOrigin)); - if (!dc) { + sk_sp<GrRenderTargetContext> rtc(ctxInfo.grContext()->makeRenderTargetContext( + SkBackingFit::kApprox, + 800, 800, + kRGBA_8888_GrPixelConfig, + nullptr, + 0, + kTopLeft_GrSurfaceOrigin)); + if (!rtc) { return; } GrTestTarget tt; - ctxInfo.grContext()->getTestTarget(&tt, dc); + ctxInfo.grContext()->getTestTarget(&tt, rtc); GrResourceProvider* rp = tt.resourceProvider(); - test_path(dc.get(), rp, create_path_0()); - test_path(dc.get(), rp, create_path_1()); - test_path(dc.get(), rp, create_path_2()); - test_path(dc.get(), rp, create_path_3()); - test_path(dc.get(), rp, create_path_4()); - test_path(dc.get(), rp, create_path_5()); - test_path(dc.get(), rp, create_path_6()); - test_path(dc.get(), rp, create_path_7()); - test_path(dc.get(), rp, create_path_8()); - test_path(dc.get(), rp, create_path_9()); - test_path(dc.get(), rp, create_path_10()); - test_path(dc.get(), rp, create_path_11()); - test_path(dc.get(), rp, create_path_12()); - test_path(dc.get(), rp, create_path_13()); - test_path(dc.get(), rp, create_path_14()); - test_path(dc.get(), rp, create_path_15()); - test_path(dc.get(), rp, create_path_16()); + test_path(rtc.get(), rp, create_path_0()); + test_path(rtc.get(), rp, create_path_1()); + test_path(rtc.get(), rp, create_path_2()); + test_path(rtc.get(), rp, create_path_3()); + test_path(rtc.get(), rp, create_path_4()); + test_path(rtc.get(), rp, create_path_5()); + test_path(rtc.get(), rp, create_path_6()); + test_path(rtc.get(), rp, create_path_7()); + test_path(rtc.get(), rp, create_path_8()); + test_path(rtc.get(), rp, create_path_9()); + test_path(rtc.get(), rp, create_path_10()); + test_path(rtc.get(), rp, create_path_11()); + test_path(rtc.get(), rp, create_path_12()); + test_path(rtc.get(), rp, create_path_13()); + test_path(rtc.get(), rp, create_path_14()); + test_path(rtc.get(), rp, create_path_15()); + test_path(rtc.get(), rp, create_path_16()); } #endif |