summaryrefslogtreecommitdiff
path: root/vcl/backendtest/outputdevice
diff options
context:
space:
mode:
authorhomeboy445 <akshitsan13@gmail.com>2021-08-05 19:56:27 +0530
committerTomaž Vajngerl <quikee@gmail.com>2021-10-22 23:54:40 +0200
commitf8bb970fd385c80b085a071da0f8acc119498005 (patch)
tree49189de42799c1066565964e6ccf05bd5909dbb0 /vcl/backendtest/outputdevice
parent5760cba3b276a372d6cccf3f6b6db7fb26c20351 (diff)
backendtest:Reconfigured Rectangle tests to be Asymmetrical
The tests were previously drawing squares in the middle, however, now the tests draws rectangle taking offset from the middle. Change-Id: I26a4af997feac9ced443d7c9b4e3541ea2ba868a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120076 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/backendtest/outputdevice')
-rw-r--r--vcl/backendtest/outputdevice/common.cxx103
-rw-r--r--vcl/backendtest/outputdevice/line.cxx10
-rw-r--r--vcl/backendtest/outputdevice/pixel.cxx11
-rw-r--r--vcl/backendtest/outputdevice/polygon.cxx9
-rw-r--r--vcl/backendtest/outputdevice/polyline.cxx11
-rw-r--r--vcl/backendtest/outputdevice/polyline_b2d.cxx9
-rw-r--r--vcl/backendtest/outputdevice/polypolygon.cxx14
-rw-r--r--vcl/backendtest/outputdevice/polypolygon_b2d.cxx12
-rw-r--r--vcl/backendtest/outputdevice/rectangle.cxx6
9 files changed, 141 insertions, 44 deletions
diff --git a/vcl/backendtest/outputdevice/common.cxx b/vcl/backendtest/outputdevice/common.cxx
index 2aa7de78a294..9e9f67bd9513 100644
--- a/vcl/backendtest/outputdevice/common.cxx
+++ b/vcl/backendtest/outputdevice/common.cxx
@@ -468,25 +468,104 @@ TestResult OutputDeviceTestCommon::checkRectangle(Bitmap& aBitmap)
return checkRectangles(aBitmap, aExpected);
}
-TestResult OutputDeviceTestCommon::checkRectangleAA(Bitmap& aBitmap)
+TestResult OutputDeviceTestCommon::checkRectangles(Bitmap& rBitmap, bool aEnableAA)
{
- std::vector<Color> aExpected
+ BitmapScopedWriteAccess pAccess(rBitmap);
+
+ TestResult aResult = TestResult::Passed;
+ int nNumberOfQuirks = 0;
+ int nNumberOfErrors = 0;
+
+ std::vector<Color> aExpected = { constBackgroundColor, constLineColor, constLineColor };
+
+ for (size_t aLayerNumber = 0; aLayerNumber < aExpected.size(); aLayerNumber++)
{
- constBackgroundColor, constBackgroundColor, constLineColor,
- constBackgroundColor, constBackgroundColor, constLineColor, constBackgroundColor
- };
- return checkRectangles(aBitmap, aExpected);
+ tools::Long startX = aLayerNumber, endX = pAccess->Width() / 2 - aLayerNumber + 1;
+ tools::Long startY = aLayerNumber, endY = pAccess->Height() - aLayerNumber - 1;
+
+ for (tools::Long ptX = startX; ptX <= endX; ++ptX)
+ {
+ if (aEnableAA)
+ {
+ checkValueAA(pAccess, ptX, startY + (aLayerNumber == 2 ? 2 : 0),
+ aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors);
+ checkValueAA(pAccess, ptX, endY - (aLayerNumber == 2 ? 2 : 0),
+ aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors);
+ }
+ else
+ {
+ checkValue(pAccess, ptX, startY + (aLayerNumber == 2 ? 2 : 0),
+ aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors, true);
+ 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;
+}
+
+TestResult OutputDeviceTestCommon::checkRectangleAA(Bitmap& aBitmap)
+{
+ return checkRectangles(aBitmap, true);
}
TestResult OutputDeviceTestCommon::checkFilledRectangle(Bitmap& aBitmap, bool useLineColor)
{
- std::vector<Color> aExpected
+ std::vector<Color> aExpected{ constBackgroundColor,
+ useLineColor ? constLineColor : constFillColor, constFillColor,
+ constFillColor, constFillColor };
+
+ BitmapScopedWriteAccess pAccess(aBitmap);
+
+ TestResult aResult = TestResult::Passed;
+ int nNumberOfQuirks = 0;
+ int nNumberOfErrors = 0;
+
+ for (size_t aLayerNumber = 0; aLayerNumber < aExpected.size(); aLayerNumber++)
{
- constBackgroundColor, constBackgroundColor,
- useLineColor ? constLineColor : constFillColor,
- constFillColor, constFillColor, constFillColor, constFillColor
- };
- return checkRectangles(aBitmap, aExpected);
+ tools::Long startX = aLayerNumber, endX = pAccess->Width() / 2 - aLayerNumber + 1;
+ tools::Long startY = aLayerNumber, endY = pAccess->Height() - aLayerNumber - 1;
+
+ for (tools::Long ptX = startX; ptX <= endX; ++ptX)
+ {
+ checkValue(pAccess, ptX, startY, aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors,
+ true);
+ checkValue(pAccess, ptX, endY, aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors, true);
+ }
+ for (tools::Long ptY = startY; ptY <= endY; ++ptY)
+ {
+ 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;
}
TestResult OutputDeviceTestCommon::checkFilled(Bitmap& rBitmap, tools::Rectangle aRectangle, Color aExpectedColor)
diff --git a/vcl/backendtest/outputdevice/line.cxx b/vcl/backendtest/outputdevice/line.cxx
index ddff80683898..5cb6db10a9af 100644
--- a/vcl/backendtest/outputdevice/line.cxx
+++ b/vcl/backendtest/outputdevice/line.cxx
@@ -22,10 +22,12 @@ namespace
void drawLineOffset(OutputDevice& rDevice, tools::Rectangle const & rRect, int nOffset)
{
- Point aLeftTop (rRect.Left() + nOffset, rRect.Top() + nOffset);
- Point aRightTop (rRect.Right() - nOffset, rRect.Top() + nOffset);
- Point aLeftBottom (rRect.Left() + nOffset, rRect.Bottom() - nOffset);
- Point aRightBottom (rRect.Right() - nOffset, rRect.Bottom() - nOffset);
+
+ int nMidOffset = rRect.GetWidth()/2;
+ Point aLeftTop (rRect.Left() + nOffset - (nOffset+1)/2, rRect.Top() + nOffset - 1);
+ Point aRightTop (rRect.Right() - nMidOffset - nOffset/3, rRect.Top() + nOffset - 1);
+ Point aLeftBottom (rRect.Left() + nOffset - (nOffset+1)/2, rRect.Bottom() - nOffset + 1);
+ Point aRightBottom (rRect.Right() - nMidOffset - nOffset/3, rRect.Bottom() - nOffset + 1);
rDevice.DrawLine(aLeftTop, aRightTop);
rDevice.DrawLine(aRightTop, aRightBottom);
diff --git a/vcl/backendtest/outputdevice/pixel.cxx b/vcl/backendtest/outputdevice/pixel.cxx
index 8801a9e70d35..3892160ef723 100644
--- a/vcl/backendtest/outputdevice/pixel.cxx
+++ b/vcl/backendtest/outputdevice/pixel.cxx
@@ -16,10 +16,11 @@ namespace
{
void drawPixelOffset(OutputDevice& rDevice, tools::Rectangle const& rRect, int nOffset)
{
- for (tools::Long x = 0 + nOffset; x < (rRect.GetWidth() - nOffset); ++x)
+ int nMidOffset = rRect.GetWidth() / 2;
+ for (tools::Long x = 0 + nOffset / 2; x < (rRect.GetWidth() - nMidOffset); ++x)
{
- tools::Long y1 = nOffset;
- tools::Long y2 = rRect.GetHeight() - nOffset - 1;
+ tools::Long y1 = nOffset - 1;
+ tools::Long y2 = rRect.GetHeight() - nOffset;
rDevice.DrawPixel(Point(x, y1));
rDevice.DrawPixel(Point(x, y2));
@@ -27,8 +28,8 @@ void drawPixelOffset(OutputDevice& rDevice, tools::Rectangle const& rRect, int n
for (tools::Long y = 0 + nOffset; y < (rRect.GetHeight() - nOffset); ++y)
{
- tools::Long x1 = nOffset;
- tools::Long x2 = rRect.GetWidth() - nOffset - 1;
+ tools::Long x1 = nOffset / 2;
+ tools::Long x2 = rRect.GetWidth() - nMidOffset - nOffset / std::max((nOffset - 3), 2);
rDevice.DrawPixel(Point(x1, y));
rDevice.DrawPixel(Point(x2, y));
diff --git a/vcl/backendtest/outputdevice/polygon.cxx b/vcl/backendtest/outputdevice/polygon.cxx
index fdc15bc54214..6b52ccabf72c 100644
--- a/vcl/backendtest/outputdevice/polygon.cxx
+++ b/vcl/backendtest/outputdevice/polygon.cxx
@@ -22,10 +22,11 @@ void drawPolygonOffset(OutputDevice& rDevice, tools::Rectangle const& rRect, int
// overlaps when drawing adjacent polygons. Specifying nFix = 1 allows to visually compensate
// for this by making the polygon explicitly larger.
tools::Polygon aPolygon(4);
- aPolygon.SetPoint(Point(rRect.Left() + nOffset, rRect.Top() + nOffset), 0);
- aPolygon.SetPoint(Point(rRect.Right() - nOffset + nFix, rRect.Top() + nOffset), 1);
- aPolygon.SetPoint(Point(rRect.Right() - nOffset + nFix, rRect.Bottom() - nOffset + nFix), 2);
- aPolygon.SetPoint(Point(rRect.Left() + nOffset, rRect.Bottom() - nOffset + nFix), 3);
+ int nMidOffset = rRect.GetWidth() / 2;
+ aPolygon.SetPoint(Point(rRect.Left() + nOffset - (nOffset+1)/2, rRect.Top() + nOffset - 1), 0);
+ aPolygon.SetPoint(Point(rRect.Right() - nMidOffset + nFix - nOffset/3, rRect.Top() + nOffset - 1), 1);
+ aPolygon.SetPoint(Point(rRect.Right() - nMidOffset + nFix - nOffset/3, rRect.Bottom() - nOffset + nFix + 1), 2);
+ aPolygon.SetPoint(Point(rRect.Left() + nOffset - (nOffset+1)/2, rRect.Bottom() - nOffset + nFix + 1), 3);
aPolygon.Optimize(PolyOptimizeFlags::CLOSE);
rDevice.DrawPolygon(aPolygon);
diff --git a/vcl/backendtest/outputdevice/polyline.cxx b/vcl/backendtest/outputdevice/polyline.cxx
index 82450c82d67c..86f9de6306b4 100644
--- a/vcl/backendtest/outputdevice/polyline.cxx
+++ b/vcl/backendtest/outputdevice/polyline.cxx
@@ -21,13 +21,14 @@ namespace
void drawPolyLineOffset(OutputDevice& rDevice, tools::Rectangle const & rRect, int nOffset)
{
tools::Polygon aPolygon(4);
- aPolygon.SetPoint(Point(rRect.Left() + nOffset, rRect.Top() + nOffset), 0);
- aPolygon.SetPoint(Point(rRect.Right() - nOffset, rRect.Top() + nOffset), 1);
- aPolygon.SetPoint(Point(rRect.Right() - nOffset, rRect.Bottom() - nOffset), 2);
- aPolygon.SetPoint(Point(rRect.Left() + nOffset, rRect.Bottom() - nOffset), 3);
+ int nMidOffset = rRect.GetWidth() / 2;
+ aPolygon.SetPoint(Point(rRect.Left() + nOffset - (nOffset+1)/2, rRect.Top() + nOffset - 1), 0);
+ aPolygon.SetPoint(Point(rRect.Right() - nMidOffset - nOffset/3, rRect.Top() + nOffset - 1), 1);
+ aPolygon.SetPoint(Point(rRect.Right() - nMidOffset - nOffset/3, rRect.Bottom() - nOffset + 1), 2);
+ aPolygon.SetPoint(Point(rRect.Left() + nOffset - (nOffset+1)/2, rRect.Bottom() - nOffset + 1), 3);
aPolygon.Optimize(PolyOptimizeFlags::CLOSE);
- rDevice.DrawPolyLine(aPolygon);
+ rDevice.DrawPolygon(aPolygon);
}
} // end anonymous namespace
diff --git a/vcl/backendtest/outputdevice/polyline_b2d.cxx b/vcl/backendtest/outputdevice/polyline_b2d.cxx
index 9204188b6f58..cef4c6e66aeb 100644
--- a/vcl/backendtest/outputdevice/polyline_b2d.cxx
+++ b/vcl/backendtest/outputdevice/polyline_b2d.cxx
@@ -17,11 +17,12 @@ namespace
{
void drawPolyLineOffset(OutputDevice& rDevice, tools::Rectangle const& rRect, int nOffset)
{
+ int nMidOffset = rRect.GetWidth() / 2;
basegfx::B2DPolygon aPolygon{
- basegfx::B2DPoint(rRect.Left() + nOffset, rRect.Top() + nOffset),
- basegfx::B2DPoint(rRect.Right() - nOffset, rRect.Top() + nOffset),
- basegfx::B2DPoint(rRect.Right() - nOffset, rRect.Bottom() - nOffset),
- basegfx::B2DPoint(rRect.Left() + nOffset, rRect.Bottom() - nOffset),
+ basegfx::B2DPoint(rRect.Left() + nOffset - (nOffset + 1) / 2, rRect.Top() + nOffset - 1),
+ basegfx::B2DPoint(rRect.Right() - nMidOffset - nOffset / 3, rRect.Top() + nOffset - 1),
+ basegfx::B2DPoint(rRect.Right() - nMidOffset - nOffset / 3, rRect.Bottom() - nOffset + 1),
+ basegfx::B2DPoint(rRect.Left() + nOffset - (nOffset + 1) / 2, rRect.Bottom() - nOffset + 1),
};
aPolygon.setClosed(true);
diff --git a/vcl/backendtest/outputdevice/polypolygon.cxx b/vcl/backendtest/outputdevice/polypolygon.cxx
index 4233e997bef4..8c96f2d33447 100644
--- a/vcl/backendtest/outputdevice/polypolygon.cxx
+++ b/vcl/backendtest/outputdevice/polypolygon.cxx
@@ -21,10 +21,16 @@ tools::Polygon createPolygonOffset(tools::Rectangle const& rRect, int nOffset, i
// overlaps when drawing adjacent polygons. Specifying nFix = 1 allows to visually compensate
// for this by making the polygon explicitly larger.
tools::Polygon aPolygon(4);
- aPolygon.SetPoint(Point(rRect.Left() + nOffset, rRect.Top() + nOffset), 0);
- aPolygon.SetPoint(Point(rRect.Right() - nOffset + nFix, rRect.Top() + nOffset), 1);
- aPolygon.SetPoint(Point(rRect.Right() - nOffset + nFix, rRect.Bottom() - nOffset + nFix), 2);
- aPolygon.SetPoint(Point(rRect.Left() + nOffset, rRect.Bottom() - nOffset + nFix), 3);
+ int nMidOffset = rRect.GetWidth() / 2;
+ aPolygon.SetPoint(Point(rRect.Left() + nOffset - (nOffset + 1) / 2, rRect.Top() + nOffset - 1),
+ 0);
+ aPolygon.SetPoint(
+ Point(rRect.Right() - nMidOffset + nFix - nOffset / 3, rRect.Top() + nOffset - 1), 1);
+ aPolygon.SetPoint(
+ Point(rRect.Right() - nMidOffset + nFix - nOffset / 3, rRect.Bottom() - nOffset + nFix + 1),
+ 2);
+ aPolygon.SetPoint(
+ Point(rRect.Left() + nOffset - (nOffset + 1) / 2, rRect.Bottom() - nOffset + nFix + 1), 3);
aPolygon.Optimize(PolyOptimizeFlags::CLOSE);
return aPolygon;
}
diff --git a/vcl/backendtest/outputdevice/polypolygon_b2d.cxx b/vcl/backendtest/outputdevice/polypolygon_b2d.cxx
index 5695920a4a32..432fc429b6e5 100644
--- a/vcl/backendtest/outputdevice/polypolygon_b2d.cxx
+++ b/vcl/backendtest/outputdevice/polypolygon_b2d.cxx
@@ -20,11 +20,15 @@ basegfx::B2DPolygon createPolygonOffset(tools::Rectangle const& rRect, int nOffs
// filling polygons always skips the right-most and bottom-most pixels, in order to avoid
// overlaps when drawing adjacent polygons. Specifying nFix = 1 allows to visually compensate
// for this by making the polygon explicitly larger.
+ int nMidOffset = rRect.GetWidth() / 2;
basegfx::B2DPolygon aPolygon{
- basegfx::B2DPoint(rRect.Left() + nOffset, rRect.Top() + nOffset),
- basegfx::B2DPoint(rRect.Right() - nOffset + nFix, rRect.Top() + nOffset),
- basegfx::B2DPoint(rRect.Right() - nOffset + nFix, rRect.Bottom() - nOffset + nFix),
- basegfx::B2DPoint(rRect.Left() + nOffset, rRect.Bottom() - nOffset + nFix),
+ basegfx::B2DPoint(rRect.Left() + nOffset - (nOffset + 1) / 2, rRect.Top() + nOffset - 1),
+ basegfx::B2DPoint(rRect.Right() - nMidOffset - nOffset / 3 + nFix,
+ rRect.Top() + nOffset - 1),
+ basegfx::B2DPoint(rRect.Right() - nMidOffset - nOffset / 3 + nFix,
+ rRect.Bottom() - nOffset + 1 + nFix),
+ basegfx::B2DPoint(rRect.Left() + nOffset - (nOffset + 1) / 2,
+ rRect.Bottom() - nOffset + 1 + nFix),
};
aPolygon.setClosed(true);
return aPolygon;
diff --git a/vcl/backendtest/outputdevice/rectangle.cxx b/vcl/backendtest/outputdevice/rectangle.cxx
index d202687d35e8..f35285f28220 100644
--- a/vcl/backendtest/outputdevice/rectangle.cxx
+++ b/vcl/backendtest/outputdevice/rectangle.cxx
@@ -16,8 +16,10 @@ namespace
{
void drawRectOffset(OutputDevice& rDevice, tools::Rectangle const& rRect, int nOffset)
{
- rDevice.DrawRect(tools::Rectangle(rRect.Left() + nOffset, rRect.Top() + nOffset,
- rRect.Right() - nOffset, rRect.Bottom() - 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,