summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-10-02 15:07:25 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:15 +0900
commit3889feca24ad3dba2aead16261a6b8dde0687b57 (patch)
tree25a42bb93d0e582abbc8d9be482555c8a0f89e94 /src/modules
parent2cd0b316f156efef4891dff9b1aba23ae50f1ff5 (diff)
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.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_image.c147
1 files changed, 132 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..36b40aa5f4 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_image.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_image.c
@@ -1,5 +1,9 @@
1#include "evas_gl_private.h" 1#include "evas_gl_private.h"
2 2
3#ifdef EVAS_CSERVE2
4#include "evas_cs2_private.h"
5#endif
6
3void 7void
4evas_gl_common_image_alloc_ensure(Evas_GL_Image *im) 8evas_gl_common_image_alloc_ensure(Evas_GL_Image *im)
5{ 9{
@@ -16,7 +20,15 @@ evas_gl_common_image_all_unload(Evas_Engine_GL_Context *gc)
16 20
17 EINA_LIST_FOREACH(gc->shared->images, l, im) 21 EINA_LIST_FOREACH(gc->shared->images, l, im)
18 { 22 {
19 if (im->im) evas_cache_image_unload_data(&im->im->cache_entry); 23 if (im->im)
24 {
25#ifdef EVAS_CSERVE2
26 if (evas_cache2_image_cached(&im->im->cache_entry))
27 evas_cache2_image_unload_data(&im->im->cache_entry);
28 else
29#endif
30 evas_cache_image_unload_data(&im->im->cache_entry);
31 }
20 if (im->tex) 32 if (im->tex)
21 { 33 {
22 if (!im->tex->pt->dyn.img) 34 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_
141 im = calloc(1, sizeof(Evas_GL_Image)); 153 im = calloc(1, sizeof(Evas_GL_Image));
142 if (!im) 154 if (!im)
143 { 155 {
144 evas_cache_image_drop(&(im_im->cache_entry)); 156#ifdef EVAS_CSERVE2
157 if (evas_cache2_image_cached(&im_im->cache_entry))
158 evas_cache2_image_close(&(im_im->cache_entry));
159 else
160#endif
161 evas_cache_image_drop(&(im_im->cache_entry));
145 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; 162 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
146 return NULL; 163 return NULL;
147 } 164 }
@@ -163,6 +180,26 @@ evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const char *file, const ch
163{ 180{
164 RGBA_Image *im_im; 181 RGBA_Image *im_im;
165 182
183#ifdef EVAS_CSERVE2
184 if (evas_cserve2_use_get())
185 {
186 im_im = (RGBA_Image *) evas_cache2_image_open
187 (evas_common_image_cache2_get(), file, key, lo, error);
188 if (im_im)
189 {
190 *error = evas_cache2_image_open_wait(&im_im->cache_entry);
191 if ((*error != EVAS_LOAD_ERROR_NONE)
192 && im_im->cache_entry.animated.animated)
193 {
194 evas_cache2_image_close(&im_im->cache_entry);
195 im_im = NULL;
196 }
197 else
198 return _evas_gl_common_image(gc, im_im, lo, error);
199 }
200 }
201#endif
202
166 im_im = evas_common_load_image_from_file(file, key, lo, error); 203 im_im = evas_common_load_image_from_file(file, key, lo, error);
167 if (!im_im) return NULL; 204 if (!im_im) return NULL;
168 205
@@ -174,6 +211,26 @@ evas_gl_common_image_mmap(Evas_Engine_GL_Context *gc, Eina_File *f, const char *
174{ 211{
175 RGBA_Image *im_im; 212 RGBA_Image *im_im;
176 213
214#ifdef EVAS_CSERVE2
215 if (evas_cserve2_use_get() && !eina_file_virtual(f))
216 {
217 im_im = (RGBA_Image *) evas_cache2_image_open
218 (evas_common_image_cache2_get(), eina_file_filename_get(f), key, lo, error);
219 if (im_im)
220 {
221 *error = evas_cache2_image_open_wait(&im_im->cache_entry);
222 if ((*error != EVAS_LOAD_ERROR_NONE)
223 && im_im->cache_entry.animated.animated)
224 {
225 evas_cache2_image_close(&im_im->cache_entry);
226 im_im = NULL;
227 }
228 else
229 return _evas_gl_common_image(gc, im_im, lo, error);
230 }
231 }
232#endif
233
177 im_im = evas_common_load_image_from_mmap(f, key, lo, error); 234 im_im = evas_common_load_image_from_mmap(f, key, lo, error);
178 if (!im_im) return NULL; 235 if (!im_im) return NULL;
179 236
@@ -341,7 +398,12 @@ evas_gl_common_image_alpha_set(Evas_GL_Image *im, int alpha)
341 im->alpha = alpha; 398 im->alpha = alpha;
342 if (!im->im) return im; 399 if (!im->im) return im;
343 evas_gl_common_image_alloc_ensure(im); 400 evas_gl_common_image_alloc_ensure(im);
344 evas_cache_image_load_data(&im->im->cache_entry); 401#ifdef EVAS_CSERVE2
402 if (evas_cache2_image_cached(&im->im->cache_entry))
403 evas_cache2_image_load_data(&im->im->cache_entry);
404 else
405#endif
406 evas_cache_image_load_data(&im->im->cache_entry);
345 im->im->cache_entry.flags.alpha = alpha ? 1 : 0; 407 im->im->cache_entry.flags.alpha = alpha ? 1 : 0;
346 408
347 if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE); 409 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)
376 } 438 }
377 if (im->im) 439 if (im->im)
378 { 440 {
379 evas_cache_image_drop(&im->im->cache_entry); 441#ifdef EVAS_CSERVE2
442 if (evas_cache2_image_cached(&im->im->cache_entry))
443 evas_cache2_image_close(&im->im->cache_entry);
444 else
445#endif
446 evas_cache_image_drop(&im->im->cache_entry);
380 im->im = NULL; 447 im->im = NULL;
381 } 448 }
382 if (im->tex) 449 if (im->tex)
@@ -395,7 +462,12 @@ evas_gl_common_image_native_disable(Evas_GL_Image *im)
395{ 462{
396 if (im->im) 463 if (im->im)
397 { 464 {
398 evas_cache_image_drop(&im->im->cache_entry); 465#ifdef EVAS_CSERVE2
466 if (!evas_cache2_image_cached(&im->im->cache_entry))
467 evas_cache2_image_close(&im->im->cache_entry);
468 else
469#endif
470 evas_cache_image_drop(&im->im->cache_entry);
399 im->im = NULL; 471 im->im = NULL;
400 } 472 }
401 if (im->tex) 473 if (im->tex)
@@ -451,7 +523,12 @@ evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint)
451 } 523 }
452 if (im->im) 524 if (im->im)
453 { 525 {
454 evas_cache_image_drop(&im->im->cache_entry); 526#ifdef EVAS_CSERVE2
527 if (evas_cache2_image_cached(&im->im->cache_entry))
528 evas_cache2_image_close(&im->im->cache_entry);
529 else
530#endif
531 evas_cache_image_drop(&im->im->cache_entry);
455 im->im = NULL; 532 im->im = NULL;
456 } 533 }
457 if (im->tex) 534 if (im->tex)
@@ -466,7 +543,12 @@ evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint)
466 { 543 {
467 if (im->im) 544 if (im->im)
468 { 545 {
469 evas_cache_image_drop(&im->im->cache_entry); 546#ifdef EVAS_CSERVE2
547 if (evas_cache2_image_cached(&im->im->cache_entry))
548 evas_cache2_image_close(&im->im->cache_entry);
549 else
550#endif
551 evas_cache_image_drop(&im->im->cache_entry);
470 im->im = NULL; 552 im->im = NULL;
471 } 553 }
472 if (im->tex) 554 if (im->tex)
@@ -510,7 +592,15 @@ evas_gl_common_image_free(Evas_GL_Image *im)
510 { 592 {
511 if (_evas_gl_image_cache_add(im)) return; 593 if (_evas_gl_image_cache_add(im)) return;
512 } 594 }
513 if (im->im) evas_cache_image_drop(&im->im->cache_entry); 595 if (im->im)
596 {
597#ifdef EVAS_CSERVE2
598 if (evas_cache2_image_cached(&im->im->cache_entry))
599 evas_cache2_image_close(&im->im->cache_entry);
600 else
601#endif
602 evas_cache_image_drop(&im->im->cache_entry);
603 }
514 if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE); 604 if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE);
515 605
516 free(im); 606 free(im);
@@ -549,7 +639,12 @@ evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x, unsigned int y, un
549 if (im->im) 639 if (im->im)
550 { 640 {
551 evas_gl_common_image_alloc_ensure(im); 641 evas_gl_common_image_alloc_ensure(im);
552 im->im = (RGBA_Image *)evas_cache_image_dirty(&im->im->cache_entry, x, y, w, h); 642#ifdef EVAS_CSERVE2
643 if (evas_cache2_image_cached(&im->im->cache_entry))
644 im->im = (RGBA_Image *)evas_cache2_image_dirty(&im->im->cache_entry, x, y, w, h);
645 else
646#endif
647 im->im = (RGBA_Image *)evas_cache_image_dirty(&im->im->cache_entry, x, y, w, h);
553 } 648 }
554 im->dirty = 1; 649 im->dirty = 1;
555} 650}
@@ -588,16 +683,38 @@ evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im)
588 if ((im->tex) && 683 if ((im->tex) &&
589 ((im->dirty) || (ie->animated.animated) || (ie->flags.updated_data))) 684 ((im->dirty) || (ie->animated.animated) || (ie->flags.updated_data)))
590 { 685 {
591 evas_cache_image_load_data(&im->im->cache_entry); 686#ifdef EVAS_CSERVE2
592 evas_gl_common_texture_update(im->tex, im->im); 687 if (evas_cache2_image_cached(&im->im->cache_entry))
593 evas_cache_image_unload_data(&im->im->cache_entry); 688 {
689 evas_cache2_image_load_data(&im->im->cache_entry);
690 evas_gl_common_texture_update(im->tex, im->im);
691 evas_cache2_image_unload_data(&im->im->cache_entry);
692 }
693 else
694#endif
695 {
696 evas_cache_image_load_data(&im->im->cache_entry);
697 evas_gl_common_texture_update(im->tex, im->im);
698 evas_cache_image_unload_data(&im->im->cache_entry);
699 }
594 ie->flags.updated_data = 0; 700 ie->flags.updated_data = 0;
595 } 701 }
596 if (!im->tex) 702 if (!im->tex)
597 { 703 {
598 evas_cache_image_load_data(&im->im->cache_entry); 704#ifdef EVAS_CSERVE2
599 im->tex = evas_gl_common_texture_new(gc, im->im); 705 if (evas_cache2_image_cached(&im->im->cache_entry))
600 evas_cache_image_unload_data(&im->im->cache_entry); 706 {
707 evas_cache2_image_load_data(&im->im->cache_entry);
708 im->tex = evas_gl_common_texture_new(gc, im->im);
709 evas_cache2_image_unload_data(&im->im->cache_entry);
710 }
711 else
712#endif
713 {
714 evas_cache_image_load_data(&im->im->cache_entry);
715 im->tex = evas_gl_common_texture_new(gc, im->im);
716 evas_cache_image_unload_data(&im->im->cache_entry);
717 }
601 } 718 }
602 im->dirty = 0; 719 im->dirty = 0;
603 if (!im->tex) return; 720 if (!im->tex) return;