aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ClearTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ClearTest.cpp')
-rw-r--r--tests/ClearTest.cpp85
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);