[babl] cairo: slight improvements to speed and accuracy



commit d30a2b557ecac6f3625e86c3ec6945c6d72a4a72
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Nov 16 23:19:46 2016 +0100

    cairo: slight improvements to speed and accuracy

 extensions/cairo.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/extensions/cairo.c b/extensions/cairo.c
index 4e13337..7ebf333 100644
--- a/extensions/cairo.c
+++ b/extensions/cairo.c
@@ -99,9 +99,9 @@ static void init_table(void)
   if (done) return;
   done = 1;
 
-  for (index = 0; index < 65536 * 1; index++)
+  for (index = 0; index < 65536; index++)
   {
-    float value = index / (65535 * 1.0);
+    float value = index / 65535.5;
     linear_to_gamma[index] = babl_linear_to_gamma_2_2 (value) * 65536;
   }
 }
@@ -114,7 +114,7 @@ conv_rgbafloat_cairo32_map (float value)
     return 0x00;
   if (value >= 1.0)
     return 0xFF;
-  index = (unsigned int)(value * 65535);
+  index = (unsigned int)(value * 65535.5);
   return linear_to_gamma[index] / 257 + 0.5f;
 }
 
@@ -127,7 +127,7 @@ conv_rgbafloat_cairo32_map_a (float value,
     return 0x00;
   if (value >= 1.0)
     return 0xFF;
-  index = (unsigned int)(value * 65535);
+  index = (unsigned int)(value * 65535.5);
   return linear_to_gamma[index] * alpha / 257 + 0.5f;
 }
 
@@ -163,7 +163,6 @@ conv_rgbafloat_cairo32_le (unsigned char *src_char,
               dst[3] = src[3] * 0xFF + 0.5f;
             }
         }
-
       src += 4;
       dst += 4;
     }


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