ilo: replace a boolean by bool
[mesa.git] / src / gallium / state_trackers / xvmc / surface.c
index 834841cb3a0666410cbc83840d0059539f6f9eb1..6a895aaed6bb41864fe080ab10636d303153c0a3 100644 (file)
@@ -37,8 +37,7 @@
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
 #include "util/u_math.h"
-
-#include "vl_winsys.h"
+#include "vl/vl_winsys.h"
 
 #include "xvmc_private.h"
 
@@ -349,13 +348,18 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
 
    struct pipe_context *pipe;
    struct vl_compositor *compositor;
+   struct vl_compositor_state *cstate;
 
    XvMCSurfacePrivate *surface_priv;
    XvMCContextPrivate *context_priv;
    XvMCSubpicturePrivate *subpicture_priv;
    XvMCContext *context;
-   struct pipe_video_rect src_rect = {srcx, srcy, srcw, srch};
-   struct pipe_video_rect dst_rect = {destx, desty, destw, desth};
+   struct u_rect src_rect = {srcx, srcx + srcw, srcy, srcy + srch};
+   struct u_rect dst_rect = {destx, destx + destw, desty, desty + desth};
+
+   struct pipe_resource *tex;
+   struct pipe_surface surf_templ, *surf;
+   struct u_rect *dirty_area;
 
    XVMC_MSG(XVMC_TRACE, "[XvMC] Displaying surface %p.\n", surface);
 
@@ -375,26 +379,16 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
    subpicture_priv = surface_priv->subpicture ? surface_priv->subpicture->privData : NULL;
    pipe = context_priv->pipe;
    compositor = &context_priv->compositor;
+   cstate = &context_priv->cstate;
 
-   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) {
-
-      struct pipe_surface surf_templ;
-      struct pipe_resource *tex = vl_screen_texture_from_drawable(
-         context_priv->vscreen, drawable);
+   tex = vl_screen_texture_from_drawable(context_priv->vscreen, drawable);
+   dirty_area = vl_screen_get_dirty_area(context_priv->vscreen);
 
-      pipe_surface_reference(&context_priv->drawable_surface, NULL);
-
-      memset(&surf_templ, 0, sizeof(surf_templ));
-      surf_templ.format = tex->format;
-      surf_templ.usage = PIPE_BIND_RENDER_TARGET;
-      context_priv->drawable_surface = pipe->create_surface(pipe, tex, &surf_templ);
-      vl_compositor_reset_dirty_area(&context_priv->dirty_area);
-      context_priv->dst_rect = dst_rect;
-   }
+   memset(&surf_templ, 0, sizeof(surf_templ));
+   surf_templ.format = tex->format;
+   surf = pipe->create_surface(pipe, tex, &surf_templ);
 
-   if (!context_priv->drawable_surface)
+   if (!surf)
       return BadDrawable;
 
    /*
@@ -413,8 +407,8 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
 
    context_priv->decoder->flush(context_priv->decoder);
 
-   vl_compositor_clear_layers(compositor);
-   vl_compositor_set_buffer_layer(compositor, 0, surface_priv->video_buffer,
+   vl_compositor_clear_layers(cstate);
+   vl_compositor_set_buffer_layer(cstate, compositor, 0, surface_priv->video_buffer,
                                   &src_rect, NULL, VL_COMPOSITOR_WEAVE);
 
    if (subpicture_priv) {
@@ -423,11 +417,11 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
       assert(subpicture_priv->surface == surface);
 
       if (subpicture_priv->palette)
-         vl_compositor_set_palette_layer(compositor, 1, subpicture_priv->sampler, subpicture_priv->palette,
+         vl_compositor_set_palette_layer(cstate, compositor, 1, subpicture_priv->sampler, subpicture_priv->palette,
                                          &subpicture_priv->src_rect, &subpicture_priv->dst_rect, true);
       else
-         vl_compositor_set_rgba_layer(compositor, 1, subpicture_priv->sampler,
-                                      &subpicture_priv->src_rect, &subpicture_priv->dst_rect);
+         vl_compositor_set_rgba_layer(cstate, compositor, 1, subpicture_priv->sampler,
+                                      &subpicture_priv->src_rect, &subpicture_priv->dst_rect, NULL);
 
       surface_priv->subpicture = NULL;
       subpicture_priv->surface = NULL;
@@ -436,15 +430,17 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
    // Workaround for r600g, there seems to be a bug in the fence refcounting code
    pipe->screen->fence_reference(pipe->screen, &surface_priv->fence, NULL);
 
-   vl_compositor_render(compositor, context_priv->drawable_surface, &dst_rect, NULL, &context_priv->dirty_area);
+   vl_compositor_set_layer_dst_area(cstate, 0, &dst_rect);
+   vl_compositor_set_layer_dst_area(cstate, 1, &dst_rect);
+   vl_compositor_render(cstate, compositor, surf, dirty_area, true);
 
-   pipe->flush(pipe, &surface_priv->fence);
+   pipe->flush(pipe, &surface_priv->fence, 0);
 
    XVMC_MSG(XVMC_TRACE, "[XvMC] Submitted surface %p for display. Pushing to front buffer.\n", surface);
 
    pipe->screen->flush_frontbuffer
    (
-      pipe->screen, context_priv->drawable_surface->texture, 0, 0,
+      pipe->screen, tex, 0, 0,
       vl_screen_get_private(context_priv->vscreen)
    );