diff options
author | Robert Phillips <robertphillips@google.com> | 2018-01-16 08:06:32 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-16 13:28:43 +0000 |
commit | 0bd24dc41f2351d84f5fce32130668a5792d134b (patch) | |
tree | c46dc6fb7636fd7c2185e1f855f1dd582512fcc4 /src/gpu/GrSurfaceProxy.cpp | |
parent | 3167aa0c9c84cab1b0252031166e4a345e2afe2d (diff) |
Funnel most proxy creation through GrProxyProvider
This is to provide a choke point for DDL to create Lazy Proxies.
Change-Id: If178da13bc6447b31b7601810236d34502d9efbd
Reviewed-on: https://skia-review.googlesource.com/93303
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrSurfaceProxy.cpp')
-rw-r--r-- | src/gpu/GrSurfaceProxy.cpp | 175 |
1 files changed, 0 insertions, 175 deletions
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index e505a9c9bd..c9da6ce592 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -223,35 +223,6 @@ GrTextureOpList* GrSurfaceProxy::getLastTextureOpList() { return fLastOpList ? fLastOpList->asTextureOpList() : nullptr; } -sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrSurface> surf, GrSurfaceOrigin origin) { - if (!surf) { - return nullptr; - } - - if (surf->getUniqueKey().isValid()) { - // The proxy may already be in the hash. Thus we need to look for it first before creating - // new one. - GrProxyProvider* provider = surf->getContext()->contextPriv().proxyProvider(); - sk_sp<GrSurfaceProxy> proxy = provider->findProxyByUniqueKey(surf->getUniqueKey(), origin); - if (proxy) { - return proxy; - } - } - - if (surf->asTexture()) { - if (surf->asRenderTarget()) { - return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(std::move(surf), origin)); - } else { - return sk_sp<GrSurfaceProxy>(new GrTextureProxy(std::move(surf), origin)); - } - } else { - SkASSERT(surf->asRenderTarget()); - - // Not texturable - return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(surf), origin)); - } -} - sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex, GrSurfaceOrigin origin) { if (!tex) { return nullptr; @@ -274,152 +245,6 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex, GrSurfac } } -sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrProxyProvider* proxyProvider, - const GrSurfaceDesc& desc, - SkBackingFit fit, - SkBudgeted budgeted, - uint32_t flags) { - SkASSERT(0 == flags || GrResourceProvider::kNoPendingIO_Flag == flags); - - const GrCaps* caps = proxyProvider->caps(); - - // TODO: move this logic into GrResourceProvider! - // TODO: share this testing code with check_texture_creation_params - if (!caps->isConfigTexturable(desc.fConfig)) { - return nullptr; - } - - bool willBeRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); - if (willBeRT && !caps->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { - return nullptr; - } - - // We currently do not support multisampled textures - if (!willBeRT && desc.fSampleCnt > 0) { - return nullptr; - } - - int maxSize; - if (willBeRT) { - maxSize = caps->maxRenderTargetSize(); - } else { - maxSize = caps->maxTextureSize(); - } - - if (desc.fWidth > maxSize || desc.fHeight > maxSize || desc.fWidth <= 0 || desc.fHeight <= 0) { - return nullptr; - } - - GrSurfaceDesc copyDesc = desc; - copyDesc.fSampleCnt = caps->getSampleCount(desc.fSampleCnt, desc.fConfig); - -#ifdef SK_DISABLE_DEFERRED_PROXIES - // Temporarily force instantiation for crbug.com/769760 and crbug.com/769898 - sk_sp<GrTexture> tex; - - if (SkBackingFit::kApprox == fit) { - tex = resourceProvider->createApproxTexture(copyDesc, flags); - } else { - tex = resourceProvider->createTexture(copyDesc, budgeted, flags); - } - - if (!tex) { - return nullptr; - } - - return GrSurfaceProxy::MakeWrapped(std::move(tex), copyDesc.fOrigin); -#else - if (willBeRT) { - // We know anything we instantiate later from this deferred path will be - // both texturable and renderable - return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(*caps, copyDesc, fit, - budgeted, flags)); - } - - return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0, flags)); -#endif -} - -sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrProxyProvider* proxyProvider, - const GrSurfaceDesc& desc, - SkBudgeted budgeted, - const void* srcData, - size_t rowBytes) { - if (srcData) { - GrMipLevel mipLevel = { srcData, rowBytes }; - - return proxyProvider->createTextureProxy(desc, budgeted, mipLevel); - } - - return GrSurfaceProxy::MakeDeferred(proxyProvider, desc, SkBackingFit::kExact, budgeted); -} - -sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferredMipMap(GrProxyProvider* proxyProvider, - const GrSurfaceDesc& desc, - SkBudgeted budgeted) { - // 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; - - 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; - } - - return MakeDeferredMipMap(proxyProvider, desc, budgeted, texels.get(), mipCount); -} - -sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferredMipMap( - GrProxyProvider* proxyProvider, - const GrSurfaceDesc& desc, - SkBudgeted budgeted, - const GrMipLevel texels[], - int mipLevelCount, - SkDestinationSurfaceColorMode mipColorMode) { - if (!mipLevelCount) { - if (texels) { - return nullptr; - } - return GrSurfaceProxy::MakeDeferred(proxyProvider, desc, budgeted, nullptr, 0); - } - if (!texels) { - return nullptr; - } - - if (1 == mipLevelCount) { - return proxyProvider->createTextureProxy(desc, budgeted, texels[0]); - } - -#ifdef SK_DEBUG - // There are only three states we want to be in when uploading data to a mipped surface. - // 1) We have data to upload to all layers - // 2) We are not uploading data to any layers - // 3) We are only uploading data to the base layer - // We check here to make sure we do not have any other state. - bool firstLevelHasData = SkToBool(texels[0].fPixels); - bool allOtherLevelsHaveData = true, allOtherLevelsLackData = true; - for (int i = 1; i < mipLevelCount; ++i) { - if (texels[i].fPixels) { - allOtherLevelsLackData = false; - } else { - allOtherLevelsHaveData = false; - } - } - SkASSERT((firstLevelHasData && allOtherLevelsHaveData) || allOtherLevelsLackData); -#endif - - return proxyProvider->createTextureProxy(desc, budgeted, texels, mipLevelCount, mipColorMode); -} - -sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrappedBackend(GrContext* context, - const GrBackendTexture& backendTex, - GrSurfaceOrigin origin) { - sk_sp<GrTexture> tex(context->resourceProvider()->wrapBackendTexture(backendTex)); - return GrSurfaceProxy::MakeWrapped(std::move(tex), origin); -} - sk_sp<GrTextureProxy> GrSurfaceProxy::MakeLazy(LazyInstantiateCallback&& callback, const GrSurfaceDesc& desc, GrMipMapped mipMapped, |