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>
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index 45eb2af..b6ae685 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -42,27 +42,9 @@
     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 @@
     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 @@
                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 @@
                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 @@
                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 @@
                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 @@
                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 @@
                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 @@
                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 @@
                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);