• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
9 // DO NOT USE -- FOR INTERNAL TESTING ONLY
10 
11 #ifndef sk_canvas_DEFINED
12 #define sk_canvas_DEFINED
13 
14 #include "sk_types.h"
15 
16 SK_C_PLUS_PLUS_BEGIN_GUARD
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 */
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 */
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 */
48 SK_API void sk_canvas_restore(sk_canvas_t*);
49 
50 /**
51     Preconcat the current coordinate transformation matrix with the
52     specified translation.
53 */
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 */
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 */
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 */
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 */
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 */
79 SK_API void sk_canvas_concat(sk_canvas_t*, const sk_matrix_t*);
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 */
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 */
92 SK_API void sk_canvas_clip_path(sk_canvas_t*, const sk_path_t*);
93 
94 /**
95     Fill the entire canvas (restricted to the current clip) with the
96     specified paint.
97 */
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 */
104 SK_API void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
105 /**
106  *  Draw the circle centered at (cx, cy) with radius rad using the specified paint.
107  *  The circle will be filled or framed based on the style in the paint
108  */
109 SK_API void sk_canvas_draw_circle(sk_canvas_t*, float cx, float cy, float rad, const sk_paint_t*);
110 /**
111     Draw the specified oval using the specified paint. The oval will be
112     filled or framed based on the style in the paint
113 */
114 SK_API void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
115 /**
116     Draw the specified path using the specified paint. The path will be
117     filled or framed based on the style in the paint
118 */
119 SK_API void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*);
120 /**
121     Draw the specified image, with its top/left corner at (x,y), using
122     the specified paint, transformed by the current matrix.
123 
124     @param sk_paint_t* (may be NULL) the paint used to draw the image.
125 */
126 SK_API void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*,
127                                  float x, float y, const sk_paint_t*);
128 /**
129     Draw the specified image, scaling and translating so that it fills
130     the specified dst rect. If the src rect is non-null, only that
131     subset of the image is transformed and drawn.
132 
133     @param sk_paint_t* (may be NULL) The paint used to draw the image.
134 */
135 SK_API void sk_canvas_draw_image_rect(sk_canvas_t*, const sk_image_t*,
136                                       const sk_rect_t* src,
137                                       const sk_rect_t* dst, const sk_paint_t*);
138 
139 /**
140     Draw the picture into this canvas (replay the pciture's drawing commands).
141 
142     @param sk_matrix_t* If non-null, apply that matrix to the CTM when
143                         drawing this picture. This is logically
144                         equivalent to: save, concat, draw_picture,
145                         restore.
146 
147     @param sk_paint_t* If non-null, draw the picture into a temporary
148                        buffer, and then apply the paint's alpha,
149                        colorfilter, imagefilter, and xfermode to that
150                        buffer as it is drawn to the canvas.  This is
151                        logically equivalent to save_layer(paint),
152                        draw_picture, restore.
153 */
154 SK_API void sk_canvas_draw_picture(sk_canvas_t*, const sk_picture_t*,
155                                    const sk_matrix_t*, const sk_paint_t*);
156 
157 SK_C_PLUS_PLUS_END_GUARD
158 
159 #endif
160