diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2016-01-02 12:51:02 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2016-01-02 17:22:17 +0000 |
commit | 45c8bbe9303094b50035967846196cf3b7c72ea6 (patch) | |
tree | 17a9442b914cbcee0b6b3716a5b26338685c784d /vcl/workben | |
parent | c798c1baf176f62964e1accc5edfddf48e1102be (diff) |
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@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'vcl/workben')
-rw-r--r-- | vcl/workben/vcldemo.cxx | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 9f24deb249c2..19e4fe8f7893 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(); + } + } } }; |