Commit Graph

55 Commits

Author SHA1 Message Date
Vincent Torri fd24e89144 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 18:51:27 +01:00
Carsten Haitzler f620e0edd1 Revert "Evas: add avif evas loader"
This reverts commit dd23a6c84a.

i didn't mean to push this yet...
2020-07-14 10:55:44 +01:00
Vincent Torri dd23a6c84a Evas: add avif evas loader
Summary: Add AV1 image file loader to Evas

Test Plan: test executable with avif files found in libavif project

Reviewers: raster

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12051
2020-07-14 10:09:22 +01:00
Marcel Hollerbach 28f630ba41 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 12:54:56 -04:00
Carsten Haitzler f8e027c395 build - efl run in tree - make exception for image loaders/savers
due to meson's insistence on naming even moudles libmodule.so, and our
complexity of build as in the previous commits ... have a special case
for in tree module loading for these.
2019-10-05 20:00:52 +01:00
Carsten Haitzler 9149767184 getenv - reduce continually calling getenv for the same vars do once
do it once and remember the result from the first one. drops overhead
for sure by a chunk i actually could see in perf reports like about 1-2%
of cpu...
2019-08-08 23:57:02 +01:00
Hermet Park 23af6ec640 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 17:35:48 +09:00
Chris Michael 78d5c4bdae evas-file: Remove cserve2 support
Summary:
ref T7226
Depends on D6935

Reviewers: raster, cedric, zmike, Hermet

Reviewed By: Hermet

Subscribers: #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7226

Differential Revision: https://phab.enlightenment.org/D6937
2018-08-30 13:49:04 +09:00
Marcel Hollerbach 7ef8ab559d evas: support wayland static engine loading
Summary: This fixes static loading of the here changes engines.

Reviewers: ManMower, devilhorns

Reviewed By: devilhorns

Subscribers: cedric, #reviewers, #committers, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6795
2018-08-14 17:12:07 -04:00
Marcel Hollerbach 09fd1c273c evas: use new bs static lib 2018-02-17 21:17:58 +01:00
Vincent Torri 4ae6eeb2cf efl: remove _MSC_VER (Visual Studio macro) usage in source code 2018-01-04 12:59:47 -08:00
Vitalii Vorobiov 7d9c1256a3 vg_savers/svg: empty (for now) module that will save svg in original file
Just as a starter to make a working background that, later on, will go
through Svg_Node's and build a certain source code to be saved in SVG
picture as a file
2017-11-07 11:54:09 +09:00
Cedric Bail c8c4572d70 evas: remove duplicated code and rely on Efl.File { get; set; }
We can almost remove image_load from the engine backend after this patch.
One little bit left in Evas_3D.
2017-10-04 21:01:35 -07:00
Cedric BAIL d179a5c2a9 efl: remove PS3 backend.
This backend has received no patch and maintenance from anyone who could
actually test it over the last few years. After talking with KaKaRoTo it
is best to remove it. If anyone want to take over its maintenance, you
are welcome to revert this patch.
2017-08-25 10:48:42 -07:00
Cedric BAIL 29cde0ee81 evas: make the info size a parameter of the function to make it safer to roll in. 2017-08-25 10:48:20 -07:00
Carsten Haitzler 60d2bd233b evas module load add comments pointing out this is intentional ptr loss 2017-07-23 18:29:57 +09:00
Jean-Philippe Andre 3cb6d55ef0 evas: Fix module memleak during evas_shutdown
This fixes a minor memory leak during shutdown.

Note: This does NOT perform the dlclose (and still leaks the
Eina_Module descriptor). Calling dlclose leads to a whole lot
of other issues, so we avoid it.
2017-02-21 15:15:51 +09:00
Gustavo Sverzut Barbieri 8dc853f230 ifdef RUN_IN_TREE logic.
This logic is only needed for autotools, cmake will replicate the
installation file structure and thus eina_prefix works out of box.
2017-02-03 12:36:38 -02:00
Chris Michael 51684536f0 Revert "evas: Fix resource leak in evas_module_find_type"
Reverting this as it causes crashes in Terminology and other EFL apps.
Needs investigation.

This reverts commit 8b2ca30eb5.
2017-01-25 09:40:58 -05:00
Chris Michael 8b2ca30eb5 evas: Fix resource leak in evas_module_find_type
Coverity reports a resource leak here if we successfully load the evas
module as we were never freeing the eina_module here. Previously we
would just return the evas module without proper cleanup of the
eina_module. This patch fixes the leak by calling eina_module_free if
we successfully load the evas module.

