[cairo-commit] src/cairo-gstate.c src/cairo-surface.c
Behdad Esfahbod
behdad at kemper.freedesktop.org
Fri Jul 28 12:15:24 PDT 2006
src/cairo-gstate.c | 10 ++++++----
src/cairo-surface.c | 52 ++++++++++++++++------------------------------------
2 files changed, 22 insertions(+), 40 deletions(-)
New commits:
diff-tree 84114949488c7b9a2ae60edb33903b541ce1dadf (from 2f7da1aafb5ca050446fe3645eac3f95b9636b19)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Jul 28 15:12:10 2006 -0400
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
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index be1082b..f6bd601 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -1436,10 +1436,12 @@ _cairo_gstate_show_glyphs (cairo_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 3ff1ae7..fb25e07 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1702,7 +1702,6 @@ _cairo_surface_show_glyphs (cairo_surfac
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_surfac
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;
+ cairo_font_options_t *font_options;
+ cairo_matrix_t dev_ctm;
- 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);
- }
+ 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);
More information about the cairo-commit
mailing list