summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@samsung.com>2014-03-17 15:19:47 +0900
committerCedric BAIL <cedric.bail@free.fr>2014-04-01 22:00:15 +0900
commit3699ec6883a509510dba9956d250b740a8ac08db (patch)
tree8f7044dc7d21a40bdc2cf1549e59c43604a434d5
parent05239d8dd24da4ec296b356adfb12d76a9130f6d (diff)
evas: remove RGBA_IMAGE_ALPHA_ONLY flags and use EVAS_COLORSPACE_GRY8 instead.
-rw-r--r--src/lib/evas/common/evas_image_load.c1
-rw-r--r--src/lib/evas/common/evas_image_main.c40
-rw-r--r--src/lib/evas/include/evas_common_private.h2
3 files changed, 23 insertions, 20 deletions
diff --git a/src/lib/evas/common/evas_image_load.c b/src/lib/evas/common/evas_image_load.c
index 133f7399da..dc72986085 100644
--- a/src/lib/evas/common/evas_image_load.c
+++ b/src/lib/evas/common/evas_image_load.c
@@ -402,7 +402,6 @@ evas_common_load_rgba_image_data_from_file(Image_Entry *ie)
402 if (!ie->info.module) return EVAS_LOAD_ERROR_GENERIC; 402 if (!ie->info.module) return EVAS_LOAD_ERROR_GENERIC;
403 403
404// printf("load data [%p] %s %s\n", ie, ie->file, ie->key); 404// printf("load data [%p] %s %s\n", ie, ie->file, ie->key);
405
406 evas_image_load_func = ie->info.loader; 405 evas_image_load_func = ie->info.loader;
407 evas_module_use(ie->info.module); 406 evas_module_use(ie->info.module);
408 407
diff --git a/src/lib/evas/common/evas_image_main.c b/src/lib/evas/common/evas_image_main.c
index 5e1c8ae3c4..47a424f8e5 100644
--- a/src/lib/evas/common/evas_image_main.c
+++ b/src/lib/evas/common/evas_image_main.c
@@ -110,7 +110,7 @@ static const Evas_Cache2_Image_Func _evas_common_image_func2 =
110#endif 110#endif
111 111
112static inline size_t 112static inline size_t
113_evas_common_rgba_image_surface_size(unsigned int w, unsigned int h, Eina_Bool alpha_only) 113_evas_common_rgba_image_surface_size(unsigned int w, unsigned int h, Evas_Colorspace cspace)
114{ 114{
115#define PAGE_SIZE (4 * 1024) 115#define PAGE_SIZE (4 * 1024)
116#define HUGE_PAGE_SIZE (2 * 1024 * 1024) 116#define HUGE_PAGE_SIZE (2 * 1024 * 1024)
@@ -121,10 +121,13 @@ _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h, Eina_Bool a
121#endif 121#endif
122 size_t siz; 122 size_t siz;
123 123
124 if (alpha_only) 124 switch (cspace)
125 siz = w * h * sizeof(DATA8); 125 {
126 else 126 case EVAS_COLORSPACE_GRY8: siz = w * h * sizeof(DATA8); break;
127 siz = w * h * sizeof(DATA32); 127 case EVAS_COLORSPACE_ARGB8888: siz = w * h * sizeof(DATA32); break;
128 default:
129 return -1;
130 }
128 131
129 if (siz < PAGE_SIZE) return siz; 132 if (siz < PAGE_SIZE) return siz;
130 133
@@ -134,14 +137,14 @@ _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h, Eina_Bool a
134} 137}
135 138
136static void * 139static void *
137_evas_common_rgba_image_surface_mmap(unsigned int w, unsigned int h, Eina_Bool alpha_only) 140_evas_common_rgba_image_surface_mmap(unsigned int w, unsigned int h, Evas_Colorspace cspace)
138{ 141{
139 size_t siz; 142 size_t siz;
140#if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32)) 143#if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32))
141 void *r = MAP_FAILED; 144 void *r = MAP_FAILED;
142#endif 145#endif
143 146
144 siz = _evas_common_rgba_image_surface_size(w, h, alpha_only); 147 siz = _evas_common_rgba_image_surface_size(w, h, cspace);
145 148
146#if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32)) 149#if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32))
147#ifndef MAP_HUGETLB 150#ifndef MAP_HUGETLB
@@ -165,12 +168,12 @@ _evas_common_rgba_image_surface_mmap(unsigned int w, unsigned int h, Eina_Bool a
165} 168}
166 169
167static void 170static void
168_evas_common_rgba_image_surface_munmap(void *data, unsigned int w, unsigned int h, Eina_Bool alpha_only) 171_evas_common_rgba_image_surface_munmap(void *data, unsigned int w, unsigned int h, Evas_Colorspace cspace)
169{ 172{
170#if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32)) 173#if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32))
171 size_t siz; 174 size_t siz;
172 175
173 siz = _evas_common_rgba_image_surface_size(w, h, alpha_only); 176 siz = _evas_common_rgba_image_surface_size(w, h, cspace);
174 if (siz < PAGE_SIZE) 177 if (siz < PAGE_SIZE)
175 free(data); 178 free(data);
176 else 179 else
@@ -373,7 +376,7 @@ evas_common_rgba_image_unload(Image_Entry *ie)
373 { 376 {
374 _evas_common_rgba_image_surface_munmap(im->image.data, 377 _evas_common_rgba_image_surface_munmap(im->image.data,
375 ie->allocated.w, ie->allocated.h, 378 ie->allocated.w, ie->allocated.h,
376 (im->flags & RGBA_IMAGE_ALPHA_ONLY)); 379 ie->space);
377#ifdef SURFDBG 380#ifdef SURFDBG
378 surfs = eina_list_remove(surfs, ie); 381 surfs = eina_list_remove(surfs, ie);
379#endif 382#endif
@@ -445,21 +448,21 @@ _evas_common_rgba_image_surface_alloc(Image_Entry *ie, unsigned int w, unsigned
445 { 448 {
446 _evas_common_rgba_image_surface_munmap(im->image.data, 449 _evas_common_rgba_image_surface_munmap(im->image.data,
447 ie->allocated.w, ie->allocated.h, 450 ie->allocated.w, ie->allocated.h,
448 (im->flags & RGBA_IMAGE_ALPHA_ONLY)); 451 ie->space);
449#ifdef SURFDBG 452#ifdef SURFDBG
450 surfs = eina_list_remove(surfs, ie); 453 surfs = eina_list_remove(surfs, ie);
451#endif 454#endif
452 } 455 }
453 im->image.data = _evas_common_rgba_image_surface_mmap(w, h, (im->flags & RGBA_IMAGE_ALPHA_ONLY)); 456 im->image.data = _evas_common_rgba_image_surface_mmap(w, h, ie->space);
454 if (!im->image.data) return -1; 457 if (!im->image.data) return -1;
455 ie->allocated.w = w; 458 ie->allocated.w = w;
456 ie->allocated.h = h; 459 ie->allocated.h = h;
457#ifdef SURFDBG 460#ifdef SURFDBG
458 surfs = eina_list_append(surfs, ie); 461 surfs = eina_list_append(surfs, ie);
459#endif 462#endif
460#ifdef HAVE_VALGRIND 463#ifdef HAVE_VALGRIND
461 size_t siz = 0; 464 size_t siz = 0;
462 siz = _evas_common_rgba_image_surface_size(w, h, (im->flags & RGBA_IMAGE_ALPHA_ONLY)); 465 siz = _evas_common_rgba_image_surface_size(w, h, ie->space);
463# ifdef VALGRIND_MAKE_READABLE 466# ifdef VALGRIND_MAKE_READABLE
464 VALGRIND_MAKE_READABLE(im->image.data, siz); 467 VALGRIND_MAKE_READABLE(im->image.data, siz);
465# else 468# else
@@ -508,7 +511,7 @@ _evas_common_rgba_image_surface_delete(Image_Entry *ie)
508 { 511 {
509 _evas_common_rgba_image_surface_munmap(im->image.data, 512 _evas_common_rgba_image_surface_munmap(im->image.data,
510 ie->allocated.w, ie->allocated.h, 513 ie->allocated.w, ie->allocated.h,
511 (im->flags & RGBA_IMAGE_ALPHA_ONLY)); 514 ie->space);
512#ifdef SURFDBG 515#ifdef SURFDBG
513 surfs = eina_list_remove(surfs, ie); 516 surfs = eina_list_remove(surfs, ie);
514#endif 517#endif
@@ -626,7 +629,7 @@ evas_common_image_surface_alpha_tiles_calc(RGBA_Surface *is, int tsize)
626 if (is->spans) return; 629 if (is->spans) return;
627 if (!is->im->cache_entry.flags.alpha) return; 630 if (!is->im->cache_entry.flags.alpha) return;
628 /* FIXME: dont handle alpha only images yet */ 631 /* FIXME: dont handle alpha only images yet */
629 if ((is->im->flags & RGBA_IMAGE_ALPHA_ONLY)) return; 632 if (is->im->space != EVAS_COLORSPACE_GRY8) return;
630 if (tsize < 0) tsize = 0; 633 if (tsize < 0) tsize = 0;
631 is->spans = calloc(1, sizeof(RGBA_Image_Span *) * is->h); 634 is->spans = calloc(1, sizeof(RGBA_Image_Span *) * is->h);
632 if (!is->spans) return; 635 if (!is->spans) return;
@@ -745,6 +748,7 @@ evas_common_image_colorspace_normalize(RGBA_Image *im)
745 switch (im->cache_entry.space) 748 switch (im->cache_entry.space)
746 { 749 {
747 case EVAS_COLORSPACE_ARGB8888: 750 case EVAS_COLORSPACE_ARGB8888:
751 case EVAS_COLORSPACE_GRY8:
748 if (im->image.data != im->cs.data) 752 if (im->image.data != im->cs.data)
749 { 753 {
750#ifdef EVAS_CSERVE2 754#ifdef EVAS_CSERVE2
@@ -756,7 +760,7 @@ evas_common_image_colorspace_normalize(RGBA_Image *im)
756 _evas_common_rgba_image_surface_munmap(im->image.data, 760 _evas_common_rgba_image_surface_munmap(im->image.data,
757 im->cache_entry.allocated.w, 761 im->cache_entry.allocated.w,
758 im->cache_entry.allocated.h, 762 im->cache_entry.allocated.h,
759 (im->flags & RGBA_IMAGE_ALPHA_ONLY)); 763 im->cache_entry.space);
760#ifdef SURFDBG 764#ifdef SURFDBG
761 surfs = eina_list_remove(surfs, im); 765 surfs = eina_list_remove(surfs, im);
762#endif 766#endif
diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h
index b376cd3c82..1470ca5e6a 100644
--- a/src/lib/evas/include/evas_common_private.h
+++ b/src/lib/evas/include/evas_common_private.h
@@ -454,7 +454,7 @@ typedef enum _RGBA_Image_Flags
454/* RGBA_IMAGE_HAS_ALPHA = (1 << 0), */ 454/* RGBA_IMAGE_HAS_ALPHA = (1 << 0), */
455 RGBA_IMAGE_IS_DIRTY = (1 << 1), 455 RGBA_IMAGE_IS_DIRTY = (1 << 1),
456 RGBA_IMAGE_INDEXED = (1 << 2), 456 RGBA_IMAGE_INDEXED = (1 << 2),
457 RGBA_IMAGE_ALPHA_ONLY = (1 << 3), 457 /* RGBA_IMAGE_ALPHA_ONLY = (1 << 3), */
458 RGBA_IMAGE_ALPHA_TILES = (1 << 4), 458 RGBA_IMAGE_ALPHA_TILES = (1 << 4),
459/* RGBA_IMAGE_ALPHA_SPARSE = (1 << 5), */ 459/* RGBA_IMAGE_ALPHA_SPARSE = (1 << 5), */
460/* RGBA_IMAGE_LOADED = (1 << 6), */ 460/* RGBA_IMAGE_LOADED = (1 << 6), */