diff options
Diffstat (limited to 'src/msm-pixmap.c')
-rw-r--r-- | src/msm-pixmap.c | 79 |
1 files changed, 74 insertions, 5 deletions
diff --git a/src/msm-pixmap.c b/src/msm-pixmap.c index 7d20208..22fc006 100644 --- a/src/msm-pixmap.c +++ b/src/msm-pixmap.c @@ -33,6 +33,9 @@ #include "msm.h" +#ifdef HAVE_XA +# include <xa_tracker.h> +#endif struct fd_bo * msm_get_pixmap_bo(PixmapPtr pix) @@ -42,6 +45,19 @@ msm_get_pixmap_bo(PixmapPtr pix) if (priv && priv->bo) return priv->bo; +#ifdef HAVE_XA + /* we should only hit this path for pageflip/dri2 (in which case + * the buffer is already exported to an flink name): + */ + if (priv && priv->surf) { + MSMPtr pMsm = MSMPTR_FROM_PIXMAP(pix); + uint32_t name, stride; + xa_surface_handle(priv->surf, xa_handle_type_shared, &name, &stride); + priv->bo = fd_bo_from_name(pMsm->dev, name); + return priv->bo; + } +#endif + assert(!priv); return NULL; @@ -57,18 +73,67 @@ msm_set_pixmap_bo(PixmapPtr pix, struct fd_bo *bo) priv->bo = bo ? fd_bo_ref(bo) : NULL; if (old_bo) fd_bo_del(old_bo); +#ifdef HAVE_XA + if (priv->surf) { + xa_surface_unref(priv->surf); + priv->surf = NULL; + } + if (bo) { + MSMPtr pMsm = MSMPTR_FROM_PIXMAP(pix); + if (pMsm->xa) { + enum xa_surface_type type; + uint32_t name; + + type = (pix->drawable.bitsPerPixel > 8) ? + xa_type_argb : xa_type_a; + + fd_bo_get_name(bo, &name); + + priv->surf = xa_surface_from_handle(pMsm->xa, + pix->drawable.width, pix->drawable.height, + pix->drawable.depth, type, xa_format_unknown, + XA_FLAG_SHARED | XA_FLAG_RENDER_TARGET | XA_FLAG_SCANOUT, + name, exaGetPixmapPitch(pix)); + } + } +#endif } } +#ifdef HAVE_XA +struct xa_surface * +msm_get_pixmap_surf(PixmapPtr pix) +{ + struct msm_pixmap_priv *priv = exaGetPixmapDriverPrivate(pix); + + if (priv && priv->surf) + return priv->surf; + + return NULL; +} +#endif + int -msm_get_pixmap_name(PixmapPtr pix, unsigned int *name, unsigned int *pitch) +msm_get_pixmap_name(PixmapPtr pix, unsigned int *name, unsigned int *stride) { + MSMPtr pMsm = MSMPTR_FROM_PIXMAP(pix); int ret = -1; - struct fd_bo *bo = msm_get_pixmap_bo(pix); - if (bo) { - *pitch = exaGetPixmapPitch(pix); - ret = fd_bo_get_name(bo, name); + + if (pMsm->xa) { +#ifdef HAVE_XA + struct xa_surface *surf = msm_get_pixmap_surf(pix); + if (surf) { + ret = xa_surface_handle(surf, xa_handle_type_shared, name, stride); + } +#endif + } else { + struct fd_bo *bo = msm_get_pixmap_bo(pix); + if (bo) { + *stride = exaGetPixmapPitch(pix); + ret = fd_bo_get_name(bo, name); + } } + return ret; } @@ -78,4 +143,8 @@ msm_pixmap_exchange(PixmapPtr a, PixmapPtr b) struct msm_pixmap_priv *apriv = exaGetPixmapDriverPrivate(a); struct msm_pixmap_priv *bpriv = exaGetPixmapDriverPrivate(b); exchange(apriv->bo, bpriv->bo); + exchange(apriv->ptr, bpriv->ptr); +#ifdef HAVE_XA + exchange(apriv->surf, bpriv->surf); +#endif } |