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 ab4c138c0e.

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>
This commit is contained in:
Brian Osman 2019-03-25 10:12:57 -04:00 committed by Skia Commit-Bot
parent ddba4e646a
commit 7dcc616279
3 changed files with 15 additions and 38 deletions

View File

@ -297,6 +297,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(const GrBackendFormat&
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 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxyFromBitmap(const SkBitmap& bit
// 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 =

View File

@ -546,23 +546,10 @@ sk_sp<SkImage> SkImage::MakeCrossContextFromPixmap(GrContext* context,
}
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);
}

View File

@ -218,6 +218,10 @@ sk_sp<SkImage> SkImage::MakeFromYUVAPixmaps(
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 @@ sk_sp<SkImage> SkImage::MakeFromYUVAPixmaps(
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;
}