GNOME Bugzilla – Bug 741060
[PATCH] Graphical artifacts drawn on Win32 since 4ecbef0791d4
Last modified: 2015-02-17 20:01:07 UTC
Created attachment 292060 [details] [review] Replace create_cairo_surface() with ref_cairo_surface() As already noted in comments on bug #695636, very noticeable graphical artifacts have been showing up on Win32 (particularly in the file chooser) since commit 4ecbef0791d4. That commit made _gdk_windowing_create_cairo_surface() correctly return a new cairo_surface_t on Win32 as it does on X11, rather than just calling _gdk_windowing_ref_cairo_surface(). However, it looks like the call to _gdk_windowing_create_cairo_surface() in gdk_window_begin_paint_region() now needs to be changed to _gdk_windowing_ref_cairo_surface() in order for rendering to work correctly on Win32. Someone with more knowledge of the code should decide whether this is the right fix or not, but it does fix the graphical artifacts.
I agree, there should be no need to create multiple surface instances for the same offscreen bitmap during expose handling. Reusing the same one should be more efficient even. And i can understand cairo being confused with multiple cairo surfaces refering to the same HDC and rendering to them. Some state is probably left from an earlier rendering that the later surface is not expecting. In fact, i wonder if the same problem does not happen for the remaining use of _gdk_drawable_create_cairo_surface() in gdk_window_ref_cairo_surface(). This one is hit a bit less often (only for non-double-buffered rendering). That one needs a different surface object in order to have a different offset for each child window (of the same native window), but that could maybe be better done via cairo_surface_create_for_rectangle() subsurfaces rather than multiple surfaces based on the same hdc.
I pushed this as ad6271eca90e6139acd624209e10931d0dffbd73, as it seems correct, better and fixes a win32 issue. I'll leave the other change for now as it seems much more intrusive while fixing a much less obvious issue which we are probably not even hitting atm.
*** Bug 744169 has been marked as a duplicate of this bug. ***