OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 SkCanvas_DEFINED | 8 #ifndef SkCanvas_DEFINED |
9 #define SkCanvas_DEFINED | 9 #define SkCanvas_DEFINED |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 of the object being drawn is held by the Paint, which is provided as a | 42 of the object being drawn is held by the Paint, which is provided as a |
43 parameter to each of the draw() methods. The Paint holds attributes such as | 43 parameter to each of the draw() methods. The Paint holds attributes such as |
44 color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns), | 44 color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns), |
45 etc. | 45 etc. |
46 */ | 46 */ |
47 class SK_API SkCanvas : public SkRefCnt { | 47 class SK_API SkCanvas : public SkRefCnt { |
48 public: | 48 public: |
49 SK_DECLARE_INST_COUNT(SkCanvas) | 49 SK_DECLARE_INST_COUNT(SkCanvas) |
50 | 50 |
51 /** | 51 /** |
| 52 * Attempt to allocate an offscreen raster canvas, matching the ImageInfo. |
| 53 * On success, return a new canvas that will draw into that offscreen. |
| 54 * |
| 55 * The caller can access the pixels after drawing into this canvas by |
| 56 * calling readPixels() or peekPixels(). |
| 57 * |
| 58 * If the requested ImageInfo is opaque (either the colortype is |
| 59 * intrinsically opaque like RGB_565, or the info's alphatype is kOpaque) |
| 60 * then the pixel memory may be uninitialized. Otherwise, the pixel memory |
| 61 * will be initialized to 0, which is interpreted as transparent. |
| 62 * |
| 63 * On failure, return NULL. This can fail for several reasons: |
| 64 * 1. the memory allocation failed (e.g. request is too large) |
| 65 * 2. invalid ImageInfo (e.g. negative dimensions) |
| 66 * 3. unsupported ImageInfo for a canvas |
| 67 * - kUnknown_SkColorType, kIndex_8_SkColorType |
| 68 * - kIgnore_SkAlphaType |
| 69 * - this list is not complete, so others may also be unsupported |
| 70 * |
| 71 * Note: it is valid to request a supported ImageInfo, but with zero |
| 72 * dimensions. |
| 73 */ |
| 74 static SkCanvas* NewRaster(const SkImageInfo&); |
| 75 |
| 76 static SkCanvas* NewRasterN32(int width, int height) { |
| 77 return NewRaster(SkImageInfo::MakeN32Premul(width, height)); |
| 78 } |
| 79 |
| 80 /** |
52 * Creates an empty canvas with no backing device/pixels, and zero | 81 * Creates an empty canvas with no backing device/pixels, and zero |
53 * dimensions. | 82 * dimensions. |
54 */ | 83 */ |
55 SkCanvas(); | 84 SkCanvas(); |
56 | 85 |
57 /** | 86 /** |
58 * Creates a canvas of the specified dimensions, but explicitly not backed | 87 * Creates a canvas of the specified dimensions, but explicitly not backed |
59 * by any device/pixels. Typically this use used by subclasses who handle | 88 * by any device/pixels. Typically this use used by subclasses who handle |
60 * the draw calls in some other way. | 89 * the draw calls in some other way. |
61 */ | 90 */ |
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 bool asROBitmap(SkBitmap*) const; | 1340 bool asROBitmap(SkBitmap*) const; |
1312 | 1341 |
1313 private: | 1342 private: |
1314 SkBitmap fBitmap; // used if peekPixels() fails | 1343 SkBitmap fBitmap; // used if peekPixels() fails |
1315 const void* fAddr; // NULL on failure | 1344 const void* fAddr; // NULL on failure |
1316 SkImageInfo fInfo; | 1345 SkImageInfo fInfo; |
1317 size_t fRowBytes; | 1346 size_t fRowBytes; |
1318 }; | 1347 }; |
1319 | 1348 |
1320 #endif | 1349 #endif |
OLD | NEW |