summaryrefslogtreecommitdiffstats
path: root/vcl/inc/test/outputdevice.hxx
blob: 8412dbaf8a7b19b3a97295bb93dbf3b9b454ac8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 */

#ifndef INCLUDED_VCL_OUTDEVTESTS_HXX
#define INCLUDED_VCL_OUTDEVTESTS_HXX

#include <vcl/virdev.hxx>
#include <vcl/test/TestResult.hxx>

namespace vcl::test {

/** Common subclass for output device rendering tests.
 */
class VCL_DLLPUBLIC OutputDeviceTestCommon
{
protected:

    ScopedVclPtr<VirtualDevice> mpVirtualDevice;
    tools::Rectangle maVDRectangle;

    static const Color constBackgroundColor;
    static const Color constLineColor;
    static const Color constFillColor;

public:
    OutputDeviceTestCommon();

    OUString getRenderBackendName() const;

    void initialSetup(tools::Long nWidth, tools::Long nHeight, Color aColor, bool bEnableAA = false, bool bAlphaVirtualDevice = false);

    static TestResult checkRectangle(Bitmap& rBitmap);
    static TestResult checkRectangleAA(Bitmap& rBitmap);
    static TestResult checkFilledRectangle(Bitmap& rBitmap, bool useLineColor);
    static TestResult checkLines(Bitmap& rBitmap);
    static TestResult checkAALines(Bitmap& rBitmap);
    static TestResult checkDiamond(Bitmap& rBitmap);

    static TestResult checkInvertRectangle(Bitmap& rBitmap);
    static TestResult checkInvertN50Rectangle(Bitmap& aBitmap);
    static TestResult checkInvertTrackFrameRectangle(Bitmap& aBitmap);

    static TestResult checkRectangles(Bitmap& rBitmap, std::vector<Color>& aExpectedColors);
    static TestResult checkRectangle(Bitmap& rBitmap, int aLayerNumber, Color aExpectedColor);
    static TestResult checkRectangles(Bitmap& rBitmap, bool aEnableAA = false);

    static TestResult checkFilled(Bitmap& rBitmap, tools::Rectangle aRectangle, Color aExpectedColor);
    static TestResult checkChecker(Bitmap& rBitmap, sal_Int32 nStartX, sal_Int32 nEndX,
                                   sal_Int32 nStartY, sal_Int32 nEndY, std::vector<Color> const & rExpected);

    static TestResult checkLinearGradient(Bitmap& bitmap);
    static TestResult checkLinearGradientAngled(Bitmap& bitmap);
    static TestResult checkLinearGradientBorder(Bitmap& bitmap);
    static TestResult checkLinearGradientIntensity(Bitmap& bitmap);
    static TestResult checkLinearGradientSteps(Bitmap& bitmap);
    static TestResult checkAxialGradient(Bitmap& bitmap);
    static TestResult checkRadialGradient(Bitmap& bitmap);
    static TestResult checkRadialGradientOfs(Bitmap& bitmap);

    static void createDiamondPoints(tools::Rectangle rRect, int nOffset,
                                    Point& rPoint1, Point& rPoint2,
                                    Point& rPoint3, Point& rPoint4);

    static tools::Polygon createDropShapePolygon();
    static basegfx::B2DPolygon createHalfEllipsePolygon();
    static tools::Polygon createClosedBezierLoop(const tools::Rectangle& rRect);
    static basegfx::B2DPolygon createOpenPolygon(const tools::Rectangle& rRect, int nOffset = 4);
    static basegfx::B2DPolygon createOpenBezier();

    static void createHorizontalVerticalDiagonalLinePoints(tools::Rectangle rRect,
                                Point& rHorizontalLinePoint1, Point& rHorizontalLinePoint2,
                                Point& rVerticalLinePoint1, Point& rVerticalLinePoint2,
                                Point& rDiagonalLinePoint1, Point& rDiagonalLinePoint2);
    // tools
    static tools::Rectangle alignToCenter(tools::Rectangle aRect1, tools::Rectangle aRect2);

    static TestResult checkBezier(Bitmap& rBitmap);

    static TestResult checkLineCapRound(Bitmap& rBitmap) { return checkLineCap(rBitmap, css::drawing::LineCap_ROUND); }
    static TestResult checkLineCapSquare(Bitmap& rBitmap) { return checkLineCap(rBitmap, css::drawing::LineCap_SQUARE); }
    static TestResult checkLineCapButt(Bitmap& rBitmap) { return checkLineCap(rBitmap, css::drawing::LineCap_BUTT); }

