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

Direct2D: Tidy up clearWindowRedirectionBitmap

This commit is contained in:
reuk 2024-06-20 14:36:00 +01:00
parent fe1a11908e
commit 815da2ec6d

View file

@ -518,27 +518,28 @@ public:
void clearWindowRedirectionBitmap() void clearWindowRedirectionBitmap()
{ {
if (! opaque && swap.state == SwapChain::State::bufferAllocated) if (opaque || swap.state != SwapChain::State::bufferAllocated)
{ return;
deviceResources.deviceContext.createHwndRenderTarget (hwnd);
// Clear the GDI redirection bitmap using a Direct2D 1.0 render target deviceResources.deviceContext.createHwndRenderTarget (hwnd);
auto& hwndRenderTarget = deviceResources.deviceContext.hwndRenderTarget;
if (hwndRenderTarget) // Clear the GDI redirection bitmap using a Direct2D 1.0 render target
{ const auto& hwndRenderTarget = deviceResources.deviceContext.hwndRenderTarget;
const auto colorF = D2DUtilities::toCOLOR_F (getBackgroundTransparencyKeyColour());
RECT clientRect; if (hwndRenderTarget == nullptr)
GetClientRect (hwnd, &clientRect); return;
D2D1_SIZE_U size { (uint32) (clientRect.right - clientRect.left), (uint32) (clientRect.bottom - clientRect.top) }; const auto colorF = D2DUtilities::toCOLOR_F (getBackgroundTransparencyKeyColour());
hwndRenderTarget->Resize (size);
hwndRenderTarget->BeginDraw(); RECT clientRect;
hwndRenderTarget->Clear (colorF); GetClientRect (hwnd, &clientRect);
hwndRenderTarget->EndDraw();
} const D2D1_SIZE_U size { (uint32) (clientRect.right - clientRect.left),
} (uint32) (clientRect.bottom - clientRect.top) };
hwndRenderTarget->Resize (size);
hwndRenderTarget->BeginDraw();
hwndRenderTarget->Clear (colorF);
hwndRenderTarget->EndDraw();
} }
SavedState* startFrame (float dpiScale) override SavedState* startFrame (float dpiScale) override