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/outputdevice.hxx>
15 Bitmap
OutputDeviceTestAnotherOutDev::setupDrawOutDev()
17 ScopedVclPtrInstance
<VirtualDevice
> pSourceDev
;
18 Size
aSourceSize(9, 9);
19 pSourceDev
->SetOutputSizePixel(aSourceSize
);
20 pSourceDev
->SetBackground(Wallpaper(constFillColor
));
23 initialSetup(13, 13, constBackgroundColor
);
25 mpVirtualDevice
->DrawOutDev(Point(2, 2), aSourceSize
, Point(), aSourceSize
, *pSourceDev
);
27 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
30 Bitmap
OutputDeviceTestAnotherOutDev::setupXOR()
32 initialSetup(13, 13, constBackgroundColor
);
34 tools::Rectangle
aDrawRectangle(maVDRectangle
);
35 aDrawRectangle
.shrink(2);
37 tools::Rectangle
aScissorRectangle(maVDRectangle
);
38 aScissorRectangle
.shrink(4);
40 mpVirtualDevice
->SetRasterOp(RasterOp::Xor
);
41 mpVirtualDevice
->SetFillColor(constFillColor
);
42 mpVirtualDevice
->DrawRect(aDrawRectangle
);
44 mpVirtualDevice
->SetRasterOp(RasterOp::N0
);
45 mpVirtualDevice
->SetFillColor(COL_BLACK
);
46 mpVirtualDevice
->DrawRect(aScissorRectangle
);
48 mpVirtualDevice
->SetRasterOp(RasterOp::Xor
);
49 mpVirtualDevice
->SetFillColor(constFillColor
);
50 mpVirtualDevice
->DrawRect(aDrawRectangle
);
52 mpVirtualDevice
->SetRasterOp(RasterOp::Xor
);
53 mpVirtualDevice
->SetLineColor(constFillColor
);
54 mpVirtualDevice
->SetFillColor();
55 // Rectangle drawn twice is a no-op.
56 aDrawRectangle
= maVDRectangle
;
57 mpVirtualDevice
->DrawRect(aDrawRectangle
);
58 mpVirtualDevice
->DrawRect(aDrawRectangle
);
59 // Rectangle drawn three times is like drawing once.
60 aDrawRectangle
.shrink(1);
61 mpVirtualDevice
->DrawRect(aDrawRectangle
);
62 mpVirtualDevice
->DrawRect(aDrawRectangle
);
63 mpVirtualDevice
->DrawRect(aDrawRectangle
);
65 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
68 TestResult
OutputDeviceTestAnotherOutDev::checkDrawOutDev(Bitmap
& rBitmap
)
70 std::vector
<Color
> aExpected
72 constBackgroundColor
, constBackgroundColor
,
73 constFillColor
, constFillColor
, constFillColor
, constFillColor
, constFillColor
75 return checkRectangles(rBitmap
, aExpected
);
78 TestResult
OutputDeviceTestAnotherOutDev::checkXOR(Bitmap
& rBitmap
)
80 Color
xorColor( constBackgroundColor
.GetRed() ^ constFillColor
.GetRed(),
81 constBackgroundColor
.GetGreen() ^ constFillColor
.GetGreen(),
82 constBackgroundColor
.GetBlue() ^ constFillColor
.GetBlue());
83 std::vector
<Color
> aExpected
85 constBackgroundColor
, xorColor
,
86 constBackgroundColor
, constBackgroundColor
,
87 constFillColor
, constFillColor
,
90 return checkRectangles(rBitmap
, aExpected
);
93 } // end namespace vcl::test
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */