evas/cserve2: Fix image preload with gl-x11 engine

Cserves supports only the SW (xlib) and GL (gl-x11) engines.
Also, improve cs2 support for some lesser used functions in the
gl_x11 engine.
This commit is contained in:
Jean-Philippe Andre 2013-10-29 19:06:33 +09:00
parent b3debcc3e1
commit 82e8028b5d
7 changed files with 84 additions and 9 deletions

View File

@ -307,6 +307,7 @@ _evas_cache2_image_preloaded_cb(void *data, Eina_Bool success)
ie->cache2->preload = eina_list_remove(ie->cache2->preload, ie);
ie->flags.preload_done = success;
ie->flags.updated_data = EINA_TRUE;
while ((tmp = ie->targets))
{

View File

@ -66,6 +66,7 @@ EAPI void evas_cache2_image_close(Image_Entry *im);
EAPI int evas_cache2_image_load_data(Image_Entry *ie);
EAPI void evas_cache2_image_unload_data(Image_Entry *im);
EAPI void evas_cache2_image_preload_data(Image_Entry *im, const void *target);
EAPI void evas_cache2_image_preload_cancel(Image_Entry *im, const void *target);
EAPI void evas_cache2_image_cache_key_create(char *hkey, const char *path, size_t pathlen, const char *key, size_t keylen, const Evas_Image_Load_Opts *lo);
EAPI DATA32 * evas_cache2_image_pixels(Image_Entry *im);

View File

@ -8,6 +8,12 @@ void
evas_gl_common_image_alloc_ensure(Evas_GL_Image *im)
{
if (!im->im) return;
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&im->im->cache_entry))
im->im = (RGBA_Image *)evas_cache2_image_size_set(&im->im->cache_entry,
im->w, im->h);
else
#endif
im->im = (RGBA_Image *)evas_cache_image_size_set(&im->im->cache_entry,
im->w, im->h);
}

View File

@ -1,5 +1,9 @@
#include "evas_gl_private.h"
#ifdef EVAS_CSERVE2
#include "evas_cs2_private.h"
#endif
static Eina_Thread async_loader_thread;
static Eina_Condition async_loader_cond;
static Eina_Lock async_loader_lock;
@ -50,6 +54,11 @@ evas_gl_preload_pop(Evas_GL_Texture *tex)
if (running) evas_gl_preload_render_lock(tmp_cb, tmp_data);
evas_gl_common_texture_free(async_current->tex, EINA_FALSE);
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&async_current->im->cache_entry))
evas_cache2_image_close(&async_current->im->cache_entry);
else
#endif
evas_cache_image_drop(&async_current->im->cache_entry);
free(async_current);
@ -66,6 +75,11 @@ evas_gl_preload_pop(Evas_GL_Texture *tex)
async_loader_tex = eina_list_remove_list(async_loader_tex, l);
evas_gl_common_texture_free(async->tex, EINA_FALSE);
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&async->im->cache_entry))
evas_cache2_image_close(&async->im->cache_entry);
else
#endif
evas_cache_image_drop(&async->im->cache_entry);
free(async);
@ -100,6 +114,11 @@ _evas_gl_preload_main_loop_wakeup(void)
async->tex->aptt = NULL;
evas_gl_common_texture_free(async->tex, EINA_FALSE);
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&async->im->cache_entry))
evas_cache2_image_close(&async->im->cache_entry);
else
#endif
evas_cache_image_drop(&async->im->cache_entry);
free(async);
}

View File

@ -941,6 +941,11 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im)
async->tex = tex;
async->tex->references++;
async->im = im;
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&async->im->cache_entry))
evas_cache2_image_ref(&async->im->cache_entry);
else
#endif
evas_cache_image_ref(&async->im->cache_entry);
async->unpack_row_length = tex->gc->shared->info.unpack_row_length;
@ -949,6 +954,11 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im)
// Failed to start asynchronous upload, likely due to preload not being supported by the backend
async->tex->references--;
#ifdef EVAS_CSERVE2
if (evas_cache2_image_cached(&async->im->cache_entry))
evas_cache2_image_close(&async->im->cache_entry);
else
#endif
evas_cache_image_drop(&async->im->cache_entry);
free(async);

