From 1105224f9701e57ec5ce0354d6a380b664f5c638 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Thu, 27 Oct 2016 14:47:55 -0400 Subject: 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 Reviewed-by: Brian Salomon Reviewed-by: Robert Phillips --- tests/ClearTest.cpp | 147 ++++++++++++++++++++++++++-------------------------- 1 file changed, 74 insertions(+), 73 deletions(-) (limited to 'tests/ClearTest.cpp') 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 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* dc, GrContext* context, int w, int h) { +static bool reset_rtc(sk_sp* 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 drawContext; + sk_sp 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); } -- cgit v1.2.3