[Mesa-dev] [PATCH mesa 4/4] egl/drm: clamp image to buffer size in swrast_{get_image, put_image2}
Eric Engestrom
eric.engestrom at imgtec.com
Wed Jul 19 14:05:32 UTC 2017
From: Mun Gwan-gyeong <elongbug at gmail.com>
It adds limits of the height and the width on the copy region.
Cc: Daniel Stone <daniel at fooishbar.org>
Signed-off-by: Mun Gwan-gyeong <elongbug at gmail.com>
[Eric: compare coordinates instead of bytes (Suggested by DanielS)]
Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
---
src/egl/drivers/dri2/platform_drm.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index a952aa5456..b3c2563c2e 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -530,6 +530,12 @@ swrast_put_image2(__DRIdrawable *driDrawable,
int x_bytes, width_bytes;
char *src, *dst;
+ if (height > dri2_surf->base.Height - y)
+ height = dri2_surf->base.Height - y;
+
+ if (width > dri2_surf->base.Width - x)
+ width = dri2_surf->base.Width - x;
+
if (op != __DRI_SWRAST_IMAGE_OP_DRAW &&
op != __DRI_SWRAST_IMAGE_OP_SWAP)
return;
@@ -579,6 +585,12 @@ swrast_get_image(__DRIdrawable *driDrawable,
int x_bytes, width_bytes;
char *src, *dst;
+ if (height > dri2_surf->base.Height - y)
+ height = dri2_surf->base.Height - y;
+
+ if (width > dri2_surf->base.Width - x)
+ width = dri2_surf->base.Width - x;
+
if (get_swrast_front_bo(dri2_surf) < 0)
return;
--
Cheers,
Eric
More information about the mesa-dev
mailing list