[gtk+] cssvalue: Special case resulting color for transparency



commit 142abce46a18ef09ca77ed581cf3b385671c9515
Author: Benjamin Otte <otte redhat com>
Date:   Fri Jun 26 20:53:39 2015 +0200

    cssvalue: Special case resulting color for transparency
    
    Again, preparation for using premultiplied color transitions.

 gtk/gtkcssrgbavalue.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssrgbavalue.c b/gtk/gtkcssrgbavalue.c
index ee73a45..0b66f8a 100644
--- a/gtk/gtkcssrgbavalue.c
+++ b/gtk/gtkcssrgbavalue.c
@@ -68,9 +68,16 @@ gtk_css_value_rgba_transition (GtkCssValue *start,
 
   progress = CLAMP (progress, 0, 1);
   result.alpha = transition (start->rgba.alpha, end->rgba.alpha, progress);
-  result.red = transition (start->rgba.red, end->rgba.red, progress);
-  result.green = transition (start->rgba.green, end->rgba.green, progress);
-  result.blue = transition (start->rgba.blue, end->rgba.blue, progress);
+  if (result.alpha <= 0.0)
+    {
+      result.red = result.green = result.blue = 0.0;
+    }
+  else
+    {
+      result.red = transition (start->rgba.red, end->rgba.red, progress);
+      result.green = transition (start->rgba.green, end->rgba.green, progress);
+      result.blue = transition (start->rgba.blue, end->rgba.blue, progress);
+    }
 
   return _gtk_css_rgba_value_new_from_rgba (&result);
 }


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