Chromium Code Reviews| Index: include/gpu/GrSurface.h |
| diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h |
| index 2b40f9c1d7ddd2f3c854aa2ade912f014bf3f9ed..b01b6928ac49520557eb69cc3a2f2fc2a028b1e9 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 invokeReleaseProc() { |
|
bsalomon
2015/06/18 20:39:13
private?
|
| + if (fReleaseProc) { |
| + fReleaseProc(fReleaseCtx); |
| + fReleaseProc = NULL; |
| + } |
| + } |
| + |
| + void onRelease() override; |
| + void onAbandon() override; |
| + |
| private: |
| + ReleaseProc fReleaseProc; |
| + ReleaseCtx fReleaseCtx; |
| + |
| typedef GrGpuResource INHERITED; |
| }; |