[vim/vim] GTK4: Use GtkSnapshot for rendering instead of Cairo (PR #20324)

6 views
Skip to first unread message

Foxe Chen

unread,
May 24, 2026, 10:22:54 PM (4 hours ago) May 24
to vim/vim, Subscribed

Fully replace the cairo rendering path with one that uses GTK4's GtkSnapshot. GtkSnapshot is hardware accelerated compared to cairo which uses the CPU.

For environments where a GPU is not available or just infeasible to use smoothly, users can set the env var GSK_RENDERER=cairo beforehand so that GtkSnapshot uses internally. I do not think this should be under a feature flag (and coexist with the old cairo rendering path), since I'm assuming the GTK4 gui is experimental (its not enabled by default), and future changes that affect rendering will just be more complicated for no benefit.

A quick test on my laptop shows a 2% decrease in CPU usage (total of all cores) compared to the cairo rendering path, possibly more considering the GtkSnapshot build was built using debug flags compared to the optimized build cairo GTK4 Vim.

I also plan on this PR resolving #20301 as well

Since GtkSnapshot does not have an equivalent way of blitting to a surface like Cairo, the render nodes that make up the scene graph (which is then rendered) are cached in a custom GtkWidget. the gui_mch_* functions simply just modify/create these render nodes before the snapshot virtual function is called to render everything.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/20324

Commit Summary

  • 0e8738d use gtksnapshot for gtk4 gui

File Changes

(4 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20324@github.com>

Foxe Chen

unread,
May 24, 2026, 10:26:38 PM (3 hours ago) May 24
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 0660b67 use gtksnapshot for gtk4 gui


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20324/before/0e8738d6abe4b6e5536ecf3decf5288474086fc2/after/0660b673c68a29eaa453da5d1e8a76dc1d6d6375@github.com>

Foxe Chen

unread,
May 24, 2026, 11:33:39 PM (2 hours ago) May 24
to vim/vim, Push

@64-bitman pushed 2 commits.

  • 1066e3f refactor + optimize
  • af34ca8 implement gui_mch_delete/insert_lines


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20324/before/0660b673c68a29eaa453da5d1e8a76dc1d6d6375/after/af34ca8b61f6a87a8b68169b4b66a6649d54c757@github.com>

Foxe Chen

unread,
1:01 AM (1 hour ago) 1:01 AM
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#20324)

@mattn What is the minimum GTK4 version that Vim supports currently? I want to implement undercurls using GskPath, which is added from version 4.14 onwards. Thanks


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20324/c4531647759@github.com>

Foxe Chen

unread,
1:05 AM (1 hour ago) 1:05 AM
to vim/vim, Push

@64-bitman pushed 2 commits.

  • 3512c9a remove some cairo code
  • 82f1850 implement underlines and strikethrough


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20324/before/af34ca8b61f6a87a8b68169b4b66a6649d54c757/after/82f185082bc50a22e1914f9a6a04b4ddec474032@github.com>

Reply all
Reply to author
Forward
0 new messages