diff options
author | Greg Daniel <egdaniel@google.com> | 2018-02-14 14:40:37 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-14 14:40:48 +0000 |
commit | 0ee866dac78b60497b4c107995d3c2747309ef8b (patch) | |
tree | c03802d73fe912e44880e822ba179c6889e16ee8 /src/gpu | |
parent | 83373a82747ab600e91873f594cd8df65e1676a4 (diff) |
Revert "When creating emptyp MipMap proxies, don't instantiate them immediately."
This reverts commit 8242c5c199f5d04e4209222b265f9e27f7c55fa7.
Reason for revert: Hitting assert on intel bots on skbug6850overlay2.skp, SkASSERT(proxy->getUniqueKey().isValid()); in processInvalidProxyUniqueKey
Original change's description:
> When creating emptyp MipMap proxies, don't instantiate them immediately.
>
> This chnages makes it match how we handle non mipped proxies where we
> don't actually instantiate them until we need to.
>
> Bug: skia:
> Change-Id: Id0c50eefce43ef1458a3ff0bb1881a817b045279
> Reviewed-on: https://skia-review.googlesource.com/106966
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
TBR=egdaniel@google.com,robertphillips@google.com
Change-Id: I1fa6165b69c5bbb1d6bb10abba33dcdb55a27ba3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/107263
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrProxyProvider.cpp | 40 | ||||
-rw-r--r-- | src/gpu/GrProxyProvider.h | 9 | ||||
-rw-r--r-- | src/gpu/GrSurfaceProxy.cpp | 27 | ||||
-rw-r--r-- | src/gpu/GrTextureProxy.cpp | 7 | ||||
-rw-r--r-- | src/gpu/GrTextureRenderTargetProxy.cpp | 5 | ||||
-rw-r--r-- | src/gpu/GrTextureRenderTargetProxy.h | 2 |
6 files changed, 37 insertions, 53 deletions
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index e520046e7c..d051bfdc13 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -252,7 +252,28 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(const GrSurfaceDesc& de return nullptr; } - return this->createProxy(desc, GrMipMapped::kYes, SkBackingFit::kExact, budgeted, 0); + // 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); } sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitmap& bitmap, @@ -340,21 +361,12 @@ 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 (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)) { + if (!this->caps()->validateSurfaceDesc(desc, GrMipMapped::kNo)) { return nullptr; } GrSurfaceDesc copyDesc = desc; @@ -367,12 +379,10 @@ 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, mipMapped, fit, budgeted, - flags)); + new GrTextureRenderTargetProxy(*this->caps(), copyDesc, fit, budgeted, flags)); } - return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, mipMapped, fit, budgeted, nullptr, 0, - flags)); + return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0, flags)); } sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy( diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h index 01b3b1f305..7e7f852d91 100644 --- a/src/gpu/GrProxyProvider.h +++ b/src/gpu/GrProxyProvider.h @@ -106,13 +106,8 @@ public: /* * Create a GrSurfaceProxy without any data. */ - sk_sp<GrTextureProxy> createProxy(const GrSurfaceDesc&, GrMipMapped, SkBackingFit, SkBudgeted, - uint32_t flags); - - sk_sp<GrTextureProxy> createProxy(const GrSurfaceDesc& desc, SkBackingFit fit, - SkBudgeted budgeted, uint32_t flags = 0) { - return this->createProxy(desc, GrMipMapped::kNo, fit, budgeted, flags); - } + sk_sp<GrTextureProxy> createProxy(const GrSurfaceDesc&, SkBackingFit, SkBudgeted, + uint32_t flags = 0); // These match the definitions in SkImage & GrTexture.h, for whence they came typedef void* ReleaseContext; diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index 5b20ca5146..48d4be1c8a 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -117,6 +117,7 @@ sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl( GrSurfaceFlags flags, GrMipMapped mipMapped) const { SkASSERT(GrSurfaceProxy::LazyState::kNot == this->lazyInstantiationState()); SkASSERT(!fTarget); + SkASSERT(GrMipMapped::kNo == mipMapped); GrSurfaceDesc desc; desc.fFlags = flags; if (fNeedsClear) { @@ -129,30 +130,10 @@ sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl( desc.fSampleCnt = sampleCnt; sk_sp<GrSurface> surface; - if (GrMipMapped::kYes == mipMapped) { - SkASSERT(SkBackingFit::kExact == fFit); - - // 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; - // We should have caught the case where mipCount == 1 when making the proxy and instead - // created a non-mipmapped proxy. - SkASSERT(mipCount > 1); - 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; - } - - surface = resourceProvider->createTexture(desc, fBudgeted, texels.get(), mipCount, - SkDestinationSurfaceColorMode::kLegacy); + if (SkBackingFit::kApprox == fFit) { + surface.reset(resourceProvider->createApproxTexture(desc, fFlags).release()); } else { - if (SkBackingFit::kApprox == fFit) { - surface = resourceProvider->createApproxTexture(desc, fFlags); - } else { - surface = resourceProvider->createTexture(desc, fBudgeted, fFlags); - } + surface.reset(resourceProvider->createTexture(desc, fBudgeted, fFlags).release()); } if (!surface) { return nullptr; diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp index d6ce9feda4..9245221ef3 100644 --- a/src/gpu/GrTextureProxy.cpp +++ b/src/gpu/GrTextureProxy.cpp @@ -15,11 +15,10 @@ #include "GrTexturePriv.h" // Deferred version -GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, GrMipMapped mipMapped, - SkBackingFit fit, SkBudgeted budgeted, const void* srcData, - size_t /*rowBytes*/, uint32_t flags) +GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, SkBudgeted budgeted, + const void* srcData, size_t /*rowBytes*/, uint32_t flags) : INHERITED(srcDesc, fit, budgeted, flags) - , fMipMapped(mipMapped) + , fMipMapped(GrMipMapped::kNo) , fProxyProvider(nullptr) , fDeferredUploader(nullptr) { SkASSERT(!srcData); // currently handled in Make() diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp index 50077c4c0f..2d5dbeee9f 100644 --- a/src/gpu/GrTextureRenderTargetProxy.cpp +++ b/src/gpu/GrTextureRenderTargetProxy.cpp @@ -19,13 +19,12 @@ // GrRenderTargetProxy) so its constructor must be explicitly called. GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc& desc, - GrMipMapped mipMapped, SkBackingFit fit, SkBudgeted budgeted, uint32_t flags) : GrSurfaceProxy(desc, fit, budgeted, flags) // for now textures w/ data are always wrapped - , GrTextureProxy(desc, mipMapped, fit, budgeted, nullptr, 0, flags) + , GrTextureProxy(desc, fit, budgeted, nullptr, 0, flags) , GrRenderTargetProxy(caps, desc, fit, budgeted, flags) { } @@ -60,7 +59,7 @@ size_t GrTextureRenderTargetProxy::onUninstantiatedGpuMemorySize() const { int colorSamplesPerPixel = this->numColorSamples(); if (colorSamplesPerPixel > 1) { // Add one to account for the resolve buffer. - ++colorSamplesPerPixel; + ++colorSamplesPerPixel += 1; } // TODO: do we have enough information to improve this worst case estimate? diff --git a/src/gpu/GrTextureRenderTargetProxy.h b/src/gpu/GrTextureRenderTargetProxy.h index 06a84c206d..178185d77b 100644 --- a/src/gpu/GrTextureRenderTargetProxy.h +++ b/src/gpu/GrTextureRenderTargetProxy.h @@ -28,7 +28,7 @@ private: friend class GrProxyProvider; // for ctors // Deferred version - GrTextureRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, GrMipMapped, + GrTextureRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, SkBackingFit, SkBudgeted, uint32_t flags); // Lazy-callback version |