    static TestResult checkLineJoinBevel(Bitmap& rBitmap) { return checkLineJoin(rBitmap, basegfx::B2DLineJoin::Bevel); }
    static TestResult checkLineJoinRound(Bitmap& rBitmap) { return checkLineJoin(rBitmap, basegfx::B2DLineJoin::Round); }
    static TestResult checkLineJoinMiter(Bitmap& rBitmap) { return checkLineJoin(rBitmap, basegfx::B2DLineJoin::Miter); }
    static TestResult checkLineJoinNone(Bitmap& rBitmap) { return checkLineJoin(rBitmap, basegfx::B2DLineJoin::NONE); }
    static TestResult checkDropShape(Bitmap& rBitmap, bool aEnableAA = false);
    static TestResult checkHalfEllipse(Bitmap& rBitmap, bool aEnableAA = false);
    static TestResult checkClosedBezier(Bitmap& rBitmap);
    static TestResult checkFilledAsymmetricalDropShape(Bitmap& rBitmap);
    static TestResult checkTextLocation(Bitmap& rBitmap);
    static TestResult checkEvenOddRuleInIntersectingRecs(Bitmap &rBitmap);
    static TestResult checkIntersectingRecs(Bitmap& rBitmap,int aLayerNumber, Color aExpectedColor);
    static TestResult checkOpenPolygon(Bitmap& rBitmap, bool aEnableAA = false);
    static TestResult checkOpenBezier(Bitmap& rBitmap);
private:
    static TestResult checkLineCap(Bitmap& rBitmap, css::drawing::LineCap lineCap);
    static TestResult checkLineJoin(Bitmap& rBitmap, basegfx::B2DLineJoin lineJoin);
};

class VCL_DLLPUBLIC OutputDeviceTestBitmap : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestBitmap() = default;

    Bitmap setupDrawTransformedBitmap(vcl::PixelFormat aBitmapFormat,
                                      bool isBitmapGreyScale = false);
    Bitmap setupComplexDrawTransformedBitmap(vcl::PixelFormat aBitmapFormat,
                                             bool isBitmapGreyScale = false);
    Bitmap setupDrawBitmap(vcl::PixelFormat aBitmapFormat, bool isBitmapGreyScale = false);
    Bitmap setupDrawBitmapExWithAlpha(vcl::PixelFormat aBitmapFormat);
    Bitmap setupDrawMask(vcl::PixelFormat aBitmapFormat);
    BitmapEx setupDrawBlend(vcl::PixelFormat aBitmapFormat);

    static TestResult checkTransformedBitmap(Bitmap& rBitmap);
    static TestResult checkComplexTransformedBitmap(Bitmap& rBitmap);
    static TestResult checkBitmapExWithAlpha(Bitmap& rBitmap);
    static TestResult checkMask(Bitmap& rBitmap);
    static TestResult checkBlend(const BitmapEx& rBitmap);

    static TestResult checkTransformedBitmap8bppGreyScale(Bitmap& rBitmap);
};

class VCL_DLLPUBLIC OutputDeviceTestAnotherOutDev : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestAnotherOutDev() = default;

    Bitmap setupDrawOutDev();
    Bitmap setupDrawOutDevScaledClipped();
    Bitmap setupDrawOutDevSelf();
    Bitmap setupXOR();

    static TestResult checkDrawOutDev(Bitmap& rBitmap);
    static TestResult checkDrawOutDevScaledClipped(Bitmap& rBitmap);
    static TestResult checkDrawOutDevSelf(Bitmap& rBitmap);
    static TestResult checkXOR(Bitmap& rBitmap);
};

class VCL_DLLPUBLIC OutputDeviceTestPixel : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestPixel() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupRectangleOnSize1028();
    Bitmap setupRectangleOnSize4096();
};

class VCL_DLLPUBLIC OutputDeviceTestLine : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestLine() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupRectangleOnSize1028();
    Bitmap setupRectangleOnSize4096();
    Bitmap setupDiamond();
    Bitmap setupLines();
    Bitmap setupAALines();

    Bitmap setupDashedLine();
    static TestResult checkDashedLine(Bitmap& rBitmap);

    Bitmap setupLineCapRound() { return setupLineCap(css::drawing::LineCap_ROUND); }
    Bitmap setupLineCapSquare() { return setupLineCap(css::drawing::LineCap_SQUARE); }
    Bitmap setupLineCapButt() { return setupLineCap(css::drawing::LineCap_BUTT); }

    Bitmap setupLineJoinBevel() { return setupLineJoin(basegfx::B2DLineJoin::Bevel); }
    Bitmap setupLineJoinRound() { return setupLineJoin(basegfx::B2DLineJoin::Round); }
    Bitmap setupLineJoinMiter() { return setupLineJoin(basegfx::B2DLineJoin::Miter); }
    Bitmap setupLineJoinNone() { return setupLineJoin(basegfx::B2DLineJoin::NONE); }
