Chromium Code Reviews| 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 AsBitmapMode { | |
| 270 kRO_AsBitmapMode, | |
| 271 kRW_AsBitmapMode, | |
| 272 }; | |
| 273 | |
| 274 /** | |
| 275 * Attempt to create a bitmap with the same pixels as the image. | |
| 276 * | |
| 277 * If the mode is kRO (read-only), an attempt will be made to share the act ual pixel memory, | |
| 278 * skipping the cost of a copy. If this can be done, the returned bitmap wi ll be marked | |
| 279 * immutable. | |
| 280 * | |
| 281 * If it cannot, or if the mode is kRW (read-write), then a copy of the pix els will be made. | |
| 282 * | |
|
robertphillips
2015/07/08 15:41:26
success
reed1
2015/07/08 19:14:43
Done.
| |
| 283 * On succces, returns true. On failure, returns false and the bitmap param eter will be reset | |
| 284 * to empty. | |
| 285 */ | |
| 286 bool asBitmap(SkBitmap*, AsBitmapMode = kRO_AsBitmapMode) const; | |
| 287 | |
| 267 protected: | 288 protected: |
| 268 SkImage(int width, int height) : | 289 SkImage(int width, int height) : |
| 269 fWidth(width), | 290 fWidth(width), |
| 270 fHeight(height), | 291 fHeight(height), |
| 271 fUniqueID(NextUniqueID()) { | 292 fUniqueID(NextUniqueID()) { |
| 272 | 293 |
| 273 SkASSERT(width > 0); | 294 SkASSERT(width > 0); |
| 274 SkASSERT(height > 0); | 295 SkASSERT(height > 0); |
| 275 } | 296 } |
| 276 | 297 |
| 277 private: | 298 private: |
| 278 const int fWidth; | 299 const int fWidth; |
| 279 const int fHeight; | 300 const int fHeight; |
| 280 const uint32_t fUniqueID; | 301 const uint32_t fUniqueID; |
| 281 | 302 |
| 282 static uint32_t NextUniqueID(); | 303 static uint32_t NextUniqueID(); |
| 283 | 304 |
| 284 typedef SkRefCnt INHERITED; | 305 typedef SkRefCnt INHERITED; |
| 285 }; | 306 }; |
| 286 | 307 |
| 287 #endif | 308 #endif |
| OLD | NEW |