summaryrefslogtreecommitdiff
path: root/vcl/source/window
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-08-07 14:27:44 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-08-07 14:27:44 +0200
commitc85b25114a756e1abb3e68a4c7d3630c486917b5 (patch)
tree5118c8ab6e715920c7976cd5cbffd64b56c3de58 /vcl/source/window
parentea4a775eb1a15d2be198e42b199af025ed90926a (diff)
tdf#92982 vcl rendercontext: make PaintBufferGuard visible outside paint.cxx
Change-Id: I4bafba3d99fc45d6d5fa875a91d498518d3a0c29
Diffstat (limited to 'vcl/source/window')
-rw-r--r--vcl/source/window/paint.cxx152
1 files changed, 72 insertions, 80 deletions
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 5e83a0067d5c..1438f2cf1b7d 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -40,87 +40,79 @@
#define IMPL_PAINT_ERASE ((sal_uInt16)0x0010)
#define IMPL_PAINT_CHECKRTL ((sal_uInt16)0x0020)
-/// Sets up the buffer to have settings matching the window, and restore the original state in the dtor.
-class PaintBufferGuard
+// PaintBufferGuard
+
+PaintBufferGuard::PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow)
+ : mpFrameData(pFrameData),
+ mbBackground(false),
+ mnOutOffX(0),
+ mnOutOffY(0)
{
- ImplFrameData* mpFrameData;
- bool mbBackground;
- Wallpaper maBackground;
- AllSettings maSettings;
- long mnOutOffX;
- long mnOutOffY;
-public:
- PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow)
- : mpFrameData(pFrameData),
- mbBackground(false),
- mnOutOffX(0),
- mnOutOffY(0)
- {
- // transfer various settings
- // FIXME: this must disappear as we move to RenderContext only,
- // the painting must become state-less, so that no actual
- // vcl::Window setting affects this
- mbBackground = pFrameData->mpBuffer->IsBackground();
- if (pWindow->IsBackground())
- {
- maBackground = pFrameData->mpBuffer->GetBackground();
- pFrameData->mpBuffer->SetBackground(pWindow->GetBackground());
- }
- //else
- //SAL_WARN("vcl.doublebuffering", "the root of the double-buffering hierarchy should not have a transparent background");
-
- PushFlags nFlags = PushFlags::NONE;
- nFlags |= PushFlags::CLIPREGION;
- nFlags |= PushFlags::FILLCOLOR;
- nFlags |= PushFlags::FONT;
- nFlags |= PushFlags::LINECOLOR;
- nFlags |= PushFlags::MAPMODE;
- maSettings = pFrameData->mpBuffer->GetSettings();
- nFlags |= PushFlags::REFPOINT;
- nFlags |= PushFlags::TEXTCOLOR;
- nFlags |= PushFlags::TEXTLINECOLOR;
- nFlags |= PushFlags::OVERLINECOLOR;
- nFlags |= PushFlags::TEXTFILLCOLOR;
- nFlags |= PushFlags::TEXTALIGN;
- nFlags |= PushFlags::RASTEROP;
- nFlags |= PushFlags::TEXTLAYOUTMODE;
- nFlags |= PushFlags::TEXTLANGUAGE;
- pFrameData->mpBuffer->Push(nFlags);
- pFrameData->mpBuffer->SetClipRegion(pWindow->GetClipRegion());
- pFrameData->mpBuffer->SetFillColor(pWindow->GetFillColor());
- pFrameData->mpBuffer->SetFont(pWindow->GetFont());
- pFrameData->mpBuffer->SetLineColor(pWindow->GetLineColor());
- pFrameData->mpBuffer->SetMapMode(pWindow->GetMapMode());
- pFrameData->mpBuffer->SetRefPoint(pWindow->GetRefPoint());
- pFrameData->mpBuffer->SetSettings(pWindow->GetSettings());
- pFrameData->mpBuffer->SetTextColor(pWindow->GetTextColor());
- pFrameData->mpBuffer->SetTextLineColor(pWindow->GetTextLineColor());
- pFrameData->mpBuffer->SetOverlineColor(pWindow->GetOverlineColor());
- pFrameData->mpBuffer->SetTextFillColor(pWindow->GetTextFillColor());
- pFrameData->mpBuffer->SetTextAlign(pWindow->GetTextAlign());
- pFrameData->mpBuffer->SetRasterOp(pWindow->GetRasterOp());
- pFrameData->mpBuffer->SetLayoutMode(pWindow->GetLayoutMode());
- pFrameData->mpBuffer->SetDigitLanguage(pWindow->GetDigitLanguage());
-
- mnOutOffX = pFrameData->mpBuffer->GetOutOffXPixel();
- mnOutOffY = pFrameData->mpBuffer->GetOutOffYPixel();
- pFrameData->mpBuffer->SetOutOffXPixel(pWindow->GetOutOffXPixel());
- pFrameData->mpBuffer->SetOutOffYPixel(pWindow->GetOutOffYPixel());
- }
- ~PaintBufferGuard()
- {
- // Restore buffer state.
- mpFrameData->mpBuffer->SetOutOffXPixel(mnOutOffX);
- mpFrameData->mpBuffer->SetOutOffYPixel(mnOutOffY);
-
- mpFrameData->mpBuffer->Pop();
- mpFrameData->mpBuffer->SetSettings(maSettings);
- if (mbBackground)
- mpFrameData->mpBuffer->SetBackground(maBackground);
- else
- mpFrameData->mpBuffer->SetBackground();
- }
-};
+ // transfer various settings
+ // FIXME: this must disappear as we move to RenderContext only,
+ // the painting must become state-less, so that no actual
+ // vcl::Window setting affects this
+ mbBackground = pFrameData->mpBuffer->IsBackground();
+ if (pWindow->IsBackground())
+ {
+ maBackground = pFrameData->mpBuffer->GetBackground();
+ pFrameData->mpBuffer->SetBackground(pWindow->GetBackground());
+ }
+ //else
+ //SAL_WARN("vcl.doublebuffering", "the root of the double-buffering hierarchy should not have a transparent background");
+
+ PushFlags nFlags = PushFlags::NONE;
+ nFlags |= PushFlags::CLIPREGION;
+ nFlags |= PushFlags::FILLCOLOR;
+ nFlags |= PushFlags::FONT;
+ nFlags |= PushFlags::LINECOLOR;
+ nFlags |= PushFlags::MAPMODE;
+ maSettings = pFrameData->mpBuffer->GetSettings();
+ nFlags |= PushFlags::REFPOINT;
+ nFlags |= PushFlags::TEXTCOLOR;
+ nFlags |= PushFlags::TEXTLINECOLOR;
+ nFlags |= PushFlags::OVERLINECOLOR;
+ nFlags |= PushFlags::TEXTFILLCOLOR;
+ nFlags |= PushFlags::TEXTALIGN;
+ nFlags |= PushFlags::RASTEROP;
+ nFlags |= PushFlags::TEXTLAYOUTMODE;
+ nFlags |= PushFlags::TEXTLANGUAGE;
+ pFrameData->mpBuffer->Push(nFlags);
+ pFrameData->mpBuffer->SetClipRegion(pWindow->GetClipRegion());
+ pFrameData->mpBuffer->SetFillColor(pWindow->GetFillColor());
+ pFrameData->mpBuffer->SetFont(pWindow->GetFont());
+ pFrameData->mpBuffer->SetLineColor(pWindow->GetLineColor());
+ pFrameData->mpBuffer->SetMapMode(pWindow->GetMapMode());
+ pFrameData->mpBuffer->SetRefPoint(pWindow->GetRefPoint());
+ pFrameData->mpBuffer->SetSettings(pWindow->GetSettings());
+ pFrameData->mpBuffer->SetTextColor(pWindow->GetTextColor());
+ pFrameData->mpBuffer->SetTextLineColor(pWindow->GetTextLineColor());
+ pFrameData->mpBuffer->SetOverlineColor(pWindow->GetOverlineColor());
+ pFrameData->mpBuffer->SetTextFillColor(pWindow->GetTextFillColor());
+ pFrameData->mpBuffer->SetTextAlign(pWindow->GetTextAlign());
+ pFrameData->mpBuffer->SetRasterOp(pWindow->GetRasterOp());
+ pFrameData->mpBuffer->SetLayoutMode(pWindow->GetLayoutMode());
+ 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.
+ mpFrameData->mpBuffer->SetOutOffXPixel(mnOutOffX);
+ mpFrameData->mpBuffer->SetOutOffYPixel(mnOutOffY);
+
+ mpFrameData->mpBuffer->Pop();
+ mpFrameData->mpBuffer->SetSettings(maSettings);
+ if (mbBackground)
+ mpFrameData->mpBuffer->SetBackground(maBackground);
+ else
+ mpFrameData->mpBuffer->SetBackground();
+}
class PaintHelper
{