summaryrefslogtreecommitdiff
path: root/glamor
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2014-04-02 12:12:06 -0700
committerEric Anholt <eric@anholt.net>2014-07-17 17:34:26 -0700
commit1140a89d7762540965ff865d154cb0528049066f (patch)
tree703cffb8e47dae1381da7e3008c41dc58de19f79 /glamor
parent2ab0fba9df695f19f0b43321d01395736f865c69 (diff)
glamor: Use MIN/MAX macros to clean up glamor_transfer.c
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'glamor')
-rw-r--r--glamor/glamor_transfer.c45
1 files changed, 10 insertions, 35 deletions
diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c
index ad875c962..4eea902ad 100644
--- a/glamor/glamor_transfer.c
+++ b/glamor/glamor_transfer.c
@@ -90,27 +90,14 @@ glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
while (nbox--) {
/* compute drawable coordinates */
- int x1 = boxes->x1 + dx_dst;
- int x2 = boxes->x2 + dx_dst;
- int y1 = boxes->y1 + dy_dst;
- int y2 = boxes->y2 + dy_dst;
+ int x1 = MAX(boxes->x1 + dx_dst, box->x1);
+ int x2 = MIN(boxes->x2 + dx_dst, box->x2);
+ int y1 = MAX(boxes->y1 + dy_dst, box->y1);
+ int y2 = MIN(boxes->y2 + dy_dst, box->y2);
boxes++;
- if (x1 < box->x1)
- x1 = box->x1;
- if (box->x2 < x2)
- x2 = box->x2;
-
- if (x2 <= x1)
- continue;
-
- if (y1 < box->y1)
- y1 = box->y1;
- if (box->y2 < y2)
- y2 = box->y2;
-
- if (y2 <= y1)
+ if (x2 <= x1 || y2 <= y1)
continue;
glPixelStorei(GL_UNPACK_SKIP_ROWS, y1 - dy_dst + dy_src);
@@ -195,26 +182,14 @@ glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
while (nbox--) {
/* compute drawable coordinates */
- int x1 = boxes->x1 + dx_src;
- int x2 = boxes->x2 + dx_src;
- int y1 = boxes->y1 + dy_src;
- int y2 = boxes->y2 + dy_src;
+ int x1 = MAX(boxes->x1 + dx_src, box->x1);
+ int x2 = MIN(boxes->x2 + dx_src, box->x2);
+ int y1 = MAX(boxes->y1 + dy_src, box->y1);
+ int y2 = MIN(boxes->y2 + dy_src, box->y2);
boxes++;
- if (x1 < box->x1)
- x1 = box->x1;
- if (box->x2 < x2)
- x2 = box->x2;
-
- if (y1 < box->y1)
- y1 = box->y1;
- if (box->y2 < y2)
- y2 = box->y2;
-
- if (x2 <= x1)
- continue;
- if (y2 <= y1)
+ if (x2 <= x1 || y2 <= y1)
continue;
glPixelStorei(GL_PACK_SKIP_PIXELS, x1 - dx_src + dx_dst);