[mutter/wayland] shaped-texture: Use nearest-pixel interpolation if the texture is unscaled



commit dc4e1d4cd12a11fe7612c8914f6eb508ae445c46
Author: Hans Petter Jansson <hpj cl no>
Date:   Thu Oct 10 02:38:52 2013 +0200

    shaped-texture: Use nearest-pixel interpolation if the texture is unscaled
    
    Use nearest-pixel interpolation if the texture is unscaled. This
    improves performance, especially with software rendering.
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=708389

 src/compositor/meta-shaped-texture.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index e4b8c82..552bdbb 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -31,6 +31,7 @@
 
 #include <meta/meta-shaped-texture.h>
 #include <meta/util.h>
+#include "clutter-utils.h"
 #include "meta-texture-tower.h"
 
 #include "meta-shaped-texture-private.h"
@@ -280,6 +281,7 @@ meta_shaped_texture_paint (ClutterActor *actor)
   CoglTexture *paint_tex;
   ClutterActorBox alloc;
   cairo_region_t *blended_region = NULL;
+  CoglPipelineFilter filter;
 
   if (priv->clip_region && cairo_region_is_empty (priv->clip_region))
     return;
@@ -316,6 +318,22 @@ meta_shaped_texture_paint (ClutterActor *actor)
   if (tex_width == 0 || tex_height == 0) /* no contents yet */
     return;
 
+  /* Use nearest-pixel interpolation if the texture is unscaled. This
+   * improves performance, especially with software rendering.
+   */
+
+  filter = COGL_PIPELINE_FILTER_LINEAR;
+
+  if (!clutter_actor_is_in_clone_paint (actor))
+    {
+      int x_origin, y_origin;
+
+      if (meta_actor_is_untransformed (actor,
+                                       &x_origin,
+                                       &y_origin))
+        filter = COGL_PIPELINE_FILTER_NEAREST;
+    }
+
   ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
   fb = cogl_get_draw_framebuffer ();
 
@@ -344,6 +362,7 @@ meta_shaped_texture_paint (ClutterActor *actor)
 
       opaque_pipeline = get_unblended_pipeline (ctx);
       cogl_pipeline_set_layer_texture (opaque_pipeline, 0, paint_tex);
+      cogl_pipeline_set_layer_filters (opaque_pipeline, 0, filter, filter);
 
       n_rects = cairo_region_num_rectangles (region);
       for (i = 0; i < n_rects; i++)
@@ -385,9 +404,11 @@ meta_shaped_texture_paint (ClutterActor *actor)
     {
       pipeline = get_masked_pipeline (ctx);
       cogl_pipeline_set_layer_texture (pipeline, 1, priv->mask_texture);
+      cogl_pipeline_set_layer_filters (pipeline, 1, filter, filter);
     }
 
   cogl_pipeline_set_layer_texture (pipeline, 0, paint_tex);
+  cogl_pipeline_set_layer_filters (pipeline, 0, filter, filter);
 
   {
     CoglColor color;


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