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
.Left(), rectangle
.Top()),
62 basegfx::B2DPoint(rectangle
.Left(), rectangle
.Bottom()),
63 basegfx::B2DPoint(rectangle
.Right(), rectangle
.Bottom()),
64 basegfx::B2DPoint(rectangle
.Right(), rectangle
.Top()),
66 mpVirtualDevice
->SetBackground(constFillColor
);
67 mpVirtualDevice
->Erase(maVDRectangle
);
69 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
72 TestResult
OutputDeviceTestClip::checkClip(Bitmap
& aBitmap
)
74 std::vector
<Color
> aExpected
{ constBackgroundColor
, constBackgroundColor
, constFillColor
,
75 constFillColor
, constFillColor
, constFillColor
,
77 return checkRectangles(aBitmap
, aExpected
);
80 } // end namespace vcl::test
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */