bump product version to 7.6.3.2-android
[LibreOffice.git] / vcl / backendtest / outputdevice / polyline.cxx
blobd187d4addd3b7aeab64e54c26cfba9d545659a6c
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 #include <cmath>
14 #include <vector>
16 namespace vcl::test {
18 namespace
21 void drawPolyLineOffset(OutputDevice& rDevice, tools::Rectangle const & rRect, int nOffset)
23 tools::Polygon aPolygon(4);
24 int nMidOffset = rRect.GetWidth() / 2;
25 aPolygon.SetPoint(Point(rRect.Left() + nOffset - (nOffset+1)/2, rRect.Top() + nOffset - 1), 0);
26 aPolygon.SetPoint(Point(rRect.Right() - nMidOffset - nOffset/3, rRect.Top() + nOffset - 1), 1);
27 aPolygon.SetPoint(Point(rRect.Right() - nMidOffset - nOffset/3, rRect.Bottom() - nOffset + 1), 2);
28 aPolygon.SetPoint(Point(rRect.Left() + nOffset - (nOffset+1)/2, rRect.Bottom() - nOffset + 1), 3);
29 aPolygon.Optimize(PolyOptimizeFlags::CLOSE);
31 rDevice.DrawPolygon(aPolygon);
34 } // end anonymous namespace
36 Bitmap OutputDeviceTestPolyLine::setupRectangle(bool bEnableAA)
38 initialSetup(13, 13, constBackgroundColor, bEnableAA);
40 mpVirtualDevice->SetLineColor(constLineColor);
41 mpVirtualDevice->SetFillColor();
43 drawPolyLineOffset(*mpVirtualDevice, maVDRectangle, 2);
44 drawPolyLineOffset(*mpVirtualDevice, maVDRectangle, 5);
46 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
49 Bitmap OutputDeviceTestPolyLine::setupDiamond()
51 initialSetup(11, 11, constBackgroundColor);
53 mpVirtualDevice->SetLineColor(constLineColor);
54 mpVirtualDevice->SetFillColor();
56 Point aPoint1, aPoint2, aPoint3, aPoint4;
57 OutputDeviceTestCommon::createDiamondPoints(maVDRectangle, 4, aPoint1, aPoint2, aPoint3, aPoint4);
59 tools::Polygon aPolygon(4);
61 aPolygon.SetPoint(aPoint1, 0);
62 aPolygon.SetPoint(aPoint2, 1);
63 aPolygon.SetPoint(aPoint3, 2);
64 aPolygon.SetPoint(aPoint4, 3);
65 aPolygon.Optimize(PolyOptimizeFlags::CLOSE);
67 mpVirtualDevice->DrawPolyLine(aPolygon);
69 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
72 Bitmap OutputDeviceTestPolyLine::setupLines()
74 initialSetup(13, 13, constBackgroundColor);
76 mpVirtualDevice->SetLineColor(constLineColor);
77 mpVirtualDevice->SetFillColor();
79 Point aHorizontalLinePoint1, aHorizontalLinePoint2;
80 Point aVerticalLinePoint1, aVerticalLinePoint2;
81 Point aDiagonalLinePoint1, aDiagonalLinePoint2;
83 OutputDeviceTestCommon::createHorizontalVerticalDiagonalLinePoints(
84 maVDRectangle, aHorizontalLinePoint1, aHorizontalLinePoint2,
85 aVerticalLinePoint1, aVerticalLinePoint2,
86 aDiagonalLinePoint1, aDiagonalLinePoint2);
88 tools::Polygon aHorizontalPolygon(2);
89 aHorizontalPolygon.SetPoint(aHorizontalLinePoint1, 0);
90 aHorizontalPolygon.SetPoint(aHorizontalLinePoint2, 1);
91 mpVirtualDevice->DrawPolyLine(aHorizontalPolygon);
93 tools::Polygon aVerticalPolygon(2);
94 aVerticalPolygon.SetPoint(aVerticalLinePoint1, 0);
95 aVerticalPolygon.SetPoint(aVerticalLinePoint2, 1);
96 mpVirtualDevice->DrawPolyLine(aVerticalPolygon);
98 tools::Polygon aDiagonalPolygon(2);
99 aDiagonalPolygon.SetPoint(aDiagonalLinePoint1, 0);
100 aDiagonalPolygon.SetPoint(aDiagonalLinePoint2, 1);
101 mpVirtualDevice->DrawPolyLine(aDiagonalPolygon);
103 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
106 Bitmap OutputDeviceTestPolyLine::setupAALines()
108 initialSetup(13, 13, constBackgroundColor);
110 mpVirtualDevice->SetAntialiasing(AntialiasingFlags::Enable);
111 mpVirtualDevice->SetLineColor(constLineColor);
112 mpVirtualDevice->SetFillColor();
114 Point aHorizontalLinePoint1, aHorizontalLinePoint2;
115 Point aVerticalLinePoint1, aVerticalLinePoint2;
116 Point aDiagonalLinePoint1, aDiagonalLinePoint2;
118 OutputDeviceTestCommon::createHorizontalVerticalDiagonalLinePoints(
119 maVDRectangle, aHorizontalLinePoint1, aHorizontalLinePoint2,
120 aVerticalLinePoint1, aVerticalLinePoint2,
121 aDiagonalLinePoint1, aDiagonalLinePoint2);
123 tools::Polygon aHorizontalPolygon(2);
124 aHorizontalPolygon.SetPoint(aHorizontalLinePoint1, 0);
125 aHorizontalPolygon.SetPoint(aHorizontalLinePoint2, 1);
126 mpVirtualDevice->DrawPolyLine(aHorizontalPolygon);
128 tools::Polygon aVerticalPolygon(2);
129 aVerticalPolygon.SetPoint(aVerticalLinePoint1, 0);
130 aVerticalPolygon.SetPoint(aVerticalLinePoint2, 1);
131 mpVirtualDevice->DrawPolyLine(aVerticalPolygon);
133 tools::Polygon aDiagonalPolygon(2);
134 aDiagonalPolygon.SetPoint(aDiagonalLinePoint1, 0);
135 aDiagonalPolygon.SetPoint(aDiagonalLinePoint2, 1);
136 mpVirtualDevice->DrawPolyLine(aDiagonalPolygon);
138 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
141 Bitmap OutputDeviceTestPolyLine::setupDropShape()
143 initialSetup(21, 21, constBackgroundColor);
145 mpVirtualDevice->SetLineColor(constLineColor);
146 mpVirtualDevice->SetFillColor();
148 mpVirtualDevice->DrawPolyLine(OutputDeviceTestCommon::createDropShapePolygon());
150 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
153 Bitmap OutputDeviceTestPolyLine::setupAADropShape()
155 initialSetup(21, 21, constBackgroundColor,true);
157 mpVirtualDevice->SetLineColor(constLineColor);
158 mpVirtualDevice->SetFillColor();
160 mpVirtualDevice->DrawPolyLine(OutputDeviceTestCommon::createDropShapePolygon());
162 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
165 Bitmap OutputDeviceTestPolyLine::setupHalfEllipse(bool aEnableAA)
167 initialSetup(19, 21, constBackgroundColor, aEnableAA);
169 mpVirtualDevice->SetLineColor(constLineColor);
170 mpVirtualDevice->SetFillColor();
172 mpVirtualDevice->DrawPolyLine(
173 tools::Polygon(OutputDeviceTestCommon::createHalfEllipsePolygon()));
175 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
178 Bitmap OutputDeviceTestPolyLine::setupClosedBezier()
180 initialSetup(21, 16, constBackgroundColor);
182 mpVirtualDevice->SetLineColor(constLineColor);
183 mpVirtualDevice->SetFillColor();
185 mpVirtualDevice->DrawPolyLine(OutputDeviceTestCommon::createClosedBezierLoop(maVDRectangle));
187 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
190 Bitmap OutputDeviceTestPolyLine::setupRectangleOnSize1028()
192 initialSetup(1028, 1028, constBackgroundColor);
194 mpVirtualDevice->SetLineColor(constLineColor);
195 mpVirtualDevice->SetFillColor();
197 drawPolyLineOffset(*mpVirtualDevice, maVDRectangle, 2);
198 drawPolyLineOffset(*mpVirtualDevice, maVDRectangle, 5);
200 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
203 Bitmap OutputDeviceTestPolyLine::setupRectangleOnSize4096()
205 initialSetup(4096, 4096, constBackgroundColor);
207 mpVirtualDevice->SetLineColor(constLineColor);
208 mpVirtualDevice->SetFillColor();
210 drawPolyLineOffset(*mpVirtualDevice, maVDRectangle, 2);
211 drawPolyLineOffset(*mpVirtualDevice, maVDRectangle, 5);
213 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
216 Bitmap OutputDeviceTestPolyLine::setupOpenPolygon()
218 initialSetup(21, 21, constBackgroundColor);
220 mpVirtualDevice->SetLineColor(constLineColor);
221 mpVirtualDevice->SetFillColor();
223 mpVirtualDevice->DrawPolyLine(
224 tools::Polygon(OutputDeviceTestCommon::createOpenPolygon(maVDRectangle)));
225 mpVirtualDevice->DrawPolyLine(
226 tools::Polygon(OutputDeviceTestCommon::createOpenPolygon(maVDRectangle, 7)));
228 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
231 Bitmap OutputDeviceTestPolyLine::setupOpenBezier()
233 initialSetup(21, 21, constBackgroundColor);
235 mpVirtualDevice->SetLineColor(constLineColor);
236 mpVirtualDevice->SetFillColor();
238 mpVirtualDevice->DrawPolyLine(tools::Polygon(OutputDeviceTestCommon::createOpenBezier()));
240 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
243 } // end namespace vcl::test
245 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */