mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-29 15:00:38 +02:00
Move DRI drawable creation into dri_glx.c.
This commit is contained in:
parent
92d2a78f8d
commit
20b9230ce1
4 changed files with 68 additions and 56 deletions
|
|
@ -413,8 +413,8 @@ __glXDRIGetDrawableInfo(__DRIdrawable *drawable,
|
|||
int *backX, int *backY,
|
||||
int *numBackClipRects, drm_clip_rect_t **pBackClipRects)
|
||||
{
|
||||
__GLXdrawable *glxDraw =
|
||||
containerOf(drawable, __GLXdrawable, driDrawable);
|
||||
__GLXDRIdrawable *glxDraw =
|
||||
containerOf(drawable, __GLXDRIdrawable, driDrawable);
|
||||
__GLXscreenConfigs *psc = glxDraw->psc;
|
||||
Display *dpy = psc->dpy;
|
||||
|
||||
|
|
@ -693,6 +693,50 @@ static void driCreateContext(__GLXscreenConfigs *psc,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
|
||||
GLXDrawable drawable,
|
||||
GLXContext gc)
|
||||
{
|
||||
__GLXDRIdrawable *pdraw;
|
||||
drm_drawable_t hwDrawable;
|
||||
void *empty_attribute_list = NULL;
|
||||
|
||||
pdraw = Xmalloc(sizeof(*pdraw));
|
||||
if (!pdraw)
|
||||
return NULL;
|
||||
|
||||
pdraw->drawable = drawable;
|
||||
pdraw->psc = psc;
|
||||
|
||||
if (!XF86DRICreateDrawable(psc->dpy, psc->scr, drawable, &hwDrawable))
|
||||
return NULL;
|
||||
|
||||
/* Create a new drawable */
|
||||
pdraw->driDrawable.private =
|
||||
(*psc->__driScreen.createNewDrawable)(&psc->__driScreen,
|
||||
gc->mode,
|
||||
&pdraw->driDrawable,
|
||||
hwDrawable,
|
||||
GLX_WINDOW_BIT,
|
||||
empty_attribute_list);
|
||||
|
||||
if (!pdraw->driDrawable.private) {
|
||||
XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable);
|
||||
Xfree(pdraw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (__glxHashInsert(psc->drawHash, drawable, pdraw)) {
|
||||
(*pdraw->driDrawable.destroyDrawable)(&pdraw->driDrawable);
|
||||
XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable);
|
||||
Xfree(pdraw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pdraw;
|
||||
}
|
||||
|
||||
static void driDestroyScreen(__GLXscreenConfigs *psc)
|
||||
{
|
||||
/* Free the direct rendering per screen data */
|
||||
|
|
@ -737,6 +781,7 @@ static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,
|
|||
|
||||
psp->destroyScreen = driDestroyScreen;
|
||||
psp->createContext = driCreateContext;
|
||||
psp->createDrawable = driCreateDrawable;
|
||||
|
||||
return psp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ typedef struct _glapi_table __GLapi;
|
|||
*/
|
||||
typedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
|
||||
typedef struct __GLXDRIscreenRec __GLXDRIscreen;
|
||||
typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
|
||||
|
||||
struct __GLXDRIdisplayRec {
|
||||
/**
|
||||
|
|
@ -112,6 +113,16 @@ struct __GLXDRIscreenRec {
|
|||
void (*createContext)(__GLXscreenConfigs *psc,
|
||||
const __GLcontextModes *mode,
|
||||
GLXContext gc, GLXContext shareList, int renderType);
|
||||
|
||||
__GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc,
|
||||
GLXDrawable drawable,
|
||||
GLXContext gc);
|
||||
};
|
||||
|
||||
struct __GLXDRIdrawableRec {
|
||||
XID drawable;
|
||||
__GLXscreenConfigs *psc;
|
||||
__DRIdrawable driDrawable;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -541,17 +552,6 @@ struct __GLXdisplayPrivateRec {
|
|||
#endif
|
||||
};
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
|
||||
struct __GLXdrawableRec {
|
||||
XID drawable;
|
||||
__GLXscreenConfigs *psc;
|
||||
__DRIdrawable driDrawable;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void __glXFreeContext(__GLXcontext*);
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ static int windowExistsErrorHandler(Display *dpy, XErrorEvent *xerr)
|
|||
static void GarbageCollectDRIDrawables(Display *dpy, __GLXscreenConfigs *sc)
|
||||
{
|
||||
XID draw;
|
||||
__GLXdrawable *pdraw;
|
||||
__GLXDRIdrawable *pdraw;
|
||||
XWindowAttributes xwa;
|
||||
int (*oldXErrorHandler)(Display *, XErrorEvent *);
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ static __DRIdrawable *
|
|||
GetDRIDrawable( Display *dpy, GLXDrawable drawable, int * const scrn_num )
|
||||
{
|
||||
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
|
||||
__GLXdrawable * const pdraw;
|
||||
__GLXDRIdrawable * const pdraw;
|
||||
const unsigned screen_count = ScreenCount(dpy);
|
||||
unsigned i;
|
||||
__GLXscreenConfigs *sc;
|
||||
|
|
@ -2143,9 +2143,9 @@ __driGetMscRateOML(__DRIdrawable *draw, int32_t *numerator, int32_t *denominator
|
|||
XF86VidModeModeLine mode_line;
|
||||
int dot_clock;
|
||||
int i;
|
||||
__GLXdrawable *glxDraw;
|
||||
__GLXDRIdrawable *glxDraw;
|
||||
|
||||
glxDraw = containerOf(draw, __GLXdrawable, driDrawable);
|
||||
glxDraw = containerOf(draw, __GLXDRIdrawable, driDrawable);
|
||||
psc = glxDraw->psc;
|
||||
if (XF86VidModeQueryVersion(psc->dpy, &i, &i) &&
|
||||
XF86VidModeGetModeLine(psc->dpy, psc->scr, &dot_clock, &mode_line) ) {
|
||||
|
|
|
|||
|
|
@ -1178,53 +1178,20 @@ static Bool SendMakeCurrentRequest(Display *dpy, CARD8 opcode,
|
|||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
static __DRIdrawable *
|
||||
FetchDRIDrawable( Display *dpy, GLXDrawable drawable, GLXContext gc)
|
||||
FetchDRIDrawable(Display *dpy, GLXDrawable drawable, GLXContext gc)
|
||||
{
|
||||
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
|
||||
__GLXdrawable *pdraw;
|
||||
__GLXscreenConfigs *sc;
|
||||
drm_drawable_t hwDrawable;
|
||||
void *empty_attribute_list = NULL;
|
||||
__GLXDRIdrawable *pdraw;
|
||||
__GLXscreenConfigs *psc;
|
||||
|
||||
if (priv == NULL || priv->driDisplay == NULL)
|
||||
return NULL;
|
||||
|
||||
sc = &priv->screenConfigs[gc->screen];
|
||||
if (__glxHashLookup(sc->drawHash, drawable, (void *) &pdraw) == 0)
|
||||
psc = &priv->screenConfigs[gc->screen];
|
||||
if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0)
|
||||
return &pdraw->driDrawable;
|
||||
|
||||
/* Allocate a new drawable */
|
||||
pdraw = Xmalloc(sizeof(*pdraw));
|
||||
if (!pdraw)
|
||||
return NULL;
|
||||
|
||||
pdraw->drawable = drawable;
|
||||
pdraw->psc = sc;
|
||||
|
||||
if (!XF86DRICreateDrawable(dpy, sc->scr, drawable, &hwDrawable))
|
||||
return NULL;
|
||||
|
||||
/* Create a new drawable */
|
||||
pdraw->driDrawable.private =
|
||||
(*sc->__driScreen.createNewDrawable)(&sc->__driScreen,
|
||||
gc->mode,
|
||||
&pdraw->driDrawable,
|
||||
hwDrawable,
|
||||
GLX_WINDOW_BIT,
|
||||
empty_attribute_list);
|
||||
|
||||
if (!pdraw->driDrawable.private) {
|
||||
XF86DRIDestroyDrawable(dpy, sc->scr, drawable);
|
||||
Xfree(pdraw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (__glxHashInsert(sc->drawHash, drawable, pdraw)) {
|
||||
(*pdraw->driDrawable.destroyDrawable)(&pdraw->driDrawable);
|
||||
XF86DRIDestroyDrawable(dpy, sc->scr, drawable);
|
||||
Xfree(pdraw);
|
||||
return NULL;
|
||||
}
|
||||
pdraw = psc->driScreen->createDrawable(psc, drawable, gc);
|
||||
|
||||
return &pdraw->driDrawable;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue