diff options
author | Chris Dalton <csmartdalton@google.com> | 2017-11-29 22:01:06 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-30 15:37:12 +0000 |
commit | 706a6ff60c55bee85cff06fc9f8f3764f6e5154b (patch) | |
tree | ce416111dc4101cf58ee12bd7c35007317f33819 /src/gpu/GrTextureRenderTargetProxy.cpp | |
parent | de2f1dfebd9d28787cdfd77496f365ed3eb6894d (diff) |
Add "lazy" texture proxies
Adds ultra-deferred proxies that are instantiated by a user-supplied
callback during flush.
Bug: skia:7190
Change-Id: I75a7ac6dba953c3b0a99febc203a7f4d2f3789fc
Reviewed-on: https://skia-review.googlesource.com/76461
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrTextureRenderTargetProxy.cpp')
-rw-r--r-- | src/gpu/GrTextureRenderTargetProxy.cpp | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp index dd79bfefff..943523116d 100644 --- a/src/gpu/GrTextureRenderTargetProxy.cpp +++ b/src/gpu/GrTextureRenderTargetProxy.cpp @@ -7,6 +7,10 @@ #include "GrTextureRenderTargetProxy.h" +#include "GrTexture.h" +#include "GrRenderTarget.h" +#include "GrSurfaceProxyPriv.h" + // Deferred version // This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and // GrRenderTargetProxy) so its constructor must be explicitly called. @@ -15,10 +19,20 @@ GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps, SkBackingFit fit, SkBudgeted budgeted, uint32_t flags) - : GrSurfaceProxy(desc, fit, budgeted, flags) - // for now textures w/ data are always wrapped - , GrTextureProxy(desc, fit, budgeted, nullptr, 0, flags) - , GrRenderTargetProxy(caps, desc, fit, budgeted, flags) { + : GrSurfaceProxy(desc, fit, budgeted, flags) + // for now textures w/ data are always wrapped + , GrTextureProxy(desc, fit, budgeted, nullptr, 0, flags) + , GrRenderTargetProxy(caps, desc, fit, budgeted, flags) { +} + +// Lazy-callback version +GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(LazyInstantiateCallback&& callback, + GrPixelConfig config) + : GrSurfaceProxy(std::move(callback), config) + // Since we have virtual inheritance, we initialize GrSurfaceProxy directly. Send null + // callbacks to the texture and RT proxies simply to route to the appropriate constructors. + , GrTextureProxy(LazyInstantiateCallback(), config) + , GrRenderTargetProxy(LazyInstantiateCallback(), config) { } // Wrapped version @@ -26,9 +40,9 @@ GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps, // GrRenderTargetProxy) so its constructor must be explicitly called. GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf, GrSurfaceOrigin origin) - : GrSurfaceProxy(surf, origin, SkBackingFit::kExact) - , GrTextureProxy(surf, origin) - , GrRenderTargetProxy(surf, origin) { + : GrSurfaceProxy(surf, origin, SkBackingFit::kExact) + , GrTextureProxy(surf, origin) + , GrRenderTargetProxy(surf, origin) { SkASSERT(surf->asTexture()); SkASSERT(surf->asRenderTarget()); } @@ -37,8 +51,8 @@ size_t GrTextureRenderTargetProxy::onUninstantiatedGpuMemorySize() const { int colorSamplesPerPixel = this->numColorSamples() + 1; // TODO: do we have enough information to improve this worst case estimate? - return GrSurface::ComputeSize(fConfig, fWidth, fHeight, colorSamplesPerPixel, this->mipMapped(), - SkBackingFit::kApprox == fFit); + return GrSurface::ComputeSize(this->config(), this->width(), this->height(), + colorSamplesPerPixel, this->mipMapped(), !this->priv().isExact()); } bool GrTextureRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider) { @@ -77,3 +91,11 @@ sk_sp<GrSurface> GrTextureRenderTargetProxy::createSurface( return surface; } +#ifdef SK_DEBUG +void GrTextureRenderTargetProxy::validateLazyTexture(const GrTexture* texture) { + SkASSERT(texture->asRenderTarget()); + SkASSERT(texture->asRenderTarget()->numStencilSamples() == this->numStencilSamples()); + SkASSERT(GrMipMapped::kNo == this->mipMapped()); +} +#endif + |