Mesa (pipe-video): xvmc: recreate drawable surface only when dst area changes

Christian König deathsimple at kemper.freedesktop.org
Wed Apr 27 08:12:35 PDT 2011


Module: Mesa
Branch: pipe-video
Commit: f3f212acf0d2fc25d3b6bd70dd1f346d97a9b25d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3f212acf0d2fc25d3b6bd70dd1f346d97a9b25d

Author: Christian König <deathsimple at vodafone.de>
Date:   Wed Apr 27 12:05:46 2011 +0200

xvmc: recreate drawable surface only when dst area changes

---

 src/gallium/state_trackers/xorg/xvmc/context.c     |    1 +
 src/gallium/state_trackers/xorg/xvmc/surface.c     |   23 ++++++++++++-------
 .../state_trackers/xorg/xvmc/xvmc_private.h        |    4 +++
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/gallium/state_trackers/xorg/xvmc/context.c b/src/gallium/state_trackers/xorg/xvmc/context.c
index f77dc09..a28c3f7 100644
--- a/src/gallium/state_trackers/xorg/xvmc/context.c
+++ b/src/gallium/state_trackers/xorg/xvmc/context.c
@@ -318,6 +318,7 @@ Status XvMCDestroyContext(Display *dpy, XvMCContext *context)
    context_priv = context->privData;
    vctx = context_priv->vctx;
    vscreen = vctx->vscreen;
+   pipe_surface_reference(&context_priv->drawable_surface, NULL);
    context_priv->decoder->destroy(context_priv->decoder);
    context_priv->compositor->destroy(context_priv->compositor);
    vl_video_destroy(vctx);
diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c
index a805158..7819fe0 100644
--- a/src/gallium/state_trackers/xorg/xvmc/surface.c
+++ b/src/gallium/state_trackers/xorg/xvmc/surface.c
@@ -488,7 +488,6 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
    XvMCContext *context;
    struct pipe_video_rect src_rect = {srcx, srcy, srcw, srch};
    struct pipe_video_rect dst_rect = {destx, desty, destw, desth};
-   struct pipe_surface *drawable_surface;
 
    XVMC_MSG(XVMC_TRACE, "[XvMC] Displaying surface %p.\n", surface);
 
@@ -501,8 +500,15 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
    context = surface_priv->context;
    context_priv = context->privData;
 
-   drawable_surface = vl_drawable_surface_get(context_priv->vctx, drawable);
-   if (!drawable_surface)
+   if (!context_priv->drawable_surface ||
+       context_priv->dst_rect.x != dst_rect.x || context_priv->dst_rect.y != dst_rect.y ||
+       context_priv->dst_rect.w != dst_rect.w || context_priv->dst_rect.h != dst_rect.h) {
+
+      context_priv->drawable_surface = vl_drawable_surface_get(context_priv->vctx, drawable);
+      context_priv->dst_rect = dst_rect;
+   }
+
+   if (!context_priv->drawable_surface)
       return BadDrawable;
 
    assert(flags == XVMC_TOP_FIELD || flags == XVMC_BOTTOM_FIELD || flags == XVMC_FRAME_PICTURE);
@@ -538,7 +544,8 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
          compositor->set_palette_layer(compositor, 1, subpicture_priv->sampler, subpicture_priv->palette,
                                        &subpicture_priv->src_rect, &subpicture_priv->dst_rect);
       else
-         compositor->set_rgba_layer(compositor, 1, subpicture_priv->sampler, &src_rect, &dst_rect);
+         compositor->set_rgba_layer(compositor, 1, subpicture_priv->sampler,
+                                    &subpicture_priv->src_rect, &subpicture_priv->dst_rect);
 
       surface_priv->subpicture = NULL;
       subpicture_priv->surface = NULL;
@@ -547,20 +554,18 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
    // Workaround for r600g, there seems to be a bug in the fence refcounting code
    vpipe->screen->fence_reference(vpipe->screen, &surface_priv->fence, NULL);
 
-   compositor->render_picture(compositor, PictureToPipe(flags), drawable_surface, &dst_rect, &surface_priv->fence);
+   compositor->render_picture(compositor, PictureToPipe(flags), context_priv->drawable_surface, &dst_rect, &surface_priv->fence);
 
    XVMC_MSG(XVMC_TRACE, "[XvMC] Submitted surface %p for display. Pushing to front buffer.\n", surface);
 
    vpipe->screen->flush_frontbuffer
    (
       vpipe->screen,
-      drawable_surface->texture,
+      context_priv->drawable_surface->texture,
       0, 0,
-      vl_contextprivate_get(context_priv->vctx, drawable_surface)
+      vl_contextprivate_get(context_priv->vctx, context_priv->drawable_surface)
    );
 
-   pipe_surface_reference(&drawable_surface, NULL);
-
    if(dump_window == -1) {
       dump_window = debug_get_num_option("XVMC_DUMP", 0);
    }
diff --git a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
index 262adac..8d26b19 100644
--- a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
+++ b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
@@ -62,6 +62,10 @@ typedef struct
 
    unsigned short subpicture_max_width;
    unsigned short subpicture_max_height;
+
+   struct pipe_video_rect dst_rect;
+   struct pipe_surface *drawable_surface;
+
 } XvMCContextPrivate;
 
 typedef struct



More information about the mesa-commit mailing list