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 |
11 | 11 |
12 #include "GrTypes.h" | 12 #include "GrTypes.h" |
13 #include "GrGpuResource.h" | 13 #include "GrGpuResource.h" |
14 #include "SkImageInfo.h" | 14 #include "SkImageInfo.h" |
15 #include "SkRect.h" | 15 #include "SkRect.h" |
16 | 16 |
17 class GrRenderTarget; | 17 class GrRenderTarget; |
18 class GrSurfacePriv; | 18 class GrSurfacePriv; |
19 class GrTexture; | 19 class GrTexture; |
20 | 20 |
21 class GrSurface : public GrGpuResource { | 21 class GrSurface : public GrGpuResource { |
22 public: | 22 public: |
23 SK_DECLARE_INST_COUNT(GrSurface); | |
24 | |
25 /** | 23 /** |
26 * Retrieves the width of the surface. | 24 * Retrieves the width of the surface. |
27 */ | 25 */ |
28 int width() const { return fDesc.fWidth; } | 26 int width() const { return fDesc.fWidth; } |
29 | 27 |
30 /** | 28 /** |
31 * Retrieves the height of the surface. | 29 * Retrieves the height of the surface. |
32 */ | 30 */ |
33 int height() const { return fDesc.fHeight; } | 31 int height() const { return fDesc.fHeight; } |
34 | 32 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 * After this returns any pending writes to the surface will be issued to th
e backend 3D API. | 113 * After this returns any pending writes to the surface will be issued to th
e backend 3D API. |
116 */ | 114 */ |
117 void flushWrites(); | 115 void flushWrites(); |
118 | 116 |
119 | 117 |
120 /** | 118 /** |
121 * After this returns any pending writes to the surface will be issued to th
e backend 3D API and | 119 * 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. | 120 * if the surface has MSAA it will be resolved. |
123 */ | 121 */ |
124 void prepareForExternalRead(); | 122 void prepareForExternalRead(); |
125 | 123 |
126 /** Access methods that are only to be used within Skia code. */ | 124 /** Access methods that are only to be used within Skia code. */ |
127 inline GrSurfacePriv surfacePriv(); | 125 inline GrSurfacePriv surfacePriv(); |
128 inline const GrSurfacePriv surfacePriv() const; | 126 inline const GrSurfacePriv surfacePriv() const; |
129 | 127 |
130 typedef void* ReleaseCtx; | 128 typedef void* ReleaseCtx; |
131 typedef void (*ReleaseProc)(ReleaseCtx); | 129 typedef void (*ReleaseProc)(ReleaseCtx); |
132 | 130 |
133 void setRelease(ReleaseProc proc, ReleaseCtx ctx) { | 131 void setRelease(ReleaseProc proc, ReleaseCtx ctx) { |
134 fReleaseProc = proc; | 132 fReleaseProc = proc; |
135 fReleaseCtx = ctx; | 133 fReleaseCtx = ctx; |
136 } | 134 } |
137 | 135 |
138 protected: | 136 protected: |
139 // Methods made available via GrSurfacePriv | 137 // Methods made available via GrSurfacePriv |
140 SkImageInfo info(SkAlphaType) const; | 138 SkImageInfo info(SkAlphaType) const; |
141 bool savePixels(const char* filename); | 139 bool savePixels(const char* filename); |
142 bool hasPendingRead() const; | 140 bool hasPendingRead() const; |
(...skipping 20 matching lines...) Expand all Loading... |
163 void onRelease() override; | 161 void onRelease() override; |
164 void onAbandon() override; | 162 void onAbandon() override; |
165 | 163 |
166 private: | 164 private: |
167 void invokeReleaseProc() { | 165 void invokeReleaseProc() { |
168 if (fReleaseProc) { | 166 if (fReleaseProc) { |
169 fReleaseProc(fReleaseCtx); | 167 fReleaseProc(fReleaseCtx); |
170 fReleaseProc = NULL; | 168 fReleaseProc = NULL; |
171 } | 169 } |
172 } | 170 } |
173 | 171 |
174 ReleaseProc fReleaseProc; | 172 ReleaseProc fReleaseProc; |
175 ReleaseCtx fReleaseCtx; | 173 ReleaseCtx fReleaseCtx; |
176 | 174 |
177 typedef GrGpuResource INHERITED; | 175 typedef GrGpuResource INHERITED; |
178 }; | 176 }; |
179 | 177 |
180 #endif | 178 #endif |
OLD | NEW |