summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2021-08-25 17:07:07 +1000
committerMike Kaganski <mike.kaganski@collabora.com>2021-09-07 08:15:00 +0200
commit7ccfae545d7650a7f3e6bc8a010c97cd0a60e9a5 (patch)
treefa6cb2979c90ef935df0c83cfdbbbfcfa4ea00ff /vcl
parente70399e5bd4a41a2989030ddfb0404b6248f655d (diff)
vcl: move OutputDevice rasterop functions to outdev.cxx
Split off RasterOp enum into own header, and also add unit tests for SetRasterOp() and GetRasterOp(). Change-Id: I1c97e87ef2d0684cb15b6ac544597eace5adb48a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121018 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/outdev.cxx21
-rw-r--r--vcl/source/outdev/outdev.cxx22
-rw-r--r--vcl/source/outdev/outdevstate.cxx22
3 files changed, 43 insertions, 22 deletions
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 2df0df7d8a69..0a635a1a139d 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -57,6 +57,7 @@ public:
void testTransparentFont();
void testDefaultRefPoint();
void testRefPoint();
+ void testRasterOp();
void testSystemTextColor();
void testShouldDrawWavePixelAsRect();
void testGetWaveLineSize();
@@ -90,6 +91,7 @@ public:
CPPUNIT_TEST(testTransparentFont);
CPPUNIT_TEST(testDefaultRefPoint);
CPPUNIT_TEST(testRefPoint);
+ CPPUNIT_TEST(testRasterOp);
CPPUNIT_TEST(testSystemTextColor);
CPPUNIT_TEST(testShouldDrawWavePixelAsRect);
CPPUNIT_TEST(testGetWaveLineSize);
@@ -836,6 +838,25 @@ void VclOutdevTest::testRefPoint()
CPPUNIT_ASSERT_EQUAL(Point(10, 20), pRefPointAction->GetRefPoint());
}
+void VclOutdevTest::testRasterOp()
+{
+ ScopedVclPtrInstance<VirtualDevice> pVDev;
+
+ GDIMetaFile aMtf;
+ aMtf.Record(pVDev.get());
+
+ pVDev->SetRasterOp(RasterOp::Invert);
+
+ CPPUNIT_ASSERT_EQUAL(RasterOp::Invert, pVDev->GetRasterOp());
+ CPPUNIT_ASSERT(pVDev->IsLineColor());
+ CPPUNIT_ASSERT(pVDev->IsFillColor());
+
+ MetaAction* pAction = aMtf.GetAction(0);
+ CPPUNIT_ASSERT_EQUAL(MetaActionType::RASTEROP, pAction->GetType());
+ auto pRasterOpAction = static_cast<MetaRasterOpAction*>(pAction);
+ CPPUNIT_ASSERT_EQUAL(RasterOp::Invert, pRasterOpAction->GetRasterOp());
+}
+
void VclOutdevTest::testSystemTextColor()
{
{
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index eaef70931062..1bbfc24cdb4d 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -297,6 +297,7 @@ void OutputDevice::SetRefPoint()
if( mpAlphaVDev )
mpAlphaVDev->SetRefPoint();
}
+
void OutputDevice::SetRefPoint( const Point& rRefPoint )
{
if ( mpMetaFile )
@@ -309,6 +310,27 @@ void OutputDevice::SetRefPoint( const Point& rRefPoint )
mpAlphaVDev->SetRefPoint( rRefPoint );
}
+void OutputDevice::SetRasterOp( RasterOp eRasterOp )
+{
+ if ( mpMetaFile )
+ mpMetaFile->AddAction( new MetaRasterOpAction( eRasterOp ) );
+
+ if ( meRasterOp != eRasterOp )
+ {
+ meRasterOp = eRasterOp;
+ mbInitLineColor = mbInitFillColor = true;
+
+ if( mpGraphics || AcquireGraphics() )
+ {
+ assert(mpGraphics);
+ mpGraphics->SetXORMode( (RasterOp::Invert == meRasterOp) || (RasterOp::Xor == meRasterOp), RasterOp::Invert == meRasterOp );
+ }
+ }
+
+ if( mpAlphaVDev )
+ mpAlphaVDev->SetRasterOp( eRasterOp );
+}
+
sal_uInt16 OutputDevice::GetBitCount() const
{
// we need a graphics instance
diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx
index 7be07f4d81e1..90fe67eccb1a 100644
--- a/vcl/source/outdev/outdevstate.cxx
+++ b/vcl/source/outdev/outdevstate.cxx
@@ -255,26 +255,4 @@ void OutputDevice::SetDigitLanguage( LanguageType eTextLanguage )
mpAlphaVDev->SetDigitLanguage( eTextLanguage );
}
-void OutputDevice::SetRasterOp( RasterOp eRasterOp )
-{
-
- if ( mpMetaFile )
- mpMetaFile->AddAction( new MetaRasterOpAction( eRasterOp ) );
-
- if ( meRasterOp != eRasterOp )
- {
- meRasterOp = eRasterOp;
- mbInitLineColor = mbInitFillColor = true;
-
- if( mpGraphics || AcquireGraphics() )
- {
- assert(mpGraphics);
- mpGraphics->SetXORMode( (RasterOp::Invert == meRasterOp) || (RasterOp::Xor == meRasterOp), RasterOp::Invert == meRasterOp );
- }
- }
-
- if( mpAlphaVDev )
- mpAlphaVDev->SetRasterOp( eRasterOp );
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */