[glsdk/xserver.git] / debian / patches / 1001-xfree86-modes-Let-the-driver-handle-the-transform.patch
1 From 245cb8e94fd15990e1b7d6622added460f104dba Mon Sep 17 00:00:00 2001
2 From: Aaron Plattner <aplattner@nvidia.com>
3 Date: Thu, 25 Aug 2011 10:19:48 -0700
4 Subject: [PATCH 1/2] xfree86/modes: Let the driver handle the transform
6 If a driver can use hardware to handle the crtc transform, then
7 there's no need for the server's shadow layer to do it. Add a crtc
8 flag that lets the driver indicate that it is handling the transform.
9 If it's set, consider the transformed size of the screen but don't
10 actually enable the shadow layer. Also stop adjusting the cursor
11 image and position.
13 Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
14 ---
15 hw/xfree86/modes/xf86Crtc.h | 16 +++++-
16 hw/xfree86/modes/xf86Cursors.c | 31 +++++++---
17 hw/xfree86/modes/xf86Rotate.c | 131 +++++++++++++++++++++-------------------
18 3 files changed, 107 insertions(+), 71 deletions(-)
20 diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
21 index 68a968c..0d7a6a6 100644
22 --- a/hw/xfree86/modes/xf86Crtc.h
23 +++ b/hw/xfree86/modes/xf86Crtc.h
24 @@ -1,5 +1,6 @@
25 /*
26 * Copyright © 2006 Keith Packard
27 + * Copyright © 2011 Aaron Plattner
28 *
29 * Permission to use, copy, modify, distribute, and sell this software and its
30 * documentation for any purpose is hereby granted without fee, provided that
31 @@ -223,7 +224,7 @@ typedef struct _xf86CrtcFuncs {
33 } xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
35 -#define XF86_CRTC_VERSION 3
36 +#define XF86_CRTC_VERSION 4
38 struct _xf86Crtc {
39 /**
40 @@ -361,6 +362,19 @@ struct _xf86Crtc {
41 * Clear the shadow
42 */
43 Bool shadowClear;
44 +
45 + /**
46 + * Indicates that the driver is handling the transform, so the shadow
47 + * surface should be disabled. The driver writes this field before calling
48 + * xf86CrtcRotate to indicate that it is handling the transform (including
49 + * rotation and reflection).
50 + *
51 + * Setting this flag also causes the server to stop adjusting the cursor
52 + * image and position.
53 + *
54 + * Added in ABI version 4
55 + */
56 + Bool driverIsPerformingTransform;
57 };
59 typedef struct _xf86OutputFuncs {
60 diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
61 index 23c48eb..02dea5c 100644
62 --- a/hw/xfree86/modes/xf86Cursors.c
63 +++ b/hw/xfree86/modes/xf86Cursors.c
64 @@ -1,6 +1,6 @@
65 /*
66 * Copyright © 2007 Keith Packard
67 - * Copyright © 2010 Aaron Plattner
68 + * Copyright © 2010-2011 Aaron Plattner
69 *
70 * Permission to use, copy, modify, distribute, and sell this software and its
71 * documentation for any purpose is hereby granted without fee, provided that
72 @@ -47,6 +47,18 @@
73 #include "inputstr.h"
75 /*
76 + * Returns the rotation being performed by the server. If the driver indicates
77 + * that it's handling the screen transform, then this returns RR_Rotate_0.
78 + */
79 +static Rotation
80 +xf86_crtc_cursor_rotation (xf86CrtcPtr crtc)
81 +{
82 + if (crtc->driverIsPerformingTransform)
83 + return RR_Rotate_0;
84 + return crtc->rotation;
85 +}
86 +
87 +/*
88 * Given a screen coordinate, rotate back to a cursor source coordinate
89 */
90 static void
91 @@ -214,6 +226,7 @@ xf86_crtc_convert_cursor_to_argb (xf86CrtcPtr crtc, unsigned char *src)
92 int xin, yin;
93 int flags = cursor_info->Flags;
94 CARD32 bits;
95 + const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
97 #ifdef ARGB_CURSOR
98 crtc->cursor_argb = FALSE;
99 @@ -222,7 +235,7 @@ xf86_crtc_convert_cursor_to_argb (xf86CrtcPtr crtc, unsigned char *src)
100 for (y = 0; y < cursor_info->MaxHeight; y++)
101 for (x = 0; x < cursor_info->MaxWidth; x++)
102 {
103 - xf86_crtc_rotate_coord (crtc->rotation,
104 + xf86_crtc_rotate_coord (rotation,
105 cursor_info->MaxWidth,
106 cursor_info->MaxHeight,
107 x, y, &xin, &yin);
108 @@ -338,7 +351,7 @@ xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
109 /*
110 * Transform position of cursor on screen
111 */
112 - if (crtc->transform_in_use)
113 + if (crtc->transform_in_use && !crtc->driverIsPerformingTransform)
114 {
115 ScreenPtr screen = scrn->pScreen;
116 xf86CursorScreenPtr ScreenPriv =
117 @@ -420,12 +433,13 @@ xf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src)
118 xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
119 xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
120 CARD8 *cursor_image;
121 + const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
123 #ifdef ARGB_CURSOR
124 crtc->cursor_argb = FALSE;
125 #endif
127 - if (crtc->rotation == RR_Rotate_0)
128 + if (rotation == RR_Rotate_0)
129 cursor_image = src;
130 else
131 {
132 @@ -439,7 +453,7 @@ xf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src)
133 for (y = 0; y < cursor_info->MaxHeight; y++)
134 for (x = 0; x < cursor_info->MaxWidth; x++)
135 {
136 - xf86_crtc_rotate_coord (crtc->rotation,
137 + xf86_crtc_rotate_coord (rotation,
138 cursor_info->MaxWidth,
139 cursor_info->MaxHeight,
140 x, y, &xin, &yin);
141 @@ -532,12 +546,13 @@ xf86_crtc_load_cursor_argb (xf86CrtcPtr crtc, CursorPtr cursor)
142 int source_height = cursor->bits->height;
143 int image_width = cursor_info->MaxWidth;
144 int image_height = cursor_info->MaxHeight;
145 -
146 + const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
147 +
148 for (y = 0; y < image_height; y++)
149 for (x = 0; x < image_width; x++)
150 {
151 - xf86_crtc_rotate_coord (crtc->rotation, image_width, image_height,
152 - x, y, &xin, &yin);
153 + xf86_crtc_rotate_coord (rotation, image_width, image_height, x, y,
154 + &xin, &yin);
155 if (xin < source_width && yin < source_height)
156 bits = cursor_source[yin * source_width + xin];
157 else
158 diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
159 index 57c3499..45aabf0 100644
160 --- a/hw/xfree86/modes/xf86Rotate.c
161 +++ b/hw/xfree86/modes/xf86Rotate.c
162 @@ -1,5 +1,6 @@
163 /*
164 * Copyright © 2006 Keith Packard
165 + * Copyright © 2011 Aaron Plattner
166 *
167 * Permission to use, copy, modify, distribute, and sell this software and its
168 * documentation for any purpose is hereby granted without fee, provided that
169 @@ -84,7 +85,10 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
170 int n = RegionNumRects(region);
171 BoxPtr b = RegionRects(region);
172 XID include_inferiors = IncludeInferiors;
173 -
174 +
175 + if (crtc->driverIsPerformingTransform)
176 + return;
177 +
178 src = CreatePicture (None,
179 &root->drawable,
180 format,
181 @@ -290,7 +294,7 @@ xf86RotateDestroy (xf86CrtcPtr crtc)
182 }
184 for (c = 0; c < xf86_config->num_crtc; c++)
185 - if (xf86_config->crtc[c]->transform_in_use)
186 + if (xf86_config->crtc[c]->rotatedData)
187 return;
189 /*
190 @@ -414,52 +418,73 @@ xf86CrtcRotate (xf86CrtcPtr crtc)
191 }
192 else
193 {
194 - /*
195 - * these are the size of the shadow pixmap, which
196 - * matches the mode, not the pre-rotated copy in the
197 - * frame buffer
198 - */
199 - int width = crtc->mode.HDisplay;
200 - int height = crtc->mode.VDisplay;
201 - void *shadowData = crtc->rotatedData;
202 - PixmapPtr shadow = crtc->rotatedPixmap;
203 - int old_width = shadow ? shadow->drawable.width : 0;
204 - int old_height = shadow ? shadow->drawable.height : 0;
205 -
206 - /* Allocate memory for rotation */
207 - if (old_width != width || old_height != height)
208 - {
209 - if (shadow || shadowData)
210 + if (crtc->driverIsPerformingTransform) {
211 + xf86RotateDestroy(crtc);
212 + } else {
213 + /*
214 + * these are the size of the shadow pixmap, which
215 + * matches the mode, not the pre-rotated copy in the
216 + * frame buffer
217 + */
218 + int width = crtc->mode.HDisplay;
219 + int height = crtc->mode.VDisplay;
220 + void *shadowData = crtc->rotatedData;
221 + PixmapPtr shadow = crtc->rotatedPixmap;
222 + int old_width = shadow ? shadow->drawable.width : 0;
223 + int old_height = shadow ? shadow->drawable.height : 0;
224 +
225 + /* Allocate memory for rotation */
226 + if (old_width != width || old_height != height)
227 {
228 - crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
229 - crtc->rotatedPixmap = NULL;
230 - crtc->rotatedData = NULL;
231 + if (shadow || shadowData)
232 + {
233 + crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
234 + crtc->rotatedPixmap = NULL;
235 + crtc->rotatedData = NULL;
236 + }
237 + shadowData = crtc->funcs->shadow_allocate (crtc, width, height);
238 + if (!shadowData)
239 + goto bail1;
240 + crtc->rotatedData = shadowData;
241 + /* shadow will be damaged in xf86RotatePrepare */
242 + }
243 + else
244 + {
245 + /* mark shadowed area as damaged so it will be repainted */
246 + damage = TRUE;
247 }
248 - shadowData = crtc->funcs->shadow_allocate (crtc, width, height);
249 - if (!shadowData)
250 - goto bail1;
251 - crtc->rotatedData = shadowData;
252 - /* shadow will be damaged in xf86RotatePrepare */
253 - }
254 - else
255 - {
256 - /* mark shadowed area as damaged so it will be repainted */
257 - damage = TRUE;
258 - }
260 - if (!xf86_config->rotation_damage)
261 - {
262 - /* Create damage structure */
263 - xf86_config->rotation_damage = DamageCreate (NULL, NULL,
264 - DamageReportNone,
265 - TRUE, pScreen, pScreen);
266 if (!xf86_config->rotation_damage)
267 - goto bail2;
268 -
269 - /* Wrap block handler */
270 - if (!xf86_config->BlockHandler) {
271 - xf86_config->BlockHandler = pScreen->BlockHandler;
272 - pScreen->BlockHandler = xf86RotateBlockHandler;
273 + {
274 + /* Create damage structure */
275 + xf86_config->rotation_damage = DamageCreate (NULL, NULL,
276 + DamageReportNone,
277 + TRUE, pScreen, pScreen);
278 + if (!xf86_config->rotation_damage)
279 + goto bail2;
280 +
281 + /* Wrap block handler */
282 + if (!xf86_config->BlockHandler) {
283 + xf86_config->BlockHandler = pScreen->BlockHandler;
284 + pScreen->BlockHandler = xf86RotateBlockHandler;
285 + }
286 + }
287 +
288 + if (0)
289 + {
290 + bail2:
291 + if (shadow || shadowData)
292 + {
293 + crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
294 + crtc->rotatedPixmap = NULL;
295 + crtc->rotatedData = NULL;
296 + }
297 + bail1:
298 + if (old_width && old_height)
299 + crtc->rotatedPixmap =
300 + crtc->funcs->shadow_create (crtc, NULL, old_width,
301 + old_height);
302 + return FALSE;
303 }
304 }
305 #ifdef RANDR_12_INTERFACE
306 @@ -482,24 +507,6 @@ xf86CrtcRotate (xf86CrtcPtr crtc)
307 }
308 }
309 #endif
310 -
311 - if (0)
312 - {
313 - bail2:
314 - if (shadow || shadowData)
315 - {
316 - crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
317 - crtc->rotatedPixmap = NULL;
318 - crtc->rotatedData = NULL;
319 - }
320 - bail1:
321 - if (old_width && old_height)
322 - crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc,
323 - NULL,
324 - old_width,
325 - old_height);
326 - return FALSE;
327 - }
328 crtc->transform_in_use = TRUE;
329 }
330 crtc->crtc_to_framebuffer = crtc_to_fb;
331 --
332 1.7.4.1