Add a deferred copy surface (take 3)
This CL forces all GrSurface copies to go through a GrSurfaceContext (rather than GrContext).
There is a bit of goofiness going on here until read/writePixels is also consolidated in GrSurfaceContext and a proxy-backed SkImage/SkSurface is added.
This is a reland of https://skia-review.googlesource.com/c/5773/ (Add a deferred copy surface)
Change-Id: Ib8fd96d0569274ef781366eb900ed8ee839ae9bd
Reviewed-on: https://skia-review.googlesource.com/6109
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h
index 83107da..7f026ba 100644
--- a/include/private/GrRenderTargetProxy.h
+++ b/include/private/GrRenderTargetProxy.h
@@ -53,6 +53,9 @@
GrRenderTarget::Flags testingOnly_getFlags() const;
+ // TODO: move this to a priv class!
+ bool refsWrappedObjects() const;
+
protected:
friend class GrSurfaceProxy; // for ctors
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h
index 731603b..12972c2 100644
--- a/include/private/GrSurfaceProxy.h
+++ b/include/private/GrSurfaceProxy.h
@@ -266,6 +266,20 @@
return fGpuMemorySize;
}
+ // Helper function that creates a temporary SurfaceContext to perform the copy
+ static sk_sp<GrSurfaceProxy> Copy(GrContext*, GrSurfaceProxy* src,
+ SkIRect srcRect, SkBudgeted);
+
+ // Copy the entire 'src'
+ static sk_sp<GrSurfaceProxy> Copy(GrContext* context, GrSurfaceProxy* src,
+ SkBudgeted budgeted) {
+ return Copy(context, src, SkIRect::MakeWH(src->width(), src->height()), budgeted);
+ }
+
+ // Test-only entry point - should decrease in use as proxies propagate
+ static sk_sp<GrSurfaceProxy> TestCopy(GrContext* context, const GrSurfaceDesc& dstDesc,
+ GrTexture* srcTexture, SkBudgeted budgeted);
+
bool isWrapped_ForTesting() const;
SkDEBUGCODE(void validate(GrContext*) const;)