1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
11 #include <test/outputdevice.hxx>
17 basegfx::B2DPolygon
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 basegfx::B2DPolygon aPolygon
{
24 basegfx::B2DPoint(rRect
.Left() + nOffset
, rRect
.Top() + nOffset
),
25 basegfx::B2DPoint(rRect
.Right() - nOffset
+ nFix
, rRect
.Top() + nOffset
),
26 basegfx::B2DPoint(rRect
.Right() - nOffset
+ nFix
, rRect
.Bottom() - nOffset
+ nFix
),
27 basegfx::B2DPoint(rRect
.Left() + nOffset
, rRect
.Bottom() - nOffset
+ nFix
),
29 aPolygon
.setClosed(true);
33 } // end anonymous namespace
35 Bitmap
OutputDeviceTestPolyPolygonB2D::setupRectangle(bool bEnableAA
)
37 initialSetup(13, 13, constBackgroundColor
, bEnableAA
);
39 mpVirtualDevice
->SetLineColor(constLineColor
);
40 mpVirtualDevice
->SetFillColor();
42 basegfx::B2DPolyPolygon aPolyPolygon
;
43 aPolyPolygon
.append(createPolygonOffset(maVDRectangle
, 2));
44 aPolyPolygon
.append(createPolygonOffset(maVDRectangle
, 5));
46 mpVirtualDevice
->DrawPolyPolygon(aPolyPolygon
);
48 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
51 Bitmap
OutputDeviceTestPolyPolygonB2D::setupFilledRectangle(bool useLineColor
)
53 initialSetup(13, 13, constBackgroundColor
);
56 mpVirtualDevice
->SetLineColor(constLineColor
);
58 mpVirtualDevice
->SetLineColor();
59 mpVirtualDevice
->SetFillColor(constFillColor
);
61 basegfx::B2DPolyPolygon
aPolyPolygon(
62 createPolygonOffset(maVDRectangle
, 2, useLineColor
? 0 : 1));
64 mpVirtualDevice
->DrawPolyPolygon(aPolyPolygon
);
66 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
68 } // end namespace vcl::test
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */