Evas ETC2: Remove some useless operations
authorJean-Philippe Andre <jp.andre@samsung.com>
Mon, 23 Jun 2014 00:31:15 +0000 (09:31 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Mon, 23 Jun 2014 02:20:13 +0000 (11:20 +0900)
No need to write out alpha in a RGBA color when only
the RGB values are used by the distance op.

Also, add a comment on the byte order. Maybe I'm wrong
but I believe the operations are fine wrt. byte order :)

src/static_libs/rg_etc/etc2_encoder.c

index 54481e8..8f7fe3c 100644 (file)
@@ -129,6 +129,14 @@ absi(int a)
 #define G_VAL(v) ((uint8_t) ((v & 0x0000FF00) >> 8))
 #define B_VAL(v) ((uint8_t) ((v & 0x000000FF)))
 
+#ifndef WORDS_BIGENDIAN
+# define RGB_START 0
+# define RGB_END   2
+#else
+# define RGB_START 1
+# define RGB_END   3
+#endif
+
 #ifndef DBG
 # ifdef DEBUG
 #  define DBG(fmt, ...) fprintf(stderr, "%s:%d: " fmt "\n", __FUNCTION__, __LINE__, ## __VA_ARGS__)
@@ -463,6 +471,10 @@ _etc2_th_mode_block_pack(uint8_t *etc2, Eina_Bool h_mode,
    } paint_colors[4], color1, color2;
    int errAcc = 0;
 
+   paint_colors[0].v = 0;
+   paint_colors[1].v = 0;
+   paint_colors[2].v = 0;
+   paint_colors[3].v = 0;
    color1.v = c1;
    color2.v = c2;
 
@@ -488,7 +500,8 @@ _etc2_th_mode_block_pack(uint8_t *etc2, Eina_Bool h_mode,
           }
      }
 
-   for (int k = 0; k < 4; k++)
+   // Set paint_colors using R,G,B values (byte order is preserved)
+   for (int k = RGB_START; k <= RGB_END; k++)
      {
         if (!h_mode)
           {