From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- vcl/backendtest/outputdevice/rectangle.cxx | 142 +++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 vcl/backendtest/outputdevice/rectangle.cxx (limited to 'vcl/backendtest/outputdevice/rectangle.cxx') diff --git a/vcl/backendtest/outputdevice/rectangle.cxx b/vcl/backendtest/outputdevice/rectangle.cxx new file mode 100644 index 000000000..f35285f28 --- /dev/null +++ b/vcl/backendtest/outputdevice/rectangle.cxx @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#include + +namespace vcl::test +{ +namespace +{ +void drawRectOffset(OutputDevice& rDevice, tools::Rectangle const& rRect, int nOffset) +{ + int nMidOffset = rRect.Left() + (rRect.Right() - rRect.Left()) / 2; + rDevice.DrawRect( + tools::Rectangle(rRect.Left() + nOffset - (nOffset + 1) / 2, rRect.Top() + nOffset - 1, + rRect.Right() - nMidOffset - nOffset / 3, rRect.Bottom() - nOffset + 1)); +} + +void drawInvertOffset(OutputDevice& rDevice, tools::Rectangle const& rRect, int nOffset, + InvertFlags eFlags) +{ + tools::Rectangle aRectangle(rRect.Left() + nOffset, rRect.Top() + nOffset, + rRect.Right() - nOffset, rRect.Bottom() - nOffset); + rDevice.Invert(aRectangle, eFlags); +} + +} // end anonymous namespace + +Bitmap OutputDeviceTestRect::setupFilledRectangle(bool useLineColor) +{ + initialSetup(13, 13, constBackgroundColor); + + if (useLineColor) + mpVirtualDevice->SetLineColor(constLineColor); + else + mpVirtualDevice->SetLineColor(); + mpVirtualDevice->SetFillColor(constFillColor); + + drawRectOffset(*mpVirtualDevice, maVDRectangle, 2); + + return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); +} + +Bitmap OutputDeviceTestRect::setupRectangle(bool bEnableAA) +{ + initialSetup(13, 13, constBackgroundColor, bEnableAA); + + mpVirtualDevice->SetLineColor(constLineColor); + mpVirtualDevice->SetFillColor(); + + drawRectOffset(*mpVirtualDevice, maVDRectangle, 2); + drawRectOffset(*mpVirtualDevice, maVDRectangle, 5); + + return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); +} + +Bitmap OutputDeviceTestRect::setupInvert_NONE() +{ + initialSetup(20, 20, COL_WHITE); + + mpVirtualDevice->SetLineColor(); + mpVirtualDevice->SetFillColor(COL_LIGHTRED); + mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 2), Size(8, 8))); + mpVirtualDevice->SetFillColor(COL_LIGHTGREEN); + mpVirtualDevice->DrawRect(tools::Rectangle(Point(10, 2), Size(8, 8))); + mpVirtualDevice->SetFillColor(COL_LIGHTBLUE); + mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 10), Size(8, 8))); + + drawInvertOffset(*mpVirtualDevice, maVDRectangle, 2, InvertFlags::NONE); + + return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); +} + +Bitmap OutputDeviceTestRect::setupInvert_N50() +{ + initialSetup(20, 20, COL_WHITE); + + mpVirtualDevice->SetLineColor(); + mpVirtualDevice->SetFillColor(COL_LIGHTRED); + mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 2), Size(8, 8))); + mpVirtualDevice->SetFillColor(COL_LIGHTGREEN); + mpVirtualDevice->DrawRect(tools::Rectangle(Point(10, 2), Size(8, 8))); + mpVirtualDevice->SetFillColor(COL_LIGHTBLUE); + mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 10), Size(8, 8))); + + drawInvertOffset(*mpVirtualDevice, maVDRectangle, 2, InvertFlags::N50); + + return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); +} + +Bitmap OutputDeviceTestRect::setupInvert_TrackFrame() +{ + initialSetup(20, 20, COL_WHITE); + + mpVirtualDevice->SetLineColor(); + mpVirtualDevice->SetFillColor(COL_LIGHTRED); + mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 2), Size(8, 8))); + mpVirtualDevice->SetFillColor(COL_LIGHTGREEN); + mpVirtualDevice->DrawRect(tools::Rectangle(Point(10, 2), Size(8, 8))); + mpVirtualDevice->SetFillColor(COL_LIGHTBLUE); + mpVirtualDevice->DrawRect(tools::Rectangle(Point(2, 10), Size(8, 8))); + + drawInvertOffset(*mpVirtualDevice, maVDRectangle, 2, InvertFlags::TrackFrame); + + return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); +} + +Bitmap OutputDeviceTestRect::setupRectangleOnSize1028() +{ + initialSetup(1028, 1028, constBackgroundColor); + + mpVirtualDevice->SetLineColor(constLineColor); + mpVirtualDevice->SetFillColor(); + + drawRectOffset(*mpVirtualDevice, maVDRectangle, 2); + drawRectOffset(*mpVirtualDevice, maVDRectangle, 5); + + return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); +} + +Bitmap OutputDeviceTestRect::setupRectangleOnSize4096() +{ + initialSetup(4096, 4096, constBackgroundColor); + + mpVirtualDevice->SetLineColor(constLineColor); + mpVirtualDevice->SetFillColor(); + + drawRectOffset(*mpVirtualDevice, maVDRectangle, 2); + drawRectOffset(*mpVirtualDevice, maVDRectangle, 5); + + return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); +} + +} // end namespace vcl::test + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3