[pango] layout: Move PangoLayouIter struct to private header



commit fa79c5fc004b8a852074fe63670b55129f81f52e
Author: Timm Bäder <mail baedert org>
Date:   Sat Oct 7 18:15:29 2017 +0200

    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

 pango/pango-layout-private.h |   53 ++++++++++++++++++++++++++
 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 d0bf93e..9a23d9e 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 761feaf..3c817b6 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);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]