summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChunEon Park <chuneon.park@samsung.com>2013-02-23 21:45:10 +0900
committerChunEon Park <chuneon.park@samsung.com>2013-02-23 21:45:10 +0900
commit53fa4cd2d8603b8f9aa8e8597e0b73144b301181 (patch)
tree7a3089b74685b58d45d1860006284f4129e69d51
parent029d539a85306019608e27a611ace500b313dd71 (diff)
downloadefl-53fa4cd2d8603b8f9aa8e8597e0b73144b301181.tar.gz
evas/common - scale sample code refactoring. simpler and more effcient.
-rw-r--r--src/lib/evas/common/evas_scale_sample.c106
1 files changed, 56 insertions, 50 deletions
diff --git a/src/lib/evas/common/evas_scale_sample.c b/src/lib/evas/common/evas_scale_sample.c
index cec5b0f011..e0a82e5a1d 100644
--- a/src/lib/evas/common/evas_scale_sample.c
+++ b/src/lib/evas/common/evas_scale_sample.c
@@ -78,112 +78,118 @@ evas_common_scale_rgba_sample_draw(RGBA_Image *src, RGBA_Image *dst, int dst_cli
(dst_region_w <= 0) || (dst_region_h <= 0)) return;
src_w = src->cache_entry.w;
+ if (src_region_x >= src_w) return;
+
src_h = src->cache_entry.h;
+ if (src_region_y >= src_h) return;
+
dst_w = dst->cache_entry.w;
dst_h = dst->cache_entry.h;
src_data = src->image.data;
dst_data = dst->image.data;
+ /* sanitise clip x */
if (dst_clip_x < 0)
{
dst_clip_w += dst_clip_x;
dst_clip_x = 0;
}
- if (dst_clip_y < 0)
- {
- dst_clip_h += dst_clip_y;
- dst_clip_y = 0;
- }
+
if ((dst_clip_x + dst_clip_w) > dst_w)
dst_clip_w = dst_w - dst_clip_x;
- if ((dst_clip_y + dst_clip_h) > dst_h)
- dst_clip_h = dst_h - dst_clip_y;
if (dst_clip_x < dst_region_x)
{
dst_clip_w += dst_clip_x - dst_region_x;
dst_clip_x = dst_region_x;
}
+
+ if (dst_clip_x >= dst_w) return;
+
if ((dst_clip_x + dst_clip_w) > (dst_region_x + dst_region_w))
dst_clip_w = dst_region_x + dst_region_w - dst_clip_x;
+
+ if (dst_clip_w <= 0) return;
+
+ /* sanitise clip y */
+ if (dst_clip_y < 0)
+ {
+ dst_clip_h += dst_clip_y;
+ dst_clip_y = 0;
+ }
+
+ if ((dst_clip_y + dst_clip_h) > dst_h)
+ dst_clip_h = dst_h - dst_clip_y;
+
if (dst_clip_y < dst_region_y)
{
dst_clip_h += dst_clip_y - dst_region_y;
dst_clip_y = dst_region_y;
}
+
+ if (dst_clip_y >= dst_h) return;
+
if ((dst_clip_y + dst_clip_h) > (dst_region_y + dst_region_h))
dst_clip_h = dst_region_y + dst_region_h - dst_clip_y;
- if ((dst_clip_w <= 0) || (dst_clip_h <= 0)) return;
+ if (dst_clip_h <= 0) return;
- /* sanitise x */
+ /* sanitise region x */
if (src_region_x < 0)
{
dst_region_x -= (src_region_x * dst_region_w) / src_region_w;
dst_region_w += (src_region_x * dst_region_w) / src_region_w;
src_region_w += src_region_x;
src_region_x = 0;
+
+ if (dst_clip_x < dst_region_x)
+ {
+ dst_clip_w += (dst_clip_x - dst_region_x);
+ dst_clip_x = dst_region_x;
+ }
}
- if (src_region_x >= src_w) return;
+
+ if ((dst_clip_x + dst_clip_w) > dst_w)
+ dst_clip_w = dst_w - dst_clip_x;
+
+ if (dst_clip_w <= 0) return;
+
if ((src_region_x + src_region_w) > src_w)
{
dst_region_w = (dst_region_w * (src_w - src_region_x)) / (src_region_w);
src_region_w = src_w - src_region_x;
}
- if (dst_region_w <= 0) return;
- if (src_region_w <= 0) return;
- if (dst_clip_x < 0)
- {
- dst_clip_w += dst_clip_x;
- dst_clip_x = 0;
- }
- if (dst_clip_w <= 0) return;
- if (dst_clip_x >= dst_w) return;
- if (dst_clip_x < dst_region_x)
- {
- dst_clip_w += (dst_clip_x - dst_region_x);
- dst_clip_x = dst_region_x;
- }
- if ((dst_clip_x + dst_clip_w) > dst_w)
- {
- dst_clip_w = dst_w - dst_clip_x;
- }
- if (dst_clip_w <= 0) return;
- /* sanitise y */
+ if ((dst_region_w <= 0) || (src_region_w <= 0)) return;
+
+ /* sanitise region y */
if (src_region_y < 0)
{
dst_region_y -= (src_region_y * dst_region_h) / src_region_h;
dst_region_h += (src_region_y * dst_region_h) / src_region_h;
src_region_h += src_region_y;
src_region_y = 0;
+
+ if (dst_clip_y < dst_region_y)
+ {
+ dst_clip_h += (dst_clip_y - dst_region_y);
+ dst_clip_y = dst_region_y;
+ }
}
- if (src_region_y >= src_h) return;
+
+ if ((dst_clip_y + dst_clip_h) > dst_h)
+ dst_clip_h = dst_h - dst_clip_y;
+
+ if (dst_clip_h <= 0) return;
+
if ((src_region_y + src_region_h) > src_h)
{
dst_region_h = (dst_region_h * (src_h - src_region_y)) / (src_region_h);
src_region_h = src_h - src_region_y;
}
- if (dst_region_h <= 0) return;
- if (src_region_h <= 0) return;
- if (dst_clip_y < 0)
- {
- dst_clip_h += dst_clip_y;
- dst_clip_y = 0;
- }
- if (dst_clip_h <= 0) return;
- if (dst_clip_y >= dst_h) return;
- if (dst_clip_y < dst_region_y)
- {
- dst_clip_h += (dst_clip_y - dst_region_y);
- dst_clip_y = dst_region_y;
- }
- if ((dst_clip_y + dst_clip_h) > dst_h)
- {
- dst_clip_h = dst_h - dst_clip_y;
- }
- if (dst_clip_h <= 0) return;
+
+ if ((dst_region_h <= 0) || (src_region_h <= 0)) return;
/* allocate scale lookup tables */
lin_ptr = alloca(dst_clip_w * sizeof(int));