[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - vcl/workben

Michael Meeks michael.meeks at collabora.com
Thu Nov 13 05:56:47 PST 2014


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

New commits:
commit cca52572c73a7e41960744b71241f8fa8804470f
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 fa38874..06a6d86 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -510,20 +510,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);
         }
     };
 
@@ -578,17 +625,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