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

tdf#92982 vcl rendercontext: let PaintBufferGuard also manage pixel offset

Change-Id: Ifd6a75c4312f93c815f5d137f515724f3629fa0d
üst c36a00b8
...@@ -319,7 +319,6 @@ namespace vcl { ...@@ -319,7 +319,6 @@ namespace vcl {
class VCL_DLLPUBLIC OutputDevice class VCL_DLLPUBLIC OutputDevice
{ {
friend class PaintHelper;
friend class Printer; friend class Printer;
friend class VirtualDevice; friend class VirtualDevice;
friend class vcl::Window; friend class vcl::Window;
...@@ -500,6 +499,8 @@ public: ...@@ -500,6 +499,8 @@ public:
long GetOutputHeightPixel() const { return mnOutHeight; } long GetOutputHeightPixel() const { return mnOutHeight; }
long GetOutOffXPixel() const { return mnOutOffX; } long GetOutOffXPixel() const { return mnOutOffX; }
long GetOutOffYPixel() const { return mnOutOffY; } long GetOutOffYPixel() const { return mnOutOffY; }
void SetOutOffXPixel(long nOutOffX);
void SetOutOffYPixel(long nOutOffY);
Size GetOutputSize() const Size GetOutputSize() const
{ return PixelToLogic( GetOutputSizePixel() ); } { return PixelToLogic( GetOutputSizePixel() ); }
......
...@@ -426,6 +426,16 @@ sal_uInt16 OutputDevice::GetBitCount() const ...@@ -426,6 +426,16 @@ sal_uInt16 OutputDevice::GetBitCount() const
return (sal_uInt16)mpGraphics->GetBitCount(); return (sal_uInt16)mpGraphics->GetBitCount();
} }
void OutputDevice::SetOutOffXPixel(long nOutOffX)
{
mnOutOffX = nOutOffX;
}
void OutputDevice::SetOutOffYPixel(long nOutOffY)
{
mnOutOffY = nOutOffY;
}
sal_uLong OutputDevice::GetColorCount() const sal_uLong OutputDevice::GetColorCount() const
{ {
......
...@@ -47,10 +47,14 @@ class PaintBufferGuard ...@@ -47,10 +47,14 @@ class PaintBufferGuard
bool mbBackground; bool mbBackground;
Wallpaper maBackground; Wallpaper maBackground;
AllSettings maSettings; AllSettings maSettings;
long mnOutOffX;
long mnOutOffY;
public: public:
PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow) PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow)
: mpFrameData(pFrameData), : mpFrameData(pFrameData),
mbBackground(false) mbBackground(false),
mnOutOffX(0),
mnOutOffY(0)
{ {
// 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,
...@@ -97,10 +101,18 @@ public: ...@@ -97,10 +101,18 @@ public:
pFrameData->mpBuffer->SetRasterOp(pWindow->GetRasterOp()); pFrameData->mpBuffer->SetRasterOp(pWindow->GetRasterOp());
pFrameData->mpBuffer->SetLayoutMode(pWindow->GetLayoutMode()); pFrameData->mpBuffer->SetLayoutMode(pWindow->GetLayoutMode());
pFrameData->mpBuffer->SetDigitLanguage(pWindow->GetDigitLanguage()); pFrameData->mpBuffer->SetDigitLanguage(pWindow->GetDigitLanguage());
mnOutOffX = pFrameData->mpBuffer->GetOutOffXPixel();
mnOutOffY = pFrameData->mpBuffer->GetOutOffYPixel();
pFrameData->mpBuffer->SetOutOffXPixel(pWindow->GetOutOffXPixel());
pFrameData->mpBuffer->SetOutOffYPixel(pWindow->GetOutOffYPixel());
} }
~PaintBufferGuard() ~PaintBufferGuard()
{ {
// Restore buffer state. // Restore buffer state.
mpFrameData->mpBuffer->SetOutOffXPixel(mnOutOffX);
mpFrameData->mpBuffer->SetOutOffYPixel(mnOutOffY);
mpFrameData->mpBuffer->Pop(); mpFrameData->mpBuffer->Pop();
mpFrameData->mpBuffer->SetSettings(maSettings); mpFrameData->mpBuffer->SetSettings(maSettings);
if (mbBackground) if (mbBackground)
...@@ -183,16 +195,13 @@ void PaintHelper::StartBufferedPaint() ...@@ -183,16 +195,13 @@ void PaintHelper::StartBufferedPaint()
// painting over, as VirtualDevice::ImplInitVirDev() would do. // painting over, as VirtualDevice::ImplInitVirDev() would do.
// The painted area is m_aPaintRect, or in case it's empty, then the whole window. // The painted area is m_aPaintRect, or in case it's empty, then the whole window.
pFrameData->mpBuffer->SetBackground(Wallpaper(Color(COL_WHITE))); pFrameData->mpBuffer->SetBackground(Wallpaper(Color(COL_WHITE)));
long nOutOffX = pFrameData->mpBuffer->GetOutOffXPixel(); {
long nOutOffY = pFrameData->mpBuffer->GetOutOffYPixel(); PaintBufferGuard g(pFrameData, m_pWindow);
pFrameData->mpBuffer->mnOutOffX = m_pWindow->GetOutOffXPixel(); if (m_aPaintRect.IsEmpty())
pFrameData->mpBuffer->mnOutOffY = m_pWindow->GetOutOffYPixel(); pFrameData->mpBuffer->Erase(Rectangle(Point(0, 0), m_pWindow->GetOutputSize()));
if (m_aPaintRect.IsEmpty()) else
pFrameData->mpBuffer->Erase(Rectangle(Point(0, 0), m_pWindow->GetOutputSize())); pFrameData->mpBuffer->Erase(m_aPaintRect);
else }
pFrameData->mpBuffer->Erase(m_aPaintRect);
pFrameData->mpBuffer->mnOutOffX = nOutOffX;
pFrameData->mpBuffer->mnOutOffY = nOutOffY;
pFrameData->mbInBufferedPaint = true; pFrameData->mbInBufferedPaint = true;
m_bStartedBufferedPaint = true; m_bStartedBufferedPaint = true;
...@@ -232,13 +241,8 @@ void PaintHelper::PaintBuffer() ...@@ -232,13 +241,8 @@ void PaintHelper::PaintBuffer()
aPaintRectSize = m_pWindow->PixelToLogic(aRectanglePixel.GetSize()); aPaintRectSize = m_pWindow->PixelToLogic(aRectanglePixel.GetSize());
} }
long nOutOffX = pFrameData->mpBuffer->GetOutOffXPixel(); PaintBufferGuard g(pFrameData, m_pWindow);
long nOutOffY = pFrameData->mpBuffer->GetOutOffYPixel();
pFrameData->mpBuffer->mnOutOffX = m_pWindow->GetOutOffXPixel();
pFrameData->mpBuffer->mnOutOffY = m_pWindow->GetOutOffYPixel();
m_pWindow->DrawOutDev(m_aPaintRect.TopLeft(), aPaintRectSize, m_aPaintRect.TopLeft(), aPaintRectSize, *pFrameData->mpBuffer.get()); m_pWindow->DrawOutDev(m_aPaintRect.TopLeft(), aPaintRectSize, m_aPaintRect.TopLeft(), aPaintRectSize, *pFrameData->mpBuffer.get());
pFrameData->mpBuffer->mnOutOffX = nOutOffX;
pFrameData->mpBuffer->mnOutOffY = nOutOffY;
} }
} }
...@@ -289,14 +293,8 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion) ...@@ -289,14 +293,8 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion)
PaintBufferGuard g(pFrameData, m_pWindow); PaintBufferGuard g(pFrameData, m_pWindow);
m_pWindow->ApplySettings(*pFrameData->mpBuffer.get()); m_pWindow->ApplySettings(*pFrameData->mpBuffer.get());
long nOutOffX = pFrameData->mpBuffer->mnOutOffX;
long nOutOffY = pFrameData->mpBuffer->mnOutOffY;
pFrameData->mpBuffer->mnOutOffX = m_pWindow->GetOutOffXPixel();
pFrameData->mpBuffer->mnOutOffY = m_pWindow->GetOutOffYPixel();
m_pWindow->PushPaintHelper(this, *pFrameData->mpBuffer.get()); m_pWindow->PushPaintHelper(this, *pFrameData->mpBuffer.get());
m_pWindow->Paint(*pFrameData->mpBuffer.get(), m_aPaintRect); m_pWindow->Paint(*pFrameData->mpBuffer.get(), m_aPaintRect);
pFrameData->mpBuffer->mnOutOffX = nOutOffX;
pFrameData->mpBuffer->mnOutOffY = nOutOffY;
} }
else else
{ {
......
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