diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-03-02 17:36:50 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-03-02 17:45:35 +0000 |
commit | 4f853acfeccb92885f154b03125d5716591a87bd (patch) | |
tree | 5a3fff48900b76c3ff333d59a80bb7a3e8c94b80 /src | |
parent | 866a61a2590f0c5ae6592a13d4e3de3e68f5e373 (diff) |
sna: Prevent backing pixmaps being created later
We used to allow the backing pixmap to be created later in order to
accommodate ShmPixmaps and ShmPutImage. However, they are now correctly
handled upfront if we choose to accelerate those paths, and so all
choice over whether to attach to a pixmap are made during creation and
are invariant.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna.h | 12 | ||||
-rw-r--r-- | src/sna/sna_accel.c | 61 | ||||
-rw-r--r-- | src/sna/sna_blt.c | 2 | ||||
-rw-r--r-- | src/sna/sna_render.c | 4 |
4 files changed, 10 insertions, 69 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h index c772d7d3..1196cceb 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -415,18 +415,6 @@ static inline Bool pixmap_is_scanout(PixmapPtr pixmap) return pixmap == screen->GetScreenPixmap(screen); } -struct sna_pixmap *_sna_pixmap_attach(PixmapPtr pixmap); -inline static struct sna_pixmap *sna_pixmap_attach(PixmapPtr pixmap) -{ - struct sna_pixmap *priv; - - priv = sna_pixmap(pixmap); - if (priv) - return priv; - - return _sna_pixmap_attach(pixmap); -} - PixmapPtr sna_pixmap_create_upload(ScreenPtr screen, int width, int height, int depth, unsigned flags); diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index c427808c..fc44b471 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -523,8 +523,7 @@ _sna_pixmap_reset(PixmapPtr pixmap) return _sna_pixmap_init(priv, pixmap); } -static struct sna_pixmap *__sna_pixmap_attach(struct sna *sna, - PixmapPtr pixmap) +static struct sna_pixmap *sna_pixmap_attach(struct sna *sna, PixmapPtr pixmap) { struct sna_pixmap *priv; @@ -536,50 +535,6 @@ static struct sna_pixmap *__sna_pixmap_attach(struct sna *sna, return _sna_pixmap_init(priv, pixmap); } -struct sna_pixmap *_sna_pixmap_attach(PixmapPtr pixmap) -{ - struct sna *sna = to_sna_from_pixmap(pixmap); - struct sna_pixmap *priv; - - DBG(("%s: serial=%ld, %dx%d, usage=%d\n", - __FUNCTION__, - pixmap->drawable.serialNumber, - pixmap->drawable.width, - pixmap->drawable.height, - pixmap->usage_hint)); - - switch (pixmap->usage_hint) { - case CREATE_PIXMAP_USAGE_GLYPH_PICTURE: - DBG(("%s: not attaching due to crazy usage: %d\n", - __FUNCTION__, pixmap->usage_hint)); - return NULL; - - case SNA_CREATE_FB: - /* We assume that the Screen pixmap will be pre-validated */ - break; - - default: - if (!kgem_can_create_2d(&sna->kgem, - pixmap->drawable.width, - pixmap->drawable.height, - pixmap->drawable.depth)) - return NULL; - break; - } - - priv = __sna_pixmap_attach(sna, pixmap); - if (priv == NULL) - return NULL; - - DBG(("%s: created priv and marking all cpu damaged\n", __FUNCTION__)); - - sna_damage_all(&priv->cpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); - - return priv; -} - static inline PixmapPtr create_pixmap(struct sna *sna, ScreenPtr screen, int width, int height, int depth, @@ -647,7 +602,7 @@ sna_pixmap_create_shm(ScreenPtr screen, pixmap->drawable.depth = depth; pixmap->drawable.bitsPerPixel = bpp; - priv = __sna_pixmap_attach(sna, pixmap); + priv = sna_pixmap_attach(sna, pixmap); if (!priv) { fbDestroyPixmap(pixmap); return NullPixmap; @@ -729,7 +684,7 @@ sna_pixmap_create_scratch(ScreenPtr screen, pixmap->drawable.depth = depth; pixmap->drawable.bitsPerPixel = bpp; - priv = __sna_pixmap_attach(sna, pixmap); + priv = sna_pixmap_attach(sna, pixmap); if (!priv) { fbDestroyPixmap(pixmap); return NullPixmap; @@ -770,9 +725,7 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, usage = -1; goto fallback; } - - if (!sna->have_render) - goto fallback; + assert(width && height); flags = kgem_can_create_2d(&sna->kgem, width, height, depth); if (flags == 0) { @@ -811,7 +764,7 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, if (pixmap == NullPixmap) return NullPixmap; - __sna_pixmap_attach(sna, pixmap); + sna_pixmap_attach(sna, pixmap); } else { struct sna_pixmap *priv; @@ -827,7 +780,7 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, pixmap->devKind = pad; pixmap->devPrivate.ptr = NULL; - priv = __sna_pixmap_attach(sna, pixmap); + priv = sna_pixmap_attach(sna, pixmap); if (priv == NULL) { free(pixmap); goto fallback; @@ -2080,7 +2033,7 @@ sna_pixmap_force_to_gpu(PixmapPtr pixmap, unsigned flags) DBG(("%s(pixmap=%p)\n", __FUNCTION__, pixmap)); - priv = sna_pixmap_attach(pixmap); + priv = sna_pixmap(pixmap); if (priv == NULL) return NULL; diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 8c51a77c..84207302 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -1395,7 +1395,7 @@ prepare_blt_put(struct sna *sna, op->done = nop_done; src_bo = NULL; - priv = _sna_pixmap_attach(src); + priv = sna_pixmap(src); if (priv) src_bo = priv->cpu_bo; if (src_bo) { diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c index 572d6ea7..0266ea44 100644 --- a/src/sna/sna_render.c +++ b/src/sna/sna_render.c @@ -375,7 +375,7 @@ move_to_gpu(PixmapPtr pixmap, const BoxRec *box) if (w == pixmap->drawable.width && h == pixmap->drawable.height) { bool upload; - priv = sna_pixmap_attach(pixmap); + priv = sna_pixmap(pixmap); if (!priv) return false; @@ -400,7 +400,7 @@ move_to_gpu(PixmapPtr pixmap, const BoxRec *box) if (64*w*h < pixmap->drawable.width * pixmap->drawable.height) return FALSE; - priv = sna_pixmap_attach(pixmap); + priv = sna_pixmap(pixmap); if (!priv) return FALSE; |