aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrProxyProvider.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-02-15 13:06:26 -0500
committerGravatar Greg Daniel <egdaniel@google.com>2018-02-15 20:13:32 +0000
commitf6f7b67ac230b14a725fbdabe951c70ea5b4428f (patch)
treea75cefe0e22e69aeaa9a862714818d4684afddc3 /src/gpu/GrProxyProvider.cpp
parent602836138e02935885c77f9dd93dcb51a3ec9a64 (diff)
When creating emptyp MipMap proxies, don't instantiate them immediately. Attempt 3
original: https://skia-review.googlesource.com/106966 Bug: skia: Change-Id: I779985cef2d3c4f36a0129d8ecedd12e510bec7e Reviewed-on: https://skia-review.googlesource.com/107781 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrProxyProvider.cpp')
-rw-r--r--src/gpu/GrProxyProvider.cpp40
1 files changed, 15 insertions, 25 deletions
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index d051bfdc13..e520046e7c 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -252,28 +252,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(const GrSurfaceDesc& de
return nullptr;
}
- // SkMipMap doesn't include the base level in the level count so we have to add 1
- int mipCount = SkMipMap::ComputeLevelCount(desc.fWidth, desc.fHeight) + 1;
- if (1 == mipCount) {
- return this->createProxy(desc, SkBackingFit::kExact, budgeted);
- }
-
- std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipCount]);
-
- // We don't want to upload any texel data
- for (int i = 0; i < mipCount; i++) {
- texels[i].fPixels = nullptr;
- texels[i].fRowBytes = 0;
- }
-
- sk_sp<GrTexture> tex(fResourceProvider->createTexture(desc, budgeted,
- texels.get(), mipCount,
- SkDestinationSurfaceColorMode::kLegacy));
- if (!tex) {
- return nullptr;
- }
-
- return this->createWrapped(std::move(tex), desc.fOrigin);
+ return this->createProxy(desc, GrMipMapped::kYes, SkBackingFit::kExact, budgeted, 0);
}
sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitmap& bitmap,
@@ -361,12 +340,21 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitma
}
sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrSurfaceDesc& desc,
+ GrMipMapped mipMapped,
SkBackingFit fit,
SkBudgeted budgeted,
uint32_t flags) {
SkASSERT(0 == flags || GrResourceProvider::kNoPendingIO_Flag == flags);
- if (!this->caps()->validateSurfaceDesc(desc, GrMipMapped::kNo)) {
+ if (GrMipMapped::kYes == mipMapped) {
+ // SkMipMap doesn't include the base level in the level count so we have to add 1
+ int mipCount = SkMipMap::ComputeLevelCount(desc.fWidth, desc.fHeight) + 1;
+ if (1 == mipCount) {
+ mipMapped = GrMipMapped::kNo;
+ }
+ }
+
+ if (!this->caps()->validateSurfaceDesc(desc, mipMapped)) {
return nullptr;
}
GrSurfaceDesc copyDesc = desc;
@@ -379,10 +367,12 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrSurfaceDesc& desc,
// We know anything we instantiate later from this deferred path will be
// both texturable and renderable
return sk_sp<GrTextureProxy>(
- new GrTextureRenderTargetProxy(*this->caps(), copyDesc, fit, budgeted, flags));
+ new GrTextureRenderTargetProxy(*this->caps(), copyDesc, mipMapped, fit, budgeted,
+ flags));
}
- return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0, flags));
+ return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, mipMapped, fit, budgeted, nullptr, 0,
+ flags));
}
sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(