Drop createDrawable and destroyDrawable fron DRIinterfaceMethods.
authorKristian Høgsberg <krh@hinata.boston.redhat.com>
Thu, 10 May 2007 21:14:38 +0000 (17:14 -0400)
committerKristian Høgsberg <krh@redhat.com>
Wed, 10 Oct 2007 21:07:26 +0000 (17:07 -0400)
All the DRI driver did was call the createDrawable callback immediately
upon entry to DRIscreen::createNewDrawable to get the drm_drawable_t.
We can just call that before calling into the DRI driver and pass the
returned drm_drawable_t as an argument to the DRI entry point.

Likewise for destroyDrawable.

Also, DRIdrawablePrivate::draw isn't used anywhere, and since the
driver no longer needs the XID of the drawable we can now drop that.

include/GL/internal/dri_interface.h
src/glx/x11/glxcmds.c
src/glx/x11/glxext.c
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/dri_util.h
src/mesa/drivers/dri/mga/mgastate.c

index 8a6984de68a35238c2ad66123091cb77a6a10380..0f90f49507a968fe00b693d8f1b6f6a724885204 100644 (file)
@@ -194,22 +194,11 @@ struct __DRIinterfaceMethodsRec {
      */
     GLboolean (* destroyContext)( __DRIscreen *screen, __DRIid context );
 
-    /**
-     * Create the server-side portion of the drawable.
-     */
-    GLboolean (*createDrawable)( __DRIscreen *screen,
-        __DRIid drawable, drm_drawable_t * hHWDrawable );
-
-    /**
-     * Destroy the server-side portion of the drawable.
-     */
-    GLboolean (*destroyDrawable)( __DRIscreen *screen, __DRIid drawable );
-
     /**
      * This function is used to get information about the position, size, and
      * clip rects of a drawable.
      */
-    GLboolean (* getDrawableInfo) ( __DRIscreen *screen, __DRIid drawable,
+    GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
        unsigned int * index, unsigned int * stamp,
         int * x, int * y, int * width, int * height,
         int * numClipRects, drm_clip_rect_t ** pClipRects,
@@ -303,7 +292,8 @@ struct __DRIscreenRec {
      */
     void *(*createNewDrawable)(__DRIscreen *screen,
                               const __GLcontextModes *modes,
-                              __DRIid draw, __DRIdrawable *pdraw,
+                              __DRIdrawable *pdraw,
+                              drm_drawable_t hwDrawable,
                               int renderType, const int *attrs);
 
     /**
index 45ee93c5c3a6263634956dbfa20c735638a026d8..229da5a584ed6e414d9c869a76c50a2af473a4af 100644 (file)
@@ -85,7 +85,7 @@ static void GarbageCollectDRIDrawables(Display *dpy, int screen)
     __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
     __GLXscreenConfigs *sc;
     __DRIid draw;
-    __DRIdrawable *pdraw;
+    __GLXdrawable *pdraw;
     XWindowAttributes xwa;
     int (*oldXErrorHandler)(Display *, XErrorEvent *);
 
@@ -105,7 +105,8 @@ static void GarbageCollectDRIDrawables(Display *dpy, int screen)
            if (!windowExistsFlag) {
                /* Destroy the local drawable data, if the drawable no
                   longer exists in the Xserver */
-               (*pdraw->destroyDrawable)(pdraw->private);
+               (*pdraw->driDrawable.destroyDrawable)(pdraw->driDrawable.private);
+               XF86DRIDestroyDrawable(dpy, sc->scr, draw);
                Xfree(pdraw);
            }
        } while (__glxHashNext(sc->drawHash, &draw, (void *)&pdraw) == 1);
index 2ff73685e374daa8ac81cd8a6af60b304af18063..dce01d5528df3254675384384862002e42ad4287 100644 (file)
@@ -796,39 +796,19 @@ __glXDRIDestroyContext(__DRIscreen  *screen, __DRIid context_id)
 }
 
 static GLboolean
