vl/compositor: replace pipe_video_rect with u_rect
authorChristian König <deathsimple@vodafone.de>
Sat, 25 Feb 2012 12:53:29 +0000 (13:53 +0100)
committerChristian König <deathsimple@vodafone.de>
Fri, 2 Mar 2012 12:14:21 +0000 (13:14 +0100)
So we support things like flipping also.

Signed-off-by: Christian König <deathsimple@vodafone.de>
src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/auxiliary/vl/vl_compositor.h
src/gallium/include/pipe/p_video_state.h
src/gallium/state_trackers/vdpau/mixer.c
src/gallium/state_trackers/vdpau/output.c
src/gallium/state_trackers/vdpau/presentation.c
src/gallium/state_trackers/vdpau/vdpau_private.h
src/gallium/state_trackers/xvmc/subpicture.c
src/gallium/state_trackers/xvmc/surface.c
src/gallium/state_trackers/xvmc/xvmc_private.h

index 9666ad1e0478e2a81e56099c3fa099717cedfad7..b03029805619fd473c6489fc0407fb1e148764e7 100644 (file)
@@ -528,31 +528,31 @@ cleanup_buffers(struct vl_compositor *c)
    pipe_resource_reference(&c->vertex_buf.buffer, NULL);
 }
 
-static INLINE struct pipe_video_rect
+static INLINE struct u_rect
 default_rect(struct vl_compositor_layer *layer)
 {
    struct pipe_resource *res = layer->sampler_views[0]->texture;
-   struct pipe_video_rect rect = { 0, 0, res->width0, res->height0 * res->depth0 };
+   struct u_rect rect = { 0, res->width0, 0, res->height0 * res->depth0 };
    return rect;
 }
 
 static INLINE struct vertex2f
-calc_topleft(struct vertex2f size, struct pipe_video_rect rect)
+calc_topleft(struct vertex2f size, struct u_rect rect)
 {
-   struct vertex2f res = { rect.x / size.x, rect.y / size.y };
+   struct vertex2f res = { rect.x0 / size.x, rect.y0 / size.y };
    return res;
 }
 
 static INLINE struct vertex2f
