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)
+ VASurfaceID surface,
+ const VARectangle *output_rect)
{
- 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 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;
-
- width = obj_surface->width;
- height = obj_surface->height;
- src_scale_x = ((float)srcw / width) / (float)destw;
- src_scale_y = ((float)srch / height) / (float)desth;
+ struct object_surface *obj_surface = SURFACE(surface);
+ struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
+
+ 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);
}
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);
}