diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2013-10-02 15:07:25 +0900 |
---|---|---|
committer | Cedric Bail <cedric.bail@free.fr> | 2013-10-17 20:49:22 +0900 |
commit | aecb25df8ce6ee65150b8db914a99912d962a3ed (patch) | |
tree | 5ce485068deb2e08336a802596bd9c67a5e260e0 | |
parent | 8249deef2e4b3d48f6492078946a1e2977cabf7a (diff) | |
download | efl-aecb25df8ce6ee65150b8db914a99912d962a3ed.tar.gz |
evas/cserve2: Implement support for GL engine
Simply call the appropriate cache2 functions when possible
and check for usage of cache2 whenever an evas_cache_ function
is called.
This effectively adds cserve2 image (data) load support for the
GL engines. Fonts were already working out-of-the-box.
-rw-r--r-- | src/modules/evas/engines/gl_common/evas_gl_image.c | 124 |
1 files changed, 109 insertions, 15 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c b/src/modules/evas/engines/gl_common/evas_gl_image.c index 23177904fb..dfdea48a32 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_image.c +++ b/src/modules/evas/engines/gl_common/evas_gl_image.c @@ -1,4 +1,5 @@ #include "evas_gl_private.h" +#include "evas_cs2_private.h" void evas_gl_common_image_alloc_ensure(Evas_GL_Image *im) @@ -16,7 +17,13 @@ evas_gl_common_image_all_unload(Evas_Engine_GL_Context *gc) EINA_LIST_FOREACH(gc->shared->images, l, im) { - if (im->im) evas_cache_image_unload_data(&im->im->cache_entry); + if (im->im) + { + if (!evas_cache2_image_cached(&im->im->cache_entry)) + evas_cache_image_unload_data(&im->im->cache_entry); + else + evas_cache2_image_unload_data(&im->im->cache_entry); + } if (im->tex) { if (!im->tex->pt->dyn.img) @@ -141,7 +148,10 @@ _evas_gl_common_image(Evas_Engine_GL_Context *gc, RGBA_Image *im_im, Evas_Image_ im = calloc(1, sizeof(Evas_GL_Image)); if (!im) { - evas_cache_image_drop(&(im_im->cache_entry)); + if (!evas_cache2_image_cached(&im_im->cache_entry)) + evas_cache_image_drop(&(im_im->cache_entry)); + else + evas_cache2_image_close(&(im_im->cache_entry)); *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; return NULL; } @@ -163,9 +173,30 @@ evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const char *file, const ch { RGBA_Image *im_im; +#ifdef EVAS_CSERVE2 + if (evas_cserve2_use_get()) + { + im_im = (RGBA_Image *) evas_cache2_image_open + (evas_common_image_cache2_get(), file, key, lo, error); + if (im_im) + { + *error = evas_cache2_image_open_wait(&im_im->cache_entry); + if ((*error != EVAS_LOAD_ERROR_NONE) + && im_im->cache_entry.animated.animated) + { + evas_cache2_image_close(&im_im->cache_entry); + im_im = NULL; + } + else + goto image_loaded; + } + } +#endif + im_im = evas_common_load_image_from_file(file, key, lo, error); if (!im_im) return NULL; +image_loaded: return _evas_gl_common_image(gc, im_im, lo, error); } @@ -174,9 +205,30 @@ evas_gl_common_image_mmap(Evas_Engine_GL_Context *gc, Eina_File *f, const char * { RGBA_Image *im_im; +#ifdef EVAS_CSERVE2 + if (evas_cserve2_use_get() && !eina_file_virtual(f)) + { + im_im = (RGBA_Image *) evas_cache2_image_open + (evas_common_image_cache2_get(), eina_file_filename_get(f), key, lo, error); + if (im_im) + { + *error = evas_cache2_image_open_wait(&im_im->cache_entry); + if ((*error != EVAS_LOAD_ERROR_NONE) + && im_im->cache_entry.animated.animated) + { + evas_cache2_image_close(&im_im->cache_entry); + im_im = NULL; + } + else + goto image_loaded; + } + } +#endif + im_im = evas_common_load_image_from_mmap(f, key, lo, error); if (!im_im) return NULL; +image_loaded: return _evas_gl_common_image(gc, im_im, lo, error); } @@ -341,7 +393,10 @@ evas_gl_common_image_alpha_set(Evas_GL_Image *im, int alpha) im->alpha = alpha; if (!im->im) return im; evas_gl_common_image_alloc_ensure(im); - evas_cache_image_load_data(&im->im->cache_entry); + if (!evas_cache2_image_cached(&im->im->cache_entry)) + evas_cache_image_load_data(&im->im->cache_entry); + else + evas_cache2_image_load_data(&im->im->cache_entry); im->im->cache_entry.flags.alpha = alpha ? 1 : 0; if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE); @@ -376,7 +431,10 @@ evas_gl_common_image_native_enable(Evas_GL_Image *im) } if (im->im) { - evas_cache_image_drop(&im->im->cache_entry); + if (!evas_cache2_image_cached(&im->im->cache_entry)) + evas_cache_image_drop(&im->im->cache_entry); + else + evas_cache2_image_close(&im->im->cache_entry); im->im = NULL; } if (im->tex) @@ -395,7 +453,10 @@ evas_gl_common_image_native_disable(Evas_GL_Image *im) { if (im->im) { - evas_cache_image_drop(&im->im->cache_entry); + if (!evas_cache2_image_cached(&im->im->cache_entry)) + evas_cache_image_drop(&im->im->cache_entry); + else + evas_cache2_image_close(&im->im->cache_entry); im->im = NULL; } if (im->tex) @@ -451,7 +512,10 @@ evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint) } if (im->im) { - evas_cache_image_drop(&im->im->cache_entry); + if (evas_cache2_image_cached(&im->im->cache_entry)) + evas_cache_image_drop(&im->im->cache_entry); + else + evas_cache2_image_close(&im->im->cache_entry); im->im = NULL; } if (im->tex) @@ -466,7 +530,10 @@ evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint) { if (im->im) { - evas_cache_image_drop(&im->im->cache_entry); + if (evas_cache2_image_cached(&im->im->cache_entry)) + evas_cache_image_drop(&im->im->cache_entry); + else + evas_cache2_image_close(&im->im->cache_entry); im->im = NULL; } if (im->tex) @@ -510,7 +577,13 @@ evas_gl_common_image_free(Evas_GL_Image *im) { if (_evas_gl_image_cache_add(im)) return; } - if (im->im) evas_cache_image_drop(&im->im->cache_entry); + if (im->im) + { + if (!evas_cache2_image_cached(&im->im->cache_entry)) + evas_cache_image_drop(&im->im->cache_entry); + else + evas_cache2_image_close(&im->im->cache_entry); + } if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE); free(im); @@ -549,7 +622,10 @@ evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x, unsigned int y, un if (im->im) { evas_gl_common_image_alloc_ensure(im); - im->im = (RGBA_Image *)evas_cache_image_dirty(&im->im->cache_entry, x, y, w, h); + if (!evas_cache2_image_cached(&im->im->cache_entry)) + im->im = (RGBA_Image *)evas_cache_image_dirty(&im->im->cache_entry, x, y, w, h); + else + im->im = (RGBA_Image *)evas_cache2_image_dirty(&im->im->cache_entry, x, y, w, h); } im->dirty = 1; } @@ -588,16 +664,34 @@ evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im) if ((im->tex) && ((im->dirty) || (ie->animated.animated) || (ie->flags.updated_data))) { - evas_cache_image_load_data(&im->im->cache_entry); - evas_gl_common_texture_update(im->tex, im->im); - evas_cache_image_unload_data(&im->im->cache_entry); + if (!evas_cache2_image_cached(&im->im->cache_entry)) + { + evas_cache_image_load_data(&im->im->cache_entry); + evas_gl_common_texture_update(im->tex, im->im); + evas_cache_image_unload_data(&im->im->cache_entry); + } + else + { + evas_cache2_image_load_data(&im->im->cache_entry); + evas_gl_common_texture_update(im->tex, im->im); + evas_cache2_image_unload_data(&im->im->cache_entry); + } ie->flags.updated_data = 0; } if (!im->tex) { - evas_cache_image_load_data(&im->im->cache_entry); - im->tex = evas_gl_common_texture_new(gc, im->im); - evas_cache_image_unload_data(&im->im->cache_entry); + if (!evas_cache2_image_cached(&im->im->cache_entry)) + { + evas_cache_image_load_data(&im->im->cache_entry); + im->tex = evas_gl_common_texture_new(gc, im->im); + evas_cache_image_unload_data(&im->im->cache_entry); + } + else + { + evas_cache2_image_load_data(&im->im->cache_entry); + im->tex = evas_gl_common_texture_new(gc, im->im); + evas_cache2_image_unload_data(&im->im->cache_entry); + } } im->dirty = 0; if (!im->tex) return; |