[mutter] Turn off background repeats for a full-size image



commit 6260814285faf4b9a943763353b53e64eb41ac11
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Nov 15 16:19:28 2010 -0500

    Turn off background repeats for a full-size image
    
    If we have repeats on for a full-sized image, then if the background
    is displayed scaled (for example, in a desktop preview mode) then we
    can get artifacts along the edge of the background where the repeat
    of the opposite edge is blended in by bilinear scaling. So turn off
    repeats when the screen and background image sizes match.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=634833

 src/compositor/compositor.c            |    4 +-
 src/compositor/meta-background-actor.c |   34 ++++++++++++++++++++++++++++++++
 src/compositor/meta-background-actor.h |    7 +++--
 3 files changed, 40 insertions(+), 5 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 4b848b4..058114b 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -1081,8 +1081,8 @@ meta_compositor_sync_screen_size (MetaCompositor  *compositor,
   g_return_if_fail (info);
 
   clutter_actor_set_size (info->stage, width, height);
-  /* Background actor always requests the screen size */
-  clutter_actor_queue_relayout (info->background_actor);
+
+  meta_background_actor_screen_size_changed (META_BACKGROUND_ACTOR (info->background_actor));
 
   meta_verbose ("Changed size for stage on screen %d to %dx%d\n",
 		meta_screen_get_screen_number (screen),
diff --git a/src/compositor/meta-background-actor.c b/src/compositor/meta-background-actor.c
index af86778..d26fa8a 100644
--- a/src/compositor/meta-background-actor.c
+++ b/src/compositor/meta-background-actor.c
@@ -56,6 +56,26 @@ struct _MetaBackgroundActor
 G_DEFINE_TYPE (MetaBackgroundActor, meta_background_actor, CLUTTER_TYPE_ACTOR);
 
 static void
+update_wrap_mode (MetaBackgroundActor *self)
+{
+  int width, height;
+  CoglMaterialWrapMode wrap_mode;
+
+  meta_screen_get_size (self->screen, &width, &height);
+
+  /* We turn off repeating when we have a full-screen pixmap to keep from
+   * getting artifacts from one side of the image sneaking into the other
+   * side of the image via bilinear filtering.
+   */
+  if (width == self->texture_width && height == self->texture_height)
+    wrap_mode = COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE;
+  else
+    wrap_mode = COGL_PIPELINE_WRAP_MODE_REPEAT;
+
+  cogl_material_set_layer_wrap_mode (self->material, 0, wrap_mode);
+}
+
+static void
 set_texture (MetaBackgroundActor *self,
              CoglHandle           texture)
 {
@@ -73,6 +93,8 @@ set_texture (MetaBackgroundActor *self,
   self->texture_width = cogl_texture_get_width (texture);
   self->texture_height = cogl_texture_get_height (texture);
 
+  update_wrap_mode (self);
+
   clutter_actor_queue_redraw (CLUTTER_ACTOR (self));
 }
 
@@ -378,3 +400,15 @@ meta_background_actor_set_visible_region (MetaBackgroundActor *self,
     }
 }
 
+/**
+ * meta_background_actor_screen_size_changed:
+ * @self: a #MetaBackgroundActor
+ *
+ * Called by the compositor when the size of the #MetaScreen changes
+ */
+void
+meta_background_actor_screen_size_changed (MetaBackgroundActor *self)
+{
+  update_wrap_mode (self);
+  clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
+}
diff --git a/src/compositor/meta-background-actor.h b/src/compositor/meta-background-actor.h
index b211c4b..448171a 100644
--- a/src/compositor/meta-background-actor.h
+++ b/src/compositor/meta-background-actor.h
@@ -50,8 +50,9 @@ GType meta_background_actor_get_type (void);
 
 ClutterActor *meta_background_actor_new (MetaScreen *screen);
 
-void meta_background_actor_update             (MetaBackgroundActor *actor);
-void meta_background_actor_set_visible_region (MetaBackgroundActor *self,
-                                               cairo_region_t      *visible_region);
+void meta_background_actor_update              (MetaBackgroundActor *actor);
+void meta_background_actor_set_visible_region  (MetaBackgroundActor *self,
+                                                cairo_region_t      *visible_region);
+void meta_background_actor_screen_size_changed (MetaBackgroundActor *self);
 
 #endif /* META_BACKGROUND_ACTOR_H */



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