summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2021-12-14 19:09:39 +1100
committerTomaž Vajngerl <quikee@gmail.com>2021-12-27 03:47:28 +0100
commit1de7e1f4640bad725626b574b33eb2db9244f378 (patch)
treebbc37c51753b8f9f8f830d88e79b75686464cc8f /vcl/qa/cppunit
parent06230ac3a62c1cc4012e4d8d0a76f9db356911a9 (diff)
vcl: remove unnecessary actions from DrawGradientToMetafile()
It turns out, we never actually needed to decompose the gradient into seperate actions in DrawGradientToMetafile(). We still need this for AddGradientActions() however. Update tests and add new ones for AddGradientActions(). Change-Id: I2115da8e7d1efa5bcd2a8f4f00d9678216549e4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126846 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa/cppunit')
-rw-r--r--vcl/qa/cppunit/outdev.cxx112
1 files changed, 101 insertions, 11 deletions
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 469a24521643..dc2ea8ad2ed2 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -10,6 +10,7 @@
#include <test/bootstrapfixture.hxx>
#include <test/outputdevice.hxx>
+#include <sal/log.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/numeric/ftools.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
@@ -93,9 +94,12 @@ public:
void testDrawGradient_drawmode();
void testDrawGradient_rect_linear();
void testDrawGradient_rect_axial();
+ void testAddGradientActions_rect_linear();
+ void testAddGradientActions_rect_axial();
void testDrawGradient_polygon_linear();
void testDrawGradient_polygon_axial();
void testDrawGradient_rect_complex();
+ void testAddGradientActions_rect_complex();
CPPUNIT_TEST_SUITE(VclOutdevTest);
CPPUNIT_TEST(testVirtualDevice);
@@ -152,9 +156,12 @@ public:
CPPUNIT_TEST(testDrawGradient_drawmode);
CPPUNIT_TEST(testDrawGradient_rect_linear);
CPPUNIT_TEST(testDrawGradient_rect_axial);
+ CPPUNIT_TEST(testAddGradientActions_rect_linear);
+ CPPUNIT_TEST(testAddGradientActions_rect_axial);
CPPUNIT_TEST(testDrawGradient_polygon_linear);
CPPUNIT_TEST(testDrawGradient_polygon_axial);
CPPUNIT_TEST(testDrawGradient_rect_complex);
+ CPPUNIT_TEST(testAddGradientActions_rect_complex);
CPPUNIT_TEST_SUITE_END();
};
@@ -2135,12 +2142,12 @@ static size_t TestLinearStripes(GDIMetaFile& rMtf, size_t nTimes, size_t nIndex)
{
nIndex++;
MetaAction* pAction = rMtf.GetAction(nIndex);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action", MetaActionType::FILLCOLOR,
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action (start)", MetaActionType::FILLCOLOR,
pAction->GetType());
nIndex++;
pAction = rMtf.GetAction(nIndex);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polygon action", MetaActionType::POLYGON,
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polygon action (start)", MetaActionType::POLYGON,
pAction->GetType());
for (size_t i = 0; i < nTimes - 1; i++)
@@ -2158,12 +2165,12 @@ static size_t TestLinearStripes(GDIMetaFile& rMtf, size_t nTimes, size_t nIndex)
nIndex++;
pAction = rMtf.GetAction(nIndex);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action", MetaActionType::FILLCOLOR,
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action (end)", MetaActionType::FILLCOLOR,
pAction->GetType());
nIndex++;
pAction = rMtf.GetAction(nIndex);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polygon action", MetaActionType::POLYGON,
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polygon action (end)", MetaActionType::POLYGON,
pAction->GetType());
return nIndex;
@@ -2236,6 +2243,35 @@ void VclOutdevTest::testDrawGradient_rect_linear()
MetaAction* pAction = aMtf.GetAction(nIndex);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a gradient action (rectangle area)", MetaActionType::GRADIENT,
pAction->GetType());
+}
+
+void VclOutdevTest::testAddGradientActions_rect_linear()
+{
+ ScopedVclPtrInstance<VirtualDevice> pVDev;
+ GDIMetaFile aMtf;
+
+ tools::Rectangle aRect(Point(10, 10), Size(40, 40));
+ pVDev->SetOutputSizePixel(Size(100, 100));
+
+ Gradient aGradient(GradientStyle::Linear, COL_RED, COL_WHITE);
+ aGradient.SetBorder(100);
+
+ pVDev->AddGradientActions(aRect, aGradient, aMtf);
+
+ size_t nIndex = 0;
+
+ MetaAction* pAction = aMtf.GetAction(nIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a push action", MetaActionType::PUSH, pAction->GetType());
+
+ nIndex++;
+ pAction = aMtf.GetAction(nIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rectangular intersect clip action",
+ MetaActionType::ISECTRECTCLIPREGION, pAction->GetType());
+
+ nIndex++;
+ pAction = aMtf.GetAction(nIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line color action", MetaActionType::LINECOLOR,
+ pAction->GetType());
TestLinearStripes(aMtf, 3, nIndex);
}
@@ -2259,6 +2295,35 @@ void VclOutdevTest::testDrawGradient_rect_axial()
MetaAction* pAction = aMtf.GetAction(nIndex);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a gradient action (rectangle area)", MetaActionType::GRADIENT,
pAction->GetType());
+}
+
+void VclOutdevTest::testAddGradientActions_rect_axial()
+{
+ ScopedVclPtrInstance<VirtualDevice> pVDev;
+ GDIMetaFile aMtf;
+
+ tools::Rectangle aRect(Point(10, 10), Size(40, 40));
+ pVDev->SetOutputSizePixel(Size(100, 100));
+
+ Gradient aGradient(GradientStyle::Axial, COL_RED, COL_WHITE);
+ aGradient.SetBorder(100);
+
+ pVDev->AddGradientActions(aRect, aGradient, aMtf);
+
+ size_t nIndex = 0;
+
+ MetaAction* pAction = aMtf.GetAction(nIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a push action", MetaActionType::PUSH, pAction->GetType());
+
+ nIndex++;
+ pAction = aMtf.GetAction(nIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rectangular intersect clip action",
+ MetaActionType::ISECTRECTCLIPREGION, pAction->GetType());
+
+ nIndex++;
+ pAction = aMtf.GetAction(nIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line color action", MetaActionType::LINECOLOR,
+ pAction->GetType());
TestAxialStripes(aMtf, 3, nIndex);
}
@@ -2278,9 +2343,7 @@ void VclOutdevTest::testDrawGradient_polygon_linear()
pVDev->DrawGradient(aPolyPolygon, aGradient);
- size_t nIndex = ClipGradientTest(aMtf, INITIAL_SETUP_ACTION_COUNT);
-
- TestLinearStripes(aMtf, 3, nIndex);
+ ClipGradientTest(aMtf, INITIAL_SETUP_ACTION_COUNT);
}
void VclOutdevTest::testDrawGradient_polygon_axial()
@@ -2298,9 +2361,7 @@ void VclOutdevTest::testDrawGradient_polygon_axial()
pVDev->DrawGradient(aPolyPolygon, aGradient);
- size_t nIndex = ClipGradientTest(aMtf, INITIAL_SETUP_ACTION_COUNT);
-
- TestAxialStripes(aMtf, 3, nIndex);
+ ClipGradientTest(aMtf, INITIAL_SETUP_ACTION_COUNT);
}
static size_t TestComplexStripes(GDIMetaFile& rMtf, size_t nTimes, size_t nIndex)
@@ -2354,8 +2415,37 @@ void VclOutdevTest::testDrawGradient_rect_complex()
MetaAction* pAction = aMtf.GetAction(nIndex);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a gradient action (rectangle area)", MetaActionType::GRADIENT,
pAction->GetType());
+}
+
+void VclOutdevTest::testAddGradientActions_rect_complex()
+{
+ ScopedVclPtrInstance<VirtualDevice> pVDev;
+ GDIMetaFile aMtf;
+
+ tools::Rectangle aRect(Point(10, 10), Size(40, 40));
+ pVDev->SetOutputSizePixel(Size(1000, 1000));
+
+ Gradient aGradient(GradientStyle::Square, COL_RED, COL_WHITE);
+ aGradient.SetBorder(10);
+
+ pVDev->AddGradientActions(aRect, aGradient, aMtf);
+
+ size_t nIndex = 0;
+
+ MetaAction* pAction = aMtf.GetAction(nIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a push action", MetaActionType::PUSH, pAction->GetType());
+
+ nIndex++;
+ pAction = aMtf.GetAction(nIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rectangular intersect clip action",
+ MetaActionType::ISECTRECTCLIPREGION, pAction->GetType());
+
+ nIndex++;
+ pAction = aMtf.GetAction(nIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line color action", MetaActionType::LINECOLOR,
+ pAction->GetType());
- nIndex = TestComplexStripes(aMtf, 40, nIndex);
+ TestComplexStripes(aMtf, 40, nIndex);
}
CPPUNIT_TEST_SUITE_REGISTRATION(VclOutdevTest);