simon-git: putty (main): Ben Harris

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Wed May 7 00:08:12 BST 2025


TL;DR:
  19353dca GTK: faster rendering of X fonts under Cairo
  649c8155 GTK: use a persistent pixmap for rendering X fonts under Cairo
  b66ec0c2 GTK/x11font/Cairo: use XDrawString16 instead of XDrawImageString16

Repository:     https://git.tartarus.org/simon/putty.git
On the web:     https://git.tartarus.org/?p=simon/putty.git
Branch updated: main
Committer:      Ben Harris <bjh21 at bjh21.me.uk>
Date:           2025-05-07 00:08:12

commit 19353dca858fb76b399a173d8a96f122b62786ca
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=19353dca858fb76b399a173d8a96f122b62786ca;hp=a0a92da03547f321b0b293219446f4bebb7d778b
Author: Ben Harris <bjh21 at bjh21.me.uk>
Date:   Mon May 5 23:02:18 2025 +0100

    GTK: faster rendering of X fonts under Cairo
    
    Switching to server-side rendering of X fonts under Cairo turned out to
    make text rendering much slower, at least on my laptop.  This appears to
    be because PuTTY was asking the X server to render text into a
    1-bit-per-pixel (bpp) pixmap before having Cairo composite into the
    terminal surface.  On modern X servers 1bpp pixmaps are slow, being
    largely un-accelerated.
    
    Happily, it is possible to get Cairo to use an 8bpp pixmap instead, and
    this is rather faster.  It's a bit inconvenient, though, because first
    we have to confirm that that the X Rendering Extensions is present and
    find the correct picture format.  That requires linking in libXrender,
    which means a bit of CMake faff.  For now, I've make libXrender
    mandatory (for X11 builds), but it and the corresponding Cairo functions
    could be made optional fairly simply.
    
    This hasn't actually made text rendering as much faster as I'd like on
    my laptop.  While creating 1bpp pixmaps is nearly free, creating 8bpp
    pixmaps takes significant time because they actually involve the GPU.
    So I think now I need to rework my persistent-pixmap patch to work on
    top of this one.

 cmake/platforms/unix.cmake |  2 +-
 unix/CMakeLists.txt        | 10 +++++-----
 unix/unifont.c             | 48 ++++++++++++++++++++++++++++++++++++++--------
 3 files changed, 46 insertions(+), 14 deletions(-)

commit 649c8155e78a63a2ed5aa9d878c748ce19bc9451
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=649c8155e78a63a2ed5aa9d878c748ce19bc9451;hp=19353dca858fb76b399a173d8a96f122b62786ca
Author: Ben Harris <bjh21 at bjh21.me.uk>
Date:   Tue May 6 21:08:00 2025 +0100

    GTK: use a persistent pixmap for rendering X fonts under Cairo
    
    Instead of creating a new pixmap for each text-rendering operation, we
    now stash one (along with the various Cairo structures associated with
    it) in the xfont_individual structure.  This saves the 20% or so of
    Xwayland's CPU time that was being spent on CreatePixmap requests.

 unix/unifont.c | 146 +++++++++++++++++++++++++++++++++------------------------
 1 file changed, 86 insertions(+), 60 deletions(-)

commit b66ec0c25751f432745448333d95727391092f2a
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=b66ec0c25751f432745448333d95727391092f2a;hp=649c8155e78a63a2ed5aa9d878c748ce19bc9451
Author: Ben Harris <bjh21 at bjh21.me.uk>
Date:   Tue May 6 22:17:45 2025 +0100

    GTK/x11font/Cairo: use XDrawString16 instead of XDrawImageString16
    
    On my test case, this reduces Xwayland's CPU usage by 5-10%, though
    curiously in glamor_block_handler rather than the drawing routine
    itself.
    
    XDrawImageString16 isn't as helpful as it might be for two reasons.
    First, "M" type fonts (e.g. Courier Oblique) can extend beyond the
    rectangle erased by XDrawImageString16, and PuTTY tries to support such
    fonts.  And second, we really want to blank the pixmap after drawing
    rather than before, because otherwise we have to muck around clipping
    the mask operation.  So avoinding the XFillRectangle calls is difficult,
    at which point we may as well use XDrawString16.

 unix/unifont.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)



More information about the tartarus-commits mailing list