Fixes CID1367503

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-01-25 09:09:38 -05:00
Chris Michael 54655d65a3 evas: Minor formatting fix
NB: No functional changes

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-01-25 09:09:38 -05:00
Cedric BAIL 27a47da15b evas: add infrastructure for Evas_Loader to know if what they are working on is still useful. 2016-12-06 16:26:08 -08:00
Cedric Bail ccc1552380 evas: make sure that we initialize module correctly in all case. 2016-11-29 12:06:45 -08:00
Cedric Bail b6eb284c68 evas: remove useless code.
Since we disable the possibility to shutdown evas module, this code
has been useless. Let's remove it.
2016-11-29 12:06:07 -08:00
Subhransu Mohanty 8b7f060946 evas/module: add a new module in vg_saver for eet
Reviewers: cedric, jpeg

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4350
2016-10-14 15:52:51 +09:00
Subhransu Mohanty 45b103eb0a evas/module: add a new module in vg_loader for eet
Reviewers: jpeg

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4347
2016-10-13 17:09:39 +09:00
Subhransu Mohanty 0d9b168146 evas/module: Added a new module vg_loader for svg
Reviewers: cedric, jpeg

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4346
2016-10-12 18:39:10 +09:00
Carsten Haitzler 46b97aba78 evas module load - make coverity happy but not a bug
silence CID 1357364
2016-07-08 18:59:21 +09:00
Carsten Haitzler 9527240d74 efl - fix lots of little init/shutdown pairs that are wrong
i've fixed almost all the eina init/shutdown pairs to do the right
thing now... except one (ecore_shutdown) with comment inline where
eo_shutdown is not called. if this is called we are in crash land.
this needs further inspection.
2016-07-04 21:30:34 +09:00
Carsten Haitzler 22869bb94e evas - fix evas module locks to init/del when movile created/destroyed
we initted when we load and unload. this led to races with
locking/unlocking elsewhere as these expected us to be initted and we
were not yet. this fixes that!

@fix
2015-12-12 23:37:16 +09:00
Jean-Philippe Andre f3e16bc485 Evas filters: Implement Lua classes for colors & buffer
Reuse previous code for buffer. Keeps API stability.

The new class "color" is here for a more convenient color
representation. This way, colors can be represented in more
natural ways like: {r,g,b[,a]}, 0xaarrggbb, "red", "#rrggbb"

Class color is implemented in pure Lua, and adds a .lua file
to Evas' share folder.
2015-06-25 14:36:08 +09:00
Bogdan Devichev 043055fc8e evas: preparation of places for model_saver_loader separated from image_saver_loader. 2014-12-23 21:13:43 +01:00
Carsten Haitzler a14e0b8b32 fix evas modules to never free eina module - fixes seg on shutdown in x
this fixes T1946
2014-12-23 15:11:18 +09:00
Cedric BAIL 3fbe90ae53 eina: rename to eina_module_symbol_global_set
As discussed on the ML, eina_module_global_set should become eina_module_symbol_global_set.
2014-08-11 14:52:51 +02:00
Cedric BAIL 709ad7adb5 evas: load engine symbol into global namespace. 2014-07-11 15:32:51 +02:00
Jean-Philippe Andre c424153867 Evas: Add DDS image file loader
@feature: Add a Micrsoft DirectDraw Surface file loader
2014-07-03 11:37:48 +09:00
Carsten Haitzler 64d54ed964 fix tabe/whitespace format issues in evas module 2014-07-01 20:25:04 +09:00
Carsten Haitzler ae63d023dd fix static jpeg saver usage due to defines being removed from config.h 2014-07-01 20:22:42 +09:00
Cedric BAIL 0609779f17 evas: add TGV saver module. 2014-04-01 22:00:13 +09:00
Cedric BAIL 961ecab040 evas: add a tgv loader.
The TGV file format is specifically created for Evas. It is designed to allow
region decompression and parallele decompression with a fast path for GPU that
do handle ETC1 compression. Plan for adding other compression method will come
later.
2014-04-01 22:00:13 +09:00
Carsten Haitzler e8c13118eb fix mingw build for setuid fix/checks 2014-01-08 22:06:41 +09:00
Carsten Haitzler b95ef3801f setuid safeness - ensure if an app that is setuid doesn't do bad things
this makes efl ignore certain env vars for thnigs and entirely removes
user modules (that no one ever used) etc. etc. to ensure that *IF* an
app is setuid, there isn't a priv escalation path that is easy.
2014-01-08 19:46:23 +09:00
Vincent Torri 3b8b2ac66c evas: add JPEG 2000 loader.
This add finally support for JPEG 2000, but be aware that libopenjpeg
is very badly managed. There is currently only version 1.5.x that does
provide the right files, is usable by a third party and portable. You
can seriously forget any other version.
2013-10-01 16:38:44 +09:00
Rajesh P S 916f047935 evas: unset the right backend when unregistering module. 2013-07-30 14:54:26 +09:00
Jean-Philippe Andre c39b714868 evas/modules: Add preprocessor ifs
We'll want to distinguish full builds for evas and partial
builds for cserve2 slaves.

Signed-off-by: Cedric Bail <cedric.bail@samsung.com>
2013-07-02 16:58:10 +09:00
Sebastian Dransfeld 336f6ec328 efl: formatting 2013-06-20 13:28:18 +02:00
Sebastian Dransfeld 51023d2d4f evas: Keep sane name for public header
Evas_Common.h should be used for the public header, and rather rename
evas_common.h internal header to another name.

Sa:
Evas_Common_Header.h -> Evas_Common.h
evas_common.h -> evas_common_private.h

Shouldn't have both Evas_Common.h and evas_common.h because of case
insensitive filesystems.
2013-06-20 12:53:29 +02:00
Cedric Bail d1bed386bd evas: correctly detect if loader support asynchronous preloading.
This is an astonishing bug, I wonder since how long it has been there. It
is basically due to the use of void * and a wrong cast. Type checking is
clearly useful, let's use it more !
2013-06-04 11:22:13 +09:00
Igor Murzov 7a794f8477 evas: Add WebP image saver 2013-03-09 14:11:35 +04:00
Carsten Haitzler 179fd31b77 add api and lets test it - i'll document it later, but need to test
first.



SVN revision: 83867
2013-02-13 11:35:46 +00:00