Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: include/gpu/GrSurface.h

Issue 1169553003: add callbacks to Images that wrap client-provided content (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: privatize Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkImageInfo.h ('k') | src/gpu/GrSurface.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrSurface.h
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h
index 2b40f9c1d7ddd2f3c854aa2ade912f014bf3f9ed..4d40e2e8142cfdbe9fe1a8a9e360370553610cb3 100644
--- a/include/gpu/GrSurface.h
+++ b/include/gpu/GrSurface.h
@@ -127,6 +127,14 @@ public:
inline GrSurfacePriv surfacePriv();
inline const GrSurfacePriv surfacePriv() const;
+ typedef void* ReleaseCtx;
+ typedef void (*ReleaseProc)(ReleaseCtx);
+
+ void setRelease(ReleaseProc proc, ReleaseCtx ctx) {
+ fReleaseProc = proc;
+ fReleaseCtx = ctx;
+ }
+
protected:
// Methods made available via GrSurfacePriv
SkImageInfo info() const;
@@ -140,12 +148,32 @@ protected:
GrSurface(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc)
: INHERITED(gpu, lifeCycle)
- , fDesc(desc) {
+ , fDesc(desc)
+ , fReleaseProc(NULL)
+ , fReleaseCtx(NULL)
+ {}
+
+ ~GrSurface() override {
+ // check that invokeReleaseProc has been called (if needed)
+ SkASSERT(NULL == fReleaseProc);
}
GrSurfaceDesc fDesc;
+ void onRelease() override;
+ void onAbandon() override;
+
private:
+ void invokeReleaseProc() {
+ if (fReleaseProc) {
+ fReleaseProc(fReleaseCtx);
+ fReleaseProc = NULL;
+ }
+ }
+
+ ReleaseProc fReleaseProc;
+ ReleaseCtx fReleaseCtx;
+
typedef GrGpuResource INHERITED;
};
« no previous file with comments | « include/core/SkImageInfo.h ('k') | src/gpu/GrSurface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698