summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-04-18 16:39:37 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-04-18 16:50:01 +0900
commitf6eae69eb24d9bce23929ebc2fb904bc73f4a217 (patch)
tree7fe5a1c3eec48565519156aeb04b87aab9581cfa
parentca0c608b66017d85bcaa3580c32000b7595d8e52 (diff)
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
-rw-r--r--src/bin/edje/edje_cc.c14
-rw-r--r--src/bin/edje/edje_cc.h2
-rw-r--r--src/bin/edje/edje_cc_handlers.c30
-rw-r--r--src/bin/edje/edje_cc_out.c21
-rw-r--r--src/bin/edje/edje_inspector.c4
-rw-r--r--src/lib/edje/Edje_Edit.h7
-rw-r--r--src/lib/edje/edje_edit.c30
-rw-r--r--src/lib/edje/edje_private.h11
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;
37int compress_mode = EET_COMPRESSION_HI; 37int compress_mode = EET_COMPRESSION_HI;
38int threads = 0; 38int threads = 0;
39int anotate = 0; 39int anotate = 0;
40int allow_etc1 = 0; 40int no_etc1 = 0;
41 41
42static void 42static void
43_edje_cc_log_cb(const Eina_Log_Domain *d, 43_edje_cc_log_cb(const Eina_Log_Domain *d,
@@ -102,7 +102,7 @@ main_help(void)
102 "-no-lossy Do NOT allow images to be lossy\n" 102 "-no-lossy Do NOT allow images to be lossy\n"
103 "-no-comp Do NOT allow images to be stored with lossless compression\n" 103 "-no-comp Do NOT allow images to be stored with lossless compression\n"
104 "-no-raw Do NOT allow images to be stored with zero compression (raw)\n" 104 "-no-raw Do NOT allow images to be stored with zero compression (raw)\n"
105 "-etc1 Allow images to be stored as ETC1 in the EDJ file (incompatible with -no-lossy, default: no)\n" 105 "-no-etc1 Do NOT allow images to be stored as ETC1 (LOSSY_ETC1 will be then stored as JPEG)\n"
106 "-no-save Do NOT store the input EDC file in the EDJ file\n" 106 "-no-save Do NOT store the input EDC file in the EDJ file\n"
107 "-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)\n" 107 "-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)\n"
108 "-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)\n" 108 "-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)\n"
@@ -173,9 +173,9 @@ main(int argc, char **argv)
173 { 173 {
174 no_raw = 1; 174 no_raw = 1;
175 } 175 }
176 else if (!strcmp(argv[i], "-etc1") || !strcmp(argv[i], "--allow-etc1")) 176 else if (!strcmp(argv[i], "-no-etc1"))
177 { 177 {
178 allow_etc1 = 1; 178 no_etc1 = 1;
179 } 179 }
180 else if (!strcmp(argv[i], "-no-save")) 180 else if (!strcmp(argv[i], "-no-save"))
181 { 181 {
@@ -288,12 +288,6 @@ main(int argc, char **argv)
288 exit(-1); 288 exit(-1);
289 } 289 }
290 290
291 if (allow_etc1 && no_lossy)
292 {
293 WRN("-etc1 and -no-lossy are not compatible, discarded -etc1");
294 allow_etc1 = 0;
295 }
296
297 pfx = eina_prefix_new(argv[0], /* argv[0] value (optional) */ 291 pfx = eina_prefix_new(argv[0], /* argv[0] value (optional) */
298 main, /* an optional symbol to check path of */ 292 main, /* an optional symbol to check path of */
299 "EDJE", /* env var prefix to use (XXX_PREFIX, XXX_BIN_DIR etc. */ 293 "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;
237extern int no_lossy; 237extern int no_lossy;
238extern int no_comp; 238extern int no_comp;
239extern int no_raw; 239extern int no_raw;
240extern int allow_etc1; 240extern int no_etc1;
241extern int no_save; 241extern int no_save;
242extern int min_quality; 242extern int min_quality;
243extern int max_quality; 243extern 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)
1269 images { 1269 images {
1270 image: "filename1.ext" COMP; 1270 image: "filename1.ext" COMP;
1271 image: "filename2.ext" LOSSY 99; 1271 image: "filename2.ext" LOSSY 99;
1272 image: "filename2.ext" LOSSY_ETC1 50;
1272 set { 1273 set {
1273 name: "image_name_used"; 1274 name: "image_name_used";
1274 image { 1275 image {
@@ -1309,7 +1310,8 @@ st_externals_external(void)
1309 Compression methods: 1310 Compression methods:
1310 @li RAW: Uncompressed. 1311 @li RAW: Uncompressed.
1311 @li COMP: Lossless compression. 1312 @li COMP: Lossless compression.
1312 @li LOSSY [0-100]: Lossy compression with quality from 0 to 100. 1313 @li LOSSY [0-100]: JPEG lossy compression with quality from 0 to 100.
1314 @li LOSSY_ETC1 [0-100]: ETC1 lossy texture compression with quality from 0 to 100.
1313 @li USER: Do not embed the file, refer to the external file instead. 1315 @li USER: Do not embed the file, refer to the external file instead.
1314 @endproperty 1316 @endproperty
1315 */ 1317 */
@@ -1356,11 +1358,12 @@ st_images_image(void)
1356 img->entry = tmp; 1358 img->entry = tmp;
1357 img->id = edje_file->image_dir->entries_count - 1; 1359 img->id = edje_file->image_dir->entries_count - 1;
1358 v = parse_enum(1, 1360 v = parse_enum(1,
1359 "RAW", 0, 1361 "RAW", 0,
1360 "COMP", 1, 1362 "COMP", 1,
1361 "LOSSY", 2, 1363 "LOSSY", 2,
1362 "USER", 3, 1364 "LOSSY_ETC1", 3,
1363 NULL); 1365 "USER", 4,
1366 NULL);
1364 if (v == 0) 1367 if (v == 0)
1365 { 1368 {
1366 img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT; 1369 img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT;
@@ -1373,15 +1376,21 @@ st_images_image(void)
1373 } 1376 }
1374 else if (v == 2) 1377 else if (v == 2)
1375 { 1378 {
1376 img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY; 1379 img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY;
1377 img->source_param = 0; 1380 img->source_param = 0;
1378 } 1381 }
1379 else if (v == 3) 1382 else if (v == 3)
1380 { 1383 {
1384 img->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1;
1385 img->source_param = 0;
1386 }
1387 else if (v == 4)
1388 {
1381 img->source_type = EDJE_IMAGE_SOURCE_TYPE_EXTERNAL; 1389 img->source_type = EDJE_IMAGE_SOURCE_TYPE_EXTERNAL;
1382 img->source_param = 0; 1390 img->source_param = 0;
1383 } 1391 }
1384 if (img->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY) 1392 if ((img->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY)
1393 && (img->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1))
1385 check_arg_count(2); 1394 check_arg_count(2);
1386 else 1395 else
1387 { 1396 {
@@ -1509,7 +1518,8 @@ ob_images_set_image(void)
1509 Compression methods: 1518 Compression methods:
1510 @li RAW: Uncompressed. 1519 @li RAW: Uncompressed.
1511 @li COMP: Lossless compression. 1520 @li COMP: Lossless compression.
1512 @li LOSSY [0-100]: Lossy compression with quality from 0 to 100. 1521 @li LOSSY [0-100]: JPEG lossy compression with quality from 0 to 100.
1522 @li LOSSY_ETC1 [0-100]: ETC1 lossy texture compression with quality from 0 to 100.
1513 @li USER: Do not embed the file, refer to the external file instead. 1523 @li USER: Do not embed the file, refer to the external file instead.
1514 @endproperty 1524 @endproperty
1515**/ 1525**/
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)
765 else if ((iw->img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) && 765 else if ((iw->img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) &&
766 (iw->img->source_param == 1)) 766 (iw->img->source_param == 1))
767 mode = 1; /* COMPRESS */ 767 mode = 1; /* COMPRESS */
768 else if (iw->img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1)
769 mode = 3; /* LOSSY_ETC1 */
768 else 770 else
769 mode = 2; /* LOSSY */ 771 mode = 2; /* LOSSY */
770 if ((mode == 0) && (no_raw)) 772 if ((mode == 0) && (no_raw))
@@ -772,6 +774,7 @@ data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED)
772 mode = 1; /* promote compression */ 774 mode = 1; /* promote compression */
773 iw->img->source_param = 95; 775 iw->img->source_param = 95;
774 } 776 }
777 if ((mode == 3) && (no_etc1)) mode = 2; /* demote etc1 to jpeg */
775 if ((mode == 2) && (no_lossy)) mode = 1; /* demote compression */ 778 if ((mode == 2) && (no_lossy)) mode = 1; /* demote compression */
776 if ((mode == 1) && (no_comp)) 779 if ((mode == 1) && (no_comp))
777 { 780 {
@@ -787,12 +790,16 @@ data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED)
787 qual = iw->img->source_param; 790 qual = iw->img->source_param;
788 if (qual < min_quality) qual = min_quality; 791 if (qual < min_quality) qual = min_quality;
789 if (qual > max_quality) qual = max_quality; 792 if (qual > max_quality) qual = max_quality;
790 if (!allow_etc1 || (iw->alpha)) lossy = EET_IMAGE_JPEG; 793 lossy = EET_IMAGE_JPEG;
791 else 794 }
792 { 795 if (mode == 3)
793 lossy = EET_IMAGE_ETC1; 796 {
794 comp = !no_comp; 797 qual = iw->img->source_param;
795 } 798 if (qual < min_quality) qual = min_quality;
799 if (qual > max_quality) qual = max_quality;
800 // Enable TGV with LZ4. A bit redundant with EET compression.
801 comp = !no_comp;
802 lossy = EET_IMAGE_ETC1;
796 } 803 }
797 if (iw->alpha) 804 if (iw->alpha)
798 { 805 {
@@ -820,7 +827,7 @@ data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED)
820 iw->alpha, 827 iw->alpha,
821 compress_mode, 828 compress_mode,
822 0, 0); 829 0, 0);
823 else if (mode == 2) 830 else
824 bytes = eet_data_image_write(iw->ef, buf, 831 bytes = eet_data_image_write(iw->ef, buf,
825 iw->data, iw->w, iw->h, 832 iw->data, iw->w, iw->h,
826 iw->alpha, 833 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)
1379 rate = edje_edit_image_compression_rate_get(ed, img); 1379 rate = edje_edit_image_compression_rate_get(ed, img);
1380 snprintf(buf, sizeof(buf), "LOSSY %d", rate); 1380 snprintf(buf, sizeof(buf), "LOSSY %d", rate);
1381 return buf; 1381 return buf;
1382 case EDJE_EDIT_IMAGE_COMP_LOSSY_ETC1:
1383 rate = edje_edit_image_compression_rate_get(ed, img);
1384 snprintf(buf, sizeof(buf), "LOSSY_ETC1 %d", rate);
1385 return buf;
1382 default: 1386 default:
1383 ERR("Unknown compression type %d", type); 1387 ERR("Unknown compression type %d", type);
1384 return "???"; 1388 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
39 EDJE_EDIT_IMAGE_COMP_RAW, 39 EDJE_EDIT_IMAGE_COMP_RAW,
40 EDJE_EDIT_IMAGE_COMP_USER, 40 EDJE_EDIT_IMAGE_COMP_USER,
41 EDJE_EDIT_IMAGE_COMP_COMP, 41 EDJE_EDIT_IMAGE_COMP_COMP,
42 EDJE_EDIT_IMAGE_COMP_LOSSY 42 EDJE_EDIT_IMAGE_COMP_LOSSY,
43 EDJE_EDIT_IMAGE_COMP_LOSSY_ETC1
43} Edje_Edit_Image_Comp; 44} Edje_Edit_Image_Comp;
44 45
45struct _Edje_Edit_Script_Error 46struct _Edje_Edit_Script_Error
@@ -2986,7 +2987,7 @@ EAPI int edje_edit_image_id_get(Evas_Object *obj, const char *image_name);
2986 * @param image The name of the image. 2987 * @param image The name of the image.
2987 * 2988 *
2988 * @return One of Image Compression types. 2989 * @return One of Image Compression types.
2989 * (EDJE_EDIT_IMAGE_COMP_RAW, EDJE_EDIT_IMAGE_COMP_USER, EDJE_EDIT_IMAGE_COMP_COMP, EDJE_EDIT_IMAGE_COMP_LOSSY). 2990 * (EDJE_EDIT_IMAGE_COMP_RAW, EDJE_EDIT_IMAGE_COMP_USER, EDJE_EDIT_IMAGE_COMP_COMP, EDJE_EDIT_IMAGE_COMP_LOSSY[_ETC1]).
2990 */ 2991 */
2991EAPI Edje_Edit_Image_Comp edje_edit_image_compression_type_get(Evas_Object *obj, const char *image); 2992EAPI Edje_Edit_Image_Comp edje_edit_image_compression_type_get(Evas_Object *obj, const char *image);
2992 2993
@@ -2996,7 +2997,7 @@ EAPI Edje_Edit_Image_Comp edje_edit_image_compression_type_get(Evas_Object *obj,
2996 * @param image The name of the image. 2997 * @param image The name of the image.
2997 * 2998 *
2998 * @return The compression rate (if the imnage is @c 2999 * @return The compression rate (if the imnage is @c
2999 * EDJE_EDIT_IMAGE_COMP_LOSSY) or < 0, on errors. 3000 * EDJE_EDIT_IMAGE_COMP_LOSSY[_ETC1]) or < 0, on errors.
3000 */ 3001 */
3001EAPI int edje_edit_image_compression_rate_get(Evas_Object *obj, const char *image); 3002EAPI int edje_edit_image_compression_rate_get(Evas_Object *obj, const char *image);
3002 3003
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)
5302 5302
5303 switch(de->source_type) 5303 switch(de->source_type)
5304 { 5304 {
5305 case EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT: 5305 case EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT:
5306 if (de->source_param == 0) // RAW 5306 if (de->source_param == 0) // RAW
5307 return EDJE_EDIT_IMAGE_COMP_RAW; 5307 return EDJE_EDIT_IMAGE_COMP_RAW;
5308 else // COMP 5308 else // COMP
5309 return EDJE_EDIT_IMAGE_COMP_COMP; 5309 return EDJE_EDIT_IMAGE_COMP_COMP;
5310 break; 5310 case EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY: // LOSSY
5311 case EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY: // LOSSY 5311 return EDJE_EDIT_IMAGE_COMP_LOSSY;
5312 return EDJE_EDIT_IMAGE_COMP_LOSSY; 5312 case EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1: // LOSSY_ETC1
5313 break; 5313 return EDJE_EDIT_IMAGE_COMP_LOSSY_ETC1;
5314 case EDJE_IMAGE_SOURCE_TYPE_EXTERNAL: // USER 5314 case EDJE_IMAGE_SOURCE_TYPE_EXTERNAL: // USER
5315 return EDJE_EDIT_IMAGE_COMP_USER; 5315 return EDJE_EDIT_IMAGE_COMP_USER;
5316 break;
5317 } 5316 }
5318 5317
5319 return -1; 5318 return -1;
@@ -5337,7 +5336,9 @@ edje_edit_image_compression_rate_get(Evas_Object *obj, const char *image)
5337 } 5336 }
5338 5337
5339 if (i == ed->file->image_dir->entries_count) return -1; 5338 if (i == ed->file->image_dir->entries_count) return -1;
5340 if (de->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY) return -2; 5339 if ((de->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY)
5340 && (de->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1))
5341 return -2;
5341 5342
5342 return de->source_param; 5343 return de->source_param;
5343} 5344}
@@ -7089,6 +7090,9 @@ _edje_generate_image_source(Evas_Object *obj, const char *entry)
7089 if (comp == EDJE_EDIT_IMAGE_COMP_LOSSY) 7090 if (comp == EDJE_EDIT_IMAGE_COMP_LOSSY)
7090 BUF_APPENDF("LOSSY %d;\n", 7091 BUF_APPENDF("LOSSY %d;\n",
7091 edje_edit_image_compression_rate_get(obj, entry)); 7092 edje_edit_image_compression_rate_get(obj, entry));
7093 else if (comp == EDJE_EDIT_IMAGE_COMP_LOSSY_ETC1)
7094 BUF_APPENDF("LOSSY_ETC1 %d;\n",
7095 edje_edit_image_compression_rate_get(obj, entry));
7092 else if (comp == EDJE_EDIT_IMAGE_COMP_RAW) 7096 else if (comp == EDJE_EDIT_IMAGE_COMP_RAW)
7093 BUF_APPEND("RAW;\n"); 7097 BUF_APPEND("RAW;\n");
7094 else if (comp == EDJE_EDIT_IMAGE_COMP_USER) 7098 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;
346#define EDJE_INF_MAX_W 100000 346#define EDJE_INF_MAX_W 100000
347#define EDJE_INF_MAX_H 100000 347#define EDJE_INF_MAX_H 100000
348 348
349#define EDJE_IMAGE_SOURCE_TYPE_NONE 0 349#define EDJE_IMAGE_SOURCE_TYPE_NONE 0
350#define EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT 1 350#define EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT 1
351#define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY 2 351#define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY 2
352#define EDJE_IMAGE_SOURCE_TYPE_EXTERNAL 3 352#define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1 3
353#define EDJE_IMAGE_SOURCE_TYPE_LAST 4 353#define EDJE_IMAGE_SOURCE_TYPE_EXTERNAL 4
354#define EDJE_IMAGE_SOURCE_TYPE_LAST 5
354 355
355#define EDJE_SOUND_SOURCE_TYPE_NONE 0 356#define EDJE_SOUND_SOURCE_TYPE_NONE 0
356#define EDJE_SOUND_SOURCE_TYPE_INLINE_RAW 1 357#define EDJE_SOUND_SOURCE_TYPE_INLINE_RAW 1