diff options
author | Robert Phillips <robertphillips@google.com> | 2017-03-02 18:18:38 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-03 12:35:27 +0000 |
commit | 2f49314227053dd5acc011e04681faee05c5e0ff (patch) | |
tree | 2669e6d4567687bffea21da299834125124b831d | |
parent | 3b4c22d3731813d2d0f2ae0e68180b6eeacea7a2 (diff) |
Make GrSurface::MakeDeferred return sk_sp<GrTextureProxy>
This should make upcoming changes less tedious
Change-Id: I313ae9df724f109a64cf5708a974e8bfeb963025
Reviewed-on: https://skia-review.googlesource.com/9183
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r-- | gm/etc1.cpp | 11 | ||||
-rw-r--r-- | gm/texdata.cpp | 2 | ||||
-rw-r--r-- | gm/texturedomaineffect.cpp | 6 | ||||
-rw-r--r-- | gm/yuvtorgbeffect.cpp | 15 | ||||
-rw-r--r-- | include/private/GrSurfaceProxy.h | 4 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 35 | ||||
-rw-r--r-- | src/gpu/GrSurfaceProxy.cpp | 18 | ||||
-rw-r--r-- | src/gpu/effects/GrConfigConversionEffect.cpp | 6 | ||||
-rw-r--r-- | tests/CopySurfaceTest.cpp | 4 | ||||
-rw-r--r-- | tests/ImageFilterCacheTest.cpp | 11 | ||||
-rw-r--r-- | tests/IntTextureTest.cpp | 14 | ||||
-rw-r--r-- | tests/ProcessorTest.cpp | 10 | ||||
-rw-r--r-- | tests/ProxyConversionTest.cpp | 24 | ||||
-rw-r--r-- | tests/ProxyTest.cpp | 26 | ||||
-rw-r--r-- | tests/ReadWriteAlphaTest.cpp | 14 | ||||
-rw-r--r-- | tests/SRGBMipMapTest.cpp | 4 | ||||
-rw-r--r-- | tests/SpecialImageTest.cpp | 38 | ||||
-rw-r--r-- | tests/TestUtils.cpp | 2 |
18 files changed, 114 insertions, 130 deletions
diff --git a/gm/etc1.cpp b/gm/etc1.cpp index 09ef7d867a..b22a27f63f 100644 --- a/gm/etc1.cpp +++ b/gm/etc1.cpp @@ -79,20 +79,19 @@ protected: desc.fWidth = kTexWidth; desc.fHeight = kTexHeight; - sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), context->textureProvider(), desc, SkBudgeted::kYes, fETC1Data.get(), 0); - if (!proxy || !proxy->asTextureProxy()) { + if (!proxy) { return; } const SkMatrix trans = SkMatrix::MakeTrans(-kPad, -kPad); - sk_sp<GrFragmentProcessor> fp = GrSimpleTextureEffect::Make( - context, - sk_ref_sp(proxy->asTextureProxy()), - nullptr, trans); + sk_sp<GrFragmentProcessor> fp = GrSimpleTextureEffect::Make(context, + std::move(proxy), + nullptr, trans); GrPaint grPaint; grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc)); diff --git a/gm/texdata.cpp b/gm/texdata.cpp index 2921afdfb7..106b87e6dc 100644 --- a/gm/texdata.cpp +++ b/gm/texdata.cpp @@ -91,7 +91,7 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) { desc.fHeight = 2 * S; desc.fConfig = SkImageInfo2GrPixelConfig(ii, *context->caps()); - sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), context->textureProvider(), desc, SkBudgeted::kNo, gTextureData.get(), 0); diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp index d5d98d556a..8be917d4f4 100644 --- a/gm/texturedomaineffect.cpp +++ b/gm/texturedomaineffect.cpp @@ -90,12 +90,12 @@ protected: desc.fHeight = fBmp.height(); desc.fConfig = SkImageInfo2GrPixelConfig(fBmp.info(), *context->caps()); - sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), context->textureProvider(), desc, SkBudgeted::kYes, fBmp.getPixels(), fBmp.rowBytes())); - if (!proxy || !proxy->asTextureProxy()) { + if (!proxy) { return; } @@ -124,7 +124,7 @@ protected: grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc)); sk_sp<GrFragmentProcessor> fp( GrTextureDomainEffect::Make( - context, sk_ref_sp(proxy->asTextureProxy()), + context, proxy, nullptr, textureMatrices[tm], GrTextureDomain::MakeTexelDomainForMode(texelDomains[d], mode), mode, GrSamplerParams::kNone_FilterMode)); diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp index 1835fe3446..03d103a9b7 100644 --- a/gm/yuvtorgbeffect.cpp +++ b/gm/yuvtorgbeffect.cpp @@ -81,7 +81,7 @@ protected: return; } - sk_sp<GrSurfaceProxy> proxy[3]; + sk_sp<GrTextureProxy> proxy[3]; { GrSurfaceDesc desc; @@ -121,9 +121,9 @@ protected: for (int i = 0; i < 6; ++i) { sk_sp<GrFragmentProcessor> fp( GrYUVEffect::MakeYUVToRGB(context, - sk_ref_sp(proxy[indices[i][0]]->asTextureProxy()), - sk_ref_sp(proxy[indices[i][1]]->asTextureProxy()), - sk_ref_sp(proxy[indices[i][2]]->asTextureProxy()), + proxy[indices[i][0]], + proxy[indices[i][1]], + proxy[indices[i][2]], sizes, static_cast<SkYUVColorSpace>(space), false)); @@ -212,7 +212,7 @@ protected: return; } - sk_sp<GrSurfaceProxy> proxy[3]; + sk_sp<GrTextureProxy> proxy[3]; { GrSurfaceDesc desc; @@ -252,10 +252,7 @@ protected: GrPaint grPaint; grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc)); sk_sp<GrFragmentProcessor> fp( - GrYUVEffect::MakeYUVToRGB(context, - sk_ref_sp(proxy[0]->asTextureProxy()), - sk_ref_sp(proxy[1]->asTextureProxy()), - sk_ref_sp(proxy[2]->asTextureProxy()), + GrYUVEffect::MakeYUVToRGB(context, proxy[0], proxy[1], proxy[2], sizes, static_cast<SkYUVColorSpace>(space), true)); if (fp) { SkMatrix viewMatrix; diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index aedb364b4d..91a4c3ce67 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -172,13 +172,13 @@ public: static sk_sp<GrSurfaceProxy> MakeWrapped(sk_sp<GrSurface>); static sk_sp<GrTextureProxy> MakeWrapped(sk_sp<GrTexture>); - static sk_sp<GrSurfaceProxy> MakeDeferred(GrTextureProvider*, const GrCaps&, + static sk_sp<GrTextureProxy> MakeDeferred(GrTextureProvider*, const GrCaps&, const GrSurfaceDesc&, SkBackingFit, SkBudgeted, uint32_t flags = 0); // TODO: need to refine ownership semantics of 'srcData' if we're in completely // deferred mode - static sk_sp<GrSurfaceProxy> MakeDeferred(const GrCaps&, GrTextureProvider*, + static sk_sp<GrTextureProxy> MakeDeferred(const GrCaps&, GrTextureProvider*, const GrSurfaceDesc&, SkBudgeted, const void* srcData, size_t rowBytes); diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 7dfee00ed2..a4c18523f9 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -294,46 +294,43 @@ bool GrContext::writeSurfacePixels(GrSurface* surface, SkColorSpace* dstColorSpa this->flush(); } - sk_sp<GrTextureProxy> tempTextureProxy; + sk_sp<GrTextureProxy> tempProxy; if (GrGpu::kNoDraw_DrawPreference != drawPreference) { - sk_sp<GrSurfaceProxy> temp = GrSurfaceProxy::MakeDeferred(this->textureProvider(), - *this->caps(), - tempDrawInfo.fTempSurfaceDesc, - SkBackingFit::kApprox, - SkBudgeted::kYes); - if (temp) { - tempTextureProxy = sk_ref_sp(temp->asTextureProxy()); - } - if (!tempTextureProxy && GrGpu::kRequireDraw_DrawPreference == drawPreference) { + tempProxy = GrSurfaceProxy::MakeDeferred(this->textureProvider(), + *this->caps(), + tempDrawInfo.fTempSurfaceDesc, + SkBackingFit::kApprox, + SkBudgeted::kYes); + if (!tempProxy && GrGpu::kRequireDraw_DrawPreference == drawPreference) { return false; } } // temp buffer for doing sw premul conversion, if needed. SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0); - if (tempTextureProxy) { + if (tempProxy) { sk_sp<GrFragmentProcessor> fp; if (applyPremulToSrc) { - fp = this->createUPMToPMEffect(tempTextureProxy, tempDrawInfo.fSwizzle, SkMatrix::I()); + fp = this->createUPMToPMEffect(tempProxy, tempDrawInfo.fSwizzle, SkMatrix::I()); // If premultiplying was the only reason for the draw, fall back to a straight write. if (!fp) { if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) { - tempTextureProxy.reset(nullptr); + tempProxy.reset(nullptr); } } else { applyPremulToSrc = false; } } - if (tempTextureProxy) { + if (tempProxy) { if (!fp) { - fp = GrConfigConversionEffect::Make(this, tempTextureProxy, tempDrawInfo.fSwizzle, + fp = GrConfigConversionEffect::Make(this, tempProxy, tempDrawInfo.fSwizzle, GrConfigConversionEffect::kNone_PMConversion, SkMatrix::I()); if (!fp) { return false; } } - GrTexture* texture = tempTextureProxy->instantiate(this->textureProvider()); + GrTexture* texture = tempProxy->instantiate(this->textureProvider()); if (!texture) { return false; } @@ -382,7 +379,7 @@ bool GrContext::writeSurfacePixels(GrSurface* surface, SkColorSpace* dstColorSpa } } } - if (!tempTextureProxy) { + if (!tempProxy) { if (applyPremulToSrc) { size_t tmpRowBytes = 4 * width; tmpPixels.reset(width * height); @@ -625,7 +622,7 @@ sk_sp<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(const GrSurfac SkBackingFit fit, SkBudgeted isDstBudgeted) { - sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(fContext->textureProvider(), + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(fContext->textureProvider(), *fContext->caps(), dstDesc, fit, isDstBudgeted); if (!proxy) { @@ -825,7 +822,7 @@ sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext( desc.fConfig = config; desc.fSampleCnt = sampleCnt; - sk_sp<GrSurfaceProxy> rtp = GrSurfaceProxy::MakeDeferred(this->textureProvider(), + sk_sp<GrTextureProxy> rtp = GrSurfaceProxy::MakeDeferred(this->textureProvider(), *this->caps(), desc, fit, budgeted); if (!rtp) { return nullptr; diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index a66daa4561..b8fc56dd0b 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -146,7 +146,7 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex) { #include "GrResourceProvider.h" -sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeDeferred(GrTextureProvider* texProvider, +sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrTextureProvider* texProvider, const GrCaps& caps, const GrSurfaceDesc& desc, SkBackingFit fit, @@ -196,32 +196,32 @@ sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeDeferred(GrTextureProvider* texProvide copyDesc.fSampleCnt = SkTMin(desc.fSampleCnt, caps.maxSampleCount()); #ifdef SK_DISABLE_DEFERRED_PROXIES - sk_sp<GrSurface> surf; + sk_sp<GrTexture> tex; if (SkBackingFit::kApprox == fit) { - surf.reset(texProvider->createApproxTexture(copyDesc)); + tex.reset(texProvider->createApproxTexture(copyDesc)); } else { - surf.reset(texProvider->createTexture(copyDesc, budgeted)); + tex.reset(texProvider->createTexture(copyDesc, budgeted)); } - if (!surf) { + if (!tex) { return nullptr; } - return GrSurfaceProxy::MakeWrapped(std::move(surf)); + return GrSurfaceProxy::MakeWrapped(std::move(tex)); #else if (willBeRT) { // We know anything we instantiate later from this deferred path will be // both texturable and renderable - return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(caps, copyDesc, fit, + return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(caps, copyDesc, fit, budgeted, flags)); } - return sk_sp<GrSurfaceProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0, flags)); + return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0, flags)); #endif } -sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps, +sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps, GrTextureProvider* texProvider, const GrSurfaceDesc& desc, SkBudgeted budgeted, diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index ba089fab2e..6a4cca5d77 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -218,10 +218,10 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context desc.fHeight = kSize; desc.fConfig = kConfig; - sk_sp<GrSurfaceProxy> dataProxy = GrSurfaceProxy::MakeDeferred(*context->caps(), + sk_sp<GrTextureProxy> dataProxy = GrSurfaceProxy::MakeDeferred(*context->caps(), context->textureProvider(), desc, SkBudgeted::kYes, data, 0); - if (!dataProxy || !dataProxy->asTextureProxy()) { + if (!dataProxy) { return; } @@ -249,7 +249,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context GrPaint paint2; GrPaint paint3; sk_sp<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect( - context, sk_ref_sp(dataProxy->asTextureProxy()), GrSwizzle::RGBA(), + context, dataProxy, GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I())); sk_sp<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect( context, readRTC->asTextureProxyRef(), GrSwizzle::RGBA(), diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp index 19037d9200..e1765d5809 100644 --- a/tests/CopySurfaceTest.cpp +++ b/tests/CopySurfaceTest.cpp @@ -73,14 +73,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) { dstDesc.fOrigin = dOrigin; dstDesc.fFlags = dFlags; - sk_sp<GrSurfaceProxy> src(GrSurfaceProxy::MakeDeferred( + sk_sp<GrTextureProxy> src(GrSurfaceProxy::MakeDeferred( *context->caps(), context->textureProvider(), srcDesc, SkBudgeted::kNo, srcPixels.get(), kRowBytes)); - sk_sp<GrSurfaceProxy> dst(GrSurfaceProxy::MakeDeferred( + sk_sp<GrTextureProxy> dst(GrSurfaceProxy::MakeDeferred( *context->caps(), context->textureProvider(), dstDesc, SkBudgeted::kNo, diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp index a3372081f0..9e63c038df 100644 --- a/tests/ImageFilterCacheTest.cpp +++ b/tests/ImageFilterCacheTest.cpp @@ -202,12 +202,11 @@ static sk_sp<GrTextureProxy> create_proxy(GrContext* context) { desc.fWidth = kFullSize; desc.fHeight = kFullSize; - sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), - desc, SkBudgeted::kYes, - srcBM.getPixels(), - srcBM.rowBytes()); - return sk_ref_sp(proxy->asTextureProxy()); + return GrSurfaceProxy::MakeDeferred(*context->caps(), + context->textureProvider(), + desc, SkBudgeted::kYes, + srcBM.getPixels(), + srcBM.rowBytes()); } diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp index 4642e312e9..518e195f9e 100644 --- a/tests/IntTextureTest.cpp +++ b/tests/IntTextureTest.cpp @@ -70,17 +70,17 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { } // Test that we can create an integer texture. - sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), - desc, SkBudgeted::kYes, - testData.get(), - kRowBytes); + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), + context->textureProvider(), + desc, SkBudgeted::kYes, + testData.get(), + kRowBytes); REPORTER_ASSERT(reporter, proxy); - if (!proxy || !proxy->asTextureProxy()) { + if (!proxy) { return; } - GrTexture* texture = proxy->asTextureProxy()->instantiate(context->textureProvider()); + GrTexture* texture = proxy->instantiate(context->textureProvider()); REPORTER_ASSERT(reporter, texture); if (!texture) { return; diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index 9d73805987..05be7bbea4 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -118,7 +118,7 @@ inline void testingOnly_getIORefCnts(const T* resource, int* refCnt, int* readCn *writeCnt = resource->fPendingWrites; } -void testingOnly_getIORefCnts(GrSurfaceProxy* proxy, int* refCnt, int* readCnt, int* writeCnt) { +void testingOnly_getIORefCnts(GrTextureProxy* proxy, int* refCnt, int* readCnt, int* writeCnt) { *refCnt = proxy->getBackingRefCnt_TestOnly(); *readCnt = proxy->getPendingReadCnt_TestOnly(); *writeCnt = proxy->getPendingWriteCnt_TestOnly(); @@ -138,7 +138,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { { bool texelBufferSupport = context->caps()->shaderCaps()->texelBufferSupport(); bool imageLoadStoreSupport = context->caps()->shaderCaps()->imageLoadStoreSupport(); - sk_sp<GrSurfaceProxy> proxy1(GrSurfaceProxy::MakeDeferred(context->textureProvider(), + sk_sp<GrTextureProxy> proxy1(GrSurfaceProxy::MakeDeferred(context->textureProvider(), *context->caps(), desc, SkBackingFit::kExact, SkBudgeted::kYes)); @@ -157,7 +157,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { SkTArray<sk_sp<GrTextureProxy>> proxies; SkTArray<sk_sp<GrBuffer>> buffers; SkTArray<TestFP::Image> images; - proxies.push_back(sk_ref_sp(proxy1->asTextureProxy())); + proxies.push_back(proxy1); if (texelBufferSupport) { buffers.push_back(buffer); } @@ -312,7 +312,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor } desc.fConfig = kRGBA_8888_GrPixelConfig; - sk_sp<GrSurfaceProxy> dataProxy = GrSurfaceProxy::MakeDeferred(*context->caps(), + sk_sp<GrTextureProxy> dataProxy = GrSurfaceProxy::MakeDeferred(*context->caps(), context->textureProvider(), desc, SkBudgeted::kYes, rgbaData.get(), @@ -335,7 +335,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor !fp->compatibleWithCoverageAsAlpha()) { continue; } - test_draw_op(context, rtc.get(), fp, sk_ref_sp(dataProxy->asTextureProxy())); + test_draw_op(context, rtc.get(), fp, dataProxy); memset(rgbaData.get(), 0x0, sizeof(GrColor) * 256 * 256); rtc->readPixels( SkImageInfo::Make(256, 256, kRGBA_8888_SkColorType, kPremul_SkAlphaType), diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp index 4504a65b4f..468ddd9cd8 100644 --- a/tests/ProxyConversionTest.cpp +++ b/tests/ProxyConversionTest.cpp @@ -128,12 +128,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DefferredProxyConversionTest, reporter, ctxIn desc.fConfig = kRGBA_8888_GrPixelConfig; { - sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeDeferred(texProvider, caps, desc, - SkBackingFit::kApprox, - SkBudgeted::kYes)); + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(texProvider, caps, desc, + SkBackingFit::kApprox, + SkBudgeted::kYes)); // Both RenderTarget and Texture - GrRenderTargetProxy* rtProxy = sProxy->asRenderTargetProxy(); + GrRenderTargetProxy* rtProxy = proxy->asRenderTargetProxy(); REPORTER_ASSERT(reporter, rtProxy); GrTextureProxy* tProxy = rtProxy->asTextureProxy(); REPORTER_ASSERT(reporter, tProxy); @@ -142,12 +142,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DefferredProxyConversionTest, reporter, ctxIn } { - sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeDeferred(texProvider, caps, desc, - SkBackingFit::kApprox, - SkBudgeted::kYes)); + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(texProvider, caps, desc, + SkBackingFit::kApprox, + SkBudgeted::kYes)); // Both RenderTarget and Texture - but via GrTextureProxy - GrTextureProxy* tProxy = sProxy->asTextureProxy(); + GrTextureProxy* tProxy = proxy->asTextureProxy(); REPORTER_ASSERT(reporter, tProxy); GrRenderTargetProxy* rtProxy = tProxy->asRenderTargetProxy(); REPORTER_ASSERT(reporter, rtProxy); @@ -158,12 +158,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DefferredProxyConversionTest, reporter, ctxIn { desc.fFlags = kNone_GrSurfaceFlags; // force no-RT - sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeDeferred(texProvider, caps, desc, - SkBackingFit::kApprox, - SkBudgeted::kYes)); + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(texProvider, caps, desc, + SkBackingFit::kApprox, + SkBudgeted::kYes)); // Texture-only - GrTextureProxy* tProxy = sProxy->asTextureProxy(); + GrTextureProxy* tProxy = proxy->asTextureProxy(); REPORTER_ASSERT(reporter, tProxy); REPORTER_ASSERT(reporter, tProxy->asTextureProxy() == tProxy); REPORTER_ASSERT(reporter, !tProxy->asRenderTargetProxy()); diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index ac3275209f..367ec0ce64 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -140,25 +140,25 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { tex.reset(provider->createTexture(desc, budgeted)); } - sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeDeferred( + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred( provider, caps, desc, fit, budgeted)); - REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(sProxy)); - if (sProxy) { - REPORTER_ASSERT(reporter, sProxy->asRenderTargetProxy()); + REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy)); + if (proxy) { + REPORTER_ASSERT(reporter, proxy->asRenderTargetProxy()); // This forces the proxy to compute and cache its // pre-instantiation size guess. Later, when it is actually // instantiated, it checks that the instantiated size is <= to // the pre-computation. If the proxy never computed its // pre-instantiation size then the check is skipped. - sProxy->gpuMemorySize(); + proxy->gpuMemorySize(); - check_surface(reporter, sProxy.get(), origin, + check_surface(reporter, proxy.get(), origin, widthHeight, widthHeight, config, kInvalidResourceID, budgeted); check_rendertarget(reporter, caps, provider, - sProxy->asRenderTargetProxy(), + proxy->asRenderTargetProxy(), SkTMin(numSamples, caps.maxSampleCount()), fit, caps.maxWindowRectangles(), false); } @@ -174,24 +174,24 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { tex.reset(provider->createTexture(desc, budgeted)); } - sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeDeferred(provider, + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(provider, caps, desc, fit, budgeted)); - REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(sProxy)); - if (sProxy) { + REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy)); + if (proxy) { // This forces the proxy to compute and cache its pre-instantiation // size guess. Later, when it is actually instantiated, it checks // that the instantiated size is <= to the pre-computation. // If the proxy never computed its pre-instantiation size then the // check is skipped. - sProxy->gpuMemorySize(); + proxy->gpuMemorySize(); - check_surface(reporter, sProxy.get(), origin, + check_surface(reporter, proxy.get(), origin, widthHeight, widthHeight, config, kInvalidResourceID, budgeted); - check_texture(reporter, provider, sProxy->asTextureProxy(), + check_texture(reporter, provider, proxy->asTextureProxy(), fit, false); } } diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp index 613f45fd7d..bfef33fa14 100644 --- a/tests/ReadWriteAlphaTest.cpp +++ b/tests/ReadWriteAlphaTest.cpp @@ -56,17 +56,17 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { // We are initializing the texture with zeros here memset(alphaData, 0, X_SIZE * Y_SIZE); - sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), - desc, - SkBudgeted::kNo, - alphaData, 0)); - if (!sProxy) { + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), + context->textureProvider(), + desc, + SkBudgeted::kNo, + alphaData, 0)); + if (!proxy) { ERRORF(reporter, "Could not create alpha texture."); return; } sk_sp<GrSurfaceContext> sContext(context->contextPriv().makeWrappedSurfaceContext( - sProxy, nullptr)); + std::move(proxy), nullptr)); const SkImageInfo ii = SkImageInfo::MakeA8(X_SIZE, Y_SIZE); sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii)); diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp index dd87f19e8e..7865690cdf 100644 --- a/tests/SRGBMipMapTest.cpp +++ b/tests/SRGBMipMapTest.cpp @@ -119,7 +119,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) { desc.fHeight = texS; GrTextureProvider* texProvider = context->textureProvider(); - sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), texProvider, + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), texProvider, desc, SkBudgeted::kNo, texData, 0); @@ -135,7 +135,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) { GrPaint paint; paint.setPorterDuffXPFactory(SkBlendMode::kSrc); GrSamplerParams mipMapParams(SkShader::kRepeat_TileMode, GrSamplerParams::kMipMap_FilterMode); - paint.addColorTextureProcessor(context, sk_ref_sp(proxy->asTextureProxy()), + paint.addColorTextureProcessor(context, std::move(proxy), nullptr, SkMatrix::MakeScale(rtS), mipMapParams); // 1) Draw texture to S32 surface (should generate/use sRGB mips) diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp index 77015c4aa2..82dd019dea 100644 --- a/tests/SpecialImageTest.cpp +++ b/tests/SpecialImageTest.cpp @@ -233,21 +233,19 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo) // gpu const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps()); - sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), context->textureProvider(), desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes())); - if (!proxy || !proxy->asTextureProxy()) { + if (!proxy) { return; } sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeDeferredFromGpu( - context, - SkIRect::MakeWH(kFullSize, - kFullSize), - kNeedNewImageUniqueID_SpecialImage, - sk_ref_sp(proxy->asTextureProxy()), - nullptr)); + context, + SkIRect::MakeWH(kFullSize, kFullSize), + kNeedNewImageUniqueID_SpecialImage, + std::move(proxy), nullptr)); { sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context)); @@ -269,11 +267,11 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) { const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps()); - sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), context->textureProvider(), desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes())); - if (!proxy || !proxy->asTextureProxy()) { + if (!proxy) { return; } @@ -281,18 +279,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) { context, SkIRect::MakeWH(kFullSize, kFullSize), kNeedNewImageUniqueID_SpecialImage, - sk_ref_sp(proxy->asTextureProxy()), - nullptr)); + proxy, nullptr)); const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); { sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeDeferredFromGpu( - context, - subset, + context, subset, kNeedNewImageUniqueID_SpecialImage, - sk_ref_sp(proxy->asTextureProxy()), - nullptr)); + std::move(proxy), nullptr)); test_image(subSImg1, reporter, context, true, kPad, kFullSize); } @@ -312,7 +307,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_DeferredGpu, reporter, ctxInfo) desc.fWidth = kFullSize; desc.fHeight = kFullSize; - sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), context->textureProvider(), desc, SkBudgeted::kNo, bm.getPixels(), 0)); @@ -324,18 +319,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_DeferredGpu, reporter, ctxInfo) context, SkIRect::MakeWH(kFullSize, kFullSize), kNeedNewImageUniqueID_SpecialImage, - sk_ref_sp(proxy->asTextureProxy()), - nullptr)); + proxy, nullptr)); const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); { sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeDeferredFromGpu( - context, - subset, + context, subset, kNeedNewImageUniqueID_SpecialImage, - sk_ref_sp(proxy->asTextureProxy()), - nullptr)); + std::move(proxy), nullptr)); test_image(subSImg1, reporter, context, true, kPad, kFullSize); } diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp index b809a67a0a..0e6e7b0d07 100644 --- a/tests/TestUtils.cpp +++ b/tests/TestUtils.cpp @@ -106,7 +106,7 @@ void test_copy_to_surface(skiatest::Reporter* reporter, GrContext* context, for (auto flags : { kNone_GrSurfaceFlags, kRenderTarget_GrSurfaceFlag }) { copySrcDesc.fFlags = flags; - sk_sp<GrSurfaceProxy> src(GrSurfaceProxy::MakeDeferred(*context->caps(), + sk_sp<GrTextureProxy> src(GrSurfaceProxy::MakeDeferred(*context->caps(), context->textureProvider(), copySrcDesc, SkBudgeted::kYes, pixels.get(), 0)); |