1 #include "evas_common_private.h"
2 #include "evas_convert_gry_8.h"
3 
4 #ifdef USE_DITHER_44
5 extern const DATA8 _evas_dither_44[4][4];
6 #endif
7 #ifdef USE_DITHER_128128
8 extern const DATA8 _evas_dither_128128[128][128];
9 #endif
10 
evas_common_convert_rgba_to_8bpp_gry_256_dith(DATA32 * src,DATA8 * dst,int src_jump,int dst_jump,int w,int h,int dith_x EINA_UNUSED,int dith_y EINA_UNUSED,DATA8 * pal EINA_UNUSED)11 void evas_common_convert_rgba_to_8bpp_gry_256_dith     (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
12 {
13    DATA32 *src_ptr;
14    DATA8 *dst_ptr;
15    int x, y;
16    DATA8 r, g, b;
17    DATA32 gry8;
18 
19    dst_ptr = (DATA8 *)dst;
20 
21    CONVERT_LOOP_START_ROT_0();
22 
23    r = (R_VAL(src_ptr));
24    g = (G_VAL(src_ptr));
25    b = (B_VAL(src_ptr));
26 
27    // Y = 0.299 * R + 0.587 * G + 0.114 * B;
28    gry8 = ((r * 19596) + (g * 38470) + (b * 7472)) >> 16;
29 
30    *dst_ptr = gry8;
31 
32    CONVERT_LOOP_END_ROT_0();
33 }
34 
evas_common_convert_rgba_to_8bpp_gry_64_dith(DATA32 * src EINA_UNUSED,DATA8 * dst EINA_UNUSED,int src_jump EINA_UNUSED,int dst_jump EINA_UNUSED,int w EINA_UNUSED,int h EINA_UNUSED,int dith_x EINA_UNUSED,int dith_y EINA_UNUSED,DATA8 * pal EINA_UNUSED)35 void evas_common_convert_rgba_to_8bpp_gry_64_dith      (DATA32 *src EINA_UNUSED, DATA8 *dst EINA_UNUSED, int src_jump EINA_UNUSED, int dst_jump EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED){}
36 
evas_common_convert_rgba_to_8bpp_gry_16_dith(DATA32 * src,DATA8 * dst,int src_jump,int dst_jump,int w,int h,int dith_x,int dith_y,DATA8 * pal EINA_UNUSED)37 void evas_common_convert_rgba_to_8bpp_gry_16_dith      (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal EINA_UNUSED)
38 {
39    DATA32 *src_ptr;
40    DATA8 *dst_ptr;
41    int x, y;
42    DATA8 r, g, b;
43    DATA32 gry8;
44    DATA8 dith;
45 
46    dst_ptr = (DATA8 *)dst;
47 
48    CONVERT_LOOP_START_ROT_0();
49 
50    dith = DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK] >> DM_SHF(4);
51 
52    r = (R_VAL(src_ptr));
53    g = (G_VAL(src_ptr));
54    b = (B_VAL(src_ptr));
55 
56    // Y = 0.299 * R + 0.587 * G + 0.114 * B;
57    gry8 = ((r * 19596) + (g * 38470) + (b * 7472)) >> 16;
58 
59    if (((gry8 - gry8 * 255 / 4) >= dith) && (gry8 < 0x07)) gry8++;
60 
61    *dst_ptr = gry8;
62 
63    CONVERT_LOOP_END_ROT_0();
64 }
65 
evas_common_convert_rgba_to_8bpp_gry_4_dith(DATA32 * src EINA_UNUSED,DATA8 * dst EINA_UNUSED,int src_jump EINA_UNUSED,int dst_jump EINA_UNUSED,int w EINA_UNUSED,int h EINA_UNUSED,int dith_x EINA_UNUSED,int dith_y EINA_UNUSED,DATA8 * pal EINA_UNUSED)66 void evas_common_convert_rgba_to_8bpp_gry_4_dith       (DATA32 *src EINA_UNUSED, DATA8 *dst EINA_UNUSED, int src_jump EINA_UNUSED, int dst_jump EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED){}
67 
evas_common_convert_rgba_to_8bpp_gry_1_dith(DATA32 * src EINA_UNUSED,DATA8 * dst EINA_UNUSED,int src_jump EINA_UNUSED,int dst_jump EINA_UNUSED,int w EINA_UNUSED,int h EINA_UNUSED,int dith_x EINA_UNUSED,int dith_y EINA_UNUSED,DATA8 * pal EINA_UNUSED)68 void evas_common_convert_rgba_to_8bpp_gry_1_dith       (DATA32 *src EINA_UNUSED, DATA8 *dst EINA_UNUSED, int src_jump EINA_UNUSED, int dst_jump EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED){}
69