[cairo] [patch] gl: use fabs value for color difference

Henry (Yu) Song - SISA hsong at sisa.samsung.com
Thu Jul 26 10:22:20 PDT 2012


>From eaba158af31cbf17d7c0ab079e59f606edcc86d0 Mon Sep 17 00:00:00 2001
From: Henry Song <henry.song at samsung.com>
Date: Thu, 26 Jul 2012 10:14:41 -0700
Subject: [PATCH] gl: use absolute difference value in computing gradient
 sample width

---
 src/cairo-gl-gradient.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c
index a66f26d..c52b895 100644
--- a/src/cairo-gl-gradient.c
+++ b/src/cairo-gl-gradient.c
@@ -63,17 +63,17 @@ _cairo_gl_gradient_sample_width (unsigned int                 n_stops,
 	if (dx == 0)
 	    dx = 0.01;
 
-	max = stops[n].color.red - stops[n-1].color.red;
+	max = fabs (stops[n].color.red - stops[n-1].color.red);
 
-	delta = stops[n].color.green - stops[n-1].color.green;
+	delta = fabs (stops[n].color.green - stops[n-1].color.green);
 	if (delta > max)
 	    max = delta;
 
-	delta = stops[n].color.blue - stops[n-1].color.blue;
+	delta = fabs (stops[n].color.blue - stops[n-1].color.blue);
 	if (delta > max)
 	    max = delta;
 
-	delta = stops[n].color.alpha - stops[n-1].color.alpha;
+	delta = fabs (stops[n].color.alpha - stops[n-1].color.alpha);
 	if (delta > max)
 	    max = delta;
 
-- 
1.7.9.5


More information about the cairo mailing list