Reland "Simplify two more clients of proxy provider (mipped vs. non-mipped)"
Adds fix for mip-mapped requests on devices with no mip support.
This reverts commit ab4c138c0ef38ba1451698defb9b2b9518b96525.
Bug: skia:
Change-Id: I85350ae32081253448cbd2f636ea3044eb9df453
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/203057
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 611d4bc..efa7bf0 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -297,6 +297,7 @@
sk_sp<GrTextureProxy> GrProxyProvider::createProxyFromBitmap(const SkBitmap& bitmap,
GrMipMapped mipMapped) {
ASSERT_SINGLE_OWNER
+ SkASSERT(GrMipMapped::kNo == mipMapped || this->caps()->mipMapSupport());
if (this->isAbandoned()) {
return nullptr;
@@ -323,8 +324,8 @@
// If mips weren't requested (or this was too small to have any), then take the fast path
if (GrMipMapped::kNo == mipMapped ||
0 == SkMipMap::ComputeLevelCount(baseLevel->width(), baseLevel->height())) {
- return this->createTextureProxy(baseLevel, kNone_GrSurfaceFlags, 1, SkBudgeted::kYes,
- SkBackingFit::kExact);
+ return this->createTextureProxy(std::move(baseLevel), kNone_GrSurfaceFlags, 1,
+ SkBudgeted::kYes, SkBackingFit::kExact);
}
const GrBackendFormat format =
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 21aae69..b5a4a09 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -546,23 +546,10 @@
}
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
// Turn the pixmap into a GrTextureProxy
- sk_sp<GrTextureProxy> proxy;
- if (buildMips) {
- SkBitmap bmp;
- bmp.installPixels(*pixmap);
- proxy = proxyProvider->createProxyFromBitmap(bmp, GrMipMapped::kYes);
- } else {
- if (SkImageInfoIsValid(pixmap->info())) {
- ATRACE_ANDROID_FRAMEWORK("Upload Texture [%ux%u]", pixmap->width(), pixmap->height());
- // We don't need a release proc on the data in pixmap since we know we are in a
- // GrContext that has a resource provider. Thus the createTextureProxy call will
- // immediately upload the data.
- sk_sp<SkImage> image = SkImage::MakeFromRaster(*pixmap, nullptr, nullptr);
- proxy = proxyProvider->createTextureProxy(std::move(image), kNone_GrSurfaceFlags, 1,
- SkBudgeted::kYes, SkBackingFit::kExact);
- }
- }
-
+ SkBitmap bmp;
+ bmp.installPixels(*pixmap);
+ GrMipMapped mipMapped = buildMips ? GrMipMapped::kYes : GrMipMapped::kNo;
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createProxyFromBitmap(bmp, mipMapped);
if (!proxy) {
return SkImage::MakeRasterCopy(*pixmap);
}
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index 63ef026..17766b0 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -218,6 +218,10 @@
return nullptr;
}
+ if (!context->priv().caps()->mipMapSupport()) {
+ buildMips = false;
+ }
+
// Make proxies
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> tempTextureProxies[4];
@@ -240,25 +244,10 @@
pixmap = &resized;
}
// Turn the pixmap into a GrTextureProxy
- if (buildMips) {
- SkBitmap bmp;
- bmp.installPixels(*pixmap);
- tempTextureProxies[i] = proxyProvider->createProxyFromBitmap(bmp, GrMipMapped::kYes);
- }
- if (!tempTextureProxies[i]) {
- if (SkImageInfoIsValid(pixmap->info())) {
- ATRACE_ANDROID_FRAMEWORK("Upload Texture [%ux%u]",
- pixmap->width(), pixmap->height());
- // We don't need a release proc on the data in pixmap since we know we are in a
- // GrContext that has a resource provider. Thus the createTextureProxy call will
- // immediately upload the data.
- sk_sp<SkImage> image = SkImage::MakeFromRaster(*pixmap, nullptr, nullptr);
- tempTextureProxies[i] =
- proxyProvider->createTextureProxy(std::move(image), kNone_GrSurfaceFlags, 1,
- SkBudgeted::kYes, SkBackingFit::kExact);
- }
- }
-
+ SkBitmap bmp;
+ bmp.installPixels(*pixmap);
+ GrMipMapped mipMapped = buildMips ? GrMipMapped::kYes : GrMipMapped::kNo;
+ tempTextureProxies[i] = proxyProvider->createProxyFromBitmap(bmp, mipMapped);
if (!tempTextureProxies[i]) {
return nullptr;
}