Kaydet (Commit) a6c7a0bf authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#92982 vcl rendercontext: move buffer paint logic to PaintBufferGuard

The motivation is that this way vcl::Cursor will be able to reuse it.

Change-Id: I7e89d5acb5d63d3297d7c3c8050ccd2172c8608d
üst 25534a62
...@@ -386,14 +386,18 @@ public: ...@@ -386,14 +386,18 @@ public:
class PaintBufferGuard class PaintBufferGuard
{ {
ImplFrameData* mpFrameData; ImplFrameData* mpFrameData;
VclPtr<vcl::Window> m_pWindow;
bool mbBackground; bool mbBackground;
Wallpaper maBackground; Wallpaper maBackground;
AllSettings maSettings; AllSettings maSettings;
long mnOutOffX; long mnOutOffX;
long mnOutOffY; long mnOutOffY;
Rectangle m_aPaintRect;
public: public:
PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow); PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow);
~PaintBufferGuard(); ~PaintBufferGuard();
/// If this is called, then the dtor will also copy rRectangle to the window from the buffer, before restoring the state.
void SetPaintRect(const Rectangle& rRectangle);
}; };
// helper methods // helper methods
......
...@@ -44,10 +44,14 @@ ...@@ -44,10 +44,14 @@
PaintBufferGuard::PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow) PaintBufferGuard::PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow)
: mpFrameData(pFrameData), : mpFrameData(pFrameData),
m_pWindow(pWindow),
mbBackground(false), mbBackground(false),
mnOutOffX(0), mnOutOffX(0),
mnOutOffY(0) mnOutOffY(0)
{ {
if (!pFrameData->mpBuffer)
return;
// transfer various settings // transfer various settings
// FIXME: this must disappear as we move to RenderContext only, // FIXME: this must disappear as we move to RenderContext only,
// the painting must become state-less, so that no actual // the painting must become state-less, so that no actual
...@@ -102,6 +106,34 @@ PaintBufferGuard::PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWind ...@@ -102,6 +106,34 @@ PaintBufferGuard::PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWind
PaintBufferGuard::~PaintBufferGuard() PaintBufferGuard::~PaintBufferGuard()
{ {
if (!mpFrameData->mpBuffer)
return;
if (!m_aPaintRect.IsEmpty())
{
// copy the buffer content to the actual window
// export VCL_DOUBLEBUFFERING_AVOID_PAINT=1 to see where we are
// painting directly instead of using Invalidate()
// [ie. everything you can see was painted directly to the
// window either above or in eg. an event handler]
if (!getenv("VCL_DOUBLEBUFFERING_AVOID_PAINT"))
{
// Make sure that the +1 value GetSize() adds to the size is in pixels.
Size aPaintRectSize;
if (m_pWindow->GetMapMode().GetMapUnit() == MAP_PIXEL)
{
aPaintRectSize = m_aPaintRect.GetSize();
}
else
{
Rectangle aRectanglePixel = m_pWindow->LogicToPixel(m_aPaintRect);
aPaintRectSize = m_pWindow->PixelToLogic(aRectanglePixel.GetSize());
}
m_pWindow->DrawOutDev(m_aPaintRect.TopLeft(), aPaintRectSize, m_aPaintRect.TopLeft(), aPaintRectSize, *mpFrameData->mpBuffer.get());
}
}
// Restore buffer state. // Restore buffer state.
mpFrameData->mpBuffer->SetOutOffXPixel(mnOutOffX); mpFrameData->mpBuffer->SetOutOffXPixel(mnOutOffX);
mpFrameData->mpBuffer->SetOutOffYPixel(mnOutOffY); mpFrameData->mpBuffer->SetOutOffYPixel(mnOutOffY);
...@@ -114,6 +146,11 @@ PaintBufferGuard::~PaintBufferGuard() ...@@ -114,6 +146,11 @@ PaintBufferGuard::~PaintBufferGuard()
mpFrameData->mpBuffer->SetBackground(); mpFrameData->mpBuffer->SetBackground();
} }
void PaintBufferGuard::SetPaintRect(const Rectangle& rRectangle)
{
m_aPaintRect = rRectangle;
}
class PaintHelper class PaintHelper
{ {
private: private:
...@@ -192,28 +229,8 @@ void PaintHelper::PaintBuffer() ...@@ -192,28 +229,8 @@ void PaintHelper::PaintBuffer()
assert(pFrameData->mbInBufferedPaint); assert(pFrameData->mbInBufferedPaint);
assert(m_bStartedBufferedPaint); assert(m_bStartedBufferedPaint);
// copy the buffer content to the actual window PaintBufferGuard aGuard(pFrameData, m_pWindow);
// export VCL_DOUBLEBUFFERING_AVOID_PAINT=1 to see where we are aGuard.SetPaintRect(m_aPaintRect);
// painting directly instead of using Invalidate()
// [ie. everything you can see was painted directly to the
// window either above or in eg. an event handler]
if (!getenv("VCL_DOUBLEBUFFERING_AVOID_PAINT"))
{
// Make sure that the +1 value GetSize() adds to the size is in pixels.
Size aPaintRectSize;
if (m_pWindow->GetMapMode().GetMapUnit() == MAP_PIXEL)
{
aPaintRectSize = m_aPaintRect.GetSize();
}
else
{
Rectangle aRectanglePixel = m_pWindow->LogicToPixel(m_aPaintRect);
aPaintRectSize = m_pWindow->PixelToLogic(aRectanglePixel.GetSize());
}
PaintBufferGuard g(pFrameData, m_pWindow);
m_pWindow->DrawOutDev(m_aPaintRect.TopLeft(), aPaintRectSize, m_aPaintRect.TopLeft(), aPaintRectSize, *pFrameData->mpBuffer.get());
}
} }
void PaintHelper::DoPaint(const vcl::Region* pRegion) void PaintHelper::DoPaint(const vcl::Region* pRegion)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment