[Libreoffice-commits] core.git: vcl/workben

Michael Meeks michael.meeks at collabora.com
Thu Nov 13 06:20:13 PST 2014


 vcl/workben/vcldemo.cxx |   68 ++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 58 insertions(+), 10 deletions(-)

New commits:
commit 779b57b8244ee7552a125b8cef9b51ebad34921a
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Nov 13 13:48:24 2014 +0000

    vcldemo: add OutputDevice / copyBits test case.
    
    Change-Id: Ie585daba1d1a1f1dc9f2957c19462a501131d10a

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 177cd51..b5d2ccc 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -495,20 +495,67 @@ public:
 
     struct DrawToVirtualDevice : public RegionRenderer
     {
+        enum RenderType {
+            RENDER_AS_BITMAP,
+            RENDER_AS_OUTDEV,
+            RENDER_AS_BITMAPEX,
+            RENDER_AS_ALPHA_OUTDEV
+        };
+
+        void SizeAndRender(OutputDevice &rDev, Rectangle r, RenderType eType,
+                           const RenderContext &rCtx)
+        {
+            VirtualDevice *pNested;
+
+            if ((int)eType < RENDER_AS_BITMAPEX)
+                pNested = new VirtualDevice(rDev);
+            else
+                pNested = new VirtualDevice(rDev,0,0);
+
+            pNested->SetOutputSizePixel(r.GetSize());
+            Rectangle aWhole(Point(0,0), r.GetSize());
+
+            // mini me
+            rCtx.mpDemoWin->drawToDevice(*pNested, true);
+
+            if (eType == RENDER_AS_BITMAP)
+            {
+                Bitmap aBitmap(pNested->GetBitmap(Point(0,0),aWhole.GetSize()));
+                rDev.DrawBitmap(r.TopLeft(), aBitmap);
+            }
+            else if (eType == RENDER_AS_BITMAPEX)
+            {
+                BitmapEx aBitmapEx(pNested->GetBitmapEx(Point(0,0),aWhole.GetSize()));
+                rDev.DrawBitmapEx(r.TopLeft(), aBitmapEx);
+            }
+            else if (eType == RENDER_AS_OUTDEV ||
+                     eType == RENDER_AS_ALPHA_OUTDEV)
+            {
+                rDev.DrawOutDev(r.TopLeft(), r.GetSize(),
+                                aWhole.TopLeft(), aWhole.GetSize(),
+                                *pNested);
+            }
+            delete pNested;
+        }
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &rCtx) SAL_OVERRIDE
         {
             // avoid infinite recursion
             if (rCtx.mbVDev)
                 return;
-            VirtualDevice aNested(rDev);
-            aNested.SetOutputSizePixel(r.GetSize());
-            Rectangle aWhole(Point(0,0), r.GetSize());
-            // mini me
-            rCtx.mpDemoWin->drawToDevice(aNested, true);
 
-            Bitmap aBitmap(aNested.GetBitmap(Point(0,0),aWhole.GetSize()));
-            rDev.DrawBitmap(r.TopLeft(), aBitmap);
+            if (rCtx.meStyle == RENDER_EXPANDED)
+            {
+                std::vector<Rectangle> aRegions(DemoWin::partition(rDev, 2, 2));
+                DemoWin::clearRects(rDev, aRegions);
+
+                RenderType eRenderTypes[] = { RENDER_AS_BITMAP, RENDER_AS_OUTDEV,
+                                              RENDER_AS_BITMAPEX, RENDER_AS_ALPHA_OUTDEV };
+                for (size_t i = 0; i < aRegions.size(); i++)
+                    SizeAndRender(rDev, aRegions[i], eRenderTypes[i], rCtx);
+            }
+            else
+                SizeAndRender(rDev, r, RENDER_AS_BITMAP, rCtx);
         }
     };
 
@@ -563,17 +610,18 @@ public:
         }
     };
 
-    void drawToDevice(OutputDevice &rDev, bool bVdev)
+    void drawToDevice(OutputDevice &rDev, bool bVDev)
     {
         RenderContext aCtx;
-        aCtx.mbVDev = bVdev;
+        aCtx.mbVDev = bVDev;
         aCtx.mpDemoWin = this;
 
         Rectangle aWholeWin(Point(0,0), rDev.GetOutputSizePixel());
 
         drawBackground(rDev, aWholeWin);
 
-        if (mnSelectedRenderer >= 0)
+        if (!bVDev /* want everything in the vdev */ &&
+            mnSelectedRenderer >= 0)
         {
             aCtx.meStyle = RENDER_EXPANDED;
             maRenderers[mnSelectedRenderer]->RenderRegion(rDev, aWholeWin, aCtx);


More information about the Libreoffice-commits mailing list