Add asDeferredTexture & asDeferredRenderTarget helpers to GrSurfaceContext

These are proving useful in the read/write-Pixels migration

Change-Id: I297f31968362d205977b769808320b1dc06249df
Reviewed-on: https://skia-review.googlesource.com/5936
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2016-12-14 08:46:47 -05:00 committed by Skia Commit-Bot
parent 0d413f0f45
commit 2734136b68
4 changed files with 21 additions and 1 deletions

View File

@ -372,7 +372,9 @@ public:
return fRenderTargetProxy->instantiate(fContext->textureProvider());
}
GrTextureProxy* asDeferredTexture();
GrSurfaceProxy* asDeferredSurface() override { return fRenderTargetProxy.get(); }
GrTextureProxy* asDeferredTexture() override;
GrRenderTargetProxy* asDeferredRenderTarget() override { return fRenderTargetProxy.get(); }
sk_sp<GrTexture> asTexture() {
if (!this->accessRenderTarget()) {

View File

@ -12,8 +12,11 @@
class GrAuditTrail;
class GrContext;
class GrRenderTargetProxy;
class GrSingleOwner;
class GrSurface;
class GrSurfaceProxy;
class GrTextureProxy;
struct SkIPoint;
struct SkIRect;
@ -26,6 +29,11 @@ public:
virtual bool copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) = 0;
// TODO: this is virtual b.c. this object doesn't have a pointer to the wrapped GrSurfaceProxy?
virtual GrSurfaceProxy* asDeferredSurface() = 0;
virtual GrTextureProxy* asDeferredTexture() = 0;
virtual GrRenderTargetProxy* asDeferredRenderTarget() = 0;
GrAuditTrail* auditTrail() { return fAuditTrail; }
protected:

View File

@ -29,6 +29,10 @@ public:
bool copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override;
GrSurfaceProxy* asDeferredSurface() override { return fTextureProxy.get(); }
GrTextureProxy* asDeferredTexture() override { return fTextureProxy.get(); }
GrRenderTargetProxy* asDeferredRenderTarget() override;
protected:
GrTextureContext(GrContext*, GrDrawingManager*, sk_sp<GrTextureProxy>, GrAuditTrail*,
GrSingleOwner*);

View File

@ -45,6 +45,12 @@ GrTextureContext::~GrTextureContext() {
SkSafeUnref(fOpList);
}
GrRenderTargetProxy* GrTextureContext::asDeferredRenderTarget() {
// If the proxy can return an RTProxy it should've been wrapped in a RTContext
SkASSERT(!fTextureProxy->asRenderTargetProxy());
return nullptr;
}
GrTextureOpList* GrTextureContext::getOpList() {
ASSERT_SINGLE_OWNER
SkDEBUGCODE(this->validate();)