[mutter/wip/rstrode/rhel-8.0.0: 68/117] shaped-texture: Don't change the callers clip rect



commit 1fe3adcd951b7207be93bfbc3c0636e935688a1b
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Dec 20 17:32:27 2018 +0100

    shaped-texture: Don't change the callers clip rect
    
    We intersected the callers clip rect. That is probably not a good idea,
    and easily avoided, so lets avoid it.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/362

 src/compositor/meta-shaped-texture.c | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 0fa5fa92f..823bd47f2 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -925,6 +925,7 @@ meta_shaped_texture_get_image (MetaShapedTexture     *stex,
                                cairo_rectangle_int_t *clip)
 {
   MetaShapedTexturePrivate *priv = stex->priv;
+  cairo_rectangle_int_t *transformed_clip = NULL;
   CoglTexture *texture, *mask_texture;
   cairo_rectangle_int_t texture_rect = { 0, 0, 0, 0 };
   cairo_surface_t *surface;
@@ -936,21 +937,23 @@ meta_shaped_texture_get_image (MetaShapedTexture     *stex,
   if (texture == NULL)
     return NULL;
 
-  texture_rect.width = cogl_texture_get_width (texture);
-  texture_rect.height = cogl_texture_get_height (texture);
 
   if (clip != NULL)
     {
-      if (!meta_rectangle_intersect (&texture_rect, clip, clip))
+      transformed_clip = alloca (sizeof (cairo_rectangle_int_t));
+      *transformed_clip = *clip;
+
+      if (!meta_rectangle_intersect (&texture_rect, transformed_clip,
+                                     transformed_clip))
         return NULL;
     }
 
-  if (clip != NULL)
+  if (transformed_clip)
     texture = cogl_texture_new_from_sub_texture (texture,
-                                                 clip->x,
-                                                 clip->y,
-                                                 clip->width,
-                                                 clip->height);
+                                                 transformed_clip->x,
+                                                 transformed_clip->y,
+                                                 transformed_clip->width,
+                                                 transformed_clip->height);
 
   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                                         cogl_texture_get_width (texture),
@@ -962,7 +965,7 @@ meta_shaped_texture_get_image (MetaShapedTexture     *stex,
 
   cairo_surface_mark_dirty (surface);
 
-  if (clip != NULL)
+  if (transformed_clip)
     cogl_object_unref (texture);
 
   mask_texture = priv->mask_texture;
@@ -971,12 +974,13 @@ meta_shaped_texture_get_image (MetaShapedTexture     *stex,
       cairo_t *cr;
       cairo_surface_t *mask_surface;
 
-      if (clip != NULL)
-        mask_texture = cogl_texture_new_from_sub_texture (mask_texture,
-                                                          clip->x,
-                                                          clip->y,
-                                                          clip->width,
-                                                          clip->height);
+      if (transformed_clip)
+        mask_texture =
+          cogl_texture_new_from_sub_texture (mask_texture,
+                                             transformed_clip->x,
+                                             transformed_clip->y,
+                                             transformed_clip->width,
+                                             transformed_clip->height);
 
       mask_surface = cairo_image_surface_create (CAIRO_FORMAT_A8,
                                                  cogl_texture_get_width (mask_texture),
@@ -996,7 +1000,7 @@ meta_shaped_texture_get_image (MetaShapedTexture     *stex,
 
       cairo_surface_destroy (mask_surface);
 
-      if (clip != NULL)
+      if (transformed_clip)
         cogl_object_unref (mask_texture);
     }
 


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