summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Høgsberg <[email protected]>2010-07-19 18:11:03 -0400
committerKristian Høgsberg <[email protected]>2010-07-19 22:45:50 -0400
commit271c3c3a90ccfd01da9d7ac7fa451518f4e6a27c (patch)
treec0d4b2b52fddaf760d72e1e387b7c233436f5b39
parent22266c391fbe17603b15a83d4ccf5fa9455ccf8d (diff)
glx: Move __DRIdrawable pointers to DRI drawable privates
-rw-r--r--src/glx/dri2_glx.c48
-rw-r--r--src/glx/dri_glx.c73
-rw-r--r--src/glx/drisw_glx.c28
-rw-r--r--src/glx/glxclient.h1
-rw-r--r--src/glx/glxcmds.c2
5 files changed, 88 insertions, 64 deletions
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 3187fa16d9c..27223fdaeb5 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -101,6 +101,7 @@ struct dri2_context
struct dri2_drawable
{
__GLXDRIdrawable base;
+ __DRIdrawable *driDrawable;
__DRIbuffer buffers[5];
int bufferCount;
int width, height;
@@ -127,9 +128,11 @@ dri2BindContext(__GLXDRIcontext *context,
{
struct dri2_context *pcp = (struct dri2_context *) context;
struct dri2_screen *psc = (struct dri2_screen *) pcp->psc;
+ struct dri2_drawable *pdr = (struct dri2_drawable *) draw;
+ struct dri2_drawable *prd = (struct dri2_drawable *) read;
return (*psc->core->bindContext) (pcp->driContext,
- draw->driDrawable, read->driDrawable);
+ pdr->driDrawable, prd->driDrawable);
}
static void
@@ -179,18 +182,19 @@ dri2CreateContext(__GLXscreenConfigs *base,
}
static void
-dri2DestroyDrawable(__GLXDRIdrawable *pdraw)
+dri2DestroyDrawable(__GLXDRIdrawable *base)
{
- struct dri2_screen *psc = (struct dri2_screen *) pdraw->psc;
+ struct dri2_screen *psc = (struct dri2_screen *) base->psc;
+ struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
__GLXdisplayPrivate *dpyPriv;
struct dri2_display *pdp;
- dpyPriv = __glXInitialize(pdraw->psc->dpy);
+ dpyPriv = __glXInitialize(base->psc->dpy);
pdp = (struct dri2_display *)dpyPriv->dri2Display;
- __glxHashDelete(pdp->dri2Hash, pdraw->xDrawable);
+ __glxHashDelete(pdp->dri2Hash, pdraw->base.xDrawable);
(*psc->core->destroyDrawable) (pdraw->driDrawable);
- DRI2DestroyDrawable(psc->base.dpy, pdraw->xDrawable);
+ DRI2DestroyDrawable(psc->base.dpy, pdraw->base.xDrawable);
Xfree(pdraw);
}
@@ -238,18 +242,18 @@ dri2CreateDrawable(__GLXscreenConfigs *base, XID xDrawable,
dpyPriv = __glXInitialize(psc->base.dpy);
pdp = (struct dri2_display *)dpyPriv->dri2Display;;
/* Create a new drawable */
- pdraw->base.driDrawable =
+ pdraw->driDrawable =
(*psc->dri2->createNewDrawable) (psc->driScreen,
config->driConfig, pdraw);
- if (!pdraw->base.driDrawable) {
+ if (!pdraw->driDrawable) {
DRI2DestroyDrawable(psc->base.dpy, xDrawable);
Xfree(pdraw);
return NULL;
}
if (__glxHashInsert(pdp->dri2Hash, xDrawable, pdraw)) {
- (*psc->core->destroyDrawable) (pdraw->base.driDrawable);
+ (*psc->core->destroyDrawable) (pdraw->driDrawable);
DRI2DestroyDrawable(psc->base.dpy, xDrawable);
Xfree(pdraw);
return None;
@@ -319,7 +323,7 @@ dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height)
#ifdef __DRI2_FLUSH
if (psc->f)
- (*psc->f->flush) (pdraw->driDrawable);
+ (*psc->f->flush) (priv->driDrawable);
#endif
region = XFixesCreateRegion(psc->base.dpy, &xrect, 1);
@@ -349,7 +353,7 @@ dri2_copy_drawable(struct dri2_drawable *priv, int dest, int src)
#ifdef __DRI2_FLUSH
if (psc->f)
- (*psc->f->flush) (priv->base.driDrawable);
+ (*psc->f->flush) (priv->driDrawable);
#endif
region = XFixesCreateRegion(psc->base.dpy, &xrect, 1);
@@ -451,7 +455,7 @@ dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
#ifdef __DRI2_FLUSH
if (psc->f)
- (*psc->f->flush)(pdraw->driDrawable);
+ (*psc->f->flush)(priv->driDrawable);
#endif
/* Old servers don't send invalidate events */
@@ -586,10 +590,11 @@ dri2InvalidateBuffers(Display *dpy, XID drawable)
__GLXDRIdrawable *pdraw =
dri2GetGlxDrawableFromXDrawableId(dpy, drawable);
struct dri2_screen *psc = (struct dri2_screen *) pdraw->psc;
+ struct dri2_drawable *pdp = (struct dri2_drawable *) pdraw;
#if __DRI2_FLUSH_VERSION >= 3
if (pdraw && psc->f)
- psc->f->invalidate(pdraw->driDrawable);
+ psc->f->invalidate(pdp->driDrawable);
#endif
}
@@ -599,11 +604,12 @@ dri2_bind_tex_image(Display * dpy,
int buffer, const int *attrib_list)
{
GLXContext gc = __glXGetCurrentContext();
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
- __GLXdisplayPrivate *dpyPriv = __glXInitialize(dpy);
- struct dri2_display *pdp =
- (struct dri2_display *) dpyPriv->dri2Display;
- struct dri2_screen *psc = (struct dri2_screen *) pdraw->psc;
+ __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable, NULL);
+ __GLXdisplayPrivate *dpyPriv = __glXInitialize(dpy);
+ struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
+ struct dri2_display *pdp =
+ (struct dri2_display *) dpyPriv->dri2Display;
+ struct dri2_screen *psc = (struct dri2_screen *) base->psc;
if (pdraw != NULL) {
@@ -615,13 +621,13 @@ dri2_bind_tex_image(Display * dpy,
if (psc->texBuffer->base.version >= 2 &&
psc->texBuffer->setTexBuffer2 != NULL) {
(*psc->texBuffer->setTexBuffer2) (gc->__driContext,
- pdraw->textureTarget,
- pdraw->textureFormat,
+ pdraw->base.textureTarget,
+ pdraw->base.textureFormat,
pdraw->driDrawable);
}
else {
(*psc->texBuffer->setTexBuffer) (gc->__driContext,
- pdraw->textureTarget,
+ pdraw->base.textureTarget,
pdraw->driDrawable);
}
}
diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
index 373f9fb649d..d3facca8434 100644
--- a/src/glx/dri_glx.c
+++ b/src/glx/dri_glx.c
@@ -82,6 +82,13 @@ struct dri_context
__GLXscreenConfigs *psc;
};
+struct dri_drawable
+{
+ __GLXDRIdrawable base;
+
+ __DRIdrawable *driDrawable;
+};
+
/*
* Given a display pointer and screen number, determine the name of
* the DRI driver for the screen. (I.e. "r128", "tdfx", etc).
@@ -506,9 +513,11 @@ driBindContext(__GLXDRIcontext *context,
{
struct dri_context *pcp = (struct dri_context *) context;
struct dri_screen *psc = (struct dri_screen *) pcp->psc;
+ struct dri_drawable *pdr = (struct dri_drawable *) draw;
+ struct dri_drawable *prd = (struct dri_drawable *) read;
return (*psc->core->bindContext) (pcp->driContext,
- draw->driDrawable, read->driDrawable);
+ pdr->driDrawable, prd->driDrawable);
}
static void
@@ -572,8 +581,9 @@ static void
driDestroyDrawable(__GLXDRIdrawable * pdraw)
{
struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
- (*psc->core->destroyDrawable) (pdraw->driDrawable);
+ (*psc->core->destroyDrawable) (pdp->driDrawable);
XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, pdraw->drawable);
Xfree(pdraw);
}
@@ -583,46 +593,46 @@ driCreateDrawable(__GLXscreenConfigs *base,
XID xDrawable,
GLXDrawable drawable, const __GLcontextModes * modes)
{
- __GLXDRIdrawable *pdraw;
drm_drawable_t hwDrawable;
void *empty_attribute_list = NULL;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
struct dri_screen *psc = (struct dri_screen *) base;
+ struct dri_drawable *pdp;
/* Old dri can't handle GLX 1.3+ drawable constructors. */
if (xDrawable != drawable)
return NULL;
- pdraw = Xmalloc(sizeof(*pdraw));
- if (!pdraw)
+ pdp = Xmalloc(sizeof *pdp);
+ if (!pdp)
return NULL;
- pdraw->drawable = drawable;
- pdraw->psc = &psc->base;
+ pdp->base.drawable = drawable;
+ pdp->base.psc = &psc->base;
if (!XF86DRICreateDrawable(psc->base.dpy, psc->base.scr,
drawable, &hwDrawable)) {
- Xfree(pdraw);
+ Xfree(pdp);
return NULL;
}
/* Create a new drawable */
- pdraw->driDrawable =
+ pdp->driDrawable =
(*psc->legacy->createNewDrawable) (psc->driScreen,
config->driConfig,
hwDrawable,
GLX_WINDOW_BIT,
- empty_attribute_list, pdraw);
+ empty_attribute_list, pdp);
- if (!pdraw->driDrawable) {
+ if (!pdp->driDrawable) {
XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, drawable);
- Xfree(pdraw);
+ Xfree(pdp);
return NULL;
}
- pdraw->destroyDrawable = driDestroyDrawable;
+ pdp->base.destroyDrawable = driDestroyDrawable;
- return pdraw;
+ return &pdp->base;
}
static int64_t
@@ -630,8 +640,9 @@ driSwapBuffers(__GLXDRIdrawable * pdraw, int64_t unused1, int64_t unused2,
int64_t unused3)
{
struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
- (*psc->core->swapBuffers) (pdraw->driDrawable);
+ (*psc->core->swapBuffers) (pdp->driDrawable);
return 0;
}
@@ -639,8 +650,10 @@ static void
driCopySubBuffer(__GLXDRIdrawable * pdraw,
int x, int y, int width, int height)
{
- (*pdraw->psc->driCopySubBuffer->copySubBuffer) (pdraw->driDrawable,
- x, y, width, height);
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
+
+ (*pdp->base.psc->driCopySubBuffer->copySubBuffer) (pdp->driDrawable,
+ x, y, width, height);
}
static void
@@ -668,10 +681,11 @@ driDrawableGetMSC(__GLXscreenConfigs *base, __GLXDRIdrawable *pdraw,
int64_t *ust, int64_t *msc, int64_t *sbc)
{
struct dri_screen *psc = (struct dri_screen *) base;
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
- if (pdraw && psc->sbc && psc->msc)
+ if (pdp && psc->sbc && psc->msc)
return ( (*psc->msc->getMSC)(psc->driScreen, msc) == 0 &&
- (*psc->sbc->getSBC)(pdraw->driDrawable, sbc) == 0 &&
+ (*psc->sbc->getSBC)(pdp->driDrawable, sbc) == 0 &&
__glXGetUST(ust) == 0 );
}
@@ -680,9 +694,10 @@ driWaitForMSC(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc)
{
struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
- if (pdraw != NULL && psc->msc != NULL) {
- ret = (*psc->msc->waitForMSC) (pdraw->driDrawable, target_msc,
+ if (pdp != NULL && psc->msc != NULL) {
+ ret = (*psc->msc->waitForMSC) (pdp->driDrawable, target_msc,
divisor, remainder, msc, sbc);
/* __glXGetUST returns zero on success and non-zero on failure.
@@ -696,9 +711,11 @@ static int
driWaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
int64_t *msc, int64_t *sbc)
{
- if (pdraw != NULL && psc->sbc != NULL) {
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
+
+ if (pdp != NULL && psc->sbc != NULL) {
ret =
- (*psc->sbc->waitForSBC) (pdraw->driDrawable, target_sbc, msc, sbc);
+ (*psc->sbc->waitForSBC) (pdp->driDrawable, target_sbc, msc, sbc);
/* __glXGetUST returns zero on success and non-zero on failure.
* This function returns True on success and False on failure.
@@ -706,8 +723,8 @@ driWaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
return ((ret == 0) && (__glXGetUST(ust) == 0));
}
- return DRI2WaitSBC(pdraw->psc->dpy, pdraw->xDrawable, target_sbc, ust, msc,
- sbc);
+ return DRI2WaitSBC(pdp->base.psc->dpy,
+ pdp->base.xDrawable, target_sbc, ust, msc, sbc);
}
#endif
@@ -716,13 +733,14 @@ static int
driSetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
{
GLXContext gc = __glXGetCurrentContext();
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
struct dri_screen *psc;
if (gc->driContext) {
psc = (struct dri_screen *) pdraw->psc;
if (psc->swapControl != NULL && pdraw != NULL) {
- psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
+ psc->swapControl->setSwapInterval(pdp->driDrawable, interval);
return 0;
}
}
@@ -734,13 +752,14 @@ static int
driGetSwapInterval(__GLXDRIdrawable *pdraw)
{
GLXContext gc = __glXGetCurrentContext();
+ struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
struct dri_screen *psc;
if (gc != NULL && gc->driContext) {
psc = (struct dri_screen *) pdraw->psc;
if (psc->swapControl != NULL && pdraw != NULL) {
- return psc->swapControl->getSwapInterval(pdraw->driDrawable);
+ return psc->swapControl->getSwapInterval(pdp->driDrawable);
}
}
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index e9a88e6db0c..0ea846b6911 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -58,6 +58,7 @@ struct drisw_drawable
GC gc;
GC swapgc;
+ __DRIdrawable *driDrawable;
XVisualInfo *visinfo;
XImage *ximage;
};
@@ -253,9 +254,11 @@ driBindContext(__GLXDRIcontext * context,
{
struct drisw_context *pcp = (struct drisw_context *) context;
struct drisw_screen *psc = (struct drisw_screen *) pcp->psc;
+ struct drisw_drawable *pdr = (struct drisw_drawable *) draw;
+ struct drisw_drawable *prd = (struct drisw_drawable *) read;
return (*psc->core->bindContext) (pcp->driContext,
- draw->driDrawable, read->driDrawable);
+ pdr->driDrawable, prd->driDrawable);
}
static void
@@ -311,7 +314,7 @@ driDestroyDrawable(__GLXDRIdrawable * pdraw)
struct drisw_drawable *pdp = (struct drisw_drawable *) pdraw;
struct drisw_screen *psc = (struct drisw_screen *) pdp->base.psc;
- (*psc->core->destroyDrawable) (pdraw->driDrawable);
+ (*psc->core->destroyDrawable) (pdp->driDrawable);
XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable);
Xfree(pdp);
@@ -321,7 +324,6 @@ static __GLXDRIdrawable *
driCreateDrawable(__GLXscreenConfigs *base, XID xDrawable,
GLXDrawable drawable, const __GLcontextModes * modes)
{
- __GLXDRIdrawable *pdraw;
struct drisw_drawable *pdp;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
struct drisw_screen *psc = (struct drisw_screen *) base;
@@ -336,27 +338,25 @@ driCreateDrawable(__GLXscreenConfigs *base, XID xDrawable,
if (!pdp)
return NULL;
- pdraw = &(pdp->base);
- pdraw->xDrawable = xDrawable;
- pdraw->drawable = drawable;
- pdraw->psc = &psc->base;
+ pdp->base.xDrawable = xDrawable;
+ pdp->base.drawable = drawable;
+ pdp->base.psc = &psc->base;
XCreateDrawable(pdp, psc->base.dpy, xDrawable, modes->visualID);
/* Create a new drawable */
- pdraw->driDrawable =
- (*swrast->createNewDrawable) (psc->driScreen,
- config->driConfig, pdp);
+ pdp->driDrawable =
+ (*swrast->createNewDrawable) (psc->driScreen, config->driConfig, pdp);
- if (!pdraw->driDrawable) {
+ if (!pdp->driDrawable) {
XDestroyDrawable(pdp, psc->base.dpy, xDrawable);
Xfree(pdp);
return NULL;
}
- pdraw->destroyDrawable = driDestroyDrawable;
+ pdp->base.destroyDrawable = driDestroyDrawable;
- return pdraw;
+ return &pdp->base;
}
static int64_t
@@ -370,7 +370,7 @@ driSwapBuffers(__GLXDRIdrawable * pdraw,
(void) divisor;
(void) remainder;
- (*psc->core->swapBuffers) (pdraw->driDrawable);
+ (*psc->core->swapBuffers) (pdp->driDrawable);
return 0;
}
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index 4ce99050b35..65dc26b3fcc 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -173,7 +173,6 @@ struct __GLXDRIdrawableRec
XID drawable;
__GLXscreenConfigs *psc;
GLenum textureTarget;
- __DRIdrawable *driDrawable;
GLenum textureFormat; /* EXT_texture_from_pixmap support */
unsigned long eventMask;
};
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index f51df7bca14..a75226a657c 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -2481,7 +2481,7 @@ __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
if (draw == NULL)
return False;
- return __driGetMscRateOML(draw->driDrawable, numerator, denominator, draw);
+ return __driGetMscRateOML(NULL, numerator, denominator, draw);
#else
(void) dpy;
(void) drawable;