xf86-video-ati/U_17-Factor-out-transform_region-helper.patch
Max Staudt 84a4590c79 Accepting request 438260 from home:mstaudt:branches:X11:XOrg
- U_01-* ... U_20-* :
  Include patches that haven't made it into the 7.7.1 release.

  This means almost all commits between xf86-video-ati-7.7.0
  and 12d30eeb9711bd2b1609d6bbb74c4a1760596f72.

  Fixes (bsc#990066).

OBS-URL: https://build.opensuse.org/request/show/438260
OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/xf86-video-ati?expand=0&rev=51
2016-11-02 10:39:34 +00:00

108 lines
3.0 KiB
Diff

From: Michel Dänzer <michel.daenzer@amd.com>
Date: Thu Sep 1 17:19:27 2016 +0900
Subject: [PATCH 17/20]Factor out transform_region helper
Patch-mainline: Upstream
Git-repo: git://anongit.freedesktop.org/xorg/driver/xf86-video-ati
Git-commit: 5a57005178fc13b6f7e513458ca6dae72a3e5783
References: bsc#990066
Signed-off-by: Max Staudt <mstaudt@suse.de>
While we're at it, fix leaking the memory allocated for xRectangles.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
src/radeon_kms.c | 73 +++++++++++++++++++++++++++++++++-----------------------
1 file changed, 43 insertions(+), 30 deletions(-)
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 711e84a..7173b77 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -382,6 +382,45 @@ static Bool RADEONCreateScreenResources_KMS(ScreenPtr pScreen)
}
#ifdef RADEON_PIXMAP_SHARING
+
+static RegionPtr
+transform_region(RegionPtr region, struct pict_f_transform *transform,
+ int w, int h)
+{
+ BoxPtr boxes = RegionRects(region);
+ int nboxes = RegionNumRects(region);
+ xRectanglePtr rects = malloc(nboxes * sizeof(*rects));
+ RegionPtr transformed;
+ int nrects = 0;
+ BoxRec box;
+ int i;
+
+ for (i = 0; i < nboxes; i++) {
+ box.x1 = boxes[i].x1;
+ box.x2 = boxes[i].x2;
+ box.y1 = boxes[i].y1;
+ box.y2 = boxes[i].y2;
+ pixman_f_transform_bounds(transform, &box);
+
+ box.x1 = max(box.x1, 0);
+ box.y1 = max(box.y1, 0);
+ box.x2 = min(box.x2, w);
+ box.y2 = min(box.y2, h);
+ if (box.x1 >= box.x2 || box.y1 >= box.y2)
+ continue;
+
+ rects[nrects].x = box.x1;
+ rects[nrects].y = box.y1;
+ rects[nrects].width = box.x2 - box.x1;
+ rects[nrects].height = box.y2 - box.y1;
+ nrects++;
+ }
+
+ transformed = RegionFromRects(nrects, rects, CT_UNSORTED);
+ free(rects);
+ return transformed;
+}
+
static RegionPtr
dirty_region(PixmapDirtyUpdatePtr dirty)
{
@@ -390,36 +429,10 @@ dirty_region(PixmapDirtyUpdatePtr dirty)
#ifdef HAS_DIRTYTRACKING_ROTATION
if (dirty->rotation != RR_Rotate_0) {
- BoxPtr boxes = RegionRects(damageregion);
- int nboxes = RegionNumRects(damageregion);
- xRectanglePtr rects = malloc(nboxes * sizeof(*rects));
- int dst_w = dirty->slave_dst->drawable.width;
- int dst_h = dirty->slave_dst->drawable.height;
- int nrects = 0;
- BoxRec box;
- int i;
-
- for (i = 0; i < nboxes; i++) {
- box.x1 = boxes[i].x1;
- box.x2 = boxes[i].x2;
- box.y1 = boxes[i].y1;
- box.y2 = boxes[i].y2;
- pixman_f_transform_bounds(&dirty->f_inverse, &box);
-
- box.x1 = max(box.x1, 0);
- box.y1 = max(box.y1, 0);
- box.x2 = min(box.x2, dst_w);
- box.y2 = min(box.y2, dst_h);
- if (box.x1 >= box.x2 || box.y1 >= box.y2)
- continue;
-
- rects[nrects].x = box.x1;
- rects[nrects].y = box.y1;
- rects[nrects].width = box.x2 - box.x1;
- rects[nrects].height = box.y2 - box.y1;
- nrects++;
- }
- dstregion = RegionFromRects(nrects, rects, CT_UNSORTED);
+ dstregion = transform_region(damageregion,
+ &dirty->f_inverse,
+ dirty->slave_dst->drawable.width,
+ dirty->slave_dst->drawable.height);
} else
#endif
{