nss: upgrade to release 3.73
[LibreOffice.git] / vcl / backendtest / outputdevice / polypolygon.cxx
blob9151bd28ff3f59baa6045a972ff1b8fced6e838a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #include <test/outputdevice.hxx>
13 namespace vcl::test
15 namespace
17 tools::Polygon createPolygonOffset(tools::Rectangle const& rRect, int nOffset, int nFix = 0)
19 // Note: According to https://lists.freedesktop.org/archives/libreoffice/2019-November/083709.html
20 // filling polygons always skips the right-most and bottom-most pixels, in order to avoid
21 // overlaps when drawing adjacent polygons. Specifying nFix = 1 allows to visually compensate
22 // for this by making the polygon explicitly larger.
23 tools::Polygon aPolygon(4);
24 aPolygon.SetPoint(Point(rRect.Left() + nOffset, rRect.Top() + nOffset), 0);
25 aPolygon.SetPoint(Point(rRect.Right() - nOffset + nFix, rRect.Top() + nOffset), 1);
26 aPolygon.SetPoint(Point(rRect.Right() - nOffset + nFix, rRect.Bottom() - nOffset + nFix), 2);
27 aPolygon.SetPoint(Point(rRect.Left() + nOffset, rRect.Bottom() - nOffset + nFix), 3);
28 aPolygon.Optimize(PolyOptimizeFlags::CLOSE);
29 return aPolygon;
32 } // end anonymous namespace
34 Bitmap OutputDeviceTestPolyPolygon::setupRectangle(bool bEnableAA)
36 initialSetup(13, 13, constBackgroundColor, bEnableAA);
38 mpVirtualDevice->SetLineColor(constLineColor);
39 mpVirtualDevice->SetFillColor();
41 tools::PolyPolygon aPolyPolygon(2);
42 aPolyPolygon.Insert(createPolygonOffset(maVDRectangle, 2));
43 aPolyPolygon.Insert(createPolygonOffset(maVDRectangle, 5));
45 mpVirtualDevice->DrawPolyPolygon(aPolyPolygon);
47 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
50 Bitmap OutputDeviceTestPolyPolygon::setupFilledRectangle(bool useLineColor)
52 initialSetup(13, 13, constBackgroundColor);
54 if (useLineColor)
55 mpVirtualDevice->SetLineColor(constLineColor);
56 else
57 mpVirtualDevice->SetLineColor();
58 mpVirtualDevice->SetFillColor(constFillColor);
60 tools::PolyPolygon aPolyPolygon(1);
61 aPolyPolygon.Insert(createPolygonOffset(maVDRectangle, 2, useLineColor ? 0 : 1));
63 mpVirtualDevice->DrawPolyPolygon(aPolyPolygon);
65 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
68 } // end namespace vcl::test
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */