summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-07-07 14:12:51 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-07-08 21:34:21 +0100
commit975a566bed72ddc79853b329307ed72a82df24b0 (patch)
tree8778751043b4354a84722d9379a4308923a9e8f8
parent0da1c98f660269806408af5fd08c1ab5e538082e (diff)
sna/dri: Replace the DRI2 drawable type with a devPrivate
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_dri.c79
-rw-r--r--src/sna/sna_driver.c5
2 files changed, 34 insertions, 50 deletions
diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c
index e1b5de67..fd965bc9 100644
--- a/src/sna/sna_dri.c
+++ b/src/sna/sna_dri.c
@@ -107,7 +107,6 @@ struct sna_dri_frame_event {
struct sna_dri_private {
int refcnt;
PixmapPtr pixmap;
- int width, height;
struct kgem_bo *bo;
struct sna_dri_frame_event *chain;
};
@@ -116,7 +115,6 @@ static DevPrivateKeyRec sna_client_key;
static RESTYPE frame_event_client_type;
static RESTYPE frame_event_drawable_type;
-static RESTYPE dri_drawable_type;
static inline struct sna_dri_frame_event *
to_frame_event(uintptr_t data)
@@ -197,6 +195,16 @@ static struct kgem_bo *sna_pixmap_set_dri(struct sna *sna,
return priv->gpu_bo;
}
+constant static inline void *sna_pixmap_get_dri(PixmapPtr pixmap)
+{
+ return ((void **)pixmap->devPrivates)[2];
+}
+
+static inline void *sna_pixmap_set_dri(PixmapPtr pixmap, void *ptr)
+{
+ ((void **)pixmap->devPrivates)[2] = ptr;
+}
+
static DRI2Buffer2Ptr
sna_dri_create_buffer(DrawablePtr drawable,
unsigned int attachment,
@@ -217,23 +225,16 @@ sna_dri_create_buffer(DrawablePtr drawable,
switch (attachment) {
case DRI2BufferFrontLeft:
pixmap = get_drawable_pixmap(drawable);
-
- buffer = NULL;
- dixLookupResourceByType((void **)&buffer, drawable->id,
- dri_drawable_type, NULL, DixWriteAccess);
+ buffer = sna_pixmap_get_dri(pixmap);
if (buffer) {
+ DBG(("%s: reusing front buffer attachment\n",
+ __FUNCTION__));
+
private = get_private(buffer);
- if (private->pixmap == pixmap) {
- DBG(("%s: reusing front buffer attachment\n",
- __FUNCTION__));
- assert(private->width == pixmap->drawable.width);
- assert(private->height == pixmap->drawable.height);
- private->refcnt++;
- return buffer;
- }
- FreeResourceByType(drawable->id,
- dri_drawable_type,
- FALSE);
+ assert(private->pixmap == pixmap);
+
+ private->refcnt++;
+ return buffer;
}
bo = sna_pixmap_set_dri(sna, pixmap);
@@ -323,22 +324,18 @@ sna_dri_create_buffer(DrawablePtr drawable,
buffer->flags = 0;
buffer->name = kgem_bo_flink(&sna->kgem, bo);
private->refcnt = 1;
- private->pixmap = pixmap;
- if (pixmap) {
- private->width = pixmap->drawable.width;
- private->height = pixmap->drawable.height;
- }
private->bo = bo;
+ private->pixmap = pixmap;
if (buffer->name == 0)
goto err;
- if (pixmap)
+ if (pixmap) {
+ assert(attachment == DRI2BufferFrontLeft);
+ sna_pixmap_set_dri(pixmap, buffer);
+ assert(sna_pixmap_get_dri(pixmap) == buffer);
pixmap->refcnt++;
-
- if (attachment == DRI2BufferFrontLeft &&
- AddResource(drawable->id, dri_drawable_type, buffer))
- private->refcnt++;
+ }
return buffer;
@@ -361,17 +358,18 @@ static void _sna_dri_destroy_buffer(struct sna *sna, DRI2Buffer2Ptr buffer)
if (--private->refcnt == 0) {
if (private->pixmap) {
- ScreenPtr screen = private->pixmap->drawable.pScreen;
- struct sna_pixmap *priv = sna_pixmap(private->pixmap);
+ PixmapPtr pixmap = private->pixmap;
+ struct sna_pixmap *priv = sna_pixmap(pixmap);
/* Undo the DRI markings on this pixmap */
if (priv->flush && --priv->flush == 0) {
list_del(&priv->list);
sna_accel_watch_flush(sna, -1);
- priv->pinned = private->pixmap == sna->front;
+ priv->pinned = pixmap == sna->front;
}
- screen->DestroyPixmap(private->pixmap);
+ sna_pixmap_set_dri(pixmap, NULL);
+ pixmap->drawable.pScreen->DestroyPixmap(pixmap);
}
private->bo->flush = 0;
@@ -858,17 +856,6 @@ sna_dri_frame_event_drawable_gone(void *data, XID id)
return Success;
}
-static int
-sna_dri_drawable_gone(void *data, XID id)
-{
- DBG(("%s(%ld)\n", __FUNCTION__, (long)id));
-
- _sna_dri_destroy_buffer(to_sna_from_pixmap(get_private(data)->pixmap),
- data);
-
- return Success;
-}
-
static Bool
sna_dri_register_frame_event_resource_types(void)
{
@@ -890,14 +877,6 @@ sna_dri_register_frame_event_resource_types(void)
DBG(("%s: frame_event_drawable_type=%d\n",
__FUNCTION__, frame_event_drawable_type));
- dri_drawable_type =
- CreateNewResourceType(sna_dri_drawable_gone,
- "DRI2 Drawable");
- if (!dri_drawable_type)
- return FALSE;
-
- DBG(("%s: dri_drawable_type=%d\n", __FUNCTION__, dri_drawable_type));
-
return TRUE;
}
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index d12c2b0e..e242b2fe 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -82,6 +82,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
static DevPrivateKeyRec sna_private_index;
static DevPrivateKeyRec sna_pixmap_index;
+static DevPrivateKeyRec sna_dri_index;
static DevPrivateKeyRec sna_gc_index;
static DevPrivateKeyRec sna_glyph_key;
static DevPrivateKeyRec sna_window_key;
@@ -810,6 +811,10 @@ sna_register_all_privates(void)
return FALSE;
assert(sna_pixmap_index.offset == sizeof(void*));
+ if (!dixRegisterPrivateKey(&sna_dri_index, PRIVATE_PIXMAP, 0))
+ return FALSE;
+ assert(sna_dri_index.offset == 2*sizeof(void*));
+
if (!dixRegisterPrivateKey(&sna_gc_index, PRIVATE_GC,
sizeof(FbGCPrivate)))
return FALSE;