2
2
* Copyright © 2007 Keith Packard
3
* Copyright © 2010 Aaron Plattner
4
5
* Permission to use, copy, modify, distribute, and sell this software and its
5
6
* documentation for any purpose is hereby granted without fee, provided that
130
136
* Convert an x coordinate to a position within the cursor bitmap
133
cursor_bitpos (int flags, int x, Bool mask)
138
static struct cursor_bit
139
cursor_bitpos (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y,
142
const int flags = cursor_info->Flags;
143
const Bool interleaved =
144
!!(flags & (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
145
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 |
146
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 |
147
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 |
148
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64));
149
const int width = cursor_info->MaxWidth;
150
const int height = cursor_info->MaxHeight;
151
const int stride = interleaved ? width / 4 : width / 8;
153
struct cursor_bit ret;
135
157
if (flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK)
137
159
if (flags & HARDWARE_CURSOR_NIBBLE_SWAPPED)
149
171
x = ((x & ~31) << 1) | (mask << 5) | (x & 31);
150
172
else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64)
151
173
x = ((x & ~63) << 1) | (mask << 6) | (x & 63);
175
image += stride * height;
177
ret.byte = image + (x / 8);
156
184
* Fetch one bit from a cursor bitmap
159
get_bit (CARD8 *image, int stride, int flags, int x, int y, Bool mask)
187
get_bit (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
161
x = cursor_bitpos (flags, x, mask);
163
return (image[(x >> 3)] >> (x & 7)) & 1;
189
struct cursor_bit bit = cursor_bitpos(image, cursor_info, x, y, mask);
190
return (*bit.byte >> bit.bitpos) & 1;
167
194
* Set one bit in a cursor bitmap
170
set_bit (CARD8 *image, int stride, int flags, int x, int y, Bool mask)
197
set_bit (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
172
x = cursor_bitpos (flags, x, mask);
174
image[(x >> 3)] |= 1 << (x & 7);
199
struct cursor_bit bit = cursor_bitpos(image, cursor_info, x, y, mask);
200
*bit.byte |= 1 << bit.bitpos;
201
226
cursor_info->MaxWidth,
202
227
cursor_info->MaxHeight,
203
228
x, y, &xin, &yin);
204
if (get_bit (src, stride, flags, xin, yin, TRUE) ==
229
if (get_bit (src, cursor_info, xin, yin, TRUE) ==
205
230
((flags & HARDWARE_CURSOR_INVERT_MASK) == 0))
207
if (get_bit (src, stride, flags, xin, yin, FALSE))
232
if (get_bit (src, cursor_info, xin, yin, FALSE))
208
233
bits = xf86_config->cursor_fg;
210
235
bits = xf86_config->cursor_bg;
227
252
CursorPtr cursor = xf86_config->cursor;
229
254
CARD8 *bits = cursor ?
230
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
231
255
dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen))
233
cursor->devPriv[screen->myNum]
237
258
/* Save ARGB versions of these colors */
318
339
* Transform position of cursor on screen
320
if (crtc->transform_in_use)
341
if (crtc->sprite_transform_in_use)
322
343
ScreenPtr screen = scrn->pScreen;
323
344
xf86CursorScreenPtr ScreenPriv =
328
349
v.v[0] = (x + ScreenPriv->HotX) + 0.5;
329
350
v.v[1] = (y + ScreenPriv->HotY) + 0.5;
331
pixman_f_transform_point (&crtc->f_framebuffer_to_crtc, &v);
352
pixman_f_transform_point (&crtc->f_screen_to_crtc, &v);
332
353
/* cursor will have 0.5 added to it already so floor is sufficent */
333
354
x = floor (v.v[0]);
334
355
y = floor (v.v[1]);
413
434
int stride = cursor_info->MaxWidth >> 2;
414
int flags = cursor_info->Flags;
416
436
cursor_image = xf86_config->cursor_image;
417
437
memset(cursor_image, 0, cursor_info->MaxHeight * stride);
423
443
cursor_info->MaxWidth,
424
444
cursor_info->MaxHeight,
425
445
x, y, &xin, &yin);
426
if (get_bit(src, stride, flags, xin, yin, FALSE))
427
set_bit(cursor_image, stride, flags, x, y, FALSE);
428
if (get_bit(src, stride, flags, xin, yin, TRUE))
429
set_bit(cursor_image, stride, flags, x, y, TRUE);
446
if (get_bit(src, cursor_info, xin, yin, FALSE))
447
set_bit(cursor_image, cursor_info, x, y, FALSE);
448
if (get_bit(src, cursor_info, xin, yin, TRUE))
449
set_bit(cursor_image, cursor_info, x, y, TRUE);
432
452
crtc->funcs->load_cursor_image (crtc, cursor_image);
633
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
634
653
void *src = dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen));
636
void *src = cursor->devPriv[screen->myNum];
638
654
#ifdef ARGB_CURSOR
639
655
if (cursor->bits->argb && cursor_info->LoadCursorARGB)
640
656
(*cursor_info->LoadCursorARGB) (scrn, cursor);