diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2010-05-18 10:01:52 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2010-05-18 10:01:52 -0400 |
commit | 509df27c7401e96d3062890da73f6af6629adef4 (patch) | |
tree | 5e39fed3f5f749709412af2003fbe3ff268d4033 | |
parent | 5e04a81369dfc76bbc1ebbd4db00c23e71eb9e1c (diff) |
dri: Clean up DRI2 API #ifdefs a bit
Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
-rw-r--r-- | src/i830_dri.c | 81 |
1 files changed, 31 insertions, 50 deletions
diff --git a/src/i830_dri.c b/src/i830_dri.c index efd8c4aa..61abd36f 100644 --- a/src/i830_dri.c +++ b/src/i830_dri.c @@ -66,21 +66,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "dri2.h" -#ifdef DRI2 -#if DRI2INFOREC_VERSION >= 1 -#define USE_DRI2_1_1_0 -#endif - -extern XF86ModuleData dri2ModuleData; -#endif - typedef struct { int refcnt; PixmapPtr pixmap; unsigned int attachment; } I830DRI2BufferPrivateRec, *I830DRI2BufferPrivatePtr; -#ifndef USE_DRI2_1_1_0 +#if DRI2INFOREC_VERSION < 2 + static DRI2BufferPtr I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments, int count) @@ -162,6 +155,24 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments, return buffers; } +static void +I830DRI2DestroyBuffers(DrawablePtr drawable, DRI2BufferPtr buffers, int count) +{ + ScreenPtr screen = drawable->pScreen; + I830DRI2BufferPrivatePtr private; + int i; + + for (i = 0; i < count; i++) { + private = buffers[i].driverPrivate; + screen->DestroyPixmap(private->pixmap); + } + + if (buffers) { + xfree(buffers[0].driverPrivate); + xfree(buffers); + } +} + #else static DRI2Buffer2Ptr @@ -237,30 +248,6 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment, return buffer; } -#endif - -#ifndef USE_DRI2_1_1_0 - -static void -I830DRI2DestroyBuffers(DrawablePtr drawable, DRI2BufferPtr buffers, int count) -{ - ScreenPtr screen = drawable->pScreen; - I830DRI2BufferPrivatePtr private; - int i; - - for (i = 0; i < count; i++) { - private = buffers[i].driverPrivate; - screen->DestroyPixmap(private->pixmap); - } - - if (buffers) { - xfree(buffers[0].driverPrivate); - xfree(buffers); - } -} - -#else - static void I830DRI2DestroyBuffer(DrawablePtr drawable, DRI2Buffer2Ptr buffer) { if (buffer) { @@ -979,25 +966,20 @@ Bool I830DRI2ScreenInit(ScreenPtr screen) ScrnInfoPtr scrn = xf86Screens[screen->myNum]; intel_screen_private *intel = intel_get_screen_private(scrn); DRI2InfoRec info; -#ifdef USE_DRI2_1_1_0 int dri2_major = 1; int dri2_minor = 0; -#endif #if DRI2INFOREC_VERSION >= 4 const char *driverNames[1]; #endif -#ifdef USE_DRI2_1_1_0 - if (xf86LoaderCheckSymbol("DRI2Version")) { + if (xf86LoaderCheckSymbol("DRI2Version")) DRI2Version(&dri2_major, &dri2_minor); - } if (dri2_minor < 1) { xf86DrvMsg(scrn->scrnIndex, X_WARNING, "DRI2 requires DRI2 module version 1.1.0 or later\n"); return FALSE; } -#endif intel->deviceName = drmGetDeviceNameFromFd(intel->drmSubFD); memset(&info, '\0', sizeof(info)); @@ -1005,22 +987,21 @@ Bool I830DRI2ScreenInit(ScreenPtr screen) info.driverName = IS_I965G(intel) ? "i965" : "i915"; info.deviceName = intel->deviceName; -#if DRI2INFOREC_VERSION >= 3 - info.version = 3; +#if DRI2INFOREC_VERSION == 1 + info.version = 1; + info.CreateBuffers = I830DRI2CreateBuffers; + info.DestroyBuffers = I830DRI2DestroyBuffers; +#elif DRI2INFOREC_VERSION == 2 + /* The ABI between 2 and 3 was broken so we could get rid of + * the multi-buffer alloc functions. Make sure we indicate the + * right version so DRI2 can reject us if it's version 3 or above. */ + info.version = 2; info.CreateBuffer = I830DRI2CreateBuffer; info.DestroyBuffer = I830DRI2DestroyBuffer; #else -# ifdef USE_DRI2_1_1_0 - info.version = 2; - info.CreateBuffers = NULL; - info.DestroyBuffers = NULL; + info.version = 3; info.CreateBuffer = I830DRI2CreateBuffer; info.DestroyBuffer = I830DRI2DestroyBuffer; -# else - info.version = 1; - info.CreateBuffers = I830DRI2CreateBuffers; - info.DestroyBuffers = I830DRI2DestroyBuffers; -# endif #endif info.CopyRegion = I830DRI2CopyRegion; |