summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-03-23 13:33:08 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-03-28 16:40:01 +0900
commitd5b0b1e683310d16855d2183f509b11c4c3b8971 (patch)
treea8db5af3d61b143616940a97a0644fb8d51087aa /src/lib/evas/common
parent078117d367afff6862b72bec8bbc29909b259fd4 (diff)
Evas: Add SW engine map/unmap functions
Also, fix some of the code using them.
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_image.h3
-rw-r--r--src/lib/evas/common/evas_image_main.c89
2 files changed, 90 insertions, 2 deletions
diff --git a/src/lib/evas/common/evas_image.h b/src/lib/evas/common/evas_image.h
index 917bfcd119..910af43ab5 100644
--- a/src/lib/evas/common/evas_image.h
+++ b/src/lib/evas/common/evas_image.h
@@ -76,7 +76,8 @@ EAPI int evas_common_load_rgba_image_data_from_file (Image_Entry *im);
76EAPI double evas_common_load_rgba_image_frame_duration_from_file(Image_Entry *im, int start_frame, int frame_num); 76EAPI double evas_common_load_rgba_image_frame_duration_from_file(Image_Entry *im, int start_frame, int frame_num);
77 77
78void _evas_common_rgba_image_post_surface(Image_Entry *ie); 78void _evas_common_rgba_image_post_surface(Image_Entry *ie);
79int _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);
80 81
81EAPI Eina_Bool evas_common_extension_can_load_get(const char *file); 82EAPI Eina_Bool evas_common_extension_can_load_get(const char *file);
82 83
diff --git a/src/lib/evas/common/evas_image_main.c b/src/lib/evas/common/evas_image_main.c
index 01db75ff25..1b0a7d5cc0 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}; 110};
111#endif 111#endif
112 112
113int 113EAPI int
114_evas_common_rgba_image_surface_size(unsigned int w, unsigned int h, 114_evas_common_rgba_image_surface_size(unsigned int w, unsigned int h,
115 Evas_Colorspace cspace, 115 Evas_Colorspace cspace,
116 /* inout */ int *l, int *r, int *t, int *b) 116 /* inout */ int *l, int *r, int *t, int *b)
@@ -179,6 +179,93 @@ _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h,
179#undef ALIGN_TO_PAGE 179#undef ALIGN_TO_PAGE
180} 180}
181 181
182EAPI int
183_evas_common_rgba_image_data_offset(int rx, int ry, int rw, int rh, int plane, const RGBA_Image *im)
184{
185 // note: no stride support
186
187 EINA_SAFETY_ON_NULL_RETURN_VAL(im, -1);
188
189 const Image_Entry *ie = &im->cache_entry;
190
191 if ((rx < 0) || (ry < 0) || (rw < 0) || (rh < 0))
192 return -1;
193
194 if (((rx + rw) > (int) ie->w) || ((ry + rh) > (int) ie->h))
195 return -1;
196
197 switch (ie->space)
198 {
199 case EVAS_COLORSPACE_ARGB8888:
200 return (ry * ie->w + rx) * 4;
201 case EVAS_COLORSPACE_AGRY88:
202 return (ry * ie->w + rx) * 2;
203 case EVAS_COLORSPACE_GRY8:
204 return ry * ie->w + rx;
205 case EVAS_COLORSPACE_RGB565_A5P:
206 if (plane == 0)
207 return (ry * ie->w + rx) * 2;
208 else if (plane == 1)
209 return ry * ie->w + rx + (ie->w * ie->h) * 2;
210 else return -1;
211
212 // YUV
213 case EVAS_COLORSPACE_YCBCR422P601_PL:
214 case EVAS_COLORSPACE_YCBCR422P709_PL:
215 case EVAS_COLORSPACE_YCBCR422601_PL:
216 if ((rx & 1) || (rw & 1))
217 return -1;
218 if (plane == 0)
219 return ry * ie->w + rx;
220 else if (plane == 1)
221 return (ry * ie->w) / 2 + rx + ie->w * ie->h;
222 else return -1;
223
224 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
225 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
226 if ((rx & 1) || (ry & 1) || (rw & 1) || (rh & 1))
227 return -1;
228 if (plane == 0)
229 return ry * ie->w + rx;
230 else if (plane == 1)
231 return (ry * ie->w + rx) / 2 + ie->w * ie->h;
232 else return -1;
233
234 // ETC1/2 RGB, S3TC RGB
235 case EVAS_COLORSPACE_ETC1:
236 case EVAS_COLORSPACE_RGB8_ETC2:
237 case EVAS_COLORSPACE_RGB_S3TC_DXT1:
238 if ((rx & 3) || (ry & 3) || (rw & 3) || (rh & 3))
239 return -1;
240 return (ry * ie->w + rx) * 8 / 16;
241
242 // ETC2 ARGB, S3TC ARGB
243 case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
244 case EVAS_COLORSPACE_RGBA_S3TC_DXT1:
245 case EVAS_COLORSPACE_RGBA_S3TC_DXT2:
246 case EVAS_COLORSPACE_RGBA_S3TC_DXT3:
247 case EVAS_COLORSPACE_RGBA_S3TC_DXT4:
248 case EVAS_COLORSPACE_RGBA_S3TC_DXT5:
249 if ((rx & 3) || (ry & 3) || (rw & 3) || (rh & 3))
250 return -1;
251 return (ry * ie->w + rx) * 16 / 16;
252
253 // ETC1+Alpha
254 case EVAS_COLORSPACE_ETC1_ALPHA:
255 if ((rx & 3) || (ry & 3) || (rw & 3) || (rh & 3))
256 return -1;
257 if (plane == 0)
258 return (ry * ie->w + rx) * 8 / 16;
259 else if (plane == 1)
260 return (ry * ie->w + rx) * 8 / 16 + (ie->w * ie->h) * 8 / 16;
261 else return -1;
262
263 default:
264 CRI("unknown colorspace %d", ie->space);
265 return EINA_FALSE;
266 }
267}
268
182static void * 269static void *
183_evas_common_rgba_image_surface_mmap(Image_Entry *ie, unsigned int w, unsigned int h, 270_evas_common_rgba_image_surface_mmap(Image_Entry *ie, unsigned int w, unsigned int h,
184 /* inout */ int *pl, int *pr, int *pt, int *pb) 271 /* inout */ int *pl, int *pr, int *pt, int *pb)