[Libreoffice-commits] core.git: vcl/inc vcl/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Aug 7 05:28:20 PDT 2015


 vcl/inc/window.h            |   14 ++++
 vcl/source/window/paint.cxx |  152 ++++++++++++++++++++------------------------
 2 files changed, 86 insertions(+), 80 deletions(-)

New commits:
commit c85b25114a756e1abb3e68a4c7d3630c486917b5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Aug 7 14:27:44 2015 +0200

    tdf#92982 vcl rendercontext: make PaintBufferGuard visible outside paint.cxx
    
    Change-Id: I4bafba3d99fc45d6d5fa875a91d498518d3a0c29

diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index f4976f2..e2acda8 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -382,6 +382,20 @@ public:
     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer;
 };
 
+/// Sets up the buffer to have settings matching the window, and restores the original state in the dtor.
+class PaintBufferGuard
+{
+    ImplFrameData* mpFrameData;
+    bool mbBackground;
+    Wallpaper maBackground;
+    AllSettings maSettings;
+    long mnOutOffX;
+    long mnOutOffY;
+public:
+    PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow);
+    ~PaintBufferGuard();
+};
+
 // helper methods
 
 bool ImplHandleMouseEvent( vcl::Window* pWindow, MouseNotifyEvent nSVEvent, bool bMouseLeave,
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 5e83a00..1438f2c 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
 {


More information about the Libreoffice-commits mailing list