From 1102736013ac02280043c5ee7bc02b5b493dfb08 Mon Sep 17 00:00:00 2001
From: Hans Petter Jansson <hpj@cl.no>
Date: Thu, 10 Oct 2013 02:38:52 +0200
Subject: [PATCH] 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
Conflicts:
src/compositor/meta-shaped-texture.c
---
src/compositor/meta-shaped-texture.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index c6239c9..9cb709d 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -30,6 +30,7 @@
#include <config.h>
#include <meta/meta-shaped-texture.h>
+#include "clutter-utils.h"
#include "meta-texture-tower.h"
#include <clutter/clutter.h>
@@ -141,6 +142,7 @@ meta_shaped_texture_paint (ClutterActor *actor)
static CoglPipeline *pipeline_unshaped_template = NULL;
CoglPipeline *pipeline;
+ CoglPipelineFilter filter;
if (priv->clip_region && cairo_region_is_empty (priv->clip_region))
return;
@@ -177,6 +179,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;
+ }
+
if (priv->mask_texture == NULL)
{
/* Use a single-layer texture if we don't have a mask. */
@@ -210,9 +228,11 @@ meta_shaped_texture_paint (ClutterActor *actor)
pipeline = priv->pipeline;
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;
--
1.8.3.1