jpeg pushed a commit to branch master.

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

commit f6eae69eb24d9bce23929ebc2fb904bc73f4a217
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Fri Apr 18 16:39:37 2014 +0900

    Edje: Use LOSSY_ETC1 instead of LOSSY
    
    Add a new flag in EDC files to specify ETC1 compression
    should be enabled. It follows the same rules as the
    current LOSSY flag for JPEG compression.
    
    @feature
---
 src/bin/edje/edje_cc.c          | 14 ++++----------
 src/bin/edje/edje_cc.h          |  2 +-
 src/bin/edje/edje_cc_handlers.c | 30 ++++++++++++++++++++----------
 src/bin/edje/edje_cc_out.c      | 21 ++++++++++++++-------
 src/bin/edje/edje_inspector.c   |  4 ++++
 src/lib/edje/Edje_Edit.h        |  7 ++++---
 src/lib/edje/edje_edit.c        | 30 +++++++++++++++++-------------
 src/lib/edje/edje_private.h     | 11 ++++++-----
 8 files changed, 70 insertions(+), 49 deletions(-)

diff --git a/src/bin/edje/edje_cc.c b/src/bin/edje/edje_cc.c
index b3bb014..e6f791c 100644
--- a/src/bin/edje/edje_cc.c
+++ b/src/bin/edje/edje_cc.c
@@ -37,7 +37,7 @@ int        max_quality = 100;
 int        compress_mode = EET_COMPRESSION_HI;
 int        threads = 0;
 int        anotate = 0;
