From: Christian König Date: Wed, 27 Apr 2011 10:05:46 +0000 (+0200) Subject: xvmc: recreate drawable surface only when dst area changes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f3f212acf0d2fc25d3b6bd70dd1f346d97a9b25d;p=mesa.git xvmc: recreate drawable surface only when dst area changes --- diff --git a/src/gallium/state_trackers/xorg/xvmc/context.c b/src/gallium/state_trackers/xorg/xvmc/context.c index f77dc0906bb..a28c3f7a424 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 a80515839ee..7819fe0777b 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 262adac7ab6..8d26b196fdc 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