-__glXDRICreateDrawable( __DRIscreen *screen,
-                       __DRIid drawable, drm_drawable_t *hHWDrawable )
-{
-    __GLXscreenConfigs *psc =
-       containerOf(screen, __GLXscreenConfigs, driScreen);
-    Display *dpy = psc->dpy;
-
-    return XF86DRICreateDrawable(dpy, psc->scr, drawable, hHWDrawable);
-}
-
-static GLboolean
-__glXDRIDestroyDrawable(__DRIscreen *screen, __DRIid drawable)
-{
-    __GLXscreenConfigs *psc =
-       containerOf(screen, __GLXscreenConfigs, driScreen);
-    Display *dpy = psc->dpy;
-
-    return XF86DRIDestroyDrawable(dpy, psc->scr, drawable);
-}
-
-static GLboolean
-__glXDRIGetDrawableInfo(__DRIscreen *screen, __DRIid drawable,
+__glXDRIGetDrawableInfo(__DRIdrawable *drawable,
                        unsigned int *index, unsigned int *stamp, 
                        int *X, int *Y, int *W, int *H,
                        int *numClipRects, drm_clip_rect_t ** pClipRects,
                        int *backX, int *backY,
                        int *numBackClipRects, drm_clip_rect_t **pBackClipRects)
 {
-    __GLXscreenConfigs *psc =
-       containerOf(screen, __GLXscreenConfigs, driScreen);
+    __GLXdrawable *glxDraw =
+       containerOf(drawable, __GLXdrawable, driDrawable);
+    __GLXscreenConfigs *psc = glxDraw->psc;
     Display *dpy = psc->dpy;
 
-    return XF86DRIGetDrawableInfo(dpy, psc->scr, drawable,
+    return XF86DRIGetDrawableInfo(dpy, psc->scr, glxDraw->drawable,
                                  index, stamp, X, Y, W, H,
                                  numClipRects, pClipRects,
                                  backX, backY,
@@ -848,8 +828,6 @@ static const __DRIinterfaceMethods interface_methods = {
     __glXDRICreateContext,
     __glXDRIDestroyContext,
 
-    __glXDRICreateDrawable,
-    __glXDRIDestroyDrawable,
     __glXDRIGetDrawableInfo,
 
     __glXGetUST,
@@ -1667,6 +1645,7 @@ 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;
 
     if (priv == NULL || priv->driDisplay.private == NULL)
@@ -1684,22 +1663,27 @@ FetchDRIDrawable( Display *dpy, GLXDrawable drawable, GLXContext gc)
     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,
-                                          drawable, &pdraw->driDrawable,
+                                          &pdraw->driDrawable,
+                                          hwDrawable,
                                           GLX_WINDOW_BIT,
                                           empty_attribute_list);
 
     if (!pdraw->driDrawable.private) {
-       /* ERROR!!! */
+       XF86DRIDestroyDrawable(dpy, sc->scr, drawable);
        Xfree(pdraw);
        return NULL;
     }
 
     if (__glxHashInsert(sc->drawHash, drawable, pdraw)) {
        (*pdraw->driDrawable.destroyDrawable)(pdraw->driDrawable.private);
+       XF86DRIDestroyDrawable(dpy, sc->scr, drawable);
        Xfree(pdraw);
        return NULL;
     }
index 2b5d6f0a5980ca30414c7964682c27a75ee95f91..dd7068ad1035ae3c6b4431276905b15a4ac9ff3d 100644 (file)
@@ -59,7 +59,8 @@ static int driQueryFrameTracking( void *priv,
 
 static void *driCreateNewDrawable(__DRIscreen *screen,
                                  const __GLcontextModes *modes,
-                                  __DRIid draw, __DRIdrawable *pdraw,
+                                  __DRIdrawable *pdraw,
+                                 drm_drawable_t hwDrawable,
                                   int renderType, const int *attrs);
 
 static void driDestroyDrawable(void *drawablePrivate);
@@ -286,7 +287,7 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
 
     DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
 
-    if (! (*dri_interface->getDrawableInfo)(pdp->driScreenPriv->psc, pdp->draw,
+    if (! (*dri_interface->getDrawableInfo)(pdp->pdraw,
                          &pdp->index, &pdp->lastStamp,
                          &pdp->x, &pdp->y, &pdp->w, &pdp->h,
                          &pdp->numClipRects, &pdp->pClipRects,
@@ -435,8 +436,8 @@ static void driCopySubBuffer( void *drawablePrivate,
  */
 static void *driCreateNewDrawable(__DRIscreen *screen,
                                  const __GLcontextModes *modes,
-                                 __DRIid draw,
                                  __DRIdrawable *pdraw,
+                                 drm_drawable_t hwDrawable,
                                  int renderType,
                                  const int *attrs)
 {
@@ -456,14 +457,7 @@ static void *driCreateNewDrawable(__DRIscreen *screen,
        return NULL;
     }
 
-    /* Ensure that modes->screen and screen are the same screen? */
-
-    if (!(*dri_interface->createDrawable)(screen, draw, &pdp->hHWDrawable)) {
-       _mesa_free(pdp);
-       return NULL;
-    }
-
-    pdp->draw = draw;
+    pdp->hHWDrawable = hwDrawable;
     pdp->pdraw = pdraw;
     pdp->refcount = 0;
     pdp->pStamp = NULL;
@@ -484,7 +478,6 @@ static void *driCreateNewDrawable(__DRIscreen *screen,
 
     if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, modes,
                                        renderType == GLX_PIXMAP_BIT)) {
-       (void)(*dri_interface->destroyDrawable)(screen, pdp->draw);
        _mesa_free(pdp);
        return NULL;
     }
@@ -523,7 +516,6 @@ driDestroyDrawable(void *drawablePrivate)
     if (pdp) {
        psp = pdp->driScreenPriv;
         (*psp->DriverAPI.DestroyBuffer)(pdp);
-       (void)(*dri_interface->destroyDrawable)(psp->psc, pdp->draw);
        if (pdp->pClipRects) {
            _mesa_free(pdp->pClipRects);
            pdp->pClipRects = NULL;
index cae170c5f8107efb284dd0867d1824de1d35f9df..cb9bb260512d9186eeb229fab1b6c7db75e2390c 100644 (file)
@@ -248,7 +248,6 @@ struct __DRIdrawablePrivateRec {
     /**
      * X's drawable ID associated with this private drawable.
      */
-    __DRIid draw;
     __DRIdrawable *pdraw;
 
     /**
index c20a76f29efbda1b28844b13d29d57920961b1a3..88f2175cc3e45ef3ad3008991513b3756814fdfb 100644 (file)
@@ -778,8 +778,6 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
 {
    __DRIdrawablePrivate *const driDrawable = mmesa->driDrawable;
    __DRIdrawablePrivate *const driReadable = mmesa->driReadable;
-   drm_mga_sarea_t *sarea = mmesa->sarea;
-
 
    mmesa->dirty_cliprects = 0; 
 
@@ -790,9 +788,6 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
 
    mga_set_cliprects(mmesa);
 
-   sarea->req_drawable = driDrawable->draw;
-   sarea->req_draw_buffer = mmesa->draw_buffer;
-
    mgaUpdateClipping( mmesa->glCtx );
    mgaCalcViewport( mmesa->glCtx );
 }