xvmc: recreate drawable surface only when dst area changes
authorChristian König <deathsimple@vodafone.de>
Wed, 27 Apr 2011 10:05:46 +0000 (12:05 +0200)
committerChristian König <deathsimple@vodafone.de>
Wed, 27 Apr 2011 10:05:46 +0000 (12:05 +0200)
src/gallium/state_trackers/xorg/xvmc/context.c
src/gallium/state_trackers/xorg/xvmc/surface.c
src/gallium/state_trackers/xorg/xvmc/xvmc_private.h

index f77dc0906bb7bc1ac61b80c0222068bbef530e19..a28c3f7a42465fb98d9c5f966e79e658dde64df7 100644 (file)
@@ -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);
index a80515839ee9b7498f93a0a2e05bf85b0f0e0d01..7819fe0777b42f8517375827fc72f23ea1163984 100644 (file)
@@ -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);
    }
index 262adac7ab6431b53408386107828d3bde988fb0..8d26b196fdc2ed5cdb86153e06e0acfc505d3aa3 100644 (file)
@@ -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