diff options
author | Keith Packard <keithp@keithp.com> | 2010-09-23 15:30:37 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2010-09-23 15:30:37 -0700 |
commit | 98197d931b266674557b52b4a7099c6470114e55 (patch) | |
tree | 501317433e6409e5e1b90feeadf040d59976c00d | |
parent | 01ad3725a8d0a8958720b81d19598a08c072ccee (diff) | |
parent | 402942cdbc518395a2943fd226b9f3071f24d39f (diff) |
Merge remote branch 'jamey/for-keith'
-rw-r--r-- | dix/privates.c | 33 | ||||
-rw-r--r-- | doc/xml/Xserver-spec.xml | 12 | ||||
-rw-r--r-- | hw/xfree86/modes/xf86Cursors.c | 8 | ||||
-rw-r--r-- | hw/xfree86/modes/xf86EdidModes.c | 4 | ||||
-rw-r--r-- | hw/xfree86/modes/xf86Modes.c | 14 | ||||
-rw-r--r-- | hw/xfree86/modes/xf86RandR12.c | 36 | ||||
-rw-r--r-- | include/privates.h | 51 | ||||
-rw-r--r-- | mi/midispcur.c | 42 |
8 files changed, 85 insertions, 115 deletions
diff --git a/dix/privates.c b/dix/privates.c index 17e1050d9..687fa7aa0 100644 --- a/dix/privates.c +++ b/dix/privates.c @@ -237,28 +237,35 @@ dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size) return TRUE; } -/* - * Allocate a new private key. - * - * This manages the storage of the key object itself, freeing it when the - * privates system is restarted at server reset time. All other keys - * are expected to be statically allocated as the privates must be - * reset after all objects have been freed - */ -DevPrivateKey -dixCreatePrivateKey(DevPrivateType type, unsigned size) +Bool +dixRegisterScreenPrivateKey(DevScreenPrivateKey screenKey, ScreenPtr pScreen, DevPrivateType type, unsigned size) { DevPrivateKey key; + if (!dixRegisterPrivateKey(&screenKey->screenKey, PRIVATE_SCREEN, 0)) + return FALSE; + key = dixGetPrivate(&pScreen->devPrivates, &screenKey->screenKey); + if (key != NULL) { + assert(key->size == size); + assert(key->type == type); + return TRUE; + } key = calloc(sizeof (DevPrivateKeyRec), 1); if (!key) - return NULL; + return FALSE; if (!dixRegisterPrivateKey(key, type, size)) { free(key); - return NULL; + return FALSE; } key->allocated = TRUE; - return key; + dixSetPrivate(&pScreen->devPrivates, &screenKey->screenKey, key); + return TRUE; +} + +DevPrivateKey +_dixGetScreenPrivateKey(const DevScreenPrivateKey key, ScreenPtr pScreen) +{ + return dixGetPrivate(&pScreen->devPrivates, &key->screenKey); } /* diff --git a/doc/xml/Xserver-spec.xml b/doc/xml/Xserver-spec.xml index 563705fb9..4811a30a4 100644 --- a/doc/xml/Xserver-spec.xml +++ b/doc/xml/Xserver-spec.xml @@ -4854,16 +4854,16 @@ If the function is called more than once on the same key, all calls must use the same value for <type>size</type> or the server will abort.</para> <para> -To request private space and have the server manage the key, use +To request per-screen private space in an object, use <blockquote><programlisting> - DevPrivateKey dixCreatePrivateKey(DevPrivateType type, unsigned size); + Bool dixRegisterScreenPrivateKey(DevScreenPrivateKey key, ScreenPtr pScreen, DevPrivateType type, unsigned size); </programlisting></blockquote> The <parameter>type</parameter> and <parameter>size</parameter> arguments are the same as those to <function>dixRegisterPrivateKey</function> but this -function allocates a <type>DevPrivateKeyRec</type> and returns a pointer to it -instead of requiring the caller to pass a pointer to an existing structure. -The server will free it automatically when the privates system is restarted -at server reset time.</para> +function ensures the given <parameter>key</parameter> exists on objects of +the specified type with distinct storage for the given +<parameter>pScreen</parameter>. The key is usable on ScreenPrivate variants +that are otherwise equivalent to the following Private functions.</para> <para> To attach a piece of private data to an object, use: diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index 6b2ae97d4..ab07b6045 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -227,11 +227,7 @@ xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg) CursorPtr cursor = xf86_config->cursor; int c; CARD8 *bits = cursor ? -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen)) -#else - cursor->devPriv[screen->myNum] -#endif : NULL; /* Save ARGB versions of these colors */ @@ -630,11 +626,7 @@ xf86_reload_cursors (ScreenPtr screen) if (cursor) { -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) void *src = dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen)); -#else - void *src = cursor->devPriv[screen->myNum]; -#endif #ifdef ARGB_CURSOR if (cursor->bits->argb && cursor_info->LoadCursorARGB) (*cursor_info->LoadCursorARGB) (scrn, cursor); diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c index 8f4d04f93..c36774953 100644 --- a/hw/xfree86/modes/xf86EdidModes.c +++ b/hw/xfree86/modes/xf86EdidModes.c @@ -636,7 +636,6 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, return Mode; } -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) static DisplayModePtr DDCModesFromCVT(int scrnIndex, struct cvt_timings *t) { @@ -665,7 +664,6 @@ DDCModesFromCVT(int scrnIndex, struct cvt_timings *t) return modes; } -#endif static const struct { short w; @@ -1021,12 +1019,10 @@ static void handle_detailed_modes(struct detailed_monitor_section *det_mon, p->quirks, p->timing_level,p->rb); p->Modes = xf86ModesAdd(p->Modes, Mode); break; -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) case DS_CVT: Mode = DDCModesFromCVT(p->DDC->scrnIndex, det_mon->section.cvt); p->Modes = xf86ModesAdd(p->Modes, Mode); break; -#endif case DS_EST_III: Mode = DDCModesFromEstIII(det_mon->section.est_iii); p->Modes = xf86ModesAdd(p->Modes, Mode); diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c index 05f4319c9..51eb4c952 100644 --- a/hw/xfree86/modes/xf86Modes.c +++ b/hw/xfree86/modes/xf86Modes.c @@ -38,14 +38,6 @@ extern XF86ConfigPtr xf86configptr; -/* - * This is the version number where we epoched. These files get copied - * into drivers that want to use this setup infrastructure on pre-1.3 - * servers, so when that happens they need to define these symbols - * themselves. However, _in_ the server, we basically always define them now. - */ -#if XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(7,2,99,2,0) - /** * Calculates the horizontal sync rate of a mode. */ @@ -326,7 +318,6 @@ xf86PrintModeline(int scrnIndex,DisplayModePtr mode) mode->VTotal, flags, xf86ModeHSync(mode)); free(flags); } -#endif /* XORG_VERSION_CURRENT <= 7.2.99.2 */ /** * Marks as bad any modes with unsupported flags. @@ -503,12 +494,7 @@ xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList, for (mode = modeList; mode != NULL; mode = mode->next) { if (xf86ModeBandwidth(mode, depth) > bandwidth) -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) mode->status = MODE_BANDWIDTH; -#else - /* MODE_BANDWIDTH didn't exist in xserver 1.2 */ - mode->status = MODE_BAD; -#endif } } diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 043ceee08..dd2bdaca0 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -69,21 +69,12 @@ static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen); #endif static int xf86RandR12Generation; -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) static DevPrivateKeyRec xf86RandR12KeyRec; static DevPrivateKey xf86RandR12Key; #define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \ dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key)) -#else /* XORG_VERSION_CURRENT < 7.0 */ - -static int xf86RandR12Index; -#define XF86RANDRINFO(p) \ - ((XF86RandRInfoPtr)(p)->devPrivates[xf86RandR12Index].ptr) - -#endif /* XORG_VERSION_CURRENT < 7.0 */ - static int xf86RandR12ModeRefresh (DisplayModePtr mode) @@ -690,17 +681,13 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen, Bool ret = FALSE; int c; -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) if (xf86RandR12Key) { -#endif if (randrp->virtualX == -1 || randrp->virtualY == -1) { randrp->virtualX = pScrn->virtualX; randrp->virtualY = pScrn->virtualY; } -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) } -#endif if (pRoot && pScrn->vtSema) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE); @@ -843,10 +830,8 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen) mmHeight); } -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) if (xf86RandR12Key == NULL) return TRUE; -#endif if (randrp->virtualX == -1 || randrp->virtualY == -1) { @@ -882,13 +867,9 @@ xf86RandR12Init (ScreenPtr pScreen) if (xf86RandR12Generation != serverGeneration) xf86RandR12Generation = serverGeneration; -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) xf86RandR12Key = &xf86RandR12KeyRec; if (!dixRegisterPrivateKey(&xf86RandR12KeyRec, PRIVATE_SCREEN, 0)) return FALSE; -#else - xf86RandR12Index = AllocateScreenPrivateIndex(); -#endif randrp = malloc(sizeof (XF86RandRInfoRec)); if (!randrp) @@ -914,11 +895,7 @@ xf86RandR12Init (ScreenPtr pScreen) randrp->maxX = randrp->maxY = 0; -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) dixSetPrivate(&pScreen->devPrivates, xf86RandR12Key, randrp); -#else - pScreen->devPrivates[xf86RandR12Index].ptr = randrp; -#endif #if RANDR_12_INTERFACE if (!xf86RandR12Init12 (pScreen)) @@ -932,10 +909,8 @@ xf86RandR12CloseScreen (ScreenPtr pScreen) { XF86RandRInfoPtr randrp; -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) if (xf86RandR12Key == NULL) return; -#endif randrp = XF86RANDRINFO(pScreen); #if RANDR_12_INTERFACE @@ -955,10 +930,8 @@ xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations) xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); #endif -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) if (xf86RandR12Key == NULL) return; -#endif randrp = XF86RANDRINFO(pScreen); #if RANDR_12_INTERFACE @@ -981,10 +954,8 @@ xf86RandR12SetTransformSupport (ScreenPtr pScreen, Bool transforms) xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); #endif -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) if (xf86RandR12Key == NULL) return; -#endif randrp = XF86RANDRINFO(pScreen); #if RANDR_13_INTERFACE @@ -1599,10 +1570,8 @@ xf86RandR12CreateScreenResources12 (ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) if (xf86RandR12Key == NULL) return TRUE; -#endif for (c = 0; c < config->num_crtc; c++) xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc); @@ -1624,13 +1593,8 @@ xf86RandR12TellChanged (ScreenPtr pScreen) xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); int c; -#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) if (xf86RandR12Key == NULL) return; -#else - if (!XF86RANDRINFO(pScreen)) - return; -#endif xf86RandR12SetInfo12 (pScreen); for (c = 0; c < config->num_crtc; c++) diff --git a/include/privates.h b/include/privates.h index d3c0e1325..9fb6ae84e 100644 --- a/include/privates.h +++ b/include/privates.h @@ -65,6 +65,10 @@ typedef struct _DevPrivateKeyRec { struct _DevPrivateKeyRec *next; } DevPrivateKeyRec, *DevPrivateKey; +typedef struct _DevScreenPrivateKeyRec { + DevPrivateKeyRec screenKey; +} DevScreenPrivateKeyRec, *DevScreenPrivateKey; + /* * Let drivers know how to initialize private keys */ @@ -100,17 +104,6 @@ dixPrivateKeyRegistered(DevPrivateKey key) } /* - * Allocate a new private key. - * - * This manages the storage of the key object itself, freeing it when the - * privates system is restarted at server reset time. All other keys - * are expected to be statically allocated as the privates must be - * reset after all objects have been freed - */ -extern _X_EXPORT DevPrivateKey -dixCreatePrivateKey(DevPrivateType type, unsigned size); - -/* * Get the address of the private storage. * * For keys with pre-defined storage, this gets the base of that storage @@ -180,6 +173,42 @@ dixLookupPrivateAddr(PrivatePtr *privates, const DevPrivateKey key) return (pointer *)dixGetPrivateAddr(privates, key); } +extern _X_EXPORT Bool +dixRegisterScreenPrivateKey(DevScreenPrivateKey key, ScreenPtr pScreen, DevPrivateType type, unsigned size); + +extern _X_EXPORT DevPrivateKey +_dixGetScreenPrivateKey(const DevScreenPrivateKey key, ScreenPtr pScreen); + +static inline void * +dixGetScreenPrivateAddr(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenPtr pScreen) +{ + return dixGetPrivateAddr(privates, _dixGetScreenPrivateKey(key, pScreen)); +} + +static inline void * +dixGetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenPtr pScreen) +{ + return dixGetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen)); +} + +static inline void +dixSetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenPtr pScreen, pointer val) +{ + return dixSetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen), val); +} + +static inline pointer +dixLookupScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenPtr pScreen) +{ + return dixLookupPrivate(privates, _dixGetScreenPrivateKey(key, pScreen)); +} + +static inline pointer * +dixLookupScreenPrivateAddr(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenPtr pScreen) +{ + return dixLookupPrivateAddr(privates, _dixGetScreenPrivateKey(key, pScreen)); +} + /* * Allocates private data separately from main object. * diff --git a/mi/midispcur.c b/mi/midispcur.c index 323ee028b..48feb8823 100644 --- a/mi/midispcur.c +++ b/mi/midispcur.c @@ -56,6 +56,10 @@ in this Software without prior written authorization from The Open Group. /* per-screen private data */ static DevPrivateKeyRec miDCScreenKeyRec; #define miDCScreenKey (&miDCScreenKeyRec) +static DevScreenPrivateKeyRec miDCCursorBitsKeyRec; +#define miDCCursorBitsKey (&miDCCursorBitsKeyRec) +static DevScreenPrivateKeyRec miDCDeviceKeyRec; +#define miDCDeviceKey (&miDCDeviceKeyRec) static Bool miDCCloseScreen(int index, ScreenPtr pScreen); @@ -71,8 +75,8 @@ typedef struct { #define miGetDCDevice(dev, screen) \ ((DevHasCursor(dev)) ? \ - (miDCBufferPtr)dixLookupPrivate(&dev->devPrivates, miDCDeviceKey(screen)) : \ - (miDCBufferPtr)dixLookupPrivate(&dev->u.master->devPrivates, miDCDeviceKey(screen))) + (miDCBufferPtr)dixLookupScreenPrivate(&dev->devPrivates, miDCDeviceKey, screen) : \ + (miDCBufferPtr)dixLookupScreenPrivate(&dev->u.master->devPrivates, miDCDeviceKey, screen)) /* * The core pointer buffer will point to the index of the virtual core pointer @@ -80,13 +84,9 @@ typedef struct { */ typedef struct { CloseScreenProcPtr CloseScreen; - DevPrivateKey device_key; - DevPrivateKey cursor_bits_key; } miDCScreenRec, *miDCScreenPtr; #define miGetDCScreen(s) ((miDCScreenPtr)(dixLookupPrivate(&(s)->devPrivates, miDCScreenKey))) -#define miDCDeviceKey(s) (miGetDCScreen(s)->device_key) -#define miDCCursorBitsKey(s) (miGetDCScreen(s)->cursor_bits_key) /* per-cursor per-screen private data */ typedef struct { @@ -102,19 +102,15 @@ miDCInitialize (ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs) { miDCScreenPtr pScreenPriv; - if (!dixRegisterPrivateKey(&miDCScreenKeyRec, PRIVATE_SCREEN, 0)) + if (!dixRegisterPrivateKey(&miDCScreenKeyRec, PRIVATE_SCREEN, 0) || + !dixRegisterScreenPrivateKey(&miDCCursorBitsKeyRec, pScreen, PRIVATE_CURSOR_BITS, 0) || + !dixRegisterScreenPrivateKey(&miDCDeviceKeyRec, pScreen, PRIVATE_DEVICE, 0)) return FALSE; pScreenPriv = malloc(sizeof (miDCScreenRec)); if (!pScreenPriv) return FALSE; - pScreenPriv->cursor_bits_key = dixCreatePrivateKey(PRIVATE_CURSOR_BITS, 0); - pScreenPriv->device_key = dixCreatePrivateKey(PRIVATE_DEVICE, 0); - if (!pScreenPriv->cursor_bits_key || !pScreenPriv->device_key) { - free(pScreenPriv); - return FALSE; - } pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = miDCCloseScreen; @@ -144,7 +140,7 @@ Bool miDCRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) { if (pCursor->bits->refcnt <= 1) - dixSetPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey(pScreen), NULL); + dixSetScreenPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey, pScreen, NULL); return TRUE; } @@ -243,7 +239,7 @@ miDCRealize (ScreenPtr pScreen, CursorPtr pCursor) free((pointer) pPriv); return NULL; } - dixSetPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey(pScreen), pPriv); + dixSetScreenPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey, pScreen, pPriv); return pPriv; } pPriv->pPicture = 0; @@ -261,7 +257,7 @@ miDCRealize (ScreenPtr pScreen, CursorPtr pCursor) free((pointer) pPriv); return NULL; } - dixSetPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey(pScreen), pPriv); + dixSetScreenPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey, pScreen, pPriv); /* create the two sets of bits, clipping as appropriate */ @@ -305,8 +301,8 @@ miDCUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) { miDCCursorPtr pPriv; - pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates, - miDCCursorBitsKey(pScreen)); + pPriv = (miDCCursorPtr)dixLookupScreenPrivate(&pCursor->bits->devPrivates, + miDCCursorBitsKey, pScreen); if (pPriv && (pCursor->bits->refcnt <= 1)) { if (pPriv->sourceBits) @@ -318,7 +314,7 @@ miDCUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) FreePicture (pPriv->pPicture, 0); #endif free((pointer) pPriv); - dixSetPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey(pScreen), NULL); + dixSetScreenPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey, pScreen, NULL); } return TRUE; } @@ -406,8 +402,8 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, miDCBufferPtr pBuffer; WindowPtr pWin; - pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates, - miDCCursorBitsKey(pScreen)); + pPriv = (miDCCursorPtr)dixLookupScreenPrivate(&pCursor->bits->devPrivates, + miDCCursorBitsKey, pScreen); if (!pPriv) { pPriv = miDCRealize(pScreen, pCursor); @@ -523,7 +519,7 @@ miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) if (!pBuffer) goto failure; - dixSetPrivate(&pDev->devPrivates, miDCDeviceKey(pScreen), pBuffer); + dixSetScreenPrivate(&pDev->devPrivates, miDCDeviceKey, pScreen, pBuffer); pWin = pScreen->root; pBuffer->pSourceGC = miDCMakeGC(pWin); @@ -589,7 +585,7 @@ miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) if (pBuffer->pSave) (*pScreen->DestroyPixmap)(pBuffer->pSave); free(pBuffer); - dixSetPrivate(&pDev->devPrivates, miDCDeviceKey(pScreen), NULL); + dixSetScreenPrivate(&pDev->devPrivates, miDCDeviceKey, pScreen, NULL); } } } |