/**
 * Composite a sub-rectangle of a VdpBitmapSurface into a sub-rectangle of
 * a VdpOutputSurface; Output Surface object VdpOutputSurface.
 */
VdpStatus
vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface,
                                      VdpRect const *destination_rect,
                                      VdpBitmapSurface source_surface,
                                      VdpRect const *source_rect,
                                      VdpColor const *colors,
                                      VdpOutputSurfaceRenderBlendState const *blend_state,
                                      uint32_t flags)
{
   vlVdpOutputSurface *dst_vlsurface;
   vlVdpBitmapSurface *src_vlsurface;

   struct pipe_context *context;
   struct vl_compositor *compositor;
   struct vl_compositor_state *cstate;

   struct u_rect src_rect, dst_rect;

   struct vertex4f vlcolors[4];
   void *blend;

   dst_vlsurface = vlGetDataHTAB(destination_surface);
   if (!dst_vlsurface)
      return VDP_STATUS_INVALID_HANDLE;

   src_vlsurface = vlGetDataHTAB(source_surface);
   if (!src_vlsurface)
      return VDP_STATUS_INVALID_HANDLE;

   if (dst_vlsurface->device != src_vlsurface->device)
      return VDP_STATUS_HANDLE_DEVICE_MISMATCH;

   context = dst_vlsurface->device->context;
   compositor = &dst_vlsurface->device->compositor;
   cstate = &dst_vlsurface->cstate;

   pipe_mutex_lock(dst_vlsurface->device->mutex);
   vlVdpResolveDelayedRendering(dst_vlsurface->device, NULL, NULL);

   blend = BlenderToPipe(context, blend_state);

   vl_compositor_clear_layers(cstate);
   vl_compositor_set_layer_blend(cstate, 0, blend, false);
   vl_compositor_set_rgba_layer(cstate, compositor, 0, src_vlsurface->sampler_view,
                                RectToPipe(source_rect, &src_rect), NULL,
                                ColorsToPipe(colors, flags, vlcolors));
   vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
   vl_compositor_render(cstate, compositor, dst_vlsurface->surface, NULL);

   context->delete_blend_state(context, blend);
   pipe_mutex_unlock(dst_vlsurface->device->mutex);

   return VDP_STATUS_OK;
}
Exemplo n.º 2
0
/**
 * Composite a sub-rectangle of a VdpOutputSurface into a sub-rectangle of
 * another VdpOutputSurface; Output Surface object VdpOutputSurface.
 */
VdpStatus
vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface,
                                      VdpRect const *destination_rect,
                                      VdpOutputSurface source_surface,
                                      VdpRect const *source_rect,
                                      VdpColor const *colors,
                                      VdpOutputSurfaceRenderBlendState const *blend_state,
                                      uint32_t flags)
{
   vlVdpOutputSurface *dst_vlsurface;
   vlVdpOutputSurface *src_vlsurface;

   struct pipe_context *context;
   struct vl_compositor *compositor;

   struct pipe_video_rect src_rect;
   struct pipe_video_rect dst_rect;

   void *blend;

   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Composing output surfaces\n");

   dst_vlsurface = vlGetDataHTAB(destination_surface);
   if (!dst_vlsurface)
      return VDP_STATUS_INVALID_HANDLE;

   src_vlsurface = vlGetDataHTAB(source_surface);
   if (!src_vlsurface)
      return VDP_STATUS_INVALID_HANDLE;

   if (dst_vlsurface->device != src_vlsurface->device)
      return VDP_STATUS_HANDLE_DEVICE_MISMATCH;

   context = dst_vlsurface->device->context->pipe;
   compositor = &dst_vlsurface->device->compositor;

   blend = BlenderToPipe(context, blend_state);

   vl_compositor_clear_layers(compositor);
   vl_compositor_set_layer_blend(compositor, 0, blend, false);
   vl_compositor_set_rgba_layer(compositor, 0, src_vlsurface->sampler_view,
                                RectToPipe(source_rect, &src_rect), NULL);
   vl_compositor_render(compositor, dst_vlsurface->surface,
                        RectToPipe(destination_rect, &dst_rect), NULL, false);

   context->delete_blend_state(context, blend);

   return VDP_STATUS_OK;
}