diff options
author | Robert Phillips <robertphillips@google.com> | 2016-11-09 06:50:43 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-09 12:20:50 +0000 |
commit | 3743013f755d23c215d852af7d829c3cd74f34a2 (patch) | |
tree | f685cc82d3dc40153863552b55c2519582c84d15 /src/gpu/GrSurfaceProxy.cpp | |
parent | 7b8400dad2f82dcc6ed3c7cc1707ebaf85f04840 (diff) |
Consolidate GrSurfaceProxy Make methods
I think GrSurfaceDesc is still the most compact way to communicate the deferred GrSurface's settings to the Proxy but this CL, at least, reduces where it is used.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4559
Change-Id: Ica599c28a5aef1ed4094f47a4ac119e2d204d652
Reviewed-on: https://skia-review.googlesource.com/4559
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrSurfaceProxy.cpp')
-rw-r--r-- | src/gpu/GrSurfaceProxy.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index b6d0e11cbb..da552c917e 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -10,6 +10,7 @@ #include "GrGpuResourcePriv.h" #include "GrOpList.h" #include "GrTextureProvider.h" +#include "GrTextureRenderTargetProxy.h" GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit) : INHERITED(std::move(surface)) @@ -62,3 +63,47 @@ void GrSurfaceProxy::setLastOpList(GrOpList* opList) { SkRefCnt_SafeAssign(fLastOpList, opList); } + +sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrSurface> surf) { + if (surf->asTexture()) { + if (surf->asRenderTarget()) { + return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(std::move(surf))); + } else { + return sk_sp<GrSurfaceProxy>(new GrTextureProxy(std::move(surf))); + } + } else { + SkASSERT(surf->asRenderTarget()); + + // Not texturable + return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(surf))); + } +} + +sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps, + const GrSurfaceDesc& desc, + SkBackingFit fit, + SkBudgeted budgeted) { + if (kRenderTarget_GrSurfaceFlag & desc.fFlags) { + // We know anything we instantiate later from this deferred path will be + // both texturable and renderable + return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(caps, desc, fit, budgeted)); + } + + return sk_sp<GrSurfaceProxy>(new GrTextureProxy(desc, fit, budgeted, nullptr, 0)); +} + +sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps, + GrTextureProvider* texProvider, + const GrSurfaceDesc& desc, + SkBudgeted budgeted, + const void* srcData, + size_t rowBytes) { + if (srcData) { + // If we have srcData, for now, we create a wrapped GrTextureProxy + sk_sp<GrSurface> surf(texProvider->createTexture(desc, budgeted, srcData, rowBytes)); + return GrSurfaceProxy::MakeWrapped(std::move(surf)); + } + + return GrSurfaceProxy::MakeDeferred(caps, desc, SkBackingFit::kExact, budgeted); +} + |