[Mesa-stable] [Mesa-dev] [PATCH v2] egl: Fix missing clamping in eglSetDamageRegionKHR
Dylan Baker
dylan at pnwbakers.com
Tue Jul 24 16:12:47 UTC 2018
Quoting Eric Engestrom (2018-07-24 07:55:03)
> On Tuesday, 2018-07-24 18:15:54 +0530, Harish Krupo wrote:
> > Hi Eric,
> >
> > Eric Engestrom <eric.engestrom at intel.com> writes:
> >
> > > On Sunday, 2018-07-08 12:53:00 +0530, Harish Krupo wrote:
> > >> Clamp the x and y co-ordinates of the rectangles.
> > >>
> > >> v2: Clamp width/height after converting to co-ordinates
> > >> (Ilia Merkin)
> > >>
> > >> Signed-off-by: Harish Krupo <harish.krupo.kps at intel.com>
> > >> ---
> > >> src/egl/main/eglapi.c | 25 +++++++++++--------------
> > >> 1 file changed, 11 insertions(+), 14 deletions(-)
> > >>
> > >> diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
> > >> index c110349119..deb479b6d5 100644
> > >> --- a/src/egl/main/eglapi.c
> > >> +++ b/src/egl/main/eglapi.c
> > >> @@ -1320,9 +1320,7 @@ eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface surface,
> > >> }
> > >>
> > >> /**
> > >> - * If the width of the passed rect is greater than the surface's
> > >> - * width then it is clamped to the width of the surface. Same with
> > >> - * height.
> > >> + * Clamp the rectangles so that they lie within the surface.
> > >> */
> > >>
> > >> static void
> > >> @@ -1334,17 +1332,16 @@ _eglSetDamageRegionKHRClampRects(_EGLDisplay* disp, _EGLSurface* surf,
> > >> EGLint surf_width = surf->Width;
> > >>
> > >> for (i = 0; i < (4 * n_rects); i += 4) {
> > >> - EGLint x, y, rect_width, rect_height;
> > >> - x = rects[i];
> > >> - y = rects[i + 1];
> > >> - rect_width = rects[i + 2];
> > >> - rect_height = rects[i + 3];
> > >> -
> > >> - if (rect_width > surf_width - x)
> > >> - rects[i + 2] = surf_width - x;
> > >> -
> > >> - if (rect_height > surf_height - y)
> > >> - rects[i + 3] = surf_height - y;
> > >> + EGLint x1, y1, x2, y2;
> > >> + x1 = rects[i];
> > >> + y1 = rects[i + 1];
> > >> + x2 = rects[i + 2] + x1;
> > >> + y2 = rects[i + 3] + y1;
> > >> +
> > >> + rects[i] = CLAMP(x1, 0, surf_width);
> > >> + rects[i + 1] = CLAMP(y1, 0, surf_height);
> > >> + rects[i + 2] = CLAMP(x2, 0, surf_width) - rects[i];
> > >> + rects[i + 3] = CLAMP(y2, 0, surf_height) - rects[i + 1];
> > >
> > > This looks correct to me:
> > > Reviewed-by: Eric Engestrom <eric.engestrom at intel.com>
> > >
> > > I ran it through our CI as well, looks all good, no regression;
> > > would you like one of us to push it for you?
> > >
> >
> > Thanks and yes please :)
>
> Done; pushed as fd734608c3c40a1a93c6 with everyone's r-b.
>
> I also just realised (after pushing, as usual) that I forgot to add:
> Fixes: 9827547313c7239486efb "egl/android: support for EGL_KHR_partial_update"
>
> I'm therefore nominating it for stable branches by cc'ing mesa-stable@
> (and Dylan and Andres, release managers of 18.1 and 18.2).
Pulled into staging/18.1, Thanks for CC'ing me directly, that's much easier than
cc'ing stable :)
Dylan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-stable/attachments/20180724/ed7ed1a7/attachment-0001.sig>
More information about the mesa-stable
mailing list