[Libreoffice-commits] core.git: include/vcl toolkit/inc vcl/qa vcl/source
Chris Sherlock (via logerrit)
logerrit at kemper.freedesktop.org
Tue Sep 7 06:15:32 UTC 2021
include/vcl/metaact.hxx | 23 ++++++++++++++---------
include/vcl/outdev.hxx | 1 +
include/vcl/outdevstate.hxx | 1 +
include/vcl/rendercontext/RasterOp.hxx | 31 +++++++++++++++++++++++++++++++
include/vcl/vclenum.hxx | 2 --
toolkit/inc/awt/vclxgraphics.hxx | 15 ++++++++-------
vcl/qa/cppunit/outdev.cxx | 21 +++++++++++++++++++++
vcl/source/outdev/outdev.cxx | 22 ++++++++++++++++++++++
vcl/source/outdev/outdevstate.cxx | 22 ----------------------
9 files changed, 98 insertions(+), 40 deletions(-)
New commits:
commit 7ccfae545d7650a7f3e6bc8a010c97cd0a60e9a5
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Wed Aug 25 17:07:07 2021 +1000
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Sep 7 08:15:00 2021 +0200
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 at collabora.com>
diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx
index 4cb1036edd4d..38390ec9b9f5 100644
--- a/include/vcl/metaact.hxx
+++ b/include/vcl/metaact.hxx
@@ -21,22 +21,27 @@
#define INCLUDED_VCL_METAACT_HXX
#include <config_options.h>
-#include <memory>
+
+#include <rtl/ref.hxx>
+#include <salhelper/simplereferenceobject.hxx>
+#include <tools/poly.hxx>
+
#include <vcl/dllapi.h>
-#include <vcl/gradient.hxx>
-#include <vcl/hatch.hxx>
-#include <vcl/wall.hxx>
+#include <vcl/bitmapex.hxx>
#include <vcl/font.hxx>
-#include <tools/poly.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/region.hxx>
-#include <vcl/outdevstate.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/gfxlink.hxx>
+#include <vcl/gradient.hxx>
+#include <vcl/hatch.hxx>
#include <vcl/lineinfo.hxx>
#include <vcl/metaactiontypes.hxx>
-#include <salhelper/simplereferenceobject.hxx>
-#include <rtl/ref.hxx>
+#include <vcl/outdevstate.hxx>
+#include <vcl/region.hxx>
+#include <vcl/rendercontext/RasterOp.hxx>
+#include <vcl/wall.hxx>
+
+#include <memory>
class OutputDevice;
class SvStream;
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 6bf789793af6..23b70e5599c7 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -41,6 +41,7 @@
#include <vcl/rendercontext/GetDefaultFontFlags.hxx>
#include <vcl/rendercontext/ImplMapRes.hxx>
#include <vcl/rendercontext/InvertFlags.hxx>
+#include <vcl/rendercontext/RasterOp.hxx>
#include <vcl/rendercontext/SalLayoutFlags.hxx>
#include <vcl/mapmod.hxx>
#include <vcl/wall.hxx>
diff --git a/include/vcl/outdevstate.hxx b/include/vcl/outdevstate.hxx
index e058ad7dd45d..60d12ac523f5 100644
--- a/include/vcl/outdevstate.hxx
+++ b/include/vcl/outdevstate.hxx
@@ -25,6 +25,7 @@
#include <i18nlangtag/lang.h>
#include <o3tl/typed_flags_set.hxx>
+#include <vcl/rendercontext/RasterOp.hxx>
#include <vcl/font.hxx>
#include <vcl/mapmod.hxx>
#include <vcl/region.hxx>
diff --git a/include/vcl/rendercontext/RasterOp.hxx b/include/vcl/rendercontext/RasterOp.hxx
new file mode 100644
index 000000000000..44b2a6c03a17
--- /dev/null
+++ b/include/vcl/rendercontext/RasterOp.hxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+enum class RasterOp
+{
+ OverPaint,
+ Xor,
+ N0,
+ N1,
+ Invert
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/vcl/vclenum.hxx b/include/vcl/vclenum.hxx
index d18bfc70e5f0..eebefc92ce1b 100644
--- a/include/vcl/vclenum.hxx
+++ b/include/vcl/vclenum.hxx
@@ -189,8 +189,6 @@ enum class LineStyle
FORCE_EQUAL_SIZE = SAL_MAX_ENUM
};
-enum class RasterOp { OverPaint, Xor, N0, N1, Invert };
-
typedef sal_uInt32 sal_UCS4; // TODO: this should be moved to rtl
enum class OutDevSupportType { TransparentRect, B2DDraw };
diff --git a/toolkit/inc/awt/vclxgraphics.hxx b/toolkit/inc/awt/vclxgraphics.hxx
index 3ab8b59b8b2b..68902084ff24 100644
--- a/toolkit/inc/awt/vclxgraphics.hxx
+++ b/toolkit/inc/awt/vclxgraphics.hxx
@@ -19,18 +19,19 @@
#pragma once
-
-#include <com/sun/star/awt/XGraphics2.hpp>
-#include <com/sun/star/lang/XTypeProvider.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/implbase.hxx>
-
-#include <vcl/font.hxx>
#include <tools/color.hxx>
+#include <o3tl/typed_flags_set.hxx>
+#include <vcl/font.hxx>
+#include <vcl/rendercontext/RasterOp.hxx>
#include <vcl/vclenum.hxx>
#include <vcl/vclptr.hxx>
-#include <o3tl/typed_flags_set.hxx>
+
+#include <com/sun/star/awt/XGraphics2.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+
#include <memory>
class OutputDevice;
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: */
More information about the Libreoffice-commits
mailing list