diff options
author | robertphillips <robertphillips@google.com> | 2016-04-28 06:21:55 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-28 06:21:55 -0700 |
commit | aa19a5fbc58e372df11443c90a25f02a04ecef52 (patch) | |
tree | 4c6f03988d11d06477e9cedae7fda5d44dfcc650 /tests | |
parent | b8498825b54718cdd90c30c39323cfc433695f23 (diff) |
Revert of Refactor drawContext/RenderTarget creation (patchset #8 id:140001 of https://codereview.chromium.org/1914883002/ )
Reason for revert:
Experimental revert to see if this is blocking the DEPS roll.
Original issue's description:
> Refactor drawContext/RenderTarget creation
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1914883002
>
> Committed: https://skia.googlesource.com/skia/+/2f1c42e8448bbbadeb3df1c626faa90aa33f8907
TBR=bsalomon@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review-Url: https://codereview.chromium.org/1929833004
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ClearTest.cpp | 40 | ||||
-rw-r--r-- | tests/ClipBoundsTest.cpp | 18 | ||||
-rw-r--r-- | tests/PrimitiveProcessorTest.cpp | 17 |
3 files changed, 55 insertions, 20 deletions
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp index 7a533ba19c..1065d940ba 100644 --- a/tests/ClearTest.cpp +++ b/tests/ClearTest.cpp @@ -37,18 +37,31 @@ static bool check_rect(GrDrawContext* dc, const SkIRect& rect, uint32_t expected 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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { 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 @@ 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)) { + if (!reset_dc(&drawContext, &rtKeepAlive, context, kW, kH)) { ERRORF(reporter, "Could not create draw context."); return; } @@ -93,7 +107,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { 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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { 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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { 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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { 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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { 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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { 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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { 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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, ctxInfo) { 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; } diff --git a/tests/ClipBoundsTest.cpp b/tests/ClipBoundsTest.cpp index 5660afdc27..abdd3f44fa 100644 --- a/tests/ClipBoundsTest.cpp +++ b/tests/ClipBoundsTest.cpp @@ -17,8 +17,20 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrClipBounds, reporter, ctxInfo) { static const int kXSize = 100; static const int kYSize = 100; - const SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize); - const SkRect screen = SkRect::Make(intScreen); + GrSurfaceDesc desc; + desc.fFlags = kRenderTarget_GrSurfaceFlag; + desc.fConfig = kAlpha_8_GrPixelConfig; + desc.fWidth = kXSize; + desc.fHeight = kYSize; + + SkAutoTUnref<GrTexture> texture( + ctxInfo.fGrContext->textureProvider()->createTexture(desc, SkBudgeted::kYes, nullptr, 0)); + if (!texture) { + return; + } + + SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize); + SkRect screen = SkRect::Make(intScreen); SkRect clipRect(screen); clipRect.outset(10, 10); @@ -44,7 +56,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrClipBounds, reporter, ctxInfo) { clipData.setClipStack(&stack); SkIRect devGrClipBound; - clipData.getConservativeBounds(kXSize, kYSize, + clipData.getConservativeBounds(texture->width(), texture->height(), &devGrClipBound, &isIntersectionOfRects); diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index b1157a33a9..6d4ede1ce9 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -103,9 +103,18 @@ private: DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { GrContext* context = ctxInfo.fGrContext; - - sk_sp<GrDrawContext> dc(context->newDrawContext(GrContext::kLoose_BackingFit, - 1, 1, kRGBA_8888_GrPixelConfig)); + GrTextureDesc desc; + desc.fHeight = 1; + desc.fWidth = 1; + desc.fFlags = kRenderTarget_GrSurfaceFlag; + desc.fConfig = kRGBA_8888_GrPixelConfig; + SkAutoTUnref<GrTexture> target(context->textureProvider()->createTexture(desc, + SkBudgeted::kYes)); + if (!target) { + ERRORF(reporter, "Could not create render target."); + return; + } + sk_sp<GrDrawContext> dc(context->drawContext(sk_ref_sp(target->asRenderTarget()))); if (!dc) { ERRORF(reporter, "Could not create draw context."); return; @@ -123,7 +132,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { #endif SkAutoTUnref<GrDrawBatch> batch; GrPipelineBuilder pb; - pb.setRenderTarget(dc->accessRenderTarget()); + pb.setRenderTarget(target->asRenderTarget()); // This one should succeed. batch.reset(new Batch(attribCnt)); dc->drawContextPriv().testingOnly_drawBatch(pb, batch); |