Add asDeferredTexture & asDeferredRenderTarget helpers to GrSurfaceContext
authorRobert Phillips <robertphillips@google.com>
Wed, 14 Dec 2016 13:46:47 +0000 (08:46 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 14 Dec 2016 14:35:52 +0000 (14:35 +0000)
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>

include/gpu/GrRenderTargetContext.h
include/gpu/GrSurfaceContext.h
include/gpu/GrTextureContext.h
src/gpu/GrTextureContext.cpp

index 5317c3e..620bb6f 100644 (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()) {
index a05d37f..29a3f3d 100644 (file)
 
 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:
index da71c07..28fe63d 100644 (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*);
index 22620fe..59dae3f 100644 (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();)