gstate: Move device-scale font scaling to gstate

If we do this in surface it will be applied twice then
we chain to a different surface, like e.g. a subsurface.

We also remove a hack in cairo-surface-wrapper where it compensated
for the device scale not being applied.

v2: Compute the backend CTM in ensure_scaled_font().
This commit is contained in:
Alexander Larsson 2013-05-30 20:53:29 +02:00 committed by Chris Wilson
parent 25eaec0a38
commit 900fc4a890
3 changed files with 13 additions and 31 deletions

View file

@ -1842,6 +1842,7 @@ _cairo_gstate_ensure_scaled_font (cairo_gstate_t *gstate)
cairo_status_t status;
cairo_font_options_t options;
cairo_scaled_font_t *scaled_font;
cairo_matrix_t font_ctm;
if (gstate->scaled_font != NULL)
return gstate->scaled_font->status;
@ -1853,9 +1854,13 @@ _cairo_gstate_ensure_scaled_font (cairo_gstate_t *gstate)
cairo_surface_get_font_options (gstate->target, &options);
cairo_font_options_merge (&options, &gstate->font_options);
cairo_matrix_multiply (&font_ctm,
&gstate->ctm,
&gstate->target->device_transform);
scaled_font = cairo_scaled_font_create (gstate->font_face,
&gstate->font_matrix,
&gstate->ctm,
&font_ctm,
&options);
status = cairo_scaled_font_status (scaled_font);
@ -2005,6 +2010,7 @@ _cairo_gstate_show_text_glyphs (cairo_gstate_t *gstate,
if (cairo_surface_has_show_text_glyphs (gstate->target) ||
_cairo_scaled_font_get_max_scale (gstate->scaled_font) <= 10240)
{
if (info != NULL) {
status = _cairo_surface_show_text_glyphs (gstate->target, op, pattern,
info->utf8, info->utf8_len,

View file

@ -437,12 +437,11 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
_cairo_surface_wrapper_get_transform (wrapper, &m);
if (! _cairo_matrix_is_translation (&wrapper->transform)) {
if (! _cairo_matrix_is_translation (&m)) {
cairo_matrix_t ctm;
/* XXX No device-transform? A bug in the tangle of layers? */
_cairo_matrix_multiply (&ctm,
&wrapper->transform,
&m,
&scaled_font->ctm);
dev_scaled_font = cairo_scaled_font_create (scaled_font->font_face,
&scaled_font->font_matrix,

View file

@ -2459,7 +2459,6 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
const cairo_clip_t *clip)
{
cairo_int_status_t status;
cairo_scaled_font_t *dev_scaled_font = scaled_font;
TRACE ((stderr, "%s\n", __FUNCTION__));
if (unlikely (surface->status))
@ -2484,25 +2483,6 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
if (unlikely (status))
return status;
if (_cairo_surface_has_device_transform (surface) &&
! _cairo_matrix_is_integer_translation (&surface->device_transform, NULL, NULL))
{
cairo_font_options_t font_options;
cairo_matrix_t dev_ctm, font_matrix;
cairo_scaled_font_get_font_matrix (scaled_font, &font_matrix);
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);
}
status = cairo_scaled_font_status (dev_scaled_font);
if (unlikely (status))
return _cairo_surface_set_error (surface, status);
status = CAIRO_INT_STATUS_UNSUPPORTED;
/* The logic here is duplicated in _cairo_analysis_surface show_glyphs and
@ -2516,7 +2496,7 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
utf8, utf8_len,
glyphs, num_glyphs,
clusters, num_clusters, cluster_flags,
dev_scaled_font,
scaled_font,
clip);
}
if (status == CAIRO_INT_STATUS_UNSUPPORTED &&
@ -2525,7 +2505,7 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
status = surface->backend->show_glyphs (surface, op,
source,
glyphs, num_glyphs,
dev_scaled_font,
scaled_font,
clip);
}
} else {
@ -2534,7 +2514,7 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
status = surface->backend->show_glyphs (surface, op,
source,
glyphs, num_glyphs,
dev_scaled_font,
scaled_font,
clip);
} else if (surface->backend->show_text_glyphs != NULL) {
/* Intentionally only try show_text_glyphs method for show_glyphs
@ -2550,14 +2530,11 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
utf8, utf8_len,
glyphs, num_glyphs,
clusters, num_clusters, cluster_flags,
dev_scaled_font,
scaled_font,
clip);
}
}
if (dev_scaled_font != scaled_font)
cairo_scaled_font_destroy (dev_scaled_font);
if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) {
surface->is_clear = FALSE;
surface->serial++;