diff options
Diffstat (limited to 'src/gpu/GrSurfaceProxy.cpp')
-rw-r--r-- | src/gpu/GrSurfaceProxy.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index c5afd0f262..b6d0e11cbb 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -9,6 +9,7 @@ #include "GrGpuResourcePriv.h" #include "GrOpList.h" +#include "GrTextureProvider.h" GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit) : INHERITED(std::move(surface)) @@ -27,6 +28,29 @@ GrSurfaceProxy::~GrSurfaceProxy() { SkSafeUnref(fLastOpList); } +GrSurface* GrSurfaceProxy::instantiate(GrTextureProvider* texProvider) { + if (fTarget) { + return fTarget; + } + + if (SkBackingFit::kApprox == fFit) { + fTarget = texProvider->createApproxTexture(fDesc); + } else { + fTarget = texProvider->createTexture(fDesc, fBudgeted); + } + if (!fTarget) { + return nullptr; + } + +#ifdef SK_DEBUG + if (kInvalidGpuMemorySize != this->getRawGpuMemorySize_debugOnly()) { + SkASSERT(fTarget->gpuMemorySize() <= this->getRawGpuMemorySize_debugOnly()); + } +#endif + + return fTarget; +} + void GrSurfaceProxy::setLastOpList(GrOpList* opList) { if (fLastOpList) { // The non-MDB world never closes so we can't check this condition |