summaryrefslogtreecommitdiff
path: root/randr/rrcrtc.c
diff options
context:
space:
mode:
authoragoins <agoins@nvidia.com>2015-11-25 18:39:25 -0800
committerAdam Jackson <ajax@redhat.com>2015-12-01 13:14:51 -0500
commitcf5d6414e0c21140f763d618bde1e91ad2b1cb49 (patch)
treeffac33066b9fa661dbd3c5d447b5125b3f632941 /randr/rrcrtc.c
parentab9837cc6a11f46b9df780f131b69de3822c3dd9 (diff)
randr: Factor out shared pixmap destruction
Shared pixmap destruction is done by unrefing the master pixmap twice: once for the original reference, and once for the reference implicitly added by PixmapShareToSlave. Then, unrefing the slave pixmap once. When I add PRIME double buffering and synchronization, I will need to do this in multiple places. To avoid duplication of code and comments explaining it everywhere, factor it out into its own function and use that in place of where it was before. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Alex Goins <agoins@nvidia.com>
Diffstat (limited to 'randr/rrcrtc.c')
-rw-r--r--randr/rrcrtc.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 9bc456bdc..cbd03d000 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -361,6 +361,20 @@ RRComputeContiguity(ScreenPtr pScreen)
pScrPriv->discontiguous = discontiguous;
}
+static void
+rrDestroySharedPixmap(RRCrtcPtr crtc, PixmapPtr pPixmap) {
+ if (crtc->pScreen->current_master && pPixmap->master_pixmap) {
+ /*
+ * Unref the pixmap twice: once for the original reference, and once
+ * for the reference implicitly added by PixmapShareToSlave.
+ */
+ crtc->pScreen->current_master->DestroyPixmap(pPixmap->master_pixmap);
+ crtc->pScreen->current_master->DestroyPixmap(pPixmap->master_pixmap);
+ }
+
+ crtc->pScreen->DestroyPixmap(pPixmap);
+}
+
void
RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc)
{
@@ -372,14 +386,7 @@ RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc)
pScrPriv->rrCrtcSetScanoutPixmap(crtc, NULL);
if (crtc->scanout_pixmap) {
- master->StopPixmapTracking(mscreenpix, crtc->scanout_pixmap);
- /*
- * Unref the pixmap twice: once for the original reference, and once
- * for the reference implicitly added by PixmapShareToSlave.
- */
- master->DestroyPixmap(crtc->scanout_pixmap->master_pixmap);
- master->DestroyPixmap(crtc->scanout_pixmap->master_pixmap);
- crtc->pScreen->DestroyPixmap(crtc->scanout_pixmap);
+ rrDestroySharedPixmap(crtc, crtc->scanout_pixmap);
}
crtc->scanout_pixmap = NULL;
RRCrtcChanged(crtc, TRUE);