From c113f004decaf1e154abfdb6a736abf893a9bb7f Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Wed, 26 Aug 2020 13:28:22 -0400 Subject: [PATCH] Remove renderable flag from texture createLazyProxy. Besides some tests, we always set the renderable flag to kNo for this function. No need to keep supporting a code path we don't actually use. Tests that use to pass in kYes here have been converted to calling createLazyRenderTargetProxy instead. Change-Id: I91efe6cc51fd7ba04b711509ca26f18eba2af333 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313425 Commit-Queue: Greg Daniel Reviewed-by: Robert Phillips --- src/gpu/GrAHardwareBufferImageGenerator.cpp | 6 +-- src/gpu/GrBackendTextureImageGenerator.cpp | 4 +- src/gpu/GrProxyProvider.cpp | 52 +++++++-------------- src/gpu/GrProxyProvider.h | 8 ++-- src/image/SkImage_GpuBase.cpp | 4 +- tests/GrSurfaceTest.cpp | 22 +++++++-- tests/LazyProxyTest.cpp | 12 ++--- tests/ResourceAllocatorTest.cpp | 15 ++++-- 8 files changed, 60 insertions(+), 63 deletions(-) diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp index 4c03867600..ee24c3db77 100644 --- a/src/gpu/GrAHardwareBufferImageGenerator.cpp +++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp @@ -178,9 +178,9 @@ GrSurfaceProxyView GrAHardwareBufferImageGenerator::makeView(GrRecordingContext* return tex; }, - backendFormat, {width, height}, GrRenderable::kNo, 1, GrMipmapped::kNo, - GrMipmapStatus::kNotAllocated, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, - SkBudgeted::kNo, GrProtected(fIsProtectedContent), GrSurfaceProxy::UseAllocator::kYes); + backendFormat, {width, height}, GrMipmapped::kNo, GrMipmapStatus::kNotAllocated, + GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, SkBudgeted::kNo, + GrProtected(fIsProtectedContent), GrSurfaceProxy::UseAllocator::kYes); GrSwizzle readSwizzle = context->priv().caps()->getReadSwizzle(backendFormat, grColorType); diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp index ac352fc91c..8a130bef53 100644 --- a/src/gpu/GrBackendTextureImageGenerator.cpp +++ b/src/gpu/GrBackendTextureImageGenerator.cpp @@ -200,8 +200,8 @@ GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture( // proxy. return {std::move(tex), true, GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced}; }, - backendFormat, fBackendTexture.dimensions(), GrRenderable::kNo, 1, textureIsMipMapped, - mipmapStatus, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, SkBudgeted::kNo, + backendFormat, fBackendTexture.dimensions(), textureIsMipMapped, mipmapStatus, + GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes); if (!proxy) { return {}; diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index 1017b9ece1..2bb1708e17 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -329,7 +329,7 @@ sk_sp GrProxyProvider::createNonMippedProxyFromBitmap(const SkBi desc.fDimensions, desc.fFormat, colorType, desc.fRenderable, desc.fSampleCnt, desc.fBudgeted, desc.fFit, desc.fProtected, mipLevel)); }, - format, dims, GrRenderable::kNo, 1, GrMipmapped::kNo, GrMipmapStatus::kNotAllocated, + format, dims, GrMipmapped::kNo, GrMipmapStatus::kNotAllocated, GrInternalSurfaceFlags::kNone, fit, budgeted, GrProtected::kNo, UseAllocator::kYes); if (!proxy) { @@ -377,9 +377,8 @@ sk_sp GrProxyProvider::createMippedProxyFromBitmap(const SkBitma desc.fDimensions, desc.fFormat, colorType, GrRenderable::kNo, 1, desc.fBudgeted, GrProtected::kNo, texels.get(), mipLevelCount)); }, - format, dims, GrRenderable::kNo, 1, GrMipmapped::kYes, GrMipmapStatus::kValid, - GrInternalSurfaceFlags::kNone, SkBackingFit::kExact, budgeted, GrProtected::kNo, - UseAllocator::kYes); + format, dims, GrMipmapped::kYes, GrMipmapStatus::kValid, GrInternalSurfaceFlags::kNone, + SkBackingFit::kExact, budgeted, GrProtected::kNo, UseAllocator::kYes); if (!proxy) { return nullptr; @@ -465,9 +464,8 @@ sk_sp GrProxyProvider::createCompressedTextureProxy( desc.fDimensions, desc.fFormat, desc.fBudgeted, desc.fMipmapped, desc.fProtected, data.get())); }, - format, dimensions, GrRenderable::kNo, 1, mipMapped, mipmapStatus, - GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, SkBudgeted::kYes, - GrProtected::kNo, UseAllocator::kYes); + format, dimensions, mipMapped, mipmapStatus,GrInternalSurfaceFlags::kReadOnly, + SkBackingFit::kExact, SkBudgeted::kYes, GrProtected::kNo, UseAllocator::kYes); if (!proxy) { return nullptr; @@ -696,8 +694,6 @@ sk_sp GrProxyProvider::wrapVulkanSecondaryCBAsRenderTarget( sk_sp GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& callback, const GrBackendFormat& format, SkISize dimensions, - GrRenderable renderable, - int renderTargetSampleCnt, GrMipmapped mipMapped, GrMipmapStatus mipmapStatus, GrInternalSurfaceFlags surfaceFlags, @@ -721,33 +717,17 @@ sk_sp GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& return nullptr; } - if (renderable == GrRenderable::kYes) { - return sk_sp(new GrTextureRenderTargetProxy(*this->caps(), - std::move(callback), - format, - dimensions, - renderTargetSampleCnt, - mipMapped, - mipmapStatus, - fit, - budgeted, - isProtected, - surfaceFlags, - useAllocator, - this->isDDLProvider())); - } else { - return sk_sp(new GrTextureProxy(std::move(callback), - format, - dimensions, - mipMapped, - mipmapStatus, - fit, - budgeted, - isProtected, - surfaceFlags, - useAllocator, - this->isDDLProvider())); - } + return sk_sp(new GrTextureProxy(std::move(callback), + format, + dimensions, + mipMapped, + mipmapStatus, + fit, + budgeted, + isProtected, + surfaceFlags, + useAllocator, + this->isDDLProvider())); } sk_sp GrProxyProvider::createLazyRenderTargetProxy( diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h index a3b75cd627..86e706fe4b 100644 --- a/src/gpu/GrProxyProvider.h +++ b/src/gpu/GrProxyProvider.h @@ -157,9 +157,9 @@ public: /** * Creates a texture proxy that will be instantiated by a user-supplied callback during flush. - * (Stencil is not supported by this method.) The width and height must either both be greater - * than 0 or both less than or equal to zero. A non-positive value is a signal that the width - * and height are currently unknown. + * The width and height must either both be greater than 0 or both less than or equal to zero. A + * non-positive value is a signal that the width height are currently unknown. The texture will + * not be renderable. * * When called, the callback must be able to cleanup any resources that it captured at creation. * It also must support being passed in a null GrResourceProvider. When this happens, the @@ -168,8 +168,6 @@ public: sk_sp createLazyProxy(LazyInstantiateCallback&&, const GrBackendFormat&, SkISize dimensions, - GrRenderable, - int renderTargetSampleCnt, GrMipmapped, GrMipmapStatus, GrInternalSurfaceFlags, diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp index 95c4897a24..7461ab4c47 100644 --- a/src/image/SkImage_GpuBase.cpp +++ b/src/image/SkImage_GpuBase.cpp @@ -501,7 +501,7 @@ sk_sp SkImage_GpuBase::MakePromiseImageLazyProxy( // We pass kReadOnly here since we should treat content of the client's texture as immutable. // The promise API provides no way for the client to indicated that the texture is protected. return proxyProvider->createLazyProxy( - std::move(callback), backendFormat, {width, height}, GrRenderable::kNo, 1, mipMapped, - mipmapStatus, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, SkBudgeted::kNo, + std::move(callback), backendFormat, {width, height}, mipMapped, mipmapStatus, + GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes); } diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 198ff8516d..8632ad12c9 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -568,11 +568,23 @@ DEF_GPUTEST(TextureIdleProcTest, reporter, options) { } else { budgeted = SkBudgeted::kNo; } - auto proxy = dContext->priv().proxyProvider()->createLazyProxy( - singleUseLazyCB, backendFormat, desc, renderable, 1, GrMipmapped::kNo, - GrMipmapStatus::kNotAllocated, GrInternalSurfaceFlags ::kNone, - SkBackingFit::kExact, budgeted, GrProtected::kNo, - GrSurfaceProxy::UseAllocator::kYes); + sk_sp proxy; + if (renderable == GrRenderable::kYes) { + static const GrProxyProvider::TextureInfo kTexInfo = {GrMipMapped::kNo, + GrTextureType::k2D}; + proxy = dContext->priv().proxyProvider()->createLazyRenderTargetProxy( + singleUseLazyCB, backendFormat, desc, 1, + GrInternalSurfaceFlags ::kNone, &kTexInfo, + GrMipmapStatus::kNotAllocated, + SkBackingFit::kExact, budgeted, GrProtected::kNo, false, + GrSurfaceProxy::UseAllocator::kYes); + } else { + proxy = dContext->priv().proxyProvider()->createLazyProxy( + singleUseLazyCB, backendFormat, desc, GrMipmapped::kNo, + GrMipmapStatus::kNotAllocated, GrInternalSurfaceFlags ::kNone, + SkBackingFit::kExact, budgeted, GrProtected::kNo, + GrSurfaceProxy::UseAllocator::kYes); + } GrSwizzle readSwizzle = dContext->priv().caps()->getReadSwizzle( backendFormat, GrColorType::kRGBA_8888); GrSurfaceProxyView view(std::move(proxy), kTopLeft_GrSurfaceOrigin, readSwizzle); diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp index 2a8691ed56..07c52cbd57 100644 --- a/tests/LazyProxyTest.cpp +++ b/tests/LazyProxyTest.cpp @@ -273,9 +273,9 @@ DEF_GPUTEST(LazyProxyReleaseTest, reporter, /* options */) { }; sk_sp proxy = proxyProvider->createLazyProxy( TestCallback(&testCount, releaseCallback, tex), format, {kSize, kSize}, - GrRenderable::kNo, 1, GrMipmapped::kNo, GrMipmapStatus::kNotAllocated, - GrInternalSurfaceFlags::kNone, SkBackingFit::kExact, SkBudgeted::kNo, - GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes); + GrMipmapped::kNo, GrMipmapStatus::kNotAllocated, GrInternalSurfaceFlags::kNone, + SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo, + GrSurfaceProxy::UseAllocator::kYes); REPORTER_ASSERT(reporter, proxy.get()); REPORTER_ASSERT(reporter, 0 == testCount); @@ -343,9 +343,9 @@ private: desc.fProtected), true, GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced}; }, - format, dims, GrRenderable::kNo, 1, GrMipmapped::kNo, - GrMipmapStatus::kNotAllocated, GrInternalSurfaceFlags::kNone, SkBackingFit::kExact, - SkBudgeted::kNo, GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes); + format, dims, GrMipmapped::kNo, GrMipmapStatus::kNotAllocated, + GrInternalSurfaceFlags::kNone, SkBackingFit::kExact, SkBudgeted::kNo, + GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes); SkASSERT(fLazyProxy.get()); diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp index eb6bb0dd82..83ae64f296 100644 --- a/tests/ResourceAllocatorTest.cpp +++ b/tests/ResourceAllocatorTest.cpp @@ -275,10 +275,17 @@ sk_sp make_lazy(GrProxyProvider* proxyProvider, const GrCaps* ca }; GrInternalSurfaceFlags flags = GrInternalSurfaceFlags::kNone; SkISize dims = {p.fSize, p.fSize}; - return proxyProvider->createLazyProxy(callback, format, dims, p.fRenderable, p.fSampleCnt, - GrMipmapped::kNo, GrMipmapStatus::kNotAllocated, flags, - p.fFit, p.fBudgeted, GrProtected::kNo, - GrSurfaceProxy::UseAllocator::kYes); + if (p.fRenderable == GrRenderable::kYes) { + static const GrProxyProvider::TextureInfo kTexInfo = {GrMipMapped::kNo, GrTextureType::k2D}; + return proxyProvider->createLazyRenderTargetProxy( + callback, format, dims, p.fSampleCnt, flags, &kTexInfo, + GrMipmapStatus::kNotAllocated, + p.fFit, p.fBudgeted, GrProtected::kNo, false, GrSurfaceProxy::UseAllocator::kYes); + } else { + return proxyProvider->createLazyProxy( + callback, format, dims, GrMipmapped::kNo, GrMipmapStatus::kNotAllocated, flags, + p.fFit, p.fBudgeted, GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes); + } } // Set up so there are two opsTasks that need to be flushed but the resource allocator thinks