| 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 /** |
| 65 * Attempt to allocate raster canvas, matching the ImageInfo, that will dra
w directly into the | 94 * Attempt to allocate raster canvas, matching the ImageInfo, that will dra
w directly into the |
| 66 * specified pixels. To access the pixels after drawing to them, the caller
should call | 95 * specified pixels. To access the pixels after drawing to them, the caller
should call |
| 67 * flush() or call peekPixels(...). | 96 * flush() or call peekPixels(...). |
| 68 * | 97 * |
| 69 * On failure, return NULL. This can fail for several reasons: | 98 * On failure, return NULL. This can fail for several reasons: |
| 70 * 1. invalid ImageInfo (e.g. negative dimensions) | 99 * 1. invalid ImageInfo (e.g. negative dimensions) |
| 71 * 2. unsupported ImageInfo for a canvas | 100 * 2. unsupported ImageInfo for a canvas |
| 72 * - kUnknown_SkColorType, kIndex_8_SkColorType | 101 * - kUnknown_SkColorType, kIndex_8_SkColorType |
| 73 * - kIgnore_SkAlphaType | 102 * - kIgnore_SkAlphaType |
| 74 * - this list is not complete, so others may also be unsupported | 103 * - this list is not complete, so others may also be unsupported |
| (...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 | 1539 |
| 1511 class SkCanvasClipVisitor { | 1540 class SkCanvasClipVisitor { |
| 1512 public: | 1541 public: |
| 1513 virtual ~SkCanvasClipVisitor(); | 1542 virtual ~SkCanvasClipVisitor(); |
| 1514 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1543 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
| 1515 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1544 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
| 1516 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1545 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
| 1517 }; | 1546 }; |
| 1518 | 1547 |
| 1519 #endif | 1548 #endif |
| OLD | NEW |