OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef GrSurface_DEFINED | 9 #ifndef GrSurface_DEFINED |
10 #define GrSurface_DEFINED | 10 #define GrSurface_DEFINED |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 /** | 120 /** |
121 * After this returns any pending writes to the surface will be issued to th
e backend 3D API and | 121 * After this returns any pending writes to the surface will be issued to th
e backend 3D API and |
122 * if the surface has MSAA it will be resolved. | 122 * if the surface has MSAA it will be resolved. |
123 */ | 123 */ |
124 void prepareForExternalRead(); | 124 void prepareForExternalRead(); |
125 | 125 |
126 /** Access methods that are only to be used within Skia code. */ | 126 /** Access methods that are only to be used within Skia code. */ |
127 inline GrSurfacePriv surfacePriv(); | 127 inline GrSurfacePriv surfacePriv(); |
128 inline const GrSurfacePriv surfacePriv() const; | 128 inline const GrSurfacePriv surfacePriv() const; |
129 | 129 |
| 130 typedef void* ReleaseCtx; |
| 131 typedef void (*ReleaseProc)(ReleaseCtx); |
| 132 |
| 133 void setRelease(ReleaseProc proc, ReleaseCtx ctx) { |
| 134 fReleaseProc = proc; |
| 135 fReleaseCtx = ctx; |
| 136 } |
| 137 |
130 protected: | 138 protected: |
131 // Methods made available via GrSurfacePriv | 139 // Methods made available via GrSurfacePriv |
132 SkImageInfo info() const; | 140 SkImageInfo info() const; |
133 bool savePixels(const char* filename); | 141 bool savePixels(const char* filename); |
134 bool hasPendingRead() const; | 142 bool hasPendingRead() const; |
135 bool hasPendingWrite() const; | 143 bool hasPendingWrite() const; |
136 bool hasPendingIO() const; | 144 bool hasPendingIO() const; |
137 | 145 |
138 // Provides access to methods that should be public within Skia code. | 146 // Provides access to methods that should be public within Skia code. |
139 friend class GrSurfacePriv; | 147 friend class GrSurfacePriv; |
140 | 148 |
141 GrSurface(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) | 149 GrSurface(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) |
142 : INHERITED(gpu, lifeCycle) | 150 : INHERITED(gpu, lifeCycle) |
143 , fDesc(desc) { | 151 , fDesc(desc) |
| 152 , fReleaseProc(NULL) |
| 153 , fReleaseCtx(NULL) |
| 154 {} |
| 155 |
| 156 ~GrSurface() override { |
| 157 // check that invokeReleaseProc has been called (if needed) |
| 158 SkASSERT(NULL == fReleaseProc); |
144 } | 159 } |
145 | 160 |
146 GrSurfaceDesc fDesc; | 161 GrSurfaceDesc fDesc; |
147 | 162 |
| 163 void onRelease() override; |
| 164 void onAbandon() override; |
| 165 |
148 private: | 166 private: |
| 167 void invokeReleaseProc() { |
| 168 if (fReleaseProc) { |
| 169 fReleaseProc(fReleaseCtx); |
| 170 fReleaseProc = NULL; |
| 171 } |
| 172 } |
| 173 |
| 174 ReleaseProc fReleaseProc; |
| 175 ReleaseCtx fReleaseCtx; |
| 176 |
149 typedef GrGpuResource INHERITED; | 177 typedef GrGpuResource INHERITED; |
150 }; | 178 }; |
151 | 179 |
152 #endif | 180 #endif |
OLD | NEW |