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,
struct object_subpic *obj_subpic = SUBPIC(subpicture);
int i;
obj_subpic->dstx = dest_x;
obj_subpic->dsty = dest_y;
obj_subpic->src_rect.x = src_x;
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++) {
struct object_surface *obj_surface = SURFACE(target_surfaces[i]);
......
......@@ -118,8 +118,8 @@ struct object_subpic
{
struct object_base base;
VAImageID image;
int dstx;
int dsty;
VARectangle src_rect;
VARectangle dst_rect;
int width;
int height;
unsigned char palette[3][16];
......
......@@ -789,57 +789,56 @@ i965_render_binding_table(VADriverContextP ctx)
static void
i965_subpic_render_upload_vertex(VADriverContextP ctx,
VASurfaceID surface,
short srcx,
short srcy,
unsigned short srcw,
unsigned short srch,
short destx,
short desty,
unsigned short destw,
unsigned short desth)
const VARectangle *output_rect)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_render_state *render_state = &i965->render_state;
struct intel_region *dest_region = render_state->draw_region;
struct object_surface *obj_surface;
struct object_subpic *obj_subpic;
float *vb;
float src_scale_x, src_scale_y;
int i, width, height;
obj_surface = SURFACE(surface);
obj_subpic = SUBPIC(obj_surface->subpic);
assert(obj_surface);
assert(obj_subpic);
int box_x1 = dest_region->x + obj_subpic->dstx;
int box_y1 = dest_region->y + obj_subpic->dsty;
int box_x2 = box_x1 + obj_subpic->width;
int box_y2 = box_y1 + obj_subpic->height;
struct object_surface *obj_surface = SURFACE(surface);
struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
width = obj_surface->width;
height = obj_surface->height;
src_scale_x = ((float)srcw / width) / (float)destw;
src_scale_y = ((float)srch / height) / (float)desth;
const float psx = (float)obj_surface->width / (float)obj_subpic->width;
const float psy = (float)obj_surface->height / (float)obj_subpic->height;
const float ssx = (float)output_rect->width / (float)obj_surface->width;
const float ssy = (float)output_rect->height / (float)obj_surface->height;
const float sx = psx * ssx;
const float sy = psy * ssy;
float *vb, tx1, tx2, ty1, ty2, x1, x2, y1, y2;
int i = 0;
VARectangle dst_rect;
dst_rect.x = output_rect->x + sx * (float)obj_subpic->dst_rect.x;
dst_rect.y = output_rect->y + sx * (float)obj_subpic->dst_rect.y;
dst_rect.width = sx * (float)obj_subpic->dst_rect.width;
dst_rect.height = sy * (float)obj_subpic->dst_rect.height;
dri_bo_map(render_state->vb.vertex_buffer, 1);
assert(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;
vb[i++] = 0.0;
vb[i++] = (float)box_x1;
vb[i++] = (float)box_y1;
tx1 = (float)obj_subpic->src_rect.x / (float)obj_subpic->width;
ty1 = (float)obj_subpic->src_rect.y / (float)obj_subpic->height;
tx2 = (float)(obj_subpic->src_rect.x + obj_subpic->src_rect.width) / (float)obj_subpic->width;
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);
}
......@@ -947,9 +946,13 @@ i965_subpic_render_state_setup(VADriverContextP ctx,
i965_render_cc_viewport(ctx);
i965_subpic_render_cc_unit(ctx);
i965_render_binding_table(ctx);
i965_subpic_render_upload_vertex(ctx, surface,
srcx, srcy, srcw, srch,
destx, desty, destw, desth);
VARectangle output_rect;
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