From 362a1cc07034655d2ff3dee786b3c8a72ea1145e Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 9 Oct 2024 16:47:08 +0100 Subject: [PATCH] Direct2D: Convert unnecessary multi-threaded factory to single-threaded --- .../native/juce_Direct2DHwndContext_windows.cpp | 4 ++-- modules/juce_graphics/native/juce_DirectX_windows.h | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp b/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp index ee5fe35d24..2b7c483d6c 100644 --- a/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp +++ b/modules/juce_graphics/native/juce_Direct2DHwndContext_windows.cpp @@ -336,6 +336,8 @@ public: Image createSnapshot() const { + JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED + // This won't capture child windows. Perhaps a better approach would be to use // IGraphicsCaptureItemInterop, although this is only supported on Windows 10 v1903+ @@ -357,8 +359,6 @@ public: if (const auto hr = context->CreateBitmap (size, nullptr, 0, bitmapProperties, snapshot.resetAndGetPointerAddress()); FAILED (hr)) return {}; - const ScopedMultithread scope { directX->getD2DMultithread() }; - swap.chain->Present (0, DXGI_PRESENT_DO_NOT_WAIT); // Copy the swap chain buffer to the bitmap snapshot diff --git a/modules/juce_graphics/native/juce_DirectX_windows.h b/modules/juce_graphics/native/juce_DirectX_windows.h index 1959a7ea44..7e1d91688f 100644 --- a/modules/juce_graphics/native/juce_DirectX_windows.h +++ b/modules/juce_graphics/native/juce_DirectX_windows.h @@ -261,7 +261,6 @@ public: DirectX() = default; auto getD2DFactory() const { return d2dSharedFactory; } - auto getD2DMultithread() const { return multithread; } private: ComSmartPtr d2dSharedFactory = [&] @@ -270,7 +269,7 @@ private: options.debugLevel = D2D1_DEBUG_LEVEL_NONE; JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wlanguage-extension-token") ComSmartPtr result; - auto hr = D2D1CreateFactory (D2D1_FACTORY_TYPE_MULTI_THREADED, + auto hr = D2D1CreateFactory (D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof (ID2D1Factory2), &options, (void**) result.resetAndGetPointerAddress()); @@ -280,13 +279,6 @@ private: return result; }(); - ComSmartPtr multithread = [&] - { - ComSmartPtr result; - d2dSharedFactory->QueryInterface (result.resetAndGetPointerAddress()); - return result; - }(); - public: DxgiAdapters adapters { d2dSharedFactory };