OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkCanvas_DEFINED | 10 #ifndef SkCanvas_DEFINED |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 class SkBounder; | 24 class SkBounder; |
25 class SkDevice; | 25 class SkDevice; |
26 class SkDraw; | 26 class SkDraw; |
27 class SkDrawFilter; | 27 class SkDrawFilter; |
28 class SkMetaData; | 28 class SkMetaData; |
29 class SkPicture; | 29 class SkPicture; |
30 class SkRRect; | 30 class SkRRect; |
31 class SkSurface_Base; | 31 class SkSurface_Base; |
32 | 32 |
| 33 /** |
| 34 * Subclasses of this can be passed to canvas.drawPicture. During the drawing |
| 35 * of the picture, this callback will periodically be invoked. If its |
| 36 * abortDrawing() returns true, then picture playback will be interrupted. |
| 37 * |
| 38 * The resulting drawing is undefined, as there is no guarantee how often the |
| 39 * callback will be invoked. If the abort happens inside some level of nested |
| 40 * calls to save(), restore will automatically be called to return the state |
| 41 * to the same level it was before the drawPicture call was made. |
| 42 */ |
| 43 class SkDrawPictureCallback { |
| 44 public: |
| 45 SkDrawPictureCallback() {} |
| 46 virtual ~SkDrawPictureCallback() {} |
| 47 |
| 48 virtual bool abortDrawing() = 0; |
| 49 }; |
| 50 |
33 /** \class SkCanvas | 51 /** \class SkCanvas |
34 | 52 |
35 A Canvas encapsulates all of the state about drawing into a device (bitmap). | 53 A Canvas encapsulates all of the state about drawing into a device (bitmap). |
36 This includes a reference to the device itself, and a stack of matrix/clip | 54 This includes a reference to the device itself, and a stack of matrix/clip |
37 values. For any given draw call (e.g. drawRect), the geometry of the object | 55 values. For any given draw call (e.g. drawRect), the geometry of the object |
38 being drawn is transformed by the concatenation of all the matrices in the | 56 being drawn is transformed by the concatenation of all the matrices in the |
39 stack. The transformed geometry is clipped by the intersection of all of | 57 stack. The transformed geometry is clipped by the intersection of all of |
40 the clips in the stack. | 58 the clips in the stack. |
41 | 59 |
42 While the Canvas holds the state of the drawing device, the state (style) | 60 While the Canvas holds the state of the drawing device, the state (style) |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 @param pos Array of positions, used to position each character | 819 @param pos Array of positions, used to position each character |
802 @param paint The paint used for the text (e.g. color, size, style) | 820 @param paint The paint used for the text (e.g. color, size, style) |
803 @param path The path to draw on | 821 @param path The path to draw on |
804 @param matrix The canvas matrix | 822 @param matrix The canvas matrix |
805 */ | 823 */ |
806 void drawPosTextOnPath(const void* text, size_t byteLength, | 824 void drawPosTextOnPath(const void* text, size_t byteLength, |
807 const SkPoint pos[], const SkPaint& paint, | 825 const SkPoint pos[], const SkPaint& paint, |
808 const SkPath& path, const SkMatrix* matrix); | 826 const SkPath& path, const SkMatrix* matrix); |
809 #endif | 827 #endif |
810 | 828 |
| 829 |
811 /** Draw the picture into this canvas. This method effective brackets the | 830 /** Draw the picture into this canvas. This method effective brackets the |
812 playback of the picture's draw calls with save/restore, so the state | 831 playback of the picture's draw calls with save/restore, so the state |
813 of this canvas will be unchanged after this call. | 832 of this canvas will be unchanged after this call. |
814 @param picture The recorded drawing commands to playback into this | 833 @param picture The recorded drawing commands to playback into this |
815 canvas. | 834 canvas. |
816 */ | 835 */ |
817 virtual void drawPicture(SkPicture& picture); | 836 virtual void drawPicture(SkPicture& picture, SkDrawPictureCallback* = NULL); |
818 | 837 |
819 enum VertexMode { | 838 enum VertexMode { |
820 kTriangles_VertexMode, | 839 kTriangles_VertexMode, |
821 kTriangleStrip_VertexMode, | 840 kTriangleStrip_VertexMode, |
822 kTriangleFan_VertexMode | 841 kTriangleFan_VertexMode |
823 }; | 842 }; |
824 | 843 |
825 /** Draw the array of vertices, interpreted as triangles (based on mode). | 844 /** Draw the array of vertices, interpreted as triangles (based on mode). |
826 @param vmode How to interpret the array of vertices | 845 @param vmode How to interpret the array of vertices |
827 @param vertexCount The number of points in the vertices array (and | 846 @param vertexCount The number of points in the vertices array (and |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 fCanvas = NULL; | 1151 fCanvas = NULL; |
1133 } | 1152 } |
1134 } | 1153 } |
1135 | 1154 |
1136 private: | 1155 private: |
1137 SkCanvas* fCanvas; | 1156 SkCanvas* fCanvas; |
1138 int fSaveCount; | 1157 int fSaveCount; |
1139 }; | 1158 }; |
1140 | 1159 |
1141 #endif | 1160 #endif |
OLD | NEW |