View File

@ -14,6 +14,10 @@
# error gl_x11 should not get compiled if dlsym is not found on the system!
#endif
#ifdef EVAS_CSERVE2
#include "evas_cs2_private.h"
#endif
#define EVAS_GL_NO_GL_H_CHECK 1
#include "Evas_GL.h"
@ -1816,7 +1820,14 @@ eng_image_alpha_set(void *data, void *image, int has_alpha)
Evas_GL_Image *im_new;
if (!im->im->image.data)
evas_cache_image_load_data(&im->im->cache_entry);
{
#ifdef EVAS_CSERVE2
if (evas_cserve2_use_get() && 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);
}
evas_gl_common_image_alloc_ensure(im);
im_new = evas_gl_common_image_new_from_copied_data
(im->gc, im->im->cache_entry.w, im->im->cache_entry.h,
@ -2745,7 +2756,12 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
return NULL;
}
error = evas_cache_image_load_data(&im->im->cache_entry);
#ifdef EVAS_CSERVE2
if (evas_cserve2_use_get() && evas_cache2_image_cached(&im->im->cache_entry))
error = evas_cache2_image_load_data(&im->im->cache_entry);
else
#endif
error = evas_cache_image_load_data(&im->im->cache_entry);
evas_gl_common_image_alloc_ensure(im);
switch (im->cs.space)
{
@ -2874,7 +2890,13 @@ eng_image_data_preload_request(void *data, void *image, const Eo *target)
if (gim->native.data) return;
im = (RGBA_Image *)gim->im;
if (!im) return;
evas_cache_image_preload_data(&im->cache_entry, target, NULL, NULL, NULL);
#ifdef EVAS_CSERVE2
if (evas_cserve2_use_get() && evas_cache2_image_cached(&im->cache_entry))
evas_cache2_image_preload_data(&im->cache_entry, target);
else
#endif
evas_cache_image_preload_data(&im->cache_entry, target, NULL, NULL, NULL);
if (!gim->tex)
gim->tex = evas_gl_common_texture_new(re->win->gl_context, gim->im);
evas_gl_preload_target_register(gim->tex, (Eo*) target);
@ -2890,7 +2912,13 @@ eng_image_data_preload_cancel(void *data EINA_UNUSED, void *image, const Eo *tar
if (gim->native.data) return;
im = (RGBA_Image *)gim->im;
if (!im) return;
evas_cache_image_preload_cancel(&im->cache_entry, target);
#ifdef EVAS_CSERVE2
if (evas_cserve2_use_get() && evas_cache2_image_cached(&im->cache_entry))
evas_cache2_image_preload_cancel(&im->cache_entry, target);
else
#endif
evas_cache_image_preload_cancel(&im->cache_entry, target);
evas_gl_preload_target_unregister(gim->tex, (Eo*) target);
}
@ -3396,7 +3424,12 @@ eng_pixel_alpha_get(void *image, int x, int y, DATA8 *alpha, int src_region_x, i
{
DATA32 *pixel;
evas_cache_image_load_data(&im->im->cache_entry);
#ifdef EVAS_CSERVE2
if (evas_cserve2_use_get() && 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);
if (!im->im->cache_entry.flags.loaded)
{
ERR("im %p has no pixels loaded yet", im);

View File

@ -1195,12 +1195,17 @@ static void
eng_image_data_preload_cancel(void *data EINA_UNUSED, void *image, const Eo *target)
{
RGBA_Image *im = image;
#ifdef EVAS_CSERVE2
if (evas_cserve2_use_get() && evas_cache2_image_cached(&im->cache_entry))
return;
#endif
if (!im) return;
#ifdef EVAS_CSERVE2
if (evas_cserve2_use_get() && evas_cache2_image_cached(&im->cache_entry))
{
evas_cache2_image_preload_cancel(&im->cache_entry, target);
return;
}
#endif
evas_cache_image_preload_cancel(&im->cache_entry, target);
}