-int        allow_etc1 = 0;
+int        no_etc1 = 0;
 
 static void
 _edje_cc_log_cb(const Eina_Log_Domain *d,
@@ -102,7 +102,7 @@ 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"
-      "-etc1                    Allow images to be stored as ETC1 in the EDJ 
file (incompatible with -no-lossy, default: no)\n"
+      "-no-etc1                 Do NOT allow images to be stored as ETC1 
(LOSSY_ETC1 will be then stored as JPEG)\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"
@@ -173,9 +173,9 @@ main(int argc, char **argv)
          {
             no_raw = 1;
          }
-       else if (!strcmp(argv[i], "-etc1") || !strcmp(argv[i], "--allow-etc1"))
+        else if (!strcmp(argv[i], "-no-etc1"))
          {
-            allow_etc1 = 1;
+             no_etc1 = 1;
          }
        else if (!strcmp(argv[i], "-no-save"))
          {
@@ -288,12 +288,6 @@ main(int argc, char **argv)
        exit(-1);
      }
 
-   if (allow_etc1 && no_lossy)
-     {
-        WRN("-etc1 and -no-lossy are not compatible, discarded -etc1");
-        allow_etc1 = 0;
-     }
-
    pfx = eina_prefix_new(argv[0],            /* argv[0] value (optional) */
                          main,               /* an optional symbol to check 
path of */
                          "EDJE",             /* env var prefix to use 
(XXX_PREFIX, XXX_BIN_DIR etc. */
diff --git a/src/bin/edje/edje_cc.h b/src/bin/edje/edje_cc.h
index 80952a6..273a696 100644
--- a/src/bin/edje/edje_cc.h
+++ b/src/bin/edje/edje_cc.h
@@ -237,7 +237,7 @@ extern Eina_List             *licenses;
 extern int                    no_lossy;
 extern int                    no_comp;
 extern int                    no_raw;
-extern int                    allow_etc1;
+extern int                    no_etc1;
 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 740c53f..829c465 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -1269,6 +1269,7 @@ st_externals_external(void)
         images {
             image: "filename1.ext" COMP;
             image: "filename2.ext" LOSSY 99;
+            image: "filename2.ext" LOSSY_ETC1 50;
            set {
               name: "image_name_used";
                image {
@@ -1309,7 +1310,8 @@ st_externals_external(void)
         Compression methods:
         @li RAW: Uncompressed.
         @li COMP: Lossless compression.
-        @li LOSSY [0-100]: Lossy compression with quality from 0 to 100.
+        @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 USER: Do not embed the file, refer to the external file instead.
     @endproperty
  */
@@ -1356,11 +1358,12 @@ st_images_image(void)
    img->entry = tmp;
    img->id = edje_file->image_dir->entries_count - 1;
    v = parse_enum(1,
-                 "RAW", 0,
-                 "COMP", 1,
-                 "LOSSY", 2,
-                 "USER", 3,
-                 NULL);
+                  "RAW", 0,
+                  "COMP", 1,
+                  "LOSSY", 2,
+                  "LOSSY_ETC1", 3,
+                  "USER", 4,
+                  NULL);
    if (v == 0)
      {
        img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT;
@@ -1373,15 +1376,21 @@ st_images_image(void)
      }
    else if (v == 2)
      {
-       img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY;
-       img->source_param = 0;
+        img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY;
+        img->source_param = 0;
      }
    else if (v == 3)
      {
+        img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1;
+        img->source_param = 0;
+     }
+   else if (v == 4)
+     {
        img->source_type = EDJE_IMAGE_SOURCE_TYPE_EXTERNAL;
        img->source_param = 0;
      }
-   if (img->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY)
+   if ((img->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY)
+       && (img->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1))
        check_arg_count(2);
    else
      {
@@ -1509,7 +1518,8 @@ ob_images_set_image(void)
         Compression methods:
         @li RAW: Uncompressed.
         @li COMP: Lossless compression.
-        @li LOSSY [0-100]: Lossy compression with quality from 0 to 100.
+        @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 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 7691bab..21a435f 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -765,6 +765,8 @@ data_thread_image(void *data, Ecore_Thread *thread 
EINA_UNUSED)
         else if ((iw->img->source_type == 
EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) &&
                  (iw->img->source_param == 1))
           mode = 1; /* COMPRESS */
+        else if (iw->img->source_type == 
EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1)
+          mode = 3; /* LOSSY_ETC1 */
         else
           mode = 2; /* LOSSY */
         if ((mode == 0) && (no_raw))
@@ -772,6 +774,7 @@ data_thread_image(void *data, Ecore_Thread *thread 
EINA_UNUSED)
              mode = 1; /* promote compression */
              iw->img->source_param = 95;
           }
+        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))
           {
@@ -787,12 +790,16 @@ data_thread_image(void *data, Ecore_Thread *thread 
EINA_UNUSED)
              qual = iw->img->source_param;
              if (qual < min_quality) qual = min_quality;
              if (qual > max_quality) qual = max_quality;
-             if (!allow_etc1 || (iw->alpha)) lossy = EET_IMAGE_JPEG;
-             else
-               {
-                  lossy = EET_IMAGE_ETC1;
-                  comp = !no_comp;
-               }
+             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)
           {
@@ -820,7 +827,7 @@ data_thread_image(void *data, Ecore_Thread *thread 
EINA_UNUSED)
                                        iw->alpha,
                                        compress_mode,
                                        0, 0);
-        else if (mode == 2)
+        else
           bytes = eet_data_image_write(iw->ef, buf,
                                        iw->data, iw->w, iw->h,
                                        iw->alpha,
diff --git a/src/bin/edje/edje_inspector.c b/src/bin/edje/edje_inspector.c
index d0d5360..fd8972f 100644
--- a/src/bin/edje/edje_inspector.c
+++ b/src/bin/edje/edje_inspector.c
@@ -1379,6 +1379,10 @@ _comp_str_get(Evas_Object *ed, const char *img)
          rate = edje_edit_image_compression_rate_get(ed, img);
          snprintf(buf, sizeof(buf), "LOSSY %d", rate);
          return buf;
+      case EDJE_EDIT_IMAGE_COMP_LOSSY_ETC1:
+        rate = edje_edit_image_compression_rate_get(ed, img);
+        snprintf(buf, sizeof(buf), "LOSSY_ETC1 %d", rate);
+        return buf;
       default:
          ERR("Unknown compression type %d", type);
          return "???";
diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index 8a8b804..cd59288 100644
--- a/src/lib/edje/Edje_Edit.h
+++ b/src/lib/edje/Edje_Edit.h
@@ -39,7 +39,8 @@ typedef enum _Edje_Edit_Image_Comp
    EDJE_EDIT_IMAGE_COMP_RAW,
    EDJE_EDIT_IMAGE_COMP_USER,
    EDJE_EDIT_IMAGE_COMP_COMP,
-   EDJE_EDIT_IMAGE_COMP_LOSSY
+   EDJE_EDIT_IMAGE_COMP_LOSSY,
+   EDJE_EDIT_IMAGE_COMP_LOSSY_ETC1
 } Edje_Edit_Image_Comp;
 
 struct _Edje_Edit_Script_Error
@@ -2986,7 +2987,7 @@ EAPI int edje_edit_image_id_get(Evas_Object *obj, const 
char *image_name);
  * @param image The name of the image.
  *
  * @return One of Image Compression types.
- * (EDJE_EDIT_IMAGE_COMP_RAW, EDJE_EDIT_IMAGE_COMP_USER, 
EDJE_EDIT_IMAGE_COMP_COMP, EDJE_EDIT_IMAGE_COMP_LOSSY).
+ * (EDJE_EDIT_IMAGE_COMP_RAW, EDJE_EDIT_IMAGE_COMP_USER, 
EDJE_EDIT_IMAGE_COMP_COMP, EDJE_EDIT_IMAGE_COMP_LOSSY[_ETC1]).
  */
 EAPI Edje_Edit_Image_Comp edje_edit_image_compression_type_get(Evas_Object 
*obj, const char *image);
 
@@ -2996,7 +2997,7 @@ EAPI Edje_Edit_Image_Comp 
edje_edit_image_compression_type_get(Evas_Object *obj,
  * @param image The name of the image.
  *
  * @return The compression rate (if the imnage is @c
- *         EDJE_EDIT_IMAGE_COMP_LOSSY) or < 0, on errors.
+ *         EDJE_EDIT_IMAGE_COMP_LOSSY[_ETC1]) or < 0, on errors.
  */
 EAPI int edje_edit_image_compression_rate_get(Evas_Object *obj, const char 
*image);
 
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 8c67e0a..1439904 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -5302,18 +5302,17 @@ edje_edit_image_compression_type_get(Evas_Object *obj, 
const char *image)
 
    switch(de->source_type)
      {
-       case EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT:
-               if (de->source_param == 0) // RAW
-                 return EDJE_EDIT_IMAGE_COMP_RAW;
-               else // COMP
-                 return EDJE_EDIT_IMAGE_COMP_COMP;
-               break;
-       case EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY: // LOSSY
-               return EDJE_EDIT_IMAGE_COMP_LOSSY;
-               break;
-       case EDJE_IMAGE_SOURCE_TYPE_EXTERNAL: // USER
-               return EDJE_EDIT_IMAGE_COMP_USER;
-               break;
+      case EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT:
+        if (de->source_param == 0) // RAW
+          return EDJE_EDIT_IMAGE_COMP_RAW;
+        else // COMP
+          return EDJE_EDIT_IMAGE_COMP_COMP;
+      case EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY: // LOSSY
+        return EDJE_EDIT_IMAGE_COMP_LOSSY;
+      case EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1: // LOSSY_ETC1
+        return EDJE_EDIT_IMAGE_COMP_LOSSY_ETC1;
+      case EDJE_IMAGE_SOURCE_TYPE_EXTERNAL: // USER
+        return EDJE_EDIT_IMAGE_COMP_USER;
      }
 
    return -1;
@@ -5337,7 +5336,9 @@ edje_edit_image_compression_rate_get(Evas_Object *obj, 
const char *image)
      }
 
    if (i == ed->file->image_dir->entries_count) return -1;
-   if (de->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY) return -2;
+   if ((de->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY)
+       && (de->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1))
+     return -2;
 
    return de->source_param;
 }
