mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-06 19:00:12 +00:00
Merge branch 'wip/chergert/cache-text-render-node' into 'master'
textview: cache paragraph render nodes See merge request GNOME/gtk!1125
This commit is contained in:
commit
adff8c2c60
@ -2643,6 +2643,7 @@ gtk_text_line_display_finalize (GtkTextLineDisplay *display)
|
|||||||
|
|
||||||
g_clear_object (&display->layout);
|
g_clear_object (&display->layout);
|
||||||
g_clear_pointer (&display->cursors, g_array_unref);
|
g_clear_pointer (&display->cursors, g_array_unref);
|
||||||
|
g_clear_pointer (&display->node, gsk_render_node_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkTextLineDisplay *
|
GtkTextLineDisplay *
|
||||||
@ -3862,7 +3863,6 @@ render_para (GskPangoRenderer *crenderer,
|
|||||||
int screen_width;
|
int screen_width;
|
||||||
GdkRGBA *selection = NULL;
|
GdkRGBA *selection = NULL;
|
||||||
gboolean first = TRUE;
|
gboolean first = TRUE;
|
||||||
graphene_point_t point = { 0, offset_y };
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_TEXT_VIEW (crenderer->widget));
|
g_return_if_fail (GTK_IS_TEXT_VIEW (crenderer->widget));
|
||||||
|
|
||||||
@ -3880,8 +3880,12 @@ render_para (GskPangoRenderer *crenderer,
|
|||||||
gtk_style_context_restore (context);
|
gtk_style_context_restore (context);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_snapshot_save (crenderer->snapshot);
|
if (offset_y)
|
||||||
gtk_snapshot_translate (crenderer->snapshot, &point);
|
{
|
||||||
|
gtk_snapshot_save (crenderer->snapshot);
|
||||||
|
gtk_snapshot_translate (crenderer->snapshot,
|
||||||
|
&GRAPHENE_POINT_INIT (0, offset_y));
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -4054,7 +4058,8 @@ render_para (GskPangoRenderer *crenderer,
|
|||||||
}
|
}
|
||||||
while (pango_layout_iter_next_line (iter));
|
while (pango_layout_iter_next_line (iter));
|
||||||
|
|
||||||
gtk_snapshot_restore (crenderer->snapshot);
|
if (offset_y)
|
||||||
|
gtk_snapshot_restore (crenderer->snapshot);
|
||||||
|
|
||||||
gdk_rgba_free (selection);
|
gdk_rgba_free (selection);
|
||||||
pango_layout_iter_free (iter);
|
pango_layout_iter_free (iter);
|
||||||
@ -4146,9 +4151,27 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render_para (crenderer, offset_y, line_display,
|
if (line_display->node == NULL)
|
||||||
selection_start_index, selection_end_index,
|
{
|
||||||
cursor_alpha);
|
GtkSnapshot *sub = gtk_snapshot_new ();
|
||||||
|
|
||||||
|
crenderer->snapshot = sub;
|
||||||
|
render_para (crenderer, 0, line_display,
|
||||||
|
selection_start_index, selection_end_index,
|
||||||
|
cursor_alpha);
|
||||||
|
crenderer->snapshot = snapshot;
|
||||||
|
|
||||||
|
line_display->node = gtk_snapshot_free_to_node (sub);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line_display->node != NULL)
|
||||||
|
{
|
||||||
|
gtk_snapshot_save (crenderer->snapshot);
|
||||||
|
gtk_snapshot_translate (crenderer->snapshot,
|
||||||
|
&GRAPHENE_POINT_INIT (0, offset_y));
|
||||||
|
gtk_snapshot_append_node (crenderer->snapshot, line_display->node);
|
||||||
|
gtk_snapshot_restore (crenderer->snapshot);
|
||||||
|
}
|
||||||
|
|
||||||
/* We paint the cursors last, because they overlap another chunk
|
/* We paint the cursors last, because they overlap another chunk
|
||||||
* and need to appear on top.
|
* and need to appear on top.
|
||||||
|
@ -216,6 +216,9 @@ struct _GtkTextAttrAppearance
|
|||||||
struct _GtkTextLineDisplay
|
struct _GtkTextLineDisplay
|
||||||
{
|
{
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
|
|
||||||
|
GskRenderNode *node;
|
||||||
|
|
||||||
GArray *cursors; /* indexes of cursors in the PangoLayout */
|
GArray *cursors; /* indexes of cursors in the PangoLayout */
|
||||||
|
|
||||||
/* GSequenceIter backpointer for use within cache */
|
/* GSequenceIter backpointer for use within cache */
|
||||||
|
@ -234,6 +234,7 @@ gtk_text_line_display_cache_invalidate_display (GtkTextLineDisplayCache *cache,
|
|||||||
if (cursors_only)
|
if (cursors_only)
|
||||||
{
|
{
|
||||||
g_clear_pointer (&display->cursors, g_array_unref);
|
g_clear_pointer (&display->cursors, g_array_unref);
|
||||||
|
g_clear_pointer (&display->node, gsk_render_node_unref);
|
||||||
display->cursors_invalid = TRUE;
|
display->cursors_invalid = TRUE;
|
||||||
display->has_block_cursor = FALSE;
|
display->has_block_cursor = FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user