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/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp
index baff879..a32ec21 100644
--- a/src/gpu/GrBitmapTextureMaker.cpp
+++ b/src/gpu/GrBitmapTextureMaker.cpp
@@ -39,7 +39,7 @@
}
}
-GrSurfaceProxyView GrBitmapTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
+GrSurfaceProxyView GrBitmapTextureMaker::refOriginalTextureProxyView(GrMipMapped mipMapped) {
GrProxyProvider* proxyProvider = this->context()->priv().proxyProvider();
sk_sp<GrTextureProxy> proxy;
GrSwizzle swizzle;
@@ -50,7 +50,7 @@
if (proxy) {
swizzle = this->context()->priv().caps()->getReadSwizzle(proxy->backendFormat(),
this->colorType());
- if (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped()) {
+ if (mipMapped == GrMipMapped::kNo || proxy->mipMapped() == GrMipMapped::kYes) {
return GrSurfaceProxyView(std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle);
}
}
@@ -65,16 +65,14 @@
return {};
}
copy8888.setImmutable();
- proxy = proxyProvider->createProxyFromBitmap(
- copy8888, willBeMipped ? GrMipMapped::kYes : GrMipMapped::kNo, fFit);
+ proxy = proxyProvider->createProxyFromBitmap(copy8888, mipMapped, fFit);
} else {
- proxy = proxyProvider->createProxyFromBitmap(
- fBitmap, willBeMipped ? GrMipMapped::kYes : GrMipMapped::kNo, fFit);
+ proxy = proxyProvider->createProxyFromBitmap(fBitmap, mipMapped, fFit);
}
if (proxy) {
swizzle = this->context()->priv().caps()->getReadSwizzle(proxy->backendFormat(),
this->colorType());
- SkASSERT(!willBeMipped || GrMipMapped::kYes == proxy->mipMapped());
+ SkASSERT(mipMapped == GrMipMapped::kNo || proxy->mipMapped() == GrMipMapped::kYes);
if (fOriginalKey.isValid()) {
proxyProvider->assignUniqueKeyToProxy(fOriginalKey, proxy.get());
GrInstallBitmapUniqueKeyInvalidator(
@@ -85,8 +83,8 @@
}
if (proxy) {
- SkASSERT(willBeMipped);
- SkASSERT(GrMipMapped::kNo == proxy->mipMapped());
+ SkASSERT(mipMapped == GrMipMapped::kYes);
+ SkASSERT(proxy->mipMapped() == GrMipMapped::kNo);
SkASSERT(fOriginalKey.isValid());
// We need a mipped proxy, but we found a proxy earlier that wasn't mipped. Thus we generate
// a new mipped surface and copy the original proxy into the base layer. We will then let