evas/scale_sample: fix mask geometry clamping in scale thread
authorMike Blumenkrantz <zmike@samsung.com>
Mon, 13 May 2019 15:44:18 +0000 (11:44 -0400)
committerJunsuChoi <jsuya.choi@samsung.com>
Thu, 30 May 2019 08:17:50 +0000 (17:17 +0900)
Summary:
the 'y' parameter is not relevant here. this clamping exists solely
to avoid reading outside the bounds of the mask, and 'y' is the scanline
at which to begin the masking

subtracting the mask size here does not make sense: we are attempting to clamp
to the size of the mask in order to avoid buffer over-read, so this means that
we are mapping the maximum y coordinate of the mask (mask_y + mask_h) to be
relative to the clipped y coordinate (dst_clip_y)

Depends on D8838

Reviewers: cedric, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: segfaultxavi, #reviewers, #committers

Tags: #efl_rendering

Differential Revision: https://phab.enlightenment.org/D8839

src/lib/evas/common/evas_scale_sample.c

index 139f032..6fc54de 100644 (file)
@@ -146,12 +146,12 @@ _evas_common_scale_rgba_sample_scale_mask(int y,
    /* clamp/map to mask geometry */
    if (EINA_UNLIKELY(dst_clip_x < mask_x))
      dst_clip_x = mask_x;
-   if (EINA_UNLIKELY(dst_clip_y + y < mask_y))
-     dst_clip_y = mask_y + y;
+   if (EINA_UNLIKELY(dst_clip_y < mask_y))
+     dst_clip_y = mask_y;
    if (EINA_UNLIKELY(dst_clip_x + dst_clip_w > mask_x + (int)mask_ie->cache_entry.w))
-     dst_clip_w = mask_x - mask_ie->cache_entry.w - dst_clip_x;
-   if (EINA_UNLIKELY(dst_clip_y + dst_clip_h + y > mask_y + (int)mask_ie->cache_entry.h))
-     dst_clip_h = mask_y + y - mask_ie->cache_entry.h - dst_clip_y;
+     dst_clip_w = mask_x + mask_ie->cache_entry.w - dst_clip_x;
+   if (EINA_UNLIKELY(dst_clip_y + dst_clip_h > mask_y + (int)mask_ie->cache_entry.h))
+     dst_clip_h = mask_y + mask_ie->cache_entry.h - dst_clip_y;
 
    dptr = dptr + dst_w * y;
    for (; y < dst_clip_h; y++)