summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-10-30 16:41:32 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-11-10 16:12:21 +0900
commit7974f674aa9ba18588576a373e1ec0c524bbde9f (patch)
treeb81a725c7ba05b529d4e1412545ff8d537a0bb9f /src/lib/evas/common
parenta5d02848202475d87621fb61ce7a3e8dcecc11f5 (diff)
Evas: Allow edje_decc to work with ETC images
This reuses the internal function data_get, data_put, image_save respecting the border information and adding support for ETC formats. @fix
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_image_data.c100
-rw-r--r--src/lib/evas/common/evas_image_main.c30
2 files changed, 77 insertions, 53 deletions
diff --git a/src/lib/evas/common/evas_image_data.c b/src/lib/evas/common/evas_image_data.c
index b6e2bdc..1269818 100644
--- a/src/lib/evas/common/evas_image_data.c
+++ b/src/lib/evas/common/evas_image_data.c
@@ -41,6 +41,21 @@ evas_common_rgba_image_from_data(Image_Entry* ie_dst, int w, int h, DATA32 *imag
41 dst->cs.data = image_data; 41 dst->cs.data = image_data;
42 dst->cs.no_free = 1; 42 dst->cs.no_free = 1;
43 break; 43 break;
44 case EVAS_COLORSPACE_ETC1:
45 case EVAS_COLORSPACE_ETC1_ALPHA:
46 case EVAS_COLORSPACE_RGB8_ETC2:
47 case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
48 // FIXME: Borders are just guessed, not passed in (they should be)
49 dst->cache_entry.w = w;
50 dst->cache_entry.h = h;
51 dst->cache_entry.borders.l = 1;
52 dst->cache_entry.borders.t = 1;
53 dst->cache_entry.borders.r = ((w + 2 + 3) & ~0x3) - w - 1;
54 dst->cache_entry.borders.b = ((h + 2 + 3) & ~0x3) - h - 1;
55 dst->image.data = image_data;
56 dst->image.no_free = 1;
57 dst->cache_entry.flags.alpha = alpha ? 1 : 0;
58 break;
44 default: 59 default:
45 abort(); 60 abort();
46 break; 61 break;
@@ -119,58 +134,67 @@ evas_common_rgba_image_size_set(Image_Entry *ie_dst, const Image_Entry *ie_im, u
119} 134}
120 135
121int 136int
122evas_common_rgba_image_colorspace_set(Image_Entry* ie_dst, Evas_Colorspace cspace) 137evas_common_rgba_image_colorspace_set(Image_Entry* ie, Evas_Colorspace cspace)
123{ 138{
124 RGBA_Image *dst = (RGBA_Image *) ie_dst; 139 RGBA_Image *im = (RGBA_Image *) ie;
125 Eina_Bool change = (dst->cache_entry.space != cspace); 140
141 // FIXME: This function looks extremely dubious now, trying to free the
142 // data pointer without even knowing how it was allocated (malloc / mmap).
143 // Also, lacks support for S3TC and exotic formats.
144
145 if (im->cache_entry.space == cspace)
146 return 1;
147
148 if (ie->references > 1)
149 WRN("Releasing data of image with >1 refs. Bad things may happen.");
150
151 if (im->cs.data)
152 {
153 if (!im->cs.no_free) free(im->cs.data);
154 im->cs.data = NULL;
155 }
156 im->cs.no_free = 0;
157 if (im->image.data && !im->image.no_free)
158 {
159 // FIXME: Call _evas_common_rgba_image_surface_munmap
160 free(im->image.data);
161 }
162 ie->allocated.w = 0;
163 ie->allocated.h = 0;
164 ie->flags.preload_done = 0;
165 ie->flags.loaded = 0;
166 im->image.data = NULL;
167 im->image.no_free = 0;
126 168
127 switch (cspace) 169 switch (cspace)
128 { 170 {
129 case EVAS_COLORSPACE_ARGB8888: 171 case EVAS_COLORSPACE_ARGB8888:
130 case EVAS_COLORSPACE_AGRY88: 172 case EVAS_COLORSPACE_AGRY88:
131 case EVAS_COLORSPACE_GRY8: 173 case EVAS_COLORSPACE_GRY8:
132 if (dst->cs.data) 174 // all good
133 { 175 break;
134 if (!dst->cs.no_free) free(dst->cs.data); 176 case EVAS_COLORSPACE_ETC1:
135 dst->cs.data = NULL; 177 case EVAS_COLORSPACE_ETC1_ALPHA:
136 dst->cs.no_free = 0; 178 case EVAS_COLORSPACE_RGB8_ETC2:
137 } 179 case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
138 if (change && dst->image.data) 180 // living on the edge (no conversion atm)
139 {
140 if (!dst->image.no_free) free(dst->image.data);
141 dst->image.data = NULL;
142 dst->image.no_free = 0;
143 }
144 break; 181 break;
145 case EVAS_COLORSPACE_YCBCR422P601_PL: 182 case EVAS_COLORSPACE_YCBCR422P601_PL:
146 case EVAS_COLORSPACE_YCBCR422P709_PL: 183 case EVAS_COLORSPACE_YCBCR422P709_PL:
147 case EVAS_COLORSPACE_YCBCR422601_PL: 184 case EVAS_COLORSPACE_YCBCR422601_PL:
148 case EVAS_COLORSPACE_YCBCR420TM12601_PL: 185 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
149 case EVAS_COLORSPACE_YCBCR420NV12601_PL: 186 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
150 if (dst->image.no_free) 187 // prepare cspace conversion buffer
151 { 188 im->cs.data = calloc(1, im->cache_entry.h * sizeof(unsigned char *) * 2);
152 ie_dst->allocated.w = 0; 189 im->cs.no_free = 0;
153 ie_dst->allocated.h = 0;
154 ie_dst->flags.preload_done = 0;
155 ie_dst->flags.loaded = 0;
156 dst->image.data = NULL;
157 dst->image.no_free = 0;
158 /* FIXME: Must allocate image.data surface cleanly. */
159 }
160 if (dst->cs.data)
161 {
162 if (!dst->cs.no_free) free(dst->cs.data);
163 }
164 dst->cs.data = calloc(1, dst->cache_entry.h * sizeof(unsigned char *) * 2);
165 dst->cs.no_free = 0;
166 break; 190 break;
167 default: 191 default:
168 abort(); 192 CRI("Can't set colorspace to %u: unsupported", (unsigned) cspace);
169 break; 193 abort();
194 return 0;
170 } 195 }
171 dst->cache_entry.space = cspace; 196 im->cache_entry.space = cspace;
172 evas_common_image_colorspace_dirty(dst); 197 evas_common_image_colorspace_dirty(im);
173 198 _evas_common_rgba_image_post_surface(ie);
174 _evas_common_rgba_image_post_surface(ie_dst); 199 return 1;
175 return 0;
176} 200}
diff --git a/src/lib/evas/common/evas_image_main.c b/src/lib/evas/common/evas_image_main.c
index 5cf5335..b82a851 100644
--- a/src/lib/evas/common/evas_image_main.c
+++ b/src/lib/evas/common/evas_image_main.c
@@ -213,8 +213,8 @@ _evas_common_rgba_image_surface_mmap(Image_Entry *ie, unsigned int w, unsigned i
213#endif 213#endif
214} 214}
215 215
216static void 216void
217_evas_common_rgba_image_surface_munmap(void *data, unsigned int w, unsigned int h, Evas_Colorspace cspace) 217evas_common_rgba_image_surface_munmap(void *data, unsigned int w, unsigned int h, Evas_Colorspace cspace)
218{ 218{
219 if (!data) return ; 219 if (!data) return ;
220#if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32)) 220#if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32))
@@ -379,9 +379,9 @@ evas_common_rgba_image_unload_real(Image_Entry *ie)
379 379
380 if (im->image.data && !im->image.no_free) 380 if (im->image.data && !im->image.no_free)
381 { 381 {
382 _evas_common_rgba_image_surface_munmap(im->image.data, 382 evas_common_rgba_image_surface_munmap(im->image.data,
383 ie->allocated.w, ie->allocated.h, 383 ie->allocated.w, ie->allocated.h,
384 ie->space); 384 ie->space);
385#ifdef SURFDBG 385#ifdef SURFDBG
386 surfs = eina_list_remove(surfs, ie); 386 surfs = eina_list_remove(surfs, ie);
387#endif 387#endif
@@ -532,9 +532,9 @@ _evas_common_rgba_image_surface_alloc(Image_Entry *ie, unsigned int w, unsigned
532 532
533 if (im->image.data) 533 if (im->image.data)
534 { 534 {
535 _evas_common_rgba_image_surface_munmap(im->image.data, 535 evas_common_rgba_image_surface_munmap(im->image.data,
536 ie->allocated.w, ie->allocated.h, 536 ie->allocated.w, ie->allocated.h,
537 ie->space); 537 ie->space);
538 im->image.data = NULL; 538 im->image.data = NULL;
539#ifdef SURFDBG 539#ifdef SURFDBG
540 surfs = eina_list_remove(surfs, ie); 540 surfs = eina_list_remove(surfs, ie);
@@ -605,9 +605,9 @@ _evas_common_rgba_image_surface_delete(Image_Entry *ie)
605 605
606 if (im->image.data && !im->image.no_free) 606 if (im->image.data && !im->image.no_free)
607 { 607 {
608 _evas_common_rgba_image_surface_munmap(im->image.data, 608 evas_common_rgba_image_surface_munmap(im->image.data,
609 ie->allocated.w, ie->allocated.h, 609 ie->allocated.w, ie->allocated.h,
610 ie->space); 610 ie->space);
611#ifdef SURFDBG 611#ifdef SURFDBG
612 surfs = eina_list_remove(surfs, ie); 612 surfs = eina_list_remove(surfs, ie);
613#endif 613#endif
@@ -854,10 +854,10 @@ evas_common_image_colorspace_normalize(RGBA_Image *im)
854#endif 854#endif
855 if (!im->image.no_free) 855 if (!im->image.no_free)
856 { 856 {
857 _evas_common_rgba_image_surface_munmap(im->image.data, 857 evas_common_rgba_image_surface_munmap(im->image.data,
858 im->cache_entry.allocated.w, 858 im->cache_entry.allocated.w,
859 im->cache_entry.allocated.h, 859 im->cache_entry.allocated.h,
860 im->cache_entry.space); 860 im->cache_entry.space);
861#ifdef SURFDBG 861#ifdef SURFDBG
862 surfs = eina_list_remove(surfs, im); 862 surfs = eina_list_remove(surfs, im);
863#endif 863#endif