summaryrefslogtreecommitdiff
path: root/src/modules/evas
diff options
context:
space:
mode:
authorHermet Park <chuneon.park@samsung.com>2021-02-18 13:21:16 +0900
committerHermet Park <chuneon.park@samsung.com>2021-02-18 13:21:16 +0900
commit23cce0129cad582fa892dba3e431f745a8009011 (patch)
tree833211c72ab7cb7517ee2a1f470a2e00543add24 /src/modules/evas
parentd33454cfdef203c3aa4ec33e46ae0829c7aa5efa (diff)
parent1842d3997a88e22421eddeed49be50a0db08b7ce (diff)
downloadefl-23cce0129cad582fa892dba3e431f745a8009011.tar.gz
Merge branch 'master' into devs/hermet/lottie
Diffstat (limited to 'src/modules/evas')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c3
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c1
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.c2
-rw-r--r--src/modules/evas/image_loaders/heif/evas_image_load_heif.c300
-rw-r--r--src/modules/evas/image_loaders/tga/evas_image_load_tga.c20
5 files changed, 313 insertions, 13 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c
index 5b40037560..26ff021cd4 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -381,7 +381,8 @@ evas_gl_symbols(void *(*GetProcAddress)(const char *name), const char *extsn)
FINDSYM(glsym_glProgramParameteri, "glProgramParameteriEXT", "GL_EXT_geometry_shader4", glsym_func_void);
FINDSYM(glsym_glProgramParameteri, "glProgramParameteriARB", "GL_ARB_geometry_shader4", glsym_func_void);
- FINDSYMN(secsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", "GL_OES_EGL_image_external", glsym_func_void);
+ FINDSYM(secsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", "GL_OES_EGL_image_external", glsym_func_void);
+ FINDSYM(secsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", "GL_OES_EGL_image", glsym_func_void);
// Old SEC extensions
FINDSYMN(secsym_eglMapImageSEC, "eglMapImageSEC", NULL, secsym_func_void_ptr);
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index a1c48ae451..021e798169 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -1167,7 +1167,6 @@ eng_image_orient_set(void *engine, void *image, Evas_Image_Orient orient)
{
im_new->tex = im->tex;
im_new->tex->references++;
- im_new->tex->pt->references++;
}
evas_gl_common_image_free(im);
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c
index a22e9d95db..580921ff01 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -1376,8 +1376,8 @@ eng_gl_symbols(Outbuf *ob)
// This is a GL extension
exts = (const char *) glGetString(GL_EXTENSIONS);
- FINDSYM(glsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", "GL_OES_EGL_image", glsym_func_void);
FINDSYM(glsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", "GL_OES_EGL_image_external", glsym_func_void);
+ FINDSYM(glsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", "GL_OES_EGL_image", glsym_func_void);
#else
diff --git a/src/modules/evas/image_loaders/heif/evas_image_load_heif.c b/src/modules/evas/image_loaders/heif/evas_image_load_heif.c
new file mode 100644
index 0000000000..bc9f2a1e06
--- /dev/null
+++ b/src/modules/evas/image_loaders/heif/evas_image_load_heif.c
@@ -0,0 +1,300 @@
+#define _XOPEN_SOURCE 600
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <math.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+
+#include <libheif/heif.h>
+
+#include "evas_common_private.h"
+#include "evas_private.h"
+
+static int _evas_loader_heif_log_dom = -1;
+
+#ifdef ERR
+# undef ERR
+#endif
+#define ERR(...) EINA_LOG_DOM_ERR(_evas_loader_heif_log_dom, __VA_ARGS__)
+
+#ifdef INF
+# undef INF
+#endif
+#define INF(...) EINA_LOG_DOM_INFO(_evas_loader_heif_log_dom, __VA_ARGS__)
+
+
+static void *
+evas_image_load_file_open_heif(Eina_File *f, Eina_Stringshare *key EINA_UNUSED,
+ Evas_Image_Load_Opts *opts EINA_UNUSED,
+ Evas_Image_Animated *animated EINA_UNUSED,
+ int *error EINA_UNUSED)
+{
+ return f;
+}
+
+static void
+evas_image_load_file_close_heif(void *loader_data EINA_UNUSED)
+{
+}
+
+static Eina_Bool
+evas_image_load_file_head_heif(void *loader_data,
+ Emile_Image_Property *prop,
+ int *error)
+{
+ Eina_File *f = loader_data;
+ void *map;
+ size_t length;
+ struct heif_error err;
+ struct heif_context* hc = NULL;
+ struct heif_image_handle* hdl = NULL;
+ struct heif_image* img = NULL;
+ Eina_Bool r = EINA_FALSE;
+
+ *error = EVAS_LOAD_ERROR_NONE;
+
+ map = eina_file_map_all(f, EINA_FILE_RANDOM);
+ length = eina_file_size_get(f);
+
+ // init prop struct with some default null values
+ prop->w = 0;
+ prop->h = 0;
+
+ if (!map || length < 1)
+ {
+ *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
+ goto on_error;
+ }
+
+ hc = heif_context_alloc();
+ if (!hc) {
+ INF("cannot allocate heif_context");
+ *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
+ goto on_error;
+ }
+
+ err = heif_context_read_from_memory_without_copy(hc, map, length, NULL);
+ if (err.code != heif_error_Ok) {
+ INF("%s", err.message);
+ *error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
+ goto on_error;
+ }
+
+ err = heif_context_get_primary_image_handle(hc, &hdl);
+ if (err.code != heif_error_Ok) {
+ INF("%s", err.message);
+ *error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
+ goto on_error;
+ }
+
+ int has_alpha = heif_image_handle_has_alpha_channel(hdl);
+
+ err = heif_decode_image(hdl, &img, heif_colorspace_RGB,
+ has_alpha ? heif_chroma_interleaved_RGBA : heif_chroma_interleaved_RGB,
+ NULL);
+ if (err.code != heif_error_Ok) {
+ INF("%s", err.message);
+ *error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
+ goto on_error;
+ }
+
+ prop->w = heif_image_get_width(img, heif_channel_interleaved);
+ prop->h = heif_image_get_height(img, heif_channel_interleaved);
+ if (has_alpha != 3)
+ prop->alpha = 1;
+
+ r = EINA_TRUE;
+
+ on_error:
+ if (img) {
+ heif_image_release(img);
+ }
+
+ if (hdl) {
+ heif_image_handle_release(hdl);
+ }
+
+ if (hc) {
+ heif_context_free(hc);
+ }
+ eina_file_map_free(f, map);
+ return r;
+}
+
+static Eina_Bool
+evas_image_load_file_data_heif(void *loader_data,
+ Emile_Image_Property *prop,
+ void *pixels,
+ int *error)
+{
+ Eina_File *f = loader_data;
+
+ void *map;
+ size_t length;
+ struct heif_error err;
+ struct heif_context* hc = NULL;
+ struct heif_image_handle* hdl = NULL;
+ struct heif_image* img = NULL;
+ unsigned int x, y;
+ int stride, bps = 3;
+ const uint8_t* data;
+ uint8_t* dd = (uint8_t*)pixels, *ds = NULL;
+ Eina_Bool result = EINA_FALSE;
+
+ map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
+ length = eina_file_size_get(f);
+ *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
+ if (!map || length < 1)
+ goto on_error;
+
+ *error = EVAS_LOAD_ERROR_GENERIC;
+ result = EINA_FALSE;
+
+ hc = heif_context_alloc();
+ if (!hc) {
+ INF("cannot allocate heif_context");
+ *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
+ goto on_error;
+ }
+
+ err = heif_context_read_from_memory_without_copy(hc, map, length, NULL);
+ if (err.code != heif_error_Ok) {
+ INF("%s", err.message);
+ *error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
+ goto on_error;
+ }
+
+ err = heif_context_get_primary_image_handle(hc, &hdl);
+ if (err.code != heif_error_Ok) {
+ INF("%s", err.message);
+ *error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
+ goto on_error;
+ }
+
+ err = heif_decode_image(hdl, &img, heif_colorspace_RGB,
+ prop->alpha ? heif_chroma_interleaved_RGBA : heif_chroma_interleaved_RGB,
+ NULL);
+ if (err.code != heif_error_Ok) {
+ INF("%s", err.message);
+ *error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
+ goto on_error;
+ }
+ if (prop->alpha) bps = 4;
+ data = heif_image_get_plane_readonly(img, heif_channel_interleaved, &stride);
+ ds = (uint8_t*)data;
+ for (y = 0; y < prop->h; y++)
+ for (x = 0; x < prop->w; x++)
+ {
+ if (bps == 3)
+ {
+ dd[3] = 0xff;
+ dd[0] = ds[2];
+ dd[1] = ds[1];
+ dd[2] = ds[0];
+ ds+=3;
+ dd+=4;
+ }
+ else
+ {
+ dd[0] = ds[2];
+ dd[1] = ds[1];
+ dd[2] = ds[0];
+ dd[3] = ds[3];
+ ds+=4;
+ dd+=4;
+ }
+ }
+ result = EINA_TRUE;
+
+ *error = EVAS_LOAD_ERROR_NONE;
+ prop->premul = EINA_TRUE;
+
+on_error:
+
+ if (map) eina_file_map_free(f, map);
+
+ if (img) {
+ // Do not free the image here when we pass it to gdk-pixbuf, as its memory will still be used by gdk-pixbuf.
+ heif_image_release(img);
+ }
+
+ if (hdl) {
+ heif_image_handle_release(hdl);
+ }
+
+ if (hc) {
+ heif_context_free(hc);
+ }
+
+ return result;
+}
+
+static const Evas_Image_Load_Func evas_image_load_heif_func = {
+ EVAS_IMAGE_LOAD_VERSION,
+ evas_image_load_file_open_heif,
+ evas_image_load_file_close_heif,
+ (void*) evas_image_load_file_head_heif,
+ NULL,
+ (void*) evas_image_load_file_data_heif,
+ NULL,
+ EINA_TRUE,
+ EINA_FALSE
+};
+
+static int
+module_open(Evas_Module *em)
+{
+ if (!em) return 0;
+ _evas_loader_heif_log_dom = eina_log_domain_register
+ ("evas-heif", EVAS_DEFAULT_LOG_COLOR);
+ if (_evas_loader_heif_log_dom < 0)
+ {
+ EINA_LOG_ERR("Can not create a module log domain.");
+ return 0;
+ }
+
+ em->functions = (void *)(&evas_image_load_heif_func);
+ return 1;
+}
+
+static void
+module_close(Evas_Module *em EINA_UNUSED)
+{
+ if (_evas_loader_heif_log_dom >= 0)
+ {
+ eina_log_domain_unregister(_evas_loader_heif_log_dom);
+ _evas_loader_heif_log_dom = -1;
+ }
+}
+
+static Evas_Module_Api evas_modapi =
+ {
+ EVAS_MODULE_API_VERSION,
+ "heif",
+ "none",
+ {
+ module_open,
+ module_close
+ }
+ };
+
+EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_IMAGE_LOADER, image_loader, heif);
+
+
+#ifndef EVAS_STATIC_BUILD_HEIF
+EVAS_EINA_MODULE_DEFINE(image_loader, heif);
+#endif
diff --git a/src/modules/evas/image_loaders/tga/evas_image_load_tga.c b/src/modules/evas/image_loaders/tga/evas_image_load_tga.c
index d8ef67fc59..34ee83e0b1 100644
--- a/src/modules/evas/image_loaders/tga/evas_image_load_tga.c
+++ b/src/modules/evas/image_loaders/tga/evas_image_load_tga.c
@@ -77,7 +77,7 @@ evas_image_load_file_head_tga(void *loader_data,
tga_footer *footer, tfooter;
char hasa = 0;
int w, h, bpp;
- int x, y;
+// int x, y;
Eina_Bool r = EINA_FALSE;
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
@@ -104,7 +104,6 @@ evas_image_load_file_head_tga(void *loader_data,
}
}
// else goto close_file;
- //printf("1\n");
filedata = (unsigned char *)filedata + sizeof(tga_header);
switch (header->imageType)
@@ -135,13 +134,14 @@ evas_image_load_file_head_tga(void *loader_data,
(header->colorMapSize == 24) ||
(header->colorMapSize == 32)))
goto close_file;
- x = (header->xOriginHi << 8) | (header->xOriginLo);
- y = (header->yOriginHi << 8) | (header->yOriginLo);
+// x = (header->xOriginHi << 8) | (header->xOriginLo);
+// y = (header->yOriginHi << 8) | (header->yOriginLo);
w = (header->widthHi << 8) | header->widthLo;
h = (header->heightHi << 8) | header->heightLo;
// x origin gerater that width, y origin greater than height - wrong file
- if ((x >= w) || (y >= h))
- goto close_file;
+// if ((x >= w) || (y >= h))
+// goto close_file;
+ printf("x\n");
// if descriptor has either of the top 2 bits set... not tga
if (header->descriptor & 0xc0)
goto close_file;
@@ -237,13 +237,13 @@ evas_image_load_file_data_tga(void *loader_data,
(header->colorMapSize == 24) ||
(header->colorMapSize == 32)))
goto close_file;
- x = (header->xOriginHi << 8) | (header->xOriginLo);
- y = (header->yOriginHi << 8) | (header->yOriginLo);
+// x = (header->xOriginHi << 8) | (header->xOriginLo);
+// y = (header->yOriginHi << 8) | (header->yOriginLo);
w = (header->widthHi << 8) | header->widthLo;
h = (header->heightHi << 8) | header->heightLo;
// x origin gerater that width, y origin greater than height - wrong file
- if ((x >= w) || (y >= h))
- goto close_file;
+// if ((x >= w) || (y >= h))
+// goto close_file;
// if descriptor has either of the top 2 bits set... not tga
if (header->descriptor & 0xc0)
goto close_file;