WIP: gdkwindow reuse cairo_surface_t for performance gain (GTK 3.24)
Using a profiler on macOS, I found that 20% of overall execution time is spent within gdk_window_create_similar_surface when running VICE x64sc (using Gtk3 GtkGLArea). On my machine, x64sc with vanilla gtk-3-24 branch hovers around 70-75% of a host CPU core.
This patch caches and reuses the result from gdk_window_create_similar_surface when the requested surface is of the same size, and same display and rendering mode as the previous one for that window. The result is that x64sc now hovers within 50-55% of a host CPU core.
I expect that this change would also benefit any other platforms where the creation of cairo surfaces is expensive. Possibly only for OpenGL applications - it's not clear to me if other cases exist where gdk_window_begin_paint_internal () will create a similar surface.
I would like advice on whether verifying that the display hasn't changed, and verifying that the rendering mode hasn't changed, are necessary and sufficient checks for reusing the previously created surface. I have tested not checking these things and dragging our application between a high DPI macOS screen and a regular DPI screen, and it seems to work fine without these checks. It is of course required that the size of the surface be checked to allow the application to be resized.