private:
    Bitmap setupLineCap( css::drawing::LineCap lineCap );
    Bitmap setupLineJoin( basegfx::B2DLineJoin lineJoin );
};

class VCL_DLLPUBLIC OutputDeviceTestPolyLine : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestPolyLine() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupDiamond();
    Bitmap setupLines();
    Bitmap setupAALines();
    Bitmap setupDropShape();
    Bitmap setupAADropShape();
    Bitmap setupHalfEllipse(bool aEnableAA = false);
    Bitmap setupClosedBezier();
    Bitmap setupRectangleOnSize1028();
    Bitmap setupRectangleOnSize4096();
    Bitmap setupOpenPolygon();
    Bitmap setupOpenBezier();
};

class VCL_DLLPUBLIC OutputDeviceTestPolyLineB2D : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestPolyLineB2D() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupDiamond();
    Bitmap setupBezier();
    Bitmap setupAABezier();
    Bitmap setupHalfEllipse(bool aEnableAA = false);
    Bitmap setupRectangleOnSize1028();
    Bitmap setupRectangleOnSize4096();
    Bitmap setupOpenPolygon();
    Bitmap setupOpenBezier();
};

class VCL_DLLPUBLIC OutputDeviceTestRect : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestRect() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupFilledRectangle(bool useLineColor);
    Bitmap setupRectangleOnSize1028();
    Bitmap setupRectangleOnSize4096();
    Bitmap setupInvert_NONE();
    Bitmap setupInvert_N50();
    Bitmap setupInvert_TrackFrame();
};

class VCL_DLLPUBLIC OutputDeviceTestPolygon : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestPolygon() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupFilledRectangle(bool useLineColor);
    Bitmap setupDiamond();
    Bitmap setupLines();
    Bitmap setupAALines();
    Bitmap setupDropShape();
    Bitmap setupAADropShape();
    Bitmap setupHalfEllipse(bool aEnableAA = false);
    Bitmap setupClosedBezier();
    Bitmap setupFilledAsymmetricalDropShape();
    Bitmap setupRectangleOnSize1028();
    Bitmap setupRectangleOnSize4096();
    Bitmap setupOpenPolygon();
};

class VCL_DLLPUBLIC OutputDeviceTestPolyPolygon : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestPolyPolygon() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupFilledRectangle(bool useLineColor);
    Bitmap setupIntersectingRectangles();
    Bitmap setupRectangleOnSize1028();
    Bitmap setupRectangleOnSize4096();
    Bitmap setupOpenPolygon();
};

class VCL_DLLPUBLIC OutputDeviceTestPolyPolygonB2D : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestPolyPolygonB2D() = default;

    Bitmap setupRectangle(bool bEnableAA);
    Bitmap setupFilledRectangle(bool useLineColor);
    Bitmap setupIntersectingRectangles();
    Bitmap setupRectangleOnSize1028();
    Bitmap setupRectangleOnSize4096();
    Bitmap setupOpenPolygon();
};

class VCL_DLLPUBLIC OutputDeviceTestGradient : public OutputDeviceTestCommon
{
public:
    OutputDeviceTestGradient() = default;

    Bitmap setupLinearGradient();
    Bitmap setupLinearGradientAngled();
    Bitmap setupLinearGradientBorder();
    Bitmap setupLinearGradientIntensity();
    Bitmap setupLinearGradientSteps();
    Bitmap setupAxialGradient();
    Bitmap setupRadialGradient();
    Bitmap setupRadialGradientOfs();
};

class VCL_DLLPUBLIC OutputDeviceTestClip : public OutputDeviceTestCommon
{
public:
    Bitmap setupClipRectangle();
    Bitmap setupClipPolygon();
    Bitmap setupClipPolyPolygon();
    Bitmap setupClipB2DPolyPolygon();

    static TestResult checkClip(Bitmap& rBitmap);
};

class VCL_DLLPUBLIC OutputDeviceTestText : public OutputDeviceTestCommon
{
public:
    Bitmap setupTextBitmap();
};

} // end namespace vcl::test

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */