Commit c4848526 authored by Gwenole Beauchesne's avatar Gwenole Beauchesne Committed by Xiang, Haihao

the VA API spec metion that the dest rectangle to vaAssociateSubpicture() is...

the VA API spec metion that the dest rectangle to vaAssociateSubpicture() is relative to the parent surface. So, we have another level of scaling since the surface can be scaled during vaPutSurface. This patch tries to fix that.
parent 29dfeb7e
...@@ -499,8 +499,14 @@ i965_AssociateSubpicture(VADriverContextP ctx, ...@@ -499,8 +499,14 @@ i965_AssociateSubpicture(VADriverContextP ctx,
struct object_subpic *obj_subpic = SUBPIC(subpicture); struct object_subpic *obj_subpic = SUBPIC(subpicture);
int i; int i;
obj_subpic->dstx = dest_x; obj_subpic->src_rect.x = src_x;
obj_subpic->dsty = dest_y; obj_subpic->src_rect.y = src_y;
obj_subpic->src_rect.width = src_width;
obj_subpic->src_rect.height = src_height;
obj_subpic->dst_rect.x = dest_x;
obj_subpic->dst_rect.y = dest_y;
obj_subpic->dst_rect.width = dest_width;
obj_subpic->dst_rect.height = dest_height;
for (i = 0; i < num_surfaces; i++) { for (i = 0; i < num_surfaces; i++) {
struct object_surface *obj_surface = SURFACE(target_surfaces[i]); struct object_surface *obj_surface = SURFACE(target_surfaces[i]);
......
...@@ -91,7 +91,7 @@ struct object_surface ...@@ -91,7 +91,7 @@ struct object_surface
struct object_base base; struct object_base base;
VASurfaceStatus status; VASurfaceStatus status;
VASubpictureID subpic; VASubpictureID subpic;
int width; int width;
int height; int height;
int size; int size;
dri_bo *bo; dri_bo *bo;
...@@ -118,12 +118,12 @@ struct object_subpic ...@@ -118,12 +118,12 @@ struct object_subpic
{ {
struct object_base base; struct object_base base;
VAImageID image; VAImageID image;
int dstx; VARectangle src_rect;
int dsty; VARectangle dst_rect;
int width; int width;
int height; int height;
unsigned char palette[3][16]; unsigned char palette[3][16];
dri_bo *bo; dri_bo *bo;
}; };
......
...@@ -788,58 +788,57 @@ i965_render_binding_table(VADriverContextP ctx) ...@@ -788,58 +788,57 @@ i965_render_binding_table(VADriverContextP ctx)
static void static void
i965_subpic_render_upload_vertex(VADriverContextP ctx, i965_subpic_render_upload_vertex(VADriverContextP ctx,
VASurfaceID surface, VASurfaceID surface,
short srcx, const VARectangle *output_rect)
short srcy,
unsigned short srcw,
unsigned short srch,
short destx,
short desty,
unsigned short destw,
unsigned short desth)
{ {
struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_render_state *render_state = &i965->render_state; struct i965_render_state *render_state = &i965->render_state;
struct intel_region *dest_region = render_state->draw_region; struct object_surface *obj_surface = SURFACE(surface);
struct object_surface *obj_surface; struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
struct object_subpic *obj_subpic;
float *vb; const float psx = (float)obj_surface->width / (float)obj_subpic->width;
float src_scale_x, src_scale_y; const float psy = (float)obj_surface->height / (float)obj_subpic->height;
int i, width, height; const float ssx = (float)output_rect->width / (float)obj_surface->width;
obj_surface = SURFACE(surface); const float ssy = (float)output_rect->height / (float)obj_surface->height;
obj_subpic = SUBPIC(obj_surface->subpic); const float sx = psx * ssx;
assert(obj_surface); const float sy = psy * ssy;
assert(obj_subpic); float *vb, tx1, tx2, ty1, ty2, x1, x2, y1, y2;
int i = 0;
int box_x1 = dest_region->x + obj_subpic->dstx;
int box_y1 = dest_region->y + obj_subpic->dsty; VARectangle dst_rect;
int box_x2 = box_x1 + obj_subpic->width; dst_rect.x = output_rect->x + sx * (float)obj_subpic->dst_rect.x;
int box_y2 = box_y1 + obj_subpic->height; dst_rect.y = output_rect->y + sx * (float)obj_subpic->dst_rect.y;
dst_rect.width = sx * (float)obj_subpic->dst_rect.width;
width = obj_surface->width; dst_rect.height = sy * (float)obj_subpic->dst_rect.height;
height = obj_surface->height;
src_scale_x = ((float)srcw / width) / (float)destw;
src_scale_y = ((float)srch / height) / (float)desth;
dri_bo_map(render_state->vb.vertex_buffer, 1); dri_bo_map(render_state->vb.vertex_buffer, 1);
assert(render_state->vb.vertex_buffer->virtual); assert(render_state->vb.vertex_buffer->virtual);
vb = render_state->vb.vertex_buffer->virtual; vb = render_state->vb.vertex_buffer->virtual;
/*vertex covers the full subpicture*/
i = 0;
vb[i++] = 1;
vb[i++] = 1;
vb[i++] = (float)box_x2;
vb[i++] = (float)box_y2;
vb[i++] = 0.0;
vb[i++] = 1;
vb[i++] = (float)box_x1;
vb[i++] = (float)box_y2;
vb[i++] = 0.0; tx1 = (float)obj_subpic->src_rect.x / (float)obj_subpic->width;
vb[i++] = 0.0; ty1 = (float)obj_subpic->src_rect.y / (float)obj_subpic->height;
vb[i++] = (float)box_x1; tx2 = (float)(obj_subpic->src_rect.x + obj_subpic->src_rect.width) / (float)obj_subpic->width;
vb[i++] = (float)box_y1; ty2 = (float)(obj_subpic->src_rect.y + obj_subpic->src_rect.height) / (float)obj_subpic->height;
x1 = (float)dst_rect.x;
y1 = (float)dst_rect.y;
x2 = (float)(dst_rect.x + dst_rect.width);
y2 = (float)(dst_rect.y + dst_rect.height);
vb[i++] = tx2;
vb[i++] = ty2;
vb[i++] = x2;
vb[i++] = y2;
vb[i++] = tx1;
vb[i++] = ty2;
vb[i++] = x1;
vb[i++] = y2;
vb[i++] = tx1;
vb[i++] = ty1;
vb[i++] = x1;
vb[i++] = y1;
dri_bo_unmap(render_state->vb.vertex_buffer); dri_bo_unmap(render_state->vb.vertex_buffer);
} }
...@@ -947,9 +946,13 @@ i965_subpic_render_state_setup(VADriverContextP ctx, ...@@ -947,9 +946,13 @@ i965_subpic_render_state_setup(VADriverContextP ctx,
i965_render_cc_viewport(ctx); i965_render_cc_viewport(ctx);
i965_subpic_render_cc_unit(ctx); i965_subpic_render_cc_unit(ctx);
i965_render_binding_table(ctx); i965_render_binding_table(ctx);
i965_subpic_render_upload_vertex(ctx, surface,
srcx, srcy, srcw, srch, VARectangle output_rect;
destx, desty, destw, desth); output_rect.x = destx;
output_rect.y = desty;
output_rect.width = destw;
output_rect.height = desth;
i965_subpic_render_upload_vertex(ctx, surface, &output_rect);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment