1 From: Chris Wilson <chris@chris-wilson.co.uk>
2 To: xorg-devel@lists.x.org
3 Subject: [PATCH 2/3] randr: Consider rotation of slaved crtcs when computing bounds
4 Date: Wed, 23 Jul 2014 12:35:14 +0100
6 When creating a pixmap to cover a rotated slaved CRTC, we need to
7 consider its rotated size as that is the area that it occupies in the
8 framebuffer. The slave is then responsible for mapping the copy of the
9 framebuffer onto the rotated scanout - which can be the usual RandR
10 shadow composite method.
12 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
13 Cc: Dave Airlie <airlied@redhat.com>
14 Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>
16 randr/rrcrtc.c | 56 ++++++++++++++++++++++++++++++++++++--------------------
17 1 file changed, 36 insertions(+), 20 deletions(-)
21 @@ -273,27 +273,43 @@ RRCrtcPendingProperties(RRCrtcPtr crtc)
26 -crtc_bounds(RRCrtcPtr crtc, int *left, int *right, int *top, int *bottom)
27 +static int mode_height(const RRModeRec *mode, Rotation rotation)
32 - switch (crtc->rotation) {
33 + switch (rotation & 0xf) {
36 + return mode->mode.height;
39 + return mode->mode.width;
41 - *right = crtc->x + crtc->mode->mode.width;
42 - *bottom = crtc->y + crtc->mode->mode.height;
48 +static int mode_width(const RRModeRec *mode, Rotation rotation)
50 + switch (rotation & 0xf) {
53 + return mode->mode.width;
56 - *right = crtc->x + crtc->mode->mode.height;
57 - *bottom = crtc->y + crtc->mode->mode.width;
59 + return mode->mode.height;
66 +crtc_bounds(RRCrtcPtr crtc, int *left, int *right, int *top, int *bottom)
70 + *right = crtc->x + mode_width(crtc->mode, crtc->rotation);
71 + *bottom = crtc->y + mode_height(crtc->mode, crtc->rotation);
74 /* overlapping counts as adjacent */
76 crtcs_adjacent(const RRCrtcPtr a, const RRCrtcPtr b)
77 @@ -466,9 +482,9 @@ rrCheckPixmapBounding(ScreenPtr pScreen,
78 if (!pScrPriv->crtcs[c]->mode)
80 newbox.x1 = pScrPriv->crtcs[c]->x;
81 - newbox.x2 = pScrPriv->crtcs[c]->x + pScrPriv->crtcs[c]->mode->mode.width;
82 + newbox.x2 = pScrPriv->crtcs[c]->x + mode_width(pScrPriv->crtcs[c]->mode, pScrPriv->crtcs[c]->rotation);
83 newbox.y1 = pScrPriv->crtcs[c]->y;
84 - newbox.y2 = pScrPriv->crtcs[c]->y + pScrPriv->crtcs[c]->mode->mode.height;
85 + newbox.y2 = pScrPriv->crtcs[c]->y + mode_height(pScrPriv->crtcs[c]->mode, pScrPriv->crtcs[c]->rotation);
87 RegionInit(&new_crtc_region, &newbox, 1);
88 RegionUnion(&total_region, &total_region, &new_crtc_region);
89 @@ -487,9 +503,9 @@ rrCheckPixmapBounding(ScreenPtr pScreen,
90 if (!pScrPriv->crtcs[c]->mode)
92 newbox.x1 = pScrPriv->crtcs[c]->x;
93 - newbox.x2 = pScrPriv->crtcs[c]->x + pScrPriv->crtcs[c]->mode->mode.width;
94 + newbox.x2 = pScrPriv->crtcs[c]->x + mode_width(pScrPriv->crtcs[c]->mode, pScrPriv->crtcs[c]->rotation);
95 newbox.y1 = pScrPriv->crtcs[c]->y;
96 - newbox.y2 = pScrPriv->crtcs[c]->y + pScrPriv->crtcs[c]->mode->mode.height;
97 + newbox.y2 = pScrPriv->crtcs[c]->y + mode_height(pScrPriv->crtcs[c]->mode, pScrPriv->crtcs[c]->rotation);
99 RegionInit(&new_crtc_region, &newbox, 1);
100 RegionUnion(&total_region, &total_region, &new_crtc_region);
101 @@ -544,8 +560,8 @@ RRCrtcSet(RRCrtcPtr crtc,
102 int width = 0, height = 0;
105 - width = mode->mode.width;
106 - height = mode->mode.height;
107 + width = mode_width(mode, rotation);
108 + height = mode_height(mode, rotation);
110 ErrorF("have a master to look out for\n");
111 ret = rrCheckPixmapBounding(master, crtc,
112 @@ -1672,8 +1688,8 @@ RRReplaceScanoutPixmap(DrawablePtr pDraw
114 if (crtc->mode && crtc->x == pDrawable->x &&
115 crtc->y == pDrawable->y &&
116 - crtc->mode->mode.width == pDrawable->width &&
117 - crtc->mode->mode.height == pDrawable->height)
118 + mode_width(crtc->mode, crtc->rotation) == pDrawable->width &&
119 + mode_height(crtc->mode, crtc->rotation) == pDrawable->height)
122 /* is the pixmap already set? */