From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- vcl/inc/test/outputdevice.hxx | 223 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 vcl/inc/test/outputdevice.hxx (limited to 'vcl/inc/test/outputdevice.hxx') diff --git a/vcl/inc/test/outputdevice.hxx b/vcl/inc/test/outputdevice.hxx new file mode 100644 index 000000000..b8ad0b67f --- /dev/null +++ b/vcl/inc/test/outputdevice.hxx @@ -0,0 +1,223 @@ +/* -*- 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/. + * + */ + +#ifndef INCLUDED_VCL_OUTDEVTESTS_HXX +#define INCLUDED_VCL_OUTDEVTESTS_HXX + +#include + +namespace vcl { +namespace test { + +/** Rendering test result. + * + * Test either "Passed", "Failed" or "PassedWithQuirks" which means + * the test passed but at least one rendering quirk was detected. + */ +enum class TestResult +{ + Failed, + PassedWithQuirks, + Passed +}; + +/** Common subclass for output device rendering tests. + */ +class VCL_DLLPUBLIC OutputDeviceTestCommon +{ +protected: + + ScopedVclPtr mpVirtualDevice; + tools::Rectangle maVDRectangle; + + static const Color constBackgroundColor; + static const Color constLineColor; + static const Color constFillColor; + +public: + OutputDeviceTestCommon(); + + OUString getRenderBackendName() const; + + void initialSetup(long nWidth, long nHeight, Color aColor, bool bEnableAA = false, bool bAlphaVirtualDevice = false); + + static TestResult checkRectangle(Bitmap& rBitmap); + static TestResult checkRectangleAA(Bitmap& rBitmap); + static TestResult checkFilledRectangle(Bitmap& rBitmap, bool useLineColor); + static TestResult checkLines(Bitmap& rBitmap); + static TestResult checkAALines(Bitmap& rBitmap); + static TestResult checkDiamond(Bitmap& rBitmap); + + static TestResult checkInvertRectangle(Bitmap& rBitmap); + static TestResult checkInvertN50Rectangle(Bitmap& aBitmap); + static TestResult checkInvertTrackFrameRectangle(Bitmap& aBitmap); + + static TestResult checkRectangles(Bitmap& rBitmap, std::vector& aExpectedColors); + static TestResult checkRectangle(Bitmap& rBitmap, int aLayerNumber, Color aExpectedColor); + + static TestResult checkFilled(Bitmap& rBitmap, tools::Rectangle aRectangle, Color aExpectedColor); + static TestResult checkChecker(Bitmap& rBitmap, sal_Int32 nStartX, sal_Int32 nEndX, + sal_Int32 nStartY, sal_Int32 nEndY, std::vector const & rExpected); + + static void createDiamondPoints(tools::Rectangle rRect, int nOffset, + Point& rPoint1, Point& rPoint2, + Point& rPoint3, Point& rPoint4); + + static void createHorizontalVerticalDiagonalLinePoints(tools::Rectangle rRect, + Point& rHorizontalLinePoint1, Point& rHorizontalLinePoint2, + Point& rVerticalLinePoint1, Point& rVerticalLinePoint2, + Point& rDiagonalLinePoint1, Point& rDiagonalLinePoint2); + // tools + static tools::Rectangle alignToCenter(tools::Rectangle aRect1, tools::Rectangle aRect2); + + static TestResult checkBezier(Bitmap& rBitmap); +}; + +class VCL_DLLPUBLIC OutputDeviceTestBitmap : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestBitmap() = default; + + Bitmap setupDrawTransformedBitmap(); + Bitmap setupDrawBitmap(); + Bitmap setupDrawBitmapExWithAlpha(); + Bitmap setupDrawMask(); + BitmapEx setupDrawBlend(); + + static TestResult checkTransformedBitmap(Bitmap& rBitmap); + static TestResult checkBitmapExWithAlpha(Bitmap& rBitmap); + static TestResult checkMask(Bitmap& rBitmap); + static TestResult checkBlend(BitmapEx& rBitmap); +}; + +class VCL_DLLPUBLIC OutputDeviceTestAnotherOutDev : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestAnotherOutDev() = default; + + Bitmap setupDrawOutDev(); + Bitmap setupXOR(); + + static TestResult checkDrawOutDev(Bitmap& rBitmap); + static TestResult checkXOR(Bitmap& rBitmap); +}; + +class VCL_DLLPUBLIC OutputDeviceTestPixel : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestPixel() = default; + + Bitmap setupRectangle(bool bEnableAA); +}; + +class VCL_DLLPUBLIC OutputDeviceTestLine : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestLine() = default; + + Bitmap setupRectangle(bool bEnableAA); + Bitmap setupDiamond(); + Bitmap setupLines(); + Bitmap setupAALines(); + + Bitmap setupDashedLine(); + static TestResult checkDashedLine(Bitmap& rBitmap); +}; + +class VCL_DLLPUBLIC OutputDeviceTestPolyLine : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestPolyLine() = default; + + Bitmap setupRectangle(bool bEnableAA); + Bitmap setupDiamond(); + Bitmap setupLines(); + Bitmap setupAALines(); +}; + +class VCL_DLLPUBLIC OutputDeviceTestPolyLineB2D : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestPolyLineB2D() = default; + + Bitmap setupRectangle(bool bEnableAA); + Bitmap setupDiamond(); + Bitmap setupBezier(); + Bitmap setupAABezier(); +}; + +class VCL_DLLPUBLIC OutputDeviceTestRect : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestRect() = default; + + Bitmap setupRectangle(bool bEnableAA); + Bitmap setupFilledRectangle(bool useLineColor); + Bitmap setupInvert_NONE(); + Bitmap setupInvert_N50(); + Bitmap setupInvert_TrackFrame(); +}; + +class VCL_DLLPUBLIC OutputDeviceTestPolygon : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestPolygon() = default; + + Bitmap setupRectangle(bool bEnableAA); + Bitmap setupFilledRectangle(bool useLineColor); + Bitmap setupDiamond(); + Bitmap setupLines(); + Bitmap setupAALines(); +}; + +class VCL_DLLPUBLIC OutputDeviceTestPolyPolygon : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestPolyPolygon() = default; + + Bitmap setupRectangle(bool bEnableAA); + Bitmap setupFilledRectangle(bool useLineColor); +}; + +class VCL_DLLPUBLIC OutputDeviceTestPolyPolygonB2D : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestPolyPolygonB2D() = default; + + Bitmap setupRectangle(bool bEnableAA); + Bitmap setupFilledRectangle(bool useLineColor); +}; + +class VCL_DLLPUBLIC OutputDeviceTestGradient : public OutputDeviceTestCommon +{ +public: + OutputDeviceTestGradient() = default; + + Bitmap setupLinearGradient(); + Bitmap setupRadialGradient(); +}; + +class VCL_DLLPUBLIC OutputDeviceTestClip : public OutputDeviceTestCommon +{ +public: + Bitmap setupClipRectangle(); + Bitmap setupClipPolygon(); + Bitmap setupClipPolyPolygon(); + Bitmap setupClipB2DPolyPolygon(); + + static TestResult checkClip(Bitmap& rBitmap); +}; + + +}} // end namespace vcl::test + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3