prime: clean up slave bo properly. (v3)
This is an ABI break, in that we now pass NULL to a function that hasn't accepted it before. Alex Goins had a different patch for this but it wasn't symmetrical, it freed something in a very different place than it allocated it, this attempts to retain symmetry in the releasing of the backing bo. v2: use a new toplevel API, though it still passes NULL to something that wasn't expecting it. v3: pass -1 instead of 0. Signed-off-by: Dave Airlie <airlied@redhat.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Alex Goins <agoins at nvidia.com>
This commit is contained in:
parent
aa5390aa83
commit
a6b6e8ba02
|
@ -132,6 +132,13 @@ FreePixmap(PixmapPtr pPixmap)
|
||||||
free(pPixmap);
|
free(pPixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PixmapUnshareSlavePixmap(PixmapPtr slave_pixmap)
|
||||||
|
{
|
||||||
|
int ihandle = -1;
|
||||||
|
ScreenPtr pScreen = slave_pixmap->drawable.pScreen;
|
||||||
|
pScreen->SetSharedPixmapBacking(slave_pixmap, ((void *)(long)ihandle));
|
||||||
|
}
|
||||||
|
|
||||||
PixmapPtr PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave)
|
PixmapPtr PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave)
|
||||||
{
|
{
|
||||||
PixmapPtr spix;
|
PixmapPtr spix;
|
||||||
|
|
|
@ -859,6 +859,7 @@ DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest)
|
||||||
if (pPriv->prime_slave_pixmap->master_pixmap == mpix)
|
if (pPriv->prime_slave_pixmap->master_pixmap == mpix)
|
||||||
return &pPriv->prime_slave_pixmap->drawable;
|
return &pPriv->prime_slave_pixmap->drawable;
|
||||||
else {
|
else {
|
||||||
|
PixmapUnshareSlavePixmap(pPriv->prime_slave_pixmap);
|
||||||
(*pPriv->prime_slave_pixmap->master_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap->master_pixmap);
|
(*pPriv->prime_slave_pixmap->master_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap->master_pixmap);
|
||||||
(*slave->DestroyPixmap)(pPriv->prime_slave_pixmap);
|
(*slave->DestroyPixmap)(pPriv->prime_slave_pixmap);
|
||||||
pPriv->prime_slave_pixmap = NULL;
|
pPriv->prime_slave_pixmap = NULL;
|
||||||
|
|
|
@ -1074,6 +1074,10 @@ msSetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle)
|
||||||
Bool ret;
|
Bool ret;
|
||||||
int ihandle = (int) (long) fd_handle;
|
int ihandle = (int) (long) fd_handle;
|
||||||
|
|
||||||
|
if (ihandle == -1)
|
||||||
|
if (!ms->drmmode.reverse_prime_offload_mode)
|
||||||
|
return drmmode_SetSlaveBO(ppix, &ms->drmmode, ihandle, 0, 0);
|
||||||
|
|
||||||
if (ms->drmmode.reverse_prime_offload_mode) {
|
if (ms->drmmode.reverse_prime_offload_mode) {
|
||||||
ret = glamor_back_pixmap_from_fd(ppix, ihandle,
|
ret = glamor_back_pixmap_from_fd(ppix, ihandle,
|
||||||
ppix->drawable.width,
|
ppix->drawable.width,
|
||||||
|
|
|
@ -214,6 +214,12 @@ drmmode_SetSlaveBO(PixmapPtr ppix,
|
||||||
{
|
{
|
||||||
msPixmapPrivPtr ppriv = msGetPixmapPriv(drmmode, ppix);
|
msPixmapPrivPtr ppriv = msGetPixmapPriv(drmmode, ppix);
|
||||||
|
|
||||||
|
if (fd_handle == -1) {
|
||||||
|
dumb_bo_destroy(drmmode->fd, ppriv->backing_bo);
|
||||||
|
ppriv->backing_bo = NULL;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
ppriv->backing_bo =
|
ppriv->backing_bo =
|
||||||
dumb_get_bo_from_fd(drmmode->fd, fd_handle, pitch, size);
|
dumb_get_bo_from_fd(drmmode->fd, fd_handle, pitch, size);
|
||||||
if (!ppriv->backing_bo)
|
if (!ppriv->backing_bo)
|
||||||
|
|
|
@ -115,6 +115,9 @@ extern _X_EXPORT void FreePixmap(PixmapPtr /*pPixmap */ );
|
||||||
extern _X_EXPORT PixmapPtr
|
extern _X_EXPORT PixmapPtr
|
||||||
PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave);
|
PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave);
|
||||||
|
|
||||||
|
extern _X_EXPORT void
|
||||||
|
PixmapUnshareSlavePixmap(PixmapPtr slave_pixmap);
|
||||||
|
|
||||||
#define HAS_DIRTYTRACKING_ROTATION 1
|
#define HAS_DIRTYTRACKING_ROTATION 1
|
||||||
extern _X_EXPORT Bool
|
extern _X_EXPORT Bool
|
||||||
PixmapStartDirtyTracking(PixmapPtr src,
|
PixmapStartDirtyTracking(PixmapPtr src,
|
||||||
|
|
|
@ -373,6 +373,8 @@ rrDestroySharedPixmap(RRCrtcPtr crtc, PixmapPtr pPixmap) {
|
||||||
* Unref the pixmap twice: once for the original reference, and once
|
* Unref the pixmap twice: once for the original reference, and once
|
||||||
* for the reference implicitly added by PixmapShareToSlave.
|
* for the reference implicitly added by PixmapShareToSlave.
|
||||||
*/
|
*/
|
||||||
|
PixmapUnshareSlavePixmap(pPixmap);
|
||||||
|
|
||||||
master->DestroyPixmap(pPixmap->master_pixmap);
|
master->DestroyPixmap(pPixmap->master_pixmap);
|
||||||
master->DestroyPixmap(pPixmap->master_pixmap);
|
master->DestroyPixmap(pPixmap->master_pixmap);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user