jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e8d7c46253dd1d1a2a6e122cadcb24166c8a4f70

commit e8d7c46253dd1d1a2a6e122cadcb24166c8a4f70
Author: Jean-Philippe Andre <[email protected]>
Date:   Fri Jun 13 17:37:12 2014 +0900

    Edje: Add support for ETC2 through LOSSY_ETC2 images
    
    Declare your images as LOSSY_ETC2 to encode them as ETC2.
    Add options to edje_cc to disable etc2.
    Use ETC2 support from Eet.
    
    @feature
---
 src/bin/edje/edje_cc.c          | 22 ++++++++++++++--------
 src/bin/edje/edje_cc.h          |  1 +
 src/bin/edje/edje_cc_handlers.c | 16 ++++++++++++----
 src/bin/edje/edje_cc_out.c      | 30 ++++++++++++++++++++----------
 src/lib/edje/edje_private.h     |  5 +++--
 5 files changed, 50 insertions(+), 24 deletions(-)

diff --git a/src/bin/edje/edje_cc.c b/src/bin/edje/edje_cc.c
index e6f791c..8e0c55c 100644
--- a/src/bin/edje/edje_cc.c
+++ b/src/bin/edje/edje_cc.c
@@ -38,6 +38,7 @@ int        compress_mode = EET_COMPRESSION_HI;
 int        threads = 0;
 int        anotate = 0;
 int        no_etc1 = 0;
+int        no_etc2 = 0;
 
 static void
 _edje_cc_log_cb(const Eina_Log_Domain *d,
@@ -102,7 +103,8 @@ main_help(void)
       "-no-lossy                Do NOT allow images to be lossy\n"
       "-no-comp                 Do NOT allow images to be stored with lossless 
compression\n"
       "-no-raw                  Do NOT allow images to be stored with zero 
compression (raw)\n"
-      "-no-etc1                 Do NOT allow images to be stored as ETC1 
(LOSSY_ETC1 will be then stored as JPEG)\n"
+      "-no-etc1                 Do NOT allow images to be stored as ETC1\n"
+      "-no-etc2                 Do NOT allow images to be stored as ETC2\n"
       "-no-save                 Do NOT store the input EDC file in the EDJ 
file\n"
       "-min-quality VAL         Do NOT allow lossy images with quality < VAL 
(0-100)\n"
       "-max-quality VAL         Do NOT allow lossy images with quality > VAL 
(0-100)\n"
@@ -168,15 +170,19 @@ main(int argc, char **argv)
        else if (!strcmp(argv[i], "-no-comp"))
          {
             no_comp = 1;
-         }
-       else if (!strcmp(argv[i], "-no-raw"))
-         {
-            no_raw = 1;
-         }
+          }
+        else if (!strcmp(argv[i], "-no-raw"))
+          {
+             no_raw = 1;
+          }
         else if (!strcmp(argv[i], "-no-etc1"))
-         {
+          {
              no_etc1 = 1;
-         }
+          }
+        else if (!strcmp(argv[i], "-no-etc2"))
+          {
+             no_etc2 = 1;
+          }
        else if (!strcmp(argv[i], "-no-save"))
          {
             no_save = 1;
diff --git a/src/bin/edje/edje_cc.h b/src/bin/edje/edje_cc.h
index 4c03ffb..da7e9d5 100644
--- a/src/bin/edje/edje_cc.h
+++ b/src/bin/edje/edje_cc.h
@@ -263,6 +263,7 @@ extern int                    no_lossy;
 extern int                    no_comp;
 extern int                    no_raw;
 extern int                    no_etc1;
+extern int                    no_etc2;
 extern int                    no_save;
 extern int                    min_quality;
 extern int                    max_quality;
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 838aa99..fa25cf0 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -1605,6 +1605,7 @@ st_externals_external(void)
         @li COMP: Lossless compression.
         @li LOSSY [0-100]: JPEG lossy compression with quality from 0 to 100.
         @li LOSSY_ETC1 [0-100]: ETC1 lossy texture compression with quality 
from 0 to 100.
+        @li LOSSY_ETC2 [0-100]: ETC2 lossy texture compression with quality 
from 0 to 100 (supports alpha).
         @li USER: Do not embed the file, refer to the external file instead.
     @endproperty
  */
@@ -1655,8 +1656,9 @@ st_images_image(void)
                   "COMP", 1,
                   "LOSSY", 2,
                   "LOSSY_ETC1", 3,
-                  "USER", 4,
-                  NULL);
+                  "LOSSY_ETC2", 4,
+                  "USER", 5,
+                 NULL);
    if (v == 0)
      {
        img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT;
@@ -1679,11 +1681,16 @@ st_images_image(void)
      }
    else if (v == 4)
      {
+        img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC2;
+        img->source_param = 0;
+     }
+   else if (v == 5)
+     {
        img->source_type = EDJE_IMAGE_SOURCE_TYPE_EXTERNAL;
        img->source_param = 0;
      }
-   if ((img->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY)
-       && (img->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1))
+   if ((img->source_type < EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY) ||
+       (img->source_type > EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC2))
        check_arg_count(2);
    else
      {
@@ -1813,6 +1820,7 @@ ob_images_set_image(void)
         @li COMP: Lossless compression.
         @li LOSSY [0-100]: JPEG lossy compression with quality from 0 to 100.
         @li LOSSY_ETC1 [0-100]: ETC1 lossy texture compression with quality 
from 0 to 100.
+        @li LOSSY_ETC2 [0-100]: ETC2 lossy texture compression with quality 
from 0 to 100 (supports alpha).
         @li USER: Do not embed the file, refer to the external file instead.
     @endproperty
 **/
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index 88bd69c..b80afb9 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -759,6 +759,8 @@ data_thread_image(void *data, Ecore_Thread *thread 
EINA_UNUSED)
           mode = 1; /* COMPRESS */
         else if (iw->img->source_type == 
EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1)
           mode = 3; /* LOSSY_ETC1 */
+        else if (iw->img->source_type == 
EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC2)
+          mode = 4; /* LOSSY_ETC2 */
         else
           mode = 2; /* LOSSY */
         if ((mode == 0) && (no_raw))
@@ -766,6 +768,7 @@ data_thread_image(void *data, Ecore_Thread *thread 
EINA_UNUSED)
              mode = 1; /* promote compression */
              iw->img->source_param = 95;
           }
+        if ((mode == 4) && (no_etc2)) mode = 2; /* demote etc2 to jpeg */
         if ((mode == 3) && (no_etc1)) mode = 2; /* demote etc1 to jpeg */
         if ((mode == 2) && (no_lossy)) mode = 1; /* demote compression */
         if ((mode == 1) && (no_comp))
@@ -784,15 +787,6 @@ data_thread_image(void *data, Ecore_Thread *thread 
EINA_UNUSED)
              if (qual > max_quality) qual = max_quality;
              lossy = EET_IMAGE_JPEG;
           }
-        if (mode == 3)
-          {
-             qual = iw->img->source_param;
-             if (qual < min_quality) qual = min_quality;
-             if (qual > max_quality) qual = max_quality;
-             // Enable TGV with LZ4. A bit redundant with EET compression.
-             comp = !no_comp;
-             lossy = EET_IMAGE_ETC1;
-          }
         if (iw->alpha)
           {
              start = (unsigned int *) iw->data;
@@ -808,6 +802,22 @@ data_thread_image(void *data, Ecore_Thread *thread 
EINA_UNUSED)
                }
              if (opaque) iw->alpha = 0;
           }
+        if (mode == 3)
+          {
+             qual = iw->img->source_param;
+             if (qual < min_quality) qual = min_quality;
+             if (qual > max_quality) qual = max_quality;
+             // Enable TGV with LZ4. A bit redundant with EET compression.
+             comp = !no_comp;
+             lossy = EET_IMAGE_ETC1;
+          }
+        if (mode == 4)
+          {
+             qual = iw->img->source_param;
+             if (qual < min_quality) qual = min_quality;
+             if (qual > max_quality) qual = max_quality;
+             lossy = opaque ? EET_IMAGE_ETC2_RGB : EET_IMAGE_ETC2_RGBA;
+          }
         if (mode == 0)
           bytes = eet_data_image_write(iw->ef, buf,
                                        iw->data, iw->w, iw->h,
@@ -819,7 +829,7 @@ data_thread_image(void *data, Ecore_Thread *thread 
EINA_UNUSED)
                                        iw->alpha,
                                        compress_mode,
                                        0, 0);
-        else
+        else if (mode >= 2)
           bytes = eet_data_image_write(iw->ef, buf,
                                        iw->data, iw->w, iw->h,
                                        iw->alpha,
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 1424cdb..54fe09a 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -350,8 +350,9 @@ typedef struct _Edje_Signal_Callback_Custom 
Edje_Signal_Callback_Custom;
 #define EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT       1
 #define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY         2
 #define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1    3
-#define EDJE_IMAGE_SOURCE_TYPE_EXTERNAL             4
-#define EDJE_IMAGE_SOURCE_TYPE_LAST                 5
+#define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC2    4
+#define EDJE_IMAGE_SOURCE_TYPE_EXTERNAL             5
+#define EDJE_IMAGE_SOURCE_TYPE_LAST                 6
 
 #define EDJE_SOUND_SOURCE_TYPE_NONE           0
 #define EDJE_SOUND_SOURCE_TYPE_INLINE_RAW     1

-- 


Reply via email to