[gtk+] cssvalue: Restructure RGBA transitions



commit e3d8f03b3a69c0b1e1dea653ffeca34092be6ce8
Author: Benjamin Otte <otte redhat com>
Date:   Fri Jun 26 19:06:02 2015 +0200

    cssvalue: Restructure RGBA transitions
    
    Split out a function to make the code clearer for the changes ahead.

 gtk/gtkcssrgbavalue.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcssrgbavalue.c b/gtk/gtkcssrgbavalue.c
index 3caa647..ee73a45 100644
--- a/gtk/gtkcssrgbavalue.c
+++ b/gtk/gtkcssrgbavalue.c
@@ -50,21 +50,29 @@ gtk_css_value_rgba_equal (const GtkCssValue *rgba1,
   return gdk_rgba_equal (&rgba1->rgba, &rgba2->rgba);
 }
 
+static inline double
+transition (double start,
+            double end,
+            double progress)
+{
+  return start + (end - start) * progress;
+}
+
 static GtkCssValue *
 gtk_css_value_rgba_transition (GtkCssValue *start,
                                GtkCssValue *end,
                                guint        property_id,
                                double       progress)
 {
-  GdkRGBA transition;
+  GdkRGBA result;
 
   progress = CLAMP (progress, 0, 1);
-  transition.red = start->rgba.red + (end->rgba.red - start->rgba.red) * progress;
-  transition.green = start->rgba.green + (end->rgba.green - start->rgba.green) * progress;
-  transition.blue = start->rgba.blue + (end->rgba.blue - start->rgba.blue) * progress;
-  transition.alpha = start->rgba.alpha + (end->rgba.alpha - start->rgba.alpha) * progress;
+  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);
 
-  return _gtk_css_rgba_value_new_from_rgba (&transition);
+  return _gtk_css_rgba_value_new_from_rgba (&result);
 }
 
 static void


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