[mutter] background: Don't render with blending when we don't need to
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] background: Don't render with blending when we don't need to
- Date: Thu, 7 Aug 2014 18:02:23 +0000 (UTC)
commit 2d6954186ed621deeb4c7cb575501861272b99d6
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Aug 7 12:38:42 2014 -0400
background: Don't render with blending when we don't need to
If we have an opaque background image, then we shouldn't need to blend
against anything for it to work. Turn off blending in this case.
src/compositor/meta-background.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/compositor/meta-background.c b/src/compositor/meta-background.c
index 634a2de..22b3b89 100644
--- a/src/compositor/meta-background.c
+++ b/src/compositor/meta-background.c
@@ -288,6 +288,26 @@ get_wrap_mode (MetaBackground *self)
}
}
+static gboolean
+texture_has_alpha (CoglTexture *texture)
+{
+ if (!texture)
+ return FALSE;
+
+ switch (cogl_texture_get_components (texture))
+ {
+ case COGL_TEXTURE_COMPONENTS_A:
+ case COGL_TEXTURE_COMPONENTS_RGBA:
+ return TRUE;
+ case COGL_TEXTURE_COMPONENTS_RG:
+ case COGL_TEXTURE_COMPONENTS_RGB:
+ case COGL_TEXTURE_COMPONENTS_DEPTH:
+ return FALSE;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
static ClutterPaintNode *
meta_background_paint_node_new (MetaBackground *self,
ClutterActor *actor)
@@ -296,6 +316,7 @@ meta_background_paint_node_new (MetaBackground *self,
ClutterPaintNode *node;
guint8 opacity;
guint8 color_component;
+ gboolean needs_blending;
opacity = clutter_actor_get_paint_opacity (actor);
color_component = (guint8) (0.5 + opacity * priv->brightness);
@@ -308,6 +329,13 @@ meta_background_paint_node_new (MetaBackground *self,
node = clutter_pipeline_node_new (priv->pipeline);
+ needs_blending = (opacity < 255) || (texture_has_alpha (priv->texture));
+
+ if (needs_blending)
+ cogl_pipeline_set_blend (priv->pipeline, "RGBA = ADD (SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))", NULL);
+ else
+ cogl_pipeline_set_blend (priv->pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL);
+
return node;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]