From 42dfc21b2dfdc11a9ab1bc51cfba50156733acdc Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 12 Mar 2021 18:26:15 -0500 Subject: [PATCH 1/3] ngl: Fix up some debug printouts --- gsk/ngl/gsknglcommandqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsk/ngl/gsknglcommandqueue.c b/gsk/ngl/gsknglcommandqueue.c index d955f49bc3..aff201cb4a 100644 --- a/gsk/ngl/gsknglcommandqueue.c +++ b/gsk/ngl/gsknglcommandqueue.c @@ -143,7 +143,7 @@ G_GNUC_UNUSED static inline void gsk_ngl_command_queue_print_batch (GskNglCommandQueue *self, const GskNglCommandBatch *batch) { - static const char *command_kinds[] = { "Clear", NULL, NULL, "Draw", }; + static const char *command_kinds[] = { "Clear", "Draw", }; guint framebuffer_id; g_assert (GSK_IS_NGL_COMMAND_QUEUE (self)); From 3a928c898007709066dabbc8f50c40f3f90a2527 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 12 Mar 2021 19:28:36 -0500 Subject: [PATCH 2/3] textlayout: Render cursors at the end Don't place the insertion cursor render nodes in the middle of the text nodes for all the text. This helps the renderer batching the text draw calls together. --- gtk/gtktextlayout.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index 9c994137ae..358a92e517 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -4142,6 +4142,8 @@ gtk_text_layout_snapshot (GtkTextLayout *layout, GSList *line_list; GSList *tmp_list; GdkRGBA color; + GtkSnapshot *cursor_snapshot; + GskRenderNode *cursors; g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout)); g_return_if_fail (layout->default_style != NULL); @@ -4158,6 +4160,8 @@ gtk_text_layout_snapshot (GtkTextLayout *layout, if (line_list == NULL) return; /* nothing on the screen */ + cursor_snapshot = gtk_snapshot_new (); + crenderer = gsk_pango_renderer_acquire (); gsk_pango_renderer_set_shape_handler (crenderer, snapshot_shape); @@ -4267,14 +4271,14 @@ gtk_text_layout_snapshot (GtkTextLayout *layout, dir = (line_display->direction == GTK_TEXT_DIR_RTL) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR; if (cursor.is_insert || cursor.is_selection_bound) - gtk_snapshot_push_opacity (crenderer->snapshot, cursor_alpha); + gtk_snapshot_push_opacity (cursor_snapshot, cursor_alpha); - gtk_snapshot_render_insertion_cursor (crenderer->snapshot, context, + gtk_snapshot_render_insertion_cursor (cursor_snapshot, context, line_display->x_offset, offset_y + line_display->top_margin, line_display->layout, cursor.pos, dir); if (cursor.is_insert || cursor.is_selection_bound) - gtk_snapshot_pop (crenderer->snapshot); + gtk_snapshot_pop (cursor_snapshot); } } } /* line_display->height > 0 */ @@ -4288,6 +4292,13 @@ gtk_text_layout_snapshot (GtkTextLayout *layout, gtk_text_layout_wrap_loop_end (layout); + cursors = gtk_snapshot_free_to_node (cursor_snapshot); + if (cursors) + { + gtk_snapshot_append_node (crenderer->snapshot, cursors); + gsk_render_node_unref (cursors); + } + /* Only update eviction source once per snapshot */ gtk_text_line_display_cache_delay_eviction (priv->cache); From 9be2f130f05fe2fff9a9de6d49f27f36fd6a2355 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 12 Mar 2021 19:44:31 -0500 Subject: [PATCH 3/3] textview: Fix blinking block cursors When we have a block cursor, we need to discard the cached node of the line containing the cursor, in order to get a blinking cursor. --- gtk/gtktextlayout.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index 358a92e517..b90e6d12f1 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -4236,6 +4236,13 @@ gtk_text_layout_snapshot (GtkTextLayout *layout, selection_end_index = -1; } + if (line_display->node != NULL) + { + if (line_display->has_block_cursor && + gtk_widget_has_focus (widget)) + g_clear_pointer (&line_display->node, gsk_render_node_unref); + } + if (line_display->node == NULL) { gtk_snapshot_push_collect (snapshot);