[gtk+/wip/pango-shadow-cache: 7/8] cssshadowvalue: Convert the current point into a translate
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/pango-shadow-cache: 7/8] cssshadowvalue: Convert the current point into a translate
- Date: Wed, 3 Sep 2014 20:03:34 +0000 (UTC)
commit 05d4e37a40f0502259bc35c653e2c2e318392f46
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Sep 3 09:32:45 2014 -0700
cssshadowvalue: Convert the current point into a translate
Pango uses the current point to determine where to paint the text, which
is considerably inconvenient since it doesn't work well with
translations.
To make this simpler for us, turn the current point into a translation,
which lets us merge the three different pieces of context setup into
just one.
gtk/gtkcssshadowvalue.c | 33 +++++++++++++++------------------
1 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index 89035cf..f8acb4a 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -421,29 +421,32 @@ _gtk_css_shadow_value_paint_layout (const GtkCssValue *shadow,
cairo_t *cr,
PangoLayout *layout)
{
+ double x, y;
+
g_return_if_fail (shadow->class == >K_CSS_VALUE_SHADOW);
cairo_save (cr);
+ cairo_get_current_point (cr, &x, &y);
+ cairo_translate (cr, x, y);
+ cairo_new_sub_path (cr);
+
+ cairo_translate (cr,
+ _gtk_css_number_value_get (shadow->hoffset, 0),
+ _gtk_css_number_value_get (shadow->voffset, 0));
+ gdk_cairo_set_source_rgba (cr, _gtk_css_rgba_value_get_rgba (shadow->color));
+
if (needs_blur (shadow))
{
cairo_surface_t *cached_surface = get_cached_surface (layout, shadow);
if (cached_surface)
{
- cairo_translate (cr,
- _gtk_css_number_value_get (shadow->hoffset, 0),
- _gtk_css_number_value_get (shadow->voffset, 0));
- gdk_cairo_set_source_rgba (cr, _gtk_css_rgba_value_get_rgba (shadow->color));
cairo_mask_surface (cr, cached_surface, 0, 0);
}
else
{
guint radius, serial;
- cairo_rel_move_to (cr,
- _gtk_css_number_value_get (shadow->hoffset, 0),
- _gtk_css_number_value_get (shadow->voffset, 0));
- gdk_cairo_set_source_rgba (cr, _gtk_css_rgba_value_get_rgba (shadow->color));
cr = gtk_css_shadow_value_start_drawing (shadow, cr);
_gtk_pango_fill_layout (cr, layout);
cached_surface = cairo_get_target (cr);
@@ -451,9 +454,6 @@ _gtk_css_shadow_value_paint_layout (const GtkCssValue *shadow,
cairo_surface_reference (cached_surface),
(GDestroyNotify) cairo_surface_destroy);
cr = gtk_css_shadow_value_finish_drawing (shadow, cr);
- cairo_rel_move_to (cr,
- - _gtk_css_number_value_get (shadow->hoffset, 0),
- - _gtk_css_number_value_get (shadow->voffset, 0));
radius = _gtk_css_number_value_get (shadow->radius, 0);
cairo_surface_set_user_data (cached_surface, &radius_key, GUINT_TO_POINTER (radius), NULL);
@@ -464,17 +464,14 @@ _gtk_css_shadow_value_paint_layout (const GtkCssValue *shadow,
}
else
{
- cairo_rel_move_to (cr,
- _gtk_css_number_value_get (shadow->hoffset, 0),
- _gtk_css_number_value_get (shadow->voffset, 0));
- gdk_cairo_set_source_rgba (cr, _gtk_css_rgba_value_get_rgba (shadow->color));
_gtk_pango_fill_layout (cr, layout);
- cairo_rel_move_to (cr,
- - _gtk_css_number_value_get (shadow->hoffset, 0),
- - _gtk_css_number_value_get (shadow->voffset, 0));
}
cairo_restore (cr);
+
+ /* Put the current point back where it was. */
+ cairo_new_sub_path (cr);
+ cairo_move_to (cr, x, y);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]