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
OutputDeviceTestClip::setupClipRectangle()
17 initialSetup(13, 13, constBackgroundColor
);
19 tools::Rectangle rectangle
= maVDRectangle
;
21 mpVirtualDevice
->SetClipRegion(vcl::Region(rectangle
));
22 mpVirtualDevice
->SetBackground(constFillColor
);
23 mpVirtualDevice
->Erase(maVDRectangle
);
25 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
28 Bitmap
OutputDeviceTestClip::setupClipPolygon()
30 initialSetup(13, 13, constBackgroundColor
);
32 tools::Rectangle rectangle
= maVDRectangle
;
34 mpVirtualDevice
->SetClipRegion(vcl::Region(tools::Polygon(rectangle
)));
35 mpVirtualDevice
->SetBackground(constFillColor
);
36 mpVirtualDevice
->Erase(maVDRectangle
);
38 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
41 Bitmap
OutputDeviceTestClip::setupClipPolyPolygon()
43 initialSetup(13, 13, constBackgroundColor
);
45 tools::Rectangle rectangle
= maVDRectangle
;
47 mpVirtualDevice
->SetClipRegion(vcl::Region(tools::PolyPolygon(rectangle
)));
48 mpVirtualDevice
->SetBackground(constFillColor
);
49 mpVirtualDevice
->Erase(maVDRectangle
);
51 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
54 Bitmap
OutputDeviceTestClip::setupClipB2DPolyPolygon()
56 initialSetup(13, 13, constBackgroundColor
);
58 tools::Rectangle rectangle
= maVDRectangle
;
60 mpVirtualDevice
->SetClipRegion(vcl::Region(basegfx::B2DPolyPolygon(basegfx::B2DPolygon
{
61 basegfx::B2DPoint(rectangle
.getX(), rectangle
.getY()),
62 basegfx::B2DPoint(rectangle
.getX(), rectangle
.getY() + rectangle
.getHeight()),
63 basegfx::B2DPoint(rectangle
.getX() + rectangle
.getWidth(),
64 rectangle
.getY() + rectangle
.getHeight()),
65 basegfx::B2DPoint(rectangle
.getX() + rectangle
.getWidth(), rectangle
.getY()),
67 mpVirtualDevice
->SetBackground(constFillColor
);
68 mpVirtualDevice
->Erase(maVDRectangle
);
70 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
73 TestResult
OutputDeviceTestClip::checkClip(Bitmap
& aBitmap
)
75 std::vector
<Color
> aExpected
{ constBackgroundColor
, constBackgroundColor
, constFillColor
,
76 constFillColor
, constFillColor
, constFillColor
,
78 return checkRectangles(aBitmap
, aExpected
);
81 } // end namespace vcl::test
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */