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

Michael Meeks michael.meeks at collabora.com
Sat Jan 2 09:22:53 PST 2016


 vcl/workben/vcldemo.cxx |   78 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

New commits:
commit 45c8bbe9303094b50035967846196cf3b7c72ea6
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Jan 2 12:51:02 2016 +0000

    vcldemo - more clipping tests for RegionBand and Polygon cases.
    
    Change-Id: I959c0874c670027e79163ded6a1d8c8b55d66376
    Reviewed-on: https://gerrit.libreoffice.org/21045
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 9f24deb..19e4fe8 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -811,6 +811,84 @@ public:
                 }
                 rDev.Pop();
             }
+
+            {
+                sal_uInt16 nHue = 0;
+                Rectangle aOuter = aRegions[2];
+                std::vector<Rectangle> aPieces(DemoRenderer::partition(aOuter, 2, 2));
+                for (int j = 0; j < std::min(aOuter.GetWidth(), aOuter.GetHeight())/5; ++j)
+                {
+                    rDev.Push(PushFlags::CLIPREGION);
+
+                    vcl::Region aClipRegion;
+                    for (int i = 0; i < 4; ++i)
+                    {
+                        aPieces[i].expand(-1);
+                        aPieces[i].Move(2 - i/2, 2 - i/2);
+                        aClipRegion.Union(aPieces[i]);
+                    }
+                    assert (aClipRegion.getRegionBand());
+                    rDev.SetClipRegion(vcl::Region(aClipRegion));
+                    rDev.SetFillColor(Color::HSBtoRGB(nHue, 75, 75));
+                    nHue = (nHue + 97) % 360;
+                    rDev.DrawRect(aOuter);
+
+                    rDev.Pop();
+                }
+            }
+
+            {
+                sal_uInt16 nHue = 0;
+                Rectangle aOuter = aRegions[3];
+                std::vector<Rectangle> aPieces(DemoRenderer::partition(aOuter, 2, 2));
+                bool bDone = false;
+                for (int j = 0; !bDone; ++j)
+                {
+                    rDev.Push(PushFlags::CLIPREGION);
+
+                    for (int i = 0; i < 4; ++i)
+                    {
+                        vcl::Region aClipRegion;
+                        tools::Polygon aPoly;
+                        switch (i) {
+                        case 3:
+                        case 0: // 45degree rectangle.
+                            aPoly = tools::Polygon(aPieces[i]);
+                            aPoly.Rotate(aPieces[i].Center(), 450);
+                            break;
+                        case 1: // arc
+                            aPoly = tools::Polygon(aPieces[i],
+                                                   aPieces[i].TopLeft(),
+                                                   aPieces[i].BottomRight());
+                            break;
+                        case 2:
+                            aPoly = tools::Polygon(aPieces[i],
+                                                   aPieces[i].GetWidth()/5,
+                                                   aPieces[i].GetHeight()/5);
+                            aPoly.Rotate(aPieces[i].Center(), 450);
+                            break;
+                        }
+                        aClipRegion = vcl::Region(aPoly);
+                        aPieces[i].expand(-1);
+                        aPieces[i].Move(2 - i/2, 2 - i/2);
+
+                        bDone = aPieces[i].GetWidth() < 4 ||
+                                aPieces[i].GetHeight() < 4;
+
+                        if (!bDone)
+                        {
+                            assert (!aClipRegion.getRegionBand());
+
+                            rDev.SetClipRegion(vcl::Region(aClipRegion));
+                            rDev.SetFillColor(Color::HSBtoRGB(nHue, 50, 75));
+                            nHue = (nHue + 97) % 360;
+                            rDev.DrawRect(aOuter);
+                        }
+                    }
+
+                    rDev.Pop();
+                }
+            }
         }
     };
 


More information about the Libreoffice-commits mailing list