From: Mikhail Gusarov <dottedmag@dottedmag.net>
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 17 Aug 2009 01:41:07 +0000 (01:41 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 17 Aug 2009 01:41:07 +0000 (01:41 +0000)
Subject: [E-devel] [evas] Add RGBA -> grayscale 64 entries palette conversion

This is needed for E-Ink devices outta there. Names of new files,
configure.ac variables and macros are awful, suggestions are welcome.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@41825 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

configure.ac
src/lib/engines/common/Makefile.am
src/lib/engines/common/evas_convert_grypal_6.c [new file with mode: 0644]
src/lib/engines/common/evas_convert_grypal_6.h [new file with mode: 0644]
src/lib/engines/common/evas_convert_main.c

index 4389b49..c130d6b 100644 (file)
@@ -1072,6 +1072,27 @@ EVAS_CONVERT_ROT(32, RGB, 270)
 ## Convert to 32bpp RGB with rotation of 90
 EVAS_CONVERT_ROT(32, RGB, 90)
 
+#######################################
+## Convert to 8bpp grayscale, 64-palette
+conv_8_grayscale_64="yes"
+AC_MSG_CHECKING(whether to build 8bpp grayscale 64-palette converter code)
+AC_ARG_ENABLE(convert-8-grayscale-64,
+  AC_HELP_STRING([--disable-convert-8-grayscale-64], [disable 8bpp grayscale 64-palette converter code]),
+  [
+     if test "$enableval" = "xyes"; then
+       AC_DEFINE(BUILD_CONVERT_8_GRAYSCALE_64, 1, [8bpp Grayscale 64-palette Converter Support])
+       conv_8_grayscale_64="yes"
+     else
+       conv_8_grayscale_64="no"
+     fi
+  ], [
+     if test "x$conv_8_grayscale_64" = "xyes"; then
+       AC_DEFINE(BUILD_CONVERT_8_GRAYSCALE_64, 1, [32bpp Grayscale 64-palette Converter Support])
+     fi
+  ]
+)
+AC_MSG_RESULT($conv_8_grayscale_64)
+
 ## valgrind
 want_valgrind="no"
 have_valgrind="no"
@@ -1286,6 +1307,7 @@ echo "  8bpp RGB 222............: $conv_8_rgb_222"
 echo "  8bpp RGB 221............: $conv_8_rgb_221"
 echo "  8bpp RGB 121............: $conv_8_rgb_121"
 echo "  8bpp RGB 111............: $conv_8_rgb_111"
+echo "  8bpp Grayscale 64-pal...: $conv_8_grayscale_64"
 # FIXME: add grayscale and B&W support
 echo "  16bpp RGB 565...........: $conv_16_rgb_565"
 echo "  16bpp BGR 565...........: $conv_16_bgr_565"
index 4b998bc..75a358c 100644 (file)
@@ -35,6 +35,7 @@ evas_convert_rgb_16.c \
 evas_convert_rgb_24.c \
 evas_convert_rgb_32.c \
 evas_convert_rgb_8.c \
+evas_convert_grypal_6.c \
 evas_convert_yuv.c \
 evas_cpu.c \
 evas_draw_main.c \
@@ -78,6 +79,7 @@ evas_convert_colorspace.h \
 evas_convert_gry_1.h \
 evas_convert_gry_4.h \
 evas_convert_gry_8.h \
+evas_convert_grypal_6.h \
 evas_convert_main.h \
 evas_convert_rgb_16.h \
 evas_convert_rgb_24.h \
diff --git a/src/lib/engines/common/evas_convert_grypal_6.c b/src/lib/engines/common/evas_convert_grypal_6.c
new file mode 100644 (file)
index 0000000..64d3756
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+
+#include "evas_common.h"
+#include "evas_convert_grypal_6.h"
+
+#ifdef BUILD_CONVERT_8_GRAYSCALE_64
+void evas_common_convert_rgba_to_8bpp_pal_gray64       (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal)
+{
+    DATA32 *src_ptr;
+    DATA8 *dst_ptr;
+    int x, y;
+    DATA8 Y;
+
+    dst_ptr = dst;
+    CONVERT_LOOP_START_ROT_0();
+
+    /* RGB -> YUV conversion */
+    Y = ((R_VAL(src_ptr) * 76) + 
+         (G_VAL(src_ptr) * 151) + 
+         (B_VAL(src_ptr) * 29)) >> 10;
+    *dst_ptr = pal[Y];
+
+    CONVERT_LOOP_END_ROT_0();
+}
+#endif
diff --git a/src/lib/engines/common/evas_convert_grypal_6.h b/src/lib/engines/common/evas_convert_grypal_6.h
new file mode 100644 (file)
index 0000000..38ccda8
--- /dev/null
@@ -0,0 +1,10 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+
+#ifndef _EVAS_CONVERT_GRY_4_H
+#define _EVAS_CONVERT_GRY_4_H
+
+void evas_common_convert_rgba_to_8bpp_pal_gray64               (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal);
+
+#endif /* _EVAS_CONVERT_GRY_4_H */
index 6271464..6182667 100644 (file)
@@ -7,6 +7,7 @@
 #include "evas_convert_rgb_16.h"
 #include "evas_convert_rgb_24.h"
 #include "evas_convert_rgb_32.h"
+#include "evas_convert_grypal_6.h"
 #include "evas_convert_yuv.h"
 
 #ifdef USE_DITHER_44
@@ -193,6 +194,10 @@ evas_common_convert_func_get(DATA8 *dest, int w, int h, int depth, DATA32 rmask,
             if (pal_mode == PAL_MODE_RGB111)
               return evas_common_convert_rgba_to_8bpp_rgb_111_dith;
 #endif
+#ifdef BUILD_CONVERT_8_GRAYSCALE_64
+         if (pal_mode == PAL_MODE_GRAY64)
+            return evas_common_convert_rgba_to_8bpp_pal_gray64;
+#endif
          }
        if (depth == 1)
          {