LibreOffice Module vcl (master)  1
outputdevice.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  */
10 
11 #ifndef INCLUDED_VCL_OUTDEVTESTS_HXX
12 #define INCLUDED_VCL_OUTDEVTESTS_HXX
13 
14 #include <vcl/virdev.hxx>
15 #include <vcl/test/TestResult.hxx>
16 
17 namespace vcl::test {
18 
22 {
23 protected:
24 
27 
29  static const Color constLineColor;
30  static const Color constFillColor;
31 
32 public:
34 
35  OUString getRenderBackendName() const;
36 
37  void initialSetup(tools::Long nWidth, tools::Long nHeight, Color aColor, bool bEnableAA = false, bool bAlphaVirtualDevice = false);
38 
39  static TestResult checkRectangle(Bitmap& rBitmap);
40  static TestResult checkRectangleAA(Bitmap& rBitmap);
41  static TestResult checkFilledRectangle(Bitmap& rBitmap, bool useLineColor);
42  static TestResult checkLines(Bitmap& rBitmap);
43  static TestResult checkAALines(Bitmap& rBitmap);
44  static TestResult checkDiamond(Bitmap& rBitmap);
45 
46  static TestResult checkInvertRectangle(Bitmap& rBitmap);
47  static TestResult checkInvertN50Rectangle(Bitmap& aBitmap);
48  static TestResult checkInvertTrackFrameRectangle(Bitmap& aBitmap);
49 
50  static TestResult checkRectangles(Bitmap& rBitmap, std::vector<Color>& aExpectedColors);
51  static TestResult checkRectangle(Bitmap& rBitmap, int aLayerNumber, Color aExpectedColor);
52  static TestResult checkRectangles(Bitmap& rBitmap, bool aEnableAA = false);
53 
54  static TestResult checkFilled(Bitmap& rBitmap, tools::Rectangle aRectangle, Color aExpectedColor);
55  static TestResult checkChecker(Bitmap& rBitmap, sal_Int32 nStartX, sal_Int32 nEndX,
56  sal_Int32 nStartY, sal_Int32 nEndY, std::vector<Color> const & rExpected);
57 
58  static TestResult checkLinearGradient(Bitmap& bitmap);
59  static TestResult checkLinearGradientAngled(Bitmap& bitmap);
60  static TestResult checkLinearGradientBorder(Bitmap& bitmap);
61  static TestResult checkLinearGradientIntensity(Bitmap& bitmap);
62  static TestResult checkLinearGradientSteps(Bitmap& bitmap);
63  static TestResult checkAxialGradient(Bitmap& bitmap);
64  static TestResult checkRadialGradient(Bitmap& bitmap);
65  static TestResult checkRadialGradientOfs(Bitmap& bitmap);
66 
67  static void createDiamondPoints(tools::Rectangle rRect, int nOffset,
68  Point& rPoint1, Point& rPoint2,
69  Point& rPoint3, Point& rPoint4);
70 
71  static tools::Polygon createDropShapePolygon();
72  static basegfx::B2DPolygon createHalfEllipsePolygon();
73  static tools::Polygon createClosedBezierLoop(const tools::Rectangle& rRect);
74  static basegfx::B2DPolygon createOpenPolygon(const tools::Rectangle& rRect, int nOffset = 4);
75  static basegfx::B2DPolygon createOpenBezier();
76 
77  static void createHorizontalVerticalDiagonalLinePoints(tools::Rectangle rRect,
78  Point& rHorizontalLinePoint1, Point& rHorizontalLinePoint2,
79  Point& rVerticalLinePoint1, Point& rVerticalLinePoint2,
80  Point& rDiagonalLinePoint1, Point& rDiagonalLinePoint2);
81  // tools
82  static tools::Rectangle alignToCenter(tools::Rectangle aRect1, tools::Rectangle aRect2);
83 
84  static TestResult checkBezier(Bitmap& rBitmap);
85 
86  static TestResult checkLineCapRound(Bitmap& rBitmap) { return checkLineCap(rBitmap, css::drawing::LineCap_ROUND); }
87  static TestResult checkLineCapSquare(Bitmap& rBitmap) { return checkLineCap(rBitmap, css::drawing::LineCap_SQUARE); }
88  static TestResult checkLineCapButt(Bitmap& rBitmap) { return checkLineCap(rBitmap, css::drawing::LineCap_BUTT); }
89 
90  static TestResult checkLineJoinBevel(Bitmap& rBitmap) { return checkLineJoin(rBitmap, basegfx::B2DLineJoin::Bevel); }
91  static TestResult checkLineJoinRound(Bitmap& rBitmap) { return checkLineJoin(rBitmap, basegfx::B2DLineJoin::Round); }
92  static TestResult checkLineJoinMiter(Bitmap& rBitmap) { return checkLineJoin(rBitmap, basegfx::B2DLineJoin::Miter); }
93  static TestResult checkLineJoinNone(Bitmap& rBitmap) { return checkLineJoin(rBitmap, basegfx::B2DLineJoin::NONE); }
94  static TestResult checkDropShape(Bitmap& rBitmap, bool aEnableAA = false);
95  static TestResult checkHalfEllipse(Bitmap& rBitmap, bool aEnableAA = false);
96  static TestResult checkClosedBezier(Bitmap& rBitmap);
97  static TestResult checkFilledAsymmetricalDropShape(Bitmap& rBitmap);
98  static TestResult checkTextLocation(Bitmap& rBitmap);
99  static TestResult checkEvenOddRuleInIntersectingRecs(Bitmap &rBitmap);
100  static TestResult checkIntersectingRecs(Bitmap& rBitmap,int aLayerNumber, Color aExpectedColor);
101  static TestResult checkOpenPolygon(Bitmap& rBitmap, bool aEnableAA = false);
102  static TestResult checkOpenBezier(Bitmap& rBitmap);
103 private:
104  static TestResult checkLineCap(Bitmap& rBitmap, css::drawing::LineCap lineCap);
105  static TestResult checkLineJoin(Bitmap& rBitmap, basegfx::B2DLineJoin lineJoin);
106 };
107 
109 {
110 public:
111  OutputDeviceTestBitmap() = default;
112 
113  Bitmap setupDrawTransformedBitmap(vcl::PixelFormat aBitmapFormat,
114  bool isBitmapGreyScale = false);
115  Bitmap setupComplexDrawTransformedBitmap(vcl::PixelFormat aBitmapFormat,
116  bool isBitmapGreyScale = false);
117  Bitmap setupDrawBitmap(vcl::PixelFormat aBitmapFormat, bool isBitmapGreyScale = false);
118  Bitmap setupDrawBitmapExWithAlpha(vcl::PixelFormat aBitmapFormat);
119  Bitmap setupDrawMask(vcl::PixelFormat aBitmapFormat);
120  BitmapEx setupDrawBlend(vcl::PixelFormat aBitmapFormat);
121 
122  static TestResult checkTransformedBitmap(Bitmap& rBitmap);
123  static TestResult checkComplexTransformedBitmap(Bitmap& rBitmap);
124  static TestResult checkBitmapExWithAlpha(Bitmap& rBitmap);
125  static TestResult checkMask(Bitmap& rBitmap);
126  static TestResult checkBlend(const BitmapEx& rBitmap);
127 
128  static TestResult checkTransformedBitmap8bppGreyScale(Bitmap& rBitmap);
129 };
130 
132 {
133 public:
134  OutputDeviceTestAnotherOutDev() = default;
135 
136  Bitmap setupDrawOutDev();
137  Bitmap setupDrawOutDevScaledClipped();
138  Bitmap setupDrawOutDevSelf();
139  Bitmap setupXOR();
140 
141  static TestResult checkDrawOutDev(Bitmap& rBitmap);
142  static TestResult checkDrawOutDevScaledClipped(Bitmap& rBitmap);
143  static TestResult checkDrawOutDevSelf(Bitmap& rBitmap);
144  static TestResult checkXOR(Bitmap& rBitmap);
145 };
146 
148 {
149 public:
150  OutputDeviceTestPixel() = default;
151 
152  Bitmap setupRectangle(bool bEnableAA);
153  Bitmap setupRectangleOnSize1028();
154  Bitmap setupRectangleOnSize4096();
155 };
156 
158 {
159 public:
160  OutputDeviceTestLine() = default;
161 
162  Bitmap setupRectangle(bool bEnableAA);
163  Bitmap setupRectangleOnSize1028();
164  Bitmap setupRectangleOnSize4096();
165  Bitmap setupDiamond();
166  Bitmap setupLines();
167  Bitmap setupAALines();
168 
169  Bitmap setupDashedLine();
170  static TestResult checkDashedLine(Bitmap& rBitmap);
171 
172  Bitmap setupLineCapRound() { return setupLineCap(css::drawing::LineCap_ROUND); }
173  Bitmap setupLineCapSquare() { return setupLineCap(css::drawing::LineCap_SQUARE); }
174  Bitmap setupLineCapButt() { return setupLineCap(css::drawing::LineCap_BUTT); }
175 
180 private:
181  Bitmap setupLineCap( css::drawing::LineCap lineCap );
182  Bitmap setupLineJoin( basegfx::B2DLineJoin lineJoin );
183 };
184 
186 {
187 public:
188  OutputDeviceTestPolyLine() = default;
189 
190  Bitmap setupRectangle(bool bEnableAA);
191  Bitmap setupDiamond();
192  Bitmap setupLines();
193  Bitmap setupAALines();
194  Bitmap setupDropShape();
195  Bitmap setupAADropShape();
196  Bitmap setupHalfEllipse(bool aEnableAA = false);
197  Bitmap setupClosedBezier();
198  Bitmap setupRectangleOnSize1028();
199  Bitmap setupRectangleOnSize4096();
200  Bitmap setupOpenPolygon();
201  Bitmap setupOpenBezier();
202 };
203 
205 {
206 public:
207  OutputDeviceTestPolyLineB2D() = default;
208 
209  Bitmap setupRectangle(bool bEnableAA);
210  Bitmap setupDiamond();
211  Bitmap setupBezier();
212  Bitmap setupAABezier();
213  Bitmap setupHalfEllipse(bool aEnableAA = false);
214  Bitmap setupRectangleOnSize1028();
215  Bitmap setupRectangleOnSize4096();
216  Bitmap setupOpenPolygon();
217  Bitmap setupOpenBezier();
218 };
219 
221 {
222 public:
223  OutputDeviceTestRect() = default;
224 
225  Bitmap setupRectangle(bool bEnableAA);
226  Bitmap setupFilledRectangle(bool useLineColor);
227  Bitmap setupRectangleOnSize1028();
228  Bitmap setupRectangleOnSize4096();
229  Bitmap setupInvert_NONE();
230  Bitmap setupInvert_N50();
231  Bitmap setupInvert_TrackFrame();
232 };
233 
235 {
236 public:
237  OutputDeviceTestPolygon() = default;
238 
239  Bitmap setupRectangle(bool bEnableAA);
240  Bitmap setupFilledRectangle(bool useLineColor);
241  Bitmap setupDiamond();
242  Bitmap setupLines();
243  Bitmap setupAALines();
244  Bitmap setupDropShape();
245  Bitmap setupAADropShape();
246  Bitmap setupHalfEllipse(bool aEnableAA = false);
247  Bitmap setupClosedBezier();
248  Bitmap setupFilledAsymmetricalDropShape();
249  Bitmap setupRectangleOnSize1028();
250  Bitmap setupRectangleOnSize4096();
251  Bitmap setupOpenPolygon();
252 };
253 
255 {
256 public:
257  OutputDeviceTestPolyPolygon() = default;
258 
259  Bitmap setupRectangle(bool bEnableAA);
260  Bitmap setupFilledRectangle(bool useLineColor);
261  Bitmap setupIntersectingRectangles();
262  Bitmap setupRectangleOnSize1028();
263  Bitmap setupRectangleOnSize4096();
264  Bitmap setupOpenPolygon();
265 };
266 
268 {
269 public:
270  OutputDeviceTestPolyPolygonB2D() = default;
271 
272  Bitmap setupRectangle(bool bEnableAA);
273  Bitmap setupFilledRectangle(bool useLineColor);
274  Bitmap setupIntersectingRectangles();
275  Bitmap setupRectangleOnSize1028();
276  Bitmap setupRectangleOnSize4096();
277  Bitmap setupOpenPolygon();
278 };
279 
281 {
282 public:
283  OutputDeviceTestGradient() = default;
284 
285  Bitmap setupLinearGradient();
286  Bitmap setupLinearGradientAngled();
287  Bitmap setupLinearGradientBorder();
288  Bitmap setupLinearGradientIntensity();
289  Bitmap setupLinearGradientSteps();
290  Bitmap setupAxialGradient();
291  Bitmap setupRadialGradient();
292  Bitmap setupRadialGradientOfs();
293 };
294 
296 {
297 public:
298  Bitmap setupClipRectangle();
299  Bitmap setupClipPolygon();
300  Bitmap setupClipPolyPolygon();
301  Bitmap setupClipB2DPolyPolygon();
302 
303  static TestResult checkClip(Bitmap& rBitmap);
304 };
305 
307 {
308 public:
309  Bitmap setupTextBitmap();
310 };
311 
312 } // end namespace vcl::test
313 
314 #endif
315 
316 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PixelFormat
Pixel format of the bitmap in bits per pixel.
Definition: BitmapTypes.hxx:19
Rendering test result.
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
static TestResult checkLineJoinNone(Bitmap &rBitmap)
long Long
static const Color constBackgroundColor
static TestResult checkLineJoinBevel(Bitmap &rBitmap)
static TestResult checkLineCapSquare(Bitmap &rBitmap)
ScopedVclPtr< VirtualDevice > mpVirtualDevice
Common subclass for output device rendering tests.
static TestResult checkLineJoinRound(Bitmap &rBitmap)
static TestResult checkLineCapRound(Bitmap &rBitmap)
static TestResult checkLineJoinMiter(Bitmap &rBitmap)
static TestResult checkLineCapButt(Bitmap &rBitmap)