Bool DRIFinishScreenInit(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); /* Allocate zero sized private area for each window. Should a window * become a DRI window, we'll hang a DRIWindowPrivateRec off of this * private index. */ if (!AllocateWindowPrivate(pScreen, DRIWindowPrivIndex, 0)) return FALSE; /* Wrap DRI support */ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree; pScreen->ValidateTree = DRIValidateTree; pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree; pScreen->PostValidateTree = DRIPostValidateTree; pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures; pScreen->WindowExposures = DRIWindowExposures; pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow; pScreen->CopyWindow = DRICopyWindow; pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify; pScreen->ClipNotify = DRIClipNotify; ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum); return TRUE; }
void DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) { ScreenPtr pScreen; DRIScreenPrivPtr pDRIPriv; if (pParent) { pScreen = pParent->drawable.pScreen; } else { pScreen = pChild->drawable.pScreen; } pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (pDRIPriv->wrap.PostValidateTree) { /* unwrap */ pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree; /* call lower layers */ (*pScreen->PostValidateTree)(pParent, pChild, kind); /* rewrap */ pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree; pScreen->PostValidateTree = DRIPostValidateTree; } }
Bool DRIFinishScreenInit(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); /* Wrap DRI support */ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree; pScreen->ValidateTree = DRIValidateTree; pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree; pScreen->PostValidateTree = DRIPostValidateTree; pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures; pScreen->WindowExposures = DRIWindowExposures; pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow; pScreen->CopyWindow = DRICopyWindow; pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify; pScreen->ClipNotify = DRIClipNotify; // ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum); return DRIWrapInit(pScreen); }
void DRICloseScreen(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (pDRIPriv && pDRIPriv->directRenderingSupport) { xfree(pDRIPriv); pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; } }
void DRICloseScreen(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (pDRIPriv && pDRIPriv->directRenderingSupport) { xfree(pDRIPriv); dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); } }
Bool DRIAuthConnection(ScreenPtr pScreen, unsigned int magic) { #if 0 /* FIXME: something? */ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE; #endif return TRUE; }
Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (pDRIPriv) *isCapable = pDRIPriv->directRenderingSupport; else *isCapable = FALSE; return TRUE; }
/* * 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; }
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; }
void DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg) { ScreenPtr pScreen = pWin->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); if (pDRIDrawablePriv) { /* FIXME: something? */ } pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures; (*pScreen->WindowExposures)(pWin, prgn, bsreg); pScreen->WindowExposures = DRIWindowExposures; }
int DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) { ScreenPtr pScreen = pParent->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); int returnValue; /* unwrap */ pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree; /* call lower layers */ returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind); /* rewrap */ pScreen->ValidateTree = DRIValidateTree; return returnValue; }
void DRIClipNotify(WindowPtr pWin, int dx, int dy) { ScreenPtr pScreen = pWin->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIDrawablePrivPtr pDRIDrawablePriv; if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable); } if (pDRIPriv->wrap.ClipNotify) { pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify; (*pScreen->ClipNotify)(pWin, dx, dy); pScreen->ClipNotify = DRIClipNotify; } }
void DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { ScreenPtr pScreen = pWin->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIDrawablePrivPtr pDRIDrawablePriv; if (pDRIPriv->nrWindows > 0) { pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); if (pDRIDrawablePriv != NULL) { DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable); } } /* unwrap */ pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow; /* call lower layers */ (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); /* rewrap */ pScreen->CopyWindow = DRICopyWindow; }
/* This lets us get at the unwrapped functions so that they can correctly * call the lower level functions, and choose whether they will be * called at every level of recursion (eg in validatetree). */ DRIWrappedFuncsRec * DRIGetWrappedFuncs(ScreenPtr pScreen) { return &(DRI_SCREEN_PRIV(pScreen)->wrap); }
Bool DRICreateSurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, xp_client_id client_id, xp_surface_id *surface_id, unsigned int ret_key[2], void (*notify) (void *arg, void *data), void *notify_data) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIDrawablePrivPtr pDRIDrawablePriv; xp_window_id wid = 0; if (pDrawable->type == DRAWABLE_WINDOW) { WindowPtr pWin = (WindowPtr)pDrawable; pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); if (pDRIDrawablePriv == NULL) { xp_error err; xp_window_changes wc; /* allocate a DRI Window Private record */ if (!(pDRIDrawablePriv = xalloc(sizeof(DRIDrawablePrivRec)))) { return FALSE; } pDRIDrawablePriv->pDraw = pDrawable; pDRIDrawablePriv->pScreen = pScreen; pDRIDrawablePriv->refCount = 0; pDRIDrawablePriv->drawableIndex = -1; pDRIDrawablePriv->notifiers = NULL; /* find the physical window */ wid = (xp_window_id) RootlessFrameForWindow(pWin, TRUE); if (wid == 0) { xfree(pDRIDrawablePriv); return FALSE; } /* allocate the physical surface */ err = xp_create_surface(wid, &pDRIDrawablePriv->sid); if (err != Success) { xfree(pDRIDrawablePriv); return FALSE; } /* Make it visible */ wc.stack_mode = XP_MAPPED_ABOVE; wc.sibling = 0; err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc); if (err != Success) { xp_destroy_surface(pDRIDrawablePriv->sid); xfree(pDRIDrawablePriv); return FALSE; } /* save private off of preallocated index */ pWin->devPrivates[DRIWindowPrivIndex].ptr = (pointer)pDRIDrawablePriv; } } #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 else if (pDrawable->type == DRAWABLE_PIXMAP) { PixmapPtr pPix = (PixmapPtr)pDrawable; pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix); if (pDRIDrawablePriv == NULL) { xp_error err; /* allocate a DRI Window Private record */ if (!(pDRIDrawablePriv = xcalloc(1, sizeof(DRIDrawablePrivRec)))) { return FALSE; } pDRIDrawablePriv->pDraw = pDrawable; pDRIDrawablePriv->pScreen = pScreen; pDRIDrawablePriv->refCount = 0; pDRIDrawablePriv->drawableIndex = -1; pDRIDrawablePriv->notifiers = NULL; /* Passing a null window id to Xplugin in 10.3+ asks for an accelerated offscreen surface. */ err = xp_create_surface(0, &pDRIDrawablePriv->sid); if (err != Success) { xfree(pDRIDrawablePriv); return FALSE; } /* save private off of preallocated index */ pPix->devPrivates[DRIPixmapPrivIndex].ptr = (pointer)pDRIDrawablePriv; } } #endif else { /* for GLX 1.3, a PBuffer */ /* NOT_DONE */ return FALSE; } /* Finish initialization of new surfaces */ if (pDRIDrawablePriv->refCount == 0) { unsigned int key[2] = {0}; xp_error err; /* try to give the client access to the surface */ if (client_id != 0 && wid != 0) { err = xp_export_surface(wid, pDRIDrawablePriv->sid, client_id, key); if (err != Success) { xp_destroy_surface(pDRIDrawablePriv->sid); xfree(pDRIDrawablePriv); return FALSE; } } pDRIDrawablePriv->key[0] = key[0]; pDRIDrawablePriv->key[1] = key[1]; ++pDRIPriv->nrWindows; /* and stash it by surface id */ if (surface_hash == NULL) surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL); x_hash_table_insert(surface_hash, (void *) pDRIDrawablePriv->sid, pDRIDrawablePriv); /* track this in case this window is destroyed */ AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable); /* Initialize shape */ DRIUpdateSurface(pDRIDrawablePriv, pDrawable); } pDRIDrawablePriv->refCount++; *surface_id = pDRIDrawablePriv->sid; if (ret_key != NULL) { ret_key[0] = pDRIDrawablePriv->key[0]; ret_key[1] = pDRIDrawablePriv->key[1]; } if (notify != NULL) { pDRIDrawablePriv->notifiers = x_hook_add(pDRIDrawablePriv->notifiers, notify, notify_data); } return TRUE; }
Bool DRICreateSurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, xp_client_id client_id, xp_surface_id *surface_id, unsigned int ret_key[2], void (*notify) (void *arg, void *data), void *notify_data) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); xp_window_id wid = 0; DRIDrawablePrivPtr pDRIDrawablePriv; if (pDrawable->type == DRAWABLE_WINDOW) { pDRIDrawablePriv = CreateSurfaceForWindow(pScreen, (WindowPtr)pDrawable, &wid); if(NULL == pDRIDrawablePriv) return FALSE; /*error*/ } #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 else if (pDrawable->type == DRAWABLE_PIXMAP) { pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen, (PixmapPtr)pDrawable); if(NULL == pDRIDrawablePriv) return FALSE; /*error*/ } #endif else { /* for GLX 1.3, a PBuffer */ /* NOT_DONE */ return FALSE; } /* Finish initialization of new surfaces */ if (pDRIDrawablePriv->refCount == 0) { unsigned int key[2] = {0}; xp_error err; /* try to give the client access to the surface */ if (client_id != 0) { /* * Xplugin accepts a 0 wid if the surface id is offscreen, such * as for a pixmap. */ err = xp_export_surface(wid, pDRIDrawablePriv->sid, client_id, key); if (err != Success) { xp_destroy_surface(pDRIDrawablePriv->sid); xfree(pDRIDrawablePriv); /* * Now set the dix privates to NULL that were previously set. * This prevents reusing an invalid pointer. */ if(pDrawable->type == DRAWABLE_WINDOW) { WindowPtr pWin = (WindowPtr)pDrawable; dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL); } else if(pDrawable->type == DRAWABLE_PIXMAP) { PixmapPtr pPix = (PixmapPtr)pDrawable; dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL); } return FALSE; } } pDRIDrawablePriv->key[0] = key[0]; pDRIDrawablePriv->key[1] = key[1]; ++pDRIPriv->nrWindows; /* and stash it by surface id */ if (surface_hash == NULL) surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL); x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(pDRIDrawablePriv->sid), pDRIDrawablePriv); /* track this in case this window is destroyed */ AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable); /* Initialize shape */ DRIUpdateSurface(pDRIDrawablePriv, pDrawable); } pDRIDrawablePriv->refCount++; *surface_id = pDRIDrawablePriv->sid; if (ret_key != NULL) { ret_key[0] = pDRIDrawablePriv->key[0]; ret_key[1] = pDRIDrawablePriv->key[1]; } if (notify != NULL) { pDRIDrawablePriv->notifiers = x_hook_add(pDRIDrawablePriv->notifiers, notify, notify_data); } return TRUE; }