summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-09-02 17:55:33 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-09-06 16:54:54 +0900
commit2f737e8f3bb6705fa981bced09a5337db3ee2bcb (patch)
tree54e2244dd6be6e87e1d6c9bcb5c163fed467105c /src/lib/evas/common
parent69132b5c1ded800f7e1f51dc0c121f01cb8530e9 (diff)
evas: Change internal function image_data_direct
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_image.h1
-rw-r--r--src/lib/evas/common/evas_image_main.c155
2 files changed, 156 insertions, 0 deletions
diff --git a/src/lib/evas/common/evas_image.h b/src/lib/evas/common/evas_image.h
index 910af43ab5..e686ef7351 100644
--- a/src/lib/evas/common/evas_image.h
+++ b/src/lib/evas/common/evas_image.h
@@ -78,6 +78,7 @@ EAPI double evas_common_load_rgba_image_frame_duration_from_file(Image_Entry *im
78void _evas_common_rgba_image_post_surface(Image_Entry *ie); 78void _evas_common_rgba_image_post_surface(Image_Entry *ie);
79EAPI int _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h, Evas_Colorspace cspace, /* inout */ int *l, int *r, int *t, int *b); 79EAPI int _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h, Evas_Colorspace cspace, /* inout */ int *l, int *r, int *t, int *b);
80EAPI int _evas_common_rgba_image_data_offset(int rx, int ry, int rw, int rh, int plane, const RGBA_Image *im); 80EAPI int _evas_common_rgba_image_data_offset(int rx, int ry, int rw, int rh, int plane, const RGBA_Image *im);
81EAPI Eina_Bool _evas_common_rgba_image_plane_get(const RGBA_Image *im, int plane, Eina_Slice *slice);
81 82
82EAPI Eina_Bool evas_common_extension_can_load_get(const char *file); 83EAPI Eina_Bool evas_common_extension_can_load_get(const char *file);
83 84
diff --git a/src/lib/evas/common/evas_image_main.c b/src/lib/evas/common/evas_image_main.c
index b0023c399c..df2e5e27eb 100644
--- a/src/lib/evas/common/evas_image_main.c
+++ b/src/lib/evas/common/evas_image_main.c
@@ -181,6 +181,161 @@ _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h,
181#undef ALIGN_TO_PAGE 181#undef ALIGN_TO_PAGE
182} 182}
183 183
184EAPI Eina_Bool
185_evas_common_rgba_image_plane_get(const RGBA_Image *im, int plane, Eina_Slice *slice)
186{
187 unsigned char **csdata;
188 Evas_Colorspace cs;
189 int w, h;
190
191 if (!im || !slice) return EINA_FALSE;
192 cs = im->cache_entry.space;
193 w = im->cache_entry.w;
194 h = im->cache_entry.h;
195
196 switch (cs)
197 {
198 case EVAS_COLORSPACE_YCBCR422P601_PL:
199 case EVAS_COLORSPACE_YCBCR422P709_PL:
200 case EVAS_COLORSPACE_YCBCR422601_PL:
201 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
202 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
203 if (!im->cs.data)
204 return EINA_FALSE;
205 csdata = im->cs.data;
206 break;
207
208 default:
209 if (!im->image.data)
210 return EINA_FALSE;
211 break;
212 }
213
214 switch (cs)
215 {
216 case EVAS_COLORSPACE_ARGB8888:
217 if (plane != 0) return EINA_FALSE;
218 slice->len = w * h * 4;
219 slice->mem = im->image.data;
220 return EINA_TRUE;
221
222 case EVAS_COLORSPACE_AGRY88:
223 if (plane != 0) return EINA_FALSE;
224 slice->len = w * h * 2;
225 slice->mem = im->image.data;
226 return EINA_TRUE;
227
228 case EVAS_COLORSPACE_GRY8:
229 if (plane != 0) return EINA_FALSE;
230 slice->len = w * h;
231 slice->mem = im->image.data;
232 return EINA_TRUE;
233
234 case EVAS_COLORSPACE_RGB565_A5P:
235 if (plane == 0)
236 {
237 slice->mem = im->image.data;
238 slice->len = w * h * 2;
239 return EINA_TRUE;
240 }
241 else if (plane == 1)
242 {
243 slice->mem = im->image.data8 + (w * h * 2);
244 slice->len = w * h;
245 return EINA_TRUE;
246 }
247 return EINA_FALSE;
248
249 // YUV, assume contiguous memory within a plane (and no padding)
250 // single interleaved plane
251 case EVAS_COLORSPACE_YCBCR422601_PL:
252 if (plane != 0) return EINA_FALSE;
253 slice->mem = csdata[0];
254 slice->len = (w * h * 3) / 2;
255 return EINA_TRUE;
256
257 // 2 planes
258 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
259 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
260 if (plane == 0)
261 {
262 slice->mem = csdata[0];
263 slice->len = w * h;
264 return EINA_TRUE;
265 }
266 else if (plane == 1)
267 {
268 slice->mem = csdata[h];
269 slice->len = w * h / 4;
270 return EINA_TRUE;
271 }
272 return EINA_FALSE;
273
274 // 3 planes
275 case EVAS_COLORSPACE_YCBCR422P601_PL:
276 case EVAS_COLORSPACE_YCBCR422P709_PL:
277 if (plane == 0)
278 {
279 slice->mem = csdata[0];
280 slice->len = w * h;
281 return EINA_TRUE;
282 }
283 else if (plane == 1)
284 {
285 slice->mem = csdata[h];
286 slice->len = w * h / 4;
287 return EINA_TRUE;
288 }
289 else if (plane == 2)
290 {
291 slice->mem = csdata[2 * h];
292 slice->len = w * h / 4;
293 return EINA_TRUE;
294 }
295 return EINA_FALSE;
296
297 // ETC1/2 RGB, S3TC RGB
298 case EVAS_COLORSPACE_ETC1:
299 case EVAS_COLORSPACE_RGB8_ETC2:
300 case EVAS_COLORSPACE_RGB_S3TC_DXT1:
301 if (plane != 0) return EINA_FALSE;
302 slice->mem = im->image.data;
303 slice->len = (w * h * 8) / 16;
304 return EINA_TRUE;
305
306 // ETC2 ARGB, S3TC ARGB
307 case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
308 case EVAS_COLORSPACE_RGBA_S3TC_DXT1:
309 case EVAS_COLORSPACE_RGBA_S3TC_DXT2:
310 case EVAS_COLORSPACE_RGBA_S3TC_DXT3:
311 case EVAS_COLORSPACE_RGBA_S3TC_DXT4:
312 case EVAS_COLORSPACE_RGBA_S3TC_DXT5:
313 if (plane != 0) return EINA_FALSE;
314 slice->mem = im->image.data;
315 slice->len = (w * h * 16) / 16;
316 return EINA_TRUE;
317
318 // ETC1+Alpha
319 case EVAS_COLORSPACE_ETC1_ALPHA:
320 if (plane == 0)
321 {
322 slice->mem = im->image.data;
323 slice->len = (w * h * 8) / 16;
324 return EINA_TRUE;
325 }
326 else if (plane == 1)
327 {
328 slice->mem = im->image.data8 + (w * h * 8) / 16;
329 slice->len = (w * h * 8) / 16;
330 return EINA_TRUE;
331 }
332 return EINA_FALSE;
333
334 default:
335 return EINA_FALSE;
336 }
337}
338
184EAPI int 339EAPI int
185_evas_common_rgba_image_data_offset(int rx, int ry, int rw, int rh, int plane, const RGBA_Image *im) 340_evas_common_rgba_image_data_offset(int rx, int ry, int rw, int rh, int plane, const RGBA_Image *im)
186{ 341{