void DRISurfaceNotify(xp_surface_id id, int kind) { DRIDrawablePrivPtr pDRIDrawablePriv = NULL; DRISurfaceNotifyArg arg; arg.id = id; arg.kind = kind; if (surface_hash != NULL) { pDRIDrawablePriv = x_hash_table_lookup(surface_hash, (void *) id, NULL); } if (pDRIDrawablePriv == NULL) return; if (kind == AppleDRISurfaceNotifyDestroyed) { pDRIDrawablePriv->sid = 0; x_hash_table_remove(surface_hash, (void *) id); } x_hook_run(pDRIDrawablePriv->notifiers, &arg); if (kind == AppleDRISurfaceNotifyDestroyed) { /* Kill off the handle. */ FreeResourceByType(pDRIDrawablePriv->pDraw->id, DRIDrawablePrivResType, FALSE); } }
static void glxClientCallback(CallbackListPtr *list, pointer closure, pointer data) { NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; ClientPtr pClient = clientinfo->client; __GLXclientState *cl = glxGetClient(pClient); __GLXcontext *c, *next; switch (pClient->clientState) { case ClientStateRunning: cl->client = pClient; break; case ClientStateGone: /* detach from all current contexts */ for (c = glxAllContexts; c; c = next) { next = c->next; if (c->currentClient == pClient) { c->loseCurrent(c); c->currentClient = NULL; FreeResourceByType(c, __glXContextRes, FALSE); } } free(cl->returnBuf); free(cl->largeCmdBuf); free(cl->GLClientextensions); break; default: break; } }
Bool DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, void (*notify) (void *, void *), void *notify_data) { DRIDrawablePrivPtr pDRIDrawablePriv; if (pDrawable->type == DRAWABLE_WINDOW) { pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable); } else if (pDrawable->type == DRAWABLE_PIXMAP) { pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr)pDrawable); } else { return FALSE; } if (pDRIDrawablePriv != NULL) { if (notify != NULL) { pDRIDrawablePriv->notifiers = x_hook_remove(pDRIDrawablePriv->notifiers, notify, notify_data); } if (--pDRIDrawablePriv->refCount <= 0) { /* This calls back to DRIDrawablePrivDelete which frees the private area */ FreeResourceByType(id, DRIDrawablePrivResType, FALSE); } } return TRUE; }
void DRIDestroyPixmap(DrawablePtr pDrawable) { if (DRIFreePixmapImp(pDrawable)) FreeResourceByType(pDrawable->id, DRIDrawablePrivResType, FALSE); }
/* ** Destroy routine that gets called when a drawable is freed. A drawable ** contains the ancillary buffers needed for rendering. */ static Bool DrawableGone(__GLXdrawable * glxPriv, XID xid) { __GLXcontext *c, *next; if (glxPriv->type == GLX_DRAWABLE_WINDOW) { /* If this was created by glXCreateWindow, free the matching resource */ if (glxPriv->drawId != glxPriv->pDraw->id) { if (xid == glxPriv->drawId) FreeResourceByType(glxPriv->pDraw->id, __glXDrawableRes, TRUE); else FreeResourceByType(glxPriv->drawId, __glXDrawableRes, TRUE); } /* otherwise this window was implicitly created by MakeCurrent */ } for (c = glxAllContexts; c; c = next) { next = c->next; if (c->isCurrent && (c->drawPriv == glxPriv || c->readPriv == glxPriv)) { if (GET_DISPATCH()) FlushContext(c); /* Only flush if we still have a context */ (*c->loseCurrent) (c); c->isCurrent = GL_FALSE; if (c == __glXLastContext) __glXFlushContextCache(); } if (c->drawPriv == glxPriv) c->drawPriv = NULL; if (c->readPriv == glxPriv) c->readPriv = NULL; } /* drop our reference to any backing pixmap */ if (glxPriv->type == GLX_DRAWABLE_PIXMAP) glxPriv->pDraw->pScreen->DestroyPixmap((PixmapPtr) glxPriv->pDraw); glxPriv->destroy(glxPriv); return True; }
Bool DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, void (*notify)(void *, void *), void *notify_data) { DRIDrawablePrivPtr pDRIDrawablePriv; if (pDrawable->type == DRAWABLE_WINDOW) { pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable); } else if (pDrawable->type == DRAWABLE_PIXMAP) { pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr)pDrawable); } else { return FALSE; } if (pDRIDrawablePriv != NULL) { /* * This doesn't seem to be used, because notify is NULL in all callers. */ if (notify != NULL) { pDRIDrawablePriv->notifiers = x_hook_remove( pDRIDrawablePriv->notifiers, notify, notify_data); } --pDRIDrawablePriv->refCount; /* * Check if the drawable privates still have a reference to the * surface. */ if (pDRIDrawablePriv->refCount <= 0) { /* * This calls back to DRIDrawablePrivDelete which * frees the private area and dispatches events, if needed. */ FreeResourceByType(id, DRIDrawablePrivResType, FALSE); } } return TRUE; }
static int FreeDamageExt(pointer value, XID did) { DamageExtPtr pDamageExt = (DamageExtPtr) value; /* * Get rid of the resource table entry hanging from the window id */ pDamageExt->id = 0; if (WindowDrawable(pDamageExt->pDrawable->type)) FreeResourceByType(pDamageExt->pDrawable->id, DamageExtWinType, TRUE); if (pDamageExt->pDamage) { DamageUnregister(pDamageExt->pDrawable, pDamageExt->pDamage); DamageDestroy(pDamageExt->pDamage); } free(pDamageExt); return Success; }
/* * Note: this also cleans up the hash table in addition to notifying clients. * The sid/surface-id should not be used after this, because it will be * invalid. */ void DRISurfaceNotify(xp_surface_id id, int kind) { DRIDrawablePrivPtr pDRIDrawablePriv = NULL; DRISurfaceNotifyArg arg; arg.id = id; arg.kind = kind; if (surface_hash != NULL) { pDRIDrawablePriv = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(id), NULL); } if (pDRIDrawablePriv == NULL) return; if (kind == AppleDRISurfaceNotifyDestroyed) { x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(id)); } x_hook_run(pDRIDrawablePriv->notifiers, &arg); if (kind == AppleDRISurfaceNotifyDestroyed) { xp_error error; error = xp_destroy_surface(pDRIDrawablePriv->sid); if(error) ErrorF("%s: xp_destroy_surface failed: %d\n", __func__, error); /* Guard against reuse, even though we are freeing after this. */ pDRIDrawablePriv->sid = 0; FreeResourceByType(pDRIDrawablePriv->pDraw->id, DRIDrawablePrivResType, FALSE); } }