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 #ifndef SkSurface_DEFINED | 8 #ifndef SkSurface_DEFINED |
9 #define SkSurface_DEFINED | 9 #define SkSurface_DEFINED |
10 | 10 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 * RAM) return the const-address of those pixels, and if not null, return | 205 * RAM) return the const-address of those pixels, and if not null, return |
206 * the ImageInfo and rowBytes. The returned address is only valid while | 206 * the ImageInfo and rowBytes. The returned address is only valid while |
207 * the surface object is in scope, and no API call is made on the surface | 207 * the surface object is in scope, and no API call is made on the surface |
208 * or its canvas. | 208 * or its canvas. |
209 * | 209 * |
210 * On failure, returns NULL and the info and rowBytes parameters are | 210 * On failure, returns NULL and the info and rowBytes parameters are |
211 * ignored. | 211 * ignored. |
212 */ | 212 */ |
213 const void* peekPixels(SkImageInfo* info, size_t* rowBytes); | 213 const void* peekPixels(SkImageInfo* info, size_t* rowBytes); |
214 | 214 |
| 215 /** |
| 216 * Copy the pixels from the surface into the specified buffer (pixels + row
Bytes), |
| 217 * converting them into the requested format (dstInfo). The base-layer pixe
ls are read |
| 218 * starting at the specified (srcX,srcY) location in the coordinate system
of the base-layer. |
| 219 * |
| 220 * The specified ImageInfo and (srcX,srcY) offset specifies a source rectan
gle |
| 221 * |
| 222 * srcR.setXYWH(srcX, srcY, dstInfo.width(), dstInfo.height()); |
| 223 * |
| 224 * srcR is intersected with the bounds of the base-layer. If this intersect
ion is not empty, |
| 225 * then we have two sets of pixels (of equal size). Replace the dst pixels
with the |
| 226 * corresponding src pixels, performing any colortype/alphatype transformat
ions needed |
| 227 * (in the case where the src and dst have different colortypes or alphatyp
es). |
| 228 * |
| 229 * This call can fail, returning false, for several reasons: |
| 230 * - If srcR does not intersect the surface bounds. |
| 231 * - If the requested colortype/alphatype cannot be converted from the base
-layer's types. |
| 232 */ |
| 233 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy
tes, |
| 234 int srcX, int srcY); |
| 235 |
| 236 /** |
| 237 * Helper for allocating pixels and then calling readPixels(info, ...). The
bitmap is resized |
| 238 * to the intersection of srcRect and the surface bounds (if srcRect is non
-null). |
| 239 * On success, pixels will be allocated in bitmap and true returned. On fai
lure, |
| 240 * false is returned and bitmap will be set to empty. |
| 241 */ |
| 242 bool readPixels(SkBitmap* dst, const SkIRect* srcRect = NULL); |
| 243 |
215 const SkSurfaceProps& props() const { return fProps; } | 244 const SkSurfaceProps& props() const { return fProps; } |
216 | 245 |
217 protected: | 246 protected: |
218 SkSurface(int width, int height, const SkSurfaceProps*); | 247 SkSurface(int width, int height, const SkSurfaceProps*); |
219 SkSurface(const SkImageInfo&, const SkSurfaceProps*); | 248 SkSurface(const SkImageInfo&, const SkSurfaceProps*); |
220 | 249 |
221 // called by subclass if their contents have changed | 250 // called by subclass if their contents have changed |
222 void dirtyGenerationID() { | 251 void dirtyGenerationID() { |
223 fGenerationID = 0; | 252 fGenerationID = 0; |
224 } | 253 } |
225 | 254 |
226 private: | 255 private: |
227 const SkSurfaceProps fProps; | 256 const SkSurfaceProps fProps; |
228 const int fWidth; | 257 const int fWidth; |
229 const int fHeight; | 258 const int fHeight; |
230 uint32_t fGenerationID; | 259 uint32_t fGenerationID; |
231 | 260 |
232 typedef SkRefCnt INHERITED; | 261 typedef SkRefCnt INHERITED; |
233 }; | 262 }; |
234 | 263 |
235 #endif | 264 #endif |
OLD | NEW |