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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 * (if the new dimensions == the src dimensions and subset is NULL or ==
src dimensions). | 257 * (if the new dimensions == the src dimensions and subset is NULL or ==
src dimensions). |
258 * | 258 * |
259 * - it is legal for the "scaled" image to have changed its SkAlphaType fro
m unpremul | 259 * - it is legal for the "scaled" image to have changed its SkAlphaType fro
m unpremul |
260 * to premul (as required by the impl). The image should draw (nearly) id
entically, | 260 * to premul (as required by the impl). The image should draw (nearly) id
entically, |
261 * since during drawing we will "apply the alpha" to the pixels. Future o
ptimizations | 261 * since during drawing we will "apply the alpha" to the pixels. Future o
ptimizations |
262 * may take away this caveat, preserving unpremul. | 262 * may take away this caveat, preserving unpremul. |
263 */ | 263 */ |
264 SkImage* newImage(int newWidth, int newHeight, const SkIRect* subset = NULL, | 264 SkImage* newImage(int newWidth, int newHeight, const SkIRect* subset = NULL, |
265 SkFilterQuality = kNone_SkFilterQuality) const; | 265 SkFilterQuality = kNone_SkFilterQuality) const; |
266 | 266 |
| 267 // Helper functions to convert to SkBitmap |
| 268 |
| 269 enum LegacyBitmapMode { |
| 270 kRO_LegacyBitmapMode, |
| 271 kRW_LegacyBitmapMode, |
| 272 }; |
| 273 |
| 274 /** |
| 275 * Attempt to create a bitmap with the same pixels as the image. The result
will always be |
| 276 * a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not s
upported here). |
| 277 * |
| 278 * If the mode is kRO (read-only), the resulting bitmap will be marked as i
mmutable. |
| 279 * |
| 280 * On succcess, returns true. On failure, returns false and the bitmap para
meter will be reset |
| 281 * to empty. |
| 282 */ |
| 283 bool asLegacyBitmap(SkBitmap*, LegacyBitmapMode) const; |
| 284 |
267 protected: | 285 protected: |
268 SkImage(int width, int height) : | 286 SkImage(int width, int height) : |
269 fWidth(width), | 287 fWidth(width), |
270 fHeight(height), | 288 fHeight(height), |
271 fUniqueID(NextUniqueID()) { | 289 fUniqueID(NextUniqueID()) { |
272 | 290 |
273 SkASSERT(width > 0); | 291 SkASSERT(width > 0); |
274 SkASSERT(height > 0); | 292 SkASSERT(height > 0); |
275 } | 293 } |
276 | 294 |
277 private: | 295 private: |
278 const int fWidth; | 296 const int fWidth; |
279 const int fHeight; | 297 const int fHeight; |
280 const uint32_t fUniqueID; | 298 const uint32_t fUniqueID; |
281 | 299 |
282 static uint32_t NextUniqueID(); | 300 static uint32_t NextUniqueID(); |
283 | 301 |
284 typedef SkRefCnt INHERITED; | 302 typedef SkRefCnt INHERITED; |
285 }; | 303 }; |
286 | 304 |
287 #endif | 305 #endif |
OLD | NEW |