Cleanup mip-mapped proxy creation slightly

Re-land of portions of https://skia-review.googlesource.com/c/skia/+/154080,
without deferring the mipmap construction.

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>
This commit is contained in:
Brian Osman 2018-09-13 13:43:25 -04:00 committed by Skia Commit-Bot
parent 1b97f13904
commit bc6b9cb6ac

View File

@ -279,20 +279,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitma
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, 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
@ -300,18 +287,23 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitma
SkCopyPixelsMode copyMode = this->recordingDDL() ? kIfMutable_SkCopyPixelsMode
: kNever_SkCopyPixelsMode;
sk_sp<SkImage> baseLevel = SkMakeImageFromRasterBitmap(bitmap, copyMode);
if (!baseLevel) {
return nullptr;
}
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info());
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, 1, SkBudgeted::kYes,
SkBackingFit::kExact);
}
sk_sp<SkMipMap> mipmaps(SkMipMap::Build(bitmap, nullptr));
if (!mipmaps) {
return nullptr;
}
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info());
sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
[desc, baseLevel, mipmaps](GrResourceProvider* resourceProvider) {
if (!resourceProvider) {