1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-30 02:50:05 +00:00

Direct2D: Remove setResizing and getResizing members from renderer

We instead query from the renderer whether the current render size has
changed since the last frame, and repaint the entire window if so.
This commit is contained in:
reuk 2024-10-02 16:33:42 +01:00
parent 7e73ed7c36
commit c7f7a7c1bb
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
3 changed files with 6 additions and 130 deletions

View file

@ -316,7 +316,6 @@ private:
std::optional<CompositionTree> compositionTree;
RectangleList<int> deferredRepaints;
std::vector<RECT> dirtyRectangles;
bool resizing = false;
int64 lastFinishFrameTicks = 0;
HWND hwnd = nullptr;
@ -377,7 +376,7 @@ private:
RectangleList<int> getPaintAreas() const override
{
// Does the entire buffer need to be filled?
if (swap.state == SwapChain::State::bufferAllocated || resizing)
if (swap.state == SwapChain::State::bufferAllocated)
return swap.getSize();
return deferredRepaints;
@ -451,20 +450,10 @@ public:
return {};
}
void setResizing (bool x)
{
resizing = x;
}
bool getResizing() const
{
return resizing;
}
void setSize (Rectangle<int> size)
bool setSize (Rectangle<int> size)
{
if (size == swap.getSize() || size.isEmpty())
return;
return false;
// Require the entire window to be repainted
deferredRepaints = size;
@ -485,6 +474,8 @@ public:
if (swapChainThread)
swapChainThread->notify();
}
return true;
}
void addDeferredRepaint (Rectangle<int> deferredRepaint)
@ -496,12 +487,7 @@ public:
SavedState* startFrame (float dpiScale) override
{
if (resizing)
{
const auto size = getClientRect();
setSize (size);
deferredRepaints = size;
}
setSize (getClientRect());
auto* savedState = Pimpl::startFrame (dpiScale);
@ -665,7 +651,6 @@ Direct2DHwndContext::Direct2DHwndContext (HWND windowHandle)
#endif
pimpl = std::make_unique<HwndPimpl> (*this, windowHandle);
updateSize();
}
Direct2DHwndContext::~Direct2DHwndContext()
@ -685,26 +670,6 @@ void Direct2DHwndContext::handleShowWindow()
pimpl->handleShowWindow();
}
void Direct2DHwndContext::setResizing (bool x)
{
pimpl->setResizing (x);
}
bool Direct2DHwndContext::getResizing() const
{
return pimpl->getResizing();
}
void Direct2DHwndContext::setSize (int width, int height)
{
pimpl->setSize ({ width, height });
}
void Direct2DHwndContext::updateSize()
{
pimpl->setSize (pimpl->getClientRect());
}
void Direct2DHwndContext::addDeferredRepaint (Rectangle<int> deferredRepaint)
{
pimpl->addDeferredRepaint (deferredRepaint);

View file

@ -43,11 +43,6 @@ public:
void handleShowWindow();
void setResizing (bool);
bool getResizing() const;
void setSize (int width, int height);
void updateSize();
void addDeferredRepaint (Rectangle<int> deferredRepaint);
Image createSnapshot() const override;

View file

@ -1410,10 +1410,7 @@ struct RenderContext
virtual void dispatchDeferredRepaints() = 0;
virtual void performAnyPendingRepaintsNow() = 0;
virtual void onVBlank() = 0;
virtual void setResizing (bool) = 0;
virtual bool getResizing() const = 0;
virtual void handleShowWindow() = 0;
virtual void setSize (int, int) = 0;
/* Gets a snapshot of whatever the render context is currently showing. */
virtual Image createSnapshot() = 0;
@ -1552,16 +1549,6 @@ public:
info.rcWindow.right - info.rcClient.right };
}
void updateBorderSize()
{
if (renderContext == nullptr)
return;
RECT r;
GetClientRect (hwnd, &r);
renderContext->setSize (r.right - r.left, r.bottom - r.top);
}
void setBounds (const Rectangle<int>& bounds, bool isNowFullScreen) override
{
// If we try to set new bounds while handling an existing position change,
@ -1574,13 +1561,6 @@ public:
if (isNowFullScreen != isFullScreen())
setFullScreen (isNowFullScreen);
// This is more of a guess than a certainty, but if we've captured the mouse and we're also
// updating the bounds, there's a good chance we're in a client-initiated resize.
// The resizing flag will be unset by WM_CAPTURECHANGED.
if (GetCapture() == hwnd)
if (renderContext != nullptr)
renderContext->setResizing (true);
const ScopedValueSetter<bool> scope (shouldIgnoreModalDismiss, true);
const auto borderSize = findPhysicalBorderSize();
@ -1633,7 +1613,6 @@ public:
if (hasResized && isValidPeer (this))
{
updateBorderSize();
repaintNowIfTransparent();
}
}
@ -1758,8 +1737,6 @@ public:
if (constrainer != nullptr)
constrainer->resizeEnd();
}
updateBorderSize();
}
bool isFullScreen() const override
@ -2498,7 +2475,6 @@ private:
scaleFactor = getScaleFactorForWindow (hwnd);
setMessageFilter();
updateBorderSize();
checkForPointerAPI();
// This is needed so that our plugin window gets notified of WM_SETTINGCHANGE messages
@ -2861,9 +2837,6 @@ private:
constrainerIsResizing = false;
}
if (renderContext != nullptr && renderContext->getResizing())
renderContext->setResizing (false);
if (isDragging)
doMouseUp (getCurrentMousePos(), (WPARAM) 0, false);
}
@ -3393,8 +3366,6 @@ private:
r = D2DUtilities::toRECT (modifiedPhysicalBounds);
}
updateBorderSize();
return TRUE;
}
@ -3529,7 +3500,6 @@ private:
return true;
}
updateBorderSize();
handleMovedOrResized();
updateCurrentMonitorAndRefreshVBlankDispatcher();
@ -4026,17 +3996,8 @@ private:
break;
case WM_EXITSIZEMOVE:
if (renderContext != nullptr)
renderContext->setResizing (false);
break;
//==============================================================================
case WM_SIZING:
if (renderContext != nullptr)
renderContext->setResizing (true);
return handleSizeConstraining (*(RECT*) lParam, wParam);
case WM_MOVING:
@ -4831,11 +4792,8 @@ public:
: createSnapshotOfNormalWindow();
}
void setSize (int, int) override {}
void onVBlank() override {}
void setResizing (bool x) override { resizing = x; }
bool getResizing() const override { return resizing; }
void handleShowWindow() override {}
private:
@ -5074,7 +5032,6 @@ private:
HWNDComponentPeer& peer;
TemporaryImage offscreenImageGenerator;
RectangleList<int> deferredRepaints;
bool resizing = false;
};
class D2DRenderContext : public RenderContext
@ -5138,24 +5095,6 @@ public:
handleDirect2DPaint();
}
void setResizing (bool x) override
{
direct2DContext->setResizing (x);
}
bool getResizing() const override
{
return direct2DContext->getResizing();
}
void setSize (int w, int h) override
{
JUCE_TRACE_LOG_D2D_RESIZE (WM_NCCALCSIZE);
if (peer.getComponent().isVisible())
direct2DContext->setSize (w, h);
}
void handleShowWindow() override
{
direct2DContext->handleShowWindow();
@ -5168,9 +5107,6 @@ private:
virtual ~WrappedD2DHwndContextBase() = default;
virtual void addDeferredRepaint (Rectangle<int> area) = 0;
virtual Image createSnapshot() const = 0;
virtual void setResizing (bool x) = 0;
virtual bool getResizing() const = 0;
virtual void setSize (int w, int h) = 0;
virtual void handleShowWindow() = 0;
virtual LowLevelGraphicsContext* startFrame (float dpiScale) = 0;
virtual void endFrame() = 0;
@ -5208,21 +5144,6 @@ private:
return ctx.createSnapshot();
}
void setResizing (bool x) override
{
ctx.setResizing (x);
}
bool getResizing() const override
{
return ctx.getResizing();
}
void setSize (int w, int h) override
{
ctx.setSize (w, h);
}
void handleShowWindow() override
{
ctx.handleShowWindow();
@ -5395,10 +5316,6 @@ private:
return renderer.getImage();
}
void setResizing (bool x) override { resizing = x; }
bool getResizing() const override { return resizing; }
void setSize (int, int) override {}
void handleShowWindow() override {}
LowLevelGraphicsContext* startFrame (float scale) override
@ -5490,7 +5407,6 @@ private:
DxgiBitmapRenderer bitmapRenderer;
RectangleList<int> deferredRepaints;
bool resizing = false;
};
void handleDirect2DPaint()