summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-05-30 20:53:29 +0200
committerChris Wilson <chris@chris-wilson.co.uk>2013-09-05 16:08:19 +0100
commit900fc4a890026e46a3b0a00967632f57074b8b93 (patch)
tree9bccd996bdf3faa161770ae2aa5365485f0a3ab2
parent25eaec0a3874a2090e1bb97547a328eb5c00b0b1 (diff)
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().
-rw-r--r--src/cairo-gstate.c8
-rw-r--r--src/cairo-surface-wrapper.c5
-rw-r--r--src/cairo-surface.c31
3 files changed, 13 insertions, 31 deletions
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 56e961e66..8ddb3affd 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -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,
diff --git a/src/cairo-surface-wrapper.c b/src/cairo-surface-wrapper.c
index 578e8e2be..030de670a 100644
--- a/src/cairo-surface-wrapper.c
+++ b/src/cairo-surface-wrapper.c
@@ -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,
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 5e18b07e6..79b2f2e30 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -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++;