[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
Tue Aug 1 17:42:03 UTC 2017


I have pushed 1-3.

DanielS, do we want this one too?

Emil, I just realized that 2 and 3 depend on 1, but 1 isn't nominated
for stable. I'll let you decide whether to pull all 3 in 17.2 or not.


On Wednesday, 2017-07-19 15:05:32 +0100, Eric Engestrom wrote:
> 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