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 #ifndef INCLUDED_VCL_OUTDEVTESTS_HXX
12 #define INCLUDED_VCL_OUTDEVTESTS_HXX
14 #include <vcl/virdev.hxx>
18 /** Rendering test result.
20 * Test either "Passed", "Failed" or "PassedWithQuirks" which means
21 * the test passed but at least one rendering quirk was detected.
30 /** Common subclass for output device rendering tests.
32 class VCL_DLLPUBLIC OutputDeviceTestCommon
36 ScopedVclPtr
<VirtualDevice
> mpVirtualDevice
;
37 tools::Rectangle maVDRectangle
;
39 static const Color constBackgroundColor
;
40 static const Color constLineColor
;
41 static const Color constFillColor
;
44 OutputDeviceTestCommon();
46 OUString
getRenderBackendName() const;
48 void initialSetup(tools::Long nWidth
, tools::Long nHeight
, Color aColor
, bool bEnableAA
= false, bool bAlphaVirtualDevice
= false);
50 static TestResult
checkRectangle(Bitmap
& rBitmap
);
51 static TestResult
checkRectangleAA(Bitmap
& rBitmap
);
52 static TestResult
checkFilledRectangle(Bitmap
& rBitmap
, bool useLineColor
);
53 static TestResult
checkLines(Bitmap
& rBitmap
);
54 static TestResult
checkAALines(Bitmap
& rBitmap
);
55 static TestResult
checkDiamond(Bitmap
& rBitmap
);
57 static TestResult
checkInvertRectangle(Bitmap
& rBitmap
);
58 static TestResult
checkInvertN50Rectangle(Bitmap
& aBitmap
);
59 static TestResult
checkInvertTrackFrameRectangle(Bitmap
& aBitmap
);
61 static TestResult
checkRectangles(Bitmap
& rBitmap
, std::vector
<Color
>& aExpectedColors
);
62 static TestResult
checkRectangle(Bitmap
& rBitmap
, int aLayerNumber
, Color aExpectedColor
);
64 static TestResult
checkFilled(Bitmap
& rBitmap
, tools::Rectangle aRectangle
, Color aExpectedColor
);
65 static TestResult
checkChecker(Bitmap
& rBitmap
, sal_Int32 nStartX
, sal_Int32 nEndX
,
66 sal_Int32 nStartY
, sal_Int32 nEndY
, std::vector
<Color
> const & rExpected
);
68 static TestResult
checkLinearGradient(Bitmap
& bitmap
);
69 static TestResult
checkLinearGradientAngled(Bitmap
& bitmap
);
70 static TestResult
checkLinearGradientBorder(Bitmap
& bitmap
);
71 static TestResult
checkLinearGradientIntensity(Bitmap
& bitmap
);
72 static TestResult
checkLinearGradientSteps(Bitmap
& bitmap
);
73 static TestResult
checkAxialGradient(Bitmap
& bitmap
);
74 static TestResult
checkRadialGradient(Bitmap
& bitmap
);
75 static TestResult
checkRadialGradientOfs(Bitmap
& bitmap
);
77 static void createDiamondPoints(tools::Rectangle rRect
, int nOffset
,
78 Point
& rPoint1
, Point
& rPoint2
,
79 Point
& rPoint3
, Point
& rPoint4
);
81 static void createHorizontalVerticalDiagonalLinePoints(tools::Rectangle rRect
,
82 Point
& rHorizontalLinePoint1
, Point
& rHorizontalLinePoint2
,
83 Point
& rVerticalLinePoint1
, Point
& rVerticalLinePoint2
,
84 Point
& rDiagonalLinePoint1
, Point
& rDiagonalLinePoint2
);
86 static tools::Rectangle
alignToCenter(tools::Rectangle aRect1
, tools::Rectangle aRect2
);
88 static TestResult
checkBezier(Bitmap
& rBitmap
);
90 static TestResult
checkLineCapRound(Bitmap
& rBitmap
) { return checkLineCap(rBitmap
, css::drawing::LineCap_ROUND
); }
91 static TestResult
checkLineCapSquare(Bitmap
& rBitmap
) { return checkLineCap(rBitmap
, css::drawing::LineCap_SQUARE
); }
92 static TestResult
checkLineCapButt(Bitmap
& rBitmap
) { return checkLineCap(rBitmap
, css::drawing::LineCap_BUTT
); }
94 static TestResult
checkLineJoinBevel(Bitmap
& rBitmap
) { return checkLineJoin(rBitmap
, basegfx::B2DLineJoin::Bevel
); }
95 static TestResult
checkLineJoinRound(Bitmap
& rBitmap
) { return checkLineJoin(rBitmap
, basegfx::B2DLineJoin::Round
); }
96 static TestResult
checkLineJoinMiter(Bitmap
& rBitmap
) { return checkLineJoin(rBitmap
, basegfx::B2DLineJoin::Miter
); }
97 static TestResult
checkLineJoinNone(Bitmap
& rBitmap
) { return checkLineJoin(rBitmap
, basegfx::B2DLineJoin::NONE
); }
99 static TestResult
checkLineCap(Bitmap
& rBitmap
, css::drawing::LineCap lineCap
);
100 static TestResult
checkLineJoin(Bitmap
& rBitmap
, basegfx::B2DLineJoin lineJoin
);
103 class VCL_DLLPUBLIC OutputDeviceTestBitmap
: public OutputDeviceTestCommon
106 OutputDeviceTestBitmap() = default;
108 Bitmap
setupDrawTransformedBitmap();
109 Bitmap
setupDrawBitmap();
110 Bitmap
setupDrawBitmapExWithAlpha();
111 Bitmap
setupDrawMask();
112 BitmapEx
setupDrawBlend();
114 static TestResult
checkTransformedBitmap(Bitmap
& rBitmap
);
115 static TestResult
checkBitmapExWithAlpha(Bitmap
& rBitmap
);
116 static TestResult
checkMask(Bitmap
& rBitmap
);
117 static TestResult
checkBlend(const BitmapEx
& rBitmap
);
120 class VCL_DLLPUBLIC OutputDeviceTestAnotherOutDev
: public OutputDeviceTestCommon
123 OutputDeviceTestAnotherOutDev() = default;
125 Bitmap
setupDrawOutDev();
128 static TestResult
checkDrawOutDev(Bitmap
& rBitmap
);
129 static TestResult
checkXOR(Bitmap
& rBitmap
);
132 class VCL_DLLPUBLIC OutputDeviceTestPixel
: public OutputDeviceTestCommon
135 OutputDeviceTestPixel() = default;
137 Bitmap
setupRectangle(bool bEnableAA
);
140 class VCL_DLLPUBLIC OutputDeviceTestLine
: public OutputDeviceTestCommon
143 OutputDeviceTestLine() = default;
145 Bitmap
setupRectangle(bool bEnableAA
);
146 Bitmap
setupDiamond();
148 Bitmap
setupAALines();
150 Bitmap
setupDashedLine();
151 static TestResult
checkDashedLine(Bitmap
& rBitmap
);
153 Bitmap
setupLineCapRound() { return setupLineCap(css::drawing::LineCap_ROUND
); }
154 Bitmap
setupLineCapSquare() { return setupLineCap(css::drawing::LineCap_SQUARE
); }
155 Bitmap
setupLineCapButt() { return setupLineCap(css::drawing::LineCap_BUTT
); }
157 Bitmap
setupLineJoinBevel() { return setupLineJoin(basegfx::B2DLineJoin::Bevel
); }
158 Bitmap
setupLineJoinRound() { return setupLineJoin(basegfx::B2DLineJoin::Round
); }
159 Bitmap
setupLineJoinMiter() { return setupLineJoin(basegfx::B2DLineJoin::Miter
); }
160 Bitmap
setupLineJoinNone() { return setupLineJoin(basegfx::B2DLineJoin::NONE
); }
162 Bitmap
setupLineCap( css::drawing::LineCap lineCap
);
163 Bitmap
setupLineJoin( basegfx::B2DLineJoin lineJoin
);
166 class VCL_DLLPUBLIC OutputDeviceTestPolyLine
: public OutputDeviceTestCommon
169 OutputDeviceTestPolyLine() = default;
171 Bitmap
setupRectangle(bool bEnableAA
);
172 Bitmap
setupDiamond();
174 Bitmap
setupAALines();
177 class VCL_DLLPUBLIC OutputDeviceTestPolyLineB2D
: public OutputDeviceTestCommon
180 OutputDeviceTestPolyLineB2D() = default;
182 Bitmap
setupRectangle(bool bEnableAA
);
183 Bitmap
setupDiamond();
184 Bitmap
setupBezier();
185 Bitmap
setupAABezier();
188 class VCL_DLLPUBLIC OutputDeviceTestRect
: public OutputDeviceTestCommon
191 OutputDeviceTestRect() = default;
193 Bitmap
setupRectangle(bool bEnableAA
);
194 Bitmap
setupFilledRectangle(bool useLineColor
);
195 Bitmap
setupInvert_NONE();
196 Bitmap
setupInvert_N50();
197 Bitmap
setupInvert_TrackFrame();
200 class VCL_DLLPUBLIC OutputDeviceTestPolygon
: public OutputDeviceTestCommon
203 OutputDeviceTestPolygon() = default;
205 Bitmap
setupRectangle(bool bEnableAA
);
206 Bitmap
setupFilledRectangle(bool useLineColor
);
207 Bitmap
setupDiamond();
209 Bitmap
setupAALines();
212 class VCL_DLLPUBLIC OutputDeviceTestPolyPolygon
: public OutputDeviceTestCommon
215 OutputDeviceTestPolyPolygon() = default;
217 Bitmap
setupRectangle(bool bEnableAA
);
218 Bitmap
setupFilledRectangle(bool useLineColor
);
221 class VCL_DLLPUBLIC OutputDeviceTestPolyPolygonB2D
: public OutputDeviceTestCommon
224 OutputDeviceTestPolyPolygonB2D() = default;
226 Bitmap
setupRectangle(bool bEnableAA
);
227 Bitmap
setupFilledRectangle(bool useLineColor
);
230 class VCL_DLLPUBLIC OutputDeviceTestGradient
: public OutputDeviceTestCommon
233 OutputDeviceTestGradient() = default;
235 Bitmap
setupLinearGradient();
236 Bitmap
setupLinearGradientAngled();
237 Bitmap
setupLinearGradientBorder();
238 Bitmap
setupLinearGradientIntensity();
239 Bitmap
setupLinearGradientSteps();
240 Bitmap
setupAxialGradient();
241 Bitmap
setupRadialGradient();
242 Bitmap
setupRadialGradientOfs();
245 class VCL_DLLPUBLIC OutputDeviceTestClip
: public OutputDeviceTestCommon
248 Bitmap
setupClipRectangle();
249 Bitmap
setupClipPolygon();
250 Bitmap
setupClipPolyPolygon();
251 Bitmap
setupClipB2DPolyPolygon();
253 static TestResult
checkClip(Bitmap
& rBitmap
);
257 } // end namespace vcl::test
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */