From b08310f748d9797c15c4369edd31f7f142d6f45b Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sun, 14 Mar 2021 13:01:37 +0900 Subject: [PATCH] d3d11: Run gst-indent for all C++ code Since all d3d11 plugin implementation code are C++, we need to run gst-indent manually. This is preparation for later "gst-indent sys/d3d11/*.cpp" run. Part-of: --- sys/d3d11/gstd3d11desktopdup.cpp | 29 +++++---- sys/d3d11/gstd3d11window.cpp | 98 +++++++++++++++-------------- sys/d3d11/gstd3d11window_corewindow.cpp | 62 +++++++++++------- sys/d3d11/gstd3d11window_dummy.cpp | 27 ++++---- sys/d3d11/gstd3d11window_swapchainpanel.cpp | 33 +++++++--- sys/d3d11/gstd3d11window_win32.cpp | 19 +++--- 6 files changed, 155 insertions(+), 113 deletions(-) diff --git a/sys/d3d11/gstd3d11desktopdup.cpp b/sys/d3d11/gstd3d11desktopdup.cpp index e3045cd..065378d 100644 --- a/sys/d3d11/gstd3d11desktopdup.cpp +++ b/sys/d3d11/gstd3d11desktopdup.cpp @@ -53,6 +53,7 @@ #include +/* *INDENT-OFF* */ using namespace Microsoft::WRL; G_BEGIN_DECLS @@ -1408,6 +1409,7 @@ private: BYTE *vertex_buffer_; UINT vertex_buffer_size_; }; +/* *INDENT-ON* */ struct _GstD3D11DesktopDup { @@ -1450,17 +1452,15 @@ gst_d3d11_desktop_dup_class_init (GstD3D11DesktopDupClass * klass) g_object_class_install_property (gobject_class, PROP_D3D11_DEVICE, g_param_spec_object ("d3d11device", "D3D11 Device", "GstD3D11Device object for operating", - GST_TYPE_D3D11_DEVICE, - (GParamFlags) + GST_TYPE_D3D11_DEVICE, (GParamFlags) (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS))); + G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_OUTPUT_INDEX, g_param_spec_int ("monitor-index", "Monitor Index", "Zero-based index for monitor to capture (-1 = primary monitor)", - -1, G_MAXINT, DEFAULT_MONITOR_INDEX, - (GParamFlags) + -1, G_MAXINT, DEFAULT_MONITOR_INDEX, (GParamFlags) (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS))); + G_PARAM_STATIC_STRINGS))); } static void @@ -1480,7 +1480,7 @@ gst_d3d11_desktop_dup_get_monitor_size (GstD3D11DesktopDup * self, DEVMODE dev_mode; monitor_info.cbSize = sizeof (MONITORINFOEX); - if (!GetMonitorInfo (hmonitor, (LPMONITORINFO) &monitor_info)) { + if (!GetMonitorInfo (hmonitor, (LPMONITORINFO) & monitor_info)) { GST_WARNING_OBJECT (self, "Couldn't get monitor info"); return FALSE; } @@ -1506,10 +1506,12 @@ static void gst_d3d11_desktop_dup_constructed (GObject * object) { GstD3D11DesktopDup *self = GST_D3D11_DESKTOP_DUP (object); + /* *INDENT-OFF* */ ComPtr dxgi_device; ComPtr adapter; ComPtr output; ComPtr output1; + /* *INDENT-ON* */ ID3D11Device *device_handle; HRESULT hr; gboolean ret = FALSE; @@ -1537,7 +1539,7 @@ gst_d3d11_desktop_dup_constructed (GObject * object) guint index = 0; /* Enumerate all outputs to find primary monitor */ do { - hr = adapter->EnumOutputs (index, output.ReleaseAndGetAddressOf()); + hr = adapter->EnumOutputs (index, output.ReleaseAndGetAddressOf ()); if (!gst_d3d11_result (hr, self->device)) goto out; @@ -1576,7 +1578,7 @@ gst_d3d11_desktop_dup_constructed (GObject * object) * application is running without dpi-awareness. To get actual monitor size, * we need to use Win32 API... */ if (!gst_d3d11_desktop_dup_get_monitor_size (self, - output_desc.Monitor, &self->desktop_coordinates)) { + output_desc.Monitor, &self->desktop_coordinates)) { goto out; } @@ -1587,8 +1589,9 @@ gst_d3d11_desktop_dup_constructed (GObject * object) GST_DEBUG_OBJECT (self, "Desktop coordinates left:top:right:bottom = %ld:%ld:%ld:%ld (%dx%d)", - self->desktop_coordinates.left, self->desktop_coordinates.top, self->desktop_coordinates.right, - self->desktop_coordinates.bottom, self->width, self->height); + self->desktop_coordinates.left, self->desktop_coordinates.top, + self->desktop_coordinates.right, self->desktop_coordinates.bottom, + self->width, self->height); ret = TRUE; @@ -1649,7 +1652,9 @@ gst_d3d11_desktop_dup_setup_texture (GstD3D11DesktopDup * self) D3D11_TEXTURE2D_DESC texture_desc = { 0, }; ID3D11Device *device_handle; HRESULT hr; + /* *INDENT-OFF* */ ComPtr texture; + /* *INDENT-ON* */ /* This texture is for copying/updating only updated region from previously * captured frame (like a reference frame) */ @@ -1674,7 +1679,7 @@ gst_d3d11_desktop_dup_setup_texture (GstD3D11DesktopDup * self) return FALSE; } - self->texture = texture.Detach(); + self->texture = texture.Detach (); return TRUE; } diff --git a/sys/d3d11/gstd3d11window.cpp b/sys/d3d11/gstd3d11window.cpp index 515c0a4..8077f5b 100644 --- a/sys/d3d11/gstd3d11window.cpp +++ b/sys/d3d11/gstd3d11window.cpp @@ -128,7 +128,7 @@ static void gst_d3d11_window_get_property (GObject * object, guint prop_id, static void gst_d3d11_window_dispose (GObject * object); static GstFlowReturn gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer, GstStructure * stats, - ID3D11VideoProcessorOutputView *pov, ID3D11RenderTargetView * rtv); + ID3D11VideoProcessorOutputView * pov, ID3D11RenderTargetView * rtv); static void gst_d3d11_window_on_resize_default (GstD3D11Window * window, guint width, guint height); static gboolean gst_d3d11_window_prepare_default (GstD3D11Window * window, @@ -311,7 +311,9 @@ gst_d3d11_window_prepare_dwrite_device (GstD3D11Window * self) { GstD3D11WindowPrivate *priv = self->priv; HRESULT hr; + /* *INDENT-OFF* */ ComPtr dxgi_device; + /* *INDENT-ON* */ ID3D11Device *device_handle; if (!self->device) { @@ -337,23 +339,25 @@ gst_d3d11_window_prepare_dwrite_device (GstD3D11Window * self) if (!gst_d3d11_result (hr, self->device)) goto error; - hr = priv->d2d_device->CreateDeviceContext (D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS, + hr = priv->d2d_device->CreateDeviceContext + (D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS, &priv->d2d_device_context); if (!gst_d3d11_result (hr, self->device)) goto error; - hr = priv->d2d_device_context->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Yellow), - &priv->d2d_brush); + hr = priv-> + d2d_device_context->CreateSolidColorBrush (D2D1::ColorF (D2D1::ColorF:: + Yellow), &priv->d2d_brush); if (!gst_d3d11_result (hr, self->device)) goto error; hr = DWriteCreateFactory (DWRITE_FACTORY_TYPE_SHARED, - __uuidof (IDWriteFactory), (IUnknown **) &priv->dwrite_factory); + __uuidof (IDWriteFactory), (IUnknown **) & priv->dwrite_factory); if (!gst_d3d11_result (hr, self->device)) goto error; /* Configure font */ - hr = priv->dwrite_factory->CreateTextFormat(L"Arial", NULL, + hr = priv->dwrite_factory->CreateTextFormat (L"Arial", NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 12.0f, L"en-US", &priv->dwrite_format); if (!gst_d3d11_result (hr, self->device)) @@ -372,8 +376,10 @@ gst_d3d11_window_dwrite_on_resize (GstD3D11Window * self, ID3D11Texture2D * backbuffer) { GstD3D11WindowPrivate *priv = self->priv; + /* *INDENT-OFF* */ ComPtr dxgi_surface; ComPtr bitmap; + /* *INDENT-ON* */ D2D1_BITMAP_PROPERTIES1 prop; HRESULT hr; @@ -393,8 +399,8 @@ gst_d3d11_window_dwrite_on_resize (GstD3D11Window * self, if (!gst_d3d11_result (hr, self->device)) goto error; - hr = priv->d2d_device_context->CreateBitmapFromDxgiSurface (dxgi_surface.Get (), - &prop, &bitmap); + hr = priv->d2d_device_context-> + CreateBitmapFromDxgiSurface (dxgi_surface.Get (), &prop, &bitmap); if (!gst_d3d11_result (hr, self->device)) goto error; @@ -535,10 +541,9 @@ gst_d3d11_window_on_resize_default (GstD3D11Window * window, guint width, pov_desc.Texture2D.MipSlice = 0; if (!gst_d3d11_video_processor_create_output_view (window->processor, - &pov_desc, (ID3D11Resource *) backbuffer, &window->pov)) + &pov_desc, (ID3D11Resource *) backbuffer, &window->pov)) goto done; } - #ifdef HAVE_DIRECT_WRITE if (window->render_stats) gst_d3d11_window_dwrite_on_resize (window, backbuffer); @@ -624,12 +629,12 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_DISPLAY; UINT supported_flags = 0; GstD3D11WindowDisplayFormat formats[] = { - { DXGI_FORMAT_R8G8B8A8_UNORM, GST_VIDEO_FORMAT_RGBA, FALSE }, - { DXGI_FORMAT_B8G8R8A8_UNORM, GST_VIDEO_FORMAT_BGRA, FALSE }, - { DXGI_FORMAT_R10G10B10A2_UNORM, GST_VIDEO_FORMAT_RGB10A2_LE, FALSE }, + {DXGI_FORMAT_R8G8B8A8_UNORM, GST_VIDEO_FORMAT_RGBA, FALSE}, + {DXGI_FORMAT_B8G8R8A8_UNORM, GST_VIDEO_FORMAT_BGRA, FALSE}, + {DXGI_FORMAT_R10G10B10A2_UNORM, GST_VIDEO_FORMAT_RGB10A2_LE, FALSE}, }; const GstD3D11WindowDisplayFormat *chosen_format = NULL; - const GstDxgiColorSpace * chosen_colorspace = NULL; + const GstDxgiColorSpace *chosen_colorspace = NULL; #if (GST_D3D11_DXGI_HEADER_VERSION >= 4) gboolean have_hdr10 = FALSE; DXGI_COLOR_SPACE_TYPE native_colorspace_type = @@ -669,7 +674,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, "Cannot determine render format"); return FALSE; } - #ifdef HAVE_DIRECT_WRITE if (window->render_stats && formats[1].supported) { /* FIXME: D2D seems to be accepting only DXGI_FORMAT_B8G8R8A8_UNORM */ @@ -730,7 +734,8 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, klass = GST_D3D11_WINDOW_GET_CLASS (window); if (!window->swap_chain && !klass->create_swap_chain (window, window->dxgi_format, - display_width, display_height, swapchain_flags, &window->swap_chain)) { + display_width, display_height, swapchain_flags, + &window->swap_chain)) { GST_ERROR_OBJECT (window, "Cannot create swapchain"); g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED, "Cannot create swapchain"); @@ -771,7 +776,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, HRESULT hr; hr = window->swap_chain->QueryInterface (IID_IDXGISwapChain4, - (void **) &swapchain4); + (void **) &swapchain4); if (gst_d3d11_result (hr, window->device)) { GST_DEBUG_OBJECT (window, "Have HDR metadata, set to DXGI swapchain"); @@ -814,7 +819,8 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, (void **) &swapchain3); if (gst_d3d11_result (hr, window->device)) { - chosen_colorspace = gst_d3d11_find_swap_chain_color_space (&window->render_info, + chosen_colorspace = + gst_d3d11_find_swap_chain_color_space (&window->render_info, swapchain3, have_hdr10); if (chosen_colorspace) { native_colorspace_type = @@ -822,7 +828,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, hr = swapchain3->SetColorSpace1 (native_colorspace_type); if (!gst_d3d11_result (hr, window->device)) { GST_WARNING_OBJECT (window, "Failed to set colorspace %d, hr: 0x%x", - native_colorspace_type, (guint) hr); + native_colorspace_type, (guint) hr); chosen_colorspace = NULL; native_colorspace_type = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709; } else { @@ -834,10 +840,8 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, chosen_colorspace->primaries; window->render_info.colorimetry.transfer = chosen_colorspace->transfer; - window->render_info.colorimetry.range = - chosen_colorspace->range; - window->render_info.colorimetry.matrix = - chosen_colorspace->matrix; + window->render_info.colorimetry.range = chosen_colorspace->range; + window->render_info.colorimetry.matrix = chosen_colorspace->matrix; } } @@ -854,7 +858,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, window->render_info.colorimetry.transfer = GST_VIDEO_TRANSFER_BT709; window->render_info.colorimetry.range = GST_VIDEO_COLOR_RANGE_0_255; } - #if (GST_D3D11_DXGI_HEADER_VERSION >= 4) if (chosen_colorspace) { const GstDxgiColorSpace *in_color_space = @@ -874,8 +877,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, processor = gst_d3d11_video_processor_new (window->device, GST_VIDEO_INFO_WIDTH (&window->info), - GST_VIDEO_INFO_HEIGHT (&window->info), - display_width, display_height); + GST_VIDEO_INFO_HEIGHT (&window->info), display_width, display_height); } if (processor) { @@ -935,7 +937,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, "Cannot create overlay compositor"); goto error; } - #ifdef HAVE_DIRECT_WRITE if (window->render_stats) gst_d3d11_window_prepare_dwrite_device (window); @@ -1016,7 +1017,9 @@ gst_d3d11_window_present_d2d (GstD3D11Window * self, GstStructure * stats) guint64 dropped = 0; guint64 rendered = 0; std::wostringstream stats_str; + /* *INDENT-OFF* */ ComPtr layout; + /* *INDENT-ON* */ FLOAT left; FLOAT top; @@ -1035,11 +1038,10 @@ gst_d3d11_window_present_d2d (GstD3D11Window * self, GstStructure * stats) stats_str << "Dropped: " << dropped << std::endl; stats_str << "Rendered: " << rendered << std::endl; - hr = priv->dwrite_factory->CreateTextLayout (stats_str.str().c_str(), - (UINT32) stats_str.str().size(), priv->dwrite_format, + hr = priv->dwrite_factory->CreateTextLayout (stats_str.str ().c_str (), + (UINT32) stats_str.str ().size (), priv->dwrite_format, self->render_rect.right - self->render_rect.left, - self->render_rect.bottom - self->render_rect.top, - &layout); + self->render_rect.bottom - self->render_rect.top, &layout); if (!gst_d3d11_result (hr, self->device)) return; @@ -1047,8 +1049,8 @@ gst_d3d11_window_present_d2d (GstD3D11Window * self, GstStructure * stats) top = self->render_rect.top + 5.0f; priv->d2d_device_context->BeginDraw (); - priv->d2d_device_context->DrawTextLayout(D2D1::Point2F(left, top), - layout.Get(), priv->d2d_brush); + priv->d2d_device_context->DrawTextLayout (D2D1::Point2F (left, top), + layout.Get (), priv->d2d_brush); hr = priv->d2d_device_context->EndDraw (); gst_d3d11_result (hr, self->device); @@ -1059,7 +1061,7 @@ gst_d3d11_window_present_d2d (GstD3D11Window * self, GstStructure * stats) static GstFlowReturn gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer, - GstStructure * stats, ID3D11VideoProcessorOutputView *pov, + GstStructure * stats, ID3D11VideoProcessorOutputView * pov, ID3D11RenderTargetView * rtv) { GstD3D11WindowClass *klass = GST_D3D11_WINDOW_GET_CLASS (self); @@ -1077,16 +1079,14 @@ gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer, gst_d3d11_device_get_device_handle (self->device); /* Map memory in any case so that we can upload pending stage texture */ - if (!gst_d3d11_buffer_map (buffer, device_handle, - infos, GST_MAP_READ)) { + if (!gst_d3d11_buffer_map (buffer, device_handle, infos, GST_MAP_READ)) { GST_ERROR_OBJECT (self, "Couldn't map buffer"); return GST_FLOW_ERROR; } if (!gst_d3d11_buffer_get_shader_resource_view (buffer, srv)) { - if (!gst_d3d11_window_buffer_ensure_processor_input (self, - buffer, &piv)) { + if (!gst_d3d11_window_buffer_ensure_processor_input (self, buffer, &piv)) { GST_ERROR_OBJECT (self, "Input texture cannot be used for converter"); return GST_FLOW_ERROR; } @@ -1101,16 +1101,16 @@ gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer, viewport.Height = self->render_rect.bottom - self->render_rect.top; viewport.MinDepth = 0.0f; viewport.MaxDepth = 1.0f; - gst_d3d11_converter_update_viewport (self->converter, - &viewport); + gst_d3d11_converter_update_viewport (self->converter, &viewport); gst_d3d11_overlay_compositor_update_viewport (self->compositor, &viewport); } if (self->processor && piv && pov) { if (!gst_d3d11_video_processor_render_unlocked (self->processor, - &self->input_rect, piv, &self->render_rect, pov)) { - GST_ERROR_OBJECT (self, "Couldn't render to backbuffer using processor"); + &self->input_rect, piv, &self->render_rect, pov)) { + GST_ERROR_OBJECT (self, + "Couldn't render to backbuffer using processor"); ret = GST_FLOW_ERROR; goto unmap_and_out; } else { @@ -1118,8 +1118,9 @@ gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer, } } else { if (!gst_d3d11_converter_convert_unlocked (self->converter, - srv, &rtv, NULL, NULL)) { - GST_ERROR_OBJECT (self, "Couldn't render to backbuffer using converter"); + srv, &rtv, NULL, NULL)) { + GST_ERROR_OBJECT (self, + "Couldn't render to backbuffer using converter"); ret = GST_FLOW_ERROR; goto unmap_and_out; } else { @@ -1145,7 +1146,7 @@ gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer, self->first_present = FALSE; -unmap_and_out: + unmap_and_out: gst_d3d11_buffer_unmap (buffer, infos); } @@ -1231,8 +1232,7 @@ gst_d3d11_window_render_on_shared_handle (GstD3D11Window * window, pov = data.pov; } - ret = gst_d3d111_window_present (window, buffer, NULL, - pov, rtv); + ret = gst_d3d111_window_present (window, buffer, NULL, pov, rtv); klass->release_shared_handle (window, &data); gst_d3d11_device_unlock (window->device); @@ -1301,9 +1301,11 @@ gst_d3d11_window_get_native_type_from_handle (guintptr handle) #endif #if GST_D3D11_WINAPI_ONLY_APP { + /* *INDENT-OFF* */ ComPtr window = reinterpret_cast (handle); ComPtr core_window; ComPtr panel; + /* *INDENT-ON* */ if (SUCCEEDED (window.As (&core_window))) return GST_D3D11_WINDOW_NATIVE_TYPE_CORE_WINDOW; @@ -1333,4 +1335,4 @@ gst_d3d11_window_get_native_type_to_string (GstD3D11WindowNativeType type) } return "none"; -} \ No newline at end of file +} diff --git a/sys/d3d11/gstd3d11window_corewindow.cpp b/sys/d3d11/gstd3d11window_corewindow.cpp index 4fab021..136097b 100644 --- a/sys/d3d11/gstd3d11window_corewindow.cpp +++ b/sys/d3d11/gstd3d11window_corewindow.cpp @@ -35,6 +35,7 @@ #include #include +/* *INDENT-OFF* */ using namespace Microsoft::WRL; using namespace Microsoft::WRL::Wrappers; using namespace ABI::Windows::UI; @@ -46,10 +47,11 @@ typedef ABI::Windows::Foundation:: __FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowSizeChangedEventArgs_t IWindowSizeChangedEventHandler; -extern "C" { +G_BEGIN_DECLS GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_window_debug); #define GST_CAT_DEFAULT gst_d3d11_window_debug -} + +G_END_DECLS /* timeout to wait busy UI thread */ #define DEFAULT_ASYNC_TIMEOUT (10 * 1000) @@ -61,6 +63,7 @@ typedef struct _CoreWindowWinRTStorage HANDLE cancellable; EventRegistrationToken event_token; } CoreWindowWinRTStorage; +/* *INDENT-ON* */ struct _GstD3D11WindowCoreWindow { @@ -75,18 +78,16 @@ G_DEFINE_TYPE (GstD3D11WindowCoreWindow, gst_d3d11_window_core_window, static void gst_d3d11_window_core_window_constructed (GObject * object); static void gst_d3d11_window_core_window_dispose (GObject * object); -static void gst_d3d11_window_core_window_update_swap_chain (GstD3D11Window * window); -static void -gst_d3d11_window_core_window_change_fullscreen_mode (GstD3D11Window * window); -static gboolean -gst_d3d11_window_core_window_create_swap_chain (GstD3D11Window * window, - DXGI_FORMAT format, guint width, guint height, guint swapchain_flags, - IDXGISwapChain ** swap_chain); -static GstFlowReturn -gst_d3d11_window_core_window_present (GstD3D11Window * window, - guint present_flags); -static gboolean -gst_d3d11_window_core_window_unlock (GstD3D11Window * window); +static void gst_d3d11_window_core_window_update_swap_chain (GstD3D11Window * + window); +static void gst_d3d11_window_core_window_change_fullscreen_mode (GstD3D11Window + * window); +static gboolean gst_d3d11_window_core_window_create_swap_chain (GstD3D11Window * + window, DXGI_FORMAT format, guint width, guint height, + guint swapchain_flags, IDXGISwapChain ** swap_chain); +static GstFlowReturn gst_d3d11_window_core_window_present (GstD3D11Window * + window, guint present_flags); +static gboolean gst_d3d11_window_core_window_unlock (GstD3D11Window * window); static gboolean gst_d3d11_window_core_window_unlock_stop (GstD3D11Window * window); static void @@ -94,18 +95,20 @@ gst_d3d11_window_core_window_on_resize (GstD3D11Window * window, guint width, guint height); static void gst_d3d11_window_core_window_on_resize_sync (GstD3D11Window * window); -static void -gst_d3d11_window_core_window_unprepare (GstD3D11Window * window); +static void gst_d3d11_window_core_window_unprepare (GstD3D11Window * window); static float get_logical_dpi (void) { + /* *INDENT-OFF* */ ComPtr properties; + /* *INDENT-ON* */ HRESULT hr; HStringReference str_ref = - HStringReference (RuntimeClass_Windows_Graphics_Display_DisplayProperties); + HStringReference + (RuntimeClass_Windows_Graphics_Display_DisplayProperties); - hr = GetActivationFactory (str_ref.Get(), properties.GetAddressOf()); + hr = GetActivationFactory (str_ref.Get (), properties.GetAddressOf ()); if (gst_d3d11_result (hr, NULL)) { float dpi = 96.0f; @@ -118,12 +121,14 @@ get_logical_dpi (void) return 96.0f; } -static inline float dip_to_pixel (float dip) +static inline float +dip_to_pixel (float dip) { /* https://docs.microsoft.com/en-us/windows/win32/learnwin32/dpi-and-device-independent-pixels */ - return dip * get_logical_dpi() / 96.0f; + return dip * get_logical_dpi () / 96.0f; } +/* *INDENT-OFF* */ class CoreResizeHandler : public RuntimeClass, IWindowSizeChangedEventHandler> @@ -233,6 +238,7 @@ get_window_size (const ComPtr &dispatcher, return hr; }); } +/* *INDENT-ON* */ static void gst_d3d11_window_core_window_class_init (GstD3D11WindowCoreWindowClass * klass) @@ -268,6 +274,7 @@ gst_d3d11_window_core_window_init (GstD3D11WindowCoreWindow * self) self->storage->cancellable = CreateEvent (NULL, TRUE, FALSE, NULL); } +/* *INDENT-OFF* */ static void gst_d3d11_window_core_window_constructed (GObject * object) { @@ -277,8 +284,8 @@ gst_d3d11_window_core_window_constructed (GObject * object) HRESULT hr; ComPtr inspectable; ComPtr resize_handler; - Size size; ComPtr core_window; + Size size; if (!window->external_handle) { GST_ERROR_OBJECT (self, "No external window handle"); @@ -329,6 +336,7 @@ error: GST_ERROR_OBJECT (self, "Invalid window handle"); return; } +/* *INDENT-ON* */ static void gst_d3d11_window_core_window_dispose (GObject * object) @@ -338,6 +346,7 @@ gst_d3d11_window_core_window_dispose (GObject * object) G_OBJECT_CLASS (parent_class)->dispose (object); } +/* *INDENT-OFF* */ static void gst_d3d11_window_core_window_unprepare (GstD3D11Window * window) { @@ -365,6 +374,7 @@ gst_d3d11_window_core_window_unprepare (GstD3D11Window * window) self->storage = NULL; } +/* *INDENT-ON* */ static IDXGISwapChain1 * create_swap_chain_for_core_window (GstD3D11WindowCoreWindow * self, @@ -405,7 +415,9 @@ gst_d3d11_window_core_window_create_swap_chain (GstD3D11Window * window, IDXGISwapChain ** swap_chain) { GstD3D11WindowCoreWindow *self = GST_D3D11_WINDOW_CORE_WINDOW (window); + /* *INDENT-OFF* */ ComPtr new_swapchain; + /* *INDENT-ON* */ GstD3D11Device *device = window->device; DXGI_SWAP_CHAIN_DESC1 desc1 = { 0, }; @@ -423,8 +435,8 @@ gst_d3d11_window_core_window_create_swap_chain (GstD3D11Window * window, desc1.Flags = swapchain_flags; new_swapchain = - create_swap_chain_for_core_window (self, device, - window->external_handle, &desc1, NULL); + create_swap_chain_for_core_window (self, device, + window->external_handle, &desc1, NULL); if (!new_swapchain) { GST_ERROR_OBJECT (self, "Cannot create swapchain"); @@ -507,11 +519,13 @@ gst_d3d11_window_core_window_on_resize (GstD3D11Window * window, GstD3D11WindowCoreWindow *self = GST_D3D11_WINDOW_CORE_WINDOW (window); CoreWindowWinRTStorage *storage = self->storage; + /* *INDENT-OFF* */ run_async (storage->dispatcher, storage->cancellable, INFINITE, [window] { gst_d3d11_window_core_window_on_resize_sync (window); return S_OK; }); + /* *INDENT-ON* */ } static void @@ -544,4 +558,4 @@ gst_d3d11_window_core_window_new (GstD3D11Device * device, guintptr handle) g_object_ref_sink (window); return window; -} \ No newline at end of file +} diff --git a/sys/d3d11/gstd3d11window_dummy.cpp b/sys/d3d11/gstd3d11window_dummy.cpp index 6822576..f3dc4f5 100644 --- a/sys/d3d11/gstd3d11window_dummy.cpp +++ b/sys/d3d11/gstd3d11window_dummy.cpp @@ -26,6 +26,7 @@ #include "gstd3d11pluginutils.h" #include +/* *INDENT-OFF* */ using namespace Microsoft::WRL; G_BEGIN_DECLS @@ -34,6 +35,7 @@ GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_window_debug); #define GST_CAT_DEFAULT gst_d3d11_window_debug G_END_DECLS +/* *INDENT-ON* */ struct _GstD3D11WindowDummy { @@ -68,8 +70,7 @@ gst_d3d11_window_dummy_class_init (GstD3D11WindowDummyClass * klass) window_class->on_resize = GST_DEBUG_FUNCPTR (gst_d3d11_window_dummy_on_resize); - window_class->prepare = - GST_DEBUG_FUNCPTR (gst_d3d11_window_dummy_prepare); + window_class->prepare = GST_DEBUG_FUNCPTR (gst_d3d11_window_dummy_prepare); window_class->unprepare = GST_DEBUG_FUNCPTR (gst_d3d11_window_dummy_unprepare); window_class->open_shared_handle = @@ -142,8 +143,7 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window, processor = gst_d3d11_video_processor_new (window->device, GST_VIDEO_INFO_WIDTH (&window->info), - GST_VIDEO_INFO_HEIGHT (&window->info), - display_width, display_height); + GST_VIDEO_INFO_HEIGHT (&window->info), display_width, display_height); } /* Check if video processor can support all possible output dxgi formats */ @@ -319,8 +319,8 @@ gst_d3d11_window_dummy_setup_fallback_texture (GstD3D11Window * window, pov_desc.Texture2D.MipSlice = 0; if (!gst_d3d11_video_processor_create_output_view (window->processor, - &pov_desc, (ID3D11Resource *) self->fallback_texture, - &self->fallback_pov)) { + &pov_desc, (ID3D11Resource *) self->fallback_texture, + &self->fallback_pov)) { GST_ERROR_OBJECT (window, "ID3D11VideoProcessorOutputView is unavailable"); gst_d3d11_window_dummy_clear_resources (self); @@ -331,6 +331,7 @@ gst_d3d11_window_dummy_setup_fallback_texture (GstD3D11Window * window, return TRUE; } +/* *INDENT-OFF* */ static gboolean gst_d3d11_window_dummy_open_shared_handle (GstD3D11Window * window, GstD3D11WindowSharedHandleData * data) @@ -404,8 +405,9 @@ gst_d3d11_window_dummy_open_shared_handle (GstD3D11Window * window, GST_TRACE_OBJECT (window, "We are using video processor but keyed mutex is unavailable"); - if (!gst_d3d11_window_dummy_setup_fallback_texture (window, &desc)) + if (!gst_d3d11_window_dummy_setup_fallback_texture (window, &desc)) { goto out; + } } } @@ -447,6 +449,7 @@ out: return FALSE; } +/* *INDENT-ON* */ static gboolean gst_d3d11_window_dummy_release_shared_handle (GstD3D11Window * window, @@ -463,7 +466,9 @@ gst_d3d11_window_dummy_release_shared_handle (GstD3D11Window * window, data->keyed_mutex->Release (); } else { + /* *INDENT-OFF* */ ComPtr query; + /* *INDENT-ON* */ D3D11_QUERY_DESC query_desc; ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device); ID3D11DeviceContext *context_handle = @@ -485,7 +490,7 @@ gst_d3d11_window_dummy_release_shared_handle (GstD3D11Window * window, if (data->fallback_rtv) { D3D11_BOX src_box; D3D11_TEXTURE2D_DESC desc; - ID3D11DeviceContext * context_handle = + ID3D11DeviceContext *context_handle = gst_d3d11_device_get_device_context_handle (device); data->texture->GetDesc (&desc); @@ -500,11 +505,11 @@ gst_d3d11_window_dummy_release_shared_handle (GstD3D11Window * window, context_handle->CopySubresourceRegion (data->texture, 0, 0, 0, 0, self->fallback_texture, 0, &src_box); } - context_handle->End (query.Get()); + context_handle->End (query.Get ()); /* Wait until all issued GPU commands are finished */ do { - context_handle->GetData (query.Get(), &sync_done, sizeof (BOOL), 0); + context_handle->GetData (query.Get (), &sync_done, sizeof (BOOL), 0); } while (!sync_done && (hr == S_OK || hr == S_FALSE)); if (!gst_d3d11_result (hr, device)) { @@ -534,4 +539,4 @@ gst_d3d11_window_dummy_new (GstD3D11Device * device) g_object_ref_sink (window); return window; -} \ No newline at end of file +} diff --git a/sys/d3d11/gstd3d11window_swapchainpanel.cpp b/sys/d3d11/gstd3d11window_swapchainpanel.cpp index c0c1977..b0a58cf 100644 --- a/sys/d3d11/gstd3d11window_swapchainpanel.cpp +++ b/sys/d3d11/gstd3d11window_swapchainpanel.cpp @@ -34,15 +34,19 @@ #include #include +/* *INDENT-OFF* */ + using namespace Microsoft::WRL; using namespace Microsoft::WRL::Wrappers; using namespace ABI::Windows::UI; using namespace ABI::Windows::Foundation; -extern "C" { +G_BEGIN_DECLS + GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_window_debug); #define GST_CAT_DEFAULT gst_d3d11_window_debug -} + +G_END_DECLS /* timeout to wait busy UI thread */ #define DEFAULT_ASYNC_TIMEOUT (10 * 1000) @@ -55,6 +59,7 @@ typedef struct _SwapChainPanelWinRTStorage HANDLE cancellable; EventRegistrationToken event_token; } SwapChainPanelWinRTStorage; +/* *INDENT-ON* */ struct _GstD3D11WindowSwapChainPanel { @@ -90,11 +95,11 @@ static void gst_d3d11_window_swap_chain_panel_on_resize (GstD3D11Window * window, guint width, guint height); static void -gst_d3d11_window_swap_chain_panel_on_resize_sync (GstD3D11Window * - window); +gst_d3d11_window_swap_chain_panel_on_resize_sync (GstD3D11Window * window); static void gst_d3d11_window_swap_chain_panel_unprepare (GstD3D11Window * window); +/* *INDENT-OFF* */ class PanelResizeHandler : public RuntimeClass, Xaml::ISizeChangedEventHandler> @@ -198,6 +203,7 @@ get_panel_size (const ComPtr &dispatcher, return hr; } +/* *INDENT-ON* */ static void gst_d3d11_window_swap_chain_panel_class_init (GstD3D11WindowSwapChainPanelClass @@ -212,7 +218,8 @@ gst_d3d11_window_swap_chain_panel_class_init (GstD3D11WindowSwapChainPanelClass window_class->update_swap_chain = GST_DEBUG_FUNCPTR (gst_d3d11_window_swap_chain_panel_update_swap_chain); window_class->change_fullscreen_mode = - GST_DEBUG_FUNCPTR (gst_d3d11_window_swap_chain_panel_change_fullscreen_mode); + GST_DEBUG_FUNCPTR + (gst_d3d11_window_swap_chain_panel_change_fullscreen_mode); window_class->create_swap_chain = GST_DEBUG_FUNCPTR (gst_d3d11_window_swap_chain_panel_create_swap_chain); window_class->present = @@ -234,6 +241,7 @@ gst_d3d11_window_swap_chain_panel_init (GstD3D11WindowSwapChainPanel * self) self->storage->cancellable = CreateEvent (NULL, TRUE, FALSE, NULL); } +/* *INDENT-OFF* */ static void gst_d3d11_window_swap_chain_panel_constructed (GObject * object) { @@ -301,6 +309,7 @@ error: GST_ERROR_OBJECT (self, "Invalid window handle"); return; } +/* *INDENT-ON* */ static void gst_d3d11_window_swap_chain_panel_dispose (GObject * object) @@ -310,6 +319,7 @@ gst_d3d11_window_swap_chain_panel_dispose (GObject * object) G_OBJECT_CLASS (parent_class)->dispose (object); } +/* *INDENT-OFF* */ static void gst_d3d11_window_swap_chain_panel_unprepare (GstD3D11Window * window) { @@ -339,6 +349,7 @@ gst_d3d11_window_swap_chain_panel_unprepare (GstD3D11Window * window) self->storage = NULL; } +/* *INDENT-ON* */ static IDXGISwapChain1 * create_swap_chain_for_composition (GstD3D11WindowSwapChainPanel * self, @@ -372,6 +383,7 @@ create_swap_chain_for_composition (GstD3D11WindowSwapChainPanel * self, return swap_chain; } +/* *INDENT-OFF* */ static gboolean gst_d3d11_window_swap_chain_panel_create_swap_chain (GstD3D11Window * window, DXGI_FORMAT format, guint width, guint height, guint swapchain_flags, @@ -424,6 +436,7 @@ gst_d3d11_window_swap_chain_panel_create_swap_chain (GstD3D11Window * window, return TRUE; } +/* *INDENT-ON* */ static GstFlowReturn gst_d3d11_window_swap_chain_panel_present (GstD3D11Window * window, @@ -501,11 +514,11 @@ gst_d3d11_window_swap_chain_panel_on_resize (GstD3D11Window * window, GST_D3D11_WINDOW_SWAP_CHAIN_PANEL (window); SwapChainPanelWinRTStorage *storage = self->storage; - run_async (storage->dispatcher, storage->cancellable, INFINITE, - [window] { + run_async (storage->dispatcher, storage->cancellable, INFINITE,[window] { gst_d3d11_window_swap_chain_panel_on_resize_sync (window); return S_OK; - }); + } + ); } static void @@ -528,7 +541,7 @@ gst_d3d11_window_swap_chain_panel_new (GstD3D11Device * device, guintptr handle) window = (GstD3D11Window *) g_object_new (GST_TYPE_D3D11_WINDOW_SWAP_CHAIN_PANEL, - "d3d11device", device, "window-handle", handle, NULL); + "d3d11device", device, "window-handle", handle, NULL); if (!window->initialized) { gst_object_unref (window); return NULL; @@ -537,4 +550,4 @@ gst_d3d11_window_swap_chain_panel_new (GstD3D11Device * device, guintptr handle) g_object_ref_sink (window); return window; -} \ No newline at end of file +} diff --git a/sys/d3d11/gstd3d11window_win32.cpp b/sys/d3d11/gstd3d11window_win32.cpp index 668ac07..ef01465 100644 --- a/sys/d3d11/gstd3d11window_win32.cpp +++ b/sys/d3d11/gstd3d11window_win32.cpp @@ -26,10 +26,14 @@ #include "gstd3d11window_win32.h" -extern "C" { +/* *INDENT-OFF* */ +G_BEGIN_DECLS + GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_window_debug); #define GST_CAT_DEFAULT gst_d3d11_window_debug -} + +G_END_DECLS +/* *INDENT-ON* */ G_LOCK_DEFINE_STATIC (create_lock); @@ -350,7 +354,7 @@ gst_d3d11_window_win32_release_external_handle (GstD3D11WindowWin32 * self) external_proc); if (!SetWindowLongPtr (self->external_hwnd, - GWLP_WNDPROC, (LONG_PTR) external_proc)) { + GWLP_WNDPROC, (LONG_PTR) external_proc)) { GST_WARNING_OBJECT (self, "Couldn't restore original window procedure"); } @@ -599,7 +603,8 @@ gst_d3d11_window_win32_handle_window_proc (GstD3D11WindowWin32 * self, case WM_MOUSEMOVE: /* To handle mouse event only once, do this only for internal window */ if (self->internal_hwnd && self->internal_hwnd == hWnd) - gst_d3d11_window_win32_on_mouse_event (self, hWnd, uMsg, wParam, lParam); + gst_d3d11_window_win32_on_mouse_event (self, hWnd, uMsg, wParam, + lParam); /* DefWindowProc will not chain up mouse event to parent window */ if (self->external_hwnd && self->external_hwnd != hWnd) @@ -757,8 +762,7 @@ create_swap_chain (GstD3D11WindowWin32 * self, GstD3D11Device * device, IDXGIFactory1 *factory = gst_d3d11_device_get_dxgi_factory_handle (device); gst_d3d11_device_lock (device); - hr = factory->CreateSwapChain ((IUnknown *) device_handle, - desc, &swap_chain); + hr = factory->CreateSwapChain ((IUnknown *) device_handle, desc, &swap_chain); gst_d3d11_device_unlock (device); if (!gst_d3d11_result (hr, device)) { @@ -948,7 +952,6 @@ gst_d3d11_window_win32_present (GstD3D11Window * window, guint present_flags) return GST_D3D11_WINDOW_FLOW_CLOSED; } - #if (GST_D3D11_DXGI_HEADER_VERSION >= 2) if (self->have_swapchain1) { IDXGISwapChain1 *swap_chain1 = (IDXGISwapChain1 *) window->swap_chain; @@ -1022,4 +1025,4 @@ gst_d3d11_window_win32_new (GstD3D11Device * device, guintptr handle) g_object_ref_sink (window); return window; -} \ No newline at end of file +} -- 2.7.4