diff options
Diffstat (limited to 'src/cairo-script-surface.c')
-rw-r--r-- | src/cairo-script-surface.c | 120 |
1 files changed, 100 insertions, 20 deletions
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c index 0f0446d..5200b3a 100644 --- a/src/cairo-script-surface.c +++ b/src/cairo-script-surface.c @@ -929,10 +929,8 @@ _emit_linear_pattern (cairo_script_surface_t *surface, _cairo_output_stream_printf (ctx->stream, "%f %f %f %f linear", - _cairo_fixed_to_double (linear->p1.x), - _cairo_fixed_to_double (linear->p1.y), - _cairo_fixed_to_double (linear->p2.x), - _cairo_fixed_to_double (linear->p2.y)); + linear->pd1.x, linear->pd1.y, + linear->pd2.x, linear->pd2.y); return _emit_gradient_color_stops (&linear->base, ctx->stream); } @@ -947,16 +945,97 @@ _emit_radial_pattern (cairo_script_surface_t *surface, _cairo_output_stream_printf (ctx->stream, "%f %f %f %f %f %f radial", - _cairo_fixed_to_double (radial->c1.x), - _cairo_fixed_to_double (radial->c1.y), - _cairo_fixed_to_double (radial->r1), - _cairo_fixed_to_double (radial->c2.x), - _cairo_fixed_to_double (radial->c2.y), - _cairo_fixed_to_double (radial->r2)); + radial->cd1.center.x, + radial->cd1.center.y, + radial->cd1.radius, + radial->cd2.center.x, + radial->cd2.center.y, + radial->cd2.radius); return _emit_gradient_color_stops (&radial->base, ctx->stream); } static cairo_status_t +_emit_mesh_pattern (cairo_script_surface_t *surface, + const cairo_pattern_t *pattern) +{ + cairo_script_context_t *ctx = to_context (surface); + cairo_pattern_t *mesh; + cairo_status_t status; + unsigned int i, n; + + mesh = (cairo_pattern_t *) pattern; + status = cairo_pattern_mesh_get_patch_count (mesh, &n); + if (unlikely (status)) + return status; + + _cairo_output_stream_printf (ctx->stream, "mesh"); + for (i = 0; i < n; i++) { + cairo_path_t *path; + cairo_path_data_t *data; + int j; + + _cairo_output_stream_printf (ctx->stream, "\n mesh-begin-patch"); + + path = cairo_pattern_mesh_get_path (mesh, i); + if (unlikely (path->status)) + return path->status; + + for (j = 0; j < path->num_data; j+=data[0].header.length) { + data = &path->data[j]; + switch (data->header.type) { + case CAIRO_PATH_MOVE_TO: + _cairo_output_stream_printf (ctx->stream, + "\n %f %f mesh-move-to", + data[1].point.x, data[1].point.y); + break; + case CAIRO_PATH_LINE_TO: + _cairo_output_stream_printf (ctx->stream, + "\n %f %f mesh-line-to", + data[1].point.x, data[1].point.y); + break; + case CAIRO_PATH_CURVE_TO: + _cairo_output_stream_printf (ctx->stream, + "\n %f %f %f %f %f %f mesh-curve-to", + data[1].point.x, data[1].point.y, + data[2].point.x, data[2].point.y, + data[3].point.x, data[3].point.y); + break; + case CAIRO_PATH_CLOSE_PATH: + break; + } + } + cairo_path_destroy (path); + + for (j = 0; j < 4; j++) { + double x, y; + + status = cairo_pattern_mesh_get_control_point (mesh, i, j, &x, &y); + if (unlikely (status)) + return status; + _cairo_output_stream_printf (ctx->stream, + "\n %d %f %f mesh-set-control-point", + j, x, y); + } + + for (j = 0; j < 4; j++) { + double r, g, b, a; + + status = cairo_pattern_mesh_get_corner_color_rgba (mesh, i, j, &r, &g, &b, &a); + if (unlikely (status)) + return status; + + _cairo_output_stream_printf (ctx->stream, + "\n %d %f %f %f %f mesh-set-corner-color", + j, r, g, b, a); + } + + _cairo_output_stream_printf (ctx->stream, "\n mesh-end-patch"); + } + + return CAIRO_STATUS_SUCCESS; +} + +static cairo_status_t _emit_recording_surface_pattern (cairo_script_surface_t *surface, cairo_recording_surface_t *source) { @@ -1465,6 +1544,10 @@ _emit_pattern (cairo_script_surface_t *surface, status = _emit_radial_pattern (surface, pattern); is_default_extend = pattern->extend == CAIRO_EXTEND_GRADIENT_DEFAULT; break; + case CAIRO_PATTERN_TYPE_MESH: + status = _emit_mesh_pattern (surface, pattern); + is_default_extend = TRUE; + break; case CAIRO_PATTERN_TYPE_SURFACE: status = _emit_surface_pattern (surface, pattern); is_default_extend = pattern->extend == CAIRO_EXTEND_SURFACE_DEFAULT; @@ -1666,7 +1749,6 @@ _emit_path (cairo_script_surface_t *surface, return status; status = _cairo_path_fixed_interpret (path, - CAIRO_DIRECTION_FORWARD, _path_move_to, _path_line_to, _path_curve_to, @@ -2054,13 +2136,13 @@ _cairo_script_surface_clipper_intersect_clip_path (cairo_surface_clipper_t *clip if (unlikely (status)) return status; - if (! path->is_rectilinear) { + if (path->has_curve_to) { status = _emit_tolerance (surface, tolerance, matrix_updated); if (unlikely (status)) return status; } - if (! path->maybe_fill_region) { + if (! _cairo_path_fixed_fill_maybe_region (path)) { status = _emit_antialias (surface, antialias); if (unlikely (status)) return status; @@ -2343,11 +2425,9 @@ _cairo_script_surface_stroke (void *abstract_surface, if (unlikely (status)) goto BAIL; - if (! path->is_rectilinear) { - status = _emit_tolerance (surface, tolerance, matrix_updated); - if (unlikely (status)) - goto BAIL; - } + status = _emit_tolerance (surface, tolerance, matrix_updated); + if (unlikely (status)) + goto BAIL; status = _emit_antialias (surface, antialias); if (unlikely (status)) @@ -2414,13 +2494,13 @@ _cairo_script_surface_fill (void *abstract_surface, goto BAIL; } - if (! path->is_rectilinear) { + if (path->has_curve_to) { status = _emit_tolerance (surface, tolerance, matrix_updated); if (unlikely (status)) goto BAIL; } - if (! path->maybe_fill_region) { + if (! _cairo_path_fixed_fill_maybe_region (path)) { status = _emit_antialias (surface, antialias); if (unlikely (status)) goto BAIL; |