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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 /** | 180 /** |
181 * Draw the image, cropped to the src rect, to the dst rect of a canvas. | 181 * Draw the image, cropped to the src rect, to the dst rect of a canvas. |
182 * If src is larger than the bounds of the image, the rest of the image is | 182 * If src is larger than the bounds of the image, the rest of the image is |
183 * filled with transparent black pixels. | 183 * filled with transparent black pixels. |
184 * | 184 * |
185 * See SkCanvas::drawBitmapRectToRect for similar behavior. | 185 * See SkCanvas::drawBitmapRectToRect for similar behavior. |
186 */ | 186 */ |
187 void drawRect(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint
*) const; | 187 void drawRect(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint
*) const; |
188 }; | 188 }; |
189 | 189 |
| 190 /** A helper for common in pixel access done with CPU: lock pixels of the render
ing of the |
| 191 * image in N32 format, or fail. The condition bitmap->getPixels() != NULL signi
fies success. |
| 192 * Will unref the image if succesful, as this may save memory. |
| 193 */ |
| 194 class SkAutoAdoptImageAsN32Bitmap : SkNoncopyable { |
| 195 public: |
| 196 /** |
| 197 * @param image image to adopt as bitmap. will be reset(NULL) if operation i
s successful. |
| 198 */ |
| 199 SkAutoAdoptImageAsN32Bitmap(SkAutoTUnref<const SkImage>& image, SkBitmap* bi
tmap); |
| 200 ~SkAutoAdoptImageAsN32Bitmap() { |
| 201 if (fBitmap) { |
| 202 fBitmap->unlockPixels(); |
| 203 } |
| 204 } |
| 205 private: |
| 206 SkBitmap* fBitmap; |
| 207 }; |
| 208 |
| 209 /** A helper for common in pixel access done with CPU: lock pixels of the render
ing of the |
| 210 * image in N32 format, or fail. The condition bitmap->getPixels() != NULL signi
fies success. |
| 211 */ |
| 212 class SkAutoImageAsN32Bitmap : SkNoncopyable { |
| 213 public: |
| 214 SkAutoImageAsN32Bitmap(const SkImage* image, SkBitmap* bitmap); |
| 215 ~SkAutoImageAsN32Bitmap() { |
| 216 if (fBitmap) { |
| 217 fBitmap->unlockPixels(); |
| 218 } |
| 219 } |
| 220 private: |
| 221 SkBitmap* fBitmap; |
| 222 }; |
| 223 |
190 #endif | 224 #endif |
OLD | NEW |