OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL | 8 // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL |
9 // DO NOT USE -- FOR INTERNAL TESTING ONLY | 9 // DO NOT USE -- FOR INTERNAL TESTING ONLY |
10 | 10 |
11 #ifndef sk_canvas_DEFINED | 11 #ifndef sk_canvas_DEFINED |
12 #define sk_canvas_DEFINED | 12 #define sk_canvas_DEFINED |
13 | 13 |
14 #include "sk_types.h" | 14 #include "sk_types.h" |
15 | 15 |
16 SK_C_PLUS_PLUS_BEGIN_GUARD | 16 SK_C_PLUS_PLUS_BEGIN_GUARD |
17 | 17 |
| 18 /** |
| 19 Save the current matrix and clip on the canvas. When the |
| 20 balancing call to sk_canvas_restore() is made, the previous matrix |
| 21 and clip are restored. |
| 22 */ |
18 SK_API void sk_canvas_save(sk_canvas_t*); | 23 SK_API void sk_canvas_save(sk_canvas_t*); |
| 24 /** |
| 25 This behaves the same as sk_canvas_save(), but in addition it |
| 26 allocates an offscreen surface. All drawing calls are directed |
| 27 there, and only when the balancing call to sk_canvas_restore() is |
| 28 made is that offscreen transfered to the canvas (or the previous |
| 29 layer). |
| 30 |
| 31 @param sk_rect_t* (may be null) This rect, if non-null, is used as |
| 32 a hint to limit the size of the offscreen, and |
| 33 thus drawing may be clipped to it, though that |
| 34 clipping is not guaranteed to happen. If exact |
| 35 clipping is desired, use sk_canvas_clip_rect(). |
| 36 @param sk_paint_t* (may be null) The paint is copied, and is applied |
| 37 to the offscreen when sk_canvas_restore() is |
| 38 called. |
| 39 */ |
19 SK_API void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_
t*); | 40 SK_API void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_
t*); |
| 41 /** |
| 42 This call balances a previous call to sk_canvas_save() or |
| 43 sk_canvas_save_layer(), and is used to remove all modifications to |
| 44 the matrix and clip state since the last save call. It is an |
| 45 error to call sk_canvas_restore() more times than save and |
| 46 save_layer were called. |
| 47 */ |
20 SK_API void sk_canvas_restore(sk_canvas_t*); | 48 SK_API void sk_canvas_restore(sk_canvas_t*); |
21 | 49 |
| 50 /** |
| 51 Preconcat the current coordinate transformation matrix with the |
| 52 specified translation. |
| 53 */ |
22 SK_API void sk_canvas_translate(sk_canvas_t*, float dx, float dy); | 54 SK_API void sk_canvas_translate(sk_canvas_t*, float dx, float dy); |
| 55 /** |
| 56 Preconcat the current coordinate transformation matrix with the |
| 57 specified scale. |
| 58 */ |
23 SK_API void sk_canvas_scale(sk_canvas_t*, float sx, float sy); | 59 SK_API void sk_canvas_scale(sk_canvas_t*, float sx, float sy); |
| 60 /** |
| 61 Preconcat the current coordinate transformation matrix with the |
| 62 specified rotation in degrees. |
| 63 */ |
24 SK_API void sk_canvas_rotate_degrees(sk_canvas_t*, float degrees); | 64 SK_API void sk_canvas_rotate_degrees(sk_canvas_t*, float degrees); |
| 65 /** |
| 66 Preconcat the current coordinate transformation matrix with the |
| 67 specified rotation in radians. |
| 68 */ |
25 SK_API void sk_canvas_rotate_radians(sk_canvas_t*, float radians); | 69 SK_API void sk_canvas_rotate_radians(sk_canvas_t*, float radians); |
| 70 /** |
| 71 Preconcat the current coordinate transformation matrix with the |
| 72 specified skew. |
| 73 */ |
26 SK_API void sk_canvas_skew(sk_canvas_t*, float sx, float sy); | 74 SK_API void sk_canvas_skew(sk_canvas_t*, float sx, float sy); |
| 75 /** |
| 76 Preconcat the current coordinate transformation matrix with the |
| 77 specified matrix. |
| 78 */ |
27 SK_API void sk_canvas_concat(sk_canvas_t*, const sk_matrix_t*); | 79 SK_API void sk_canvas_concat(sk_canvas_t*, const sk_matrix_t*); |
28 | 80 |
| 81 /** |
| 82 Modify the current clip with the specified rectangle. The new |
| 83 current clip will be the intersection of the old clip and the |
| 84 rectange. |
| 85 */ |
29 SK_API void sk_canvas_clip_rect(sk_canvas_t*, const sk_rect_t*); | 86 SK_API void sk_canvas_clip_rect(sk_canvas_t*, const sk_rect_t*); |
| 87 /** |
| 88 Modify the current clip with the specified path. The new |
| 89 current clip will be the intersection of the old clip and the |
| 90 path. |
| 91 */ |
30 SK_API void sk_canvas_clip_path(sk_canvas_t*, const sk_path_t*); | 92 SK_API void sk_canvas_clip_path(sk_canvas_t*, const sk_path_t*); |
31 | 93 |
| 94 /** |
| 95 Fill the entire canvas (restricted to the current clip) with the |
| 96 specified paint. |
| 97 */ |
32 SK_API void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*); | 98 SK_API void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*); |
| 99 /** |
| 100 Draw the specified rectangle using the specified paint. The |
| 101 rectangle will be filled or stroked based on the style in the |
| 102 paint. |
| 103 */ |
33 SK_API void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t
*); | 104 SK_API void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t
*); |
| 105 /** |
| 106 Draw the specified oval using the specified paint. The oval will be |
| 107 filled or framed based on the style in the paint |
| 108 */ |
34 SK_API void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t
*); | 109 SK_API void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t
*); |
| 110 /** |
| 111 Draw the specified path using the specified paint. The path will be |
| 112 filled or framed based on the style in the paint |
| 113 */ |
35 SK_API void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t
*); | 114 SK_API void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t
*); |
| 115 /** |
| 116 Draw the specified image, with its top/left corner at (x,y), using |
| 117 the specified paint, transformed by the current matrix. |
| 118 |
| 119 @param sk_paint_t* (may be NULL) the paint used to draw the image. |
| 120 */ |
36 SK_API void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*, | 121 SK_API void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*, |
37 float x, float y, const sk_paint_t*); | 122 float x, float y, const sk_paint_t*); |
| 123 /** |
| 124 Draw the specified image, scaling and translating so that it fills |
| 125 the specified dst rect. If the src rect is non-null, only that |
| 126 subset of the image is transformed and drawn. |
| 127 |
| 128 @param sk_paint_t* (may be NULL) The paint used to draw the image. |
| 129 */ |
38 SK_API void sk_canvas_draw_image_rect(sk_canvas_t*, const sk_image_t*, | 130 SK_API void sk_canvas_draw_image_rect(sk_canvas_t*, const sk_image_t*, |
39 const sk_rect_t* src, | 131 const sk_rect_t* src, |
40 const sk_rect_t* dst, const sk_paint_t*); | 132 const sk_rect_t* dst, const sk_paint_t*); |
| 133 |
| 134 /** |
| 135 Draw the picture into this canvas (replay the pciture's drawing commands). |
| 136 |
| 137 @param sk_matrix_t* If non-null, apply that matrix to the CTM when |
| 138 drawing this picture. This is logically |
| 139 equivalent to: save, concat, draw_picture, |
| 140 restore. |
| 141 |
| 142 @param sk_paint_t* If non-null, draw the picture into a temporary |
| 143 buffer, and then apply the paint's alpha, |
| 144 colorfilter, imagefilter, and xfermode to that |
| 145 buffer as it is drawn to the canvas. This is |
| 146 logically equivalent to save_layer(paint), |
| 147 draw_picture, restore. |
| 148 */ |
41 SK_API void sk_canvas_draw_picture(sk_canvas_t*, const sk_picture_t*, | 149 SK_API void sk_canvas_draw_picture(sk_canvas_t*, const sk_picture_t*, |
42 const sk_matrix_t*, const sk_paint_t*); | 150 const sk_matrix_t*, const sk_paint_t*); |
43 | 151 |
44 SK_C_PLUS_PLUS_END_GUARD | 152 SK_C_PLUS_PLUS_END_GUARD |
45 | 153 |
46 #endif | 154 #endif |
OLD | NEW |