aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vsrc_ddagrab.c
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2023-07-15 18:48:49 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2023-07-15 18:48:49 +0200
commit3c73200be2aef966a36d8c54359fef68e22c58b6 (patch)
tree5b6b1a865adf24a90ffe1eadd31df22df902d527 /libavfilter/vsrc_ddagrab.c
parentda94c6a00c5fdeb84c14333c285bef9809d35676 (diff)
downloadffmpeg-3c73200be2aef966a36d8c54359fef68e22c58b6.tar.gz
avfilter/vsrc_ddagrab: calculate pointer position on rotated screens
Diffstat (limited to 'libavfilter/vsrc_ddagrab.c')
-rw-r--r--libavfilter/vsrc_ddagrab.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/libavfilter/vsrc_ddagrab.c b/libavfilter/vsrc_ddagrab.c
index 4bf316c15a..525d48110a 100644
--- a/libavfilter/vsrc_ddagrab.c
+++ b/libavfilter/vsrc_ddagrab.c
@@ -533,8 +533,23 @@ static int update_mouse_pointer(AVFilterContext *avctx, DXGI_OUTDUPL_FRAME_INFO
return 0;
if (frame_info->PointerPosition.Visible) {
- dda->mouse_x = frame_info->PointerPosition.Position.x;
- dda->mouse_y = frame_info->PointerPosition.Position.y;
+ switch (dda->output_desc.Rotation) {
+ case DXGI_MODE_ROTATION_ROTATE90:
+ dda->mouse_x = frame_info->PointerPosition.Position.y;
+ dda->mouse_y = dda->output_desc.DesktopCoordinates.right - dda->output_desc.DesktopCoordinates.left - frame_info->PointerPosition.Position.x - 1;
+ break;
+ case DXGI_MODE_ROTATION_ROTATE180:
+ dda->mouse_x = dda->output_desc.DesktopCoordinates.right - dda->output_desc.DesktopCoordinates.left - frame_info->PointerPosition.Position.x - 1;
+ dda->mouse_y = dda->output_desc.DesktopCoordinates.bottom - dda->output_desc.DesktopCoordinates.top - frame_info->PointerPosition.Position.y - 1;
+ break;
+ case DXGI_MODE_ROTATION_ROTATE270:
+ dda->mouse_x = dda->output_desc.DesktopCoordinates.bottom - dda->output_desc.DesktopCoordinates.top - frame_info->PointerPosition.Position.y - 1;
+ dda->mouse_y = frame_info->PointerPosition.Position.x;
+ break;
+ default:
+ dda->mouse_x = frame_info->PointerPosition.Position.x;
+ dda->mouse_y = frame_info->PointerPosition.Position.y;
+ }
} else {
dda->mouse_x = dda->mouse_y = -1;
}
@@ -853,6 +868,41 @@ static int draw_mouse_pointer(AVFilterContext *avctx, AVFrame *frame)
D3D11_SUBRESOURCE_DATA init_data = { 0 };
D3D11_BUFFER_DESC buf_desc = { 0 };
+ switch (dda->output_desc.Rotation) {
+ case DXGI_MODE_ROTATION_ROTATE90:
+ vertices[ 0] = x; vertices[ 1] = y;
+ vertices[ 5] = x; vertices[ 6] = y - tex_desc.Width;
+ vertices[10] = x + tex_desc.Height; vertices[11] = y;
+ vertices[15] = x + tex_desc.Height; vertices[16] = y - tex_desc.Width;
+ vertices[ 3] = 0.0f; vertices[ 4] = 0.0f;
+ vertices[ 8] = 1.0f; vertices[ 9] = 0.0f;
+ vertices[13] = 0.0f; vertices[14] = 1.0f;
+ vertices[18] = 1.0f; vertices[19] = 1.0f;
+ break;
+ case DXGI_MODE_ROTATION_ROTATE180:
+ vertices[ 0] = x - tex_desc.Width; vertices[ 1] = y;
+ vertices[ 5] = x - tex_desc.Width; vertices[ 6] = y - tex_desc.Height;
+ vertices[10] = x; vertices[11] = y;
+ vertices[15] = x; vertices[16] = y - tex_desc.Height;
+ vertices[ 3] = 1.0f; vertices[ 4] = 0.0f;
+ vertices[ 8] = 1.0f; vertices[ 9] = 1.0f;
+ vertices[13] = 0.0f; vertices[14] = 0.0f;
+ vertices[18] = 0.0f; vertices[19] = 1.0f;
+ break;
+ case DXGI_MODE_ROTATION_ROTATE270:
+ vertices[ 0] = x - tex_desc.Height; vertices[ 1] = y + tex_desc.Width;
+ vertices[ 5] = x - tex_desc.Height; vertices[ 6] = y;
+ vertices[10] = x; vertices[11] = y + tex_desc.Width;
+ vertices[15] = x; vertices[16] = y;
+ vertices[ 3] = 1.0f; vertices[ 4] = 1.0f;
+ vertices[ 8] = 0.0f; vertices[ 9] = 1.0f;
+ vertices[13] = 1.0f; vertices[14] = 0.0f;
+ vertices[18] = 0.0f; vertices[19] = 0.0f;
+ break;
+ default:
+ break;
+ }
+
num_vertices = sizeof(vertices) / (sizeof(FLOAT) * 5);
buf_desc.Usage = D3D11_USAGE_DEFAULT;