diff options
Diffstat (limited to 'vcl/backendtest/outputdevice/common.cxx')
-rw-r--r-- | vcl/backendtest/outputdevice/common.cxx | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/vcl/backendtest/outputdevice/common.cxx b/vcl/backendtest/outputdevice/common.cxx index 9e9f67bd9513..8a5b80cb8dec 100644 --- a/vcl/backendtest/outputdevice/common.cxx +++ b/vcl/backendtest/outputdevice/common.cxx @@ -18,6 +18,7 @@ namespace vcl::test { namespace { + int deltaColor(BitmapColor aColor1, BitmapColor aColor2) { int deltaR = std::abs(aColor1.GetRed() - aColor2.GetRed()); @@ -719,6 +720,19 @@ tools::Polygon OutputDeviceTestCommon::createClosedBezierLoop(const tools::Recta return aPolygon; } +basegfx::B2DPolygon OutputDeviceTestCommon::createOpenPolygon(tools::Rectangle& rRect, int nOffset) +{ + int nMidOffset = rRect.GetWidth() / 2; + basegfx::B2DPolygon aPolygon{ + basegfx::B2DPoint(rRect.Left() + nOffset - (nOffset + 1) / 2, rRect.Top() + nOffset - 1), + basegfx::B2DPoint(rRect.Left() + nOffset - (nOffset + 1) / 2, rRect.Bottom() - nOffset + 1), + basegfx::B2DPoint(rRect.Right() - nMidOffset - nOffset / 3, rRect.Bottom() - nOffset + 1), + basegfx::B2DPoint(rRect.Right() - nMidOffset - nOffset / 3, rRect.Top() + nOffset - 1), + }; + aPolygon.setClosed(false); + return aPolygon; +} + TestResult OutputDeviceTestCommon::checkDropShape(Bitmap& rBitmap, bool aEnableAA) { BitmapScopedWriteAccess pAccess(rBitmap); @@ -1095,6 +1109,61 @@ TestResult OutputDeviceTestCommon::checkEvenOddRuleInIntersectingRecs(Bitmap& rB return aReturnValue; } +TestResult OutputDeviceTestCommon::checkOpenPolygon(Bitmap& rBitmap, bool aEnableAA) +{ + std::vector<Color> aExpected = { constBackgroundColor, constLineColor, constLineColor }; + + BitmapScopedWriteAccess pAccess(rBitmap); + + TestResult aResult = TestResult::Passed; + int nNumberOfQuirks = 0; + int nNumberOfErrors = 0; + + for (size_t aLayerNumber = 0; aLayerNumber < aExpected.size(); aLayerNumber++) + { + tools::Long startX = aLayerNumber + 1, endX = pAccess->Width() / 2 - aLayerNumber; + tools::Long startY = aLayerNumber + 2, endY = pAccess->Height() - aLayerNumber - 3; + + for (tools::Long ptX = startX; ptX <= endX; ++ptX) + { + if (aEnableAA) + { + checkValueAA(pAccess, ptX, endY - (aLayerNumber == 2 ? 2 : 0), + aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors); + } + else + { + checkValue(pAccess, ptX, endY - (aLayerNumber == 2 ? 2 : 0), + aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors, true); + } + } + for (tools::Long ptY = startY + (aLayerNumber == 2 ? 2 : 0); + ptY <= endY - (aLayerNumber == 2 ? 2 : 0); ++ptY) + { + if (aEnableAA) + { + checkValueAA(pAccess, startX, ptY, aExpected[aLayerNumber], nNumberOfQuirks, + nNumberOfErrors); + checkValueAA(pAccess, endX, ptY, aExpected[aLayerNumber], nNumberOfQuirks, + nNumberOfErrors); + } + else + { + checkValue(pAccess, startX, ptY, aExpected[aLayerNumber], nNumberOfQuirks, + nNumberOfErrors, true); + checkValue(pAccess, endX, ptY, aExpected[aLayerNumber], nNumberOfQuirks, + nNumberOfErrors, true); + } + } + } + + if (nNumberOfQuirks > 0) + aResult = TestResult::PassedWithQuirks; + if (nNumberOfErrors > 0) + aResult = TestResult::Failed; + return aResult; +} + // Check 'count' pixels from (x,y) in (addX,addY) direction, the color values must not decrease. static bool checkGradient(BitmapScopedWriteAccess& pAccess, int x, int y, int count, int addX, int addY) { |