Evas GL common: Disable evas gl preload by default
authorJean-Philippe Andre <jp.andre@samsung.com>
Wed, 4 Mar 2015 08:11:26 +0000 (17:11 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Wed, 4 Mar 2015 08:31:31 +0000 (17:31 +0900)
Unfortunately, this "feature" has many problems and does not really
fix those it was supposed to address:

- Elm Photocam becomes horrible to use (the transition from
  low-res to high-res tiles triggers this miniature path).

- Evas async preload callback is called before the full image
  is ready (ie. the texture is not uploaded yet), when really
  the preload callback should be triggered only once the image
  is 100% ready. (TODO)

- Sometimes the miniature image keeps being used even though the
  main image has been uploaded (eg. with E background). Maybe the
  object image is not redrawn when it should.

- This uses a separate thread for the upload, which is both a good
  and bad idea because we need to do a make current. Also, this does
  not upload the full-res image tile by tile, but only in one pass,
  thus blocking the render loop until finished.

This patch changes the env var from "EVAS_GL_NOPRELOAD" to
"EVAS_GL_PRELOAD" (and only "1" will enable).

Sorry Cedric, we can talk later about how to improve this.

src/modules/evas/engines/gl_common/evas_gl_common.h
src/modules/evas/engines/gl_common/evas_gl_preload.c
src/modules/evas/engines/gl_common/evas_gl_texture.c

index 3602319..24e926f 100644 (file)
@@ -659,8 +659,9 @@ EAPI void         evas_gl_common_image_native_disable(Evas_GL_Image *im);
 EAPI void         evas_gl_common_image_free(Evas_GL_Image *im);
 EAPI void         evas_gl_common_image_native_enable(Evas_GL_Image *im);
 
-EAPI int evas_gl_preload_init(void);
-EAPI int evas_gl_preload_shutdown(void);
+EAPI int          evas_gl_preload_init(void);
+EAPI int          evas_gl_preload_shutdown(void);
+EAPI Eina_Bool    evas_gl_preload_enabled(void);
 
 EAPI Evas_Engine_GL_Context  *evas_gl_common_context_new(void);
 
index 17836c2..5344473 100644 (file)
@@ -351,7 +351,8 @@ evas_gl_preload_target_unregister(Evas_GL_Texture *tex, Eo *target)
 EAPI int
 evas_gl_preload_init(void)
 {
-   if (getenv("EVAS_GL_NOPRELOAD")) return 0;
+   const char *s = getenv("EVAS_GL_PRELOAD");
+   if (!s || (atoi(s) != 1)) return 0;
    if (async_loader_init++) return async_loader_init;
 
    eina_lock_new(&async_loader_lock);
@@ -368,7 +369,8 @@ evas_gl_preload_init(void)
 EAPI int
 evas_gl_preload_shutdown(void)
 {
-   if (getenv("EVAS_GL_NOPRELOAD")) return 0;
+   const char *s = getenv("EVAS_GL_PRELOAD");
+   if (!s || (atoi(s) != 1)) return 0;
    if (--async_loader_init) return async_loader_init;
 
    async_loader_exit = EINA_TRUE;
@@ -381,3 +383,9 @@ evas_gl_preload_shutdown(void)
 
    return async_loader_init;
 }
+
+EAPI Eina_Bool
+evas_gl_preload_enabled(void)
+{
+   return (async_loader_init >= 1);
+}
index 6c3b034..4f0c0b3 100644 (file)
@@ -1267,7 +1267,10 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im)
      }
 
    // if preloaded, then async push it in after uploading a miniature of it
-   if (im->cache_entry.flags.preload_done && tex->w > 2 * EVAS_GL_TILE_SIZE && tex->h > 2 * EVAS_GL_TILE_SIZE)
+   if (im->cache_entry.flags.preload_done
+       && (tex->w > (2 * EVAS_GL_TILE_SIZE))
+       && (tex->h > (2 * EVAS_GL_TILE_SIZE))
+       && evas_gl_preload_enabled())
      {
         Evas_GL_Texture_Async_Preload *async;
         unsigned char *in;