From a4001268892de665baa7b89e0541adb1ef2b3ab6 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Wed, 11 Dec 2019 21:51:03 +0900 Subject: [PATCH] d3d11window: Initialize surface rect with given external window handle Unlike internal window, resize event might not happen with external window. --- sys/d3d11/gstd3d11window.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/d3d11/gstd3d11window.c b/sys/d3d11/gstd3d11window.c index f9f4a4405e..05a2fdc076 100644 --- a/sys/d3d11/gstd3d11window.c +++ b/sys/d3d11/gstd3d11window.c @@ -1104,8 +1104,19 @@ gst_d3d11_window_prepare (GstD3D11Window * window, guint width, guint height, window->render_rect.w = width; window->render_rect.h = height; - desc.BufferDesc.Width = window->width = window->surface_width = width; - desc.BufferDesc.Height = window->height = window->surface_height = height; + if (window->external_win_id) { + RECT client_rect = { 0, }; + GetClientRect (window->external_win_id, &client_rect); + + window->surface_width = client_rect.right - client_rect.left; + window->surface_height = client_rect.bottom - client_rect.top; + } else { + window->surface_width = width; + window->surface_height = height; + } + + desc.BufferDesc.Width = window->width = window->surface_width; + desc.BufferDesc.Height = window->height = window->surface_height; /* don't care refresh rate */ desc.BufferDesc.RefreshRate.Numerator = 0; desc.BufferDesc.RefreshRate.Denominator = 1;