calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / qa / cppunit / BackendTest.cxx
blob4aeec29147c9ba4d78f33676486d76de3f7b4af4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 */
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 <bitmap/BitmapWriteAccess.hxx>
19 #include <svdata.hxx>
20 #include <salinst.hxx>
21 #include <salgdi.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)
34 if (mbExportBitmap)
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)
45 if (mbExportBitmap)
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)
56 if (mbExportBitmap)
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(); }
66 public:
67 BackendTest()
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());
81 (void)name;
82 return true;
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() != "qt5" \
94 && aOutDevTest.getRenderBackendName() != "qt5svp" \
95 && aOutDevTest.getRenderBackendName() != "gtk3svp" \
96 && aOutDevTest.getRenderBackendName() != "aqua" \
97 && aOutDevTest.getRenderBackendName() != "gen" \
98 && aOutDevTest.getRenderBackendName() != "genpsp" \
99 && aOutDevTest.getRenderBackendName() != "win")
101 #ifdef MACOSX
102 static OUString getRenderBackendName(OutputDevice* device)
104 assert(device);
105 return device->GetGraphics()->getRenderBackendName();
107 #endif
109 void testDrawRectWithRectangle()
111 if (getDefaultDeviceBitCount() < 24)
112 return;
113 vcl::test::OutputDeviceTestRect aOutDevTest;
114 Bitmap aBitmap = aOutDevTest.setupRectangle(false);
115 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap);
116 exportImage("01-01_rectangle_test-rectangle.png", aBitmap);
118 if (SHOULD_ASSERT)
119 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
122 void testDrawRectWithPixel()
124 if (getDefaultDeviceBitCount() < 24)
125 return;
126 vcl::test::OutputDeviceTestPixel aOutDevTest;
127 Bitmap aBitmap = aOutDevTest.setupRectangle(false);
128 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap);
129 exportImage("01-02_rectangle_test-pixel.png", aBitmap);
131 if (SHOULD_ASSERT)
132 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
135 void testDrawRectWithLine()
137 if (getDefaultDeviceBitCount() < 24)
138 return;
139 vcl::test::OutputDeviceTestLine aOutDevTest;
140 Bitmap aBitmap = aOutDevTest.setupRectangle(false);
141 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap);
142 exportImage("01-03_rectangle_test-line.png", aBitmap);
144 if (SHOULD_ASSERT)
145 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
148 void testDrawRectWithPolygon()
150 if (getDefaultDeviceBitCount() < 24)
151 return;
152 vcl::test::OutputDeviceTestPolygon aOutDevTest;
153 Bitmap aBitmap = aOutDevTest.setupRectangle(false);
154 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap);
155 exportImage("01-04_rectangle_test-polygon.png", aBitmap);
156 if (SHOULD_ASSERT)
157 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
160 void testDrawRectWithPolyLine()
162 if (getDefaultDeviceBitCount() < 24)
163 return;
164 vcl::test::OutputDeviceTestPolyLine aOutDevTest;
165 Bitmap aBitmap = aOutDevTest.setupRectangle(false);
166 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap);
167 exportImage("01-05_rectangle_test-polyline.png", aBitmap);
168 if (SHOULD_ASSERT)
169 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
172 void testDrawRectWithPolyLineB2D()
174 if (getDefaultDeviceBitCount() < 24)
175 return;
176 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest;
177 Bitmap aBitmap = aOutDevTest.setupRectangle(false);
178 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap);
179 exportImage("01-06_rectangle_test-polyline_b2d.png", aBitmap);
180 if (SHOULD_ASSERT)
181 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
184 void testDrawRectWithPolyPolygon()
186 if (getDefaultDeviceBitCount() < 24)
187 return;
188 vcl::test::OutputDeviceTestPolyPolygon aOutDevTest;
189 Bitmap aBitmap = aOutDevTest.setupRectangle(false);
190 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap);
191 exportImage("01-07_rectangle_test-polypolygon.png", aBitmap);
192 if (SHOULD_ASSERT)
193 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
196 void testDrawRectWithPolyPolygonB2D()
198 if (getDefaultDeviceBitCount() < 24)
199 return;
200 vcl::test::OutputDeviceTestPolyPolygonB2D aOutDevTest;
201 Bitmap aBitmap = aOutDevTest.setupRectangle(false);
202 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangles(aBitmap);
203 exportImage("01-08_rectangle_test-polypolygon_b2d.png", aBitmap);
204 if (SHOULD_ASSERT)
205 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
208 void testDrawRectAAWithRectangle()
210 if (getDefaultDeviceBitCount() < 24)
211 return;
212 vcl::test::OutputDeviceTestRect aOutDevTest;
213 Bitmap aBitmap = aOutDevTest.setupRectangle(true);
214 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap);
215 exportImage("02-01_rectangle_AA_test-rectangle.png", aBitmap);
216 if (SHOULD_ASSERT)
217 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
220 void testDrawRectAAWithPixel()
222 if (getDefaultDeviceBitCount() < 24)
223 return;
224 vcl::test::OutputDeviceTestPixel aOutDevTest;
225 Bitmap aBitmap = aOutDevTest.setupRectangle(true);
226 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap);
227 exportImage("02-02_rectangle_AA_test-pixel.png", aBitmap);
228 if (SHOULD_ASSERT)
229 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
232 void testDrawRectAAWithLine()
234 if (getDefaultDeviceBitCount() < 24)
235 return;
236 vcl::test::OutputDeviceTestLine aOutDevTest;
237 Bitmap aBitmap = aOutDevTest.setupRectangle(true);
238 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap);
239 exportImage("02-03_rectangle_AA_test-line.png", aBitmap);
240 if (SHOULD_ASSERT)
241 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
244 void testDrawRectAAWithPolygon()
246 if (getDefaultDeviceBitCount() < 24)
247 return;
248 vcl::test::OutputDeviceTestPolygon aOutDevTest;
249 Bitmap aBitmap = aOutDevTest.setupRectangle(true);
250 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap);
251 exportImage("02-04_rectangle_AA_test-polygon.png", aBitmap);
252 if (SHOULD_ASSERT)
253 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
256 void testDrawRectAAWithPolyLine()
258 if (getDefaultDeviceBitCount() < 24)
259 return;
260 vcl::test::OutputDeviceTestPolyLine aOutDevTest;
261 Bitmap aBitmap = aOutDevTest.setupRectangle(true);
262 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap);
263 exportImage("02-05_rectangle_AA_test-polyline.png", aBitmap);
264 if (SHOULD_ASSERT)
265 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
268 void testDrawRectAAWithPolyLineB2D()
270 if (getDefaultDeviceBitCount() < 24)
271 return;
272 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest;
273 Bitmap aBitmap = aOutDevTest.setupRectangle(true);
274 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap);
275 exportImage("02-06_rectangle_AA_test-polyline_b2d.png", aBitmap);
276 if (SHOULD_ASSERT)
277 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
280 void testDrawRectAAWithPolyPolygon()
282 if (getDefaultDeviceBitCount() < 24)
283 return;
284 vcl::test::OutputDeviceTestPolyPolygon aOutDevTest;
285 Bitmap aBitmap = aOutDevTest.setupRectangle(true);
286 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap);
287 exportImage("02-07_rectangle_AA_test-polypolygon.png", aBitmap);
288 if (SHOULD_ASSERT)
289 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
292 void testDrawRectAAWithPolyPolygonB2D()
294 if (getDefaultDeviceBitCount() < 24)
295 return;
296 vcl::test::OutputDeviceTestPolyPolygonB2D aOutDevTest;
297 Bitmap aBitmap = aOutDevTest.setupRectangle(true);
298 auto eResult = vcl::test::OutputDeviceTestCommon::checkRectangleAA(aBitmap);
299 exportImage("02-08_rectangle_AA_test-polypolygon_b2d.png", aBitmap);
300 if (SHOULD_ASSERT)
301 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
304 void testDrawFilledRectWithRectangle()
306 if (getDefaultDeviceBitCount() < 24)
307 return;
308 vcl::test::OutputDeviceTestRect aOutDevTest;
309 Bitmap aBitmap = aOutDevTest.setupFilledRectangle(false);
310 auto eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, false);
311 exportImage("03-01_filled_rectangle_test-rectangle_noline.png", aBitmap);
312 if (SHOULD_ASSERT)
313 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
314 aBitmap = aOutDevTest.setupFilledRectangle(true);
315 eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, true);
316 exportImage("03-01_filled_rectangle_test-rectangle_line.png", aBitmap);
317 if (SHOULD_ASSERT)
318 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
321 void testDrawFilledRectWithPolygon()
323 if (getDefaultDeviceBitCount() < 24)
324 return;
325 vcl::test::OutputDeviceTestPolygon aOutDevTest;
326 Bitmap aBitmap = aOutDevTest.setupFilledRectangle(false);
327 auto eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, false);
328 exportImage("03-02_filled_rectangle_test-polygon_noline.png", aBitmap);
329 if (SHOULD_ASSERT)
330 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
331 aBitmap = aOutDevTest.setupFilledRectangle(true);
332 eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, true);
333 exportImage("03-02_filled_rectangle_test-polygon_line.png", aBitmap);
334 if (SHOULD_ASSERT)
335 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
338 void testDrawFilledRectWithPolyPolygon()
340 if (getDefaultDeviceBitCount() < 24)
341 return;
342 vcl::test::OutputDeviceTestPolyPolygon aOutDevTest;
343 Bitmap aBitmap = aOutDevTest.setupFilledRectangle(false);
344 auto eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, false);
345 exportImage("03-03_filled_rectangle_test-polypolygon_noline.png", aBitmap);
346 if (SHOULD_ASSERT)
347 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
348 aBitmap = aOutDevTest.setupFilledRectangle(true);
349 eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, true);
350 exportImage("03-03_filled_rectangle_test-polypolygon_line.png", aBitmap);
351 if (SHOULD_ASSERT)
352 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
355 void testDrawFilledRectWithPolyPolygon2D()
357 if (getDefaultDeviceBitCount() < 24)
358 return;
359 vcl::test::OutputDeviceTestPolyPolygonB2D aOutDevTest;
360 Bitmap aBitmap = aOutDevTest.setupFilledRectangle(false);
361 auto eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, false);
362 exportImage("03-04_filled_rectangle_test-polypolygon_b2d_noline.png", aBitmap);
363 if (SHOULD_ASSERT)
364 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
365 aBitmap = aOutDevTest.setupFilledRectangle(true);
366 eResult = vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, true);
367 exportImage("03-04_filled_rectangle_test-polypolygon_b2d_line.png", aBitmap);
368 if (SHOULD_ASSERT)
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("04-01_diamond_test-polygon.png", aBitmap);
378 if (SHOULD_ASSERT)
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("04-02_diamond_test-line.png", aBitmap);
388 if (SHOULD_ASSERT)
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("04-03_diamond_test-polyline.png", aBitmap);
398 if (SHOULD_ASSERT)
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("04-04_diamond_test-polyline_b2d.png", aBitmap);
408 if (SHOULD_ASSERT)
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("05-01_invert_test-rectangle.png", aBitmap);
418 if (SHOULD_ASSERT)
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("05-02_invert_N50_test-rectangle.png", 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("05-03_invert_TrackFrame_test-rectangle.png", aBitmap);
438 if (SHOULD_ASSERT && aOutDevTest.getRenderBackendName() != "svp")
439 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
442 void testDrawBezierWithPolylineB2D()
444 if (getDefaultDeviceBitCount() < 24)
445 return;
446 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest;
447 Bitmap aBitmap = aOutDevTest.setupBezier();
448 auto eResult = vcl::test::OutputDeviceTestCommon::checkBezier(aBitmap);
449 exportImage("06-01_bezier_test-polyline_b2d.png", aBitmap);
450 if (SHOULD_ASSERT)
451 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
454 void testDrawBezierAAWithPolylineB2D()
456 if (getDefaultDeviceBitCount() < 24)
457 return;
458 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest;
459 Bitmap aBitmap = aOutDevTest.setupAABezier();
460 auto eResult = vcl::test::OutputDeviceTestCommon::checkBezier(aBitmap);
461 exportImage("07-01_bezier_AA_test-polyline_b2d.png", aBitmap);
462 if (SHOULD_ASSERT)
463 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
466 void testDrawBitmap24bpp()
468 if (getDefaultDeviceBitCount() < 24)
469 return;
470 vcl::test::OutputDeviceTestBitmap aOutDevTest;
471 Bitmap aBitmap = aOutDevTest.setupDrawBitmap(vcl::PixelFormat::N24_BPP);
472 exportImage("08-01_bitmap_test_24bpp.png", aBitmap);
473 auto eResult = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap);
474 if (SHOULD_ASSERT)
475 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
478 void testDrawTransformedBitmap24bpp()
480 if (getDefaultDeviceBitCount() < 24)
481 return;
482 vcl::test::OutputDeviceTestBitmap aOutDevTest;
483 Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap(vcl::PixelFormat::N24_BPP);
484 auto eResult = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap);
485 exportImage("08-02_transformed_bitmap_test_24bpp.png", aBitmap);
486 if (SHOULD_ASSERT)
487 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
490 void testComplexDrawTransformedBitmap24bpp()
492 if (getDefaultDeviceBitCount() < 24)
493 return;
494 vcl::test::OutputDeviceTestBitmap aOutDevTest;
495 Bitmap aBitmap = aOutDevTest.setupComplexDrawTransformedBitmap(vcl::PixelFormat::N24_BPP);
496 auto eResult = vcl::test::OutputDeviceTestBitmap::checkComplexTransformedBitmap(aBitmap);
497 exportImage("08-03_transformed_bitmap_test_24bpp.png", aBitmap);
498 if (SHOULD_ASSERT)
499 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
502 void testDrawBitmapExWithAlpha24bpp()
504 if (getDefaultDeviceBitCount() < 24)
505 return;
506 vcl::test::OutputDeviceTestBitmap aOutDevTest;
507 Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha(vcl::PixelFormat::N24_BPP);
508 auto eResult = vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap);
509 exportImage("08-04_bitmapex_with_alpha_test_24bpp.png", aBitmap);
510 if (SHOULD_ASSERT)
511 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
514 void testDrawMask24bpp()
516 if (getDefaultDeviceBitCount() < 24)
517 return;
518 vcl::test::OutputDeviceTestBitmap aOutDevTest;
519 Bitmap aBitmap = aOutDevTest.setupDrawMask(vcl::PixelFormat::N24_BPP);
520 auto eResult = vcl::test::OutputDeviceTestBitmap::checkMask(aBitmap);
521 exportImage("08-05_mask_test_24bpp.png", aBitmap);
522 if (SHOULD_ASSERT)
523 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
526 void testDrawBlend24bpp()
528 if (getDefaultDeviceBitCount() < 24)
529 return;
530 vcl::test::OutputDeviceTestBitmap aOutDevTest;
531 BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N24_BPP);
532 auto eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx);
533 exportImage("08-06_blend_test_24bpp.png", aBitmapEx);
534 if (SHOULD_ASSERT)
535 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
538 void testDrawBitmap32bpp()
540 if (getDefaultDeviceBitCount() < 24)
541 return;
542 vcl::test::OutputDeviceTestBitmap aOutDevTest;
543 Bitmap aBitmap = aOutDevTest.setupDrawBitmap(vcl::PixelFormat::N32_BPP);
544 exportImage("09-01_bitmap_test_32bpp.png", 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)
553 return;
554 vcl::test::OutputDeviceTestBitmap aOutDevTest;
555 Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap(vcl::PixelFormat::N32_BPP);
556 auto eResult = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap);
557 exportImage("09-02_transformed_bitmap_test_32bpp.png", aBitmap);
558 if (SHOULD_ASSERT && is32bppSupported())
559 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
562 void testDrawBitmapExWithAlpha32bpp()
564 if (getDefaultDeviceBitCount() < 24)
565 return;
566 vcl::test::OutputDeviceTestBitmap aOutDevTest;
567 Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha(vcl::PixelFormat::N32_BPP);
568 auto eResult = vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap);
569 exportImage("09-03_bitmapex_with_alpha_test_32bpp.png", aBitmap);
570 if (SHOULD_ASSERT && is32bppSupported())
571 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
574 void testDrawMask32bpp()
576 if (getDefaultDeviceBitCount() < 24)
577 return;
578 vcl::test::OutputDeviceTestBitmap aOutDevTest;
579 Bitmap aBitmap = aOutDevTest.setupDrawMask(vcl::PixelFormat::N32_BPP);
580 auto eResult = vcl::test::OutputDeviceTestBitmap::checkMask(aBitmap);
581 exportImage("09-04_mask_test_32bpp.png", aBitmap);
582 if (SHOULD_ASSERT && is32bppSupported())
583 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
586 void testDrawBlend32bpp()
588 if (getDefaultDeviceBitCount() < 24)
589 return;
590 vcl::test::OutputDeviceTestBitmap aOutDevTest;
591 BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N32_BPP);
592 auto eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx);
593 exportImage("09-05_blend_test_32bpp.png", aBitmapEx);
594 if (SHOULD_ASSERT && is32bppSupported())
595 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
598 void testDrawBitmap8bppGreyScale()
600 if (getDefaultDeviceBitCount() < 24)
601 return;
602 vcl::test::OutputDeviceTestBitmap aOutDevTest;
603 Bitmap aBitmap = aOutDevTest.setupDrawBitmap(vcl::PixelFormat::N8_BPP, true);
604 exportImage("010-01_bitmap_test_8bpp_greyscale.png", aBitmap);
605 auto eResult
606 = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap8bppGreyScale(aBitmap);
607 if (SHOULD_ASSERT)
608 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
611 void testDrawTransformedBitmap8bppGreyScale()
613 if (getDefaultDeviceBitCount() < 24)
614 return;
615 vcl::test::OutputDeviceTestBitmap aOutDevTest;
616 Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap(vcl::PixelFormat::N8_BPP, true);
617 auto eResult
618 = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap8bppGreyScale(aBitmap);
619 exportImage("010-02_transformed_bitmap_test_8bpp_greyscale.png", aBitmap);
620 if (SHOULD_ASSERT)
621 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
624 void testDrawXor()
626 if (getDefaultDeviceBitCount() < 24)
627 return;
628 vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest;
629 Bitmap aBitmap = aOutDevTest.setupXOR();
630 auto eResult = vcl::test::OutputDeviceTestAnotherOutDev::checkXOR(aBitmap);
631 exportImage("08-06_xor_test.png", aBitmap);
632 if (SHOULD_ASSERT)
633 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
636 void testDrawTransformedBitmapExAlpha()
638 if (getDefaultDeviceBitCount() < 24)
639 return;
640 ScopedVclPtrInstance<VirtualDevice> device;
641 #ifdef MACOSX
642 // TODO: This unit test is not executed for macOS unless bitmap scaling is implemented
643 if (getRenderBackendName(device) == "aqua")
644 return;
645 #endif
646 device->SetOutputSizePixel(Size(16, 16));
647 device->SetBackground(Wallpaper(COL_WHITE));
648 device->Erase();
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(Color(0x80, 0x80, 0x80), result.GetPixelColor(0, 0));
665 CPPUNIT_ASSERT_EQUAL(COL_WHITE, result.GetPixelColor(15, 15));
666 // Draw rotated and move to the bottom-left corner.
667 device->Erase();
668 aMatrix.identity();
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(Color(0x80, 0x80, 0x80), result.GetPixelColor(0, 15));
678 void testClipRectangle()
680 if (getDefaultDeviceBitCount() < 24)
681 return;
682 vcl::test::OutputDeviceTestClip aOutDevTest;
683 Bitmap aBitmap = aOutDevTest.setupClipRectangle();
684 auto eResult = vcl::test::OutputDeviceTestClip::checkClip(aBitmap);
685 exportImage("09-01_clip_rectangle_test.png", aBitmap);
686 if (SHOULD_ASSERT)
687 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
690 void testClipPolygon()
692 if (getDefaultDeviceBitCount() < 24)
693 return;
694 vcl::test::OutputDeviceTestClip aOutDevTest;
695 Bitmap aBitmap = aOutDevTest.setupClipPolygon();
696 auto eResult = vcl::test::OutputDeviceTestClip::checkClip(aBitmap);
697 exportImage("09-02_clip_polygon_test.png", aBitmap);
698 if (SHOULD_ASSERT)
699 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
702 void testClipPolyPolygon()
704 if (getDefaultDeviceBitCount() < 24)
705 return;
706 vcl::test::OutputDeviceTestClip aOutDevTest;
707 Bitmap aBitmap = aOutDevTest.setupClipPolyPolygon();
708 auto eResult = vcl::test::OutputDeviceTestClip::checkClip(aBitmap);
709 exportImage("09-03_clip_polypolygon_test.png", aBitmap);
710 if (SHOULD_ASSERT)
711 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
714 void testClipB2DPolyPolygon()
716 if (getDefaultDeviceBitCount() < 24)
717 return;
718 vcl::test::OutputDeviceTestClip aOutDevTest;
719 Bitmap aBitmap = aOutDevTest.setupClipB2DPolyPolygon();
720 auto eResult = vcl::test::OutputDeviceTestClip::checkClip(aBitmap);
721 exportImage("09-04_clip_b2dpolypolygon_test.png", aBitmap);
722 if (SHOULD_ASSERT)
723 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
726 void testDrawOutDev()
728 if (getDefaultDeviceBitCount() < 24)
729 return;
730 vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest;
731 Bitmap aBitmap = aOutDevTest.setupDrawOutDev();
732 auto eResult = vcl::test::OutputDeviceTestAnotherOutDev::checkDrawOutDev(aBitmap);
733 exportImage("10-01_draw_out_dev_test.png", aBitmap);
734 if (SHOULD_ASSERT)
735 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
738 void testDrawOutDevScaledClipped()
740 if (getDefaultDeviceBitCount() < 24)
741 return;
742 vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest;
743 Bitmap aBitmap = aOutDevTest.setupDrawOutDevScaledClipped();
744 auto eResult
745 = vcl::test::OutputDeviceTestAnotherOutDev::checkDrawOutDevScaledClipped(aBitmap);
746 exportImage("10-02_draw_out_dev_scaled_clipped_test.png", aBitmap);
747 if (SHOULD_ASSERT)
748 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
751 void testDrawOutDevSelf()
753 if (getDefaultDeviceBitCount() < 24)
754 return;
755 vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest;
756 Bitmap aBitmap = aOutDevTest.setupDrawOutDevSelf();
757 auto eResult = vcl::test::OutputDeviceTestAnotherOutDev::checkDrawOutDevSelf(aBitmap);
758 exportImage("10-03_draw_out_dev_self_test.png", aBitmap);
759 if (SHOULD_ASSERT)
760 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
763 void testDashedLine()
765 if (getDefaultDeviceBitCount() < 24)
766 return;
767 vcl::test::OutputDeviceTestLine aOutDevTest;
768 Bitmap aBitmap = aOutDevTest.setupDashedLine();
769 auto eResult = vcl::test::OutputDeviceTestLine::checkDashedLine(aBitmap);
770 exportImage("11-01_dashed_line_test.png", aBitmap);
771 if (SHOULD_ASSERT)
772 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
775 void testErase()
777 if (getDefaultDeviceBitCount() < 24)
778 return;
780 // Create normal virtual device (no alpha).
781 ScopedVclPtr<VirtualDevice> device
782 = VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT);
783 device->SetOutputSizePixel(Size(10, 10));
784 // Erase with white, check it's white.
785 device->SetBackground(Wallpaper(COL_WHITE));
786 device->Erase();
787 exportDevice("12-01_erase.png", 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));
793 device->Erase();
794 exportDevice("12-02_erase.png", 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));
800 device->Erase();
801 exportDevice("12-03_erase.png", 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::DEFAULT, DeviceFormat::DEFAULT);
810 device->SetOutputSizePixel(Size(10, 10));
811 // Erase with white, check it's white.
812 device->SetBackground(Wallpaper(COL_WHITE));
813 device->Erase();
814 exportDevice("12-04_erase.png", 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));
820 device->Erase();
821 exportDevice("12-05_erase.png", 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));
827 device->Erase();
828 exportDevice("12-06_erase.png", 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));
834 device->Erase();
835 exportDevice("12-07_erase.png", 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)
845 return;
846 vcl::test::OutputDeviceTestGradient aOutDevTest;
847 Bitmap aBitmap = aOutDevTest.setupLinearGradient();
848 auto eResult = vcl::test::OutputDeviceTestGradient::checkLinearGradient(aBitmap);
849 exportImage("13-01_linear_gradient_test.png", aBitmap);
850 if (SHOULD_ASSERT)
851 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
854 void testLinearGradientAngled()
856 if (getDefaultDeviceBitCount() < 24)
857 return;
858 vcl::test::OutputDeviceTestGradient aOutDevTest;
859 Bitmap aBitmap = aOutDevTest.setupLinearGradientAngled();
860 auto eResult = vcl::test::OutputDeviceTestGradient::checkLinearGradientAngled(aBitmap);
861 exportImage("13-02_linear_gradient_angled_test.png", aBitmap);
862 if (SHOULD_ASSERT)
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("13-03_linear_gradient_border_test.png", aBitmap);
872 if (SHOULD_ASSERT)
873 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
876 void testLinearGradientIntensity()
878 if (getDefaultDeviceBitCount() < 24)
879 return;
880 vcl::test::OutputDeviceTestGradient aOutDevTest;
881 Bitmap aBitmap = aOutDevTest.setupLinearGradientIntensity();
882 auto eResult = vcl::test::OutputDeviceTestGradient::checkLinearGradientIntensity(aBitmap);
883 exportImage("13-04_linear_gradient_intensity_test.png", aBitmap);
884 if (SHOULD_ASSERT)
885 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
888 void testLinearGradientSteps()
890 if (getDefaultDeviceBitCount() < 24)
891 return;
892 vcl::test::OutputDeviceTestGradient aOutDevTest;
893 Bitmap aBitmap = aOutDevTest.setupLinearGradientSteps();
894 auto eResult = vcl::test::OutputDeviceTestGradient::checkLinearGradientSteps(aBitmap);
895 exportImage("13-05_linear_gradient_steps_test.png", aBitmap);
896 if (SHOULD_ASSERT)
897 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
900 void testAxialGradient()
902 if (getDefaultDeviceBitCount() < 24)
903 return;
904 vcl::test::OutputDeviceTestGradient aOutDevTest;
905 Bitmap aBitmap = aOutDevTest.setupAxialGradient();
906 auto eResult = vcl::test::OutputDeviceTestGradient::checkAxialGradient(aBitmap);
907 exportImage("13-06_axial_gradient_test.png", aBitmap);
908 if (SHOULD_ASSERT)
909 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
912 void testRadialGradient()
914 if (getDefaultDeviceBitCount() < 24)
915 return;
916 vcl::test::OutputDeviceTestGradient aOutDevTest;
917 Bitmap aBitmap = aOutDevTest.setupRadialGradient();
918 auto eResult = vcl::test::OutputDeviceTestGradient::checkRadialGradient(aBitmap);
919 exportImage("13-07_radial_gradient_test.png", aBitmap);
920 if (SHOULD_ASSERT)
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("13-08_radial_gradient_ofs_test.png", aBitmap);
930 if (SHOULD_ASSERT)
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("14-01_line_join_bevel_test.png", aBitmap);
940 if (SHOULD_ASSERT)
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("14-02_line_join_round_test.png", aBitmap);
950 if (SHOULD_ASSERT)
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("14-03_line_join_miter_test.png", aBitmap);
960 if (SHOULD_ASSERT)
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("14-04_line_join_none_test.png", aBitmap);
970 if (SHOULD_ASSERT)
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("14-05_line_cap_round_test.png", aBitmap);
980 if (SHOULD_ASSERT)
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("14-06_line_cap_square_test.png", aBitmap);
990 if (SHOULD_ASSERT)
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("14-07_line_cap_butt_test.png", aBitmap);
1000 if (SHOULD_ASSERT)
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("15-01_drop_shape_test-polyline.png", aBitmap);
1010 if (SHOULD_ASSERT)
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("15-02_drop_shape_AA_test-polyline.png", aBitmap);
1020 if (SHOULD_ASSERT)
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("16-01_drop_shape_test-polygon.png", aBitmap);
1030 if (SHOULD_ASSERT)
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("16-02_drop_shape_AA_test-polygon.png", aBitmap);
1040 if (SHOULD_ASSERT)
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("17-01_half_ellipse_test-polyline.png", aBitmap);
1050 if (SHOULD_ASSERT)
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("17-02_half_ellipse_AA_test-polyline.png", aBitmap);
1060 if (SHOULD_ASSERT)
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("17-03_half_ellipse_test-polylineb2d.png", aBitmap);
1070 if (SHOULD_ASSERT)
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("17-03_half_ellipse_AA_test-polylineb2d.png", aBitmap);
1080 if (SHOULD_ASSERT)
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("17-04_half_ellipse_test-polygon.png", aBitmap);
1090 if (SHOULD_ASSERT)
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("17-05_half_ellipse_AA_test-polygon.png", aBitmap);
1100 if (SHOULD_ASSERT)
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("18-01_closed_bezier-polyline.png", aBitmap);
1110 if (SHOULD_ASSERT)
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("18-02_closed_bezier-polygon.png", aBitmap);
1120 if (SHOULD_ASSERT)
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("19-01_filled_drop_shape-polygon.png", aBitmap);
1131 if (SHOULD_ASSERT)
1132 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
1135 // Test SalGraphics::blendBitmap() and blendAlphaBitmap() calls.
1136 void testDrawBlendExtended()
1138 if (getDefaultDeviceBitCount() < 24)
1139 return;
1140 // Create virtual device with alpha.
1141 ScopedVclPtr<VirtualDevice> device
1142 = VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT, DeviceFormat::DEFAULT);
1143 #ifdef MACOSX
1144 // TODO: This unit test is not executed for macOS unless bitmap scaling is implemented
1145 if (getRenderBackendName(device) == "aqua")
1146 return;
1147 #endif
1148 device->SetOutputSizePixel(Size(10, 10));
1149 device->SetBackground(Wallpaper(COL_WHITE));
1150 device->Erase();
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("blend_extended_01.png", 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)));
1163 device->Erase();
1164 AlphaMask alpha(Size(5, 5));
1165 alpha.Erase(0); // opaque
1166 device->DrawBitmapEx(Point(2, 2), BitmapEx(bitmap, alpha));
1167 exportDevice("blend_extended_02.png", device);
1168 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device->GetPixel(Point(2, 2)));
1169 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device->GetPixel(Point(6, 6)));
1171 device->Erase();
1172 alpha.Erase(255); // transparent
1173 device->DrawBitmapEx(Point(2, 2), BitmapEx(bitmap, alpha));
1174 exportDevice("blend_extended_03.png", 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.
1181 device->Erase();
1182 alpha.Erase(255); // transparent
1183 BitmapWriteAccess* alphaWrite = alpha.AcquireAlphaWriteAccess();
1184 alphaWrite->SetPixelIndex(0, 0, 0); // opaque
1185 alpha.ReleaseAccess(alphaWrite);
1186 device->DrawBitmapEx(Point(2, 2), BitmapEx(bitmap, alpha));
1187 exportDevice("blend_extended_04.png", 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)
1195 return;
1196 // Normal virtual device.
1197 ScopedVclPtr<VirtualDevice> device = VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT);
1198 #ifdef MACOSX
1199 // TODO: This unit test is not executed for macOS unless bitmap scaling is implemented
1200 if (getRenderBackendName(device) == "aqua")
1201 return;
1202 #endif
1203 // Virtual device with alpha.
1204 ScopedVclPtr<VirtualDevice> alphaDevice
1205 = VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT, DeviceFormat::DEFAULT);
1206 device->SetOutputSizePixel(Size(20, 20));
1207 device->SetBackground(Wallpaper(COL_BLACK));
1208 device->Erase();
1209 alphaDevice->SetOutputSizePixel(Size(20, 20));
1210 alphaDevice->SetBackground(Wallpaper(COL_BLACK));
1211 alphaDevice->Erase();
1212 Bitmap bitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);
1213 AlphaMask alpha(Size(4, 4));
1214 bitmap.Erase(COL_LIGHTBLUE);
1216 BitmapScopedWriteAccess writeAccess(bitmap);
1217 writeAccess->SetPixel(3, 3, COL_LIGHTRED);
1219 // alpha 127 will make COL_LIGHTRED -> COL_RED and the same for blue
1220 alpha.Erase(127);
1221 // Normal device.
1222 device->DrawBitmapEx(Point(5, 5), Size(-4, -4), BitmapEx(bitmap));
1223 device->DrawBitmapEx(Point(15, 15), Size(4, 4), BitmapEx(bitmap));
1224 exportDevice("draw_alpha_bitmap_mirrored_01.png", device);
1225 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, device->GetPixel(Point(18, 18)));
1226 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, device->GetPixel(Point(17, 18)));
1227 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, device->GetPixel(Point(2, 2)));
1228 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, device->GetPixel(Point(3, 2)));
1229 device->Erase();
1230 device->DrawBitmapEx(Point(5, 5), Size(-4, -4), BitmapEx(bitmap, alpha));
1231 device->DrawBitmapEx(Point(15, 15), Size(4, 4), BitmapEx(bitmap, alpha));
1232 exportDevice("draw_alpha_bitmap_mirrored_02.png", device);
1233 CPPUNIT_ASSERT_EQUAL(COL_RED, device->GetPixel(Point(18, 18)));
1234 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device->GetPixel(Point(17, 18)));
1235 CPPUNIT_ASSERT_EQUAL(COL_RED, device->GetPixel(Point(2, 2)));
1236 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device->GetPixel(Point(3, 2)));
1237 device->Erase();
1238 // Now with alpha device.
1239 alphaDevice->DrawBitmapEx(Point(5, 5), Size(-4, -4), BitmapEx(bitmap));
1240 alphaDevice->DrawBitmapEx(Point(15, 15), Size(4, 4), BitmapEx(bitmap));
1241 exportDevice("draw_alpha_bitmap_mirrored_03.png", alphaDevice);
1242 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, alphaDevice->GetPixel(Point(18, 18)));
1243 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, alphaDevice->GetPixel(Point(17, 18)));
1244 CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, alphaDevice->GetPixel(Point(2, 2)));
1245 CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, alphaDevice->GetPixel(Point(3, 2)));
1246 alphaDevice->Erase();
1247 alphaDevice->DrawBitmapEx(Point(5, 5), Size(-4, -4), BitmapEx(bitmap, alpha));
1248 alphaDevice->DrawBitmapEx(Point(15, 15), Size(4, 4), BitmapEx(bitmap, alpha));
1249 exportDevice("draw_alpha_bitmap_mirrored_04.png", alphaDevice);
1250 CPPUNIT_ASSERT_EQUAL(COL_RED, alphaDevice->GetPixel(Point(18, 18)));
1251 CPPUNIT_ASSERT_EQUAL(COL_BLUE, alphaDevice->GetPixel(Point(17, 18)));
1252 CPPUNIT_ASSERT_EQUAL(COL_RED, alphaDevice->GetPixel(Point(2, 2)));
1253 CPPUNIT_ASSERT_EQUAL(COL_BLUE, alphaDevice->GetPixel(Point(3, 2)));
1254 alphaDevice->Erase();
1257 void testDrawingText()
1259 #ifndef _WIN32
1260 vcl::test::OutputDeviceTestText aOutDevTest;
1261 Bitmap aBitmap = aOutDevTest.setupTextBitmap();
1262 auto eResult = vcl::test::OutputDeviceTestCommon::checkTextLocation(aBitmap);
1263 exportImage("17-01_test_text_Drawing.png", aBitmap);
1264 if (SHOULD_ASSERT)
1265 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
1266 #endif
1269 void testEvenOddRuleInIntersectionRectangles()
1271 vcl::test::OutputDeviceTestPolyPolygon aOutDevTest;
1272 Bitmap aBitmap = aOutDevTest.setupIntersectingRectangles();
1273 auto eResult
1274 = vcl::test::OutputDeviceTestCommon::checkEvenOddRuleInIntersectingRecs(aBitmap);
1275 exportImage("18-01_test_Even-Odd-rule_intersecting_Recs.png", aBitmap);
1276 if (SHOULD_ASSERT)
1277 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
1280 void testDrawOpenPolygonWithPolyLine()
1282 vcl::test::OutputDeviceTestPolyLine aOutDevTest;
1283 Bitmap aBitmap = aOutDevTest.setupOpenPolygon();
1284 auto eResult = vcl::test::OutputDeviceTestCommon::checkOpenPolygon(aBitmap);
1285 exportImage("19-01_open_polygon-polyline.png", aBitmap);
1286 if (SHOULD_ASSERT)
1287 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
1290 void testDrawOpenPolygonWithPolyLineB2D()
1292 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest;
1293 Bitmap aBitmap = aOutDevTest.setupOpenPolygon();
1294 auto eResult = vcl::test::OutputDeviceTestCommon::checkOpenPolygon(aBitmap);
1295 exportImage("19-02_open_polygon-polyline_b2d.png", aBitmap);
1296 if (SHOULD_ASSERT)
1297 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
1300 void testDrawOpenPolygonWithPolygon()
1302 vcl::test::OutputDeviceTestPolygon aOutDevTest;
1303 Bitmap aBitmap = aOutDevTest.setupOpenPolygon();
1304 auto eResult = vcl::test::OutputDeviceTestCommon::checkOpenPolygon(aBitmap);
1305 exportImage("19-03_open_polygon-polygon.png", aBitmap);
1306 if (SHOULD_ASSERT)
1307 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
1310 void testDrawOpenPolygonWithPolyPolygon()
1312 vcl::test::OutputDeviceTestPolyPolygon aOutDevTest;
1313 Bitmap aBitmap = aOutDevTest.setupOpenPolygon();
1314 auto eResult = vcl::test::OutputDeviceTestCommon::checkOpenPolygon(aBitmap);
1315 exportImage("19-04_open_polygon-polypolygon.png", aBitmap);
1316 if (SHOULD_ASSERT)
1317 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
1320 void testDrawOpenPolygonWithPolyPolygonB2D()
1322 vcl::test::OutputDeviceTestPolyPolygonB2D aOutDevTest;
1323 Bitmap aBitmap = aOutDevTest.setupOpenPolygon();
1324 auto eResult = vcl::test::OutputDeviceTestCommon::checkOpenPolygon(aBitmap);
1325 exportImage("19-04_open_polygon-polypolygon_b2d.png", aBitmap);
1326 if (SHOULD_ASSERT)
1327 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
1330 void testDrawOpenBezierWithPolyLine()
1332 vcl::test::OutputDeviceTestPolyLine aOutDevTest;
1333 Bitmap aBitmap = aOutDevTest.setupOpenBezier();
1334 auto eResult = vcl::test::OutputDeviceTestCommon::checkOpenBezier(aBitmap);
1335 exportImage("19-01_open_bezier-polyline.png", aBitmap);
1336 if (SHOULD_ASSERT)
1337 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
1340 void testDrawOpenBezierWithPolyLineB2D()
1342 vcl::test::OutputDeviceTestPolyLineB2D aOutDevTest;
1343 Bitmap aBitmap = aOutDevTest.setupOpenBezier();
1344 auto eResult = vcl::test::OutputDeviceTestCommon::checkOpenBezier(aBitmap);
1345 exportImage("19-01_open_bezier-polyline_b2d.png", aBitmap);
1346 if (SHOULD_ASSERT)
1347 CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
1350 void testTdf124848()
1352 ScopedVclPtr<VirtualDevice> device = VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT);
1353 #ifdef MACOSX
1354 // TODO: This unit test is not executed for macOS unless bitmap scaling is implemented
1355 if (getRenderBackendName(device) == "aqua")
1356 return;
1357 #endif
1358 device->SetOutputSizePixel(Size(100, 100));
1359 device->SetBackground(Wallpaper(COL_WHITE));
1360 device->Erase();
1361 device->SetAntialiasing(AntialiasingFlags::Enable);
1362 device->SetLineColor(COL_BLACK);
1363 basegfx::B2DHomMatrix matrix;
1364 // DrawPolyLine() would apply the whole matrix to the line width, making it negative
1365 // in case of a larger rotation.
1366 matrix.rotate(M_PI); //180 degrees
1367 matrix.translate(100, 100);
1368 CPPUNIT_ASSERT(device->DrawPolyLineDirect(matrix,
1369 basegfx::B2DPolygon{ { 50, 50 }, { 50, 100 } },
1370 100, 0, nullptr, basegfx::B2DLineJoin::Miter));
1371 exportDevice("tdf124848-1.png", device);
1372 // 100px wide line should fill the entire width of the upper half
1373 CPPUNIT_ASSERT_EQUAL(COL_BLACK, device->GetPixel(Point(2, 2)));
1375 // Also check hairline.
1376 device->Erase();
1377 CPPUNIT_ASSERT(device->DrawPolyLineDirect(matrix,
1378 basegfx::B2DPolygon{ { 50, 50 }, { 50, 100 } }, 0,
1379 0, nullptr, basegfx::B2DLineJoin::Miter));
1380 exportDevice("tdf124848-2.png", device);
1381 // 1px wide
1382 CPPUNIT_ASSERT_EQUAL(COL_BLACK, device->GetPixel(Point(50, 20)));
1383 CPPUNIT_ASSERT_EQUAL(COL_WHITE, device->GetPixel(Point(49, 20)));
1384 CPPUNIT_ASSERT_EQUAL(COL_WHITE, device->GetPixel(Point(51, 20)));
1387 void testTdf136171()
1389 if (getDefaultDeviceBitCount() < 24)
1390 return;
1391 // Create virtual device with alpha.
1392 ScopedVclPtr<VirtualDevice> device
1393 = VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT, DeviceFormat::DEFAULT);
1394 device->SetOutputSizePixel(Size(10, 10));
1395 device->SetBackground(Wallpaper(COL_WHITE));
1396 device->Erase();
1397 Bitmap bitmap(Size(10, 10), vcl::PixelFormat::N24_BPP);
1398 bitmap.Erase(COL_BLUE);
1399 basegfx::B2DHomMatrix matrix;
1400 matrix.scale(bitmap.GetSizePixel().Width(),
1401 bitmap.GetSizePixel().Height()); // draw as 10x10
1402 // Draw a blue bitmap to the device. The bug was that there was no alpha, but OutputDevice::DrawTransformBitmapExDirect()
1403 // supplied a fully opaque alpha done with Erase() on the alpha bitmap, and Skia backend didn't handle such alpha correctly.
1404 device->DrawTransformedBitmapEx(matrix, BitmapEx(bitmap));
1405 exportDevice("tdf136171.png", device);
1406 // The whole virtual device content now should be blue.
1407 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device->GetPixel(Point(0, 0)));
1408 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device->GetPixel(Point(9, 0)));
1409 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device->GetPixel(Point(0, 9)));
1410 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device->GetPixel(Point(9, 9)));
1411 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device->GetPixel(Point(4, 4)));
1414 void testTdf145811()
1416 // VCL may call copyArea()/copyBits() of backends even with coordinates partially
1417 // outside of the device, so try various copying like that.
1418 ScopedVclPtr<VirtualDevice> device1 = VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT);
1419 device1->SetOutputSizePixel(Size(100, 100));
1420 device1->SetBackground(Wallpaper(COL_YELLOW));
1421 device1->Erase();
1422 device1->SetLineColor(COL_BLUE);
1423 device1->DrawPixel(Point(0, 0), COL_BLUE);
1424 device1->DrawPixel(Point(99, 99), COL_BLUE);
1425 #ifdef MACOSX
1426 // TODO: This unit test is not executed for macOS unless bitmap scaling is implemented
1427 if (getRenderBackendName(device1) == "aqua")
1428 return;
1429 #endif
1431 // Plain 1:1 copy device1->device2.
1432 ScopedVclPtr<VirtualDevice> device2 = VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT);
1433 device2->SetOutputSizePixel(Size(100, 100));
1434 device2->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1);
1435 exportDevice("tdf145811-1.png", device2);
1436 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(0, 0)));
1437 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(1, 1)));
1438 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(98, 98)));
1439 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(99, 99)));
1441 // For the rest call directly SalGraphics, because OutputDevice does range checking,
1442 // but other code may call copyArea()/copyBits() of SalGraphics directly without range checking.
1443 SalGraphics* graphics1 = device1->GetGraphics();
1444 SalGraphics* graphics2 = device2->GetGraphics();
1446 device2->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1);
1447 // Copy device1->device2 offset by 10,10.
1448 graphics2->CopyBits(SalTwoRect(0, 0, 100, 100, 10, 10, 100, 100), *graphics1, *device2,
1449 *device1);
1450 exportDevice("tdf145811-2.png", device2);
1451 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(0, 0))); // unmodified
1452 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(9, 9)));
1453 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(10, 10)));
1454 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(11, 11)));
1455 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(99, 99)));
1457 device2->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1);
1458 // Copy area of device2 offset by 10,10.
1459 graphics2->CopyArea(10, 10, 0, 0, 100, 100, *device1);
1460 exportDevice("tdf145811-3.png", device2);
1461 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(0, 0))); // unmodified
1462 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(9, 9)));
1463 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(10, 10)));
1464 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(11, 11)));
1465 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(99, 99)));
1467 device2->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1);
1468 // Copy device1->device2 offset by -20,-20.
1469 graphics2->CopyBits(SalTwoRect(0, 0, 100, 100, -20, -20, 100, 100), *graphics1, *device2,
1470 *device1);
1471 exportDevice("tdf145811-4.png", device2);
1472 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(0, 0)));
1473 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(78, 78)));
1474 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(79, 79)));
1475 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(80, 80)));
1476 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(99, 99))); // unmodified
1478 device2->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1);
1479 // Copy area of device2 offset by -20,-20.
1480 graphics2->CopyArea(-20, -20, 0, 0, 100, 100, *device1);
1481 exportDevice("tdf145811-5.png", device2);
1482 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(0, 0)));
1483 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(78, 78)));
1484 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(79, 79)));
1485 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(80, 80)));
1486 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(99, 99))); // unmodified
1488 device2->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1);
1489 // Copy device1->device2 offset by -10,-10 starting from -20,-20 at 150x150 size
1490 // (i.e. outside in all directions).
1491 graphics2->CopyBits(SalTwoRect(-20, -20, 150, 150, -30, -30, 150, 150), *graphics1,
1492 *device2, *device1);
1493 exportDevice("tdf145811-6.png", device2);
1494 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(0, 0)));
1495 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(88, 88)));
1496 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(89, 89)));
1497 // (90,90) and further originate from outside and may be garbage.
1499 device2->DrawOutDev(Point(0, 0), Size(100, 100), Point(0, 0), Size(100, 100), *device1);
1500 // Copy area of device2 offset by -10,-10 starting from -20,-20 at 150x150 size
1501 // (i.e. outside in all directions).
1502 graphics2->CopyArea(-30, -30, -20, -20, 150, 150, *device1);
1503 exportDevice("tdf145811-7.png", device2);
1504 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(0, 0)));
1505 CPPUNIT_ASSERT_EQUAL(COL_YELLOW, device2->GetPixel(Point(88, 88)));
1506 CPPUNIT_ASSERT_EQUAL(COL_BLUE, device2->GetPixel(Point(89, 89)));
1507 // (90,90) and further originate from outside and may be garbage.
1510 CPPUNIT_TEST_SUITE(BackendTest);
1511 CPPUNIT_TEST(testDrawRectWithRectangle);
1512 CPPUNIT_TEST(testDrawRectWithPixel);
1513 CPPUNIT_TEST(testDrawRectWithLine);
1514 CPPUNIT_TEST(testDrawRectWithPolygon);
1515 CPPUNIT_TEST(testDrawRectWithPolyLine);
1516 CPPUNIT_TEST(testDrawRectWithPolyLineB2D);
1517 CPPUNIT_TEST(testDrawRectWithPolyPolygon);
1518 CPPUNIT_TEST(testDrawRectWithPolyPolygonB2D);
1520 CPPUNIT_TEST(testDrawRectAAWithRectangle);
1521 CPPUNIT_TEST(testDrawRectAAWithPixel);
1522 CPPUNIT_TEST(testDrawRectAAWithLine);
1523 CPPUNIT_TEST(testDrawRectAAWithPolygon);
1524 CPPUNIT_TEST(testDrawRectAAWithPolyLine);
1525 CPPUNIT_TEST(testDrawRectAAWithPolyLineB2D);
1526 CPPUNIT_TEST(testDrawRectAAWithPolyPolygon);
1527 CPPUNIT_TEST(testDrawRectAAWithPolyPolygonB2D);
1529 CPPUNIT_TEST(testDrawFilledRectWithRectangle);
1530 CPPUNIT_TEST(testDrawFilledRectWithPolygon);
1531 CPPUNIT_TEST(testDrawFilledRectWithPolyPolygon);
1532 CPPUNIT_TEST(testDrawFilledRectWithPolyPolygon2D);
1534 CPPUNIT_TEST(testDrawDiamondWithPolygon);
1535 CPPUNIT_TEST(testDrawDiamondWithLine);
1536 CPPUNIT_TEST(testDrawDiamondWithPolyline);
1537 CPPUNIT_TEST(testDrawDiamondWithPolylineB2D);
1539 CPPUNIT_TEST(testDrawInvertWithRectangle);
1540 CPPUNIT_TEST(testDrawInvertN50WithRectangle);
1541 CPPUNIT_TEST(testDrawInvertTrackFrameWithRectangle);
1543 CPPUNIT_TEST(testDrawBezierWithPolylineB2D);
1544 CPPUNIT_TEST(testDrawBezierAAWithPolylineB2D);
1546 CPPUNIT_TEST(testDrawDropShapeWithPolyline);
1547 CPPUNIT_TEST(testDrawDropShapeAAWithPolyline);
1549 CPPUNIT_TEST(testDrawDropShapeWithPolygon);
1550 CPPUNIT_TEST(testDrawDropShapeAAWithPolygon);
1552 CPPUNIT_TEST(testDrawHaflEllipseWithPolyLine);
1553 CPPUNIT_TEST(testDrawHaflEllipseAAWithPolyLine);
1554 CPPUNIT_TEST(testDrawHaflEllipseWithPolyLineB2D);
1555 CPPUNIT_TEST(testDrawHaflEllipseAAWithPolyLineB2D);
1556 CPPUNIT_TEST(testDrawHaflEllipseWithPolygon);
1557 CPPUNIT_TEST(testDrawHaflEllipseAAWithPolygon);
1559 CPPUNIT_TEST(testClosedBezierWithPolyline);
1560 CPPUNIT_TEST(testClosedBezierWithPolygon);
1562 CPPUNIT_TEST(testFilledAsymmetricalDropShape);
1564 CPPUNIT_TEST(testDrawBitmap24bpp);
1565 CPPUNIT_TEST(testDrawTransformedBitmap24bpp);
1566 CPPUNIT_TEST(testComplexDrawTransformedBitmap24bpp);
1567 CPPUNIT_TEST(testDrawBitmapExWithAlpha24bpp);
1568 CPPUNIT_TEST(testDrawMask24bpp);
1569 CPPUNIT_TEST(testDrawBlend24bpp);
1571 CPPUNIT_TEST(testDrawXor);
1573 CPPUNIT_TEST(testDrawBitmap32bpp);
1574 CPPUNIT_TEST(testDrawTransformedBitmap32bpp);
1575 CPPUNIT_TEST(testDrawBitmapExWithAlpha32bpp);
1576 CPPUNIT_TEST(testDrawMask32bpp);
1577 CPPUNIT_TEST(testDrawBlend32bpp);
1579 CPPUNIT_TEST(testDrawTransformedBitmap8bppGreyScale);
1580 CPPUNIT_TEST(testDrawBitmap8bppGreyScale);
1582 CPPUNIT_TEST(testDrawTransformedBitmapExAlpha);
1584 CPPUNIT_TEST(testClipRectangle);
1585 CPPUNIT_TEST(testClipPolygon);
1586 CPPUNIT_TEST(testClipPolyPolygon);
1587 CPPUNIT_TEST(testClipB2DPolyPolygon);
1589 CPPUNIT_TEST(testDrawOutDev);
1590 CPPUNIT_TEST(testDrawOutDevScaledClipped);
1591 CPPUNIT_TEST(testDrawOutDevSelf);
1593 CPPUNIT_TEST(testDashedLine);
1595 CPPUNIT_TEST(testErase);
1597 CPPUNIT_TEST(testLinearGradient);
1598 CPPUNIT_TEST(testLinearGradientAngled);
1599 CPPUNIT_TEST(testLinearGradientBorder);
1600 CPPUNIT_TEST(testLinearGradientIntensity);
1601 CPPUNIT_TEST(testLinearGradientSteps);
1602 CPPUNIT_TEST(testAxialGradient);
1603 CPPUNIT_TEST(testRadialGradient);
1604 CPPUNIT_TEST(testRadialGradientOfs);
1606 CPPUNIT_TEST(testLineCapRound);
1607 CPPUNIT_TEST(testLineCapSquare);
1608 CPPUNIT_TEST(testLineCapButt);
1609 CPPUNIT_TEST(testLineJoinBevel);
1610 CPPUNIT_TEST(testLineJoinRound);
1611 CPPUNIT_TEST(testLineJoinMiter);
1612 CPPUNIT_TEST(testLineJoinNone);
1614 CPPUNIT_TEST(testDrawBlendExtended);
1615 CPPUNIT_TEST(testDrawAlphaBitmapMirrored);
1617 CPPUNIT_TEST(testDrawingText);
1618 CPPUNIT_TEST(testEvenOddRuleInIntersectionRectangles);
1620 CPPUNIT_TEST(testDrawOpenPolygonWithPolyLine);
1621 CPPUNIT_TEST(testDrawOpenPolygonWithPolyLineB2D);
1622 CPPUNIT_TEST(testDrawOpenPolygonWithPolygon);
1623 CPPUNIT_TEST(testDrawOpenPolygonWithPolyPolygon);
1624 CPPUNIT_TEST(testDrawOpenPolygonWithPolyPolygonB2D);
1626 CPPUNIT_TEST(testDrawOpenBezierWithPolyLine);
1627 CPPUNIT_TEST(testDrawOpenBezierWithPolyLineB2D);
1629 CPPUNIT_TEST(testTdf124848);
1630 CPPUNIT_TEST(testTdf136171);
1631 CPPUNIT_TEST(testTdf145811);
1633 CPPUNIT_TEST_SUITE_END();
1636 CPPUNIT_TEST_SUITE_REGISTRATION(BackendTest);
1638 CPPUNIT_PLUGIN_IMPLEMENT();
1640 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */