aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/engines/common/evas_image_data.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/evas/src/lib/engines/common/evas_image_data.c')
-rw-r--r--libraries/evas/src/lib/engines/common/evas_image_data.c147
1 files changed, 147 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/engines/common/evas_image_data.c b/libraries/evas/src/lib/engines/common/evas_image_data.c
new file mode 100644
index 0000000..10b3988
--- /dev/null
+++ b/libraries/evas/src/lib/engines/common/evas_image_data.c
@@ -0,0 +1,147 @@
1#include <assert.h>
2
3#include "evas_common.h"
4#include "evas_private.h"
5#include "evas_image.h"
6
7int
8evas_common_rgba_image_from_data(Image_Entry* ie_dst, int w, int h, DATA32 *image_data, int alpha, int cspace)
9{
10 RGBA_Image *dst = (RGBA_Image *) ie_dst;
11
12 switch (cspace)
13 {
14 case EVAS_COLORSPACE_ARGB8888:
15 dst->cache_entry.w = w;
16 dst->cache_entry.h = h;
17 dst->image.data = image_data;
18 dst->image.no_free = 1;
19 dst->cache_entry.flags.alpha = alpha ? 1 : 0;
20 break;
21 case EVAS_COLORSPACE_YCBCR422P601_PL:
22 case EVAS_COLORSPACE_YCBCR422P709_PL:
23 case EVAS_COLORSPACE_YCBCR422601_PL:
24 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
25 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
26 w &= ~0x1;
27 dst->cache_entry.w = w;
28 dst->cache_entry.h = h;
29 dst->cs.data = image_data;
30 dst->cs.no_free = 1;
31 break;
32 default:
33 abort();
34 break;
35 }
36 dst->cache_entry.space = cspace;
37 evas_common_image_colorspace_dirty(dst);
38 _evas_common_rgba_image_post_surface(ie_dst);
39 return 0;
40}
41
42int
43evas_common_rgba_image_from_copied_data(Image_Entry* ie_dst, int w, int h, DATA32 *image_data, int alpha, int cspace)
44{
45 RGBA_Image *dst = (RGBA_Image *) ie_dst;
46
47 /* FIXME: Is dst->image.data valid. */
48 switch (cspace)
49 {
50 case EVAS_COLORSPACE_ARGB8888:
51 dst->cache_entry.flags.alpha = alpha ? 1 : 0;
52 if (image_data)
53 memcpy(dst->image.data, image_data, w * h * sizeof(DATA32));
54 break;
55 case EVAS_COLORSPACE_YCBCR422P601_PL:
56 case EVAS_COLORSPACE_YCBCR422P709_PL:
57 case EVAS_COLORSPACE_YCBCR422601_PL:
58 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
59 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
60 dst->cs.data = calloc(1, dst->cache_entry.h * sizeof(unsigned char*) * 2);
61 if (image_data && (dst->cs.data))
62 memcpy(dst->cs.data, image_data, dst->cache_entry.h * sizeof(unsigned char*) * 2);
63 break;
64 default:
65 abort();
66 break;
67 }
68
69 dst->cache_entry.space = cspace;
70 evas_common_image_colorspace_dirty(dst);
71 _evas_common_rgba_image_post_surface(ie_dst);
72 return 0;
73}
74
75int
76evas_common_rgba_image_size_set(Image_Entry *ie_dst, const Image_Entry *ie_im, unsigned int w, unsigned int h __UNUSED__)
77{
78 RGBA_Image *dst = (RGBA_Image *) ie_dst;
79 RGBA_Image *im = (RGBA_Image *) ie_im;
80
81 if ((im->cache_entry.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
82 (im->cache_entry.space == EVAS_COLORSPACE_YCBCR422P709_PL) ||
83 (im->cache_entry.space == EVAS_COLORSPACE_YCBCR422601_PL) ||
84 (im->cache_entry.space == EVAS_COLORSPACE_YCBCR420TM12601_PL) ||
85 (im->cache_entry.space == EVAS_COLORSPACE_YCBCR420NV12601_PL))
86 {
87 w &= ~0x1;
88 dst->cs.data = calloc(1, dst->cache_entry.h * sizeof(unsigned char *) * 2);
89 }
90
91 dst->flags = im->flags;
92 dst->cs.no_free = 0;
93 evas_common_image_colorspace_dirty(dst);
94
95 _evas_common_rgba_image_post_surface(ie_dst);
96 return 0;
97}
98
99int
100evas_common_rgba_image_colorspace_set(Image_Entry* ie_dst, int cspace)
101{
102 RGBA_Image *dst = (RGBA_Image *) ie_dst;
103
104 switch (cspace)
105 {
106 case EVAS_COLORSPACE_ARGB8888:
107 if (dst->cs.data)
108 {
109 if (!dst->cs.no_free) free(dst->cs.data);
110 dst->cs.data = NULL;
111 dst->cs.no_free = 0;
112 }
113 break;
114 case EVAS_COLORSPACE_YCBCR422P601_PL:
115 case EVAS_COLORSPACE_YCBCR422P709_PL:
116 case EVAS_COLORSPACE_YCBCR422601_PL:
117 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
118 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
119 if (dst->image.no_free)
120 {
121 ie_dst->allocated.w = 0;
122 ie_dst->allocated.h = 0;
123#ifdef BUILD_ASYNC_PRELOAD
124 ie_dst->flags.preload_done = 0;
125#endif
126 ie_dst->flags.loaded = 0;
127 dst->image.data = NULL;
128 dst->image.no_free = 0;
129 /* FIXME: Must allocate image.data surface cleanly. */
130 }
131 if (dst->cs.data)
132 {
133 if (!dst->cs.no_free) free(dst->cs.data);
134 }
135 dst->cs.data = calloc(1, dst->cache_entry.h * sizeof(unsigned char *) * 2);
136 dst->cs.no_free = 0;
137 break;
138 default:
139 abort();
140 break;
141 }
142 dst->cache_entry.space = cspace;
143 evas_common_image_colorspace_dirty(dst);
144
145 _evas_common_rgba_image_post_surface(ie_dst);
146 return 0;
147}