2b1208f
From 72ec20e48f085af729c5b0afdd78d259694a052a Mon Sep 17 00:00:00 2001
2b1208f
From: Adel Gadllah <adel.gadllah@gmail.com>
2b1208f
Date: Thu, 24 Jul 2014 15:39:26 +0200
2b1208f
Subject: [PATCH] background: Do not assume GLSL is available
2b1208f
2b1208f
Some hardware does not support it causing crashes in cogl during paint.
2b1208f
2b1208f
https://bugzilla.gnome.org/show_bug.cgi?id=733623
2b1208f
---
2b1208f
 src/compositor/meta-background.c | 17 ++++++++++++++++-
2b1208f
 1 file changed, 16 insertions(+), 1 deletion(-)
2b1208f
2b1208f
diff --git a/src/compositor/meta-background.c b/src/compositor/meta-background.c
2b1208f
index 6eee159..ae6f459 100644
2b1208f
--- a/src/compositor/meta-background.c
2b1208f
+++ b/src/compositor/meta-background.c
2b1208f
@@ -501,7 +501,8 @@ set_brightness (MetaBackground *self,
2b1208f
 
2b1208f
   priv->brightness = brightness;
2b1208f
 
2b1208f
-  if (priv->effects & META_BACKGROUND_EFFECTS_VIGNETTE)
2b1208f
+  if (clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL) &&
2b1208f
+      priv->effects & META_BACKGROUND_EFFECTS_VIGNETTE)
2b1208f
     {
2b1208f
       ensure_pipeline (self);
2b1208f
       cogl_pipeline_set_uniform_1f (priv->pipeline,
2b1208f
@@ -509,6 +510,14 @@ set_brightness (MetaBackground *self,
2b1208f
                                                                         "brightness"),
2b1208f
                                     priv->brightness);
2b1208f
     }
2b1208f
+  else
2b1208f
+    {
2b1208f
+      ensure_pipeline (self);
2b1208f
+      CoglColor blend_color;
2b1208f
+      cogl_color_init_from_4f (&blend_color, brightness, brightness, brightness, 1.0);
2b1208f
+      cogl_pipeline_set_layer_combine (priv->pipeline, 1, "RGB=MODULATE(PREVIOUS, CONSTANT) A=REPLACE(PREVIOUS)", NULL);
2b1208f
+      cogl_pipeline_set_layer_combine_constant (priv->pipeline, 1, &blend_color);
2b1208f
+    }
2b1208f
 
2b1208f
   clutter_content_invalidate (CLUTTER_CONTENT (self));
2b1208f
 
2b1208f
@@ -526,6 +535,9 @@ set_vignette_sharpness (MetaBackground *self,
2b1208f
 
2b1208f
   priv->vignette_sharpness = sharpness;
2b1208f
 
2b1208f
+  if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
2b1208f
+    return;
2b1208f
+
2b1208f
   if (priv->effects & META_BACKGROUND_EFFECTS_VIGNETTE)
2b1208f
     {
2b1208f
       ensure_pipeline (self);
2b1208f
@@ -546,6 +558,9 @@ add_vignette (MetaBackground *self)
2b1208f
   MetaBackgroundPrivate *priv = self->priv;
2b1208f
   static CoglSnippet *snippet = NULL;
2b1208f
 
2b1208f
+  if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
2b1208f
+    return;
2b1208f
+
2b1208f
   ensure_pipeline (self);
2b1208f
 
2b1208f
   /* Cogl automatically caches pipelines with no eviction policy,
2b1208f
-- 
2b1208f
1.9.3
2b1208f