From 6402641d494ad0edbdbd093afa5960ebc1386173 Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 1 Jul 2024 15:28:31 +0100 Subject: [PATCH] Direct2D: Avoid applying pending clip list in excludeClipRectangle unless the transform is non-trivial Frequently, excludeClipRectangle will be called several times in a row, in order to trim away borders on each side of a rectangle. When this happens, we want to avoid creating geometric clip layers which exclude only two or three of the borders, and instead wait until all borders have been excluded before applying the clip list. This way, it may be possible to simplify the clip list to a single rectangle, which can be implemented using the faster axis-aligned clipping layer. --- .../native/juce_Direct2DGraphicsContext_windows.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp b/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp index 47782496a6..ed81f9b46a 100644 --- a/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp +++ b/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp @@ -1000,8 +1000,6 @@ void Direct2DGraphicsContext::excludeClipRectangle (const Rectangle& userSp { JUCE_SCOPED_TRACE_EVENT_FRAME_RECT_I32 (etw::excludeClipRectangle, etw::direct2dKeyword, getFrameId(), userSpaceExcludedRectangle) - applyPendingClipList(); - auto& transform = currentState->currentTransform; auto& deviceSpaceClipList = currentState->deviceSpaceClipList; const auto frameSize = getPimpl()->getFrameSize().toFloat(); @@ -1030,6 +1028,8 @@ void Direct2DGraphicsContext::excludeClipRectangle (const Rectangle& userSp } else { + applyPendingClipList(); + deviceSpaceClipList = frameSize; pendingClipList.subtract (userSpaceExcludedRectangle.toFloat()); }