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/bootstrapfixture.hxx>
13 #include <vcl/bitmap.hxx>
14 #include <tools/stream.hxx>
15 #include <vcl/graphicfilter.hxx>
16 #include <basegfx/matrix/b2dhommatrix.hxx>
17 #include <vcl/BitmapWriteAccess.hxx>
20 #include <salinst.hxx>
23 #include <test/outputdevice.hxx>
25 // Run tests from visualbackendtest ('bin/run visualbackendtest').
26 class BackendTest
: public test::BootstrapFixture
28 // if enabled - check the result images with:
29 // "xdg-open ./workdir/CppunitTest/vcl_backend_test.test.core/"
30 static constexpr const bool mbExportBitmap
= false;
32 void exportImage(OUString
const& rsFilename
, BitmapEx
const& rBitmapEx
)
36 BitmapEx
aBitmapEx(rBitmapEx
);
37 aBitmapEx
.Scale(Size(128, 128), BmpScaleFlag::Fast
);
38 SvFileStream
aStream(rsFilename
, StreamMode::WRITE
| StreamMode::TRUNC
);
39 GraphicFilter::GetGraphicFilter().compressAsPNG(aBitmapEx
, aStream
);
43 void exportImage(OUString
const& rsFilename
, Bitmap
const& rBitmap
)
47 Bitmap
aBitmap(rBitmap
);
48 aBitmap
.Scale(Size(128, 128), BmpScaleFlag::Fast
);
49 SvFileStream
aStream(rsFilename
, StreamMode::WRITE
| StreamMode::TRUNC
);
50 GraphicFilter::GetGraphicFilter().compressAsPNG(BitmapEx(aBitmap
), aStream
);
54 void exportDevice(const OUString
& filename
, const VclPtr
<VirtualDevice
>& device
)
58 BitmapEx
aBitmapEx(device
->GetBitmapEx(Point(0, 0), device
->GetOutputSizePixel()));
59 SvFileStream
aStream(filename
, StreamMode::WRITE
| StreamMode::TRUNC
);
60 GraphicFilter::GetGraphicFilter().compressAsPNG(aBitmapEx
, aStream
);
64 bool is32bppSupported() { return ImplGetSVData()->mpDefInst
->supportsBitmap32(); }
68 : BootstrapFixture(true, false)
72 // We need to enable tests ONE BY ONE as they fail because of backend bugs
73 // it is still important to have the test defined so we know the issues
74 // exist and we need to fix them. Consistent behaviour of our backends
75 // is of highest priority.
77 static bool assertBackendNameNotEmpty(const OUString
& name
)
79 // This ensures that all backends return a valid name.
80 assert(!name
.isEmpty());
85 // Check whether tests should fail depending on which backend is used
86 // (not all work). If you want to disable just a specific test
87 // for a specific backend, use something like
88 // 'if(SHOULD_ASSERT && aOutDevTest.getRenderBackendName() != "skia")'.
89 // The macro uses opt-out rather than opt-in so that this doesn't "pass"
90 // silently in case a new backend is added.
91 #define SHOULD_ASSERT \
92 (assertBackendNameNotEmpty(aOutDevTest.getRenderBackendName()) \
93 && aOutDevTest.getRenderBackendName() != "qt" \
94 && aOutDevTest.getRenderBackendName() != "qtsvp" \
95 && aOutDevTest.getRenderBackendName() != "gtk3svp" \
96 && aOutDevTest.getRenderBackendName() != "aqua" \
97 && aOutDevTest.getRenderBackendName() != "gen" \
98 && aOutDevTest.getRenderBackendName() != "genpsp" \
99 && aOutDevTest.getRenderBackendName() != "win")
102 static OUString
getRenderBackendName(OutputDevice
* device
)
105 return device
->GetGraphics()->getRenderBackendName();
109 void testDrawRectWithRectangle()
111 if (getDefaultDeviceBitCount() < 24)
113 vcl::test::OutputDeviceTestRect aOutDevTest
;
114 Bitmap aBitmap
= aOutDevTest
.setupRectangle(false);
115 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap
);
116 exportImage(u
"01-01_rectangle_test-rectangle.png"_ustr
, aBitmap
);
119 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
122 void testDrawRectWithPixel()
124 if (getDefaultDeviceBitCount() < 24)
126 vcl::test::OutputDeviceTestPixel aOutDevTest
;
127 Bitmap aBitmap
= aOutDevTest
.setupRectangle(false);
128 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap
);
129 exportImage(u
"01-02_rectangle_test-pixel.png"_ustr
, aBitmap
);
132 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
135 void testDrawRectWithLine()
137 if (getDefaultDeviceBitCount() < 24)
139 vcl::test::OutputDeviceTestLine aOutDevTest
;
140 Bitmap aBitmap
= aOutDevTest
.setupRectangle(false);
141 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap
);
142 exportImage(u
"01-03_rectangle_test-line.png"_ustr
, aBitmap
);
145 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
148 void testDrawRectWithPolygon()
150 if (getDefaultDeviceBitCount() < 24)
152 vcl::test::OutputDeviceTestPolygon aOutDevTest
;
153 Bitmap aBitmap
= aOutDevTest
.setupRectangle(false);
154 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap
);
155 exportImage(u
"01-04_rectangle_test-polygon.png"_ustr
, aBitmap
);
157 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
160 void testDrawRectWithPolyLine()
162 if (getDefaultDeviceBitCount() < 24)
164 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
165 Bitmap aBitmap
= aOutDevTest
.setupRectangle(false);
166 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap
);
167 exportImage(u
"01-05_rectangle_test-polyline.png"_ustr
, aBitmap
);
169 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
172 void testDrawRectWithPolyLineB2D()
174 if (getDefaultDeviceBitCount() < 24)
176 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest
;
177 Bitmap aBitmap
= aOutDevTest
.setupRectangle(false);
178 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap
);
179 exportImage(u
"01-06_rectangle_test-polyline_b2d.png"_ustr
, aBitmap
);
181 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
184 void testDrawRectWithPolyPolygon()
186 if (getDefaultDeviceBitCount() < 24)
188 vcl::test::OutputDeviceTestPolyPolygon aOutDevTest
;
189 Bitmap aBitmap
= aOutDevTest
.setupRectangle(false);
190 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap
);
191 exportImage(u
"01-07_rectangle_test-polypolygon.png"_ustr
, aBitmap
);
193 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
196 void testDrawRectWithPolyPolygonB2D()
198 if (getDefaultDeviceBitCount() < 24)
200 vcl::test::OutputDeviceTestPolyPolygonB2D aOutDevTest
;
201 Bitmap aBitmap
= aOutDevTest
.setupRectangle(false);
202 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap
);
203 exportImage(u
"01-08_rectangle_test-polypolygon_b2d.png"_ustr
, aBitmap
);
205 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
208 void testDrawRectAAWithRectangle()
210 if (getDefaultDeviceBitCount() < 24)
212 vcl::test::OutputDeviceTestRect aOutDevTest
;
213 Bitmap aBitmap
= aOutDevTest
.setupRectangle(true);
214 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap
);
215 exportImage(u
"02-01_rectangle_AA_test-rectangle.png"_ustr
, aBitmap
);
217 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
220 void testDrawRectAAWithPixel()
222 if (getDefaultDeviceBitCount() < 24)
224 vcl::test::OutputDeviceTestPixel aOutDevTest
;
225 Bitmap aBitmap
= aOutDevTest
.setupRectangle(true);
226 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap
);
227 exportImage(u
"02-02_rectangle_AA_test-pixel.png"_ustr
, aBitmap
);
229 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
232 void testDrawRectAAWithLine()
234 if (getDefaultDeviceBitCount() < 24)
236 vcl::test::OutputDeviceTestLine aOutDevTest
;
237 Bitmap aBitmap
= aOutDevTest
.setupRectangle(true);
238 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap
);
239 exportImage(u
"02-03_rectangle_AA_test-line.png"_ustr
, aBitmap
);
241 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
244 void testDrawRectAAWithPolygon()
246 if (getDefaultDeviceBitCount() < 24)
248 vcl::test::OutputDeviceTestPolygon aOutDevTest
;
249 Bitmap aBitmap
= aOutDevTest
.setupRectangle(true);
250 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap
);
251 exportImage(u
"02-04_rectangle_AA_test-polygon.png"_ustr
, aBitmap
);
253 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
256 void testDrawRectAAWithPolyLine()
258 if (getDefaultDeviceBitCount() < 24)
260 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
261 Bitmap aBitmap
= aOutDevTest
.setupRectangle(true);
262 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap
);
263 exportImage(u
"02-05_rectangle_AA_test-polyline.png"_ustr
, aBitmap
);
265 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
268 void testDrawRectAAWithPolyLineB2D()
270 if (getDefaultDeviceBitCount() < 24)
272 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest
;
273 Bitmap aBitmap
= aOutDevTest
.setupRectangle(true);
274 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap
);
275 exportImage(u
"02-06_rectangle_AA_test-polyline_b2d.png"_ustr
, aBitmap
);
277 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
280 void testDrawRectAAWithPolyPolygon()
282 if (getDefaultDeviceBitCount() < 24)
284 vcl::test::OutputDeviceTestPolyPolygon aOutDevTest
;
285 Bitmap aBitmap
= aOutDevTest
.setupRectangle(true);
286 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap
);
287 exportImage(u
"02-07_rectangle_AA_test-polypolygon.png"_ustr
, aBitmap
);
289 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
292 void testDrawRectAAWithPolyPolygonB2D()
294 if (getDefaultDeviceBitCount() < 24)
296 vcl::test::OutputDeviceTestPolyPolygonB2D aOutDevTest
;
297 Bitmap aBitmap
= aOutDevTest
.setupRectangle(true);
298 auto eResult
= vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap
);
299 exportImage(u
"02-08_rectangle_AA_test-polypolygon_b2d.png"_ustr
, aBitmap
);
301 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
304 void testDrawFilledRectWithRectangle()
306 if (getDefaultDeviceBitCount() < 24)
308 vcl::test::OutputDeviceTestRect aOutDevTest
;
309 Bitmap aBitmap
= aOutDevTest
.setupFilledRectangle(false);
310 auto eResult
= vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap
, false);
311 exportImage(u
"03-01_filled_rectangle_test-rectangle_noline.png"_ustr
, aBitmap
);
313 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
314 aBitmap
= aOutDevTest
.setupFilledRectangle(true);
315 eResult
= vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap
, true);
316 exportImage(u
"03-01_filled_rectangle_test-rectangle_line.png"_ustr
, aBitmap
);
318 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
321 void testDrawFilledRectWithPolygon()
323 if (getDefaultDeviceBitCount() < 24)
325 vcl::test::OutputDeviceTestPolygon aOutDevTest
;
326 Bitmap aBitmap
= aOutDevTest
.setupFilledRectangle(false);
327 auto eResult
= vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap
, false);
328 exportImage(u
"03-02_filled_rectangle_test-polygon_noline.png"_ustr
, aBitmap
);
330 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
331 aBitmap
= aOutDevTest
.setupFilledRectangle(true);
332 eResult
= vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap
, true);
333 exportImage(u
"03-02_filled_rectangle_test-polygon_line.png"_ustr
, aBitmap
);
335 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
338 void testDrawFilledRectWithPolyPolygon()
340 if (getDefaultDeviceBitCount() < 24)
342 vcl::test::OutputDeviceTestPolyPolygon aOutDevTest
;
343 Bitmap aBitmap
= aOutDevTest
.setupFilledRectangle(false);
344 auto eResult
= vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap
, false);
345 exportImage(u
"03-03_filled_rectangle_test-polypolygon_noline.png"_ustr
, aBitmap
);
347 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
348 aBitmap
= aOutDevTest
.setupFilledRectangle(true);
349 eResult
= vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap
, true);
350 exportImage(u
"03-03_filled_rectangle_test-polypolygon_line.png"_ustr
, aBitmap
);
352 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
355 void testDrawFilledRectWithPolyPolygon2D()
357 if (getDefaultDeviceBitCount() < 24)
359 vcl::test::OutputDeviceTestPolyPolygonB2D aOutDevTest
;
360 Bitmap aBitmap
= aOutDevTest
.setupFilledRectangle(false);
361 auto eResult
= vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap
, false);
362 exportImage(u
"03-04_filled_rectangle_test-polypolygon_b2d_noline.png"_ustr
, aBitmap
);
364 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
365 aBitmap
= aOutDevTest
.setupFilledRectangle(true);
366 eResult
= vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap
, true);
367 exportImage(u
"03-04_filled_rectangle_test-polypolygon_b2d_line.png"_ustr
, aBitmap
);
369 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
372 void testDrawDiamondWithPolygon()
374 vcl::test::OutputDeviceTestPolygon aOutDevTest
;
375 Bitmap aBitmap
= aOutDevTest
.setupDiamond();
376 auto eResult
= vcl::test::OutputDeviceTestCommon::checkDiamond(aBitmap
);
377 exportImage(u
"04-01_diamond_test-polygon.png"_ustr
, aBitmap
);
379 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
382 void testDrawDiamondWithLine()
384 vcl::test::OutputDeviceTestLine aOutDevTest
;
385 Bitmap aBitmap
= aOutDevTest
.setupDiamond();
386 auto eResult
= vcl::test::OutputDeviceTestCommon::checkDiamond(aBitmap
);
387 exportImage(u
"04-02_diamond_test-line.png"_ustr
, aBitmap
);
389 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
392 void testDrawDiamondWithPolyline()
394 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
395 Bitmap aBitmap
= aOutDevTest
.setupDiamond();
396 auto eResult
= vcl::test::OutputDeviceTestCommon::checkDiamond(aBitmap
);
397 exportImage(u
"04-03_diamond_test-polyline.png"_ustr
, aBitmap
);
399 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
402 void testDrawDiamondWithPolylineB2D()
404 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest
;
405 Bitmap aBitmap
= aOutDevTest
.setupDiamond();
406 auto eResult
= vcl::test::OutputDeviceTestCommon::checkDiamond(aBitmap
);
407 exportImage(u
"04-04_diamond_test-polyline_b2d.png"_ustr
, aBitmap
);
409 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
412 void testDrawInvertWithRectangle()
414 vcl::test::OutputDeviceTestRect aOutDevTest
;
415 Bitmap aBitmap
= aOutDevTest
.setupInvert_NONE();
416 auto eResult
= vcl::test::OutputDeviceTestCommon::checkInvertRectangle(aBitmap
);
417 exportImage(u
"05-01_invert_test-rectangle.png"_ustr
, aBitmap
);
419 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
422 void testDrawInvertN50WithRectangle()
424 vcl::test::OutputDeviceTestRect aOutDevTest
;
425 Bitmap aBitmap
= aOutDevTest
.setupInvert_N50();
426 auto eResult
= vcl::test::OutputDeviceTestCommon::checkInvertN50Rectangle(aBitmap
);
427 exportImage(u
"05-02_invert_N50_test-rectangle.png"_ustr
, aBitmap
);
428 if (SHOULD_ASSERT
&& aOutDevTest
.getRenderBackendName() != "svp")
429 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
432 void testDrawInvertTrackFrameWithRectangle()
434 vcl::test::OutputDeviceTestRect aOutDevTest
;
435 Bitmap aBitmap
= aOutDevTest
.setupInvert_TrackFrame();
436 auto eResult
= vcl::test::OutputDeviceTestCommon::checkInvertTrackFrameRectangle(aBitmap
);
437 exportImage(u
"05-03_invert_TrackFrame_test-rectangle.png"_ustr
, aBitmap
);
438 if (SHOULD_ASSERT
&& aOutDevTest
.getRenderBackendName() != "svp")
439 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
442 void testDrawBezierWithPolylineB2D()
444 if (getDefaultDeviceBitCount() < 24)
446 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest
;
447 Bitmap aBitmap
= aOutDevTest
.setupBezier();
448 auto eResult
= vcl::test::OutputDeviceTestCommon::checkBezier(aBitmap
);
449 exportImage(u
"06-01_bezier_test-polyline_b2d.png"_ustr
, aBitmap
);
451 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
454 void testDrawBezierAAWithPolylineB2D()
456 if (getDefaultDeviceBitCount() < 24)
458 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest
;
459 Bitmap aBitmap
= aOutDevTest
.setupAABezier();
460 auto eResult
= vcl::test::OutputDeviceTestCommon::checkBezier(aBitmap
);
461 exportImage(u
"07-01_bezier_AA_test-polyline_b2d.png"_ustr
, aBitmap
);
463 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
466 void testDrawBitmap24bpp()
468 if (getDefaultDeviceBitCount() < 24)
470 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
471 Bitmap aBitmap
= aOutDevTest
.setupDrawBitmap(vcl::PixelFormat::N24_BPP
);
472 exportImage(u
"08-01_bitmap_test_24bpp.png"_ustr
, aBitmap
);
473 auto eResult
= vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap
);
475 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
478 void testDrawTransformedBitmap24bpp()
480 if (getDefaultDeviceBitCount() < 24)
482 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
483 Bitmap aBitmap
= aOutDevTest
.setupDrawTransformedBitmap(vcl::PixelFormat::N24_BPP
);
484 auto eResult
= vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap
);
485 exportImage(u
"08-02_transformed_bitmap_test_24bpp.png"_ustr
, aBitmap
);
487 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
490 void testComplexDrawTransformedBitmap24bpp()
492 if (getDefaultDeviceBitCount() < 24)
494 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
495 Bitmap aBitmap
= aOutDevTest
.setupComplexDrawTransformedBitmap(vcl::PixelFormat::N24_BPP
);
496 auto eResult
= vcl::test::OutputDeviceTestBitmap::checkComplexTransformedBitmap(aBitmap
);
497 exportImage(u
"08-03_transformed_bitmap_test_24bpp.png"_ustr
, aBitmap
);
499 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
502 void testDrawBitmapExWithAlpha24bpp()
504 if (getDefaultDeviceBitCount() < 24)
506 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
507 Bitmap aBitmap
= aOutDevTest
.setupDrawBitmapExWithAlpha(vcl::PixelFormat::N24_BPP
);
508 auto eResult
= vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap
);
509 exportImage(u
"08-04_bitmapex_with_alpha_test_24bpp.png"_ustr
, aBitmap
);
511 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
514 void testDrawMask24bpp()
516 if (getDefaultDeviceBitCount() < 24)
518 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
519 Bitmap aBitmap
= aOutDevTest
.setupDrawMask(vcl::PixelFormat::N24_BPP
);
520 auto eResult
= vcl::test::OutputDeviceTestBitmap::checkMask(aBitmap
);
521 exportImage(u
"08-05_mask_test_24bpp.png"_ustr
, aBitmap
);
523 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
526 void testDrawBlend24bpp()
528 if (getDefaultDeviceBitCount() < 24)
530 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
531 BitmapEx aBitmapEx
= aOutDevTest
.setupDrawBlend(vcl::PixelFormat::N24_BPP
);
532 auto eResult
= vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx
);
533 exportImage(u
"08-06_blend_test_24bpp.png"_ustr
, aBitmapEx
);
535 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
538 void testDrawBitmap32bpp()
540 if (getDefaultDeviceBitCount() < 24)
542 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
543 Bitmap aBitmap
= aOutDevTest
.setupDrawBitmap(vcl::PixelFormat::N32_BPP
);
544 exportImage(u
"09-01_bitmap_test_32bpp.png"_ustr
, aBitmap
);
545 auto eResult
= vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap
);
546 if (SHOULD_ASSERT
&& is32bppSupported())
547 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
550 void testDrawTransformedBitmap32bpp()
552 if (getDefaultDeviceBitCount() < 24)
554 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
555 Bitmap aBitmap
= aOutDevTest
.setupDrawTransformedBitmap(vcl::PixelFormat::N32_BPP
);
556 auto eResult
= vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap
);
557 exportImage(u
"09-02_transformed_bitmap_test_32bpp.png"_ustr
, aBitmap
);
558 if (SHOULD_ASSERT
&& is32bppSupported())
559 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
562 void testDrawBitmapExWithAlpha32bpp()
564 if (getDefaultDeviceBitCount() < 24)
566 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
567 Bitmap aBitmap
= aOutDevTest
.setupDrawBitmapExWithAlpha(vcl::PixelFormat::N32_BPP
);
568 auto eResult
= vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap
);
569 exportImage(u
"09-03_bitmapex_with_alpha_test_32bpp.png"_ustr
, aBitmap
);
570 if (SHOULD_ASSERT
&& is32bppSupported())
571 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
574 void testDrawMask32bpp()
576 if (getDefaultDeviceBitCount() < 24)
578 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
579 Bitmap aBitmap
= aOutDevTest
.setupDrawMask(vcl::PixelFormat::N32_BPP
);
580 auto eResult
= vcl::test::OutputDeviceTestBitmap::checkMask(aBitmap
);
581 exportImage(u
"09-04_mask_test_32bpp.png"_ustr
, aBitmap
);
582 if (SHOULD_ASSERT
&& is32bppSupported())
583 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
586 void testDrawBlend32bpp()
588 if (getDefaultDeviceBitCount() < 24)
590 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
591 BitmapEx aBitmapEx
= aOutDevTest
.setupDrawBlend(vcl::PixelFormat::N32_BPP
);
592 auto eResult
= vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx
);
593 exportImage(u
"09-05_blend_test_32bpp.png"_ustr
, aBitmapEx
);
594 if (SHOULD_ASSERT
&& is32bppSupported())
595 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
598 void testDrawBitmap8bppGreyScale()
600 if (getDefaultDeviceBitCount() < 24)
602 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
603 Bitmap aBitmap
= aOutDevTest
.setupDrawBitmap(vcl::PixelFormat::N8_BPP
, true);
604 exportImage(u
"010-01_bitmap_test_8bpp_greyscale.png"_ustr
, aBitmap
);
606 = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap8bppGreyScale(aBitmap
);
608 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
611 void testDrawTransformedBitmap8bppGreyScale()
613 if (getDefaultDeviceBitCount() < 24)
615 vcl::test::OutputDeviceTestBitmap aOutDevTest
;
616 Bitmap aBitmap
= aOutDevTest
.setupDrawTransformedBitmap(vcl::PixelFormat::N8_BPP
, true);
618 = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap8bppGreyScale(aBitmap
);
619 exportImage(u
"010-02_transformed_bitmap_test_8bpp_greyscale.png"_ustr
, aBitmap
);
621 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
626 if (getDefaultDeviceBitCount() < 24)
628 vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest
;
629 Bitmap aBitmap
= aOutDevTest
.setupXOR();
630 auto eResult
= vcl::test::OutputDeviceTestAnotherOutDev::checkXOR(aBitmap
);
631 exportImage(u
"08-06_xor_test.png"_ustr
, aBitmap
);
633 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
636 void testDrawTransformedBitmapExAlpha()
638 if (getDefaultDeviceBitCount() < 24)
640 ScopedVclPtrInstance
<VirtualDevice
> device
;
642 // TODO: This unit test is not executed for macOS unless bitmap scaling is implemented
643 if (getRenderBackendName(device
) == "aqua")
646 device
->SetOutputSizePixel(Size(16, 16));
647 device
->SetBackground(Wallpaper(COL_WHITE
));
649 Bitmap
aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP
);
651 // Fill the top left quarter with black.
652 BitmapScopedWriteAccess
pWriteAccess(aBitmap
);
653 pWriteAccess
->Erase(COL_WHITE
);
654 for (int i
= 0; i
< 8; ++i
)
655 for (int j
= 0; j
< 8; ++j
)
656 pWriteAccess
->SetPixel(j
, i
, COL_BLACK
);
658 BitmapEx
aBitmapEx(aBitmap
);
659 basegfx::B2DHomMatrix aMatrix
;
660 // Draw with no transformation, only alpha change.
661 aMatrix
.scale(16, 16);
662 device
->DrawTransformedBitmapEx(aMatrix
, aBitmapEx
, 0.5);
663 BitmapEx result
= device
->GetBitmapEx(Point(0, 0), Size(16, 16));
664 CPPUNIT_ASSERT_EQUAL(COL_GRAY
, result
.GetPixelColor(0, 0));
665 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, result
.GetPixelColor(15, 15));
666 // Draw rotated and move to the bottom-left corner.
669 aMatrix
.scale(16, 16);
670 aMatrix
.rotate(M_PI
/ 2);
671 aMatrix
.translate(8, 8);
672 device
->DrawTransformedBitmapEx(aMatrix
, aBitmapEx
, 0.5);
673 result
= device
->GetBitmap(Point(0, 0), Size(16, 16));
674 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, result
.GetPixelColor(0, 0));
675 CPPUNIT_ASSERT_EQUAL(COL_GRAY
, result
.GetPixelColor(0, 15));
678 void testClipRectangle()
680 if (getDefaultDeviceBitCount() < 24)
682 vcl::test::OutputDeviceTestClip aOutDevTest
;
683 Bitmap aBitmap
= aOutDevTest
.setupClipRectangle();
684 auto eResult
= vcl::test::OutputDeviceTestClip::checkClip(aBitmap
);
685 exportImage(u
"09-01_clip_rectangle_test.png"_ustr
, aBitmap
);
687 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
690 void testClipPolygon()
692 if (getDefaultDeviceBitCount() < 24)
694 vcl::test::OutputDeviceTestClip aOutDevTest
;
695 Bitmap aBitmap
= aOutDevTest
.setupClipPolygon();
696 auto eResult
= vcl::test::OutputDeviceTestClip::checkClip(aBitmap
);
697 exportImage(u
"09-02_clip_polygon_test.png"_ustr
, aBitmap
);
699 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
702 void testClipPolyPolygon()
704 if (getDefaultDeviceBitCount() < 24)
706 vcl::test::OutputDeviceTestClip aOutDevTest
;
707 Bitmap aBitmap
= aOutDevTest
.setupClipPolyPolygon();
708 auto eResult
= vcl::test::OutputDeviceTestClip::checkClip(aBitmap
);
709 exportImage(u
"09-03_clip_polypolygon_test.png"_ustr
, aBitmap
);
711 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
714 void testClipB2DPolyPolygon()
716 if (getDefaultDeviceBitCount() < 24)
718 vcl::test::OutputDeviceTestClip aOutDevTest
;
719 Bitmap aBitmap
= aOutDevTest
.setupClipB2DPolyPolygon();
720 auto eResult
= vcl::test::OutputDeviceTestClip::checkClip(aBitmap
);
721 exportImage(u
"09-04_clip_b2dpolypolygon_test.png"_ustr
, aBitmap
);
723 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
726 void testDrawOutDev()
728 if (getDefaultDeviceBitCount() < 24)
730 vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest
;
731 Bitmap aBitmap
= aOutDevTest
.setupDrawOutDev();
732 auto eResult
= vcl::test::OutputDeviceTestAnotherOutDev::checkDrawOutDev(aBitmap
);
733 exportImage(u
"10-01_draw_out_dev_test.png"_ustr
, aBitmap
);
735 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
738 void testDrawOutDevScaledClipped()
740 if (getDefaultDeviceBitCount() < 24)
742 vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest
;
743 Bitmap aBitmap
= aOutDevTest
.setupDrawOutDevScaledClipped();
745 = vcl::test::OutputDeviceTestAnotherOutDev::checkDrawOutDevScaledClipped(aBitmap
);
746 exportImage(u
"10-02_draw_out_dev_scaled_clipped_test.png"_ustr
, aBitmap
);
748 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
751 void testDrawOutDevSelf()
753 if (getDefaultDeviceBitCount() < 24)
755 vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest
;
756 Bitmap aBitmap
= aOutDevTest
.setupDrawOutDevSelf();
757 auto eResult
= vcl::test::OutputDeviceTestAnotherOutDev::checkDrawOutDevSelf(aBitmap
);
758 exportImage(u
"10-03_draw_out_dev_self_test.png"_ustr
, aBitmap
);
760 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
763 void testDashedLine()
765 if (getDefaultDeviceBitCount() < 24)
767 vcl::test::OutputDeviceTestLine aOutDevTest
;
768 Bitmap aBitmap
= aOutDevTest
.setupDashedLine();
769 auto eResult
= vcl::test::OutputDeviceTestLine::checkDashedLine(aBitmap
);
770 exportImage(u
"11-01_dashed_line_test.png"_ustr
, aBitmap
);
772 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
777 if (getDefaultDeviceBitCount() < 24)
780 // Create normal virtual device (no alpha).
781 ScopedVclPtr
<VirtualDevice
> device
782 = VclPtr
<VirtualDevice
>::Create(DeviceFormat::WITHOUT_ALPHA
);
783 device
->SetOutputSizePixel(Size(10, 10));
784 // Erase with white, check it's white.
785 device
->SetBackground(Wallpaper(COL_WHITE
));
787 exportDevice(u
"12-01_erase.png"_ustr
, device
);
788 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(0, 0)));
789 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(9, 9)));
790 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(5, 5)));
791 // Erase with black, check it's black.
792 device
->SetBackground(Wallpaper(COL_BLACK
));
794 exportDevice(u
"12-02_erase.png"_ustr
, device
);
795 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, device
->GetPixel(Point(0, 0)));
796 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, device
->GetPixel(Point(9, 9)));
797 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, device
->GetPixel(Point(5, 5)));
798 // Erase with cyan, check it's cyan.
799 device
->SetBackground(Wallpaper(COL_CYAN
));
801 exportDevice(u
"12-03_erase.png"_ustr
, device
);
802 CPPUNIT_ASSERT_EQUAL(COL_CYAN
, device
->GetPixel(Point(0, 0)));
803 CPPUNIT_ASSERT_EQUAL(COL_CYAN
, device
->GetPixel(Point(9, 9)));
804 CPPUNIT_ASSERT_EQUAL(COL_CYAN
, device
->GetPixel(Point(5, 5)));
807 // Create virtual device with alpha.
808 ScopedVclPtr
<VirtualDevice
> device
809 = VclPtr
<VirtualDevice
>::Create(DeviceFormat::WITH_ALPHA
);
810 device
->SetOutputSizePixel(Size(10, 10));
811 // Erase with white, check it's white.
812 device
->SetBackground(Wallpaper(COL_WHITE
));
814 exportDevice(u
"12-04_erase.png"_ustr
, device
);
815 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(0, 0)));
816 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(9, 9)));
817 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(5, 5)));
818 // Erase with black, check it's black.
819 device
->SetBackground(Wallpaper(COL_BLACK
));
821 exportDevice(u
"12-05_erase.png"_ustr
, device
);
822 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, device
->GetPixel(Point(0, 0)));
823 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, device
->GetPixel(Point(9, 9)));
824 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, device
->GetPixel(Point(5, 5)));
825 // Erase with cyan, check it's cyan.
826 device
->SetBackground(Wallpaper(COL_CYAN
));
828 exportDevice(u
"12-06_erase.png"_ustr
, device
);
829 CPPUNIT_ASSERT_EQUAL(COL_CYAN
, device
->GetPixel(Point(0, 0)));
830 CPPUNIT_ASSERT_EQUAL(COL_CYAN
, device
->GetPixel(Point(9, 9)));
831 CPPUNIT_ASSERT_EQUAL(COL_CYAN
, device
->GetPixel(Point(5, 5)));
832 // Erase with transparent, check it's transparent.
833 device
->SetBackground(Wallpaper(COL_TRANSPARENT
));
835 exportDevice(u
"12-07_erase.png"_ustr
, device
);
836 CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), device
->GetPixel(Point(0, 0)).GetAlpha());
837 CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), device
->GetPixel(Point(9, 9)).GetAlpha());
838 CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), device
->GetPixel(Point(5, 5)).GetAlpha());
842 void testLinearGradient()
844 if (getDefaultDeviceBitCount() < 24)
846 vcl::test::OutputDeviceTestGradient aOutDevTest
;
847 Bitmap aBitmap
= aOutDevTest
.setupLinearGradient();
848 auto eResult
= vcl::test::OutputDeviceTestGradient::checkLinearGradient(aBitmap
);
849 exportImage(u
"13-01_linear_gradient_test.png"_ustr
, aBitmap
);
851 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
854 void testLinearGradientAngled()
856 if (getDefaultDeviceBitCount() < 24)
858 vcl::test::OutputDeviceTestGradient aOutDevTest
;
859 Bitmap aBitmap
= aOutDevTest
.setupLinearGradientAngled();
860 auto eResult
= vcl::test::OutputDeviceTestGradient::checkLinearGradientAngled(aBitmap
);
861 exportImage(u
"13-02_linear_gradient_angled_test.png"_ustr
, aBitmap
);
863 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
866 void testLinearGradientBorder()
868 vcl::test::OutputDeviceTestGradient aOutDevTest
;
869 Bitmap aBitmap
= aOutDevTest
.setupLinearGradientBorder();
870 auto eResult
= vcl::test::OutputDeviceTestGradient::checkLinearGradientBorder(aBitmap
);
871 exportImage(u
"13-03_linear_gradient_border_test.png"_ustr
, aBitmap
);
873 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
876 void testLinearGradientIntensity()
878 if (getDefaultDeviceBitCount() < 24)
880 vcl::test::OutputDeviceTestGradient aOutDevTest
;
881 Bitmap aBitmap
= aOutDevTest
.setupLinearGradientIntensity();
882 auto eResult
= vcl::test::OutputDeviceTestGradient::checkLinearGradientIntensity(aBitmap
);
883 exportImage(u
"13-04_linear_gradient_intensity_test.png"_ustr
, aBitmap
);
885 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
888 void testLinearGradientSteps()
890 if (getDefaultDeviceBitCount() < 24)
892 vcl::test::OutputDeviceTestGradient aOutDevTest
;
893 Bitmap aBitmap
= aOutDevTest
.setupLinearGradientSteps();
894 auto eResult
= vcl::test::OutputDeviceTestGradient::checkLinearGradientSteps(aBitmap
);
895 exportImage(u
"13-05_linear_gradient_steps_test.png"_ustr
, aBitmap
);
897 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
900 void testAxialGradient()
902 if (getDefaultDeviceBitCount() < 24)
904 vcl::test::OutputDeviceTestGradient aOutDevTest
;
905 Bitmap aBitmap
= aOutDevTest
.setupAxialGradient();
906 auto eResult
= vcl::test::OutputDeviceTestGradient::checkAxialGradient(aBitmap
);
907 exportImage(u
"13-06_axial_gradient_test.png"_ustr
, aBitmap
);
909 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
912 void testRadialGradient()
914 if (getDefaultDeviceBitCount() < 24)
916 vcl::test::OutputDeviceTestGradient aOutDevTest
;
917 Bitmap aBitmap
= aOutDevTest
.setupRadialGradient();
918 auto eResult
= vcl::test::OutputDeviceTestGradient::checkRadialGradient(aBitmap
);
919 exportImage(u
"13-07_radial_gradient_test.png"_ustr
, aBitmap
);
921 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
924 void testRadialGradientOfs()
926 vcl::test::OutputDeviceTestGradient aOutDevTest
;
927 Bitmap aBitmap
= aOutDevTest
.setupRadialGradientOfs();
928 auto eResult
= vcl::test::OutputDeviceTestGradient::checkRadialGradientOfs(aBitmap
);
929 exportImage(u
"13-08_radial_gradient_ofs_test.png"_ustr
, aBitmap
);
931 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
934 void testLineJoinBevel()
936 vcl::test::OutputDeviceTestLine aOutDevTest
;
937 Bitmap aBitmap
= aOutDevTest
.setupLineJoinBevel();
938 auto eResult
= vcl::test::OutputDeviceTestLine::checkLineJoinBevel(aBitmap
);
939 exportImage(u
"14-01_line_join_bevel_test.png"_ustr
, aBitmap
);
941 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
944 void testLineJoinRound()
946 vcl::test::OutputDeviceTestLine aOutDevTest
;
947 Bitmap aBitmap
= aOutDevTest
.setupLineJoinRound();
948 auto eResult
= vcl::test::OutputDeviceTestLine::checkLineJoinRound(aBitmap
);
949 exportImage(u
"14-02_line_join_round_test.png"_ustr
, aBitmap
);
951 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
954 void testLineJoinMiter()
956 vcl::test::OutputDeviceTestLine aOutDevTest
;
957 Bitmap aBitmap
= aOutDevTest
.setupLineJoinMiter();
958 auto eResult
= vcl::test::OutputDeviceTestLine::checkLineJoinMiter(aBitmap
);
959 exportImage(u
"14-03_line_join_miter_test.png"_ustr
, aBitmap
);
961 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
964 void testLineJoinNone()
966 vcl::test::OutputDeviceTestLine aOutDevTest
;
967 Bitmap aBitmap
= aOutDevTest
.setupLineJoinNone();
968 auto eResult
= vcl::test::OutputDeviceTestLine::checkLineJoinNone(aBitmap
);
969 exportImage(u
"14-04_line_join_none_test.png"_ustr
, aBitmap
);
971 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
974 void testLineCapRound()
976 vcl::test::OutputDeviceTestLine aOutDevTest
;
977 Bitmap aBitmap
= aOutDevTest
.setupLineCapRound();
978 auto eResult
= vcl::test::OutputDeviceTestLine::checkLineCapRound(aBitmap
);
979 exportImage(u
"14-05_line_cap_round_test.png"_ustr
, aBitmap
);
981 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
984 void testLineCapSquare()
986 vcl::test::OutputDeviceTestLine aOutDevTest
;
987 Bitmap aBitmap
= aOutDevTest
.setupLineCapSquare();
988 auto eResult
= vcl::test::OutputDeviceTestLine::checkLineCapSquare(aBitmap
);
989 exportImage(u
"14-06_line_cap_square_test.png"_ustr
, aBitmap
);
991 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
994 void testLineCapButt()
996 vcl::test::OutputDeviceTestLine aOutDevTest
;
997 Bitmap aBitmap
= aOutDevTest
.setupLineCapButt();
998 auto eResult
= vcl::test::OutputDeviceTestLine::checkLineCapButt(aBitmap
);
999 exportImage(u
"14-07_line_cap_butt_test.png"_ustr
, aBitmap
);
1001 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1004 void testDrawDropShapeWithPolyline()
1006 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
1007 Bitmap aBitmap
= aOutDevTest
.setupDropShape();
1008 auto eResult
= vcl::test::OutputDeviceTestCommon::checkDropShape(aBitmap
);
1009 exportImage(u
"15-01_drop_shape_test-polyline.png"_ustr
, aBitmap
);
1011 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1014 void testDrawDropShapeAAWithPolyline()
1016 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
1017 Bitmap aBitmap
= aOutDevTest
.setupAADropShape();
1018 auto eResult
= vcl::test::OutputDeviceTestCommon::checkDropShape(aBitmap
, true);
1019 exportImage(u
"15-02_drop_shape_AA_test-polyline.png"_ustr
, aBitmap
);
1021 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1024 void testDrawDropShapeWithPolygon()
1026 vcl::test::OutputDeviceTestPolygon aOutDevTest
;
1027 Bitmap aBitmap
= aOutDevTest
.setupDropShape();
1028 auto eResult
= vcl::test::OutputDeviceTestCommon::checkDropShape(aBitmap
);
1029 exportImage(u
"16-01_drop_shape_test-polygon.png"_ustr
, aBitmap
);
1031 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1034 void testDrawDropShapeAAWithPolygon()
1036 vcl::test::OutputDeviceTestPolygon aOutDevTest
;
1037 Bitmap aBitmap
= aOutDevTest
.setupAADropShape();
1038 auto eResult
= vcl::test::OutputDeviceTestCommon::checkDropShape(aBitmap
, true);
1039 exportImage(u
"16-02_drop_shape_AA_test-polygon.png"_ustr
, aBitmap
);
1041 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1044 void testDrawHaflEllipseWithPolyLine()
1046 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
1047 Bitmap aBitmap
= aOutDevTest
.setupHalfEllipse();
1048 auto eResult
= vcl::test::OutputDeviceTestCommon::checkHalfEllipse(aBitmap
);
1049 exportImage(u
"17-01_half_ellipse_test-polyline.png"_ustr
, aBitmap
);
1051 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1054 void testDrawHaflEllipseAAWithPolyLine()
1056 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
1057 Bitmap aBitmap
= aOutDevTest
.setupHalfEllipse(true);
1058 auto eResult
= vcl::test::OutputDeviceTestCommon::checkHalfEllipse(aBitmap
, true);
1059 exportImage(u
"17-02_half_ellipse_AA_test-polyline.png"_ustr
, aBitmap
);
1061 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1064 void testDrawHaflEllipseWithPolyLineB2D()
1066 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest
;
1067 Bitmap aBitmap
= aOutDevTest
.setupHalfEllipse();
1068 auto eResult
= vcl::test::OutputDeviceTestCommon::checkHalfEllipse(aBitmap
);
1069 exportImage(u
"17-03_half_ellipse_test-polylineb2d.png"_ustr
, aBitmap
);
1071 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1074 void testDrawHaflEllipseAAWithPolyLineB2D()
1076 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest
;
1077 Bitmap aBitmap
= aOutDevTest
.setupHalfEllipse(true);
1078 auto eResult
= vcl::test::OutputDeviceTestCommon::checkHalfEllipse(aBitmap
, true);
1079 exportImage(u
"17-03_half_ellipse_AA_test-polylineb2d.png"_ustr
, aBitmap
);
1081 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1084 void testDrawHaflEllipseWithPolygon()
1086 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
1087 Bitmap aBitmap
= aOutDevTest
.setupHalfEllipse();
1088 auto eResult
= vcl::test::OutputDeviceTestCommon::checkHalfEllipse(aBitmap
);
1089 exportImage(u
"17-04_half_ellipse_test-polygon.png"_ustr
, aBitmap
);
1091 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1094 void testDrawHaflEllipseAAWithPolygon()
1096 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
1097 Bitmap aBitmap
= aOutDevTest
.setupHalfEllipse(true);
1098 auto eResult
= vcl::test::OutputDeviceTestCommon::checkHalfEllipse(aBitmap
, true);
1099 exportImage(u
"17-05_half_ellipse_AA_test-polygon.png"_ustr
, aBitmap
);
1101 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1104 void testClosedBezierWithPolyline()
1106 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
1107 Bitmap aBitmap
= aOutDevTest
.setupClosedBezier();
1108 auto eResult
= vcl::test::OutputDeviceTestCommon::checkClosedBezier(aBitmap
);
1109 exportImage(u
"18-01_closed_bezier-polyline.png"_ustr
, aBitmap
);
1111 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1114 void testClosedBezierWithPolygon()
1116 vcl::test::OutputDeviceTestPolygon aOutDevTest
;
1117 Bitmap aBitmap
= aOutDevTest
.setupClosedBezier();
1118 auto eResult
= vcl::test::OutputDeviceTestCommon::checkClosedBezier(aBitmap
);
1119 exportImage(u
"18-02_closed_bezier-polygon.png"_ustr
, aBitmap
);
1121 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1124 void testFilledAsymmetricalDropShape()
1126 vcl::test::OutputDeviceTestPolygon aOutDevTest
;
1127 Bitmap aBitmap
= aOutDevTest
.setupFilledAsymmetricalDropShape();
1128 vcl::test::TestResult eResult
1129 = vcl::test::OutputDeviceTestLine::checkFilledAsymmetricalDropShape(aBitmap
);
1130 exportImage(u
"19-01_filled_drop_shape-polygon.png"_ustr
, aBitmap
);
1132 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1135 // Test SalGraphics::blendBitmap() and blendAlphaBitmap() calls.
1136 void testDrawBlendExtended()
1138 if (getDefaultDeviceBitCount() < 24)
1140 // Create virtual device with alpha.
1141 ScopedVclPtr
<VirtualDevice
> device
1142 = VclPtr
<VirtualDevice
>::Create(DeviceFormat::WITH_ALPHA
);
1144 // TODO: This unit test is not executed for macOS unless bitmap scaling is implemented
1145 if (getRenderBackendName(device
) == "aqua")
1148 device
->SetOutputSizePixel(Size(10, 10));
1149 device
->SetBackground(Wallpaper(COL_WHITE
));
1151 Bitmap
bitmap(Size(5, 5), vcl::PixelFormat::N24_BPP
);
1152 bitmap
.Erase(COL_BLUE
);
1153 // No alpha, this will actually call SalGraphics::DrawBitmap(), but still check
1154 // the alpha of the device is handled correctly.
1155 device
->DrawBitmapEx(Point(2, 2), BitmapEx(bitmap
));
1156 exportDevice(u
"blend_extended_01.png"_ustr
, device
);
1157 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(2, 2)));
1158 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(6, 6)));
1159 // Check pixels outside of the bitmap aren't affected.
1160 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(1, 1)));
1161 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(7, 7)));
1164 AlphaMask
alpha(Size(5, 5));
1165 alpha
.Erase(0); // opaque
1166 device
->DrawBitmapEx(Point(2, 2), BitmapEx(bitmap
, alpha
));
1167 exportDevice(u
"blend_extended_02.png"_ustr
, device
);
1168 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(2, 2)));
1169 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(6, 6)));
1172 alpha
.Erase(255); // transparent
1173 device
->DrawBitmapEx(Point(2, 2), BitmapEx(bitmap
, alpha
));
1174 exportDevice(u
"blend_extended_03.png"_ustr
, device
);
1175 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(2, 2)));
1176 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(6, 6)));
1178 // Skia optimizes bitmaps that have just been Erase()-ed, so explicitly
1179 // set some pixels in the alpha to avoid this and have an actual bitmap
1180 // as the alpha mask.
1182 alpha
.Erase(255); // transparent
1183 BitmapScopedWriteAccess
alphaWrite(alpha
);
1184 alphaWrite
->SetPixelIndex(0, 0, 255); // opaque
1186 device
->DrawBitmapEx(Point(2, 2), BitmapEx(bitmap
, alpha
));
1187 exportDevice(u
"blend_extended_04.png"_ustr
, device
);
1188 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(2, 2)));
1189 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(6, 6)));
1192 void testDrawAlphaBitmapMirrored()
1194 if (getDefaultDeviceBitCount() < 24)
1196 // Normal virtual device.
1197 ScopedVclPtr
<VirtualDevice
> device
1198 = VclPtr
<VirtualDevice
>::Create(DeviceFormat::WITHOUT_ALPHA
);
1200 // TODO: This unit test is not executed for macOS unless bitmap scaling is implemented
1201 if (getRenderBackendName(device
) == "aqua")
1204 // Virtual device with alpha.
1205 ScopedVclPtr
<VirtualDevice
> alphaDevice
1206 = VclPtr
<VirtualDevice
>::Create(DeviceFormat::WITH_ALPHA
);
1207 device
->SetOutputSizePixel(Size(20, 20));
1208 device
->SetBackground(Wallpaper(COL_BLACK
));
1210 alphaDevice
->SetOutputSizePixel(Size(20, 20));
1211 alphaDevice
->SetBackground(Wallpaper(COL_BLACK
));
1212 alphaDevice
->Erase();
1213 Bitmap
bitmap(Size(4, 4), vcl::PixelFormat::N24_BPP
);
1214 AlphaMask
alpha(Size(4, 4));
1215 bitmap
.Erase(COL_LIGHTBLUE
);
1217 BitmapScopedWriteAccess
writeAccess(bitmap
);
1218 writeAccess
->SetPixel(3, 3, COL_LIGHTRED
);
1220 // alpha 127 will make COL_LIGHTRED -> COL_RED and the same for blue
1223 device
->DrawBitmapEx(Point(5, 5), Size(-4, -4), BitmapEx(bitmap
));
1224 device
->DrawBitmapEx(Point(15, 15), Size(4, 4), BitmapEx(bitmap
));
1225 exportDevice(u
"draw_alpha_bitmap_mirrored_01.png"_ustr
, device
);
1226 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED
, device
->GetPixel(Point(18, 18)));
1227 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE
, device
->GetPixel(Point(17, 18)));
1228 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED
, device
->GetPixel(Point(2, 2)));
1229 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE
, device
->GetPixel(Point(3, 2)));
1231 device
->DrawBitmapEx(Point(5, 5), Size(-4, -4), BitmapEx(bitmap
, alpha
));
1232 device
->DrawBitmapEx(Point(15, 15), Size(4, 4), BitmapEx(bitmap
, alpha
));
1233 exportDevice(u
"draw_alpha_bitmap_mirrored_02.png"_ustr
, device
);
1234 CPPUNIT_ASSERT_EQUAL(COL_RED
, device
->GetPixel(Point(18, 18)));
1235 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(17, 18)));
1236 CPPUNIT_ASSERT_EQUAL(COL_RED
, device
->GetPixel(Point(2, 2)));
1237 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(3, 2)));
1239 // Now with alpha device.
1240 alphaDevice
->DrawBitmapEx(Point(5, 5), Size(-4, -4), BitmapEx(bitmap
));
1241 alphaDevice
->DrawBitmapEx(Point(15, 15), Size(4, 4), BitmapEx(bitmap
));
1242 exportDevice(u
"draw_alpha_bitmap_mirrored_03.png"_ustr
, alphaDevice
);
1243 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED
, alphaDevice
->GetPixel(Point(18, 18)));
1244 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE
, alphaDevice
->GetPixel(Point(17, 18)));
1245 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED
, alphaDevice
->GetPixel(Point(2, 2)));
1246 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE
, alphaDevice
->GetPixel(Point(3, 2)));
1247 alphaDevice
->Erase();
1248 alphaDevice
->DrawBitmapEx(Point(5, 5), Size(-4, -4), BitmapEx(bitmap
, alpha
));
1249 alphaDevice
->DrawBitmapEx(Point(15, 15), Size(4, 4), BitmapEx(bitmap
, alpha
));
1250 exportDevice(u
"draw_alpha_bitmap_mirrored_04.png"_ustr
, alphaDevice
);
1251 CPPUNIT_ASSERT_EQUAL(COL_RED
, alphaDevice
->GetPixel(Point(18, 18)));
1252 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, alphaDevice
->GetPixel(Point(17, 18)));
1253 CPPUNIT_ASSERT_EQUAL(COL_RED
, alphaDevice
->GetPixel(Point(2, 2)));
1254 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, alphaDevice
->GetPixel(Point(3, 2)));
1255 alphaDevice
->Erase();
1258 void testDrawingText()
1261 vcl::test::OutputDeviceTestText aOutDevTest
;
1262 Bitmap aBitmap
= aOutDevTest
.setupTextBitmap();
1263 auto eResult
= vcl::test::OutputDeviceTestCommon::checkTextLocation(aBitmap
);
1264 exportImage(u
"17-01_test_text_Drawing.png"_ustr
, aBitmap
);
1266 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1270 void testEvenOddRuleInIntersectionRectangles()
1272 vcl::test::OutputDeviceTestPolyPolygon aOutDevTest
;
1273 Bitmap aBitmap
= aOutDevTest
.setupIntersectingRectangles();
1275 = vcl::test::OutputDeviceTestCommon::checkEvenOddRuleInIntersectingRecs(aBitmap
);
1276 exportImage(u
"18-01_test_Even-Odd-rule_intersecting_Recs.png"_ustr
, aBitmap
);
1278 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1281 void testDrawOpenPolygonWithPolyLine()
1283 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
1284 Bitmap aBitmap
= aOutDevTest
.setupOpenPolygon();
1285 auto eResult
= vcl::test::OutputDeviceTestCommon::checkOpenPolygon(aBitmap
);
1286 exportImage(u
"19-01_open_polygon-polyline.png"_ustr
, aBitmap
);
1288 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1291 void testDrawOpenPolygonWithPolyLineB2D()
1293 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest
;
1294 Bitmap aBitmap
= aOutDevTest
.setupOpenPolygon();
1295 auto eResult
= vcl::test::OutputDeviceTestCommon::checkOpenPolygon(aBitmap
);
1296 exportImage(u
"19-02_open_polygon-polyline_b2d.png"_ustr
, aBitmap
);
1298 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1301 void testDrawOpenPolygonWithPolygon()
1303 vcl::test::OutputDeviceTestPolygon aOutDevTest
;
1304 Bitmap aBitmap
= aOutDevTest
.setupOpenPolygon();
1305 auto eResult
= vcl::test::OutputDeviceTestCommon::checkOpenPolygon(aBitmap
);
1306 exportImage(u
"19-03_open_polygon-polygon.png"_ustr
, aBitmap
);
1308 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1311 void testDrawOpenPolygonWithPolyPolygon()
1313 vcl::test::OutputDeviceTestPolyPolygon aOutDevTest
;
1314 Bitmap aBitmap
= aOutDevTest
.setupOpenPolygon();
1315 auto eResult
= vcl::test::OutputDeviceTestCommon::checkOpenPolygon(aBitmap
);
1316 exportImage(u
"19-04_open_polygon-polypolygon.png"_ustr
, aBitmap
);
1318 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1321 void testDrawOpenPolygonWithPolyPolygonB2D()
1323 vcl::test::OutputDeviceTestPolyPolygonB2D aOutDevTest
;
1324 Bitmap aBitmap
= aOutDevTest
.setupOpenPolygon();
1325 auto eResult
= vcl::test::OutputDeviceTestCommon::checkOpenPolygon(aBitmap
);
1326 exportImage(u
"19-04_open_polygon-polypolygon_b2d.png"_ustr
, aBitmap
);
1328 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1331 void testDrawOpenBezierWithPolyLine()
1333 vcl::test::OutputDeviceTestPolyLine aOutDevTest
;
1334 Bitmap aBitmap
= aOutDevTest
.setupOpenBezier();
1335 auto eResult
= vcl::test::OutputDeviceTestCommon::checkOpenBezier(aBitmap
);
1336 exportImage(u
"19-01_open_bezier-polyline.png"_ustr
, aBitmap
);
1338 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1341 void testDrawOpenBezierWithPolyLineB2D()
1343 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest
;
1344 Bitmap aBitmap
= aOutDevTest
.setupOpenBezier();
1345 auto eResult
= vcl::test::OutputDeviceTestCommon::checkOpenBezier(aBitmap
);
1346 exportImage(u
"19-01_open_bezier-polyline_b2d.png"_ustr
, aBitmap
);
1348 CPPUNIT_ASSERT(eResult
!= vcl::test::TestResult::Failed
);
1351 void testTdf124848()
1353 ScopedVclPtr
<VirtualDevice
> device
1354 = VclPtr
<VirtualDevice
>::Create(DeviceFormat::WITHOUT_ALPHA
);
1356 // TODO: This unit test is not executed for macOS unless bitmap scaling is implemented
1357 if (getRenderBackendName(device
) == "aqua")
1360 device
->SetOutputSizePixel(Size(100, 100));
1361 device
->SetBackground(Wallpaper(COL_WHITE
));
1363 device
->SetAntialiasing(AntialiasingFlags::Enable
);
1364 device
->SetLineColor(COL_BLACK
);
1365 basegfx::B2DHomMatrix matrix
;
1366 // DrawPolyLine() would apply the whole matrix to the line width, making it negative
1367 // in case of a larger rotation.
1368 matrix
.rotate(M_PI
); //180 degrees
1369 matrix
.translate(100, 100);
1370 CPPUNIT_ASSERT(device
->DrawPolyLineDirect(matrix
,
1371 basegfx::B2DPolygon
{ { 50, 50 }, { 50, 100 } },
1372 100, 0, nullptr, basegfx::B2DLineJoin::Miter
));
1373 exportDevice(u
"tdf124848-1.png"_ustr
, device
);
1374 // 100px wide line should fill the entire width of the upper half
1375 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, device
->GetPixel(Point(2, 2)));
1377 // Also check hairline.
1379 CPPUNIT_ASSERT(device
->DrawPolyLineDirect(matrix
,
1380 basegfx::B2DPolygon
{ { 50, 50 }, { 50, 100 } }, 0,
1381 0, nullptr, basegfx::B2DLineJoin::Miter
));
1382 exportDevice(u
"tdf124848-2.png"_ustr
, device
);
1384 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, device
->GetPixel(Point(50, 20)));
1385 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(49, 20)));
1386 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, device
->GetPixel(Point(51, 20)));
1389 void testTdf136171()
1391 if (getDefaultDeviceBitCount() < 24)
1393 // Create virtual device with alpha.
1394 ScopedVclPtr
<VirtualDevice
> device
1395 = VclPtr
<VirtualDevice
>::Create(DeviceFormat::WITH_ALPHA
);
1396 device
->SetOutputSizePixel(Size(10, 10));
1397 device
->SetBackground(Wallpaper(COL_WHITE
));
1399 Bitmap
bitmap(Size(10, 10), vcl::PixelFormat::N24_BPP
);
1400 bitmap
.Erase(COL_BLUE
);
1401 basegfx::B2DHomMatrix matrix
;
1402 matrix
.scale(bitmap
.GetSizePixel().Width(),
1403 bitmap
.GetSizePixel().Height()); // draw as 10x10
1404 // Draw a blue bitmap to the device. The bug was that there was no alpha, but OutputDevice::DrawTransformBitmapExDirect()
1405 // supplied a fully opaque alpha done with Erase() on the alpha bitmap, and Skia backend didn't handle such alpha correctly.
1406 device
->DrawTransformedBitmapEx(matrix
, BitmapEx(bitmap
));
1407 exportDevice(u
"tdf136171.png"_ustr
, device
);
1408 // The whole virtual device content now should be blue.
1409 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(0, 0)));
1410 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(9, 0)));
1411 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(0, 9)));
1412 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(9, 9)));
1413 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device
->GetPixel(Point(4, 4)));
1416 void testTdf145811()
1418 // VCL may call copyArea()/copyBits() of backends even with coordinates partially
1419 // outside of the device, so try various copying like that.
1420 ScopedVclPtr
<VirtualDevice
> device1
1421 = VclPtr
<VirtualDevice
>::Create(DeviceFormat::WITHOUT_ALPHA
);
1422 device1
->SetOutputSizePixel(Size(100, 100));
1423 device1
->SetBackground(Wallpaper(COL_YELLOW
));
1425 device1
->SetLineColor(COL_BLUE
);
1426 device1
->DrawPixel(Point(0, 0), COL_BLUE
);
1427 device1
->DrawPixel(Point(99, 99), COL_BLUE
);
1429 // TODO: This unit test is not executed for macOS unless bitmap scaling is implemented
1430 if (getRenderBackendName(device1
) == "aqua")
1434 // Plain 1:1 copy device1->device2.
1435 ScopedVclPtr
<VirtualDevice
> device2
1436 = VclPtr
<VirtualDevice
>::Create(DeviceFormat::WITHOUT_ALPHA
);
1437 device2
->SetOutputSizePixel(Size(100, 100));
1438 device2
->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1
);
1439 exportDevice(u
"tdf145811-1.png"_ustr
, device2
);
1440 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(0, 0)));
1441 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(1, 1)));
1442 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(98, 98)));
1443 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(99, 99)));
1445 // For the rest call directly SalGraphics, because OutputDevice does range checking,
1446 // but other code may call copyArea()/copyBits() of SalGraphics directly without range checking.
1447 SalGraphics
* graphics1
= device1
->GetGraphics();
1448 SalGraphics
* graphics2
= device2
->GetGraphics();
1450 device2
->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1
);
1451 // Copy device1->device2 offset by 10,10.
1452 graphics2
->CopyBits(SalTwoRect(0, 0, 100, 100, 10, 10, 100, 100), *graphics1
, *device2
,
1454 exportDevice(u
"tdf145811-2.png"_ustr
, device2
);
1455 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(0, 0))); // unmodified
1456 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(9, 9)));
1457 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(10, 10)));
1458 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(11, 11)));
1459 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(99, 99)));
1461 device2
->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1
);
1462 // Copy area of device2 offset by 10,10.
1463 graphics2
->CopyArea(10, 10, 0, 0, 100, 100, *device1
);
1464 exportDevice(u
"tdf145811-3.png"_ustr
, device2
);
1465 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(0, 0))); // unmodified
1466 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(9, 9)));
1467 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(10, 10)));
1468 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(11, 11)));
1469 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(99, 99)));
1471 device2
->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1
);
1472 // Copy device1->device2 offset by -20,-20.
1473 graphics2
->CopyBits(SalTwoRect(0, 0, 100, 100, -20, -20, 100, 100), *graphics1
, *device2
,
1475 exportDevice(u
"tdf145811-4.png"_ustr
, device2
);
1476 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(0, 0)));
1477 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(78, 78)));
1478 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(79, 79)));
1479 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(80, 80)));
1480 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(99, 99))); // unmodified
1482 device2
->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1
);
1483 // Copy area of device2 offset by -20,-20.
1484 graphics2
->CopyArea(-20, -20, 0, 0, 100, 100, *device1
);
1485 exportDevice(u
"tdf145811-5.png"_ustr
, device2
);
1486 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(0, 0)));
1487 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(78, 78)));
1488 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(79, 79)));
1489 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(80, 80)));
1490 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(99, 99))); // unmodified
1492 device2
->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1
);
1493 // Copy device1->device2 offset by -10,-10 starting from -20,-20 at 150x150 size
1494 // (i.e. outside in all directions).
1495 graphics2
->CopyBits(SalTwoRect(-20, -20, 150, 150, -30, -30, 150, 150), *graphics1
,
1496 *device2
, *device1
);
1497 exportDevice(u
"tdf145811-6.png"_ustr
, device2
);
1498 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(0, 0)));
1499 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(88, 88)));
1500 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(89, 89)));
1501 // (90,90) and further originate from outside and may be garbage.
1503 device2
->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1
);
1504 // Copy area of device2 offset by -10,-10 starting from -20,-20 at 150x150 size
1505 // (i.e. outside in all directions).
1506 graphics2
->CopyArea(-30, -30, -20, -20, 150, 150, *device1
);
1507 exportDevice(u
"tdf145811-7.png"_ustr
, device2
);
1508 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(0, 0)));
1509 CPPUNIT_ASSERT_EQUAL(COL_YELLOW
, device2
->GetPixel(Point(88, 88)));
1510 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, device2
->GetPixel(Point(89, 89)));
1511 // (90,90) and further originate from outside and may be garbage.
1514 CPPUNIT_TEST_SUITE(BackendTest
);
1515 CPPUNIT_TEST(testDrawRectWithRectangle
);
1516 CPPUNIT_TEST(testDrawRectWithPixel
);
1517 CPPUNIT_TEST(testDrawRectWithLine
);
1518 CPPUNIT_TEST(testDrawRectWithPolygon
);
1519 CPPUNIT_TEST(testDrawRectWithPolyLine
);
1520 CPPUNIT_TEST(testDrawRectWithPolyLineB2D
);
1521 CPPUNIT_TEST(testDrawRectWithPolyPolygon
);
1522 CPPUNIT_TEST(testDrawRectWithPolyPolygonB2D
);
1524 CPPUNIT_TEST(testDrawRectAAWithRectangle
);
1525 CPPUNIT_TEST(testDrawRectAAWithPixel
);
1526 CPPUNIT_TEST(testDrawRectAAWithLine
);
1527 CPPUNIT_TEST(testDrawRectAAWithPolygon
);
1528 CPPUNIT_TEST(testDrawRectAAWithPolyLine
);
1529 CPPUNIT_TEST(testDrawRectAAWithPolyLineB2D
);
1530 CPPUNIT_TEST(testDrawRectAAWithPolyPolygon
);
1531 CPPUNIT_TEST(testDrawRectAAWithPolyPolygonB2D
);
1533 CPPUNIT_TEST(testDrawFilledRectWithRectangle
);
1534 CPPUNIT_TEST(testDrawFilledRectWithPolygon
);
1535 CPPUNIT_TEST(testDrawFilledRectWithPolyPolygon
);
1536 CPPUNIT_TEST(testDrawFilledRectWithPolyPolygon2D
);
1538 CPPUNIT_TEST(testDrawDiamondWithPolygon
);
1539 CPPUNIT_TEST(testDrawDiamondWithLine
);
1540 CPPUNIT_TEST(testDrawDiamondWithPolyline
);
1541 CPPUNIT_TEST(testDrawDiamondWithPolylineB2D
);
1543 CPPUNIT_TEST(testDrawInvertWithRectangle
);
1544 CPPUNIT_TEST(testDrawInvertN50WithRectangle
);
1545 CPPUNIT_TEST(testDrawInvertTrackFrameWithRectangle
);
1547 CPPUNIT_TEST(testDrawBezierWithPolylineB2D
);
1548 CPPUNIT_TEST(testDrawBezierAAWithPolylineB2D
);
1550 CPPUNIT_TEST(testDrawDropShapeWithPolyline
);
1551 CPPUNIT_TEST(testDrawDropShapeAAWithPolyline
);
1553 CPPUNIT_TEST(testDrawDropShapeWithPolygon
);
1554 CPPUNIT_TEST(testDrawDropShapeAAWithPolygon
);
1556 CPPUNIT_TEST(testDrawHaflEllipseWithPolyLine
);
1557 CPPUNIT_TEST(testDrawHaflEllipseAAWithPolyLine
);
1558 CPPUNIT_TEST(testDrawHaflEllipseWithPolyLineB2D
);
1559 CPPUNIT_TEST(testDrawHaflEllipseAAWithPolyLineB2D
);
1560 CPPUNIT_TEST(testDrawHaflEllipseWithPolygon
);
1561 CPPUNIT_TEST(testDrawHaflEllipseAAWithPolygon
);
1563 CPPUNIT_TEST(testClosedBezierWithPolyline
);
1564 CPPUNIT_TEST(testClosedBezierWithPolygon
);
1566 CPPUNIT_TEST(testFilledAsymmetricalDropShape
);
1568 CPPUNIT_TEST(testDrawBitmap24bpp
);
1569 CPPUNIT_TEST(testDrawTransformedBitmap24bpp
);
1570 CPPUNIT_TEST(testComplexDrawTransformedBitmap24bpp
);
1571 CPPUNIT_TEST(testDrawBitmapExWithAlpha24bpp
);
1572 CPPUNIT_TEST(testDrawMask24bpp
);
1573 CPPUNIT_TEST(testDrawBlend24bpp
);
1575 CPPUNIT_TEST(testDrawXor
);
1577 CPPUNIT_TEST(testDrawBitmap32bpp
);
1578 CPPUNIT_TEST(testDrawTransformedBitmap32bpp
);
1579 CPPUNIT_TEST(testDrawBitmapExWithAlpha32bpp
);
1580 CPPUNIT_TEST(testDrawMask32bpp
);
1581 CPPUNIT_TEST(testDrawBlend32bpp
);
1583 CPPUNIT_TEST(testDrawTransformedBitmap8bppGreyScale
);
1584 CPPUNIT_TEST(testDrawBitmap8bppGreyScale
);
1586 CPPUNIT_TEST(testDrawTransformedBitmapExAlpha
);
1588 CPPUNIT_TEST(testClipRectangle
);
1589 CPPUNIT_TEST(testClipPolygon
);
1590 CPPUNIT_TEST(testClipPolyPolygon
);
1591 CPPUNIT_TEST(testClipB2DPolyPolygon
);
1593 CPPUNIT_TEST(testDrawOutDev
);
1594 CPPUNIT_TEST(testDrawOutDevScaledClipped
);
1595 CPPUNIT_TEST(testDrawOutDevSelf
);
1597 CPPUNIT_TEST(testDashedLine
);
1599 CPPUNIT_TEST(testErase
);
1601 CPPUNIT_TEST(testLinearGradient
);
1602 CPPUNIT_TEST(testLinearGradientAngled
);
1603 CPPUNIT_TEST(testLinearGradientBorder
);
1604 CPPUNIT_TEST(testLinearGradientIntensity
);
1605 CPPUNIT_TEST(testLinearGradientSteps
);
1606 CPPUNIT_TEST(testAxialGradient
);
1607 CPPUNIT_TEST(testRadialGradient
);
1608 CPPUNIT_TEST(testRadialGradientOfs
);
1610 CPPUNIT_TEST(testLineCapRound
);
1611 CPPUNIT_TEST(testLineCapSquare
);
1612 CPPUNIT_TEST(testLineCapButt
);
1613 CPPUNIT_TEST(testLineJoinBevel
);
1614 CPPUNIT_TEST(testLineJoinRound
);
1615 CPPUNIT_TEST(testLineJoinMiter
);
1616 CPPUNIT_TEST(testLineJoinNone
);
1618 CPPUNIT_TEST(testDrawBlendExtended
);
1619 CPPUNIT_TEST(testDrawAlphaBitmapMirrored
);
1621 CPPUNIT_TEST(testDrawingText
);
1622 CPPUNIT_TEST(testEvenOddRuleInIntersectionRectangles
);
1624 CPPUNIT_TEST(testDrawOpenPolygonWithPolyLine
);
1625 CPPUNIT_TEST(testDrawOpenPolygonWithPolyLineB2D
);
1626 CPPUNIT_TEST(testDrawOpenPolygonWithPolygon
);
1627 CPPUNIT_TEST(testDrawOpenPolygonWithPolyPolygon
);
1628 CPPUNIT_TEST(testDrawOpenPolygonWithPolyPolygonB2D
);
1630 CPPUNIT_TEST(testDrawOpenBezierWithPolyLine
);
1631 CPPUNIT_TEST(testDrawOpenBezierWithPolyLineB2D
);
1633 CPPUNIT_TEST(testTdf124848
);
1634 CPPUNIT_TEST(testTdf136171
);
1635 CPPUNIT_TEST(testTdf145811
);
1637 CPPUNIT_TEST_SUITE_END();
1640 CPPUNIT_TEST_SUITE_REGISTRATION(BackendTest
);
1642 CPPUNIT_PLUGIN_IMPLEMENT();
1644 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */