d3d11window: Initialize surface rect with given external window handle
authorSeungha Yang <seungha.yang@navercorp.com>
Wed, 11 Dec 2019 12:51:03 +0000 (21:51 +0900)
committerSeungha Yang <seungha.yang@navercorp.com>
Wed, 11 Dec 2019 14:04:55 +0000 (23:04 +0900)
Unlike internal window, resize event might not happen with external window.

sys/d3d11/gstd3d11window.c

index f9f4a44..05a2fdc 100644 (file)
@@ -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;