Chromium Code Reviews| Index: include/core/SkImage.h |
| diff --git a/include/core/SkImage.h b/include/core/SkImage.h |
| index 41a1bd85272f163bb5e5a2135ad353ff92cf897b..f623c1f4f378e5dc6fedf2853e7f4d6d9c6f4641 100644 |
| --- a/include/core/SkImage.h |
| +++ b/include/core/SkImage.h |
| @@ -264,6 +264,27 @@ public: |
| SkImage* newImage(int newWidth, int newHeight, const SkIRect* subset = NULL, |
| SkFilterQuality = kNone_SkFilterQuality) const; |
| + // Helper functions to convert to SkBitmap |
| + |
| + enum AsBitmapMode { |
| + kRO_AsBitmapMode, |
| + kRW_AsBitmapMode, |
| + }; |
| + |
| + /** |
| + * Attempt to create a bitmap with the same pixels as the image. |
| + * |
| + * If the mode is kRO (read-only), an attempt will be made to share the actual pixel memory, |
| + * skipping the cost of a copy. If this can be done, the returned bitmap will be marked |
| + * immutable. |
| + * |
| + * If it cannot, or if the mode is kRW (read-write), then a copy of the pixels will be made. |
| + * |
|
robertphillips
2015/07/08 15:41:26
success
reed1
2015/07/08 19:14:43
Done.
|
| + * On succces, returns true. On failure, returns false and the bitmap parameter will be reset |
| + * to empty. |
| + */ |
| + bool asBitmap(SkBitmap*, AsBitmapMode = kRO_AsBitmapMode) const; |
| + |
| protected: |
| SkImage(int width, int height) : |
| fWidth(width), |