-calc_bottomright(struct vertex2f size, struct pipe_video_rect rect)
+calc_bottomright(struct vertex2f size, struct u_rect rect)
 {
-   struct vertex2f res = { (rect.x + rect.w) / size.x, (rect.y + rect.h) / size.y };
+   struct vertex2f res = { rect.x1 / size.x, rect.y1 / size.y };
    return res;
 }
 
 static INLINE void
 calc_src_and_dst(struct vl_compositor_layer *layer, unsigned width, unsigned height,
-                 struct pipe_video_rect src, struct pipe_video_rect dst)
+                 struct u_rect src, struct u_rect dst)
 {
    struct vertex2f size =  { width, height };
 
@@ -766,30 +766,30 @@ vl_compositor_set_csc_matrix(struct vl_compositor_state *s, const float matrix[1
 }
 
 void
-vl_compositor_set_dst_area(struct vl_compositor_state *s, struct pipe_video_rect *dst_area)
+vl_compositor_set_dst_area(struct vl_compositor_state *s, struct u_rect *dst_area)
 {
    assert(s);
 
    s->viewport_valid = dst_area != NULL;
    if (dst_area) {
-      s->viewport.scale[0] = dst_area->w;
-      s->viewport.scale[1] = dst_area->h;
-      s->viewport.translate[0] = dst_area->x;
-      s->viewport.translate[1] = dst_area->y;
+      s->viewport.scale[0] = dst_area->x1 - dst_area->x0;
+      s->viewport.scale[1] = dst_area->y1 - dst_area->y0;
+      s->viewport.translate[0] = dst_area->x0;
+      s->viewport.translate[1] = dst_area->y0;
    }
 }
 
 void
-vl_compositor_set_dst_clip(struct vl_compositor_state *s, struct pipe_video_rect *dst_clip)
+vl_compositor_set_dst_clip(struct vl_compositor_state *s, struct u_rect *dst_clip)
 {
    assert(s);
 
    s->scissor_valid = dst_clip != NULL;
    if (dst_clip) {
-      s->scissor.minx = dst_clip->x;
-      s->scissor.miny = dst_clip->y;
-      s->scissor.maxx = dst_clip->x + dst_clip->w;
-      s->scissor.maxy = dst_clip->y + dst_clip->h;
+      s->scissor.minx = dst_clip->x0;
+      s->scissor.miny = dst_clip->y0;
+      s->scissor.maxx = dst_clip->x1;
+      s->scissor.maxy = dst_clip->y1;
    }
 }
 
@@ -811,8 +811,8 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
                                struct vl_compositor *c,
                                unsigned layer,
                                struct pipe_video_buffer *buffer,
-                               struct pipe_video_rect *src_rect,
-                               struct pipe_video_rect *dst_rect,
+                               struct u_rect *src_rect,
+                               struct u_rect *dst_rect,
                                enum vl_compositor_deinterlace deinterlace)
 {
    struct pipe_sampler_view **sampler_views;
@@ -865,8 +865,8 @@ vl_compositor_set_palette_layer(struct vl_compositor_state *s,
                                 unsigned layer,
                                 struct pipe_sampler_view *indexes,
                                 struct pipe_sampler_view *palette,
-                                struct pipe_video_rect *src_rect,
-                                struct pipe_video_rect *dst_rect,
+                                struct u_rect *src_rect,
+                                struct u_rect *dst_rect,
                                 bool include_color_conversion)
 {
    assert(s && c && indexes && palette);
@@ -894,8 +894,8 @@ vl_compositor_set_rgba_layer(struct vl_compositor_state *s,
                              struct vl_compositor *c,
                              unsigned layer,
                              struct pipe_sampler_view *rgba,
-                             struct pipe_video_rect *src_rect,
-                             struct pipe_video_rect *dst_rect)
+                             struct u_rect *src_rect,
+                             struct u_rect *dst_rect)
 {
    assert(s && c && rgba);
 
index 8c574798591017b25982c432105b90fb0db0026a..f998a2e081c554b411666883eba4ce5162ee7316 100644 (file)
@@ -147,13 +147,13 @@ vl_compositor_get_clear_color(struct vl_compositor_state *settings, union pipe_c
  * set the destination area
  */
 void
-vl_compositor_set_dst_area(struct vl_compositor_state *settings, struct pipe_video_rect *dst_area);
+vl_compositor_set_dst_area(struct vl_compositor_state *settings, struct u_rect *dst_area);
 
 /**
  * set the destination clipping
  */
 void
-vl_compositor_set_dst_clip(struct vl_compositor_state *settings, struct pipe_video_rect *dst_clip);
+vl_compositor_set_dst_clip(struct vl_compositor_state *settings, struct u_rect *dst_clip);
 
 /**
  * set overlay samplers
@@ -181,8 +181,8 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *state,
                                struct vl_compositor *compositor,
                                unsigned layer,
                                struct pipe_video_buffer *buffer,
-                               struct pipe_video_rect *src_rect,
-                               struct pipe_video_rect *dst_rect,
+                               struct u_rect *src_rect,
+                               struct u_rect *dst_rect,
                                enum vl_compositor_deinterlace deinterlace);
 
 /**
@@ -194,8 +194,8 @@ vl_compositor_set_palette_layer(struct vl_compositor_state *state,
                                 unsigned layer,
                                 struct pipe_sampler_view *indexes,
                                 struct pipe_sampler_view *palette,
-                                struct pipe_video_rect *src_rect,
-                                struct pipe_video_rect *dst_rect,
+                                struct u_rect *src_rect,
+                                struct u_rect *dst_rect,
                                 bool include_color_conversion);
 
 /**
@@ -206,8 +206,8 @@ vl_compositor_set_rgba_layer(struct vl_compositor_state *state,
                              struct vl_compositor *compositor,
                              unsigned layer,
                              struct pipe_sampler_view *rgba,
-                             struct pipe_video_rect *src_rect,
-                             struct pipe_video_rect *dst_rect);
+                             struct u_rect *src_rect,
+                             struct u_rect *dst_rect);
 
 /*@}*/
 
index b73c94b7a5d2df57cf8f5fdcdb927f35e9b8f36f..00390d3e170ce974cf5ed490c6c81110268ff578 100644 (file)
 extern "C" {
 #endif
 
-struct pipe_video_rect
-{
-   unsigned x, y, w, h;
-};
-
 /*
  * see table 6-12 in the spec
  */
index ac0ce86beeb38457ceb7bd200d03a3c7a1c22c40..ead9323eb8ff9702dd5be9bddec69296b12c5ace 100644 (file)
@@ -204,7 +204,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
                                 uint32_t layer_count,
                                 VdpLayer const *layers)
 {
-   struct pipe_video_rect src_rect, dst_rect, dst_clip;
+   struct u_rect src_rect, dst_rect, dst_clip;
    enum vl_compositor_deinterlace deinterlace;
    unsigned layer = 0;
 
index 0583c52fe82c60782169905c71ab18b333c135ab..0ea502939c3bcb4933963bb5a8c587a7bb6d6932 100644 (file)
@@ -214,7 +214,7 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
    struct pipe_sampler_view *sv_idx = NULL, *sv_tbl = NULL;
 
    struct pipe_box box;
-   struct pipe_video_rect dst_rect;
+   struct u_rect dst_rect;
 
    vlsurface = vlGetDataHTAB(surface);
    if (!vlsurface)
@@ -448,8 +448,7 @@ vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface,
    struct vl_compositor *compositor;
    struct vl_compositor_state *cstate;
 
-   struct pipe_video_rect src_rect;
-   struct pipe_video_rect dst_rect;
+   struct u_rect src_rect, dst_rect;
 
    void *blend;
 
index 71447793f5856549990cffacf4fe0aceb26ba478..4d12bb3e700ab6394c622f92b2cac1e8ffd38fbc 100644 (file)
@@ -202,8 +202,7 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue,
    struct pipe_context *pipe;
    struct pipe_resource *tex;
    struct pipe_surface surf_templ, *surf_draw;
-   struct pipe_video_rect src_rect, dst_clip;
-   struct u_rect *dirty_area;
+   struct u_rect src_rect, dst_clip, *dirty_area;
 
    struct vl_compositor *compositor;
 
@@ -231,15 +230,15 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue,
 
    surf->timestamp = (vlVdpTime)earliest_presentation_time;
 
-   src_rect.x = 0;
-   src_rect.y = 0;
-   src_rect.w = surf_draw->width;
-   src_rect.h = surf_draw->height;
+   src_rect.x0 = 0;
+   src_rect.y0 = 0;
+   src_rect.x1 = surf_draw->width;
+   src_rect.y1 = surf_draw->height;
 
-   dst_clip.x = 0;
-   dst_clip.y = 0;
-   dst_clip.w = clip_width ? clip_width : surf_draw->width;
-   dst_clip.h = clip_height ? clip_height : surf_draw->height;
+   dst_clip.x0 = 0;
+   dst_clip.y0 = 0;
+   dst_clip.x1 = clip_width ? clip_width : surf_draw->width;
+   dst_clip.y1 = clip_height ? clip_height : surf_draw->height;
 
    vl_compositor_clear_layers(&pq->cstate);
    vl_compositor_set_rgba_layer(&pq->cstate, compositor, 0, surf->sampler_view, &src_rect, NULL);
index e74c68187d2abe1522370ebdfe82fc3837d4ea97..1b617847d4a8674f6f3fd27bdbe6f7241de89c42 100644 (file)
@@ -270,14 +270,14 @@ PipeToProfile(enum pipe_video_profile p_profile)
    }
 }
 
-static inline struct pipe_video_rect *
-RectToPipe(const VdpRect *src, struct pipe_video_rect *dst)
+static inline struct u_rect *
+RectToPipe(const VdpRect *src, struct u_rect *dst)
 {
    if (src) {
-      dst->x = MIN2(src->x1, src->x0);
-      dst->y = MIN2(src->y1, src->y0);
-      dst->w = abs(src->x1 - src->x0);
-      dst->h = abs(src->y1 - src->y0);
+      dst->x0 = src->x0;
+      dst->y0 = src->y0;
+      dst->x1 = src->x1;
+      dst->y1 = src->y1;
       return dst;
    }
    return NULL;
index 6b1b091cf891457871688b80a97b791556594134..058c56816ac41742fef17520ae504d61d8406b60 100644 (file)
@@ -437,8 +437,8 @@ Status XvMCBlendSubpicture(Display *dpy, XvMCSurface *target_surface, XvMCSubpic
                            short subx, short suby, unsigned short subw, unsigned short subh,
                            short surfx, short surfy, unsigned short surfw, unsigned short surfh)
 {
-   struct pipe_video_rect src_rect = {subx, suby, subw, subh};
-   struct pipe_video_rect dst_rect = {surfx, surfy, surfw, surfh};
+   struct u_rect src_rect = {subx, subx + subw, suby, suby + subh};
+   struct u_rect dst_rect = {surfx, surfx + surfw, surfy, surfy + surfh};
 
    XvMCSurfacePrivate *surface_priv;
    XvMCSubpicturePrivate *subpicture_priv;
index 47853cf6924151fc443bdf2a743927289a00aaea..33b7dc2b1642107669c3830874de03fc60b58f4a 100644 (file)
@@ -355,8 +355,8 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
    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;
index 26f874ad87a328c0113500c0f7625b57f810d5c2..014d83f0516a62323e0fbe17b28374e3b4949d12 100644 (file)
@@ -90,8 +90,8 @@ typedef struct
    /* optional palette for this subpicture */
    struct pipe_sampler_view *palette;
 
-   struct pipe_video_rect src_rect;
-   struct pipe_video_rect dst_rect;
+   struct u_rect src_rect;
+   struct u_rect dst_rect;
 
    /* The surface this subpicture is currently associated with, if any. */
    XvMCSurface *surface;