2010-10-07 12:52:47 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
2006-01-14 04:13:38 -08:00
|
|
|
#endif
|
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
#include <string.h>
|
2006-01-14 04:13:38 -08:00
|
|
|
|
2013-06-20 03:53:29 -07:00
|
|
|
#include "evas_common_private.h"
|
2013-06-03 19:17:21 -07:00
|
|
|
#include "evas_private.h"
|
2018-02-12 11:52:28 -08:00
|
|
|
#include "../../static_libs/buildsystem/buildsystem.h"
|
2009-09-23 00:12:11 -07:00
|
|
|
|
2006-01-14 04:13:38 -08:00
|
|
|
|
2013-07-01 19:00:44 -07:00
|
|
|
#ifndef EVAS_MODULE_NO_ENGINES
|
|
|
|
#define EVAS_MODULE_NO_ENGINES 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef EVAS_MODULE_NO_IMAGE_LOADERS
|
|
|
|
#define EVAS_MODULE_NO_IMAGE_LOADERS 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef EVAS_MODULE_NO_IMAGE_SAVERS
|
|
|
|
#define EVAS_MODULE_NO_IMAGE_SAVERS 0
|
|
|
|
#endif
|
|
|
|
|
2016-10-12 02:39:10 -07:00
|
|
|
#ifndef EVAS_MODULE_NO_VG_LOADERS
|
|
|
|
#define EVAS_MODULE_NO_VG_LOADERS 0
|
|
|
|
#endif
|
|
|
|
|
2016-10-13 23:52:51 -07:00
|
|
|
#ifndef EVAS_MODULE_NO_VG_SAVERS
|
|
|
|
#define EVAS_MODULE_NO_VG_SAVERS 0
|
|
|
|
#endif
|
|
|
|
|
2016-12-06 11:34:56 -08:00
|
|
|
typedef struct _Evas_Module_Task Evas_Module_Task;
|
|
|
|
struct _Evas_Module_Task
|
|
|
|
{
|
|
|
|
Eina_Bool (*cancelled)(void *data);
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
static Eina_TLS task = 0;
|
|
|
|
|
evas: Rename EAPI macro to EVAS_API in Evas library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
This patch is from a series of patches to rename EAPI symbols to
specific library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
LIBAPI is the only solution that works for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Reviewers: vtorri, woohyun, jptiz, lucas
Reviewed By: vtorri, lucas
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12214
2020-12-15 18:02:20 -08:00
|
|
|
EVAS_API Eina_Bool
|
2016-12-06 11:34:56 -08:00
|
|
|
evas_module_task_cancelled(void)
|
|
|
|
{
|
|
|
|
Evas_Module_Task *t;
|
|
|
|
|
|
|
|
t = eina_tls_get(task);
|
|
|
|
if (!t) return EINA_FALSE;
|
|
|
|
|
|
|
|
return t->cancelled(t->data);
|
|
|
|
}
|
|
|
|
|
evas: Rename EAPI macro to EVAS_API in Evas library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
This patch is from a series of patches to rename EAPI symbols to
specific library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
LIBAPI is the only solution that works for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Reviewers: vtorri, woohyun, jptiz, lucas
Reviewed By: vtorri, lucas
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12214
2020-12-15 18:02:20 -08:00
|
|
|
EVAS_API void
|
2016-12-06 11:34:56 -08:00
|
|
|
evas_module_task_register(Eina_Bool (*cancelled)(void *data), void *data)
|
|
|
|
{
|
|
|
|
Evas_Module_Task *t;
|
|
|
|
|
|
|
|
t = malloc(sizeof (Evas_Module_Task));
|
|
|
|
if (!t) return ;
|
|
|
|
|
|
|
|
t->cancelled = cancelled;
|
|
|
|
t->data = data;
|
|
|
|
|
|
|
|
eina_tls_set(task, t);
|
|
|
|
}
|
|
|
|
|
evas: Rename EAPI macro to EVAS_API in Evas library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
This patch is from a series of patches to rename EAPI symbols to
specific library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
LIBAPI is the only solution that works for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Reviewers: vtorri, woohyun, jptiz, lucas
Reviewed By: vtorri, lucas
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12214
2020-12-15 18:02:20 -08:00
|
|
|
EVAS_API void
|
2016-12-06 11:34:56 -08:00
|
|
|
evas_module_task_unregister(void)
|
|
|
|
{
|
|
|
|
Evas_Module_Task *t;
|
|
|
|
|
|
|
|
t = eina_tls_get(task);
|
|
|
|
if (!t) return ;
|
|
|
|
|
|
|
|
eina_tls_set(task, NULL);
|
|
|
|
free(t);
|
|
|
|
}
|
2013-07-01 19:00:44 -07:00
|
|
|
|
2016-10-13 23:52:51 -07:00
|
|
|
static Eina_Hash *evas_modules[6] = {
|
|
|
|
NULL,
|
2016-10-12 02:39:10 -07:00
|
|
|
NULL,
|
2009-06-16 06:01:36 -07:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2008-10-21 09:31:05 -07:00
|
|
|
static Eina_List *evas_module_paths = NULL;
|
2009-06-16 06:01:36 -07:00
|
|
|
static Eina_Array *evas_engines = NULL;
|
2006-01-14 04:13:38 -08:00
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
static Eina_List *
|
|
|
|
_evas_module_append(Eina_List *list, char *path)
|
2006-01-14 04:13:38 -08:00
|
|
|
{
|
2009-06-16 06:01:36 -07:00
|
|
|
if (path)
|
2006-01-14 04:13:38 -08:00
|
|
|
{
|
2014-07-01 04:25:04 -07:00
|
|
|
if (evas_file_path_exists(path))
|
|
|
|
list = eina_list_append(list, path);
|
|
|
|
else
|
|
|
|
free(path);
|
2006-01-14 04:13:38 -08:00
|
|
|
}
|
2009-06-16 06:01:36 -07:00
|
|
|
return list;
|
2006-01-14 04:13:38 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* this will alloc a list of paths to search for the modules */
|
|
|
|
/* by now these are: */
|
|
|
|
/* 1. ~/.evas/modules/ */
|
2007-10-17 02:29:18 -07:00
|
|
|
/* 2. $(EVAS_MODULE_DIR)/evas/modules/ */
|
2006-01-14 04:13:38 -08:00
|
|
|
/* 3. dladdr/evas/modules/ */
|
2007-10-17 02:29:18 -07:00
|
|
|
/* 4. PREFIX/evas/modules/ */
|
2006-01-14 04:13:38 -08:00
|
|
|
void
|
|
|
|
evas_module_paths_init(void)
|
|
|
|
{
|
2012-07-31 23:29:26 -07:00
|
|
|
char *libdir, *path;
|
2007-08-13 05:13:03 -07:00
|
|
|
|
2017-02-03 05:49:38 -08:00
|
|
|
#ifdef NEED_RUN_IN_TREE
|
2014-01-08 05:06:41 -08:00
|
|
|
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
|
|
|
|
if (getuid() == geteuid())
|
|
|
|
#endif
|
2013-01-04 09:19:43 -08:00
|
|
|
{
|
2019-08-08 15:55:40 -07:00
|
|
|
static signed char run_in_tree = -1;
|
|
|
|
|
|
|
|
if (run_in_tree == -1)
|
|
|
|
{
|
|
|
|
if (getenv("EFL_RUN_IN_TREE")) run_in_tree = 1;
|
|
|
|
else run_in_tree = 0;
|
|
|
|
}
|
|
|
|
if (run_in_tree == 1)
|
2013-01-04 09:19:43 -08:00
|
|
|
{
|
2014-01-08 02:46:23 -08:00
|
|
|
struct stat st;
|
|
|
|
const char mp[] = PACKAGE_BUILD_DIR"/src/modules/evas";
|
|
|
|
if (stat(mp, &st) == 0)
|
|
|
|
{
|
|
|
|
evas_module_paths = _evas_module_append(evas_module_paths, strdup(mp));
|
|
|
|
return;
|
|
|
|
}
|
2013-01-04 09:19:43 -08:00
|
|
|
}
|
|
|
|
}
|
2017-02-03 05:49:38 -08:00
|
|
|
#endif
|
2013-01-04 09:19:43 -08:00
|
|
|
|
2014-01-08 02:46:23 -08:00
|
|
|
/* 1. libevas.so/../evas/modules/ */
|
2012-07-31 23:29:26 -07:00
|
|
|
libdir = (char *)_evas_module_libdir_get();
|
|
|
|
if (!libdir)
|
|
|
|
path = eina_module_symbol_path_get(evas_module_paths_init, "/evas/modules");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
path = malloc(strlen(libdir) + strlen("/evas/modules") + 1);
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
strcpy(path, libdir);
|
|
|
|
strcat(path, "/evas/modules");
|
|
|
|
}
|
|
|
|
}
|
2010-12-14 06:17:07 -08:00
|
|
|
if (eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
|
|
|
|
free(path);
|
2009-06-16 08:02:57 -07:00
|
|
|
else
|
2010-12-14 06:17:07 -08:00
|
|
|
evas_module_paths = _evas_module_append(evas_module_paths, path);
|
2007-10-17 02:29:18 -07:00
|
|
|
|
2014-01-08 02:46:23 -08:00
|
|
|
/* 2. PREFIX/lib/evas/modules/ */
|
2010-12-14 06:17:07 -08:00
|
|
|
path = PACKAGE_LIB_DIR "/evas/modules";
|
|
|
|
if (!eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
|
2006-01-31 22:19:38 -08:00
|
|
|
{
|
2014-07-01 04:25:04 -07:00
|
|
|
path = strdup(path);
|
|
|
|
if (path)
|
|
|
|
evas_module_paths = _evas_module_append(evas_module_paths, path);
|
2006-01-14 04:13:38 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-01 04:25:04 -07:00
|
|
|
#define EVAS_EINA_STATIC_MODULE_DEFINE(Tn, Name) \
|
|
|
|
Eina_Bool evas_##Tn##_##Name##_init(void); \
|
2009-06-16 06:01:36 -07:00
|
|
|
void evas_##Tn##_##Name##_shutdown(void);
|
|
|
|
|
2014-07-01 04:25:04 -07:00
|
|
|
#define EVAS_EINA_STATIC_MODULE_USE(Tn, Name) \
|
2009-06-16 06:01:36 -07:00
|
|
|
{ evas_##Tn##_##Name##_init, evas_##Tn##_##Name##_shutdown }
|
|
|
|
|
2013-07-01 19:00:44 -07:00
|
|
|
#if !EVAS_MODULE_NO_ENGINES
|
2009-06-16 06:01:36 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, buffer);
|
2018-08-14 14:12:07 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, drm);
|
2009-06-16 06:01:36 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, fb);
|
2014-07-11 03:13:37 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, gl_generic);
|
2018-08-14 14:12:07 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, gl_drm);
|
2009-06-16 06:01:36 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, gl_x11);
|
2010-11-16 05:09:14 -08:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, gl_sdl);
|
2010-07-27 17:16:06 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, software_8);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, software_8_x11);
|
2009-06-16 06:01:36 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, software_ddraw);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, software_gdi);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, software_generic);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, software_x11);
|
2018-08-14 14:12:07 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, wayland_shm);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(engine, wayland_egl);
|
2013-07-01 19:00:44 -07:00
|
|
|
#endif
|
|
|
|
|
2016-10-12 02:39:10 -07:00
|
|
|
#if !EVAS_MODULE_NO_VG_LOADERS
|
2016-10-13 01:09:39 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(vg_loader, eet);
|
2016-10-12 02:39:10 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(vg_loader, svg);
|
evas vector: support json loader for rlottie integration.
Summary:
Introduce a new evas json loader to support lottie animation.
This json loader uses rlottie library which is a new github open project.
These days most ui frameworks (windowpws, skia, qt, xamarin, react, nativescript) supports lottie,
the rlottie was designed to support lottie as a standalone library and compatible with efl as well.
To enable this,please install rlottie library then remove json disabler in meson_options.txt
For more information, See lottie/rlottie project and its a introdcution article:
https://airbnb.io/lottie/#/
https://github.com/samsung/rlottie
https://hermet.pe.kr/143
Co-authored-by: JunsuChoi <jsuya.choi@samsung.com>
{D8941}
{D8944}
Reviewers: #committers, jsuya, bu5hm4n
Subscribers: bu5hm4n, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8940
2019-06-21 01:30:19 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(vg_loader, json);
|
2016-10-12 02:39:10 -07:00
|
|
|
#endif
|
|
|
|
|
2013-07-01 19:00:44 -07:00
|
|
|
#if !EVAS_MODULE_NO_IMAGE_LOADERS
|
Evas: add avif evas loader and saver
Summary:
Add AV1 image file loader and saver to Evas
The loader can be tested with this code :
```
#include <stdlib.h>
#include <stdio.h>
#include <Eina.h>
#include <Ecore.h>
#include <Evas.h>
#include <Ecore_Evas.h>
static int i = 0;
static unsigned char _timer(void *data)
{
Evas_Object *o = (Evas_Object *)data;
if (i < evas_object_image_animated_frame_count_get(o))
{
evas_object_image_animated_frame_set(o, i);
i++;
return ECORE_CALLBACK_RENEW;
}
return ECORE_CALLBACK_DONE;
}
static void _quit(Ecore_Evas *ee)
{
ecore_main_loop_quit();
(void)ee;
}
int main(int argc, char *argv[])
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
int w,h;
Evas_Load_Error err;
if (argc < 2)
{
printf("usage : %s file\n", argv[0]);
return 1;
}
ecore_evas_init();
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
{
printf("no ee\n");
return 0;
}
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, "avif test");
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, argv[1], NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
argv[1], evas_load_error_str(err));
return 1;
}
evas_object_image_size_get(o, &w, &h);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
printf("animated : %s\n", evas_object_image_animated_get(o) ? "yes" : "no");
fflush(stdout);
if (evas_object_image_animated_get(o))
{
Ecore_Timer *timer;
printf("frame count : %d\n", evas_object_image_animated_frame_count_get(o));
printf("duration : %f\n", evas_object_image_animated_frame_duration_get(o,1,0));
printf("loop count : %d\n", evas_object_image_animated_loop_count_get(o));
fflush(stdout);
timer = ecore_timer_add(evas_object_image_animated_frame_duration_get(o,1,0), _timer, o);
}
ecore_evas_resize(ee, w, h);
ecore_evas_show(ee);
ecore_main_loop_begin();
ecore_evas_shutdown();
return 0;
}
```
non animated files : https://github.com/AOMediaCodec/libavif/tree/master/tests/data/originals
animated files : https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Netflix/avifs
to test the saver :
```
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <Eina.h>
#include <Ecore.h>
#include <Evas.h>
#include <Ecore_Evas.h>
void _quit(Ecore_Evas *ee)
{
ecore_main_loop_quit();
(void)ee;
}
static Evas_Object *
display_data(int w, int h, const char *title, unsigned int *data)
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
unsigned int *d;
ee = ecore_evas_new(NULL, 0, 0, w, h, NULL);
if (!ee)
return NULL;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, title);
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_image_size_set(o, w, h);
d = evas_object_image_data_get(o, 1);
for (int i = 0; i < w*h; i++)
d[i] = data[i];
evas_object_image_data_set(o, d);
evas_object_image_data_update_add(o, 0, 0, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
ecore_evas_show(ee);
return o;
}
static unsigned int *
display_file(const char *title, const char *filename, int *w, int *h)
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
Evas_Load_Error err;
unsigned int *data;
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
return NULL;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, title);
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, filename, NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
filename, evas_load_error_str(err));
fflush(stderr);
return NULL;
}
evas_object_image_size_get(o, w, h);
evas_object_image_fill_set(o, 0, 0, *w, *h);
evas_object_image_size_set(o, *w, *h);
evas_object_move(o, 0, 0);
evas_object_resize(o, *w, *h);
evas_object_show(o);
ecore_evas_resize(ee, *w, *h);
ecore_evas_show(ee);
data = evas_object_image_data_get(o, 1);
return data;
}
double psnr(int w, int h, unsigned int *data_orig, unsigned int *data)
{
unsigned char *iter_orig;
unsigned char *iter;
double psnr;
psnr = 0.0;
iter_orig = (unsigned char *)data_orig;
iter = (unsigned char *)data;
for (int i = 0; i < 4 * w * h; i++, iter_orig++, iter++)
psnr += (*iter_orig - *iter) * (*iter_orig - *iter);
psnr /= 4 * w * h;
psnr = 10 * log10(255.0 * 255.0 / psnr);
return psnr;
}
void compare(int quality, int w, int h, unsigned int *data_orig)
{
char title[1024];
char filename[1024];
unsigned char *data;
unsigned int *data_jpeg;
unsigned int *data_avif;
unsigned char *iter_orig;
unsigned char *iter_jpeg;
unsigned char *iter_avif;
double psnr_jpeg;
double psnr_avif;
Eina_File *f_jpeg;
Eina_File *f_avif;
size_t size_jpeg;
size_t size_avif;
/* jpeg */
snprintf(title, sizeof(title), "jpeg test quality %d", quality);
snprintf(filename, sizeof(filename), "test_%d.jpg", quality);
data_jpeg = display_file(title, filename, &w, &h);
if (!data_jpeg)
return;
f_jpeg = eina_file_open(filename, EINA_FALSE);
size_jpeg = eina_file_size_get(f_jpeg);
eina_file_close(f_jpeg);
fprintf(stderr, "size : %u\n", (unsigned int)size_jpeg);
fflush(stderr);
/* avif */
snprintf(title, sizeof(title), "avif test quality %d", quality);
snprintf(filename, sizeof(filename), "test_%d.avif", quality);
data_avif = display_file(title, filename, &w, &h);
if (!data_avif)
return;
f_avif = eina_file_open(filename, EINA_FALSE);
size_avif = eina_file_size_get(f_avif);
eina_file_close(f_avif);
fprintf(stderr, "size : %u\n", (unsigned int)size_avif);
fflush(stderr);
psnr_jpeg = psnr(w, h, data_orig, data_jpeg);
fprintf(stderr, "psnr jpeg : %f\n", psnr_jpeg);
fflush(stderr);
snprintf(title, sizeof(title), "jpeg vs orig (psnr: %.2f, size: %u b)", psnr_jpeg, (unsigned int)size_jpeg);
iter_orig = (unsigned char *)data_orig;
iter_jpeg = (unsigned char *)data_jpeg;
data = malloc(4*w*h);
for (int i = 0; i < 4*w*h; i++, iter_orig++, iter_jpeg++)
data[i] = abs(*iter_jpeg - *iter_orig);
display_data(w, h, title, (unsigned int *)data);
psnr_avif = psnr(w, h, data_orig, data_avif);
fprintf(stderr, "psnr avif : %f\n", psnr_avif);
fflush(stderr);
snprintf(title, sizeof(title), "avif vs orig (psnr: %.2f, size: %u b)", psnr_avif, (unsigned int)size_avif);
iter_orig = (unsigned char *)data_orig;
iter_avif = (unsigned char *)data_avif;
data = malloc(4*w*h);
for (int i = 0; i < 4*w*h; i++, iter_orig++, iter_avif++)
data[i] = abs(*iter_avif - *iter_orig);
display_data(w, h, title, (unsigned int *)data);
}
int main()
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
Evas_Load_Error err;
unsigned int *data;
int w,h;
ecore_evas_init();
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
return 1;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, "original");
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, "x1d-II-sample-02.fff", NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
"x1d-II-sample-02.fff", evas_load_error_str(err));
fflush(stderr);
return 1;
}
evas_object_image_size_get(o, &w, &h);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_image_size_set(o, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
data = evas_object_image_data_get(o, 1);
ecore_evas_resize(ee, w, h);
ecore_evas_show(ee);
/* evas_object_image_save(o, "test_100.jpg", NULL, "quality=100"); */
evas_object_image_save(o, "test_90.jpg", NULL, "quality=90");
/* evas_object_image_save(o, "test_70.jpg", NULL, "quality=70"); */
/* evas_object_image_save(o, "test_50.jpg", NULL, "quality=50"); */
/* evas_object_image_save(o, "test_100.avif", NULL, "quality=100"); */
evas_object_image_save(o, "test_90.avif", NULL, "quality=90");
/* evas_object_image_save(o, "test_70.avif", NULL, "quality=70"); */
/* evas_object_image_save(o, "test_50.avif", NULL, "quality=50"); */
compare(90, w, h, data);
ecore_main_loop_begin();
ecore_evas_shutdown();
return 0;
}
```
the raw file canbe found here : https://www.hasselblad.com/learn/sample-images/
Test Plan: test executable with avif files found in libavif project
Reviewers: raster, q66
Reviewed By: q66
Subscribers: q66, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12051
2020-07-15 10:51:27 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, avif);
|
2010-10-25 19:55:56 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, bmp);
|
2014-06-18 01:55:44 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, dds);
|
2011-06-03 22:33:37 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, eet);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, generic);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, gif);
|
2021-02-06 07:45:42 -08:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, heif);
|
2011-03-11 07:07:25 -08:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, ico);
|
2011-06-03 22:33:37 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, jpeg);
|
2013-09-28 05:28:41 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, jp2k);
|
2011-06-03 22:33:37 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, pmaps);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, png);
|
2011-04-24 12:45:43 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, psd);
|
2011-06-03 22:33:37 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, svg);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, tga);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, tiff);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, wbmp);
|
2012-09-02 23:22:59 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, webp);
|
2011-06-03 22:33:37 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, xpm);
|
2014-03-11 03:08:40 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, tgv);
|
2013-07-01 19:00:44 -07:00
|
|
|
#endif
|
|
|
|
|
2016-10-13 23:52:51 -07:00
|
|
|
#if !EVAS_MODULE_NO_VG_SAVERS
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(vg_saver, eet);
|
2017-01-27 03:54:47 -08:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(vg_saver, svg);
|
2016-10-13 23:52:51 -07:00
|
|
|
#endif
|
|
|
|
|
2013-07-01 19:00:44 -07:00
|
|
|
#if !EVAS_MODULE_NO_IMAGE_SAVERS
|
Evas: add avif evas loader and saver
Summary:
Add AV1 image file loader and saver to Evas
The loader can be tested with this code :
```
#include <stdlib.h>
#include <stdio.h>
#include <Eina.h>
#include <Ecore.h>
#include <Evas.h>
#include <Ecore_Evas.h>
static int i = 0;
static unsigned char _timer(void *data)
{
Evas_Object *o = (Evas_Object *)data;
if (i < evas_object_image_animated_frame_count_get(o))
{
evas_object_image_animated_frame_set(o, i);
i++;
return ECORE_CALLBACK_RENEW;
}
return ECORE_CALLBACK_DONE;
}
static void _quit(Ecore_Evas *ee)
{
ecore_main_loop_quit();
(void)ee;
}
int main(int argc, char *argv[])
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
int w,h;
Evas_Load_Error err;
if (argc < 2)
{
printf("usage : %s file\n", argv[0]);
return 1;
}
ecore_evas_init();
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
{
printf("no ee\n");
return 0;
}
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, "avif test");
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, argv[1], NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
argv[1], evas_load_error_str(err));
return 1;
}
evas_object_image_size_get(o, &w, &h);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
printf("animated : %s\n", evas_object_image_animated_get(o) ? "yes" : "no");
fflush(stdout);
if (evas_object_image_animated_get(o))
{
Ecore_Timer *timer;
printf("frame count : %d\n", evas_object_image_animated_frame_count_get(o));
printf("duration : %f\n", evas_object_image_animated_frame_duration_get(o,1,0));
printf("loop count : %d\n", evas_object_image_animated_loop_count_get(o));
fflush(stdout);
timer = ecore_timer_add(evas_object_image_animated_frame_duration_get(o,1,0), _timer, o);
}
ecore_evas_resize(ee, w, h);
ecore_evas_show(ee);
ecore_main_loop_begin();
ecore_evas_shutdown();
return 0;
}
```
non animated files : https://github.com/AOMediaCodec/libavif/tree/master/tests/data/originals
animated files : https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Netflix/avifs
to test the saver :
```
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <Eina.h>
#include <Ecore.h>
#include <Evas.h>
#include <Ecore_Evas.h>
void _quit(Ecore_Evas *ee)
{
ecore_main_loop_quit();
(void)ee;
}
static Evas_Object *
display_data(int w, int h, const char *title, unsigned int *data)
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
unsigned int *d;
ee = ecore_evas_new(NULL, 0, 0, w, h, NULL);
if (!ee)
return NULL;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, title);
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_image_size_set(o, w, h);
d = evas_object_image_data_get(o, 1);
for (int i = 0; i < w*h; i++)
d[i] = data[i];
evas_object_image_data_set(o, d);
evas_object_image_data_update_add(o, 0, 0, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
ecore_evas_show(ee);
return o;
}
static unsigned int *
display_file(const char *title, const char *filename, int *w, int *h)
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
Evas_Load_Error err;
unsigned int *data;
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
return NULL;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, title);
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, filename, NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
filename, evas_load_error_str(err));
fflush(stderr);
return NULL;
}
evas_object_image_size_get(o, w, h);
evas_object_image_fill_set(o, 0, 0, *w, *h);
evas_object_image_size_set(o, *w, *h);
evas_object_move(o, 0, 0);
evas_object_resize(o, *w, *h);
evas_object_show(o);
ecore_evas_resize(ee, *w, *h);
ecore_evas_show(ee);
data = evas_object_image_data_get(o, 1);
return data;
}
double psnr(int w, int h, unsigned int *data_orig, unsigned int *data)
{
unsigned char *iter_orig;
unsigned char *iter;
double psnr;
psnr = 0.0;
iter_orig = (unsigned char *)data_orig;
iter = (unsigned char *)data;
for (int i = 0; i < 4 * w * h; i++, iter_orig++, iter++)
psnr += (*iter_orig - *iter) * (*iter_orig - *iter);
psnr /= 4 * w * h;
psnr = 10 * log10(255.0 * 255.0 / psnr);
return psnr;
}
void compare(int quality, int w, int h, unsigned int *data_orig)
{
char title[1024];
char filename[1024];
unsigned char *data;
unsigned int *data_jpeg;
unsigned int *data_avif;
unsigned char *iter_orig;
unsigned char *iter_jpeg;
unsigned char *iter_avif;
double psnr_jpeg;
double psnr_avif;
Eina_File *f_jpeg;
Eina_File *f_avif;
size_t size_jpeg;
size_t size_avif;
/* jpeg */
snprintf(title, sizeof(title), "jpeg test quality %d", quality);
snprintf(filename, sizeof(filename), "test_%d.jpg", quality);
data_jpeg = display_file(title, filename, &w, &h);
if (!data_jpeg)
return;
f_jpeg = eina_file_open(filename, EINA_FALSE);
size_jpeg = eina_file_size_get(f_jpeg);
eina_file_close(f_jpeg);
fprintf(stderr, "size : %u\n", (unsigned int)size_jpeg);
fflush(stderr);
/* avif */
snprintf(title, sizeof(title), "avif test quality %d", quality);
snprintf(filename, sizeof(filename), "test_%d.avif", quality);
data_avif = display_file(title, filename, &w, &h);
if (!data_avif)
return;
f_avif = eina_file_open(filename, EINA_FALSE);
size_avif = eina_file_size_get(f_avif);
eina_file_close(f_avif);
fprintf(stderr, "size : %u\n", (unsigned int)size_avif);
fflush(stderr);
psnr_jpeg = psnr(w, h, data_orig, data_jpeg);
fprintf(stderr, "psnr jpeg : %f\n", psnr_jpeg);
fflush(stderr);
snprintf(title, sizeof(title), "jpeg vs orig (psnr: %.2f, size: %u b)", psnr_jpeg, (unsigned int)size_jpeg);
iter_orig = (unsigned char *)data_orig;
iter_jpeg = (unsigned char *)data_jpeg;
data = malloc(4*w*h);
for (int i = 0; i < 4*w*h; i++, iter_orig++, iter_jpeg++)
data[i] = abs(*iter_jpeg - *iter_orig);
display_data(w, h, title, (unsigned int *)data);
psnr_avif = psnr(w, h, data_orig, data_avif);
fprintf(stderr, "psnr avif : %f\n", psnr_avif);
fflush(stderr);
snprintf(title, sizeof(title), "avif vs orig (psnr: %.2f, size: %u b)", psnr_avif, (unsigned int)size_avif);
iter_orig = (unsigned char *)data_orig;
iter_avif = (unsigned char *)data_avif;
data = malloc(4*w*h);
for (int i = 0; i < 4*w*h; i++, iter_orig++, iter_avif++)
data[i] = abs(*iter_avif - *iter_orig);
display_data(w, h, title, (unsigned int *)data);
}
int main()
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
Evas_Load_Error err;
unsigned int *data;
int w,h;
ecore_evas_init();
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
return 1;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, "original");
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, "x1d-II-sample-02.fff", NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
"x1d-II-sample-02.fff", evas_load_error_str(err));
fflush(stderr);
return 1;
}
evas_object_image_size_get(o, &w, &h);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_image_size_set(o, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
data = evas_object_image_data_get(o, 1);
ecore_evas_resize(ee, w, h);
ecore_evas_show(ee);
/* evas_object_image_save(o, "test_100.jpg", NULL, "quality=100"); */
evas_object_image_save(o, "test_90.jpg", NULL, "quality=90");
/* evas_object_image_save(o, "test_70.jpg", NULL, "quality=70"); */
/* evas_object_image_save(o, "test_50.jpg", NULL, "quality=50"); */
/* evas_object_image_save(o, "test_100.avif", NULL, "quality=100"); */
evas_object_image_save(o, "test_90.avif", NULL, "quality=90");
/* evas_object_image_save(o, "test_70.avif", NULL, "quality=70"); */
/* evas_object_image_save(o, "test_50.avif", NULL, "quality=50"); */
compare(90, w, h, data);
ecore_main_loop_begin();
ecore_evas_shutdown();
return 0;
}
```
the raw file canbe found here : https://www.hasselblad.com/learn/sample-images/
Test Plan: test executable with avif files found in libavif project
Reviewers: raster, q66
Reviewed By: q66
Subscribers: q66, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12051
2020-07-15 10:51:27 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, avif);
|
2009-06-16 06:01:36 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, eet);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, jpeg);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, png);
|
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, tiff);
|
2013-03-05 15:09:05 -08:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, webp);
|
2014-03-12 00:32:17 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, tgv);
|
2013-07-01 19:00:44 -07:00
|
|
|
#endif
|
2009-06-16 06:01:36 -07:00
|
|
|
|
|
|
|
static const struct {
|
|
|
|
Eina_Bool (*init)(void);
|
|
|
|
void (*shutdown)(void);
|
|
|
|
} evas_static_module[] = {
|
2013-07-01 19:00:44 -07:00
|
|
|
#if !EVAS_MODULE_NO_ENGINES
|
2009-06-16 06:01:36 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_BUFFER
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, buffer),
|
|
|
|
#endif
|
2018-08-14 14:12:07 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_DRM
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, drm),
|
|
|
|
#endif
|
2009-06-16 06:01:36 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_FB
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, fb),
|
|
|
|
#endif
|
2014-07-11 03:13:37 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_GL_COMMON
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, gl_generic),
|
|
|
|
#endif
|
2018-08-14 14:12:07 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_GL_DRM
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, gl_drm),
|
|
|
|
#endif
|
2009-06-16 06:01:36 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_GL_X11
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, gl_x11),
|
|
|
|
#endif
|
2010-11-16 05:09:14 -08:00
|
|
|
#ifdef EVAS_STATIC_BUILD_GL_SDL
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, gl_sdl),
|
|
|
|
#endif
|
2012-06-19 10:06:44 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_SOFTWARE_DDRAW
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, software_ddraw),
|
|
|
|
#endif
|
|
|
|
#ifdef EVAS_STATIC_BUILD_SOFTWARE_GDI
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, software_gdi),
|
|
|
|
#endif
|
2009-06-16 06:01:36 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_SOFTWARE_GENERIC
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, software_generic),
|
|
|
|
#endif
|
|
|
|
#ifdef EVAS_STATIC_BUILD_SOFTWARE_X11
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, software_x11),
|
|
|
|
#endif
|
2018-08-14 14:12:07 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_WAYLAND_EGL
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, wayland_egl),
|
|
|
|
#endif
|
|
|
|
#ifdef EVAS_STATIC_BUILD_WAYLAND_SHM
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(engine, wayland_shm),
|
|
|
|
#endif
|
2013-07-01 19:00:44 -07:00
|
|
|
#endif
|
2016-10-12 02:39:10 -07:00
|
|
|
#if !EVAS_MODULE_NO_VG_LOADERS
|
|
|
|
#ifdef EVAS_STATIC_BUILD_VG_SVG
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(vg_loader, svg),
|
|
|
|
#endif
|
2016-10-13 01:09:39 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_VG_EET
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(vg_loader, eet),
|
|
|
|
#endif
|
evas vector: support json loader for rlottie integration.
Summary:
Introduce a new evas json loader to support lottie animation.
This json loader uses rlottie library which is a new github open project.
These days most ui frameworks (windowpws, skia, qt, xamarin, react, nativescript) supports lottie,
the rlottie was designed to support lottie as a standalone library and compatible with efl as well.
To enable this,please install rlottie library then remove json disabler in meson_options.txt
For more information, See lottie/rlottie project and its a introdcution article:
https://airbnb.io/lottie/#/
https://github.com/samsung/rlottie
https://hermet.pe.kr/143
Co-authored-by: JunsuChoi <jsuya.choi@samsung.com>
{D8941}
{D8944}
Reviewers: #committers, jsuya, bu5hm4n
Subscribers: bu5hm4n, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8940
2019-06-21 01:30:19 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_VG_JSON
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(vg_loader, json),
|
|
|
|
#endif
|
2016-10-12 02:39:10 -07:00
|
|
|
#endif
|
2013-07-01 19:00:44 -07:00
|
|
|
#if !EVAS_MODULE_NO_IMAGE_LOADERS
|
Evas: add avif evas loader and saver
Summary:
Add AV1 image file loader and saver to Evas
The loader can be tested with this code :
```
#include <stdlib.h>
#include <stdio.h>
#include <Eina.h>
#include <Ecore.h>
#include <Evas.h>
#include <Ecore_Evas.h>
static int i = 0;
static unsigned char _timer(void *data)
{
Evas_Object *o = (Evas_Object *)data;
if (i < evas_object_image_animated_frame_count_get(o))
{
evas_object_image_animated_frame_set(o, i);
i++;
return ECORE_CALLBACK_RENEW;
}
return ECORE_CALLBACK_DONE;
}
static void _quit(Ecore_Evas *ee)
{
ecore_main_loop_quit();
(void)ee;
}
int main(int argc, char *argv[])
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
int w,h;
Evas_Load_Error err;
if (argc < 2)
{
printf("usage : %s file\n", argv[0]);
return 1;
}
ecore_evas_init();
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
{
printf("no ee\n");
return 0;
}
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, "avif test");
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, argv[1], NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
argv[1], evas_load_error_str(err));
return 1;
}
evas_object_image_size_get(o, &w, &h);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
printf("animated : %s\n", evas_object_image_animated_get(o) ? "yes" : "no");
fflush(stdout);
if (evas_object_image_animated_get(o))
{
Ecore_Timer *timer;
printf("frame count : %d\n", evas_object_image_animated_frame_count_get(o));
printf("duration : %f\n", evas_object_image_animated_frame_duration_get(o,1,0));
printf("loop count : %d\n", evas_object_image_animated_loop_count_get(o));
fflush(stdout);
timer = ecore_timer_add(evas_object_image_animated_frame_duration_get(o,1,0), _timer, o);
}
ecore_evas_resize(ee, w, h);
ecore_evas_show(ee);
ecore_main_loop_begin();
ecore_evas_shutdown();
return 0;
}
```
non animated files : https://github.com/AOMediaCodec/libavif/tree/master/tests/data/originals
animated files : https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Netflix/avifs
to test the saver :
```
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <Eina.h>
#include <Ecore.h>
#include <Evas.h>
#include <Ecore_Evas.h>
void _quit(Ecore_Evas *ee)
{
ecore_main_loop_quit();
(void)ee;
}
static Evas_Object *
display_data(int w, int h, const char *title, unsigned int *data)
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
unsigned int *d;
ee = ecore_evas_new(NULL, 0, 0, w, h, NULL);
if (!ee)
return NULL;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, title);
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_image_size_set(o, w, h);
d = evas_object_image_data_get(o, 1);
for (int i = 0; i < w*h; i++)
d[i] = data[i];
evas_object_image_data_set(o, d);
evas_object_image_data_update_add(o, 0, 0, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
ecore_evas_show(ee);
return o;
}
static unsigned int *
display_file(const char *title, const char *filename, int *w, int *h)
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
Evas_Load_Error err;
unsigned int *data;
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
return NULL;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, title);
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, filename, NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
filename, evas_load_error_str(err));
fflush(stderr);
return NULL;
}
evas_object_image_size_get(o, w, h);
evas_object_image_fill_set(o, 0, 0, *w, *h);
evas_object_image_size_set(o, *w, *h);
evas_object_move(o, 0, 0);
evas_object_resize(o, *w, *h);
evas_object_show(o);
ecore_evas_resize(ee, *w, *h);
ecore_evas_show(ee);
data = evas_object_image_data_get(o, 1);
return data;
}
double psnr(int w, int h, unsigned int *data_orig, unsigned int *data)
{
unsigned char *iter_orig;
unsigned char *iter;
double psnr;
psnr = 0.0;
iter_orig = (unsigned char *)data_orig;
iter = (unsigned char *)data;
for (int i = 0; i < 4 * w * h; i++, iter_orig++, iter++)
psnr += (*iter_orig - *iter) * (*iter_orig - *iter);
psnr /= 4 * w * h;
psnr = 10 * log10(255.0 * 255.0 / psnr);
return psnr;
}
void compare(int quality, int w, int h, unsigned int *data_orig)
{
char title[1024];
char filename[1024];
unsigned char *data;
unsigned int *data_jpeg;
unsigned int *data_avif;
unsigned char *iter_orig;
unsigned char *iter_jpeg;
unsigned char *iter_avif;
double psnr_jpeg;
double psnr_avif;
Eina_File *f_jpeg;
Eina_File *f_avif;
size_t size_jpeg;
size_t size_avif;
/* jpeg */
snprintf(title, sizeof(title), "jpeg test quality %d", quality);
snprintf(filename, sizeof(filename), "test_%d.jpg", quality);
data_jpeg = display_file(title, filename, &w, &h);
if (!data_jpeg)
return;
f_jpeg = eina_file_open(filename, EINA_FALSE);
size_jpeg = eina_file_size_get(f_jpeg);
eina_file_close(f_jpeg);
fprintf(stderr, "size : %u\n", (unsigned int)size_jpeg);
fflush(stderr);
/* avif */
snprintf(title, sizeof(title), "avif test quality %d", quality);
snprintf(filename, sizeof(filename), "test_%d.avif", quality);
data_avif = display_file(title, filename, &w, &h);
if (!data_avif)
return;
f_avif = eina_file_open(filename, EINA_FALSE);
size_avif = eina_file_size_get(f_avif);
eina_file_close(f_avif);
fprintf(stderr, "size : %u\n", (unsigned int)size_avif);
fflush(stderr);
psnr_jpeg = psnr(w, h, data_orig, data_jpeg);
fprintf(stderr, "psnr jpeg : %f\n", psnr_jpeg);
fflush(stderr);
snprintf(title, sizeof(title), "jpeg vs orig (psnr: %.2f, size: %u b)", psnr_jpeg, (unsigned int)size_jpeg);
iter_orig = (unsigned char *)data_orig;
iter_jpeg = (unsigned char *)data_jpeg;
data = malloc(4*w*h);
for (int i = 0; i < 4*w*h; i++, iter_orig++, iter_jpeg++)
data[i] = abs(*iter_jpeg - *iter_orig);
display_data(w, h, title, (unsigned int *)data);
psnr_avif = psnr(w, h, data_orig, data_avif);
fprintf(stderr, "psnr avif : %f\n", psnr_avif);
fflush(stderr);
snprintf(title, sizeof(title), "avif vs orig (psnr: %.2f, size: %u b)", psnr_avif, (unsigned int)size_avif);
iter_orig = (unsigned char *)data_orig;
iter_avif = (unsigned char *)data_avif;
data = malloc(4*w*h);
for (int i = 0; i < 4*w*h; i++, iter_orig++, iter_avif++)
data[i] = abs(*iter_avif - *iter_orig);
display_data(w, h, title, (unsigned int *)data);
}
int main()
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
Evas_Load_Error err;
unsigned int *data;
int w,h;
ecore_evas_init();
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
return 1;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, "original");
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, "x1d-II-sample-02.fff", NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
"x1d-II-sample-02.fff", evas_load_error_str(err));
fflush(stderr);
return 1;
}
evas_object_image_size_get(o, &w, &h);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_image_size_set(o, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
data = evas_object_image_data_get(o, 1);
ecore_evas_resize(ee, w, h);
ecore_evas_show(ee);
/* evas_object_image_save(o, "test_100.jpg", NULL, "quality=100"); */
evas_object_image_save(o, "test_90.jpg", NULL, "quality=90");
/* evas_object_image_save(o, "test_70.jpg", NULL, "quality=70"); */
/* evas_object_image_save(o, "test_50.jpg", NULL, "quality=50"); */
/* evas_object_image_save(o, "test_100.avif", NULL, "quality=100"); */
evas_object_image_save(o, "test_90.avif", NULL, "quality=90");
/* evas_object_image_save(o, "test_70.avif", NULL, "quality=70"); */
/* evas_object_image_save(o, "test_50.avif", NULL, "quality=50"); */
compare(90, w, h, data);
ecore_main_loop_begin();
ecore_evas_shutdown();
return 0;
}
```
the raw file canbe found here : https://www.hasselblad.com/learn/sample-images/
Test Plan: test executable with avif files found in libavif project
Reviewers: raster, q66
Reviewed By: q66
Subscribers: q66, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12051
2020-07-15 10:51:27 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_AVIF
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, avif),
|
|
|
|
#endif
|
2010-10-25 19:55:56 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_BMP
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, bmp),
|
|
|
|
#endif
|
2014-06-18 01:55:44 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_DDS
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, dds),
|
|
|
|
#endif
|
2011-06-03 22:33:37 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_EET
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, eet),
|
2009-06-16 06:01:36 -07:00
|
|
|
#endif
|
2011-06-03 22:33:37 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_GENERIC
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, generic),
|
2009-06-16 06:01:36 -07:00
|
|
|
#endif
|
2011-06-03 22:33:37 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_GIF
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, gif),
|
|
|
|
#endif
|
2021-02-06 07:45:42 -08:00
|
|
|
#ifdef EVAS_STATIC_BUILD_HEIF
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, heif),
|
|
|
|
#endif
|
2011-06-03 22:33:37 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_ICO
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, ico),
|
2009-06-16 06:01:36 -07:00
|
|
|
#endif
|
|
|
|
#ifdef EVAS_STATIC_BUILD_JPEG
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, jpeg),
|
|
|
|
#endif
|
2013-09-28 05:28:41 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_JP2K
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, jp2k),
|
|
|
|
#endif
|
2011-06-03 22:33:37 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_PMAPS
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, pmaps),
|
2009-06-16 06:01:36 -07:00
|
|
|
#endif
|
2011-06-03 22:33:37 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_PNG
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, png),
|
2009-06-16 06:01:36 -07:00
|
|
|
#endif
|
2011-06-03 22:33:37 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_PSD
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, psd),
|
|
|
|
#endif
|
|
|
|
#ifdef EVAS_STATIC_BUILD_SVG
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, svg),
|
2009-06-16 06:01:36 -07:00
|
|
|
#endif
|
2010-10-26 01:29:39 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_TGA
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, tga),
|
|
|
|
#endif
|
2011-06-03 22:33:37 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_TIFF
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, tiff),
|
|
|
|
#endif
|
2011-02-01 01:38:48 -08:00
|
|
|
#ifdef EVAS_STATIC_BUILD_WBMP
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, wbmp),
|
|
|
|
#endif
|
2012-09-02 23:22:59 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_WEBP
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, webp),
|
|
|
|
#endif
|
2011-06-03 22:33:37 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_XPM
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, xpm),
|
2011-03-11 07:07:25 -08:00
|
|
|
#endif
|
2014-03-11 03:08:40 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_TGV
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, tgv),
|
|
|
|
#endif
|
2013-07-01 19:00:44 -07:00
|
|
|
#endif
|
2016-10-13 23:52:51 -07:00
|
|
|
#if !EVAS_MODULE_NO_VG_SAVERS
|
|
|
|
#ifdef EVAS_STATIC_BUILD_VG_EET
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(vg_saver, eet),
|
|
|
|
#endif
|
2017-01-27 03:54:47 -08:00
|
|
|
#ifdef EVAS_STATIC_BUILD_VG_SVG
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(vg_saver, svg),
|
|
|
|
#endif
|
2016-10-13 23:52:51 -07:00
|
|
|
#endif
|
2013-07-01 19:00:44 -07:00
|
|
|
#if !EVAS_MODULE_NO_IMAGE_SAVERS
|
Evas: add avif evas loader and saver
Summary:
Add AV1 image file loader and saver to Evas
The loader can be tested with this code :
```
#include <stdlib.h>
#include <stdio.h>
#include <Eina.h>
#include <Ecore.h>
#include <Evas.h>
#include <Ecore_Evas.h>
static int i = 0;
static unsigned char _timer(void *data)
{
Evas_Object *o = (Evas_Object *)data;
if (i < evas_object_image_animated_frame_count_get(o))
{
evas_object_image_animated_frame_set(o, i);
i++;
return ECORE_CALLBACK_RENEW;
}
return ECORE_CALLBACK_DONE;
}
static void _quit(Ecore_Evas *ee)
{
ecore_main_loop_quit();
(void)ee;
}
int main(int argc, char *argv[])
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
int w,h;
Evas_Load_Error err;
if (argc < 2)
{
printf("usage : %s file\n", argv[0]);
return 1;
}
ecore_evas_init();
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
{
printf("no ee\n");
return 0;
}
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, "avif test");
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, argv[1], NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
argv[1], evas_load_error_str(err));
return 1;
}
evas_object_image_size_get(o, &w, &h);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
printf("animated : %s\n", evas_object_image_animated_get(o) ? "yes" : "no");
fflush(stdout);
if (evas_object_image_animated_get(o))
{
Ecore_Timer *timer;
printf("frame count : %d\n", evas_object_image_animated_frame_count_get(o));
printf("duration : %f\n", evas_object_image_animated_frame_duration_get(o,1,0));
printf("loop count : %d\n", evas_object_image_animated_loop_count_get(o));
fflush(stdout);
timer = ecore_timer_add(evas_object_image_animated_frame_duration_get(o,1,0), _timer, o);
}
ecore_evas_resize(ee, w, h);
ecore_evas_show(ee);
ecore_main_loop_begin();
ecore_evas_shutdown();
return 0;
}
```
non animated files : https://github.com/AOMediaCodec/libavif/tree/master/tests/data/originals
animated files : https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Netflix/avifs
to test the saver :
```
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <Eina.h>
#include <Ecore.h>
#include <Evas.h>
#include <Ecore_Evas.h>
void _quit(Ecore_Evas *ee)
{
ecore_main_loop_quit();
(void)ee;
}
static Evas_Object *
display_data(int w, int h, const char *title, unsigned int *data)
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
unsigned int *d;
ee = ecore_evas_new(NULL, 0, 0, w, h, NULL);
if (!ee)
return NULL;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, title);
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_image_size_set(o, w, h);
d = evas_object_image_data_get(o, 1);
for (int i = 0; i < w*h; i++)
d[i] = data[i];
evas_object_image_data_set(o, d);
evas_object_image_data_update_add(o, 0, 0, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
ecore_evas_show(ee);
return o;
}
static unsigned int *
display_file(const char *title, const char *filename, int *w, int *h)
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
Evas_Load_Error err;
unsigned int *data;
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
return NULL;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, title);
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, filename, NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
filename, evas_load_error_str(err));
fflush(stderr);
return NULL;
}
evas_object_image_size_get(o, w, h);
evas_object_image_fill_set(o, 0, 0, *w, *h);
evas_object_image_size_set(o, *w, *h);
evas_object_move(o, 0, 0);
evas_object_resize(o, *w, *h);
evas_object_show(o);
ecore_evas_resize(ee, *w, *h);
ecore_evas_show(ee);
data = evas_object_image_data_get(o, 1);
return data;
}
double psnr(int w, int h, unsigned int *data_orig, unsigned int *data)
{
unsigned char *iter_orig;
unsigned char *iter;
double psnr;
psnr = 0.0;
iter_orig = (unsigned char *)data_orig;
iter = (unsigned char *)data;
for (int i = 0; i < 4 * w * h; i++, iter_orig++, iter++)
psnr += (*iter_orig - *iter) * (*iter_orig - *iter);
psnr /= 4 * w * h;
psnr = 10 * log10(255.0 * 255.0 / psnr);
return psnr;
}
void compare(int quality, int w, int h, unsigned int *data_orig)
{
char title[1024];
char filename[1024];
unsigned char *data;
unsigned int *data_jpeg;
unsigned int *data_avif;
unsigned char *iter_orig;
unsigned char *iter_jpeg;
unsigned char *iter_avif;
double psnr_jpeg;
double psnr_avif;
Eina_File *f_jpeg;
Eina_File *f_avif;
size_t size_jpeg;
size_t size_avif;
/* jpeg */
snprintf(title, sizeof(title), "jpeg test quality %d", quality);
snprintf(filename, sizeof(filename), "test_%d.jpg", quality);
data_jpeg = display_file(title, filename, &w, &h);
if (!data_jpeg)
return;
f_jpeg = eina_file_open(filename, EINA_FALSE);
size_jpeg = eina_file_size_get(f_jpeg);
eina_file_close(f_jpeg);
fprintf(stderr, "size : %u\n", (unsigned int)size_jpeg);
fflush(stderr);
/* avif */
snprintf(title, sizeof(title), "avif test quality %d", quality);
snprintf(filename, sizeof(filename), "test_%d.avif", quality);
data_avif = display_file(title, filename, &w, &h);
if (!data_avif)
return;
f_avif = eina_file_open(filename, EINA_FALSE);
size_avif = eina_file_size_get(f_avif);
eina_file_close(f_avif);
fprintf(stderr, "size : %u\n", (unsigned int)size_avif);
fflush(stderr);
psnr_jpeg = psnr(w, h, data_orig, data_jpeg);
fprintf(stderr, "psnr jpeg : %f\n", psnr_jpeg);
fflush(stderr);
snprintf(title, sizeof(title), "jpeg vs orig (psnr: %.2f, size: %u b)", psnr_jpeg, (unsigned int)size_jpeg);
iter_orig = (unsigned char *)data_orig;
iter_jpeg = (unsigned char *)data_jpeg;
data = malloc(4*w*h);
for (int i = 0; i < 4*w*h; i++, iter_orig++, iter_jpeg++)
data[i] = abs(*iter_jpeg - *iter_orig);
display_data(w, h, title, (unsigned int *)data);
psnr_avif = psnr(w, h, data_orig, data_avif);
fprintf(stderr, "psnr avif : %f\n", psnr_avif);
fflush(stderr);
snprintf(title, sizeof(title), "avif vs orig (psnr: %.2f, size: %u b)", psnr_avif, (unsigned int)size_avif);
iter_orig = (unsigned char *)data_orig;
iter_avif = (unsigned char *)data_avif;
data = malloc(4*w*h);
for (int i = 0; i < 4*w*h; i++, iter_orig++, iter_avif++)
data[i] = abs(*iter_avif - *iter_orig);
display_data(w, h, title, (unsigned int *)data);
}
int main()
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *o;
Evas_Load_Error err;
unsigned int *data;
int w,h;
ecore_evas_init();
ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);
if (!ee)
return 1;
evas = ecore_evas_get(ee);
ecore_evas_title_set(ee, "original");
ecore_evas_callback_delete_request_set(ee, _quit);
o = evas_object_image_add(evas);
evas_object_image_file_set(o, "x1d-II-sample-02.fff", NULL);
err = evas_object_image_load_error_get(o);
if (err != EVAS_LOAD_ERROR_NONE)
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
"x1d-II-sample-02.fff", evas_load_error_str(err));
fflush(stderr);
return 1;
}
evas_object_image_size_get(o, &w, &h);
evas_object_image_fill_set(o, 0, 0, w, h);
evas_object_image_size_set(o, w, h);
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
data = evas_object_image_data_get(o, 1);
ecore_evas_resize(ee, w, h);
ecore_evas_show(ee);
/* evas_object_image_save(o, "test_100.jpg", NULL, "quality=100"); */
evas_object_image_save(o, "test_90.jpg", NULL, "quality=90");
/* evas_object_image_save(o, "test_70.jpg", NULL, "quality=70"); */
/* evas_object_image_save(o, "test_50.jpg", NULL, "quality=50"); */
/* evas_object_image_save(o, "test_100.avif", NULL, "quality=100"); */
evas_object_image_save(o, "test_90.avif", NULL, "quality=90");
/* evas_object_image_save(o, "test_70.avif", NULL, "quality=70"); */
/* evas_object_image_save(o, "test_50.avif", NULL, "quality=50"); */
compare(90, w, h, data);
ecore_main_loop_begin();
ecore_evas_shutdown();
return 0;
}
```
the raw file canbe found here : https://www.hasselblad.com/learn/sample-images/
Test Plan: test executable with avif files found in libavif project
Reviewers: raster, q66
Reviewed By: q66
Subscribers: q66, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12051
2020-07-15 10:51:27 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_AVIF
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_saver, avif),
|
|
|
|
#endif
|
2009-07-28 16:48:27 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_EET
|
2009-06-16 06:01:36 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_saver, eet),
|
|
|
|
#endif
|
2014-07-01 04:22:42 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_JPEG
|
2009-06-16 06:01:36 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_saver, jpeg),
|
|
|
|
#endif
|
2009-07-28 16:48:27 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_PNG
|
2009-06-16 06:01:36 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_saver, png),
|
|
|
|
#endif
|
2009-07-28 16:48:27 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_TIFF
|
2009-06-16 06:01:36 -07:00
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_saver, tiff),
|
2013-03-05 15:09:05 -08:00
|
|
|
#endif
|
|
|
|
#ifdef EVAS_STATIC_BUILD_WEBP
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_saver, webp),
|
2013-07-01 19:00:44 -07:00
|
|
|
#endif
|
2014-03-12 00:32:17 -07:00
|
|
|
#ifdef EVAS_STATIC_BUILD_TGV
|
|
|
|
EVAS_EINA_STATIC_MODULE_USE(image_saver, tgv),
|
|
|
|
#endif
|
2009-06-16 06:01:36 -07:00
|
|
|
#endif
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
2017-02-20 21:46:02 -08:00
|
|
|
static void _evas_module_hash_free_cb(void *data);
|
|
|
|
|
2007-08-13 05:13:03 -07:00
|
|
|
/* this will alloc an Evas_Module struct for each module
|
2006-01-14 04:13:38 -08:00
|
|
|
* it finds on the paths */
|
|
|
|
void
|
|
|
|
evas_module_init(void)
|
|
|
|
{
|
2009-06-16 06:01:36 -07:00
|
|
|
int i;
|
2007-08-13 05:13:03 -07:00
|
|
|
|
2006-01-14 04:13:38 -08:00
|
|
|
evas_module_paths_init();
|
2007-08-13 05:13:03 -07:00
|
|
|
|
2017-02-20 21:46:02 -08:00
|
|
|
evas_modules[EVAS_MODULE_TYPE_ENGINE] = eina_hash_string_small_new(_evas_module_hash_free_cb);
|
|
|
|
evas_modules[EVAS_MODULE_TYPE_IMAGE_LOADER] = eina_hash_string_small_new(_evas_module_hash_free_cb);
|
|
|
|
evas_modules[EVAS_MODULE_TYPE_IMAGE_SAVER] = eina_hash_string_small_new(_evas_module_hash_free_cb);
|
|
|
|
evas_modules[EVAS_MODULE_TYPE_OBJECT] = eina_hash_string_small_new(_evas_module_hash_free_cb);
|
|
|
|
evas_modules[EVAS_MODULE_TYPE_VG_LOADER] = eina_hash_string_small_new(_evas_module_hash_free_cb);
|
|
|
|
evas_modules[EVAS_MODULE_TYPE_VG_SAVER] = eina_hash_string_small_new(_evas_module_hash_free_cb);
|
2009-06-16 06:01:36 -07:00
|
|
|
|
|
|
|
evas_engines = eina_array_new(4);
|
|
|
|
|
2016-12-06 11:34:56 -08:00
|
|
|
eina_tls_cb_new(&task, (Eina_TLS_Delete_Cb) evas_module_task_unregister);
|
|
|
|
|
2010-08-21 06:52:25 -07:00
|
|
|
for (i = 0; evas_static_module[i].init; ++i)
|
2009-06-16 06:01:36 -07:00
|
|
|
evas_static_module[i].init();
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
evas_module_register(const Evas_Module_Api *module, Evas_Module_Type type)
|
|
|
|
{
|
|
|
|
Evas_Module *em;
|
|
|
|
|
2016-10-13 23:52:51 -07:00
|
|
|
if ((unsigned int)type > 5) return EINA_FALSE;
|
2009-06-16 06:01:36 -07:00
|
|
|
if (!module) return EINA_FALSE;
|
2010-11-16 05:09:14 -08:00
|
|
|
if (module->version != EVAS_MODULE_API_VERSION) return EINA_FALSE;
|
2009-06-16 06:01:36 -07:00
|
|
|
|
|
|
|
em = eina_hash_find(evas_modules[type], module->name);
|
|
|
|
if (em) return EINA_FALSE;
|
|
|
|
|
|
|
|
em = calloc(1, sizeof (Evas_Module));
|
|
|
|
if (!em) return EINA_FALSE;
|
|
|
|
|
2015-12-12 06:37:16 -08:00
|
|
|
LKI(em->lock);
|
2009-06-17 06:10:00 -07:00
|
|
|
em->definition = module;
|
2009-06-16 06:01:36 -07:00
|
|
|
|
|
|
|
if (type == EVAS_MODULE_TYPE_ENGINE)
|
|
|
|
{
|
2014-07-01 04:25:04 -07:00
|
|
|
eina_array_push(evas_engines, em);
|
|
|
|
em->id_engine = eina_array_count(evas_engines);
|
2006-01-14 04:13:38 -08:00
|
|
|
}
|
2009-06-16 06:01:36 -07:00
|
|
|
|
|
|
|
eina_hash_direct_add(evas_modules[type], module->name, em);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2006-01-14 04:13:38 -08:00
|
|
|
}
|
|
|
|
|
2011-09-19 07:20:18 -07:00
|
|
|
Eina_List *
|
|
|
|
evas_module_engine_list(void)
|
|
|
|
{
|
|
|
|
Evas_Module *em;
|
2012-03-26 03:56:55 -07:00
|
|
|
Eina_List *r = NULL, *l, *ll;
|
2011-09-19 07:20:18 -07:00
|
|
|
Eina_Array_Iterator iterator;
|
2012-03-26 03:56:55 -07:00
|
|
|
Eina_Iterator *it, *it2;
|
2011-09-19 07:20:18 -07:00
|
|
|
unsigned int i;
|
2012-03-26 03:56:55 -07:00
|
|
|
const char *s, *s2;
|
2013-01-04 09:19:43 -08:00
|
|
|
char buf[PATH_MAX];
|
2017-02-03 05:49:38 -08:00
|
|
|
#ifdef NEED_RUN_IN_TREE
|
2019-08-08 15:55:40 -07:00
|
|
|
static signed char run_in_tree = -1;
|
2013-01-04 09:19:43 -08:00
|
|
|
|
2019-08-08 15:55:40 -07:00
|
|
|
if (run_in_tree == -1)
|
|
|
|
{
|
|
|
|
if (getenv("EFL_RUN_IN_TREE")) run_in_tree = 1;
|
|
|
|
else run_in_tree = 0;
|
|
|
|
}
|
2017-02-03 05:49:38 -08:00
|
|
|
#endif
|
2011-09-19 07:20:18 -07:00
|
|
|
|
2012-03-26 03:56:55 -07:00
|
|
|
EINA_LIST_FOREACH(evas_module_paths, l, s)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/engines", s);
|
|
|
|
it = eina_file_direct_ls(buf);
|
|
|
|
if (it)
|
|
|
|
{
|
|
|
|
Eina_File_Direct_Info *fi;
|
|
|
|
|
|
|
|
EINA_ITERATOR_FOREACH(it, fi)
|
|
|
|
{
|
|
|
|
const char *fname = fi->path + fi->name_start;
|
2013-01-04 09:19:43 -08:00
|
|
|
|
2017-02-03 05:49:38 -08:00
|
|
|
#ifdef NEED_RUN_IN_TREE
|
2013-01-04 09:19:43 -08:00
|
|
|
buf[0] = '\0';
|
2014-01-08 05:06:41 -08:00
|
|
|
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
|
|
|
|
if (getuid() == geteuid())
|
|
|
|
#endif
|
2013-01-04 09:19:43 -08:00
|
|
|
{
|
2019-08-08 15:55:40 -07:00
|
|
|
if (run_in_tree == 1)
|
2014-01-08 02:46:23 -08:00
|
|
|
{
|
2018-02-12 11:52:28 -08:00
|
|
|
bs_mod_dir_get(buf, sizeof(buf), "evas/engines", fname);
|
2014-01-08 02:46:23 -08:00
|
|
|
if (!evas_file_path_exists(buf))
|
|
|
|
buf[0] = '\0';
|
|
|
|
}
|
2013-01-04 09:19:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (buf[0] == '\0')
|
2017-02-03 05:49:38 -08:00
|
|
|
#endif
|
2013-01-04 09:19:43 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/engines/%s/%s",
|
|
|
|
s, fname, MODULE_ARCH);
|
|
|
|
|
2012-03-26 03:56:55 -07:00
|
|
|
it2 = eina_file_ls(buf);
|
|
|
|
if (it2)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(r, ll, s2)
|
|
|
|
{
|
|
|
|
if (!strcmp(fname, s2)) break;
|
|
|
|
}
|
|
|
|
if (!ll)
|
|
|
|
r = eina_list_append(r, eina_stringshare_add(fname));
|
|
|
|
eina_iterator_free(it2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eina_iterator_free(it);
|
|
|
|
}
|
|
|
|
}
|
2014-07-01 04:25:04 -07:00
|
|
|
|
2011-09-19 07:20:18 -07:00
|
|
|
EINA_ARRAY_ITER_NEXT(evas_engines, i, em, iterator)
|
2012-03-26 03:56:55 -07:00
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(r, ll, s2)
|
|
|
|
{
|
|
|
|
if (!strcmp(em->definition->name, s2)) break;
|
|
|
|
}
|
|
|
|
if (!ll)
|
|
|
|
r = eina_list_append(r, eina_stringshare_add(em->definition->name));
|
|
|
|
}
|
2011-09-19 07:20:18 -07:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
Eina_Bool
|
|
|
|
evas_module_unregister(const Evas_Module_Api *module, Evas_Module_Type type)
|
|
|
|
{
|
|
|
|
Evas_Module *em;
|
|
|
|
|
2016-10-13 23:52:51 -07:00
|
|
|
if ((unsigned int)type > 5) return EINA_FALSE;
|
2009-06-16 06:01:36 -07:00
|
|
|
if (!module) return EINA_FALSE;
|
|
|
|
|
|
|
|
em = eina_hash_find(evas_modules[type], module->name);
|
2009-06-17 06:10:00 -07:00
|
|
|
if (!em || em->definition != module) return EINA_FALSE;
|
2009-06-16 06:01:36 -07:00
|
|
|
|
|
|
|
eina_hash_del(evas_modules[type], module->name, em);
|
2016-07-04 04:07:30 -07:00
|
|
|
|
2017-02-20 21:46:02 -08:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_module_hash_free_cb(void *data)
|
|
|
|
{
|
|
|
|
Evas_Module *em = data;
|
|
|
|
|
|
|
|
// Note: This free callback leaks the Eina_Module, and does not call
|
|
|
|
// dlclose(). This is by choice as dlclose() leads to other issues.
|
|
|
|
|
|
|
|
if (!em) return;
|
|
|
|
if (em->id_engine > 0)
|
|
|
|
eina_array_data_set(evas_engines, em->id_engine - 1, NULL);
|
2016-07-04 04:07:30 -07:00
|
|
|
if (em->loaded)
|
|
|
|
{
|
|
|
|
em->definition->func.close(em);
|
|
|
|
em->loaded = 0;
|
|
|
|
}
|
|
|
|
|
2015-12-12 06:37:16 -08:00
|
|
|
LKD(em->lock);
|
2009-06-16 06:01:36 -07:00
|
|
|
free(em);
|
|
|
|
}
|
|
|
|
|
2013-01-04 09:19:43 -08:00
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
|
|
# define EVAS_MODULE_NAME "module.dll"
|
2009-06-16 06:01:36 -07:00
|
|
|
#else
|
2013-01-04 09:19:43 -08:00
|
|
|
# define EVAS_MODULE_NAME "module.so"
|
2009-06-16 06:01:36 -07:00
|
|
|
#endif
|
|
|
|
|
2006-01-14 04:13:38 -08:00
|
|
|
Evas_Module *
|
|
|
|
evas_module_find_type(Evas_Module_Type type, const char *name)
|
|
|
|
{
|
2009-06-16 06:01:36 -07:00
|
|
|
const char *path;
|
2013-01-04 09:19:43 -08:00
|
|
|
char buffer[PATH_MAX];
|
2008-10-21 09:31:05 -07:00
|
|
|
Evas_Module *em;
|
2009-06-16 06:01:36 -07:00
|
|
|
Eina_Module *en;
|
|
|
|
Eina_List *l;
|
2017-02-03 05:49:38 -08:00
|
|
|
#ifdef NEED_RUN_IN_TREE
|
2019-08-08 15:55:40 -07:00
|
|
|
static signed char run_in_tree = -1;
|
|
|
|
|
|
|
|
if (run_in_tree == -1)
|
|
|
|
{
|
|
|
|
if (getenv("EFL_RUN_IN_TREE")) run_in_tree = 1;
|
|
|
|
else run_in_tree = 0;
|
|
|
|
}
|
2017-02-03 05:49:38 -08:00
|
|
|
#endif
|
2009-06-16 06:01:36 -07:00
|
|
|
|
2016-10-13 23:52:51 -07:00
|
|
|
if ((unsigned int)type > 5) return NULL;
|
2009-06-16 06:01:36 -07:00
|
|
|
|
|
|
|
em = eina_hash_find(evas_modules[type], name);
|
2016-07-04 04:07:30 -07:00
|
|
|
if (em)
|
|
|
|
{
|
2016-07-08 02:59:21 -07:00
|
|
|
if (evas_module_load(em)) return em;
|
|
|
|
return NULL;
|
2016-07-04 04:07:30 -07:00
|
|
|
}
|
2007-08-13 05:13:03 -07:00
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
EINA_LIST_FOREACH(evas_module_paths, l, path)
|
2006-01-14 04:13:38 -08:00
|
|
|
{
|
2013-01-04 09:19:43 -08:00
|
|
|
const char *type_str = "unknown";
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case EVAS_MODULE_TYPE_ENGINE: type_str = "engines"; break;
|
2014-11-26 08:50:43 -08:00
|
|
|
case EVAS_MODULE_TYPE_IMAGE_LOADER: type_str = "image_loaders"; break;
|
|
|
|
case EVAS_MODULE_TYPE_IMAGE_SAVER: type_str = "image_savers"; break;
|
2013-01-04 09:19:43 -08:00
|
|
|
case EVAS_MODULE_TYPE_OBJECT: type_str = "object"; break;
|
2016-10-12 02:39:10 -07:00
|
|
|
case EVAS_MODULE_TYPE_VG_LOADER: type_str = "vg_loaders"; break;
|
2016-10-13 23:52:51 -07:00
|
|
|
case EVAS_MODULE_TYPE_VG_SAVER: type_str = "vg_savers"; break;
|
2013-01-04 09:19:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
2017-02-03 05:49:38 -08:00
|
|
|
#if NEED_RUN_IN_TREE
|
2014-01-08 05:06:41 -08:00
|
|
|
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
|
|
|
|
if (getuid() == geteuid())
|
|
|
|
#endif
|
2013-01-04 09:19:43 -08:00
|
|
|
{
|
2019-08-08 15:55:40 -07:00
|
|
|
if (run_in_tree == 1)
|
2014-01-08 02:46:23 -08:00
|
|
|
{
|
meson: redo evas building
Summary:
before recent times we had to support static and shared building based
on the options of the user, which forced us to complicate our build with
the evas_goal hack. the evas_goal hack more or less was the idea of
"faking" the evas build in the evas directory, finish all the .eo
generation there, then build the modules and make all the static files
ready. Then build everything in evas_goal.
Now, that we just build everything the same always, we can simply build
it in the evas way (removing the evas_goal hack FINALLY), as the same modules
are build statically and shared.
This also gives us the possibility to build the shared image loaders
*again* the the modules directory, which unbreaks peoples build scripts
who packaged loader files seperatly.
Reviewers: zmike, raster, cedric, stefan_schmidt
Reviewed By: zmike
Subscribers: #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10548
2019-10-29 09:54:55 -07:00
|
|
|
char subsystem[PATH_MAX];
|
2018-02-12 11:52:28 -08:00
|
|
|
|
meson: redo evas building
Summary:
before recent times we had to support static and shared building based
on the options of the user, which forced us to complicate our build with
the evas_goal hack. the evas_goal hack more or less was the idea of
"faking" the evas build in the evas directory, finish all the .eo
generation there, then build the modules and make all the static files
ready. Then build everything in evas_goal.
Now, that we just build everything the same always, we can simply build
it in the evas way (removing the evas_goal hack FINALLY), as the same modules
are build statically and shared.
This also gives us the possibility to build the shared image loaders
*again* the the modules directory, which unbreaks peoples build scripts
who packaged loader files seperatly.
Reviewers: zmike, raster, cedric, stefan_schmidt
Reviewed By: zmike
Subscribers: #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D10548
2019-10-29 09:54:55 -07:00
|
|
|
snprintf(subsystem, sizeof(subsystem), "evas/%s", type_str);
|
|
|
|
bs_mod_get(buffer, sizeof(buffer), subsystem, name);
|
|
|
|
if (!evas_file_path_exists(buffer))
|
|
|
|
buffer[0] = '\0';
|
2014-01-08 02:46:23 -08:00
|
|
|
}
|
2013-01-04 09:19:43 -08:00
|
|
|
}
|
2017-02-03 05:49:38 -08:00
|
|
|
#endif
|
2013-01-04 09:19:43 -08:00
|
|
|
|
|
|
|
if (buffer[0] == '\0')
|
|
|
|
snprintf(buffer, sizeof(buffer), "%s/%s/%s/%s/%s",
|
|
|
|
path, type_str, name, MODULE_ARCH, EVAS_MODULE_NAME);
|
2009-06-16 06:01:36 -07:00
|
|
|
|
2013-01-04 09:19:43 -08:00
|
|
|
if (!evas_file_path_is_file(buffer)) continue;
|
2009-06-16 06:01:36 -07:00
|
|
|
|
2014-07-01 04:25:04 -07:00
|
|
|
en = eina_module_new(buffer);
|
|
|
|
if (!en) continue;
|
2009-06-16 06:01:36 -07:00
|
|
|
|
2017-01-25 05:52:47 -08:00
|
|
|
if (type == EVAS_MODULE_TYPE_ENGINE)
|
|
|
|
eina_module_symbol_global_set(en, EINA_TRUE);
|
2014-07-11 03:13:37 -07:00
|
|
|
|
2014-07-01 04:25:04 -07:00
|
|
|
if (!eina_module_load(en))
|
|
|
|
{
|
|
|
|
eina_module_free(en);
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-23 02:29:57 -07:00
|
|
|
// this is intentional. the above module load if it succeeds
|
|
|
|
// registers the evas module below in the table that we then
|
|
|
|
// lookup in the hash... and then load that as a 2nd stage.
|
|
|
|
// since we will never unload a module once used it doesnt matter
|
|
|
|
// what happens to the handle anyway.
|
2014-07-01 04:25:04 -07:00
|
|
|
em = eina_hash_find(evas_modules[type], name);
|
|
|
|
if (em)
|
|
|
|
{
|
2017-01-25 06:40:07 -08:00
|
|
|
if (evas_module_load(em)) return em;
|
2014-07-01 04:25:04 -07:00
|
|
|
}
|
2009-06-16 06:01:36 -07:00
|
|
|
|
2014-07-01 04:25:04 -07:00
|
|
|
eina_module_free(en);
|
2006-01-14 04:13:38 -08:00
|
|
|
}
|
2009-06-16 06:01:36 -07:00
|
|
|
|
2006-01-14 04:13:38 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
Evas_Module *
|
|
|
|
evas_module_engine_get(int render_method)
|
|
|
|
{
|
2010-09-18 16:07:31 -07:00
|
|
|
if ((render_method <= 0) ||
|
2012-01-10 07:34:39 -08:00
|
|
|
((unsigned int)render_method > eina_array_count(evas_engines)))
|
2009-06-16 06:01:36 -07:00
|
|
|
return NULL;
|
|
|
|
return eina_array_data_get(evas_engines, render_method - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_module_foreach_image_loader(Eina_Hash_Foreach cb, const void *fdata)
|
|
|
|
{
|
|
|
|
eina_hash_foreach(evas_modules[EVAS_MODULE_TYPE_IMAGE_LOADER], cb, fdata);
|
|
|
|
}
|
|
|
|
|
2006-01-14 04:13:38 -08:00
|
|
|
int
|
|
|
|
evas_module_load(Evas_Module *em)
|
|
|
|
{
|
2006-01-14 15:36:52 -08:00
|
|
|
if (em->loaded) return 1;
|
2010-08-21 06:52:25 -07:00
|
|
|
if (!em->definition) return 0;
|
2006-01-14 15:36:52 -08:00
|
|
|
|
2009-06-17 06:10:00 -07:00
|
|
|
if (!em->definition->func.open(em)) return 0;
|
2009-06-16 06:01:36 -07:00
|
|
|
em->loaded = 1;
|
2007-08-13 05:13:03 -07:00
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
return 1;
|
2006-01-14 04:13:38 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_module_unload(Evas_Module *em)
|
|
|
|
{
|
|
|
|
if (!em->loaded)
|
|
|
|
return;
|
2010-08-21 06:52:25 -07:00
|
|
|
if (!em->definition)
|
2013-06-20 04:28:18 -07:00
|
|
|
return;
|
2009-06-16 06:01:36 -07:00
|
|
|
|
2018-02-12 11:52:28 -08:00
|
|
|
// for now lets not unload modules - they may still be in use.
|
2010-05-21 00:31:03 -07:00
|
|
|
// em->definition->func.close(em);
|
|
|
|
// em->loaded = 0;
|
2009-06-16 06:01:36 -07:00
|
|
|
|
2006-01-14 04:13:38 -08:00
|
|
|
}
|
|
|
|
|
2006-09-18 02:40:29 -07:00
|
|
|
void
|
|
|
|
evas_module_ref(Evas_Module *em)
|
|
|
|
{
|
2009-03-13 02:32:42 -07:00
|
|
|
LKL(em->lock);
|
2006-09-18 02:40:29 -07:00
|
|
|
em->ref++;
|
2009-03-13 02:32:42 -07:00
|
|
|
LKU(em->lock);
|
2006-09-18 02:40:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_module_unref(Evas_Module *em)
|
|
|
|
{
|
2009-03-13 02:32:42 -07:00
|
|
|
LKL(em->lock);
|
2006-09-18 02:40:29 -07:00
|
|
|
em->ref--;
|
2009-03-13 02:32:42 -07:00
|
|
|
LKU(em->lock);
|
2006-09-18 02:40:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int use_count = 0;
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_module_use(Evas_Module *em)
|
|
|
|
{
|
|
|
|
em->last_used = use_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_module_clean(void)
|
|
|
|
{
|
|
|
|
static int call_count = 0;
|
2009-06-16 06:01:36 -07:00
|
|
|
/* int ago; */
|
2019-08-08 15:55:40 -07:00
|
|
|
static signed char noclean = -1;
|
2009-06-16 06:01:36 -07:00
|
|
|
/* Eina_List *l; */
|
|
|
|
/* Evas_Module *em; */
|
2006-09-18 02:40:29 -07:00
|
|
|
|
2006-09-18 02:47:34 -07:00
|
|
|
/* only clean modules every 256 calls */
|
2006-09-18 02:40:29 -07:00
|
|
|
call_count++;
|
2006-09-18 02:47:34 -07:00
|
|
|
if (call_count <= 256) return;
|
2006-09-18 02:40:29 -07:00
|
|
|
call_count = 0;
|
|
|
|
|
|
|
|
if (noclean == -1)
|
|
|
|
{
|
2019-08-08 15:55:40 -07:00
|
|
|
if (getenv("EVAS_NOCLEAN")) noclean = 1;
|
|
|
|
else noclean = 0;
|
2006-09-18 02:40:29 -07:00
|
|
|
}
|
|
|
|
if (noclean == 1) return;
|
2007-08-13 05:13:03 -07:00
|
|
|
|
2007-05-04 01:18:07 -07:00
|
|
|
/* disable module cleaning for now - may cause instability with some modules */
|
|
|
|
return;
|
2007-08-13 05:13:03 -07:00
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
/* FIXME: Don't know what it is supposed to do. */
|
|
|
|
/* /\* incriment use counter = 28bits *\/ */
|
|
|
|
/* use_count++; */
|
|
|
|
/* if (use_count > 0x0fffffff) use_count = 0; */
|
|
|
|
|
|
|
|
/* /\* printf("CLEAN!\n"); *\/ */
|
|
|
|
/* /\* go through all modules *\/ */
|
|
|
|
/* EINA_LIST_FOREACH(evas_modules, l, em) */
|
|
|
|
/* { */
|
|
|
|
/* /\* printf("M %s %i %i\n", em->name, em->ref, em->loaded); *\/ */
|
|
|
|
/* /\* if the module is refernced - skip *\/ */
|
|
|
|
/* if ((em->ref > 0) || (!em->loaded)) continue; */
|
|
|
|
/* /\* how many clean cycles ago was this module last used *\/ */
|
|
|
|
/* ago = use_count - em->last_used; */
|
|
|
|
/* if (em->last_used > use_count) ago += 0x10000000; */
|
|
|
|
/* /\* if it was used last more than N clean cycles ago - unload *\/ */
|
|
|
|
/* if (ago > 5) */
|
|
|
|
/* { */
|
|
|
|
/* /\* printf(" UNLOAD %s\n", em->name); *\/ */
|
|
|
|
/* evas_module_unload(em); */
|
|
|
|
/* } */
|
|
|
|
/* } */
|
2006-09-18 02:40:29 -07:00
|
|
|
}
|
|
|
|
|
2012-08-03 21:14:38 -07:00
|
|
|
static Eina_Prefix *pfx = NULL;
|
|
|
|
|
2006-01-14 07:43:05 -08:00
|
|
|
/* will dlclose all the modules loaded and free all the structs */
|
2006-01-14 04:13:38 -08:00
|
|
|
void
|
|
|
|
evas_module_shutdown(void)
|
|
|
|
{
|
2009-06-16 06:01:36 -07:00
|
|
|
char *path;
|
|
|
|
int i;
|
2007-08-13 05:13:03 -07:00
|
|
|
|
2010-08-21 06:52:25 -07:00
|
|
|
for (i = 0; evas_static_module[i].shutdown; ++i)
|
2009-06-16 06:01:36 -07:00
|
|
|
evas_static_module[i].shutdown();
|
2006-01-15 02:24:37 -08:00
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
eina_hash_free(evas_modules[EVAS_MODULE_TYPE_ENGINE]);
|
2010-10-20 06:59:23 -07:00
|
|
|
evas_modules[EVAS_MODULE_TYPE_ENGINE] = NULL;
|
2009-06-16 06:01:36 -07:00
|
|
|
eina_hash_free(evas_modules[EVAS_MODULE_TYPE_IMAGE_LOADER]);
|
2010-10-20 06:59:23 -07:00
|
|
|
evas_modules[EVAS_MODULE_TYPE_IMAGE_LOADER] = NULL;
|
2009-06-16 06:01:36 -07:00
|
|
|
eina_hash_free(evas_modules[EVAS_MODULE_TYPE_IMAGE_SAVER]);
|
2010-10-20 06:59:23 -07:00
|
|
|
evas_modules[EVAS_MODULE_TYPE_IMAGE_SAVER] = NULL;
|
2009-06-16 06:01:36 -07:00
|
|
|
eina_hash_free(evas_modules[EVAS_MODULE_TYPE_OBJECT]);
|
2010-10-20 06:59:23 -07:00
|
|
|
evas_modules[EVAS_MODULE_TYPE_OBJECT] = NULL;
|
2016-10-12 02:39:10 -07:00
|
|
|
eina_hash_free(evas_modules[EVAS_MODULE_TYPE_VG_LOADER]);
|
|
|
|
evas_modules[EVAS_MODULE_TYPE_VG_LOADER] = NULL;
|
2016-10-13 23:52:51 -07:00
|
|
|
eina_hash_free(evas_modules[EVAS_MODULE_TYPE_VG_SAVER]);
|
|
|
|
evas_modules[EVAS_MODULE_TYPE_VG_SAVER] = NULL;
|
2009-06-16 06:01:36 -07:00
|
|
|
|
2016-12-06 11:34:56 -08:00
|
|
|
eina_tls_free(task);
|
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
EINA_LIST_FREE(evas_module_paths, path)
|
|
|
|
free(path);
|
2009-06-20 00:36:30 -07:00
|
|
|
|
|
|
|
eina_array_free(evas_engines);
|
|
|
|
evas_engines = NULL;
|
2012-08-03 21:14:38 -07:00
|
|
|
if (pfx)
|
|
|
|
{
|
|
|
|
eina_prefix_free(pfx);
|
|
|
|
pfx = NULL;
|
|
|
|
}
|
2006-01-14 04:13:38 -08:00
|
|
|
}
|
2006-03-02 00:06:10 -08:00
|
|
|
|
evas: Rename EAPI macro to EVAS_API in Evas library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
This patch is from a series of patches to rename EAPI symbols to
specific library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
LIBAPI is the only solution that works for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Reviewers: vtorri, woohyun, jptiz, lucas
Reviewed By: vtorri, lucas
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12214
2020-12-15 18:02:20 -08:00
|
|
|
EVAS_API int
|
2017-08-25 10:48:20 -07:00
|
|
|
_evas_module_engine_inherit(Evas_Func *funcs, char *name, size_t info)
|
2006-03-02 00:06:10 -08:00
|
|
|
{
|
|
|
|
Evas_Module *em;
|
2007-08-13 05:13:03 -07:00
|
|
|
|
2006-03-02 00:06:10 -08:00
|
|
|
em = evas_module_find_type(EVAS_MODULE_TYPE_ENGINE, name);
|
|
|
|
if (em)
|
|
|
|
{
|
2014-07-01 04:25:04 -07:00
|
|
|
if (evas_module_load(em))
|
|
|
|
{
|
|
|
|
/* FIXME: no way to unref */
|
|
|
|
evas_module_ref(em);
|
|
|
|
evas_module_use(em);
|
|
|
|
*funcs = *((Evas_Func *)(em->functions));
|
2017-08-25 10:48:20 -07:00
|
|
|
funcs->info_size = info;
|
2014-07-01 04:25:04 -07:00
|
|
|
return 1;
|
|
|
|
}
|
2006-03-02 00:06:10 -08:00
|
|
|
}
|
|
|
|
return 0;
|
2006-04-23 08:38:23 -07:00
|
|
|
}
|
2011-09-02 20:48:39 -07:00
|
|
|
|
evas: Rename EAPI macro to EVAS_API in Evas library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
This patch is from a series of patches to rename EAPI symbols to
specific library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
LIBAPI is the only solution that works for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Reviewers: vtorri, woohyun, jptiz, lucas
Reviewed By: vtorri, lucas
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12214
2020-12-15 18:02:20 -08:00
|
|
|
EVAS_API const char *
|
2011-09-02 20:48:39 -07:00
|
|
|
_evas_module_libdir_get(void)
|
|
|
|
{
|
|
|
|
if (!pfx) pfx = eina_prefix_new
|
2012-07-31 23:29:26 -07:00
|
|
|
(NULL, _evas_module_libdir_get, "EVAS", "evas", "checkme",
|
2011-09-02 20:48:39 -07:00
|
|
|
PACKAGE_BIN_DIR, PACKAGE_LIB_DIR, PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
|
2017-10-04 21:01:35 -07:00
|
|
|
if (!pfx) return "";
|
2011-09-02 20:48:39 -07:00
|
|
|
return eina_prefix_lib_get(pfx);
|
|
|
|
}
|
2013-02-13 03:35:46 -08:00
|
|
|
|
2015-06-04 03:42:38 -07:00
|
|
|
const char *
|
|
|
|
_evas_module_datadir_get(void)
|
|
|
|
{
|
|
|
|
if (!pfx) pfx = eina_prefix_new
|
|
|
|
(NULL, _evas_module_libdir_get, "EVAS", "evas", "checkme",
|
|
|
|
PACKAGE_BIN_DIR, PACKAGE_LIB_DIR, PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
|
|
|
|
if (!pfx) return NULL;
|
|
|
|
return eina_prefix_data_get(pfx);
|
|
|
|
}
|
|
|
|
|
2018-08-29 21:49:04 -07:00
|
|
|
/* deprecated */
|
evas: Rename EAPI macro to EVAS_API in Evas library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
This patch is from a series of patches to rename EAPI symbols to
specific library DSOs.
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
LIBAPI is the only solution that works for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Reviewers: vtorri, woohyun, jptiz, lucas
Reviewed By: vtorri, lucas
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12214
2020-12-15 18:02:20 -08:00
|
|
|
EVAS_API const char *
|
2013-02-13 03:35:46 -08:00
|
|
|
evas_cserve_path_get(void)
|
|
|
|
{
|
2018-08-29 21:49:04 -07:00
|
|
|
return NULL;
|
2013-02-13 03:35:46 -08:00
|
|
|
}
|