diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2006-07-28 15:12:10 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2006-07-28 15:15:15 -0400 |
commit | 84114949488c7b9a2ae60edb33903b541ce1dadf (patch) | |
tree | 642ee4246c9f27ffcbdb11dad8b1e0692251a7f3 /src | |
parent | 2f7da1aafb5ca050446fe3645eac3f95b9636b19 (diff) |
Move font-matrix translation and device transform from surface to gstate
Fixes the bug that paginated backends had font-matrix translation
applied twice, AND removes a second copy of the glyphs. It's
essentially similar to what cworth did for stroke/fill/clip in
this commit: bd92eb7f3c58fdcbe05f67b9a879798246c616bc
Reviewed by: Carl Worth
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-gstate.c | 10 | ||||
-rw-r--r-- | src/cairo-surface.c | 54 |
2 files changed, 23 insertions, 41 deletions
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index be1082bc6..f6bd6013a 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -1436,10 +1436,12 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate, for (i = 0; i < num_glyphs; ++i) { - transformed_glyphs[i] = glyphs[i]; - _cairo_gstate_user_to_device (gstate, - &transformed_glyphs[i].x, - &transformed_glyphs[i].y); + transformed_glyphs[i].index = glyphs[i].index; + transformed_glyphs[i].x = glyphs[i].x + gstate->font_matrix.x0; + transformed_glyphs[i].y = glyphs[i].y + gstate->font_matrix.y0; + _cairo_gstate_user_to_backend (gstate, + &transformed_glyphs[i].x, + &transformed_glyphs[i].y); } _cairo_gstate_copy_transformed_source (gstate, &source_pattern.base); diff --git a/src/cairo-surface.c b/src/cairo-surface.c index 3ff1ae7c1..fb25e075b 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -1702,7 +1702,6 @@ _cairo_surface_show_glyphs (cairo_surface_t *surface, cairo_scaled_font_t *scaled_font) { cairo_status_t status; - cairo_glyph_t *dev_glyphs = (cairo_glyph_t*) glyphs; cairo_scaled_font_t *dev_scaled_font = scaled_font; cairo_pattern_union_t dev_source; cairo_matrix_t font_matrix; @@ -1721,56 +1720,37 @@ _cairo_surface_show_glyphs (cairo_surface_t *surface, cairo_scaled_font_get_font_matrix (scaled_font, &font_matrix); - if (_cairo_surface_has_device_transform (surface) || font_matrix.x0 != 0.0 || font_matrix.y0 != 0.0) + if (_cairo_surface_has_device_transform (surface) && + ! _cairo_matrix_is_integer_translation (&surface->device_transform, NULL, NULL)) { - int i; - - dev_glyphs = malloc (sizeof(cairo_glyph_t) * num_glyphs); - if (!dev_glyphs) - return CAIRO_STATUS_NO_MEMORY; - - for (i = 0; i < num_glyphs; i++) { - dev_glyphs[i].index = glyphs[i].index; - dev_glyphs[i].x = glyphs[i].x + font_matrix.x0; - dev_glyphs[i].y = glyphs[i].y + font_matrix.y0; - cairo_matrix_transform_point (&surface->device_transform, - &dev_glyphs[i].x, - &dev_glyphs[i].y); - } - - if (! _cairo_matrix_is_integer_translation (&surface->device_transform, NULL, NULL)) { - cairo_font_options_t *font_options; - cairo_matrix_t dev_ctm; - - font_options = cairo_font_options_create (); - - cairo_scaled_font_get_ctm (scaled_font, &dev_ctm); - cairo_matrix_multiply (&dev_ctm, &dev_ctm, &surface->device_transform); - cairo_scaled_font_get_font_options (scaled_font, font_options); - dev_scaled_font = cairo_scaled_font_create (cairo_scaled_font_get_font_face (scaled_font), - &font_matrix, - &dev_ctm, - font_options); - cairo_font_options_destroy (font_options); - } + cairo_font_options_t *font_options; + cairo_matrix_t dev_ctm; + + font_options = cairo_font_options_create (); + + cairo_scaled_font_get_ctm (scaled_font, &dev_ctm); + cairo_matrix_multiply (&dev_ctm, &dev_ctm, &surface->device_transform); + cairo_scaled_font_get_font_options (scaled_font, font_options); + dev_scaled_font = cairo_scaled_font_create (cairo_scaled_font_get_font_face (scaled_font), + &font_matrix, + &dev_ctm, + font_options); + cairo_font_options_destroy (font_options); } if (surface->backend->show_glyphs) { status = surface->backend->show_glyphs (surface, op, &dev_source.base, - dev_glyphs, num_glyphs, + glyphs, num_glyphs, dev_scaled_font); if (status != CAIRO_INT_STATUS_UNSUPPORTED) goto FINISH; } status = _cairo_surface_fallback_show_glyphs (surface, op, &dev_source.base, - dev_glyphs, num_glyphs, + glyphs, num_glyphs, dev_scaled_font); FINISH: - if (dev_glyphs != glyphs) - free (dev_glyphs); - if (dev_scaled_font != scaled_font) cairo_scaled_font_destroy (dev_scaled_font); |