summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-08-11 22:43:31 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-08-29 08:08:35 +0100
commit858211f3944507362b2a18d56a65e9a478ccd305 (patch)
tree9b5c19f8c5f1213c00d375c5694bae7796e0f22c
parentb6db3053dcde99e26471fdeaedcadd4a6f93b5ef (diff)
[script] Suppress resetting stroke-style elements after matrix switch
If the user is just using the default values, there is no point re-emitting them.
-rw-r--r--src/cairo-script-surface.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index 4ac62329..e14a9bd2 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -520,8 +520,12 @@ _emit_tolerance (cairo_script_surface_t *surface,
{
assert (target_is_active (surface));
- if (! force && surface->cr.current_tolerance == tolerance)
+ if ((! force ||
+ fabs (tolerance - CAIRO_GSTATE_TOLERANCE_DEFAULT) < 1e-5) &&
+ surface->cr.current_tolerance == tolerance)
+ {
return CAIRO_STATUS_SUCCESS;
+ }
surface->cr.current_tolerance = tolerance;
@@ -556,8 +560,12 @@ _emit_line_width (cairo_script_surface_t *surface,
{
assert (target_is_active (surface));
- if (! force && surface->cr.current_style.line_width == line_width)
+ if ((! force ||
+ fabs (line_width - CAIRO_GSTATE_LINE_WIDTH_DEFAULT) < 1e-5) &&
+ surface->cr.current_style.line_width == line_width)
+ {
return CAIRO_STATUS_SUCCESS;
+ }
surface->cr.current_style.line_width = line_width;
@@ -608,8 +616,12 @@ _emit_miter_limit (cairo_script_surface_t *surface,
{
assert (target_is_active (surface));
- if (! force && surface->cr.current_style.miter_limit == miter_limit)
+ if ((! force ||
+ fabs (miter_limit - CAIRO_GSTATE_MITER_LIMIT_DEFAULT) < 1e-5) &&
+ surface->cr.current_style.miter_limit == miter_limit)
+ {
return CAIRO_STATUS_SUCCESS;
+ }
surface->cr.current_style.miter_limit = miter_limit;
@@ -1507,31 +1519,29 @@ _emit_scaling_matrix (cairo_script_surface_t *surface,
const cairo_matrix_t *ctm,
cairo_bool_t *matrix_updated)
{
- cairo_matrix_t current, ctm_scaling;
-
assert (target_is_active (surface));
- current = surface->cr.current_ctm;
- current.x0 = current.y0 = 0;
-
- ctm_scaling = *ctm;
- ctm_scaling.x0 = ctm_scaling.y0 = 0;
-
- if (memcmp (&current, &ctm_scaling, sizeof (cairo_matrix_t)) == 0)
+ if (fabs (surface->cr.current_ctm.xx - ctm->xx) < 1e-5 &&
+ fabs (surface->cr.current_ctm.xy - ctm->xy) < 1e-5 &&
+ fabs (surface->cr.current_ctm.yx - ctm->yx) < 1e-5 &&
+ fabs (surface->cr.current_ctm.yy - ctm->yy) < 1e-5)
+ {
return CAIRO_STATUS_SUCCESS;
+ }
*matrix_updated = TRUE;
surface->cr.current_ctm = *ctm;
+ surface->cr.current_ctm.x0 = 0.;
+ surface->cr.current_ctm.y0 = 0.;
- if (_cairo_matrix_is_identity (ctm)) {
+ if (_cairo_matrix_is_identity (&surface->cr.current_ctm)) {
_cairo_output_stream_puts (surface->ctx->stream,
"identity set-matrix\n");
} else {
_cairo_output_stream_printf (surface->ctx->stream,
- "[%f %f %f %f %f %f] set-matrix\n",
+ "[%f %f %f %f 0 0] set-matrix\n",
ctm->xx, ctm->yx,
- ctm->xy, ctm->yy,
- ctm->x0, ctm->y0);
+ ctm->xy, ctm->yy);
}
return CAIRO_STATUS_SUCCESS;