diff options
author | Timm Bäder <mail@baedert.org> | 2017-10-07 18:15:29 +0200 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-10-27 16:29:14 -0400 |
commit | fa79c5fc004b8a852074fe63670b55129f81f52e (patch) | |
tree | 5ac0bdd1f7854c034d202a40088aadbc6cfb75cb | |
parent | c53d56212a3491ea3eeb49f7e38391eb95dfe671 (diff) | |
download | pango-fa79c5fc004b8a852074fe63670b55129f81f52e.tar.gz |
layout: Move PangoLayouIter struct to private header
And add _pango_layout_get_iter as well as _pango_layout_iter_destroy
that can be used for internal, stack allocated PangoLayoutIters.
https://bugzilla.gnome.org/show_bug.cgi?id=788643
-rw-r--r-- | pango/pango-layout-private.h | 53 | ||||
-rw-r--r-- | pango/pango-layout.c | 84 |
2 files changed, 80 insertions, 57 deletions
diff --git a/pango/pango-layout-private.h b/pango/pango-layout-private.h index d0bf93eb..9a23d9e7 100644 --- a/pango/pango-layout-private.h +++ b/pango/pango-layout-private.h @@ -82,10 +82,63 @@ struct _PangoLayout guint line_count; /* Number of lines in @lines. 0 if lines is %NULL */ }; +struct _PangoLayoutIter +{ + PangoLayout *layout; + GSList *line_list_link; + PangoLayoutLine *line; + + /* If run is NULL, it means we're on a "virtual run" + * at the end of the line with 0 width + */ + GSList *run_list_link; + PangoLayoutRun *run; /* FIXME nuke this, just keep the link */ + int index; + + /* list of Extents for each line in layout coordinates */ + GSList *line_extents; + GSList *line_extents_link; + + /* X position of the current run */ + int run_x; + + /* Width of the current run */ + int run_width; + + /* this run is left-to-right */ + gboolean ltr; + + /* X position of the left side of the current cluster */ + int cluster_x; + + /* The width of the current cluster */ + int cluster_width; + + /* glyph offset to the current cluster start */ + int cluster_start; + + /* first glyph in the next cluster */ + int next_cluster_glyph; + + /* number of Unicode chars in current cluster */ + int cluster_num_chars; + + /* visual position of current character within the cluster */ + int character_position; + + /* the real width of layout */ + int layout_width; +}; + gboolean _pango_layout_line_ellipsize (PangoLayoutLine *line, PangoAttrList *attrs, int goal_width); +void _pango_layout_get_iter (PangoLayout *layout, + PangoLayoutIter *iter); + +void _pango_layout_iter_destroy (PangoLayoutIter *iter); + G_END_DECLS #endif /* __PANGO_LAYOUT_PRIVATE_H__ */ diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 761feafa..3c817b61 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -104,54 +104,6 @@ struct _ItemProperties PangoRectangle *shape_logical_rect; }; -struct _PangoLayoutIter -{ - PangoLayout *layout; - GSList *line_list_link; - PangoLayoutLine *line; - - /* If run is NULL, it means we're on a "virtual run" - * at the end of the line with 0 width - */ - GSList *run_list_link; - PangoLayoutRun *run; /* FIXME nuke this, just keep the link */ - int index; - - /* list of Extents for each line in layout coordinates */ - GSList *line_extents; - GSList *line_extents_link; - - /* X position of the current run */ - int run_x; - - /* Width of the current run */ - int run_width; - - /* this run is left-to-right */ - gboolean ltr; - - /* X position of the left side of the current cluster */ - int cluster_x; - - /* The width of the current cluster */ - int cluster_width; - - /* glyph offset to the current cluster start */ - int cluster_start; - - /* first glyph in the next cluster */ - int next_cluster_glyph; - - /* number of Unicode chars in current cluster */ - int cluster_num_chars; - - /* visual position of current character within the cluster */ - int character_position; - - /* the real width of layout */ - int layout_width; -}; - typedef struct _PangoLayoutLinePrivate PangoLayoutLinePrivate; struct _PangoLayoutLinePrivate @@ -5753,16 +5705,27 @@ G_DEFINE_BOXED_TYPE (PangoLayoutIter, pango_layout_iter, PangoLayoutIter* pango_layout_get_iter (PangoLayout *layout) { - int run_start_index; PangoLayoutIter *iter; - PangoRectangle logical_rect; g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL); iter = g_slice_new (PangoLayoutIter); - iter->layout = layout; - g_object_ref (iter->layout); + _pango_layout_get_iter (layout, iter); + + return iter; +} + +void +_pango_layout_get_iter (PangoLayout *layout, + PangoLayoutIter*iter) +{ + int run_start_index; + PangoRectangle logical_rect; + + g_return_if_fail (PANGO_IS_LAYOUT (layout)); + + iter->layout = g_object_ref (layout); pango_layout_check_lines (layout); @@ -5791,8 +5754,18 @@ pango_layout_get_iter (PangoLayout *layout) iter->line_extents_link = iter->line_extents; update_run (iter, run_start_index); +} - return iter; +void +_pango_layout_iter_destroy (PangoLayoutIter *iter) +{ + if (iter == NULL) + return; + + g_slist_foreach (iter->line_extents, (GFunc)extents_free, NULL); + g_slist_free (iter->line_extents); + pango_layout_line_unref (iter->line); + g_object_unref (iter->layout); } /** @@ -5807,10 +5780,7 @@ pango_layout_iter_free (PangoLayoutIter *iter) if (iter == NULL) return; - g_slist_foreach (iter->line_extents, (GFunc)extents_free, NULL); - g_slist_free (iter->line_extents); - pango_layout_line_unref (iter->line); - g_object_unref (iter->layout); + _pango_layout_iter_destroy (iter); g_slice_free (PangoLayoutIter, iter); } |