Re: [PATCH 23/36] randr: add initial scanout pixmap support (v2)

2012-07-03 Thread Dave Airlie
On Tue, Jul 3, 2012 at 12:51 AM, Keith Packard kei...@keithp.com wrote:
 Dave Airlie airl...@gmail.com writes:

 From: Dave Airlie airl...@redhat.com

 When randr notices a crtc configuration request for a slave device,
 it checks if the slave allocated pixmap exists and is suitable,
 if not it allocates a new shared pixmap from the master, shares
 it to the slave, and starts the master tracking damage to it,
 to keep it updated from the current front pixmap.

 If the resize means the crtc is no longer used it will destroy
 the slave pixmap.

 This adds the concept of a scanout_pixmap to the randr_crtc object,
 and also adds a master pixmap pointer to the pixmap object, along
 with defining some pixmap helper functions for getting pixmap
 box/regions.

 I'd rather store the master pixmap somewhere else; it looks like you
 could stick it in the crtc pretty easily, right next to the
 scanout_pixmap member.

 Otherwise, this looks good to me.

The master_pixmap is also used in DRI2 code later for sharing, the last patch.

So it made sense to stick it in the pixmap when I had two users, I
suppose I could
try and stash it somewhere else in each user but it might get a bit ugly.

Dave.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH 23/36] randr: add initial scanout pixmap support (v2)

2012-07-03 Thread Keith Packard
Dave Airlie airl...@gmail.com writes:

 So it made sense to stick it in the pixmap when I had two users, I
 suppose I could
 try and stash it somewhere else in each user but it might get a bit
 ugly.

Meh. It's a bit weird to have it in the pixmap, but I guess it does seem
simplest.

-- 
keith.pack...@intel.com


pgpcfueRsCiux.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 23/36] randr: add initial scanout pixmap support (v2)

2012-07-02 Thread Dave Airlie
From: Dave Airlie airl...@redhat.com

When randr notices a crtc configuration request for a slave device,
it checks if the slave allocated pixmap exists and is suitable,
if not it allocates a new shared pixmap from the master, shares
it to the slave, and starts the master tracking damage to it,
to keep it updated from the current front pixmap.

If the resize means the crtc is no longer used it will destroy
the slave pixmap.

This adds the concept of a scanout_pixmap to the randr_crtc object,
and also adds a master pixmap pointer to the pixmap object, along
with defining some pixmap helper functions for getting pixmap box/regions.

v2: split out pixmap sharing to a separate function.

Signed-off-by: Dave Airlie airl...@redhat.com
---
 dix/pixmap.c|   29 +
 include/pixmap.h|3 +
 include/pixmapstr.h |   22 +++
 randr/randrstr.h|   12 
 randr/rrcrtc.c  |  171 +++
 5 files changed, 237 insertions(+)

diff --git a/dix/pixmap.c b/dix/pixmap.c
index 545ff54..993e16e 100644
--- a/dix/pixmap.c
+++ b/dix/pixmap.c
@@ -129,3 +129,32 @@ FreePixmap(PixmapPtr pPixmap)
 dixFiniPrivates(pPixmap, PRIVATE_PIXMAP);
 free(pPixmap);
 }
+
+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, slave, 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);
+
+spix-master_pixmap = pixmap;
+
+ret = slave-SetSharedPixmapBacking(spix, fd_handle);
+if (ret == FALSE) {
+   slave-DestroyPixmap(spix);
+   return NULL;
+}
+
+return spix;
+}
diff --git a/include/pixmap.h b/include/pixmap.h
index 9bb5bb7..8c523bd 100644
--- a/include/pixmap.h
+++ b/include/pixmap.h
@@ -109,4 +109,7 @@ extern _X_EXPORT PixmapPtr AllocatePixmap(ScreenPtr 
/*pScreen */ ,
 
 extern _X_EXPORT void FreePixmap(PixmapPtr /*pPixmap */ );
 
+extern _X_EXPORT PixmapPtr
+PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave);
+
 #endif  /* PIXMAP_H */
