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

Direct2D: Avoid using dirty rects when painting full frame

This fixes an issue where Direct2D will emit an error when using dirty
rects on the first full frame after resizing.

The issue isn't present on all hardware/drivers, but was observed on a
Windows 11 computer with a 890M iGPU.
This commit is contained in:
reuk 2024-10-11 22:08:39 +01:00
parent 83dc660a30
commit f5cc7902b1

View file

@ -301,20 +301,23 @@ public:
if (swap.buffer == nullptr || dirtyRegionsInBackBuffer.isEmpty() || ! swapEventReceived)
return;
// Allocate enough memory for the array of dirty rectangles
dirtyRectangles.resize ((size_t) dirtyRegionsInBackBuffer.getNumRectangles());
// Fill the array of dirty rectangles, intersecting each paint area with the swap chain buffer
DXGI_PRESENT_PARAMETERS presentParameters{};
presentParameters.pDirtyRects = dirtyRectangles.data();
presentParameters.DirtyRectsCount = 0;
auto const swapChainSize = swap.getSize();
DXGI_PRESENT_PARAMETERS presentParameters{};
for (const auto& area : dirtyRegionsInBackBuffer)
if (! dirtyRegionsInBackBuffer.containsRectangle (swapChainSize))
{
if (const auto intersection = area.getIntersection (swapChainSize); ! intersection.isEmpty())
presentParameters.pDirtyRects[presentParameters.DirtyRectsCount++] = D2DUtilities::toRECT (intersection);
// Allocate enough memory for the array of dirty rectangles
dirtyRectangles.resize ((size_t) dirtyRegionsInBackBuffer.getNumRectangles());
// Fill the array of dirty rectangles, intersecting each paint area with the swap chain buffer
presentParameters.pDirtyRects = dirtyRectangles.data();
presentParameters.DirtyRectsCount = 0;
for (const auto& area : dirtyRegionsInBackBuffer)
{
if (const auto intersection = area.getIntersection (swapChainSize); ! intersection.isEmpty())
presentParameters.pDirtyRects[presentParameters.DirtyRectsCount++] = D2DUtilities::toRECT (intersection);
}
}
// Present the freshly painted buffer