edje: add ability to reference images from other edje files
this uses the just-added "id" property to allow referencing images by name from that theme. example: =FILE1= id: "myfile"; images.image: "someimage.png" COMP; =FILE2= requires: "myfile"; images.image: "someimage.png" EXTERNAL "myfile"; FILE2 will now load someimage.png from FILE1 at runtime if FILE1 is currently opened in edje, and FILE1 will be kept open until FILE2 is closed @feature
This commit is contained in:
parent
3a86768f3b
commit
3d9dcbd478
|
@ -33,6 +33,7 @@ char *depfile = NULL;
|
||||||
char *authors = NULL;
|
char *authors = NULL;
|
||||||
char *license = NULL;
|
char *license = NULL;
|
||||||
Eina_List *licenses = NULL;
|
Eina_List *licenses = NULL;
|
||||||
|
Eina_Array *requires;
|
||||||
|
|
||||||
static const char *progname = NULL;
|
static const char *progname = NULL;
|
||||||
|
|
||||||
|
@ -418,6 +419,7 @@ main(int argc, char **argv)
|
||||||
edje_file->efl_version.major = 1;
|
edje_file->efl_version.major = 1;
|
||||||
edje_file->efl_version.minor = 18;
|
edje_file->efl_version.minor = 18;
|
||||||
edje_file->base_scale = FROM_INT(1);
|
edje_file->base_scale = FROM_INT(1);
|
||||||
|
requires = eina_array_new(10);
|
||||||
|
|
||||||
#ifdef HAVE_SYS_RESOURCE_H
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
{
|
{
|
||||||
|
|
|
@ -355,5 +355,5 @@ extern int beta;
|
||||||
extern int had_quote;
|
extern int had_quote;
|
||||||
|
|
||||||
extern unsigned int max_open_files;
|
extern unsigned int max_open_files;
|
||||||
|
extern Eina_Array *requires;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -203,6 +203,7 @@ static void *_part_free(Edje_Part_Collection *pc, Edje_Part *ep);
|
||||||
static void check_has_anchors(void);
|
static void check_has_anchors(void);
|
||||||
|
|
||||||
static void st_id(void);
|
static void st_id(void);
|
||||||
|
static void st_requires(void);
|
||||||
static void st_efl_version(void);
|
static void st_efl_version(void);
|
||||||
static void st_externals_external(void);
|
static void st_externals_external(void);
|
||||||
|
|
||||||
|
@ -703,6 +704,7 @@ static void _handle_vector_image(void);
|
||||||
New_Statement_Handler statement_handlers[] =
|
New_Statement_Handler statement_handlers[] =
|
||||||
{
|
{
|
||||||
{"id", st_id},
|
{"id", st_id},
|
||||||
|
{"requires", st_requires},
|
||||||
{"efl_version", st_efl_version},
|
{"efl_version", st_efl_version},
|
||||||
{"externals.external", st_externals_external},
|
{"externals.external", st_externals_external},
|
||||||
IMAGE_STATEMENTS("")
|
IMAGE_STATEMENTS("")
|
||||||
|
@ -2243,10 +2245,47 @@ st_efl_version(void)
|
||||||
static void
|
static void
|
||||||
st_id(void)
|
st_id(void)
|
||||||
{
|
{
|
||||||
|
Eina_Array_Iterator it;
|
||||||
|
unsigned int i;
|
||||||
|
char *str, *id;
|
||||||
|
|
||||||
|
check_arg_count(1);
|
||||||
|
id = parse_str(0);
|
||||||
|
|
||||||
|
EINA_ARRAY_ITER_NEXT(requires, i, str, it)
|
||||||
|
if (eina_streq(str, id))
|
||||||
|
error_and_abort(NULL, "Cannot use same id for file as one of its required files!");
|
||||||
|
free((void*)edje_file->id);
|
||||||
|
edje_file->id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @edcsubsection{toplevel_requires,
|
||||||
|
* requires} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
@page edcref
|
||||||
|
|
||||||
|
@property
|
||||||
|
requires
|
||||||
|
@parameters
|
||||||
|
[name]
|
||||||
|
@effect
|
||||||
|
Specifying this property informs edje not to close the
|
||||||
|
file with the corresponding id property for as long as this
|
||||||
|
file is open. Multiple requires properties can be individually specified.
|
||||||
|
@since 1.21
|
||||||
|
@endproperty
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
st_requires(void)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
check_arg_count(1);
|
check_arg_count(1);
|
||||||
|
|
||||||
free(edje_file->id);
|
str = parse_str(0);
|
||||||
edje_file->id = parse_str(0);
|
if (eina_streq(str, edje_file->id))
|
||||||
|
error_and_abort(NULL, "Cannot require the current file!");
|
||||||
|
eina_array_push(requires, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @edcsubsection{toplevel_externals,
|
/** @edcsubsection{toplevel_externals,
|
||||||
|
@ -2353,7 +2392,7 @@ st_externals_external(void)
|
||||||
@property
|
@property
|
||||||
image
|
image
|
||||||
@parameters
|
@parameters
|
||||||
[image file] [compression method] (compression level)
|
[image file] [compression method] (compression level)(edje file id)
|
||||||
@effect
|
@effect
|
||||||
Used to include each image file. The full path to the directory holding
|
Used to include each image file. The full path to the directory holding
|
||||||
the images can be defined later with edje_cc's "-id" option.
|
the images can be defined later with edje_cc's "-id" option.
|
||||||
|
@ -2364,6 +2403,7 @@ st_externals_external(void)
|
||||||
@li LOSSY_ETC1 [0-100]: ETC1 lossy texture 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 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.
|
@li USER: Do not embed the file, refer to the external file instead.
|
||||||
|
@li EXTERNAL: The file exists in the edje file with the specified id.
|
||||||
|
|
||||||
Defaults: compression level for lossy methods is 90.
|
Defaults: compression level for lossy methods is 90.
|
||||||
@endproperty
|
@endproperty
|
||||||
|
@ -2417,6 +2457,7 @@ st_images_image(void)
|
||||||
"LOSSY_ETC1", 3,
|
"LOSSY_ETC1", 3,
|
||||||
"LOSSY_ETC2", 4,
|
"LOSSY_ETC2", 4,
|
||||||
"USER", 5,
|
"USER", 5,
|
||||||
|
"EXTERNAL", 6,
|
||||||
NULL);
|
NULL);
|
||||||
if (v == 0)
|
if (v == 0)
|
||||||
{
|
{
|
||||||
|
@ -2448,16 +2489,29 @@ st_images_image(void)
|
||||||
img->source_type = EDJE_IMAGE_SOURCE_TYPE_USER;
|
img->source_type = EDJE_IMAGE_SOURCE_TYPE_USER;
|
||||||
img->source_param = 0;
|
img->source_param = 0;
|
||||||
}
|
}
|
||||||
|
else if (v == 6)
|
||||||
|
{
|
||||||
|
img->source_type = EDJE_IMAGE_SOURCE_TYPE_EXTERNAL;
|
||||||
|
img->source_param = 0;
|
||||||
|
img->external_id = parse_str(2);
|
||||||
|
}
|
||||||
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_ETC2))
|
(img->source_type == EDJE_IMAGE_SOURCE_TYPE_USER))
|
||||||
check_arg_count(2);
|
check_arg_count(2);
|
||||||
else
|
else if (img->source_type != EDJE_IMAGE_SOURCE_TYPE_EXTERNAL)
|
||||||
{
|
{
|
||||||
if (check_range_arg_count(2, 3) > 2)
|
if (check_range_arg_count(2, 3) > 2)
|
||||||
img->source_param = parse_int_range(2, 0, 100);
|
img->source_param = parse_int_range(2, 0, 100);
|
||||||
else
|
else
|
||||||
img->source_param = 90;
|
img->source_param = 90;
|
||||||
}
|
}
|
||||||
|
if (!edje_file->image_id_hash)
|
||||||
|
edje_file->image_id_hash = eina_hash_string_superfast_new(free);
|
||||||
|
{
|
||||||
|
Edje_Image_Hash *eih = mem_alloc(SZ(Edje_Image_Hash));
|
||||||
|
eih->id = img->id;
|
||||||
|
eina_hash_add(edje_file->image_id_hash, tmp, eih);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2736,7 +2790,7 @@ ob_images_set_image(void)
|
||||||
@property
|
@property
|
||||||
image
|
image
|
||||||
@parameters
|
@parameters
|
||||||
[image file] [compression method] (compression level)
|
[image file] [compression method] (compression level)(edje file id)
|
||||||
@effect
|
@effect
|
||||||
Used to include each image file. The full path to the directory holding
|
Used to include each image file. The full path to the directory holding
|
||||||
the images can be defined later with edje_cc's "-id" option.
|
the images can be defined later with edje_cc's "-id" option.
|
||||||
|
@ -2747,6 +2801,7 @@ ob_images_set_image(void)
|
||||||
@li LOSSY_ETC1 [0-100]: ETC1 lossy texture 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 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.
|
@li USER: Do not embed the file, refer to the external file instead.
|
||||||
|
@li EXTERNAL: The file exists in the edje file with the specified id.
|
||||||
|
|
||||||
Defaults: compression level for lossy methods is 90.
|
Defaults: compression level for lossy methods is 90.
|
||||||
@endproperty
|
@endproperty
|
||||||
|
|
|
@ -1381,7 +1381,7 @@ data_write_images(void)
|
||||||
Image_Write *iw;
|
Image_Write *iw;
|
||||||
|
|
||||||
img = &edje_file->image_dir->entries[cur_image_entry];
|
img = &edje_file->image_dir->entries[cur_image_entry];
|
||||||
if ((img->source_type == EDJE_IMAGE_SOURCE_TYPE_USER) || !img->entry)
|
if ((img->source_type >= EDJE_IMAGE_SOURCE_TYPE_USER) || !img->entry)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1 ||
|
if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1 ||
|
||||||
|
@ -1452,7 +1452,7 @@ data_write_images(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (img->source_type != EDJE_IMAGE_SOURCE_TYPE_USER)
|
if (img->source_type < EDJE_IMAGE_SOURCE_TYPE_USER)
|
||||||
{
|
{
|
||||||
ext = strrchr(img->entry, '.');
|
ext = strrchr(img->entry, '.');
|
||||||
if (ext && (!strcasecmp(ext, ".svg") || !strcasecmp(ext, ".svgz")))
|
if (ext && (!strcasecmp(ext, ".svg") || !strcasecmp(ext, ".svgz")))
|
||||||
|
@ -2713,6 +2713,20 @@ data_write(void)
|
||||||
EFL_VERSION_MAJOR, EFL_VERSION_MINOR);
|
EFL_VERSION_MAJOR, EFL_VERSION_MINOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (eina_array_count(requires))
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
edje_file->requires_count = eina_array_count(requires);
|
||||||
|
edje_file->requires = mem_alloc(edje_file->requires_count * sizeof(void*));
|
||||||
|
do
|
||||||
|
{
|
||||||
|
edje_file->requires[i] = eina_array_pop(requires);
|
||||||
|
i++;
|
||||||
|
} while (eina_array_count(requires));
|
||||||
|
eina_array_free(requires);
|
||||||
|
}
|
||||||
|
|
||||||
check_groups(ef);
|
check_groups(ef);
|
||||||
|
|
||||||
ecore_thread_max_set(ecore_thread_max_get() * 2);
|
ecore_thread_max_set(ecore_thread_max_get() * 2);
|
||||||
|
@ -3947,7 +3961,7 @@ free_group:
|
||||||
|
|
||||||
if ((de->entry) && (!strcmp(de->entry, image->name)))
|
if ((de->entry) && (!strcmp(de->entry, image->name)))
|
||||||
{
|
{
|
||||||
if (de->source_type == EDJE_IMAGE_SOURCE_TYPE_USER)
|
if (de->source_type >= EDJE_IMAGE_SOURCE_TYPE_USER)
|
||||||
*(image->dest) = -de->id - 1;
|
*(image->dest) = -de->id - 1;
|
||||||
else
|
else
|
||||||
*(image->dest) = de->id;
|
*(image->dest) = de->id;
|
||||||
|
|
|
@ -304,6 +304,7 @@ output(void)
|
||||||
if ((ei->source_type > EDJE_IMAGE_SOURCE_TYPE_NONE) &&
|
if ((ei->source_type > EDJE_IMAGE_SOURCE_TYPE_NONE) &&
|
||||||
(ei->source_type < EDJE_IMAGE_SOURCE_TYPE_LAST) &&
|
(ei->source_type < EDJE_IMAGE_SOURCE_TYPE_LAST) &&
|
||||||
(ei->source_type != EDJE_IMAGE_SOURCE_TYPE_USER) &&
|
(ei->source_type != EDJE_IMAGE_SOURCE_TYPE_USER) &&
|
||||||
|
(ei->source_type != EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) &&
|
||||||
(ei->entry))
|
(ei->entry))
|
||||||
{
|
{
|
||||||
Ecore_Evas *ee;
|
Ecore_Evas *ee;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include "edje_private.h"
|
#include "edje_private.h"
|
||||||
|
|
||||||
Eina_Hash *_edje_file_hash = NULL;
|
Eina_Hash *_edje_file_hash = NULL;
|
||||||
|
Eina_Hash *_edje_id_hash = NULL;
|
||||||
|
|
||||||
|
static Eina_Hash *_edje_requires_pending;
|
||||||
static int _edje_file_cache_size = 16;
|
static int _edje_file_cache_size = 16;
|
||||||
static Eina_List *_edje_file_cache = NULL;
|
static Eina_List *_edje_file_cache = NULL;
|
||||||
|
|
||||||
|
@ -387,6 +389,46 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool coll
|
||||||
if (sc->name)
|
if (sc->name)
|
||||||
eina_hash_direct_add(edf->size_hash, sc->name, sc);
|
eina_hash_direct_add(edf->size_hash, sc->name, sc);
|
||||||
|
|
||||||
|
if (edf->requires_count)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
Edje_File *required_edf;
|
||||||
|
char **requires = (char**)edf->requires;
|
||||||
|
|
||||||
|
/* EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING returns an mmapped blob, not stringshares */
|
||||||
|
edf->requires = malloc(edf->requires_count * sizeof(char*));
|
||||||
|
for (i = 0; i < edf->requires_count; i++)
|
||||||
|
{
|
||||||
|
char *str = (char*)requires[i];
|
||||||
|
|
||||||
|
edf->requires[i] = eina_stringshare_add(str);
|
||||||
|
required_edf = eina_hash_find(_edje_id_hash, edf->requires[i]);
|
||||||
|
if (required_edf)
|
||||||
|
{
|
||||||
|
required_edf->references++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ERR("edje file '%s' REQUIRES file '%s' which is not loaded", edf->path, edf->requires[i]);
|
||||||
|
if (!_edje_requires_pending)
|
||||||
|
_edje_requires_pending = eina_hash_stringshared_new(NULL);
|
||||||
|
eina_hash_list_append(_edje_requires_pending, edf->requires[i], edf);
|
||||||
|
}
|
||||||
|
free(requires);
|
||||||
|
}
|
||||||
|
if (_edje_requires_pending && edf->id)
|
||||||
|
{
|
||||||
|
l = eina_hash_set(_edje_requires_pending, edf->id, NULL);
|
||||||
|
|
||||||
|
edf->references += eina_list_count(l);
|
||||||
|
eina_list_free(l);
|
||||||
|
|
||||||
|
if (!eina_hash_population(_edje_requires_pending))
|
||||||
|
{
|
||||||
|
eina_hash_free(_edje_requires_pending);
|
||||||
|
_edje_requires_pending = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return edf;
|
return edf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,6 +458,8 @@ _edje_cache_file_coll_open(const Eina_File *file, const char *coll, int *error_r
|
||||||
Edje_Part_Collection *edc;
|
Edje_Part_Collection *edc;
|
||||||
Edje_Part *ep;
|
Edje_Part *ep;
|
||||||
|
|
||||||
|
if (!_edje_id_hash)
|
||||||
|
_edje_id_hash = eina_hash_stringshared_new(NULL);
|
||||||
if (!_edje_file_hash)
|
if (!_edje_file_hash)
|
||||||
{
|
{
|
||||||
_edje_file_hash = eina_hash_pointer_new(NULL);
|
_edje_file_hash = eina_hash_pointer_new(NULL);
|
||||||
|
@ -445,6 +489,8 @@ find_list:
|
||||||
if (!edf) return NULL;
|
if (!edf) return NULL;
|
||||||
|
|
||||||
eina_hash_direct_add(_edje_file_hash, &edf->f, edf);
|
eina_hash_direct_add(_edje_file_hash, &edf->f, edf);
|
||||||
|
if (edf->id)
|
||||||
|
eina_hash_list_append(_edje_id_hash, edf->id, edf);
|
||||||
/* return edf; */
|
/* return edf; */
|
||||||
|
|
||||||
open:
|
open:
|
||||||
|
@ -648,12 +694,41 @@ _edje_cache_file_unref(Edje_File *edf)
|
||||||
edf->references--;
|
edf->references--;
|
||||||
if (edf->references != 0) return;
|
if (edf->references != 0) return;
|
||||||
|
|
||||||
|
if (edf->requires_count)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < edf->requires_count; i++)
|
||||||
|
{
|
||||||
|
Edje_File *required_edf = eina_hash_find(_edje_id_hash, edf->requires[i]);
|
||||||
|
|
||||||
|
if (required_edf)
|
||||||
|
_edje_cache_file_unref(edf);
|
||||||
|
else if (_edje_requires_pending)
|
||||||
|
{
|
||||||
|
eina_hash_list_remove(_edje_requires_pending, edf->requires[i], edf);
|
||||||
|
if (!eina_hash_population(_edje_requires_pending))
|
||||||
|
{
|
||||||
|
eina_hash_free(_edje_requires_pending);
|
||||||
|
_edje_requires_pending = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (edf->dangling)
|
if (edf->dangling)
|
||||||
{
|
{
|
||||||
_edje_file_free(edf);
|
_edje_file_free(edf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (edf->id)
|
||||||
|
eina_hash_list_remove(_edje_id_hash, edf->id, edf);
|
||||||
|
if (!eina_hash_population(_edje_id_hash))
|
||||||
|
{
|
||||||
|
eina_hash_free(_edje_id_hash);
|
||||||
|
_edje_id_hash = NULL;
|
||||||
|
}
|
||||||
eina_hash_del(_edje_file_hash, &edf->f, edf);
|
eina_hash_del(_edje_file_hash, &edf->f, edf);
|
||||||
if (!eina_hash_population(_edje_file_hash))
|
if (!eina_hash_population(_edje_file_hash))
|
||||||
{
|
{
|
||||||
|
|
|
@ -596,6 +596,100 @@ _edje_image_find(Evas_Object *obj, Edje *ed, Edje_Real_Part_Set **eps,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_edje_real_part_image_error_check(Edje_Real_Part *ep)
|
||||||
|
{
|
||||||
|
switch (evas_object_image_load_error_get(ep->object))
|
||||||
|
{
|
||||||
|
case EVAS_LOAD_ERROR_GENERIC:
|
||||||
|
ERR("Error type: EVAS_LOAD_ERROR_GENERIC");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVAS_LOAD_ERROR_DOES_NOT_EXIST:
|
||||||
|
ERR("Error type: EVAS_LOAD_ERROR_DOES_NOT_EXIST");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVAS_LOAD_ERROR_PERMISSION_DENIED:
|
||||||
|
ERR("Error type: EVAS_LOAD_ERROR_PERMISSION_DENIED");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
|
||||||
|
ERR("Error type: EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVAS_LOAD_ERROR_CORRUPT_FILE:
|
||||||
|
ERR("Error type: EVAS_LOAD_ERROR_CORRUPT_FILE");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVAS_LOAD_ERROR_UNKNOWN_FORMAT:
|
||||||
|
ERR("Error type: EVAS_LOAD_ERROR_UNKNOWN_FORMAT");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ERR("Error type: ???");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_edje_real_part_image_internal_set(Edje_File *edf, Edje_Real_Part *ep, int image_id)
|
||||||
|
{
|
||||||
|
char buf[1024] = "edje/images/";
|
||||||
|
|
||||||
|
/* Replace snprint("edje/images/%i") == memcpy + itoa */
|
||||||
|
eina_convert_itoa(image_id, buf + 12); /* No need to check length as 2³² need only 10 characteres. */
|
||||||
|
|
||||||
|
evas_object_image_mmap_set(ep->object, edf->f, buf);
|
||||||
|
if (evas_object_image_load_error_get(ep->object) != EVAS_LOAD_ERROR_NONE)
|
||||||
|
{
|
||||||
|
ERR("Error loading image collection \"%s\" from "
|
||||||
|
"file \"%s\". Missing EET Evas loader module?",
|
||||||
|
buf, edf->path);
|
||||||
|
_edje_real_part_image_error_check(ep);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_edje_real_part_image_external_set(Edje_File *edf, Edje_Real_Part *ep, int image_id)
|
||||||
|
{
|
||||||
|
Edje_Image_Directory_Entry *ie;
|
||||||
|
|
||||||
|
if (!edf->image_dir) return EINA_FALSE;
|
||||||
|
ie = edf->image_dir->entries + (-image_id) - 1;
|
||||||
|
if ((ie) &&
|
||||||
|
(ie->source_type == EDJE_IMAGE_SOURCE_TYPE_USER) &&
|
||||||
|
(ie->entry))
|
||||||
|
{
|
||||||
|
evas_object_image_file_set(ep->object, ie->entry, NULL);
|
||||||
|
_edje_real_part_image_error_check(ep);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
else if ((ie) &&
|
||||||
|
(ie->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) &&
|
||||||
|
(ie->entry))
|
||||||
|
{
|
||||||
|
Edje_File *edff;
|
||||||
|
Eina_List *l, *ll;
|
||||||
|
|
||||||
|
l = eina_hash_find(_edje_id_hash, ie->external_id);
|
||||||
|
EINA_LIST_FOREACH(l, ll, edff)
|
||||||
|
{
|
||||||
|
Edje_Image_Hash *eih = eina_hash_find(edff->image_id_hash, ie->entry);
|
||||||
|
|
||||||
|
if (!eih) continue;
|
||||||
|
if (eih->id < 0)
|
||||||
|
return _edje_real_part_image_external_set(edff, ep, eih->id);
|
||||||
|
else
|
||||||
|
_edje_real_part_image_internal_set(edff, ep, eih->id);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_edje_real_part_image_set(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_Set **set, FLOAT_T pos)
|
_edje_real_part_image_set(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_Set **set, FLOAT_T pos)
|
||||||
{
|
{
|
||||||
|
@ -609,16 +703,7 @@ _edje_real_part_image_set(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_Set **set
|
||||||
if (set) *set = ep->param1.set;
|
if (set) *set = ep->param1.set;
|
||||||
if (image_id < 0)
|
if (image_id < 0)
|
||||||
{
|
{
|
||||||
Edje_Image_Directory_Entry *ie;
|
_edje_real_part_image_external_set(ed->file, ep, image_id);
|
||||||
|
|
||||||
if (!ed->file->image_dir) ie = NULL;
|
|
||||||
else ie = ed->file->image_dir->entries + (-image_id) - 1;
|
|
||||||
if ((ie) &&
|
|
||||||
(ie->source_type == EDJE_IMAGE_SOURCE_TYPE_USER) &&
|
|
||||||
(ie->entry))
|
|
||||||
{
|
|
||||||
evas_object_image_file_set(ep->object, ie->entry, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -659,58 +744,18 @@ _edje_real_part_image_set(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_Set **set
|
||||||
}
|
}
|
||||||
if (image_id < 0)
|
if (image_id < 0)
|
||||||
{
|
{
|
||||||
ERR("Part \"%s\" description, "
|
if (!_edje_real_part_image_external_set(ed->file, ep, image_id))
|
||||||
"\"%s\" %3.3f with image %i index has a missing image id in a set of %i !!!",
|
ERR("Part \"%s\" description, "
|
||||||
ep->part->name,
|
"\"%s\" %3.3f with image %i index has a missing image id in a set of %i !!!",
|
||||||
ep->param1.description->state.name,
|
ep->part->name,
|
||||||
ep->param1.description->state.value,
|
ep->param1.description->state.name,
|
||||||
image_num,
|
ep->param1.description->state.value,
|
||||||
image_count);
|
image_num,
|
||||||
|
image_count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char buf[1024] = "edje/images/";
|
_edje_real_part_image_internal_set(ed->file, ep, image_id);
|
||||||
|
|
||||||
/* Replace snprint("edje/images/%i") == memcpy + itoa */
|
|
||||||
eina_convert_itoa(image_id, buf + 12); /* No need to check length as 2³² need only 10 characteres. */
|
|
||||||
|
|
||||||
evas_object_image_mmap_set(ep->object, ed->file->f, buf);
|
|
||||||
if (evas_object_image_load_error_get(ep->object) != EVAS_LOAD_ERROR_NONE)
|
|
||||||
{
|
|
||||||
ERR("Error loading image collection \"%s\" from "
|
|
||||||
"file \"%s\". Missing EET Evas loader module?",
|
|
||||||
buf, ed->file->path);
|
|
||||||
switch (evas_object_image_load_error_get(ep->object))
|
|
||||||
{
|
|
||||||
case EVAS_LOAD_ERROR_GENERIC:
|
|
||||||
ERR("Error type: EVAS_LOAD_ERROR_GENERIC");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVAS_LOAD_ERROR_DOES_NOT_EXIST:
|
|
||||||
ERR("Error type: EVAS_LOAD_ERROR_DOES_NOT_EXIST");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVAS_LOAD_ERROR_PERMISSION_DENIED:
|
|
||||||
ERR("Error type: EVAS_LOAD_ERROR_PERMISSION_DENIED");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
|
|
||||||
ERR("Error type: EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVAS_LOAD_ERROR_CORRUPT_FILE:
|
|
||||||
ERR("Error type: EVAS_LOAD_ERROR_CORRUPT_FILE");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVAS_LOAD_ERROR_UNKNOWN_FORMAT:
|
|
||||||
ERR("Error type: EVAS_LOAD_ERROR_UNKNOWN_FORMAT");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
ERR("Error type: ???");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ Eet_Data_Descriptor *_edje_edd_edje_size_class = NULL;
|
||||||
Eet_Data_Descriptor *_edje_edd_edje_external_directory = NULL;
|
Eet_Data_Descriptor *_edje_edd_edje_external_directory = NULL;
|
||||||
Eet_Data_Descriptor *_edje_edd_edje_external_directory_entry = NULL;
|
Eet_Data_Descriptor *_edje_edd_edje_external_directory_entry = NULL;
|
||||||
Eet_Data_Descriptor *_edje_edd_edje_font_directory_entry = NULL;
|
Eet_Data_Descriptor *_edje_edd_edje_font_directory_entry = NULL;
|
||||||
|
Eet_Data_Descriptor *_edje_edd_edje_image_id_hash = NULL;
|
||||||
Eet_Data_Descriptor *_edje_edd_edje_image_directory = NULL;
|
Eet_Data_Descriptor *_edje_edd_edje_image_directory = NULL;
|
||||||
Eet_Data_Descriptor *_edje_edd_edje_image_directory_entry = NULL;
|
Eet_Data_Descriptor *_edje_edd_edje_image_directory_entry = NULL;
|
||||||
Eet_Data_Descriptor *_edje_edd_edje_image_directory_set = NULL;
|
Eet_Data_Descriptor *_edje_edd_edje_image_directory_set = NULL;
|
||||||
|
@ -253,6 +254,7 @@ _edje_edd_shutdown(void)
|
||||||
FREED(_edje_edd_edje_external_directory);
|
FREED(_edje_edd_edje_external_directory);
|
||||||
FREED(_edje_edd_edje_external_directory_entry);
|
FREED(_edje_edd_edje_external_directory_entry);
|
||||||
FREED(_edje_edd_edje_font_directory_entry);
|
FREED(_edje_edd_edje_font_directory_entry);
|
||||||
|
FREED(_edje_edd_edje_image_id_hash);
|
||||||
FREED(_edje_edd_edje_image_directory);
|
FREED(_edje_edd_edje_image_directory);
|
||||||
FREED(_edje_edd_edje_image_directory_entry);
|
FREED(_edje_edd_edje_image_directory_entry);
|
||||||
FREED(_edje_edd_edje_image_directory_set);
|
FREED(_edje_edd_edje_image_directory_set);
|
||||||
|
@ -374,6 +376,11 @@ _edje_edd_init(void)
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_font_directory_entry, Edje_Font_Directory_Entry, "entry", entry, EET_T_STRING);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_font_directory_entry, Edje_Font_Directory_Entry, "entry", entry, EET_T_STRING);
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_font_directory_entry, Edje_Font_Directory_Entry, "file", file, EET_T_STRING);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_font_directory_entry, Edje_Font_Directory_Entry, "file", file, EET_T_STRING);
|
||||||
|
|
||||||
|
/* image hash */
|
||||||
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Hash);
|
||||||
|
_edje_edd_edje_image_id_hash = eet_data_descriptor_file_new(&eddc);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_id_hash, Edje_Image_Hash, "id", id, EET_T_INT);
|
||||||
|
|
||||||
/* image directory */
|
/* image directory */
|
||||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Entry);
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Entry);
|
||||||
_edje_edd_edje_image_directory_entry =
|
_edje_edd_edje_image_directory_entry =
|
||||||
|
@ -382,6 +389,7 @@ _edje_edd_init(void)
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_type", source_type, EET_T_INT);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_type", source_type, EET_T_INT);
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_param", source_param, EET_T_INT);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_param", source_param, EET_T_INT);
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "id", id, EET_T_INT);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "id", id, EET_T_INT);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "external_id", external_id, EET_T_STRING);
|
||||||
|
|
||||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set_Entry);
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set_Entry);
|
||||||
_edje_edd_edje_image_directory_set_entry =
|
_edje_edd_edje_image_directory_set_entry =
|
||||||
|
@ -614,6 +622,7 @@ _edje_edd_init(void)
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "efl_version.minor", efl_version.minor, EET_T_INT);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "efl_version.minor", efl_version.minor, EET_T_INT);
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "base_scale", base_scale, EDJE_T_FLOAT);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "base_scale", base_scale, EDJE_T_FLOAT);
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "id", id, EET_T_STRING);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "id", id, EET_T_STRING);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING(_edje_edd_edje_file, Edje_File, "requires", requires);
|
||||||
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "external_dir", external_dir, _edje_edd_edje_external_directory);
|
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "external_dir", external_dir, _edje_edd_edje_external_directory);
|
||||||
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "image_dir", image_dir, _edje_edd_edje_image_directory);
|
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "image_dir", image_dir, _edje_edd_edje_image_directory);
|
||||||
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "model_dir", model_dir, _edje_edd_edje_model_directory);
|
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "model_dir", model_dir, _edje_edd_edje_model_directory);
|
||||||
|
@ -630,6 +639,7 @@ _edje_edd_init(void)
|
||||||
EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "data", data, _edje_edd_edje_string);
|
EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "data", data, _edje_edd_edje_string);
|
||||||
EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "fonts", fonts, _edje_edd_edje_font_directory_entry);
|
EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "fonts", fonts, _edje_edd_edje_font_directory_entry);
|
||||||
EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "collection", collection, _edje_edd_edje_part_collection_directory_entry);
|
EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "collection", collection, _edje_edd_edje_part_collection_directory_entry);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "image_id_hash", image_id_hash, _edje_edd_edje_image_id_hash);
|
||||||
|
|
||||||
/* parts & limit & programs - loaded induvidually */
|
/* parts & limit & programs - loaded induvidually */
|
||||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Limit);
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Limit);
|
||||||
|
|
|
@ -2111,6 +2111,16 @@ _edje_file_free(Edje_File *edf)
|
||||||
HASH_FREE(edf->fonts);
|
HASH_FREE(edf->fonts);
|
||||||
HASH_FREE(edf->collection);
|
HASH_FREE(edf->collection);
|
||||||
HASH_FREE(edf->data);
|
HASH_FREE(edf->data);
|
||||||
|
HASH_FREE(edf->image_id_hash);
|
||||||
|
|
||||||
|
if (edf->requires_count)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < edf->requires_count; i++)
|
||||||
|
eina_stringshare_del(edf->requires[i]);
|
||||||
|
free(edf->requires);
|
||||||
|
}
|
||||||
|
|
||||||
if (edf->image_dir)
|
if (edf->image_dir)
|
||||||
{
|
{
|
||||||
|
|
|
@ -430,7 +430,8 @@ typedef struct _Edje_Signal_Callback_Custom Edje_Signal_Callback_Custom;
|
||||||
#define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1 3
|
#define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1 3
|
||||||
#define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC2 4
|
#define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC2 4
|
||||||
#define EDJE_IMAGE_SOURCE_TYPE_USER 5
|
#define EDJE_IMAGE_SOURCE_TYPE_USER 5
|
||||||
#define EDJE_IMAGE_SOURCE_TYPE_LAST 6
|
#define EDJE_IMAGE_SOURCE_TYPE_EXTERNAL 6
|
||||||
|
#define EDJE_IMAGE_SOURCE_TYPE_LAST 7
|
||||||
|
|
||||||
#define EDJE_SOUND_SOURCE_TYPE_NONE 0
|
#define EDJE_SOUND_SOURCE_TYPE_NONE 0
|
||||||
#define EDJE_SOUND_SOURCE_TYPE_INLINE_RAW 1
|
#define EDJE_SOUND_SOURCE_TYPE_INLINE_RAW 1
|
||||||
|
@ -551,6 +552,11 @@ struct _AABB {
|
||||||
int rel_to;
|
int rel_to;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct Edje_Image_Hash
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
} Edje_Image_Hash;
|
||||||
|
|
||||||
struct _Edje_File
|
struct _Edje_File
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
|
@ -563,6 +569,10 @@ struct _Edje_File
|
||||||
Edje_Mo_Directory *mo_dir;
|
Edje_Mo_Directory *mo_dir;
|
||||||
Edje_Gfx_Filter_Directory *filter_dir;
|
Edje_Gfx_Filter_Directory *filter_dir;
|
||||||
|
|
||||||
|
Eina_Hash *image_id_hash;
|
||||||
|
Eina_Stringshare **requires;
|
||||||
|
unsigned int requires_count;
|
||||||
|
|
||||||
Eina_List *styles;
|
Eina_List *styles;
|
||||||
|
|
||||||
Eina_List *color_tree;
|
Eina_List *color_tree;
|
||||||
|
@ -682,6 +692,7 @@ struct _Edje_Image_Directory_Entry
|
||||||
const char *entry; /* the nominal name of the image - if any */
|
const char *entry; /* the nominal name of the image - if any */
|
||||||
int source_type; /* alternate source mode. 0 = none */
|
int source_type; /* alternate source mode. 0 = none */
|
||||||
int source_param; /* extra params on encoding */
|
int source_param; /* extra params on encoding */
|
||||||
|
Eina_Stringshare *external_id;
|
||||||
int id; /* the id no. of the image */
|
int id; /* the id no. of the image */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2377,6 +2388,7 @@ extern Eina_Cow *_edje_calc_params_map_cow;
|
||||||
extern Eina_Cow *_edje_calc_params_physics_cow;
|
extern Eina_Cow *_edje_calc_params_physics_cow;
|
||||||
|
|
||||||
extern Eina_Hash *_edje_file_hash;
|
extern Eina_Hash *_edje_file_hash;
|
||||||
|
extern Eina_Hash *_edje_id_hash;
|
||||||
|
|
||||||
extern const char *_edje_language;
|
extern const char *_edje_language;
|
||||||
extern const char *_edje_cache_path;
|
extern const char *_edje_cache_path;
|
||||||
|
|
Loading…
Reference in New Issue