Example #1
0
/*
 * The assumption is that this is called when the refCount of a surface
 * drops to <= 0, or the window/pixmap is destroyed.
 */
Bool
DRIDrawablePrivDelete(pointer pResource, XID id)
{
    DrawablePtr pDrawable = (DrawablePtr)pResource;
    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen);
    DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
    WindowPtr pWin = NULL;
    PixmapPtr pPix = NULL;

    if (pDrawable->type == DRAWABLE_WINDOW) {
        pWin = (WindowPtr)pDrawable;
        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
    }
    else if (pDrawable->type == DRAWABLE_PIXMAP) {
        pPix = (PixmapPtr)pDrawable;
        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
    }

    if (pDRIDrawablePriv == NULL) {
        /*
         * We reuse __func__ and the resource type for the GLXPixmap code.
         * Attempt to free a pixmap buffer associated with the resource
         * if possible.
         */
        return DRIFreePixmapImp(pDrawable);
    }

    if (pDRIDrawablePriv->drawableIndex != -1) {
        /* release drawable table entry */
        pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
    }

    if (pDRIDrawablePriv->sid != 0) {
        DRISurfaceNotify(pDRIDrawablePriv->sid,
                         AppleDRISurfaceNotifyDestroyed);
    }

    if (pDRIDrawablePriv->notifiers != NULL)
        x_hook_free(pDRIDrawablePriv->notifiers);

    free(pDRIDrawablePriv);

    if (pDrawable->type == DRAWABLE_WINDOW) {
        dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
    }
    else if (pDrawable->type == DRAWABLE_PIXMAP) {
        dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
    }

    --pDRIPriv->nrWindows;

    return TRUE;
}
Example #2
0
File: dri.c Project: L3oV1nc3/VMGL
Bool
DRIDrawablePrivDelete(pointer pResource, XID id)
{
    DrawablePtr         pDrawable = (DrawablePtr)pResource;
    DRIScreenPrivPtr    pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen);
    DRIDrawablePrivPtr  pDRIDrawablePriv = NULL;
    WindowPtr           pWin = NULL;
    PixmapPtr           pPix = NULL;

    if (pDrawable->type == DRAWABLE_WINDOW) {
        pWin = (WindowPtr)pDrawable;
        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
    } else if (pDrawable->type == DRAWABLE_PIXMAP) {
        pPix = (PixmapPtr)pDrawable;
        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
    }

    if (pDRIDrawablePriv == NULL) {
	return DRIFreePixmapImp(pDrawable);
    }

    if (pDRIDrawablePriv->drawableIndex != -1) {
        /* release drawable table entry */
        pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
    }

    if (pDRIDrawablePriv->sid != 0) {
        xp_destroy_surface(pDRIDrawablePriv->sid);
        x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(pDRIDrawablePriv->sid));
    }

    if (pDRIDrawablePriv->notifiers != NULL)
        x_hook_free(pDRIDrawablePriv->notifiers);

    xfree(pDRIDrawablePriv);

    if (pDrawable->type == DRAWABLE_WINDOW) {
	dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
    } else if (pDrawable->type == DRAWABLE_PIXMAP) {
	dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
    }

    --pDRIPriv->nrWindows;

    return TRUE;
}