Simplify view getters on GrTextureProducer.
The only thing that affects the view returned is whether it ought to
be MIP mapped or not. So don't take a whole GrSamplerState.
The view() function won't ever change the colortype so just query
GrTextureProducer rather than having view() return a tuple.
The rest is transitively reaching through callers and callees of
GrTextureProducer::view() to only pass filter or GrMipMapped instead of
GrSamplerState. Also, some params that indicate whether MIPs are
requested are changed from bool to GrMipMapped. And some minor style
stuff (mainly de-yoda-ifying GrMipMapped checks, using
GrSurfaceProxyView operator bool()).
Change-Id: Ia184aa793cf51d42642ea3bb0521ce06da2efb10
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274205
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 096a17d..2a807d6 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -93,9 +93,10 @@
refHelper->unref();
}
-GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture(
- GrRecordingContext* context, const SkImageInfo& info,
- const SkIPoint& origin, bool willNeedMipMaps) {
+GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture(GrRecordingContext* context,
+ const SkImageInfo& info,
+ const SkIPoint& origin,
+ GrMipMapped mipMapped) {
SkASSERT(context);
if (context->backend() != fBackendTexture.backend()) {
@@ -144,7 +145,8 @@
GrColorType grColorType = SkColorTypeToGrColorType(info.colorType());
- GrMipMapped mipMapped = fBackendTexture.hasMipMaps() ? GrMipMapped::kYes : GrMipMapped::kNo;
+ GrMipMapped textureIsMipMapped = fBackendTexture.hasMipMaps() ? GrMipMapped::kYes
+ : GrMipMapped::kNo;
// Ganesh assumes that, when wrapping a mipmapped backend texture from a client, that its
// mipmaps are fully fleshed out.
@@ -155,12 +157,11 @@
// Must make copies of member variables to capture in the lambda since this image generator may
// be deleted before we actually execute the lambda.
- sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
- [
- refHelper = fRefHelper, releaseProcHelper, backendTexture = fBackendTexture,
- grColorType
- ](GrResourceProvider * resourceProvider)
- ->GrSurfaceProxy::LazyCallbackResult {
+ sk_sp<GrTextureProxy> proxy =
+ proxyProvider->createLazyProxy(
+ [refHelper = fRefHelper, releaseProcHelper, backendTexture = fBackendTexture,
+ grColorType](GrResourceProvider* resourceProvider)
+ -> GrSurfaceProxy::LazyCallbackResult {
if (refHelper->fSemaphore) {
resourceProvider->priv().gpu()->waitSemaphore(
refHelper->fSemaphore.get());
@@ -201,22 +202,22 @@
return {std::move(tex), true,
GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced};
},
- backendFormat, fBackendTexture.dimensions(), readSwizzle, GrRenderable::kNo, 1,
- mipMapped, mipMapsStatus, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact,
- SkBudgeted::kNo, GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes);
+ backendFormat, fBackendTexture.dimensions(), readSwizzle, GrRenderable::kNo, 1,
+ textureIsMipMapped, mipMapsStatus, GrInternalSurfaceFlags::kReadOnly,
+ SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo,
+ GrSurfaceProxy::UseAllocator::kYes);
if (!proxy) {
return {};
}
if (origin.isZero() && info.dimensions() == fBackendTexture.dimensions() &&
- (!willNeedMipMaps || GrMipMapped::kYes == proxy->mipMapped())) {
+ (mipMapped == GrMipMapped::kNo || proxy->mipMapped() == GrMipMapped::kYes)) {
// If the caller wants the entire texture and we have the correct mip support, we're done
return GrSurfaceProxyView(std::move(proxy), fSurfaceOrigin, readSwizzle);
} else {
// Otherwise, make a copy of the requested subset. Make sure our temporary is renderable,
// because Vulkan will want to do the copy as a draw. All other copies would require a
// layout change in Vulkan and we do not change the layout of borrowed images.
- GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, info.width(), info.height());
return GrSurfaceProxy::Copy(