diff options
author | Robert Phillips <robertphillips@google.com> | 2017-06-02 14:53:40 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-02 19:21:37 +0000 |
commit | e4d45bf5ba413e5a26d4f6c24886bbd104b14885 (patch) | |
tree | 9b0e04caff926ec04009216325a02c1485713b72 /tests/ClearTest.cpp | |
parent | 0271c5b7dba460f523611d65c5711a9cf21c7761 (diff) |
Remove accessRenderTarget call from Clear tests
In the split-opList world the full screen clear optimization no longer relies on the rendertarget ID.
Change-Id: Ifc7bf10753355a18507998e30f9de7e8c1eb57c1
Reviewed-on: https://skia-review.googlesource.com/18497
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/ClearTest.cpp')
-rw-r--r-- | tests/ClearTest.cpp | 85 |
1 files changed, 29 insertions, 56 deletions
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp index 45eb2afa2d..b6ae685831 100644 --- a/tests/ClearTest.cpp +++ b/tests/ClearTest.cpp @@ -42,27 +42,9 @@ static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t return true; } -// TODO: this test does this thorough purging of the rendertargets b.c. right now -// the clear optimizations rely on the rendertarget's uniqueID. It can be -// relaxed when we switch that over to using rendertargetcontext ids (although -// we probably will want to have more clear values then too) -static bool reset_rtc(sk_sp<GrRenderTargetContext>* rtc, GrContext* context, int w, int h) { -#ifdef SK_DEBUG - GrGpuResource::UniqueID oldID = GrGpuResource::UniqueID::InvalidID(); -#endif - - if (*rtc) { - SkDEBUGCODE(oldID = (*rtc)->accessRenderTarget()->uniqueID();) - rtc->reset(nullptr); - } - context->freeGpuResources(); - - *rtc = context->makeDeferredRenderTargetContext(SkBackingFit::kExact, w, h, +sk_sp<GrRenderTargetContext> newRTC(GrContext* context, int w, int h) { + return context->makeDeferredRenderTargetContext(SkBackingFit::kExact, w, h, kRGBA_8888_GrPixelConfig, nullptr); - - SkASSERT((*rtc)->accessRenderTarget()->uniqueID() != oldID); - - return *rtc != nullptr; } DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) { @@ -95,10 +77,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) { static const GrColor kColor1 = 0xABCDEF01; static const GrColor kColor2 = ~kColor1; - if (!reset_rtc(&rtContext, context, kW, kH)) { - ERRORF(reporter, "Could not create render target context."); - return; - } + rtContext = newRTC(context, kW, kH); + SkASSERT(rtContext); + // Check a full clear rtContext->clear(&fullRect, kColor1, false); if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { @@ -106,10 +87,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) { failX, failY); } - if (!reset_rtc(&rtContext, context, kW, kH)) { - ERRORF(reporter, "Could not create render target context."); - return; - } + rtContext = newRTC(context, kW, kH); + SkASSERT(rtContext); + // Check two full clears, same color rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor1, false); @@ -118,10 +98,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) { failX, failY); } - if (!reset_rtc(&rtContext, context, kW, kH)) { - ERRORF(reporter, "Could not create render target context."); - return; - } + rtContext = newRTC(context, kW, kH); + SkASSERT(rtContext); + // Check two full clears, different colors rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor2, false); @@ -130,10 +109,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) { failX, failY); } - if (!reset_rtc(&rtContext, context, kW, kH)) { - ERRORF(reporter, "Could not create render target context."); - return; - } + rtContext = newRTC(context, kW, kH); + SkASSERT(rtContext); + // Test a full clear followed by a same color inset clear rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&mid1Rect, kColor1, false); @@ -142,10 +120,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) { failX, failY); } - if (!reset_rtc(&rtContext, context, kW, kH)) { - ERRORF(reporter, "Could not create render target context."); - return; - } + rtContext = newRTC(context, kW, kH); + SkASSERT(rtContext); + // Test a inset clear followed by same color full clear rtContext->clear(&mid1Rect, kColor1, false); rtContext->clear(&fullRect, kColor1, false); @@ -154,10 +131,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) { failX, failY); } - if (!reset_rtc(&rtContext, context, kW, kH)) { - ERRORF(reporter, "Could not create render target context."); - return; - } + rtContext = newRTC(context, kW, kH); + SkASSERT(rtContext); + // Test a full clear followed by a different color inset clear rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&mid1Rect, kColor2, false); @@ -173,10 +149,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) { failX, failY); } - if (!reset_rtc(&rtContext, context, kW, kH)) { - ERRORF(reporter, "Could not create render target context."); - return; - } + rtContext = newRTC(context, kW, kH); + SkASSERT(rtContext); + // Test a inset clear followed by a different full clear rtContext->clear(&mid1Rect, kColor2, false); rtContext->clear(&fullRect, kColor1, false); @@ -185,10 +160,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) { failX, failY); } - if (!reset_rtc(&rtContext, context, kW, kH)) { - ERRORF(reporter, "Could not create render target context."); - return; - } + rtContext = newRTC(context, kW, kH); + SkASSERT(rtContext); + // Check three nested clears from largest to smallest where outermost and innermost are same // color. rtContext->clear(&fullRect, kColor1, false); @@ -213,10 +187,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) { failX, failY); } - if (!reset_rtc(&rtContext, context, kW, kH)) { - ERRORF(reporter, "Could not create render target context."); - return; - } + rtContext = newRTC(context, kW, kH); + SkASSERT(rtContext); + // Swap the order of the second two clears in the above test. rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&mid2Rect, kColor1, false); |