diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2007-10-24 06:37:13 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2007-10-24 06:37:13 +0000 |
commit | 60507b9471bf6755fff6d52789b18d3bc5540cea (patch) | |
tree | f2d491823e6ba79a69bf29d86d69d07ea58b2b3f /pango/pangocairo-render.c | |
parent | fb097dd671439d53dfc26f73f70c7aa8c8918304 (diff) | |
download | pango-60507b9471bf6755fff6d52789b18d3bc5540cea.tar.gz |
Bug 472629 – Add pango_renderer_get_layout(_line)
2007-10-24 Behdad Esfahbod <behdad@gnome.org>
Bug 472629 – Add pango_renderer_get_layout(_line)
* pango/pango-renderer.h:
* pango/pango-renderer.c:
New public API:
pango_renderer_get_layout()
pango_renderer_get_layout_line()
* pango/pangocairo-render.c (pango_cairo_renderer_draw_shape),
(release_renderer), (_pango_cairo_do_layout_line),
(_pango_cairo_do_layout): Use above API to simplify
shape_renderer implementation.
* pango/pango.def:
* docs/pango-sections.txt:
* docs/tmpl/pango-renderer.sgml:
Update.
svn path=/trunk/; revision=2460
Diffstat (limited to 'pango/pangocairo-render.c')
-rw-r--r-- | pango/pangocairo-render.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c index b0ef136d..21792cb1 100644 --- a/pango/pangocairo-render.c +++ b/pango/pangocairo-render.c @@ -36,8 +36,6 @@ struct _PangoCairoRenderer cairo_t *cr; gboolean do_path; double x_offset, y_offset; - PangoCairoShapeRendererFunc shape_renderer; - gpointer shape_renderer_data; }; struct _PangoCairoRendererClass @@ -414,19 +412,32 @@ pango_cairo_renderer_draw_shape (PangoRenderer *renderer, { PangoCairoRenderer *crenderer = (PangoCairoRenderer *) (renderer); cairo_t *cr = crenderer->cr; - double base_x = crenderer->x_offset + (double)x / PANGO_SCALE; - double base_y = crenderer->y_offset + (double)y / PANGO_SCALE; + PangoLayout *layout; + PangoCairoShapeRendererFunc shape_renderer; + gpointer shape_renderer_data; + double base_x, base_y; + + layout = pango_renderer_get_layout (renderer); + + if (!layout) + return; - if (!crenderer->shape_renderer) + shape_renderer = pango_cairo_context_get_shape_renderer (pango_layout_get_context (layout), + &shape_renderer_data); + + if (!shape_renderer) return; + base_x = crenderer->x_offset + (double)x / PANGO_SCALE; + base_y = crenderer->y_offset + (double)y / PANGO_SCALE; + cairo_save (cr); if (!crenderer->do_path) set_color (crenderer, PANGO_RENDER_PART_FOREGROUND); cairo_move_to (cr, base_x, base_y); - crenderer->shape_renderer (cr, attr, crenderer->do_path, crenderer->shape_renderer_data); + shape_renderer (cr, attr, crenderer->do_path, shape_renderer_data); cairo_restore (cr); } @@ -479,8 +490,6 @@ release_renderer (PangoCairoRenderer *renderer, gboolean free_renderer) { renderer->cr = NULL; renderer->do_path = FALSE; - renderer->shape_renderer = NULL; - renderer->shape_renderer_data = NULL; renderer->x_offset = 0.; renderer->y_offset = 0.; @@ -543,8 +552,6 @@ _pango_cairo_do_layout_line (cairo_t *cr, crenderer->cr = cr; crenderer->do_path = do_path; - crenderer->shape_renderer = pango_cairo_context_get_shape_renderer (pango_layout_get_context (line->layout), - &crenderer->shape_renderer_data); cairo_get_current_point (cr, &crenderer->x_offset, &crenderer->y_offset); pango_renderer_draw_layout_line (renderer, line, 0, 0); @@ -563,8 +570,6 @@ _pango_cairo_do_layout (cairo_t *cr, crenderer->cr = cr; crenderer->do_path = do_path; - crenderer->shape_renderer = pango_cairo_context_get_shape_renderer (pango_layout_get_context (layout), - &crenderer->shape_renderer_data); cairo_get_current_point (cr, &crenderer->x_offset, &crenderer->y_offset); pango_renderer_draw_layout (renderer, layout, 0, 0); |