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>
19 void drawPolygonOffset(OutputDevice
& rDevice
, tools::Rectangle
const & rRect
, int nOffset
)
21 tools::Polygon
aPolygon(4);
22 aPolygon
.SetPoint(Point(rRect
.Left() + nOffset
, rRect
.Top() + nOffset
), 0);
23 aPolygon
.SetPoint(Point(rRect
.Right() - nOffset
, rRect
.Top() + nOffset
), 1);
24 aPolygon
.SetPoint(Point(rRect
.Right() - nOffset
, rRect
.Bottom() - nOffset
), 2);
25 aPolygon
.SetPoint(Point(rRect
.Left() + nOffset
, rRect
.Bottom() - nOffset
), 3);
26 aPolygon
.Optimize(PolyOptimizeFlags::CLOSE
);
28 rDevice
.DrawPolygon(aPolygon
);
31 } // end anonymous namespace
33 Bitmap
OutputDeviceTestPolygon::setupRectangle(bool bEnableAA
)
35 initialSetup(13, 13, constBackgroundColor
, bEnableAA
);
37 mpVirtualDevice
->SetLineColor(constLineColor
);
38 mpVirtualDevice
->SetFillColor();
40 drawPolygonOffset(*mpVirtualDevice
, maVDRectangle
, 2);
41 drawPolygonOffset(*mpVirtualDevice
, maVDRectangle
, 5);
43 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
46 Bitmap
OutputDeviceTestPolygon::setupFilledRectangle()
48 initialSetup(13, 13, constBackgroundColor
);
50 mpVirtualDevice
->SetLineColor();
51 mpVirtualDevice
->SetFillColor(constFillColor
);
52 drawPolygonOffset(*mpVirtualDevice
, maVDRectangle
, 2);
54 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
57 Bitmap
OutputDeviceTestPolygon::setupDiamond()
59 initialSetup(11, 11, constBackgroundColor
);
61 mpVirtualDevice
->SetLineColor(constLineColor
);
62 mpVirtualDevice
->SetFillColor();
64 Point aPoint1
, aPoint2
, aPoint3
, aPoint4
;
65 OutputDeviceTestCommon::createDiamondPoints(maVDRectangle
, 4, aPoint1
, aPoint2
, aPoint3
, aPoint4
);
67 tools::Polygon
aPolygon(4);
69 aPolygon
.SetPoint(aPoint1
, 0);
70 aPolygon
.SetPoint(aPoint2
, 1);
71 aPolygon
.SetPoint(aPoint3
, 2);
72 aPolygon
.SetPoint(aPoint4
, 3);
73 aPolygon
.Optimize(PolyOptimizeFlags::CLOSE
);
75 mpVirtualDevice
->DrawPolygon(aPolygon
);
77 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
80 Bitmap
OutputDeviceTestPolygon::setupLines()
82 initialSetup(13, 13, constBackgroundColor
);
84 mpVirtualDevice
->SetLineColor(constLineColor
);
85 mpVirtualDevice
->SetFillColor();
87 Point aHorizontalLinePoint1
, aHorizontalLinePoint2
;
88 Point aVerticalLinePoint1
, aVerticalLinePoint2
;
89 Point aDiagonalLinePoint1
, aDiagonalLinePoint2
;
91 OutputDeviceTestCommon::createHorizontalVerticalDiagonalLinePoints(
92 maVDRectangle
, aHorizontalLinePoint1
, aHorizontalLinePoint2
,
93 aVerticalLinePoint1
, aVerticalLinePoint2
,
94 aDiagonalLinePoint1
, aDiagonalLinePoint2
);
96 tools::Polygon
aHorizontalPolygon(2);
97 aHorizontalPolygon
.SetPoint(aHorizontalLinePoint1
, 0);
98 aHorizontalPolygon
.SetPoint(aHorizontalLinePoint2
, 1);
99 mpVirtualDevice
->DrawPolygon(aHorizontalPolygon
);
101 tools::Polygon
aVerticalPolygon(2);
102 aVerticalPolygon
.SetPoint(aVerticalLinePoint1
, 0);
103 aVerticalPolygon
.SetPoint(aVerticalLinePoint2
, 1);
104 mpVirtualDevice
->DrawPolygon(aVerticalPolygon
);
106 tools::Polygon
aDiagonalPolygon(2);
107 aDiagonalPolygon
.SetPoint(aDiagonalLinePoint1
, 0);
108 aDiagonalPolygon
.SetPoint(aDiagonalLinePoint2
, 1);
109 mpVirtualDevice
->DrawPolygon(aDiagonalPolygon
);
111 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
114 Bitmap
OutputDeviceTestPolygon::setupAALines()
116 initialSetup(13, 13, constBackgroundColor
);
118 mpVirtualDevice
->SetAntialiasing(AntialiasingFlags::EnableB2dDraw
);
119 mpVirtualDevice
->SetLineColor(constLineColor
);
120 mpVirtualDevice
->SetFillColor();
122 Point aHorizontalLinePoint1
, aHorizontalLinePoint2
;
123 Point aVerticalLinePoint1
, aVerticalLinePoint2
;
124 Point aDiagonalLinePoint1
, aDiagonalLinePoint2
;
126 OutputDeviceTestCommon::createHorizontalVerticalDiagonalLinePoints(
127 maVDRectangle
, aHorizontalLinePoint1
, aHorizontalLinePoint2
,
128 aVerticalLinePoint1
, aVerticalLinePoint2
,
129 aDiagonalLinePoint1
, aDiagonalLinePoint2
);
131 tools::Polygon
aHorizontalPolygon(2);
132 aHorizontalPolygon
.SetPoint(aHorizontalLinePoint1
, 0);
133 aHorizontalPolygon
.SetPoint(aHorizontalLinePoint2
, 1);
134 mpVirtualDevice
->DrawPolygon(aHorizontalPolygon
);
136 tools::Polygon
aVerticalPolygon(2);
137 aVerticalPolygon
.SetPoint(aVerticalLinePoint1
, 0);
138 aVerticalPolygon
.SetPoint(aVerticalLinePoint2
, 1);
139 mpVirtualDevice
->DrawPolygon(aVerticalPolygon
);
141 tools::Polygon
aDiagonalPolygon(2);
142 aDiagonalPolygon
.SetPoint(aDiagonalLinePoint1
, 0);
143 aDiagonalPolygon
.SetPoint(aDiagonalLinePoint2
, 1);
144 mpVirtualDevice
->DrawPolygon(aDiagonalPolygon
);
146 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
149 }} // end namespace vcl::test
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */