[gnome-shell] shadow: Only use correctly sized textures for shortcut



commit 7015bb2ca97524def5ec5d7009dec35b2eeada7a
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Sep 22 15:18:11 2017 +0200

    shadow: Only use correctly sized textures for shortcut
    
    When creating a shadow for a ClutterTexture, we currently use the
    underlying CoglTexture directly instead of rendering the actor to
    an offscreen buffer. This assumes that the CoglTexture is directly
    suitable as shadow source, which isn't necessarily the case - it
    may have a very different size than what is shown and scaled up or
    down by the hardware. In that case we end up with a scaled shadow
    texture as well, which messes up the desired blur effect - the
    result will be too light when scaling up, or too sharp when scaling
    down. To fix this, only take the shortcut when a ClutterTexture's
    underlying texture has the correct size and fall back to offscreen
    rendering otherwise.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788039

 src/st/st-private.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/src/st/st-private.c b/src/st/st-private.c
index 0db257a..d625860 100644
--- a/src/st/st-private.c
+++ b/src/st/st-private.c
@@ -414,31 +414,34 @@ _st_create_shadow_pipeline_from_actor (StShadow     *shadow_spec,
                                        ClutterActor *actor)
 {
   CoglPipeline *shadow_pipeline = NULL;
+  ClutterActorBox box;
+  float width, height;
+
+  clutter_actor_get_allocation_box (actor, &box);
+  clutter_actor_box_get_size (&box, &width, &height);
+
+  if (width == 0 || height == 0)
+    return NULL;
 
   if (CLUTTER_IS_TEXTURE (actor))
     {
       CoglTexture *texture;
 
       texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (actor));
-      if (texture)
+      if (texture &&
+          cogl_texture_get_width (texture) == width &&
+          cogl_texture_get_height (texture) == height)
         shadow_pipeline = _st_create_shadow_pipeline (shadow_spec, texture);
     }
-  else
+
+  if (shadow_pipeline == NULL)
     {
       CoglTexture *buffer;
       CoglOffscreen *offscreen;
       CoglFramebuffer *fb;
-      ClutterActorBox box;
       CoglColor clear_color;
-      float width, height;
       CoglError *catch_error = NULL;
 
-      clutter_actor_get_allocation_box (actor, &box);
-      clutter_actor_box_get_size (&box, &width, &height);
-
-      if (width == 0 || height == 0)
-        return NULL;
-
       buffer = cogl_texture_new_with_size (width,
                                            height,
                                            COGL_TEXTURE_NO_SLICING,


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