Commit dd923e86 authored by dscho's avatar dscho

add convenience function to clip using x2,y2 instead of w,h

parent 9cc78e54
......@@ -803,6 +803,28 @@ sraClipRect(int *x, int *y, int *w, int *h,
return (*w>0) && (*h>0);
}
rfbBool
sraClipRect2(int *x, int *y, int *x2, int *y2,
int cx, int cy, int cx2, int cy2) {
if (*x < cx)
*x = cx;
if (*y < cy)
*y = cy;
if (*x >= cx2)
*x = cx2-1;
if (*y >= cy2)
*y = cy2-1;
if (*x2 <= cx)
*x2 = cx+1;
if (*y2 <= cy)
*y2 = cy+1;
if (*x2 > cx2)
*x2 = cx2;
if (*y2 > cy2)
*y2 = cy2;
return (*x2>*x) && (*y2>*y);
}
/* test */
#ifdef SRA_TEST
......
......@@ -59,4 +59,7 @@ void sraRgnPrint(const sraRegion *s);
extern rfbBool sraClipRect(int *x, int *y, int *w, int *h,
int cx, int cy, int cw, int ch);
extern rfbBool sraClipRect2(int *x, int *y, int *x2, int *y2,
int cx, int cy, int cx2, int cy2);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment