ector: correct implementation for color multiplication.
authorJose Gonzalez <jose_ogp@juno.com>
Fri, 3 Apr 2015 14:33:01 +0000 (16:33 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Fri, 3 Apr 2015 14:33:01 +0000 (16:33 +0200)
src/Makefile_Ector.am
src/lib/ector/Ector.h
src/lib/ector/ector_util.h [new file with mode: 0644]

index 11ed70c..fd0810f 100644 (file)
@@ -40,6 +40,7 @@ lib_LTLIBRARIES += lib/ector/libector.la
 installed_ectormainheadersdir = $(includedir)/ector-@VMAJ@
 dist_installed_ectormainheaders_DATA = \
 lib/ector/Ector.h \
+lib/ector/ector_util.h \
 lib/ector/cairo/Ector_Cairo.h \
 lib/ector/software/Ector_Software.h
 
index fe8d13c..0a53fac 100644 (file)
@@ -174,6 +174,7 @@ EAPI int ector_shutdown(void);
 
 #include "ector_surface.h"
 #include "ector_renderer.h"
+#include "ector_util.h"
 
 #endif
 
diff --git a/src/lib/ector/ector_util.h b/src/lib/ector/ector_util.h
new file mode 100644 (file)
index 0000000..664fdb2
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef ECTOR_UTIL_H
+# define ECTOR_UTIL_H
+
+static inline unsigned int
+ector_color_multiply(unsigned int c1, unsigned int c2)
+{
+   return ( ((((((c1) >> 16) & 0xff00) * (((c2) >> 16) & 0xff00)) + 0xff0000) & 0xff000000) +
+            ((((((c1) >> 8) & 0xff00) * (((c2) >> 16) & 0xff)) + 0xff00) & 0xff0000) +
+            ((((((c1) & 0xff00) * ((c2) & 0xff00)) + 0xff00) >> 16) & 0xff00) +
+            (((((c1) & 0xff) * ((c2) & 0xff)) + 0xff) >> 8) );
+}
+
+#endif