4 * An object oriented GL/GLES Abstraction/Utility Layer
6 * Copyright (C) 2010 Intel Corporation.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library. If not, see
20 * <http://www.gnu.org/licenses/>.
23 * Robert Bragg <robert@linux.intel.com>
30 #include "cogl-util.h"
31 #include "cogl-internal.h"
32 #include "cogl-context-private.h"
33 #include "cogl2-path.h"
38 #undef cogl_path_set_fill_rule
39 #undef cogl_path_get_fill_rule
41 #undef cogl_path_fill_preserve
42 #undef cogl_path_stroke
43 #undef cogl_path_stroke_preserve
44 #undef cogl_path_move_to
45 #undef cogl_path_rel_move_to
46 #undef cogl_path_line_to
47 #undef cogl_path_rel_line_to
48 #undef cogl_path_close
51 #undef cogl_path_polyline
52 #undef cogl_path_polygon
53 #undef cogl_path_rectangle
55 #undef cogl_path_ellipse
56 #undef cogl_path_round_rectangle
57 #undef cogl_path_curve_to
58 #undef cogl_path_rel_curve_to
60 #include "cogl-path-functions.h"
63 cogl_path_set_fill_rule (CoglPathFillRule fill_rule)
65 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
67 cogl2_path_set_fill_rule (ctx->current_path, fill_rule);
71 cogl_path_get_fill_rule (void)
73 _COGL_GET_CONTEXT (ctx, COGL_PATH_FILL_RULE_EVEN_ODD);
75 return cogl2_path_get_fill_rule (ctx->current_path);
81 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
83 cogl2_path_fill (ctx->current_path);
85 cogl_object_unref (ctx->current_path);
86 ctx->current_path = cogl2_path_new ();
90 cogl_path_fill_preserve (void)
92 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
94 cogl2_path_fill (ctx->current_path);
98 cogl_path_stroke (void)
100 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
102 cogl2_path_stroke (ctx->current_path);
104 cogl_object_unref (ctx->current_path);
105 ctx->current_path = cogl2_path_new ();
109 cogl_path_stroke_preserve (void)
111 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
113 cogl2_path_stroke (ctx->current_path);
117 cogl_path_move_to (float x,
120 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
122 cogl2_path_move_to (ctx->current_path, x, y);
126 cogl_path_rel_move_to (float x,
129 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
131 cogl2_path_rel_move_to (ctx->current_path, x, y);
135 cogl_path_line_to (float x,
138 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
140 cogl2_path_line_to (ctx->current_path, x, y);
144 cogl_path_rel_line_to (float x,
147 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
149 cogl2_path_rel_line_to (ctx->current_path, x, y);
153 cogl_path_close (void)
155 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
157 cogl2_path_close (ctx->current_path);
163 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
165 cogl_object_unref (ctx->current_path);
166 ctx->current_path = cogl2_path_new ();
170 cogl_path_line (float x_1,
175 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
177 cogl2_path_line (ctx->current_path, x_1, y_1, x_2, y_2);
181 cogl_path_polyline (const float *coords,
184 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
186 cogl2_path_polyline (ctx->current_path, coords, num_points);
190 cogl_path_polygon (const float *coords,
193 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
195 cogl2_path_polygon (ctx->current_path, coords, num_points);
199 cogl_path_rectangle (float x_1,
204 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
206 cogl2_path_rectangle (ctx->current_path, x_1, y_1, x_2, y_2);
210 cogl_path_arc (float center_x,
217 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
219 cogl2_path_arc (ctx->current_path,
229 cogl_path_ellipse (float center_x,
234 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
236 cogl2_path_ellipse (ctx->current_path,
244 cogl_path_round_rectangle (float x_1,
251 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
253 cogl2_path_round_rectangle (ctx->current_path,
254 x_1, y_1, x_2, y_2, radius, arc_step);
258 cogl_path_curve_to (float x_1,
265 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
267 cogl2_path_curve_to (ctx->current_path,
268 x_1, y_1, x_2, y_2, x_3, y_3);
272 cogl_path_rel_curve_to (float x_1,
279 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
281 cogl2_path_rel_curve_to (ctx->current_path,
282 x_1, y_1, x_2, y_2, x_3, y_3);
288 _COGL_GET_CONTEXT (ctx, NULL);
290 return ctx->current_path;
294 cogl_set_path (CoglPath *path)
296 _COGL_GET_CONTEXT (ctx, NO_RETVAL);
298 _COGL_RETURN_IF_FAIL (cogl_is_path (path));
300 /* Reference the new object first in case it is the same as the old
302 cogl_object_ref (path);
303 cogl_object_unref (ctx->current_path);
304 ctx->current_path = path;