diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2016-12-28 12:56:08 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2016-12-28 13:31:48 +0900 |
commit | ef49935f72e578cd6fceb5b6a19130f738d5d438 (patch) | |
tree | 9cd95eeb1dd19cfb3e85644eecf6c96f842eb964 /src/lib/evas/common | |
parent | 8424c2b4a35eae7003b784b2b7c9d3ad73b48972 (diff) |
evas - clean up whitespace and 80 column wrapping and commented out code
this doenst change functionality but just cleans up the file
whitespacing and formatting and removed commented out junk, 80 column
wrapping/overflow etc.
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r-- | src/lib/evas/common/evas_image_main.c | 512 |
1 files changed, 166 insertions, 346 deletions
diff --git a/src/lib/evas/common/evas_image_main.c b/src/lib/evas/common/evas_image_main.c index 2928b47314..ab6d06d9e3 100644 --- a/src/lib/evas/common/evas_image_main.c +++ b/src/lib/evas/common/evas_image_main.c | |||
@@ -22,51 +22,45 @@ | |||
22 | 22 | ||
23 | //#define SURFDBG 1 | 23 | //#define SURFDBG 1 |
24 | 24 | ||
25 | static Evas_Cache_Image * eci = NULL; | 25 | static Evas_Cache_Image *eci = NULL; |
26 | #ifdef EVAS_CSERVE2 | 26 | #ifdef EVAS_CSERVE2 |
27 | #define EVAS_CSERVE2_SCALE_CACHE_SIZE (4 * 1024 * 1024) | 27 | #define EVAS_CSERVE2_SCALE_CACHE_SIZE (4 * 1024 * 1024) |
28 | static Evas_Cache2 * eci2 = NULL; | 28 | static Evas_Cache2 *eci2 = NULL; |
29 | #endif | 29 | #endif |
30 | static int reference = 0; | 30 | static int reference = 0; |
31 | static int evas_image_no_mmap = -1; | 31 | static int evas_image_no_mmap = -1; |
32 | 32 | ||
33 | /* static RGBA_Image *evas_rgba_line_buffer = NULL; */ | 33 | /* static RGBA_Image *evas_rgba_line_buffer = NULL; */ |
34 | 34 | ||
35 | #define EVAS_RGBA_LINE_BUFFER_MIN_LEN 256 | 35 | #define EVAS_RGBA_LINE_BUFFER_MIN_LEN 256 |
36 | #define EVAS_RGBA_LINE_BUFFER_MAX_LEN 2048 | 36 | #define EVAS_RGBA_LINE_BUFFER_MAX_LEN 2048 |
37 | 37 | ||
38 | /* static RGBA_Image *evas_alpha_line_buffer = NULL; */ | 38 | /* static RGBA_Image *evas_alpha_line_buffer = NULL; */ |
39 | 39 | ||
40 | #define EVAS_ALPHA_LINE_BUFFER_MIN_LEN 256 | 40 | #define EVAS_ALPHA_LINE_BUFFER_MIN_LEN 256 |
41 | #define EVAS_ALPHA_LINE_BUFFER_MAX_LEN 2048 | 41 | #define EVAS_ALPHA_LINE_BUFFER_MAX_LEN 2048 |
42 | 42 | ||
43 | 43 | static Image_Entry *_evas_common_rgba_image_new(void); | |
44 | static Image_Entry *_evas_common_rgba_image_new(void); | 44 | static void _evas_common_rgba_image_delete(Image_Entry *ie); |
45 | static void _evas_common_rgba_image_delete(Image_Entry *ie); | 45 | static int _evas_common_rgba_image_surface_alloc(Image_Entry *ie, |
46 | 46 | unsigned int w, | |
47 | static int _evas_common_rgba_image_surface_alloc(Image_Entry *ie, unsigned int w, unsigned int h); | 47 | unsigned int h); |
48 | static void _evas_common_rgba_image_surface_delete(Image_Entry *ie); | 48 | static void _evas_common_rgba_image_surface_delete(Image_Entry *ie); |
49 | static DATA32 *_evas_common_rgba_image_surface_pixels(Image_Entry *ie); | 49 | static DATA32 *_evas_common_rgba_image_surface_pixels(Image_Entry *ie); |
50 | 50 | static void _evas_common_rgba_image_unload(Image_Entry *im); | |
51 | static void _evas_common_rgba_image_unload(Image_Entry *im); | 51 | static void _evas_common_rgba_image_dirty_region(Image_Entry *im, |
52 | 52 | unsigned int x, | |
53 | static void _evas_common_rgba_image_dirty_region(Image_Entry *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h); | 53 | unsigned int y, |
54 | 54 | unsigned int w, | |
55 | static int _evas_common_rgba_image_ram_usage(Image_Entry *ie); | 55 | unsigned int h); |
56 | static int _evas_common_rgba_image_ram_usage(Image_Entry *ie); | ||
56 | 57 | ||
57 | /* Only called when references > 0. Need to provide a fresh copie of im. */ | 58 | /* Only called when references > 0. Need to provide a fresh copie of im. */ |
58 | /* The destination surface does have a surface, but no allocated pixel data. */ | 59 | /* The destination surface does have a surface, but no allocated pixel data. */ |
59 | static int _evas_common_rgba_image_dirty(Image_Entry* dst, const Image_Entry* src); | 60 | static int _evas_common_rgba_image_dirty(Image_Entry* dst, |
61 | const Image_Entry* src); | ||
60 | 62 | ||
61 | #if 0 | 63 | static const Evas_Cache_Image_Func _evas_common_image_func = |
62 | static void | ||
63 | _evas_common_rgba_image_debug(const char* context, Image_Entry *eim) | ||
64 | { | ||
65 | DBG("%p = [%s] {%s,%s} %i [%i|%i]", eim, context, eim->file, eim->key, eim->references, eim->w, eim->h); | ||
66 | } | ||
67 | #endif | ||
68 | |||
69 | static const Evas_Cache_Image_Func _evas_common_image_func = | ||
70 | { | 64 | { |
71 | _evas_common_rgba_image_new, | 65 | _evas_common_rgba_image_new, |
72 | _evas_common_rgba_image_delete, | 66 | _evas_common_rgba_image_delete, |
@@ -83,48 +77,41 @@ static const Evas_Cache_Image_Func _evas_common_image_func = | |||
83 | evas_common_rgba_image_colorspace_set, | 77 | evas_common_rgba_image_colorspace_set, |
84 | evas_common_load_rgba_image_data_from_file, | 78 | evas_common_load_rgba_image_data_from_file, |
85 | _evas_common_rgba_image_ram_usage, | 79 | _evas_common_rgba_image_ram_usage, |
86 | /* _evas_common_rgba_image_debug */ | 80 | NULL // _evas_common_rgba_image_debug |
87 | NULL | ||
88 | }; | 81 | }; |
89 | 82 | ||
90 | #ifdef EVAS_CSERVE2 | 83 | #ifdef EVAS_CSERVE2 |
91 | static const Evas_Cache2_Image_Func _evas_common_image_func2 = | 84 | static const Evas_Cache2_Image_Func _evas_common_image_func2 = |
92 | { | 85 | { |
93 | // _evas_common_rgba_image_new, | ||
94 | // _evas_common_rgba_image_delete, | ||
95 | _evas_common_rgba_image_surface_alloc, | 86 | _evas_common_rgba_image_surface_alloc, |
96 | _evas_common_rgba_image_surface_delete, | 87 | _evas_common_rgba_image_surface_delete, |
97 | _evas_common_rgba_image_surface_pixels, | 88 | _evas_common_rgba_image_surface_pixels, |
98 | // evas_common_load_rgba_image_module_from_file, | ||
99 | // _evas_common_rgba_image_unload, | ||
100 | NULL, // _evas_common_rgba_image_dirty_region, | 89 | NULL, // _evas_common_rgba_image_dirty_region, |
101 | NULL, // _evas_common_rgba_image_dirty, | 90 | NULL, // _evas_common_rgba_image_dirty, |
102 | evas_common_rgba_image_size_set, | 91 | evas_common_rgba_image_size_set, |
103 | evas_common_rgba_image_from_copied_data, | 92 | evas_common_rgba_image_from_copied_data, |
104 | evas_common_rgba_image_from_data, | 93 | evas_common_rgba_image_from_data, |
105 | NULL, // evas_common_rgba_image_colorspace_set, | 94 | NULL, // evas_common_rgba_image_colorspace_set, |
106 | // evas_common_load_rgba_image_data_from_file, | ||
107 | _evas_common_rgba_image_ram_usage, | 95 | _evas_common_rgba_image_ram_usage, |
108 | /* _evas_common_rgba_image_debug */ | 96 | NULL // _evas_common_rgba_image_debug |
109 | NULL | ||
110 | }; | 97 | }; |
111 | #endif | 98 | #endif |
112 | 99 | ||
113 | EAPI int | 100 | EAPI int |
114 | _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h, | 101 | _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h, |
115 | Evas_Colorspace cspace, | 102 | Evas_Colorspace cspace, |
116 | /* inout */ int *l, int *r, int *t, int *b) | 103 | /*inout*/int *l, int *r, int *t, int *b) |
117 | { | 104 | { |
118 | #ifndef PAGE_SIZE | 105 | #ifndef PAGE_SIZE |
119 | # define PAGE_SIZE (4 * 1024) | 106 | # define PAGE_SIZE (4 * 1024) |
120 | #endif | 107 | #endif |
121 | #define HUGE_PAGE_SIZE (2 * 1024 * 1024) | 108 | #define HUGE_PAGE_SIZE (2 * 1024 * 1024) |
122 | #if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32)) | 109 | #if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32)) |
123 | # define ALIGN_TO_PAGE(Siz) (((Siz / PAGE_SIZE) + (Siz % PAGE_SIZE ? 1 : 0)) * PAGE_SIZE) | 110 | # define ALIGN_TO_PAGE(Siz) \ |
111 | (((Siz / PAGE_SIZE) + (Siz % PAGE_SIZE ? 1 : 0)) * PAGE_SIZE) | ||
124 | #else | 112 | #else |
125 | # define ALIGN_TO_PAGE(Siz) Siz | 113 | # define ALIGN_TO_PAGE(Siz) Siz |
126 | #endif | 114 | #endif |
127 | |||
128 | int siz, block_size = 8; | 115 | int siz, block_size = 8; |
129 | Eina_Bool reset_borders = EINA_TRUE; | 116 | Eina_Bool reset_borders = EINA_TRUE; |
130 | 117 | ||
@@ -133,7 +120,7 @@ _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h, | |||
133 | const char *s = getenv("EVAS_IMAGE_NO_MMAP"); | 120 | const char *s = getenv("EVAS_IMAGE_NO_MMAP"); |
134 | evas_image_no_mmap = s && (atoi(s)); | 121 | evas_image_no_mmap = s && (atoi(s)); |
135 | if (evas_image_no_mmap) | 122 | if (evas_image_no_mmap) |
136 | WRN("EVAS_IMAGE_NO_MMAP is set, use this only for debugging purposes!"); | 123 | WRN("EVAS_IMAGE_NO_MMAP is set, use this only for debugging!"); |
137 | } | 124 | } |
138 | 125 | ||
139 | switch (cspace) | 126 | switch (cspace) |
@@ -173,16 +160,15 @@ _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h, | |||
173 | if (b) *b = 0; | 160 | if (b) *b = 0; |
174 | } | 161 | } |
175 | 162 | ||
176 | if ((siz < PAGE_SIZE) || evas_image_no_mmap) | 163 | if ((siz < PAGE_SIZE) || evas_image_no_mmap) return siz; |
177 | return siz; | ||
178 | 164 | ||
179 | return ALIGN_TO_PAGE(siz); | 165 | return ALIGN_TO_PAGE(siz); |
180 | |||
181 | #undef ALIGN_TO_PAGE | 166 | #undef ALIGN_TO_PAGE |
182 | } | 167 | } |
183 | 168 | ||
184 | EAPI Eina_Bool | 169 | EAPI Eina_Bool |
185 | _evas_common_rgba_image_plane_get(const RGBA_Image *im, int plane, Eina_Slice *slice) | 170 | _evas_common_rgba_image_plane_get(const RGBA_Image *im, int plane, |
171 | Eina_Slice *slice) | ||
186 | { | 172 | { |
187 | unsigned char **csdata = NULL; | 173 | unsigned char **csdata = NULL; |
188 | Evas_Colorspace cs; | 174 | Evas_Colorspace cs; |
@@ -200,14 +186,12 @@ _evas_common_rgba_image_plane_get(const RGBA_Image *im, int plane, Eina_Slice *s | |||
200 | case EVAS_COLORSPACE_YCBCR422601_PL: | 186 | case EVAS_COLORSPACE_YCBCR422601_PL: |
201 | case EVAS_COLORSPACE_YCBCR420NV12601_PL: | 187 | case EVAS_COLORSPACE_YCBCR420NV12601_PL: |
202 | case EVAS_COLORSPACE_YCBCR420TM12601_PL: | 188 | case EVAS_COLORSPACE_YCBCR420TM12601_PL: |
203 | if (!im->cs.data) | 189 | if (!im->cs.data) return EINA_FALSE; |
204 | return EINA_FALSE; | ||
205 | csdata = im->cs.data; | 190 | csdata = im->cs.data; |
206 | break; | 191 | break; |
207 | 192 | ||
208 | default: | 193 | default: |
209 | if (!im->image.data) | 194 | if (!im->image.data) return EINA_FALSE; |
210 | return EINA_FALSE; | ||
211 | break; | 195 | break; |
212 | } | 196 | } |
213 | 197 | ||
@@ -337,19 +321,17 @@ _evas_common_rgba_image_plane_get(const RGBA_Image *im, int plane, Eina_Slice *s | |||
337 | } | 321 | } |
338 | 322 | ||
339 | EAPI int | 323 | EAPI int |
340 | _evas_common_rgba_image_data_offset(int rx, int ry, int rw, int rh, int plane, const RGBA_Image *im) | 324 | _evas_common_rgba_image_data_offset(int rx, int ry, int rw, int rh, |
325 | int plane, const RGBA_Image *im) | ||
341 | { | 326 | { |
342 | // note: no stride support | 327 | // note: no stride support |
343 | |||
344 | EINA_SAFETY_ON_NULL_RETURN_VAL(im, -1); | 328 | EINA_SAFETY_ON_NULL_RETURN_VAL(im, -1); |
345 | 329 | ||
346 | const Image_Entry *ie = &im->cache_entry; | 330 | const Image_Entry *ie = &im->cache_entry; |
347 | 331 | ||
348 | if ((rx < 0) || (ry < 0) || (rw < 0) || (rh < 0)) | 332 | if ((rx < 0) || (ry < 0) || (rw < 0) || (rh < 0)) return -1; |
349 | return -1; | ||
350 | 333 | ||
351 | if (((rx + rw) > (int) ie->w) || ((ry + rh) > (int) ie->h)) | 334 | if (((rx + rw) > (int) ie->w) || ((ry + rh) > (int) ie->h)) return -1; |
352 | return -1; | ||
353 | 335 | ||
354 | switch (ie->space) | 336 | switch (ie->space) |
355 | { | 337 | { |
@@ -360,40 +342,31 @@ _evas_common_rgba_image_data_offset(int rx, int ry, int rw, int rh, int plane, c | |||
360 | case EVAS_COLORSPACE_GRY8: | 342 | case EVAS_COLORSPACE_GRY8: |
361 | return ry * ie->w + rx; | 343 | return ry * ie->w + rx; |
362 | case EVAS_COLORSPACE_RGB565_A5P: | 344 | case EVAS_COLORSPACE_RGB565_A5P: |
363 | if (plane == 0) | 345 | if (plane == 0) return (ry * ie->w + rx) * 2; |
364 | return (ry * ie->w + rx) * 2; | 346 | else if (plane == 1) return ry * ie->w + rx + (ie->w * ie->h) * 2; |
365 | else if (plane == 1) | ||
366 | return ry * ie->w + rx + (ie->w * ie->h) * 2; | ||
367 | else return -1; | 347 | else return -1; |
368 | 348 | ||
369 | // YUV | 349 | // YUV |
370 | case EVAS_COLORSPACE_YCBCR422P601_PL: | 350 | case EVAS_COLORSPACE_YCBCR422P601_PL: |
371 | case EVAS_COLORSPACE_YCBCR422P709_PL: | 351 | case EVAS_COLORSPACE_YCBCR422P709_PL: |
372 | case EVAS_COLORSPACE_YCBCR422601_PL: | 352 | case EVAS_COLORSPACE_YCBCR422601_PL: |
373 | if ((rx & 1) || (rw & 1)) | 353 | if ((rx & 1) || (rw & 1)) return -1; |
374 | return -1; | 354 | if (plane == 0) return ry * ie->w + rx; |
375 | if (plane == 0) | 355 | else if (plane == 1) return (ry * ie->w) / 2 + rx + ie->w * ie->h; |
376 | return ry * ie->w + rx; | ||
377 | else if (plane == 1) | ||
378 | return (ry * ie->w) / 2 + rx + ie->w * ie->h; | ||
379 | else return -1; | 356 | else return -1; |
380 | 357 | ||
381 | case EVAS_COLORSPACE_YCBCR420NV12601_PL: | 358 | case EVAS_COLORSPACE_YCBCR420NV12601_PL: |
382 | case EVAS_COLORSPACE_YCBCR420TM12601_PL: | 359 | case EVAS_COLORSPACE_YCBCR420TM12601_PL: |
383 | if ((rx & 1) || (ry & 1) || (rw & 1) || (rh & 1)) | 360 | if ((rx & 1) || (ry & 1) || (rw & 1) || (rh & 1)) return -1; |
384 | return -1; | 361 | if (plane == 0) return ry * ie->w + rx; |
385 | if (plane == 0) | 362 | else if (plane == 1) return (ry * ie->w + rx) / 2 + ie->w * ie->h; |
386 | return ry * ie->w + rx; | ||
387 | else if (plane == 1) | ||
388 | return (ry * ie->w + rx) / 2 + ie->w * ie->h; | ||
389 | else return -1; | 363 | else return -1; |
390 | 364 | ||
391 | // ETC1/2 RGB, S3TC RGB | 365 | // ETC1/2 RGB, S3TC RGB |
392 | case EVAS_COLORSPACE_ETC1: | 366 | case EVAS_COLORSPACE_ETC1: |
393 | case EVAS_COLORSPACE_RGB8_ETC2: | 367 | case EVAS_COLORSPACE_RGB8_ETC2: |
394 | case EVAS_COLORSPACE_RGB_S3TC_DXT1: | 368 | case EVAS_COLORSPACE_RGB_S3TC_DXT1: |
395 | if ((rx & 3) || (ry & 3) || (rw & 3) || (rh & 3)) | 369 | if ((rx & 3) || (ry & 3) || (rw & 3) || (rh & 3)) return -1; |
396 | return -1; | ||
397 | return (ry * ie->w + rx) * 8 / 16; | 370 | return (ry * ie->w + rx) * 8 / 16; |
398 | 371 | ||
399 | // ETC2 ARGB, S3TC ARGB | 372 | // ETC2 ARGB, S3TC ARGB |
@@ -403,16 +376,13 @@ _evas_common_rgba_image_data_offset(int rx, int ry, int rw, int rh, int plane, c | |||
403 | case EVAS_COLORSPACE_RGBA_S3TC_DXT3: | 376 | case EVAS_COLORSPACE_RGBA_S3TC_DXT3: |
404 | case EVAS_COLORSPACE_RGBA_S3TC_DXT4: | 377 | case EVAS_COLORSPACE_RGBA_S3TC_DXT4: |
405 | case EVAS_COLORSPACE_RGBA_S3TC_DXT5: | 378 | case EVAS_COLORSPACE_RGBA_S3TC_DXT5: |
406 | if ((rx & 3) || (ry & 3) || (rw & 3) || (rh & 3)) | 379 | if ((rx & 3) || (ry & 3) || (rw & 3) || (rh & 3)) return -1; |
407 | return -1; | ||
408 | return (ry * ie->w + rx) * 16 / 16; | 380 | return (ry * ie->w + rx) * 16 / 16; |
409 | 381 | ||
410 | // ETC1+Alpha | 382 | // ETC1+Alpha |
411 | case EVAS_COLORSPACE_ETC1_ALPHA: | 383 | case EVAS_COLORSPACE_ETC1_ALPHA: |
412 | if ((rx & 3) || (ry & 3) || (rw & 3) || (rh & 3)) | 384 | if ((rx & 3) || (ry & 3) || (rw & 3) || (rh & 3)) return -1; |
413 | return -1; | 385 | if (plane == 0) return (ry * ie->w + rx) * 8 / 16; |
414 | if (plane == 0) | ||
415 | return (ry * ie->w + rx) * 8 / 16; | ||
416 | else if (plane == 1) | 386 | else if (plane == 1) |
417 | return (ry * ie->w + rx) * 8 / 16 + (ie->w * ie->h) * 8 / 16; | 387 | return (ry * ie->w + rx) * 8 / 16 + (ie->w * ie->h) * 8 / 16; |
418 | else return -1; | 388 | else return -1; |
@@ -424,8 +394,10 @@ _evas_common_rgba_image_data_offset(int rx, int ry, int rw, int rh, int plane, c | |||
424 | } | 394 | } |
425 | 395 | ||
426 | static void * | 396 | static void * |
427 | _evas_common_rgba_image_surface_mmap(Image_Entry *ie, unsigned int w, unsigned int h, | 397 | _evas_common_rgba_image_surface_mmap(Image_Entry *ie, |
428 | /* inout */ int *pl, int *pr, int *pt, int *pb) | 398 | unsigned int w, unsigned int h, |
399 | /*inout*/int *pl, int *pr, | ||
400 | int *pt, int *pb) | ||
429 | { | 401 | { |
430 | int siz; | 402 | int siz; |
431 | #if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32)) | 403 | #if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32)) |
@@ -438,11 +410,9 @@ _evas_common_rgba_image_surface_mmap(Image_Entry *ie, unsigned int w, unsigned i | |||
438 | #ifndef MAP_HUGETLB | 410 | #ifndef MAP_HUGETLB |
439 | # define MAP_HUGETLB 0 | 411 | # define MAP_HUGETLB 0 |
440 | #endif | 412 | #endif |
441 | if (siz < 0) | 413 | if (siz < 0) return NULL; |
442 | return NULL; | ||
443 | 414 | ||
444 | if ((siz < PAGE_SIZE) || evas_image_no_mmap) | 415 | if ((siz < PAGE_SIZE) || evas_image_no_mmap) return malloc(siz); |
445 | return malloc(siz); | ||
446 | 416 | ||
447 | if (siz > ((HUGE_PAGE_SIZE * 75) / 100)) | 417 | if (siz > ((HUGE_PAGE_SIZE * 75) / 100)) |
448 | r = mmap(NULL, siz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_HUGETLB, -1, 0); | 418 | r = mmap(NULL, siz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_HUGETLB, -1, 0); |
@@ -460,15 +430,14 @@ _evas_common_rgba_image_surface_mmap(Image_Entry *ie, unsigned int w, unsigned i | |||
460 | void | 430 | void |
461 | evas_common_rgba_image_surface_munmap(void *data, unsigned int w, unsigned int h, Evas_Colorspace cspace) | 431 | evas_common_rgba_image_surface_munmap(void *data, unsigned int w, unsigned int h, Evas_Colorspace cspace) |
462 | { | 432 | { |
463 | if (!data) return ; | 433 | if (!data) return; |
464 | #if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32)) | 434 | #if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32)) |
465 | size_t siz; | 435 | size_t siz; |
466 | 436 | ||
467 | siz = _evas_common_rgba_image_surface_size(w, h, cspace, NULL, NULL, NULL, NULL); | 437 | siz = _evas_common_rgba_image_surface_size(w, h, cspace, |
468 | if ((siz < PAGE_SIZE) || evas_image_no_mmap) | 438 | NULL, NULL, NULL, NULL); |
469 | free(data); | 439 | if ((siz < PAGE_SIZE) || evas_image_no_mmap) free(data); |
470 | else | 440 | else munmap(data, siz); |
471 | munmap(data, siz); | ||
472 | #else | 441 | #else |
473 | (void)w; | 442 | (void)w; |
474 | (void)h; | 443 | (void)h; |
@@ -480,14 +449,11 @@ evas_common_rgba_image_surface_munmap(void *data, unsigned int w, unsigned int h | |||
480 | EAPI void | 449 | EAPI void |
481 | evas_common_image_init(void) | 450 | evas_common_image_init(void) |
482 | { | 451 | { |
483 | if (!eci) | 452 | if (!eci) eci = evas_cache_image_init(&_evas_common_image_func); |
484 | eci = evas_cache_image_init(&_evas_common_image_func); | ||
485 | #ifdef EVAS_CSERVE2 | 453 | #ifdef EVAS_CSERVE2 |
486 | if (!eci2) | 454 | if (!eci2) eci2 = evas_cache2_init(&_evas_common_image_func2); |
487 | eci2 = evas_cache2_init(&_evas_common_image_func2); | ||
488 | #endif | 455 | #endif |
489 | reference++; | 456 | reference++; |
490 | //// ERR("REF++=%i", reference); | ||
491 | 457 | ||
492 | evas_common_scalecache_init(); | 458 | evas_common_scalecache_init(); |
493 | } | 459 | } |
@@ -520,7 +486,6 @@ evas_common_image_shutdown(void) | |||
520 | eci2 = NULL; | 486 | eci2 = NULL; |
521 | #endif | 487 | #endif |
522 | } | 488 | } |
523 | |||
524 | evas_common_scalecache_shutdown(); | 489 | evas_common_scalecache_shutdown(); |
525 | } | 490 | } |
526 | 491 | ||
@@ -541,7 +506,6 @@ _evas_common_rgba_image_new(void) | |||
541 | im->flags = RGBA_IMAGE_NOTHING; | 506 | im->flags = RGBA_IMAGE_NOTHING; |
542 | 507 | ||
543 | evas_common_rgba_image_scalecache_init(&im->cache_entry); | 508 | evas_common_rgba_image_scalecache_init(&im->cache_entry); |
544 | |||
545 | return &im->cache_entry; | 509 | return &im->cache_entry; |
546 | } | 510 | } |
547 | 511 | ||
@@ -560,8 +524,8 @@ _evas_common_rgba_image_delete(Image_Entry *ie) | |||
560 | 524 | ||
561 | evas_image_load_func = ie->info.loader; | 525 | evas_image_load_func = ie->info.loader; |
562 | if (evas_image_load_func) | 526 | if (evas_image_load_func) |
563 | evas_image_load_func->file_close(ie->loader_data); | 527 | evas_image_load_func->file_close(ie->loader_data); |
564 | ie->loader_data = NULL; | 528 | ie->loader_data = NULL; |
565 | } | 529 | } |
566 | evas_common_rgba_image_scalecache_shutdown(&im->cache_entry); | 530 | evas_common_rgba_image_scalecache_shutdown(&im->cache_entry); |
567 | if (ie->info.module) evas_module_unref((Evas_Module *)ie->info.module); | 531 | if (ie->info.module) evas_module_unref((Evas_Module *)ie->info.module); |
@@ -569,13 +533,12 @@ _evas_common_rgba_image_delete(Image_Entry *ie) | |||
569 | if (ie->data1) | 533 | if (ie->data1) |
570 | ERR("Shouldn't reach this point since we are using cache2: '%s' '%s'", | 534 | ERR("Shouldn't reach this point since we are using cache2: '%s' '%s'", |
571 | ie->file, ie->key); | 535 | ie->file, ie->key); |
572 | // if (ie->data1) evas_cserve2_image_free(ie); | ||
573 | #endif | 536 | #endif |
574 | 537 | ||
575 | if (ie->animated.frames) | 538 | if (ie->animated.frames) |
576 | { | 539 | { |
577 | Image_Entry_Frame *frame; | 540 | Image_Entry_Frame *frame; |
578 | 541 | ||
579 | EINA_LIST_FREE(ie->animated.frames, frame) | 542 | EINA_LIST_FREE(ie->animated.frames, frame) |
580 | { | 543 | { |
581 | if (frame->data) free(frame->data); | 544 | if (frame->data) free(frame->data); |
@@ -596,14 +559,14 @@ evas_common_rgba_image_unload_real(Image_Entry *ie) | |||
596 | 559 | ||
597 | if ((im->cs.data) && (im->image.data)) | 560 | if ((im->cs.data) && (im->image.data)) |
598 | { | 561 | { |
599 | if (im->cs.data != im->image.data) | 562 | if (im->cs.data != im->image.data) |
600 | { | 563 | { |
601 | if (!im->cs.no_free) free(im->cs.data); | 564 | if (!im->cs.no_free) free(im->cs.data); |
602 | } | 565 | } |
603 | } | 566 | } |
604 | else if (im->cs.data) | 567 | else if (im->cs.data) |
605 | { | 568 | { |
606 | if (!im->cs.no_free) free(im->cs.data); | 569 | if (!im->cs.no_free) free(im->cs.data); |
607 | } | 570 | } |
608 | im->cs.data = NULL; | 571 | im->cs.data = NULL; |
609 | 572 | ||
@@ -611,11 +574,6 @@ evas_common_rgba_image_unload_real(Image_Entry *ie) | |||
611 | if (ie->data1) | 574 | if (ie->data1) |
612 | { | 575 | { |
613 | ERR("Shouldn't reach this point since we are using cache2."); | 576 | ERR("Shouldn't reach this point since we are using cache2."); |
614 | // evas_cserve2_image_unload(ie); | ||
615 | // im->image.data = NULL; | ||
616 | // ie->allocated.w = 0; | ||
617 | // ie->allocated.h = 0; | ||
618 | // ie->flags.loaded = 0; | ||
619 | ie->flags.preload_done = 0; | 577 | ie->flags.preload_done = 0; |
620 | return; | 578 | return; |
621 | } | 579 | } |
@@ -628,7 +586,7 @@ evas_common_rgba_image_unload_real(Image_Entry *ie) | |||
628 | ie->space); | 586 | ie->space); |
629 | #ifdef SURFDBG | 587 | #ifdef SURFDBG |
630 | surfs = eina_list_remove(surfs, ie); | 588 | surfs = eina_list_remove(surfs, ie); |
631 | #endif | 589 | #endif |
632 | } | 590 | } |
633 | im->image.data = NULL; | 591 | im->image.data = NULL; |
634 | ie->allocated.w = 0; | 592 | ie->allocated.w = 0; |
@@ -638,7 +596,7 @@ evas_common_rgba_image_unload_real(Image_Entry *ie) | |||
638 | ie->need_unload = 0; | 596 | ie->need_unload = 0; |
639 | #ifdef SURFDBG | 597 | #ifdef SURFDBG |
640 | surf_debug(); | 598 | surf_debug(); |
641 | #endif | 599 | #endif |
642 | } | 600 | } |
643 | 601 | ||
644 | static Eina_List *pending_unloads = NULL; | 602 | static Eina_List *pending_unloads = NULL; |
@@ -687,12 +645,12 @@ surf_debug(void) | |||
687 | Image_Entry *ie; | 645 | Image_Entry *ie; |
688 | RGBA_Image *im; | 646 | RGBA_Image *im; |
689 | int i = 0; | 647 | int i = 0; |
690 | 648 | ||
691 | printf("----SURFS----\n"); | 649 | printf("----SURFS----\n"); |
692 | EINA_LIST_FOREACH(surfs, l, ie) | 650 | EINA_LIST_FOREACH(surfs, l, ie) |
693 | { | 651 | { |
694 | im = ie; | 652 | im = ie; |
695 | printf("%i - %p - %ix%i [%s][%s]\n", | 653 | printf("%i - %p - %ix%i [%s][%s]\n", |
696 | i, im->image.data, ie->allocated.w, ie->allocated.h, | 654 | i, im->image.data, ie->allocated.w, ie->allocated.h, |
697 | ie->file, ie->key | 655 | ie->file, ie->key |
698 | ); | 656 | ); |
@@ -724,7 +682,7 @@ void | |||
724 | _evas_common_rgba_image_post_surface(Image_Entry *ie) | 682 | _evas_common_rgba_image_post_surface(Image_Entry *ie) |
725 | { | 683 | { |
726 | #ifdef HAVE_PIXMAN | 684 | #ifdef HAVE_PIXMAN |
727 | # ifdef PIXMAN_IMAGE | 685 | # ifdef PIXMAN_IMAGE |
728 | RGBA_Image *im = (RGBA_Image *)ie; | 686 | RGBA_Image *im = (RGBA_Image *)ie; |
729 | int w, h; | 687 | int w, h; |
730 | 688 | ||
@@ -740,20 +698,20 @@ _evas_common_rgba_image_post_surface(Image_Entry *ie) | |||
740 | if (im->cache_entry.flags.alpha) | 698 | if (im->cache_entry.flags.alpha) |
741 | { | 699 | { |
742 | im->pixman.im = pixman_image_create_bits | 700 | im->pixman.im = pixman_image_create_bits |
743 | ( | 701 | ( |
744 | // FIXME: endianess determines this | 702 | // FIXME: endianess determines this |
745 | PIXMAN_a8r8g8b8, | 703 | PIXMAN_a8r8g8b8, |
746 | // PIXMAN_b8g8r8a8, | 704 | // PIXMAN_b8g8r8a8, |
747 | w, h, im->image.data, w * 4); | 705 | w, h, im->image.data, w * 4); |
748 | } | 706 | } |
749 | else | 707 | else |
750 | { | 708 | { |
751 | im->pixman.im = pixman_image_create_bits | 709 | im->pixman.im = pixman_image_create_bits |
752 | ( | 710 | ( |
753 | // FIXME: endianess determines this | 711 | // FIXME: endianess determines this |
754 | PIXMAN_x8r8g8b8, | 712 | PIXMAN_x8r8g8b8, |
755 | // PIXMAN_b8g8r8x8, | 713 | // PIXMAN_b8g8r8x8, |
756 | w, h, im->image.data, w * 4); | 714 | w, h, im->image.data, w * 4); |
757 | } | 715 | } |
758 | # else | 716 | # else |
759 | (void)ie; | 717 | (void)ie; |
@@ -764,7 +722,8 @@ _evas_common_rgba_image_post_surface(Image_Entry *ie) | |||
764 | } | 722 | } |
765 | 723 | ||
766 | static int | 724 | static int |
767 | _evas_common_rgba_image_surface_alloc(Image_Entry *ie, unsigned int w, unsigned int h) | 725 | _evas_common_rgba_image_surface_alloc(Image_Entry *ie, |
726 | unsigned int w, unsigned int h) | ||
768 | { | 727 | { |
769 | RGBA_Image *im = (RGBA_Image *) ie; | 728 | RGBA_Image *im = (RGBA_Image *) ie; |
770 | int l = 0, r = 0, t = 0, b = 0; | 729 | int l = 0, r = 0, t = 0, b = 0; |
@@ -779,7 +738,7 @@ _evas_common_rgba_image_surface_alloc(Image_Entry *ie, unsigned int w, unsigned | |||
779 | evas_common_rgba_image_surface_munmap(im->image.data, | 738 | evas_common_rgba_image_surface_munmap(im->image.data, |
780 | ie->allocated.w, ie->allocated.h, | 739 | ie->allocated.w, ie->allocated.h, |
781 | ie->space); | 740 | ie->space); |
782 | im->image.data = NULL; | 741 | im->image.data = NULL; |
783 | #ifdef SURFDBG | 742 | #ifdef SURFDBG |
784 | surfs = eina_list_remove(surfs, ie); | 743 | surfs = eina_list_remove(surfs, ie); |
785 | #endif | 744 | #endif |
@@ -789,7 +748,8 @@ _evas_common_rgba_image_surface_alloc(Image_Entry *ie, unsigned int w, unsigned | |||
789 | r = ie->borders.r; | 748 | r = ie->borders.r; |
790 | t = ie->borders.t; | 749 | t = ie->borders.t; |
791 | b = ie->borders.b; | 750 | b = ie->borders.b; |
792 | im->image.data = _evas_common_rgba_image_surface_mmap(ie, w, h, &l, &r, &t, &b); | 751 | im->image.data = _evas_common_rgba_image_surface_mmap(ie, w, h, |
752 | &l, &r, &t, &b); | ||
793 | if (!im->image.data) return -1; | 753 | if (!im->image.data) return -1; |
794 | ie->borders.l = l; | 754 | ie->borders.l = l; |
795 | ie->borders.r = r; | 755 | ie->borders.r = r; |
@@ -832,18 +792,17 @@ _evas_common_rgba_image_surface_delete(Image_Entry *ie) | |||
832 | } | 792 | } |
833 | # endif | 793 | # endif |
834 | #endif | 794 | #endif |
835 | if (ie->file) | 795 | if (ie->file) DBG("unload: [%p] %s %s", ie, ie->file, ie->key); |
836 | DBG("unload: [%p] %s %s", ie, ie->file, ie->key); | ||
837 | if ((im->cs.data) && (im->image.data)) | 796 | if ((im->cs.data) && (im->image.data)) |
838 | { | 797 | { |
839 | if (im->cs.data != im->image.data) | 798 | if (im->cs.data != im->image.data) |
840 | { | 799 | { |
841 | if (!im->cs.no_free) free(im->cs.data); | 800 | if (!im->cs.no_free) free(im->cs.data); |
842 | } | 801 | } |
843 | } | 802 | } |
844 | else if (im->cs.data) | 803 | else if (im->cs.data) |
845 | { | 804 | { |
846 | if (!im->cs.no_free) free(im->cs.data); | 805 | if (!im->cs.no_free) free(im->cs.data); |
847 | } | 806 | } |
848 | im->cs.data = NULL; | 807 | im->cs.data = NULL; |
849 | 808 | ||
@@ -856,11 +815,6 @@ _evas_common_rgba_image_surface_delete(Image_Entry *ie) | |||
856 | surfs = eina_list_remove(surfs, ie); | 815 | surfs = eina_list_remove(surfs, ie); |
857 | #endif | 816 | #endif |
858 | } | 817 | } |
859 | // #ifdef EVAS_CSERVE2 | ||
860 | // else if (ie->data1) | ||
861 | // ERR("Shouldn't reach this point since we are using cache2."); | ||
862 | // // evas_cserve2_image_free(ie); | ||
863 | // #endif | ||
864 | 818 | ||
865 | im->image.data = NULL; | 819 | im->image.data = NULL; |
866 | ie->allocated.w = 0; | 820 | ie->allocated.w = 0; |
@@ -876,18 +830,20 @@ _evas_common_rgba_image_surface_delete(Image_Entry *ie) | |||
876 | static void | 830 | static void |
877 | _evas_common_rgba_image_unload(Image_Entry *im) | 831 | _evas_common_rgba_image_unload(Image_Entry *im) |
878 | { | 832 | { |
879 | // DBG("unload: [%p] %s %s", im, im->file, im->key); | ||
880 | evas_common_rgba_image_scalecache_dirty(im); | 833 | evas_common_rgba_image_scalecache_dirty(im); |
881 | evas_common_rgba_image_unload(im); | 834 | evas_common_rgba_image_unload(im); |
882 | } | 835 | } |
883 | 836 | ||
884 | static void | 837 | static void |
885 | _evas_common_rgba_image_dirty_region(Image_Entry* ie, unsigned int x EINA_UNUSED, unsigned int y EINA_UNUSED, unsigned int w EINA_UNUSED, unsigned int h EINA_UNUSED) | 838 | _evas_common_rgba_image_dirty_region(Image_Entry* ie, |
839 | unsigned int x EINA_UNUSED, | ||
840 | unsigned int y EINA_UNUSED, | ||
841 | unsigned int w EINA_UNUSED, | ||
842 | unsigned int h EINA_UNUSED) | ||
886 | { | 843 | { |
887 | RGBA_Image *im = (RGBA_Image *) ie; | 844 | RGBA_Image *im = (RGBA_Image *) ie; |
888 | 845 | ||
889 | #ifdef EVAS_CSERVE2 | 846 | #ifdef EVAS_CSERVE2 |
890 | // if (ie->data1) evas_cserve2_image_free(ie); | ||
891 | if (ie->data1) ERR("Shouldn't reach this point since we are using cache2."); | 847 | if (ie->data1) ERR("Shouldn't reach this point since we are using cache2."); |
892 | #endif | 848 | #endif |
893 | im->flags |= RGBA_IMAGE_IS_DIRTY; | 849 | im->flags |= RGBA_IMAGE_IS_DIRTY; |
@@ -907,24 +863,22 @@ _evas_common_rgba_image_dirty(Image_Entry *ie_dst, const Image_Entry *ie_src) | |||
907 | if (!evas_cache_image_pixels(ie_dst)) | 863 | if (!evas_cache_image_pixels(ie_dst)) |
908 | { | 864 | { |
909 | if (_evas_common_rgba_image_surface_alloc(&dst->cache_entry, | 865 | if (_evas_common_rgba_image_surface_alloc(&dst->cache_entry, |
910 | src->cache_entry.w, src->cache_entry.h)) | 866 | src->cache_entry.w, |
867 | src->cache_entry.h)) | ||
911 | { | 868 | { |
912 | #ifdef EVAS_CSERVE2 | 869 | #ifdef EVAS_CSERVE2 |
913 | // if (ie_src->data1) evas_cserve2_image_free((Image_Entry*) ie_src); | 870 | if (ie_src->data1) |
914 | if (ie_src->data1) ERR("Shouldn't reach this point since we are using cache2."); | 871 | ERR("Shouldn't reach this point since we are using cache2."); |
915 | #endif | 872 | #endif |
916 | return 1; | 873 | return 1; |
917 | } | 874 | } |
918 | } | 875 | } |
919 | #ifdef EVAS_CSERVE2 | 876 | #ifdef EVAS_CSERVE2 |
920 | // if (ie_src->data1) evas_cserve2_image_free((Image_Entry*) ie_src); | 877 | if (ie_src->data1) |
921 | if (ie_src->data1) ERR("Shouldn't reach this point since we are using cache2."); | 878 | ERR("Shouldn't reach this point since we are using cache2."); |
922 | #endif | 879 | #endif |
923 | evas_common_image_colorspace_normalize(src); | 880 | evas_common_image_colorspace_normalize(src); |
924 | evas_common_image_colorspace_normalize(dst); | 881 | evas_common_image_colorspace_normalize(dst); |
925 | /* evas_common_blit_rectangle(src, dst, 0, 0, src->cache_entry.w, src->cache_entry.h, 0, 0); */ | ||
926 | /* evas_common_cpu_end_opt(); */ | ||
927 | |||
928 | return 0; | 882 | return 0; |
929 | } | 883 | } |
930 | 884 | ||
@@ -954,87 +908,10 @@ _evas_common_rgba_image_ram_usage(Image_Entry *ie) | |||
954 | static DATA32 * | 908 | static DATA32 * |
955 | _evas_common_rgba_image_surface_pixels(Image_Entry *ie) | 909 | _evas_common_rgba_image_surface_pixels(Image_Entry *ie) |
956 | { | 910 | { |
957 | RGBA_Image *im = (RGBA_Image *) ie; | 911 | RGBA_Image *im = (RGBA_Image *)ie; |
958 | |||
959 | return im->image.data; | 912 | return im->image.data; |
960 | } | 913 | } |
961 | 914 | ||
962 | #if 0 | ||
963 | void | ||
964 | evas_common_image_surface_alpha_tiles_calc(RGBA_Surface *is, int tsize) | ||
965 | { | ||
966 | int x, y; | ||
967 | DATA32 *ptr; | ||
968 | |||
969 | if (is->spans) return; | ||
970 | if (!is->im->cache_entry.flags.alpha) return; | ||
971 | /* FIXME: dont handle alpha only images yet */ | ||
972 | if (is->im->space != EVAS_COLORSPACE_GRY8) return; | ||
973 | if (tsize < 0) tsize = 0; | ||
974 | is->spans = calloc(1, sizeof(RGBA_Image_Span *) * is->h); | ||
975 | if (!is->spans) return; | ||
976 | ptr = is->data; | ||
977 | for (y = 0; y < is->h; y++) | ||
978 | { | ||
979 | RGBA_Image_Span *sp; | ||
980 | |||
981 | sp = NULL; | ||
982 | for (x = 0; x < is->w; x++) | ||
983 | { | ||
984 | DATA8 a; | ||
985 | |||
986 | a = A_VAL(ptr); | ||
987 | if (sp) | ||
988 | { | ||
989 | if (a == 0) | ||
990 | { | ||
991 | is->spans[y] = eina_inlist_append(is->spans[y], sp); | ||
992 | sp = NULL; | ||
993 | } | ||
994 | else | ||
995 | { | ||
996 | sp->w++; | ||
997 | if ((sp->v == 2) && (a != 255)) sp->v = 1; | ||
998 | } | ||
999 | } | ||
1000 | else | ||
1001 | { | ||
1002 | if (a == 255) | ||
1003 | { | ||
1004 | sp = calloc(1, sizeof(RGBA_Image_Span)); | ||
1005 | sp->x = x; | ||
1006 | sp->w = 1; | ||
1007 | sp->v = 2; | ||
1008 | } | ||
1009 | else if (a > 0) | ||
1010 | { | ||
1011 | sp = calloc(1, sizeof(RGBA_Image_Span)); | ||
1012 | sp->x = x; | ||
1013 | sp->w = 1; | ||
1014 | sp->v = 1; | ||
1015 | } | ||
1016 | } | ||
1017 | ptr++; | ||
1018 | } | ||
1019 | if (sp) | ||
1020 | { | ||
1021 | is->spans[y] = eina_inlist_append(is->spans[y], sp); | ||
1022 | sp = NULL; | ||
1023 | } | ||
1024 | } | ||
1025 | } | ||
1026 | #endif | ||
1027 | |||
1028 | /* EAPI void */ | ||
1029 | /* evas_common_image_surface_dealloc(RGBA_Surface *is) */ | ||
1030 | /* { */ | ||
1031 | /* if ((is->data) && (!is->no_free)) */ | ||
1032 | /* { */ | ||
1033 | /* free(is->data); */ | ||
1034 | /* is->data = NULL; */ | ||
1035 | /* } */ | ||
1036 | /* } */ | ||
1037 | |||
1038 | static RGBA_Image * | 915 | static RGBA_Image * |
1039 | evas_common_image_create(unsigned int w, unsigned int h) | 916 | evas_common_image_create(unsigned int w, unsigned int h) |
1040 | { | 917 | { |
@@ -1056,7 +933,7 @@ evas_common_image_create(unsigned int w, unsigned int h) | |||
1056 | EAPI RGBA_Image * | 933 | EAPI RGBA_Image * |
1057 | evas_common_image_alpha_create(unsigned int w, unsigned int h) | 934 | evas_common_image_alpha_create(unsigned int w, unsigned int h) |
1058 | { | 935 | { |
1059 | RGBA_Image *im; | 936 | RGBA_Image *im; |
1060 | 937 | ||
1061 | im = (RGBA_Image *) _evas_common_rgba_image_new(); | 938 | im = (RGBA_Image *) _evas_common_rgba_image_new(); |
1062 | if (!im) return NULL; | 939 | if (!im) return NULL; |
@@ -1075,8 +952,7 @@ evas_common_image_alpha_create(unsigned int w, unsigned int h) | |||
1075 | EAPI RGBA_Image * | 952 | EAPI RGBA_Image * |
1076 | evas_common_image_new(unsigned int w, unsigned int h, unsigned int alpha) | 953 | evas_common_image_new(unsigned int w, unsigned int h, unsigned int alpha) |
1077 | { | 954 | { |
1078 | if (alpha) | 955 | if (alpha) return evas_common_image_alpha_create(w, h); |
1079 | return evas_common_image_alpha_create(w, h); | ||
1080 | return evas_common_image_create(w, h); | 956 | return evas_common_image_create(w, h); |
1081 | } | 957 | } |
1082 | 958 | ||
@@ -1093,15 +969,16 @@ evas_common_image_colorspace_normalize(RGBA_Image *im) | |||
1093 | if (im->image.data != im->cs.data) | 969 | if (im->image.data != im->cs.data) |
1094 | { | 970 | { |
1095 | #ifdef EVAS_CSERVE2 | 971 | #ifdef EVAS_CSERVE2 |
1096 | // if (((Image_Entry *)im)->data1) evas_cserve2_image_free(&im->cache_entry); | 972 | if (((Image_Entry *)im)->data1) |
1097 | if (((Image_Entry *)im)->data1) ERR("Shouldn't reach this point since we are using cache2."); | 973 | ERR("Shouldn't reach this point since we are using cache2."); |
1098 | #endif | 974 | #endif |
1099 | if (!im->image.no_free) | 975 | if (!im->image.no_free) |
1100 | { | 976 | { |
1101 | evas_common_rgba_image_surface_munmap(im->image.data, | 977 | evas_common_rgba_image_surface_munmap |
1102 | im->cache_entry.allocated.w, | 978 | (im->image.data, |
1103 | im->cache_entry.allocated.h, | 979 | im->cache_entry.allocated.w, |
1104 | im->cache_entry.space); | 980 | im->cache_entry.allocated.h, |
981 | im->cache_entry.space); | ||
1105 | #ifdef SURFDBG | 982 | #ifdef SURFDBG |
1106 | surfs = eina_list_remove(surfs, im); | 983 | surfs = eina_list_remove(surfs, im); |
1107 | #endif | 984 | #endif |
@@ -1114,28 +991,38 @@ evas_common_image_colorspace_normalize(RGBA_Image *im) | |||
1114 | break; | 991 | break; |
1115 | case EVAS_COLORSPACE_YCBCR422P601_PL: | 992 | case EVAS_COLORSPACE_YCBCR422P601_PL: |
1116 | if ((im->image.data) && (*((unsigned char **)im->cs.data))) | 993 | if ((im->image.data) && (*((unsigned char **)im->cs.data))) |
1117 | evas_common_convert_yuv_422p_601_rgba(im->cs.data, (DATA8*) im->image.data, | 994 | evas_common_convert_yuv_422p_601_rgba(im->cs.data, |
1118 | im->cache_entry.w, im->cache_entry.h); | 995 | (DATA8 *)im->image.data, |
996 | im->cache_entry.w, | ||
997 | im->cache_entry.h); | ||
1119 | break; | 998 | break; |
1120 | case EVAS_COLORSPACE_YCBCR422601_PL: | 999 | case EVAS_COLORSPACE_YCBCR422601_PL: |
1121 | if ((im->image.data) && (*((unsigned char **)im->cs.data))) | 1000 | if ((im->image.data) && (*((unsigned char **)im->cs.data))) |
1122 | evas_common_convert_yuv_422_601_rgba(im->cs.data, (DATA8*) im->image.data, | 1001 | evas_common_convert_yuv_422_601_rgba(im->cs.data, |
1123 | im->cache_entry.w, im->cache_entry.h); | 1002 | (DATA8 *)im->image.data, |
1003 | im->cache_entry.w, | ||
1004 | im->cache_entry.h); | ||
1124 | break; | 1005 | break; |
1125 | case EVAS_COLORSPACE_YCBCR420NV12601_PL: | 1006 | case EVAS_COLORSPACE_YCBCR420NV12601_PL: |
1126 | if ((im->image.data) && (*((unsigned char **)im->cs.data))) | 1007 | if ((im->image.data) && (*((unsigned char **)im->cs.data))) |
1127 | evas_common_convert_yuv_420_601_rgba(im->cs.data, (DATA8*) im->image.data, | 1008 | evas_common_convert_yuv_420_601_rgba(im->cs.data, |
1128 | im->cache_entry.w, im->cache_entry.h); | 1009 | (DATA8 *)im->image.data, |
1010 | im->cache_entry.w, | ||
1011 | im->cache_entry.h); | ||
1129 | break; | 1012 | break; |
1130 | case EVAS_COLORSPACE_YCBCR420TM12601_PL: | 1013 | case EVAS_COLORSPACE_YCBCR420TM12601_PL: |
1131 | if ((im->image.data) && (*((unsigned char **)im->cs.data))) | 1014 | if ((im->image.data) && (*((unsigned char **)im->cs.data))) |
1132 | evas_common_convert_yuv_420T_601_rgba(im->cs.data, (DATA8*) im->image.data, | 1015 | evas_common_convert_yuv_420T_601_rgba(im->cs.data, |
1133 | im->cache_entry.w, im->cache_entry.h); | 1016 | (DATA8 *)im->image.data, |
1017 | im->cache_entry.w, | ||
1018 | im->cache_entry.h); | ||
1134 | break; | 1019 | break; |
1135 | case EMILE_COLORSPACE_YCBCR422P709_PL: | 1020 | case EMILE_COLORSPACE_YCBCR422P709_PL: |
1136 | if ((im->image.data) && (*((unsigned char **)im->cs.data))) | 1021 | if ((im->image.data) && (*((unsigned char **)im->cs.data))) |
1137 | evas_common_convert_yuv_422p_709_rgba(im->cs.data, (DATA8*) im->image.data, | 1022 | evas_common_convert_yuv_422p_709_rgba(im->cs.data, |
1138 | im->cache_entry.w, im->cache_entry.h); | 1023 | (DATA8 *)im->image.data, |
1024 | im->cache_entry.w, | ||
1025 | im->cache_entry.h); | ||
1139 | break; | 1026 | break; |
1140 | default: | 1027 | default: |
1141 | break; | 1028 | break; |
@@ -1152,14 +1039,14 @@ evas_common_image_colorspace_dirty(RGBA_Image *im) | |||
1152 | im->cs.dirty = 1; | 1039 | im->cs.dirty = 1; |
1153 | evas_common_rgba_image_scalecache_dirty(&im->cache_entry); | 1040 | evas_common_rgba_image_scalecache_dirty(&im->cache_entry); |
1154 | #ifdef HAVE_PIXMAN | 1041 | #ifdef HAVE_PIXMAN |
1155 | # ifdef PIXMAN_IMAGE | 1042 | # ifdef PIXMAN_IMAGE |
1156 | if (im->pixman.im) | 1043 | if (im->pixman.im) |
1157 | { | 1044 | { |
1158 | pixman_image_unref(im->pixman.im); | 1045 | pixman_image_unref(im->pixman.im); |
1159 | im->pixman.im = NULL; | 1046 | im->pixman.im = NULL; |
1160 | } | 1047 | } |
1161 | _evas_common_rgba_image_post_surface((Image_Entry *)im); | 1048 | _evas_common_rgba_image_post_surface((Image_Entry *)im); |
1162 | # endif | 1049 | # endif |
1163 | #endif | 1050 | #endif |
1164 | } | 1051 | } |
1165 | 1052 | ||
@@ -1181,23 +1068,25 @@ evas_common_image_get_cache(void) | |||
1181 | } | 1068 | } |
1182 | 1069 | ||
1183 | EAPI RGBA_Image * | 1070 | EAPI RGBA_Image * |
1184 | evas_common_load_image_from_file(const char *file, const char *key, Evas_Image_Load_Opts *lo, int *error) | 1071 | evas_common_load_image_from_file(const char *file, const char *key, |
1072 | Evas_Image_Load_Opts *lo, int *error) | ||
1185 | { | 1073 | { |
1186 | if (!file) | 1074 | if (!file) |
1187 | { | 1075 | { |
1188 | *error = EVAS_LOAD_ERROR_GENERIC; | 1076 | *error = EVAS_LOAD_ERROR_GENERIC; |
1189 | return NULL; | 1077 | return NULL; |
1190 | } | 1078 | } |
1191 | return (RGBA_Image *) evas_cache_image_request(eci, file, key, lo, error); | 1079 | return (RGBA_Image *) evas_cache_image_request(eci, file, key, lo, error); |
1192 | } | 1080 | } |
1193 | 1081 | ||
1194 | EAPI RGBA_Image * | 1082 | EAPI RGBA_Image * |
1195 | evas_common_load_image_from_mmap(Eina_File *f, const char *key, Evas_Image_Load_Opts *lo, int *error) | 1083 | evas_common_load_image_from_mmap(Eina_File *f, const char *key, |
1084 | Evas_Image_Load_Opts *lo, int *error) | ||
1196 | { | 1085 | { |
1197 | if (!f) | 1086 | if (!f) |
1198 | { | 1087 | { |
1199 | *error = EVAS_LOAD_ERROR_GENERIC; | 1088 | *error = EVAS_LOAD_ERROR_GENERIC; |
1200 | return NULL; | 1089 | return NULL; |
1201 | } | 1090 | } |
1202 | return (RGBA_Image *) evas_cache_image_mmap_request(eci, f, key, lo, error); | 1091 | return (RGBA_Image *) evas_cache_image_mmap_request(eci, f, key, lo, error); |
1203 | } | 1092 | } |
@@ -1227,58 +1116,20 @@ evas_common_image_line_buffer_obtain(int len) | |||
1227 | { | 1116 | { |
1228 | if (len < 1) return NULL; | 1117 | if (len < 1) return NULL; |
1229 | if (len < EVAS_RGBA_LINE_BUFFER_MIN_LEN) | 1118 | if (len < EVAS_RGBA_LINE_BUFFER_MIN_LEN) |
1230 | len = EVAS_RGBA_LINE_BUFFER_MIN_LEN; | 1119 | len = EVAS_RGBA_LINE_BUFFER_MIN_LEN; |
1231 | return evas_common_image_create(len, 1); | 1120 | return evas_common_image_create(len, 1); |
1232 | /* | ||
1233 | if (evas_rgba_line_buffer) | ||
1234 | { | ||
1235 | if (evas_rgba_line_buffer->image->w >= len) | ||
1236 | return evas_rgba_line_buffer; | ||
1237 | evas_rgba_line_buffer->image->data = (DATA32 *)realloc(evas_rgba_line_buffer->image->data, len * sizeof(DATA32)); | ||
1238 | if (!evas_rgba_line_buffer->image->data) | ||
1239 | { | ||
1240 | evas_common_image_free(evas_rgba_line_buffer); | ||
1241 | evas_rgba_line_buffer = NULL; | ||
1242 | return NULL; | ||
1243 | } | ||
1244 | evas_rgba_line_buffer->image->w = len; | ||
1245 | return evas_rgba_line_buffer; | ||
1246 | } | ||
1247 | evas_rgba_line_buffer = evas_common_image_create(len, 1); | ||
1248 | if (!evas_rgba_line_buffer) return NULL; | ||
1249 | return evas_rgba_line_buffer; | ||
1250 | */ | ||
1251 | } | 1121 | } |
1252 | 1122 | ||
1253 | EAPI void | 1123 | EAPI void |
1254 | evas_common_image_line_buffer_release(RGBA_Image *im) | 1124 | evas_common_image_line_buffer_release(RGBA_Image *im) |
1255 | { | 1125 | { |
1256 | _evas_common_rgba_image_delete(&im->cache_entry); | 1126 | _evas_common_rgba_image_delete(&im->cache_entry); |
1257 | /* | ||
1258 | if (!evas_rgba_line_buffer) return; | ||
1259 | if (EVAS_RGBA_LINE_BUFFER_MAX_LEN < evas_rgba_line_buffer->image->w) | ||
1260 | { | ||
1261 | evas_rgba_line_buffer->image->w = EVAS_RGBA_LINE_BUFFER_MAX_LEN; | ||
1262 | evas_rgba_line_buffer->image->data = (DATA32 *)realloc(evas_rgba_line_buffer->image->data, | ||
1263 | evas_rgba_line_buffer->image->w * sizeof(DATA32)); | ||
1264 | if (!evas_rgba_line_buffer->image->data) | ||
1265 | { | ||
1266 | evas_common_image_free(evas_rgba_line_buffer); | ||
1267 | evas_rgba_line_buffer = NULL; | ||
1268 | } | ||
1269 | } | ||
1270 | */ | ||
1271 | } | 1127 | } |
1272 | 1128 | ||
1273 | EAPI void | 1129 | EAPI void |
1274 | evas_common_image_line_buffer_free(RGBA_Image *im) | 1130 | evas_common_image_line_buffer_free(RGBA_Image *im) |
1275 | { | 1131 | { |
1276 | _evas_common_rgba_image_delete(&im->cache_entry); | 1132 | _evas_common_rgba_image_delete(&im->cache_entry); |
1277 | /* | ||
1278 | if (!evas_rgba_line_buffer) return; | ||
1279 | evas_common_image_free(evas_rgba_line_buffer); | ||
1280 | evas_rgba_line_buffer = NULL; | ||
1281 | */ | ||
1282 | } | 1133 | } |
1283 | 1134 | ||
1284 | EAPI RGBA_Image * | 1135 | EAPI RGBA_Image * |
@@ -1286,52 +1137,20 @@ evas_common_image_alpha_line_buffer_obtain(int len) | |||
1286 | { | 1137 | { |
1287 | if (len < 1) return NULL; | 1138 | if (len < 1) return NULL; |
1288 | if (len < EVAS_ALPHA_LINE_BUFFER_MIN_LEN) | 1139 | if (len < EVAS_ALPHA_LINE_BUFFER_MIN_LEN) |
1289 | len = EVAS_ALPHA_LINE_BUFFER_MIN_LEN; | 1140 | len = EVAS_ALPHA_LINE_BUFFER_MIN_LEN; |
1290 | return evas_common_image_alpha_create(len, 1); | 1141 | return evas_common_image_alpha_create(len, 1); |
1291 | /* | ||
1292 | if (evas_alpha_line_buffer) | ||
1293 | { | ||
1294 | if (evas_alpha_line_buffer->image->w >= len) | ||
1295 | return evas_alpha_line_buffer; | ||
1296 | evas_alpha_line_buffer->image->data = realloc(evas_alpha_line_buffer->image->data, len * sizeof(DATA8)); | ||
1297 | if (!evas_alpha_line_buffer->image->data) | ||
1298 | { | ||
1299 | evas_common_image_free(evas_alpha_line_buffer); | ||
1300 | evas_alpha_line_buffer = NULL; | ||
1301 | return NULL; | ||
1302 | } | ||
1303 | evas_alpha_line_buffer->image->w = len; | ||
1304 | return evas_alpha_line_buffer; | ||
1305 | } | ||
1306 | evas_alpha_line_buffer = evas_common_image_alpha_create(len, 1); | ||
1307 | return evas_alpha_line_buffer; | ||
1308 | */ | ||
1309 | } | 1142 | } |
1310 | 1143 | ||
1311 | EAPI void | 1144 | EAPI void |
1312 | evas_common_image_alpha_line_buffer_release(RGBA_Image *im) | 1145 | evas_common_image_alpha_line_buffer_release(RGBA_Image *im) |
1313 | { | 1146 | { |
1314 | _evas_common_rgba_image_delete(&im->cache_entry); | 1147 | _evas_common_rgba_image_delete(&im->cache_entry); |
1315 | /* | ||
1316 | if (!evas_alpha_line_buffer) return; | ||
1317 | if (EVAS_ALPHA_LINE_BUFFER_MAX_LEN < evas_alpha_line_buffer->image->w) | ||
1318 | { | ||
1319 | evas_alpha_line_buffer->image->w = EVAS_ALPHA_LINE_BUFFER_MAX_LEN; | ||
1320 | evas_alpha_line_buffer->image->data = realloc(evas_alpha_line_buffer->image->data, | ||
1321 | evas_alpha_line_buffer->image->w * sizeof(DATA8)); | ||
1322 | if (!evas_alpha_line_buffer->image->data) | ||
1323 | { | ||
1324 | evas_common_image_free(evas_alpha_line_buffer); | ||
1325 | evas_alpha_line_buffer = NULL; | ||
1326 | } | ||
1327 | } | ||
1328 | */ | ||
1329 | } | 1148 | } |
1330 | 1149 | ||
1331 | EAPI void | 1150 | EAPI void |
1332 | evas_common_image_premul(Image_Entry *ie) | 1151 | evas_common_image_premul(Image_Entry *ie) |
1333 | { | 1152 | { |
1334 | DATA32 nas = 0; | 1153 | DATA32 nas = 0; |
1335 | 1154 | ||
1336 | if (!ie) return; | 1155 | if (!ie) return; |
1337 | if (!evas_cache_image_pixels(ie)) return; | 1156 | if (!evas_cache_image_pixels(ie)) return; |
@@ -1340,10 +1159,12 @@ evas_common_image_premul(Image_Entry *ie) | |||
1340 | switch (ie->space) | 1159 | switch (ie->space) |
1341 | { | 1160 | { |
1342 | case EVAS_COLORSPACE_ARGB8888: | 1161 | case EVAS_COLORSPACE_ARGB8888: |
1343 | nas = evas_common_convert_argb_premul(evas_cache_image_pixels(ie), ie->w * ie->h); | 1162 | nas = evas_common_convert_argb_premul |
1344 | break; | 1163 | (evas_cache_image_pixels(ie), ie->w * ie->h); |
1164 | break; | ||
1345 | case EVAS_COLORSPACE_AGRY88: | 1165 | case EVAS_COLORSPACE_AGRY88: |
1346 | nas = evas_common_convert_ag_premul((void*) evas_cache_image_pixels(ie), ie->w * ie->h); | 1166 | nas = evas_common_convert_ag_premul |
1167 | ((void *)evas_cache_image_pixels(ie), ie->w * ie->h); | ||
1347 | default: return; | 1168 | default: return; |
1348 | } | 1169 | } |
1349 | if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h)) | 1170 | if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h)) |
@@ -1353,8 +1174,8 @@ evas_common_image_premul(Image_Entry *ie) | |||
1353 | EAPI void | 1174 | EAPI void |
1354 | evas_common_image_set_alpha_sparse(Image_Entry *ie) | 1175 | evas_common_image_set_alpha_sparse(Image_Entry *ie) |
1355 | { | 1176 | { |
1356 | DATA32 *s, *se; | 1177 | DATA32 *s, *se; |
1357 | DATA32 nas = 0; | 1178 | DATA32 nas = 0; |
1358 | 1179 | ||
1359 | if (!ie) return; | 1180 | if (!ie) return; |
1360 | if (!evas_cache_image_pixels(ie)) return; | 1181 | if (!evas_cache_image_pixels(ie)) return; |
@@ -1364,11 +1185,10 @@ evas_common_image_set_alpha_sparse(Image_Entry *ie) | |||
1364 | se = s + (ie->w * ie->h); | 1185 | se = s + (ie->w * ie->h); |
1365 | while (s < se) | 1186 | while (s < se) |
1366 | { | 1187 | { |
1367 | DATA32 p = *s & 0xff000000; | 1188 | DATA32 p = *s & 0xff000000; |
1368 | 1189 | ||
1369 | if (!p || (p == 0xff000000)) | 1190 | if (!p || (p == 0xff000000)) nas++; |
1370 | nas++; | 1191 | s++; |
1371 | s++; | ||
1372 | } | 1192 | } |
1373 | if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h)) | 1193 | if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h)) |
1374 | ie->flags.alpha_sparse = 1; | 1194 | ie->flags.alpha_sparse = 1; |