~ubuntu-branches/ubuntu/precise/xorg-server/precise

« back to all changes in this revision

Viewing changes to hw/xfree86/modes/xf86Cursors.c

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2011-01-31 19:45:19 UTC
  • mfrom: (1.1.38 upstream) (0.1.19 experimental)
  • Revision ID: james.westby@ubuntu.com-20110131194519-fx30d1zsg83invba
Tags: 2:1.9.99.901+git20110131.be3be758-0ubuntu1
* Merge from (unreleased) debian-experimental.  Remaining Ubuntu changes:
  - rules:
    + Disable SELinux, libaudit-dev is not in main yet. (LP: #406226)
    + Enable xcsecurity. (LP: #247537)
    + Add --with-extra-module-dir to support GL alternatives.
  - control: 
    + Xvfb depends on xauth, x11-xkb-utils. (LP: #500102)
    + Add breaks for incompatible drivers. (LP: #614993)
    + Drop libaudit-dev from build-deps.
  - local/xvfb-run*: Add correct docs about error codes. (LP #328205)
  - debian/patches:
    + 100_rethrow_signals.patch:
      When aborting, re-raise signals for apport
    + 109_fix-swcursor-crash.patch:
      Avoid dereferencing null pointer while reloading cursors during
      resume. (LP: #371405)
    + 111_armel-drv-fallbacks.patch:
      Add support for armel driver fallbacks.
    + 121_only_switch_vt_when_active.diff:
      Add a check to prevent the X server from changing the VT when killing
      GDM from the console.
    + 122_xext_fix_card32_overflow_in_xauth.patch:
      Fix server crash when “xauth generate” is called with large timeout.
    + 157_check_null_modes.patch, 162_null_crtc_in_rotation.patch,
      166_nullptr_xinerama_keyrepeat.patch, 167_nullptr_xisbread.patch
      169_mipointer_nullptr_checks.patch,
      172_cwgetbackingpicture_nullptr_check.patch:
      Fix various segfaults in xserver by checking pointers for NULL
      values before dereferencing them.
    + 165_man_xorg_conf_no_device_ident.patch
      Correct man page
    + 168_glibc_trace_to_stderr.patch:
      Report abort traces to stderr instead of terminal
    + 184_virtual_devices_autodetect.patch:
      Use vesa for qemu device, which is not supported by cirrus
    + 188_default_primary_to_first_busid.patch:
      Pick the first device and carry on (LP: #459512)
    + 190_cache-xkbcomp_output_for_fast_start_up.patch:
    + 191-Xorg-add-an-extra-module-path.patch:
      Add support for the alternatives module path.
    + 198_nohwaccess.patch:
      Adds a -nohwaccess argument to make X not access the hardware
      ports directly.
    + 200_randr-null.patch:
      Clarify a pointer initialization.
    + 206_intel_8xx_default_to_fbdev.patch:
      Makes 8xx class intel GPUs default to fbdev for stability. (LP: #633593)
* Refresh 121_only_switch_vt_when_active.diff for new upstream.
* Drop 187_edid_quirk_hp_nc8430.patch; upstream.
* Drop 189_xserver_1.5.0_bg_none_root.patch; functionality now upstream.
* Refresh 190_cache-xkbcomp_output_for_fast_start_up.patch for new upstream.
* Drop 197_xvfb-randr.patch:
  - miRandR, which this used, has been removed from the server. 
* Drop 204_fix-neg-sync-transition.patch; upstream.
* Drop 207_dga_master_device.patch; upstream.
* Drop 208_switch_on_release.diff; upstream.
* debian/patches/209_add_legacy_bgnone_option.patch:
  - Add "-nr" as a synonym for "-background none" to ease the transition from
    the old 189_xserver_1.5.0_bg_none_root.patch patch.  Can be dropped once
    all the ?DM have been updated to use the new option.
* debian/control:
  - Add Breaks: to xserver-xorg-video-8 and current fglrx.  These proprietary
    drivers don't yet have appropriate dependency information, so manually
    handle them here to prevent broken upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Copyright © 2007 Keith Packard
 
3
 * Copyright © 2010 Aaron Plattner
3
4
 *
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
126
127
    *y_src = y_dst;
127
128
}
128
129
 
 
130
struct cursor_bit {
 
131
    CARD8 *byte;
 
132
    char bitpos;
 
133
};
 
134
 
129
135
/*
130
136
 * Convert an x coordinate to a position within the cursor bitmap
131
137
 */
132
 
static int
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,
 
140
               Bool mask)
134
141
{
 
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;
 
152
 
 
153
    struct cursor_bit ret;
 
154
 
 
155
    image += y * stride;
 
156
 
135
157
    if (flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK)
136
158
        mask = !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);
152
 
    return x;
 
174
    else if (mask)
 
175
        image += stride * height;
 
176
 
 
177
    ret.byte = image + (x / 8);
 
178
    ret.bitpos = x & 7;
 
179
 
 
180
    return ret;
153
181
}
154
182
 
155
183
/*
156
184
 * Fetch one bit from a cursor bitmap
157
185
 */
158
186
static CARD8
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)
160
188
{
161
 
    x = cursor_bitpos (flags, x, mask);
162
 
    image += y * stride;
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;
164
191
}
165
192
 
166
193
/*
167
194
 * Set one bit in a cursor bitmap
168
195
 */
169
196
static void
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)
171
198
{
172
 
    x = cursor_bitpos (flags, x, mask);
173
 
    image += y * stride;
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;
175
201
}
176
202
    
177
203
/*
186
212
    CARD32              *cursor_image = (CARD32 *) xf86_config->cursor_image;
187
213
    int                 x, y;
188
214
    int                 xin, yin;
189
 
    int                 stride = cursor_info->MaxWidth >> 2;
190
215
    int                 flags = cursor_info->Flags;
191
216
    CARD32              bits;
192
217
 
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))
206
231
            {
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;
209
234
                else
210
235
                    bits = xf86_config->cursor_bg;
227
252
    CursorPtr           cursor = xf86_config->cursor;
228
253
    int                 c;
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))
232
 
#else
233
 
        cursor->devPriv[screen->myNum]
234
 
#endif
235
256
      : NULL;
236
257
 
237
258
    /* Save ARGB versions of these colors */
317
338
    /*
318
339
     * Transform position of cursor on screen
319
340
     */
320
 
    if (crtc->transform_in_use)
 
341
    if (crtc->sprite_transform_in_use)
321
342
    {
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;
330
351
        v.v[2] = 1;
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]);
411
432
        int x, y;
412
433
        int xin, yin;
413
434
        int stride = cursor_info->MaxWidth >> 2;
414
 
        int flags = cursor_info->Flags;
415
435
        
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);
430
450
            }
431
451
    }
432
452
    crtc->funcs->load_cursor_image (crtc, cursor_image);
630
650
 
631
651
    if (cursor)
632
652
    {
633
 
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
634
653
        void *src = dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen));
635
 
#else
636
 
        void *src = cursor->devPriv[screen->myNum];
637
 
#endif
638
654
#ifdef ARGB_CURSOR
639
655
        if (cursor->bits->argb && cursor_info->LoadCursorARGB)
640
656
            (*cursor_info->LoadCursorARGB) (scrn, cursor);