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 SkImage_DEFINED | 8 #ifndef SkImage_DEFINED |
9 #define SkImage_DEFINED | 9 #define SkImage_DEFINED |
10 | 10 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 * If the image already has its contents in encoded form (e.g. PNG or JPEG)
, return a ref | 263 * If the image already has its contents in encoded form (e.g. PNG or JPEG)
, return a ref |
264 * to that data (which the caller must call unref() on). The caller is resp
onsible for calling | 264 * to that data (which the caller must call unref() on). The caller is resp
onsible for calling |
265 * unref on the data when they are done. | 265 * unref on the data when they are done. |
266 * | 266 * |
267 * If the image does not already has its contents in encoded form, return N
ULL. | 267 * If the image does not already has its contents in encoded form, return N
ULL. |
268 * | 268 * |
269 * Note: to force the image to return its contents as encoded data, try cal
ling encode(...). | 269 * Note: to force the image to return its contents as encoded data, try cal
ling encode(...). |
270 */ | 270 */ |
271 SkData* refEncoded() const; | 271 SkData* refEncoded() const; |
272 | 272 |
273 /** | |
274 * Return a new surface that is compatible with this image's internal repre
sentation | |
275 * (e.g. raster or gpu). | |
276 * | |
277 * If no surfaceprops are specified, the image will attempt to match the pr
ops of when it | |
278 * was created (if it came from a surface). | |
279 */ | |
280 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL) cons
t; | |
281 | |
282 const char* toString(SkString*) const; | 273 const char* toString(SkString*) const; |
283 | 274 |
| 275 #ifdef SK_SUPPORT_LEGACY_NEWIMAGE |
284 /** | 276 /** |
285 * Return an image that is a rescale of this image (using newWidth, newHeig
ht). | 277 * Return an image that is a rescale of this image (using newWidth, newHeig
ht). |
286 * | 278 * |
287 * If subset is NULL, then the entire original image is used as the src for
the scaling. | 279 * If subset is NULL, then the entire original image is used as the src for
the scaling. |
288 * If subset is not NULL, then it specifies subset of src-pixels used for s
caling. If | 280 * If subset is not NULL, then it specifies subset of src-pixels used for s
caling. If |
289 * subset extends beyond the bounds of the original image, then NULL is ret
urned. | 281 * subset extends beyond the bounds of the original image, then NULL is ret
urned. |
290 * | 282 * |
291 * Notes: | 283 * Notes: |
292 * - newWidth and newHeight must be > 0 or NULL will be returned. | 284 * - newWidth and newHeight must be > 0 or NULL will be returned. |
293 * | 285 * |
294 * - it is legal for the returned image to be the same instance as the src
image | 286 * - it is legal for the returned image to be the same instance as the src
image |
295 * (if the new dimensions == the src dimensions and subset is NULL or ==
src dimensions). | 287 * (if the new dimensions == the src dimensions and subset is NULL or ==
src dimensions). |
296 * | 288 * |
297 * - it is legal for the "scaled" image to have changed its SkAlphaType fro
m unpremul | 289 * - it is legal for the "scaled" image to have changed its SkAlphaType fro
m unpremul |
298 * to premul (as required by the impl). The image should draw (nearly) id
entically, | 290 * to premul (as required by the impl). The image should draw (nearly) id
entically, |
299 * since during drawing we will "apply the alpha" to the pixels. Future o
ptimizations | 291 * since during drawing we will "apply the alpha" to the pixels. Future o
ptimizations |
300 * may take away this caveat, preserving unpremul. | 292 * may take away this caveat, preserving unpremul. |
301 */ | 293 */ |
302 SkImage* newImage(int newWidth, int newHeight, const SkIRect* subset = NULL, | 294 SkImage* newImage(int newWidth, int newHeight, const SkIRect* subset) const; |
303 SkFilterQuality = kNone_SkFilterQuality) const; | 295 #endif |
| 296 |
| 297 /** |
| 298 * Return a new image that is a subset of this image. The underlying implem
entation may |
| 299 * share the pixels, or it may make a copy. |
| 300 * |
| 301 * If subset does not intersect the bounds of this image, or the copy/share
cannot be made, |
| 302 * NULL will be returned. |
| 303 */ |
| 304 SkImage* newSubset(const SkIRect& subset) const; |
304 | 305 |
305 // Helper functions to convert to SkBitmap | 306 // Helper functions to convert to SkBitmap |
306 | 307 |
307 enum LegacyBitmapMode { | 308 enum LegacyBitmapMode { |
308 kRO_LegacyBitmapMode, | 309 kRO_LegacyBitmapMode, |
309 kRW_LegacyBitmapMode, | 310 kRW_LegacyBitmapMode, |
310 }; | 311 }; |
311 | 312 |
312 /** | 313 /** |
313 * Attempt to create a bitmap with the same pixels as the image. The result
will always be | 314 * Attempt to create a bitmap with the same pixels as the image. The result
will always be |
(...skipping 17 matching lines...) Expand all Loading... |
331 | 332 |
332 private: | 333 private: |
333 const int fWidth; | 334 const int fWidth; |
334 const int fHeight; | 335 const int fHeight; |
335 const uint32_t fUniqueID; | 336 const uint32_t fUniqueID; |
336 | 337 |
337 typedef SkRefCnt INHERITED; | 338 typedef SkRefCnt INHERITED; |
338 }; | 339 }; |
339 | 340 |
340 #endif | 341 #endif |
OLD | NEW |