Edje: Add support for ETC1 encoding

Edje will compress images as ETC1 provided that they don't
contain any alpha AND the command line includes -etc1.
This commit is contained in:
Jean-Philippe Andre 2014-04-17 19:04:31 +09:00
parent f7150570b0
commit d531816b12
3 changed files with 18 additions and 4 deletions

View File

@ -36,7 +36,8 @@ int min_quality = 0;
int max_quality = 100;
int compress_mode = EET_COMPRESSION_HI;
int threads = 0;
int anotate = 0;
int anotate = 0;
int allow_etc1 = 0;
static void
_edje_cc_log_cb(const Eina_Log_Domain *d,
@ -92,7 +93,7 @@ main_help(void)
"-id image/directory Add a directory to look in for relative path images\n"
"-fd font/directory Add a directory to look in for relative path fonts\n"
"-sd sound/directory Add a directory to look in for relative path sounds samples\n"
"-vd vbiration/directory Add a directory to look in for relative path vibration samples\n"
"-vd vibration/directory Add a directory to look in for relative path vibration samples\n"
"-dd data/directory Add a directory to look in for relative path data.file entries\n"
"-td temp/directory Directory to store temporary files\n"
"-l license Specify the license of a theme\n"
@ -101,6 +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-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"
@ -171,6 +173,10 @@ main(int argc, char **argv)
{
no_raw = 1;
}
else if (!strcmp(argv[i], "-etc1") || !strcmp(argv[i], "--allow-etc1"))
{
allow_etc1 = 1;
}
else if (!strcmp(argv[i], "-no-save"))
{
no_save = 1;
@ -282,7 +288,11 @@ 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 */

View File

@ -237,6 +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_save;
extern int min_quality;
extern int max_quality;

View File

@ -753,6 +753,7 @@ data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED)
if ((iw->data) && (iw->w > 0) && (iw->h > 0))
{
Eet_Image_Encoding lossy = EET_IMAGE_LOSSLESS;
int mode, qual;
snprintf(buf, sizeof(buf), "edje/images/%i", iw->img->id);
@ -785,6 +786,8 @@ 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;
}
if (iw->alpha)
{
@ -816,7 +819,7 @@ data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED)
bytes = eet_data_image_write(iw->ef, buf,
iw->data, iw->w, iw->h,
iw->alpha,
0, qual, 1);
0, qual, lossy);
if (bytes <= 0)
{
snprintf(buf2, sizeof(buf2),