| Index: tests/ClearTest.cpp
|
| diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
|
| index 7a533ba19c45a4788a5501a8276f7f7a92c28ec6..1065d940ba84350a626f9f7b38fca1e353f11aa5 100644
|
| --- a/tests/ClearTest.cpp
|
| +++ b/tests/ClearTest.cpp
|
| @@ -37,18 +37,31 @@
|
| return true;
|
| }
|
|
|
| -static bool reset_dc(sk_sp<GrDrawContext>* dc, GrContext* context, int w, int h) {
|
| +// We only really need the DC, but currently the DC doesn't own the RT so we also ref it, but that
|
| +// could be dropped when DC is a proper owner of its RT.
|
| +static bool reset_dc(sk_sp<GrDrawContext>* dc, SkAutoTUnref<GrSurface>* rtKeepAlive,
|
| + GrContext* context, int w, int h) {
|
| SkDEBUGCODE(uint32_t oldID = 0;)
|
| if (*dc) {
|
| SkDEBUGCODE(oldID = (*dc)->accessRenderTarget()->getUniqueID();)
|
| + rtKeepAlive->reset(nullptr);
|
| dc->reset(nullptr);
|
| }
|
| context->freeGpuResources();
|
|
|
| - *dc = context->newDrawContext(GrContext::kTight_BackingFit, w, h, kRGBA_8888_GrPixelConfig);
|
| -
|
| - SkASSERT((*dc)->accessRenderTarget()->getUniqueID() != oldID);
|
| -
|
| + GrTextureDesc desc;
|
| + desc.fWidth = w;
|
| + desc.fHeight = h;
|
| + desc.fConfig = kRGBA_8888_GrPixelConfig;
|
| + desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
| +
|
| + rtKeepAlive->reset(context->textureProvider()->createTexture(desc, SkBudgeted::kYes));
|
| + if (!(*rtKeepAlive)) {
|
| + return false;
|
| + }
|
| + GrRenderTarget* rt = (*rtKeepAlive)->asRenderTarget();
|
| + SkASSERT(rt->getUniqueID() != oldID);
|
| + *dc = context->drawContext(sk_ref_sp(rt));
|
| return *dc != nullptr;
|
| }
|
|
|
| @@ -59,6 +72,7 @@
|
|
|
| SkIRect fullRect = SkIRect::MakeWH(kW, kH);
|
| sk_sp<GrDrawContext> drawContext;
|
| + SkAutoTUnref<GrSurface> rtKeepAlive;
|
|
|
| // A rectangle that is inset by one on all sides and the 1-pixel wide rectangles that surround
|
| // it.
|
| @@ -82,7 +96,7 @@
|
| static const GrColor kColor1 = 0xABCDEF01;
|
| static const GrColor kColor2 = ~kColor1;
|
|
|
| - if (!reset_dc(&drawContext, context, kW, kH)) {
|
| + if (!reset_dc(&drawContext, &rtKeepAlive, context, kW, kH)) {
|
| ERRORF(reporter, "Could not create draw context.");
|
| return;
|
| }
|
| @@ -93,7 +107,7 @@
|
| failX, failY);
|
| }
|
|
|
| - if (!reset_dc(&drawContext, context, kW, kH)) {
|
| + if (!reset_dc(&drawContext, &rtKeepAlive, context, kW, kH)) {
|
| ERRORF(reporter, "Could not create draw context.");
|
| return;
|
| }
|
| @@ -105,7 +119,7 @@
|
| failX, failY);
|
| }
|
|
|
| - if (!reset_dc(&drawContext, context, kW, kH)) {
|
| + if (!reset_dc(&drawContext, &rtKeepAlive, context, kW, kH)) {
|
| ERRORF(reporter, "Could not create draw context.");
|
| return;
|
| }
|
| @@ -117,7 +131,7 @@
|
| failX, failY);
|
| }
|
|
|
| - if (!reset_dc(&drawContext, context, kW, kH)) {
|
| + if (!reset_dc(&drawContext, &rtKeepAlive, context, kW, kH)) {
|
| ERRORF(reporter, "Could not create draw context.");
|
| return;
|
| }
|
| @@ -129,7 +143,7 @@
|
| failX, failY);
|
| }
|
|
|
| - if (!reset_dc(&drawContext, context, kW, kH)) {
|
| + if (!reset_dc(&drawContext, &rtKeepAlive, context, kW, kH)) {
|
| ERRORF(reporter, "Could not create draw context.");
|
| return;
|
| }
|
| @@ -141,7 +155,7 @@
|
| failX, failY);
|
| }
|
|
|
| - if (!reset_dc(&drawContext, context, kW, kH)) {
|
| + if (!reset_dc(&drawContext, &rtKeepAlive, context, kW, kH)) {
|
| ERRORF(reporter, "Could not create draw context.");
|
| return;
|
| }
|
| @@ -160,7 +174,7 @@
|
| failX, failY);
|
| }
|
|
|
| - if (!reset_dc(&drawContext, context, kW, kH)) {
|
| + if (!reset_dc(&drawContext, &rtKeepAlive, context, kW, kH)) {
|
| ERRORF(reporter, "Could not create draw context.");
|
| return;
|
| }
|
| @@ -172,7 +186,7 @@
|
| failX, failY);
|
| }
|
|
|
| - if (!reset_dc(&drawContext, context, kW, kH)) {
|
| + if (!reset_dc(&drawContext, &rtKeepAlive, context, kW, kH)) {
|
| ERRORF(reporter, "Could not create draw context.");
|
| return;
|
| }
|
| @@ -200,7 +214,7 @@
|
| failX, failY);
|
| }
|
|
|
| - if (!reset_dc(&drawContext, context, kW, kH)) {
|
| + if (!reset_dc(&drawContext, &rtKeepAlive, context, kW, kH)) {
|
| ERRORF(reporter, "Could not create draw context.");
|
| return;
|
| }
|
|
|