From: Dave Airlie <[email protected]> We need this same code for dri2, so split it out to dix.
Signed-off-by: Dave Airlie <[email protected]> --- dix/pixmap.c | 28 ++++++++++++++++++++++++++++ include/pixmap.h | 2 ++ randr/rrcrtc.c | 19 ++----------------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/dix/pixmap.c b/dix/pixmap.c index c5c2774..804038f 100644 --- a/dix/pixmap.c +++ b/dix/pixmap.c @@ -220,3 +220,31 @@ Bool PixmapSyncDirtyHelper(PixmapDirtyUpdatePtr dirty, RegionPtr dirty_region) pScreen->SourceValidate = SourceValidate; return TRUE; } + +PixmapPtr PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave) +{ + PixmapPtr spix; + int ret; + int fd_handle; + ScreenPtr master = pixmap->drawable.pScreen; + int depth = pixmap->drawable.depth; + + ret = master->SharePixmapBacking(pixmap, &fd_handle); + if (ret == FALSE) + return NULL; + + spix = slave->CreatePixmap(slave, 0, 0, depth, + CREATE_PIXMAP_USAGE_SHARED); + slave->ModifyPixmapHeader(spix, pixmap->drawable.width, + pixmap->drawable.height, depth, 0, + pixmap->devKind, NULL); + + ret = slave->SetSharedPixmapBacking(spix, fd_handle); + if (ret == FALSE) { + slave->DestroyPixmap(spix); + return NULL; + } + + spix->master_pixmap = pixmap; + return spix; +} diff --git a/include/pixmap.h b/include/pixmap.h index 6c85a2e..413c51c 100644 --- a/include/pixmap.h +++ b/include/pixmap.h @@ -125,4 +125,6 @@ PixmapStopDirtyTracking(PixmapPtr src, PixmapPtr slave_dst); extern _X_EXPORT Bool PixmapSyncDirtyHelper(PixmapDirtyUpdatePtr dirty, RegionPtr dirty_region); +extern _X_EXPORT PixmapPtr +PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave); #endif /* PIXMAP_H */ diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 1ca33a4..3a415a0 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -393,7 +393,6 @@ rrCreateSharedPixmap(RRCrtcPtr crtc, int width, int height, { PixmapPtr mpix, spix; ScreenPtr master = crtc->pScreen->current_master; - int fd_handle = -1; Bool ret; int depth; PixmapPtr mscreenpix; @@ -423,26 +422,12 @@ rrCreateSharedPixmap(RRCrtcPtr crtc, int width, int height, if (!mpix) return FALSE; - ret = master->SharePixmapBacking(mpix, &fd_handle); - if (ret == FALSE) { - master->DestroyPixmap(mpix); - return FALSE; - } - - spix = crtc->pScreen->CreatePixmap(crtc->pScreen, 0, 0, depth, - CREATE_PIXMAP_USAGE_SHARED); - crtc->pScreen->ModifyPixmapHeader(spix, width, height, depth, 0, - mpix->devKind, NULL); - - ret = crtc->pScreen->SetSharedPixmapBacking(spix, fd_handle); - if (ret == FALSE) { - ErrorF("failed to slave pixmap\n"); - crtc->pScreen->DestroyPixmap(spix); + spix = PixmapShareToSlave(mpix, crtc->pScreen); + if (spix == NULL) { master->DestroyPixmap(mpix); return FALSE; } - spix->master_pixmap = mpix; ret = pScrPriv->rrCrtcSetScanoutPixmap(crtc, spix); if (ret == FALSE) { ErrorF("failed to set shadow slave pixmap\n"); -- 1.7.10.2 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
