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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 of the object being drawn is held by the Paint, which is provided as a | 55 of the object being drawn is held by the Paint, which is provided as a |
56 parameter to each of the draw() methods. The Paint holds attributes such as | 56 parameter to each of the draw() methods. The Paint holds attributes such as |
57 color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns), | 57 color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns), |
58 etc. | 58 etc. |
59 */ | 59 */ |
60 class SK_API SkCanvas : public SkRefCnt { | 60 class SK_API SkCanvas : public SkRefCnt { |
61 public: | 61 public: |
62 SK_DECLARE_INST_COUNT(SkCanvas) | 62 SK_DECLARE_INST_COUNT(SkCanvas) |
63 | 63 |
64 /** | 64 /** |
65 * Attempt to allocate an offscreen raster canvas, matching the ImageInfo. | |
66 * On success, return a new canvas that will draw into that offscreen. | |
67 * | |
68 * The caller can access the pixels after drawing into this canvas by | |
69 * calling readPixels() or peekPixels(). | |
70 * | |
71 * If the requested ImageInfo is opaque (either the colortype is | |
72 * intrinsically opaque like RGB_565, or the info's alphatype is kOpaque) | |
73 * then the pixel memory may be uninitialized. Otherwise, the pixel memory | |
74 * will be initialized to 0, which is interpreted as transparent. | |
75 * | |
76 * On failure, return NULL. This can fail for several reasons: | |
77 * 1. the memory allocation failed (e.g. request is too large) | |
78 * 2. invalid ImageInfo (e.g. negative dimensions) | |
79 * 3. unsupported ImageInfo for a canvas | |
80 * - kUnknown_SkColorType, kIndex_8_SkColorType | |
81 * - kIgnore_SkAlphaType | |
82 * - this list is not complete, so others may also be unsupported | |
83 * | |
84 * Note: it is valid to request a supported ImageInfo, but with zero | |
85 * dimensions. | |
86 */ | |
87 static SkCanvas* NewRaster(const SkImageInfo&); | |
88 | |
89 static SkCanvas* NewRasterN32(int width, int height) { | |
90 return NewRaster(SkImageInfo::MakeN32Premul(width, height)); | |
91 } | |
92 | |
93 /** | |
94 * Attempt to allocate raster canvas, matching the ImageInfo, that will dra
w directly into the | 65 * Attempt to allocate raster canvas, matching the ImageInfo, that will dra
w directly into the |
95 * specified pixels. To access the pixels after drawing to them, the caller
should call | 66 * specified pixels. To access the pixels after drawing to them, the caller
should call |
96 * flush() or call peekPixels(...). | 67 * flush() or call peekPixels(...). |
97 * | 68 * |
98 * On failure, return NULL. This can fail for several reasons: | 69 * On failure, return NULL. This can fail for several reasons: |
99 * 1. invalid ImageInfo (e.g. negative dimensions) | 70 * 1. invalid ImageInfo (e.g. negative dimensions) |
100 * 2. unsupported ImageInfo for a canvas | 71 * 2. unsupported ImageInfo for a canvas |
101 * - kUnknown_SkColorType, kIndex_8_SkColorType | 72 * - kUnknown_SkColorType, kIndex_8_SkColorType |
102 * - kIgnore_SkAlphaType | 73 * - kIgnore_SkAlphaType |
103 * - this list is not complete, so others may also be unsupported | 74 * - this list is not complete, so others may also be unsupported |
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 | 1510 |
1540 class SkCanvasClipVisitor { | 1511 class SkCanvasClipVisitor { |
1541 public: | 1512 public: |
1542 virtual ~SkCanvasClipVisitor(); | 1513 virtual ~SkCanvasClipVisitor(); |
1543 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1514 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1544 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1515 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1545 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1516 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1546 }; | 1517 }; |
1547 | 1518 |
1548 #endif | 1519 #endif |
OLD | NEW |