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.
This commit is contained in:
Jean-Philippe Andre 2013-10-02 15:07:25 +09:00
parent 2cd0b316f1
commit 3889feca24
1 changed files with 132 additions and 15 deletions

View File

@ -1,5 +1,9 @@
#include "evas_gl_private.h"
#ifdef EVAS_CSERVE2
#include "evas_cs2_private.h"
#endif
void
evas_gl_common_image_alloc_ensure(Evas_GL_Image *im)
{
@ -16,7 +20,15 @@ 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)
{
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&im->im->cache_entry))
evas_cache2_image_unload_data(&im->im->cache_entry);
else
#endif
evas_cache_image_unload_data(&im->im->cache_entry);
}
if (im->tex)
{
if (!im->tex->pt->dyn.img)
@ -141,7 +153,12 @@ _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));
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&im_im->cache_entry))
evas_cache2_image_close(&(im_im->cache_entry));
else
#endif
evas_cache_image_drop(&(im_im->cache_entry));
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
return NULL;
}
@ -163,6 +180,26 @@ 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
return _evas_gl_common_image(gc, im_im, lo, error);
}
}
#endif
im_im = evas_common_load_image_from_file(file, key, lo, error);
if (!im_im) return NULL;
@ -174,6 +211,26 @@ 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
return _evas_gl_common_image(gc, im_im, lo, error);
}
}
#endif
im_im = evas_common_load_image_from_mmap(f, key, lo, error);
if (!im_im) return NULL;
@ -341,7 +398,12 @@ 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);
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&im->im->cache_entry))
evas_cache2_image_load_data(&im->im->cache_entry);
else
#endif
evas_cache_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 +438,12 @@ evas_gl_common_image_native_enable(Evas_GL_Image *im)
}
if (im->im)
{
evas_cache_image_drop(&im->im->cache_entry);
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&im->im->cache_entry))
evas_cache2_image_close(&im->im->cache_entry);
else
#endif
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
}
if (im->tex)
@ -395,7 +462,12 @@ evas_gl_common_image_native_disable(Evas_GL_Image *im)
{
if (im->im)
{
evas_cache_image_drop(&im->im->cache_entry);
#ifdef EVAS_CSERVE2
if (!evas_cache2_image_cached(&im->im->cache_entry))
evas_cache2_image_close(&im->im->cache_entry);
else
#endif
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
}
if (im->tex)
@ -451,7 +523,12 @@ evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint)
}
if (im->im)
{
evas_cache_image_drop(&im->im->cache_entry);
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&im->im->cache_entry))
evas_cache2_image_close(&im->im->cache_entry);
else
#endif
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
}
if (im->tex)
@ -466,7 +543,12 @@ evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint)
{
if (im->im)
{
evas_cache_image_drop(&im->im->cache_entry);
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&im->im->cache_entry))
evas_cache2_image_close(&im->im->cache_entry);
else
#endif
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
}
if (im->tex)
@ -510,7 +592,15 @@ 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)
{
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&im->im->cache_entry))
evas_cache2_image_close(&im->im->cache_entry);
else
#endif
evas_cache_image_drop(&im->im->cache_entry);
}
if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE);
free(im);
@ -549,7 +639,12 @@ 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);
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&im->im->cache_entry))
im->im = (RGBA_Image *)evas_cache2_image_dirty(&im->im->cache_entry, x, y, w, h);
else
#endif
im->im = (RGBA_Image *)evas_cache_image_dirty(&im->im->cache_entry, x, y, w, h);
}
im->dirty = 1;
}
@ -588,16 +683,38 @@ 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);
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&im->im->cache_entry))
{
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);
}
else
#endif
{
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);
}
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);
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&im->im->cache_entry))
{
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);
}
else
#endif
{
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);
}
}
im->dirty = 0;
if (!im->tex) return;