@@ -7089,6 +7090,9 @@ _edje_generate_image_source(Evas_Object *obj, const char 
*entry)
    if (comp == EDJE_EDIT_IMAGE_COMP_LOSSY)
      BUF_APPENDF("LOSSY %d;\n",
                  edje_edit_image_compression_rate_get(obj, entry));
+   else if (comp == EDJE_EDIT_IMAGE_COMP_LOSSY_ETC1)
+     BUF_APPENDF("LOSSY_ETC1 %d;\n",
+                 edje_edit_image_compression_rate_get(obj, entry));
    else if (comp == EDJE_EDIT_IMAGE_COMP_RAW)
      BUF_APPEND("RAW;\n");
    else if (comp == EDJE_EDIT_IMAGE_COMP_USER)
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 4dc03af..28fb179 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -346,11 +346,12 @@ typedef struct _Edje_Signal_Callback_Custom 
Edje_Signal_Callback_Custom;
 #define EDJE_INF_MAX_W 100000
 #define EDJE_INF_MAX_H 100000
 
-#define EDJE_IMAGE_SOURCE_TYPE_NONE           0
-#define EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT 1
-#define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY   2
-#define EDJE_IMAGE_SOURCE_TYPE_EXTERNAL       3
-#define EDJE_IMAGE_SOURCE_TYPE_LAST           4
+#define EDJE_IMAGE_SOURCE_TYPE_NONE                 0
+#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_SOUND_SOURCE_TYPE_NONE           0
 #define EDJE_SOUND_SOURCE_TYPE_INLINE_RAW     1

-- 


Reply via email to