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: bd92eb7f3c

Reviewed by: Carl Worth
This commit is contained in:
Behdad Esfahbod 2006-07-28 15:12:10 -04:00
parent 2f7da1aafb
commit 8411494948
2 changed files with 21 additions and 39 deletions

View file

@ -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);

View file

@ -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;
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;
font_options = cairo_font_options_create ();
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_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);