[gtk/issue-2226] Ensure that cached surface sizes are 1x1



commit 8d0138bd6bb7cef550fb15e578e3c6910012cf0e
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sat Nov 16 18:51:29 2019 +0000

    Ensure that cached surface sizes are 1x1
    
    We cannot create similar surfaces that are smaller than 1x1 on X11, so
    we should always ensure that we clamp the surface size to 1x1 when
    calling gdk_window_create_similar_surface().
    
    Fixes: #2226

 gtk/gtkpixelcache.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkpixelcache.c b/gtk/gtkpixelcache.c
index ffed591ca5..a56835d0e4 100644
--- a/gtk/gtkpixelcache.c
+++ b/gtk/gtkpixelcache.c
@@ -229,17 +229,18 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache         *cache,
     {
       cache->surface_x = -canvas_rect->x;
       cache->surface_y = -canvas_rect->y;
-      cache->surface_w = surface_w;
-      cache->surface_h = surface_h;
+      cache->surface_w = MAX (surface_w, 1);
+      cache->surface_h = MAX (surface_h, 1);
       cache->surface_scale = gdk_window_get_scale_factor (window);
 
       cache->surface =
         gdk_window_create_similar_surface (window, content,
-                                           surface_w, surface_h);
+                                           cache->surface_w,
+                                           cache->surface_h);
       rect.x = 0;
       rect.y = 0;
-      rect.width = surface_w;
-      rect.height = surface_h;
+      rect.width = cache->surface_w;
+      rect.height = cache->surface_h;
       cache->surface_dirty =
         cairo_region_create_rectangle (&rect);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]