Cleanup mip-mapped proxy creation slightly
Cherry-pick of https://skia-review.googlesource.com/c/skia/+/154305
to android/next-release. First of two changes to support fallback
for uploading F16 bitmaps.
No-Tree-Checks: true
No-Try: true
No-Presubmit: true
Bug: skia:8375
Change-Id: Ie0b1468839418032fa882f08c5d9a16de97ac38a
Reviewed-On: https://skia-review.googlesource.com/154305
Reviewed-By: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-on: https://skia-review.googlesource.com/154621
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 0027f2a..4ca0511 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -289,20 +289,7 @@
return nullptr;
}
- SkPixmap pixmap;
- if (!bitmap.peekPixels(&pixmap)) {
- return nullptr;
- }
-
- ATRACE_ANDROID_FRAMEWORK("Upload MipMap Texture [%ux%u]", pixmap.width(), pixmap.height());
- sk_sp<SkMipMap> mipmaps(SkMipMap::Build(pixmap, mipColorMode, nullptr));
- if (!mipmaps) {
- return nullptr;
- }
-
- if (mipmaps->countLevels() < 0) {
- return nullptr;
- }
+ ATRACE_ANDROID_FRAMEWORK("Upload MipMap Texture [%ux%u]", bitmap.width(), bitmap.height());
// In non-ddl we will always instantiate right away. Thus we never want to copy the SkBitmap
// even if its mutable. In ddl, if the bitmap is mutable then we must make a copy since the
@@ -310,19 +297,23 @@
SkCopyPixelsMode copyMode = this->mutableBitmapsNeedCopy() ? kIfMutable_SkCopyPixelsMode
: kNever_SkCopyPixelsMode;
sk_sp<SkImage> baseLevel = SkMakeImageFromRasterBitmap(bitmap, copyMode);
-
if (!baseLevel) {
return nullptr;
}
- GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *this->caps());
-
- if (0 == mipmaps->countLevels()) {
+ // This was never going to have mips anyway
+ if (0 == SkMipMap::ComputeLevelCount(baseLevel->width(), baseLevel->height())) {
return this->createTextureProxy(baseLevel, kNone_GrSurfaceFlags, kTopLeft_GrSurfaceOrigin,
1, SkBudgeted::kYes, SkBackingFit::kExact);
-
}
+ sk_sp<SkMipMap> mipmaps(SkMipMap::Build(bitmap, mipColorMode, nullptr));
+ if (!mipmaps) {
+ return nullptr;
+ }
+
+ GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *this->caps());
+
sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
[desc, baseLevel, mipmaps, mipColorMode]
(GrResourceProvider* resourceProvider) {