summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog21
-rw-r--r--docs/pango-sections.txt2
-rw-r--r--docs/tmpl/pango-renderer.sgml18
-rw-r--r--pango/pango-renderer.c50
-rw-r--r--pango/pango-renderer.h3
-rw-r--r--pango/pango.def2
-rw-r--r--pango/pangocairo-render.c29
7 files changed, 113 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 76ea90d9..97738899 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
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.
+
+2007-10-24 Behdad Esfahbod <behdad@gnome.org>
+
* pango/pango-attributes.c: Fix couple Oopses from my last
commit.
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index df043d75..bdc06864 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -660,6 +660,8 @@ pango_renderer_set_color
pango_renderer_get_color
pango_renderer_set_matrix
pango_renderer_get_matrix
+pango_renderer_get_layout
+pango_renderer_get_layout_line
<SUBSECTION Standard>
PANGO_RENDERER
PANGO_IS_RENDERER
diff --git a/docs/tmpl/pango-renderer.sgml b/docs/tmpl/pango-renderer.sgml
index 181986f0..c265271e 100644
--- a/docs/tmpl/pango-renderer.sgml
+++ b/docs/tmpl/pango-renderer.sgml
@@ -210,3 +210,21 @@ The #GObject type for #PangoRenderPart.
@Returns:
+<!-- ##### FUNCTION pango_renderer_get_layout ##### -->
+<para>
+
+</para>
+
+@renderer:
+@Returns:
+
+
+<!-- ##### FUNCTION pango_renderer_get_layout_line ##### -->
+<para>
+
+</para>
+
+@renderer:
+@Returns:
+
+
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c
index c7db5e57..d0cfa275 100644
--- a/pango/pango-renderer.c
+++ b/pango/pango-renderer.c
@@ -54,6 +54,7 @@ struct _PangoRendererPrivate
PangoColor color[N_RENDER_PARTS];
gboolean color_set[N_RENDER_PARTS];
+ PangoLayoutLine *line;
LineState *line_state;
};
@@ -469,6 +470,7 @@ pango_renderer_draw_layout_line (PangoRenderer *renderer,
pango_renderer_activate (renderer);
+ renderer->priv->line = line;
renderer->priv->line_state = &state;
state.underline = PANGO_UNDERLINE_NONE;
@@ -594,6 +596,7 @@ pango_renderer_draw_layout_line (PangoRenderer *renderer,
draw_strikethrough (renderer, &state);
renderer->priv->line_state = NULL;
+ renderer->priv->line = NULL;
pango_renderer_deactivate (renderer);
}
@@ -1278,3 +1281,50 @@ pango_renderer_get_matrix (PangoRenderer *renderer)
return renderer->matrix;
}
+
+/**
+ * pango_renderer_get_layout:
+ * @renderer: a #PangoRenderer
+ *
+ * Gets the layout currently being rendered using @renderer.
+ * Calling this function only makes sense from inside a subclass's
+ * methods, like in its draw_shape<!---->() for example.
+ *
+ * The returned layout should not be modified while still being
+ * rendered.
+ *
+ * Return value: the layout, or %NULL if no layout is being
+ * rendered using @renderer at this time.
+ *
+ * Since: 1.20
+ **/
+PangoLayout *
+pango_renderer_get_layout (PangoRenderer *renderer)
+{
+ if (G_UNLIKELY (renderer->priv->line == NULL))
+ return NULL;
+
+ return renderer->priv->line->layout;
+}
+
+/**
+ * pango_renderer_get_layout_line:
+ * @renderer: a #PangoRenderer
+ *
+ * Gets the layout line currently being rendered using @renderer.
+ * Calling this function only makes sense from inside a subclass's
+ * methods, like in its draw_shape<!---->() for example.
+ *
+ * The returned layout line should not be modified while still being
+ * rendered.
+ *
+ * Return value: the layout line, or %NULL if no layout line is being
+ * rendered using @renderer at this time.
+ *
+ * Since: 1.20
+ **/
+PangoLayoutLine *
+pango_renderer_get_layout_line (PangoRenderer *renderer)
+{
+ return renderer->priv->line;
+}
diff --git a/pango/pango-renderer.h b/pango/pango-renderer.h
index 47fbb017..89c45fac 100644
--- a/pango/pango-renderer.h
+++ b/pango/pango-renderer.h
@@ -237,6 +237,9 @@ void pango_renderer_set_matrix (PangoRenderer *render
const PangoMatrix *matrix);
G_CONST_RETURN PangoMatrix *pango_renderer_get_matrix (PangoRenderer *renderer);
+PangoLayout *pango_renderer_get_layout (PangoRenderer *renderer);
+PangoLayoutLine *pango_renderer_get_layout_line (PangoRenderer *renderer);
+
G_END_DECLS
#endif /* __PANGO_RENDERER_H_ */
diff --git a/pango/pango.def b/pango/pango.def
index 06ff66d7..985c03aa 100644
--- a/pango/pango.def
+++ b/pango/pango.def
@@ -328,6 +328,8 @@ EXPORTS
pango_renderer_draw_rectangle
pango_renderer_draw_trapezoid
pango_renderer_get_color
+ pango_renderer_get_layout
+ pango_renderer_get_layout_line
pango_renderer_get_matrix
pango_renderer_get_type
pango_renderer_part_changed
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);