1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Direct2D: Remove SwapChainThread completely

D2D repaints are always driven by a vblank timer, and D2D presentation
can't happen any faster than the vblank callbacks, so I think it's safe
to remove the swapchain machinery and to rely entirely on the vblank
callbacks instead.
This commit is contained in:
reuk 2025-12-15 17:54:38 +00:00
parent cd6176bd00
commit 22ae5baa42
No known key found for this signature in database
3 changed files with 13 additions and 135 deletions

View file

@ -5047,8 +5047,7 @@ private:
RectangleList<int> deferredRepaints;
};
class D2DRenderContext : public RenderContext,
private Direct2DHwndContext::SwapchainDelegate
class D2DRenderContext : public RenderContext
{
public:
static constexpr auto name = "Direct2D";
@ -5067,7 +5066,7 @@ public:
if (transparent != direct2DContext->supportsTransparency())
{
direct2DContext.reset();
direct2DContext = getContextForPeer (peer, *this);
direct2DContext = getContextForPeer (peer);
}
if (direct2DContext->supportsTransparency())
@ -5114,11 +5113,6 @@ public:
}
private:
void onSwapchainEvent() override
{
handleDirect2DPaint();
}
struct WrappedD2DHwndContextBase
{
virtual ~WrappedD2DHwndContextBase() = default;
@ -5149,8 +5143,8 @@ private:
class WrappedD2DHwndContext : public WrappedD2DHwndContextBase
{
public:
WrappedD2DHwndContext (HWND hwnd, SwapchainDelegate& swapDelegate)
: ctx (hwnd, swapDelegate) {}
explicit WrappedD2DHwndContext (HWND hwnd)
: ctx (hwnd) {}
void addDeferredRepaint (Rectangle<int> area) override
{
@ -5466,18 +5460,17 @@ private:
#endif
}
static std::unique_ptr<WrappedD2DHwndContextBase> getContextForPeer (HWNDComponentPeer& peer,
SwapchainDelegate& delegate)
static std::unique_ptr<WrappedD2DHwndContextBase> getContextForPeer (HWNDComponentPeer& peer)
{
if (peer.getTransparencyKind() != HWNDComponentPeer::TransparencyKind::opaque)
return std::make_unique<WrappedD2DHwndContextTransparent> (peer);
return std::make_unique<WrappedD2DHwndContext> (peer.getHWND(), delegate);
return std::make_unique<WrappedD2DHwndContext> (peer.getHWND());
}
HWNDComponentPeer& peer;
std::unique_ptr<WrappedD2DHwndContextBase> direct2DContext = getContextForPeer (peer, *this);
std::unique_ptr<WrappedD2DHwndContextBase> direct2DContext = getContextForPeer (peer);
UpdateRegion updateRegion;
#if JUCE_ETW_TRACELOGGING