]> asedeno.scripts.mit.edu Git - PuTTY.git/commit - unix/gtkask.c
Refactor the GTK drawing system to do both GDK and Cairo.
authorSimon Tatham <anakin@pobox.com>
Sat, 15 Aug 2015 20:05:56 +0000 (21:05 +0100)
committerSimon Tatham <anakin@pobox.com>
Sat, 15 Aug 2015 20:05:56 +0000 (21:05 +0100)
commitf750a185873eba65f0fbb95dce204b0941f3cc25
treeac353fea0c3424594ae6f079065cb05b68570c5f
parent0f60287f66c7a0586304709ae002249e092ef05e
Refactor the GTK drawing system to do both GDK and Cairo.

We're going to have to use Cairo in the GTK3 port, because that's all
GTK3 supports; but we still need old-style GDK for GTK1 support, and
also for performance reasons in GTK2 (see below). Hence, this change
completely restructures GTK PuTTY's drawing code so that there's a
central 'drawing context' structure which contains a type code
indicating GDK or Cairo, and then either some GDK gubbins or some
Cairo gubbins as appropriate; all actual drawing is abstracted through
a set of routines which test the type code in that structure and do
one thing or another. And because the type code is tested at run time,
both sets of drawing primitives can be compiled in at once, and where
possible, they will be.

X server-side bitmap fonts are still supported in the Cairo world, but
because Cairo drawing is entirely client-side, they have to work by
cheekily downloading each glyph bitmap from the server when it's first
needed, and building up a client-side cache of 'cairo_surface_t's
containing the bitmaps with which we then draw on the window. This
technique works, but it's rather slow; hence, even in GTK2, we keep
the GDK drawing back end compiled in, and switch over to it when the
main selected font is a bitmap one.

One visible effect of the new Cairo routines is in the double-width
and double-height text you can get by sending ESC # 3, ESC # 4 and
ESC # 6 escape sequences. In GDK, that's always been done by a really
horrible process of manually scaling the bitmap, server-side, column
by column and row by row, causing each pixel to be exactly doubled or
quadrupled. But in Cairo, we can just set a transformation matrix, and
then that takes effect _before_ the scalable fonts are rendered - so
the results are visibly nicer, and use all the available resolution.

(Sadly, if you're using a server-side bitmap font as your primary one,
then the GDK backend will be selected for all drawing in the terminal
as a whole - so in that situation, even fallback characters absent
from the primary font and rendered by Pango will get the old GDK
scaling treatment. It's only if your main font is scalable, so that
the Cairo backend is selected, that DW/DH characters will come out
looking nice.)
unix/gtkask.c
unix/gtkfont.c
unix/gtkfont.h
unix/gtkwin.c