diff --git a/include/pixmapstr.h b/include/pixmapstr.h
index 0800c62..40af5c4 100644
--- a/include/pixmapstr.h
+++ b/include/pixmapstr.h
@@ -80,6 +80,28 @@ typedef struct _Pixmap {
 short screen_y;
 #endif
 unsigned usage_hint;/* see CREATE_PIXMAP_USAGE_* */
+
+PixmapPtr master_pixmap;/* pointer to master copy of pixmap for pixmap 
sharing */
 } PixmapRec;
 
+static inline void
+PixmapBox(BoxPtr box, PixmapPtr pixmap)
+{
+box-x1 = 0;
+box-x2 = pixmap-drawable.width;
+
+box-y1 = 0;
+box-y2 = pixmap-drawable.height;
+}
+
+
+static inline void
+PixmapRegionInit(RegionPtr region, PixmapPtr pixmap)
+{
+BoxRec box;
+
+PixmapBox(box, pixmap);
+RegionInit(region, box, 1);
+}
+
 #endif  /* PIXMAPSTRUCT_H */
diff --git a/randr/randrstr.h b/randr/randrstr.h
index b9edb57..f0f07c8 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -127,6 +127,8 @@ struct _rrCrtc {
 PictTransform transform;
 struct pict_f_transform f_transform;
 struct pict_f_transform f_inverse;
+
+PixmapPtr scanout_pixmap;
 };
 
 struct _rrOutput {
@@ -249,6 +251,8 @@ typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen,
 
 #endif
 
+typedef Bool (*RRCrtcSetScanoutPixmapProcPtr)(RRCrtcPtr crtc, PixmapPtr 
pixmap);
+
 typedef struct _rrScrPriv {
 /*
  * 'public' part of the structure; DDXen fill this in
@@ -272,6 +276,8 @@ typedef struct _rrScrPriv {
 RRGetPanningProcPtr rrGetPanning;
 RRSetPanningProcPtr rrSetPanning;
 #endif
+/* TODO #if RANDR_15_INTERFACE */
+RRCrtcSetScanoutPixmapProcPtr rrCrtcSetScanoutPixmap;
 
 RRProviderSetRoleProcPtr rrProviderSetRole;
 RRProviderGetPropertyProcPtr rrProviderGetProperty;
@@ -657,6 +663,12 @@ extern _X_EXPORT void
  RRCrtcInitErrorValue(void);
 
 /*
+ * Detach and free a scanout pixmap
+ */
+extern _X_EXPORT void
+ RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc);
+
+/*
  * Crtc dispatch
  */
 
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 0c596dd..29b02a9 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -367,6 +367,154 @@ RRComputeContiguity(ScreenPtr pScreen)
 pScrPriv-discontiguous = discontiguous;
 }
 
+void
+RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc)
+{
+ScreenPtr master = crtc-pScreen-current_master;
+int ret;
+PixmapPtr mscreenpix;
+rrScrPriv(crtc-pScreen);
+
+mscreenpix = master-GetScreenPixmap(master);
+
+ret = pScrPriv-rrCrtcSetScanoutPixmap(crtc, NULL);
+if (crtc-scanout_pixmap) {
+

Re: [PATCH 23/36] randr: add initial scanout pixmap support (v2)

2012-07-02 Thread Keith Packard
Dave Airlie airl...@gmail.com writes:

 From: Dave Airlie airl...@redhat.com

 When randr notices a crtc configuration request for a slave device,
 it checks if the slave allocated pixmap exists and is suitable,
 if not it allocates a new shared pixmap from the master, shares
 it to the slave, and starts the master tracking damage to it,
 to keep it updated from the current front pixmap.

 If the resize means the crtc is no longer used it will destroy
 the slave pixmap.

 This adds the concept of a scanout_pixmap to the randr_crtc object,
 and also adds a master pixmap pointer to the pixmap object, along
 with defining some pixmap helper functions for getting pixmap
 box/regions.

I'd rather store the master pixmap somewhere else; it looks like you
could stick it in the crtc pretty easily, right next to the
scanout_pixmap member.

Otherwise, this looks good to me.

-- 
keith.pack...@intel.com


pgpc4yZy7fDCR.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel