[Libreoffice-commits] core.git: include/vcl vcl/source
Chris Sherlock (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jan 13 09:47:51 UTC 2021
include/vcl/gradient.hxx | 13 +++++++------
include/vcl/outdev.hxx | 1 -
vcl/source/gdi/gradient.cxx | 14 ++++++++++++++
vcl/source/outdev/gradient.cxx | 29 +++--------------------------
4 files changed, 24 insertions(+), 33 deletions(-)
New commits:
commit 19c4014c57c059b08cb7e90d3c9aef9d458fe774
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Mon Dec 28 01:37:59 2020 +1100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Jan 13 10:47:01 2021 +0100
vcl: migrate OutputDevice::SetGrayscaleColors() to Gradient::MakeGrayscale()
Change-Id: I125ad3db3ee30833022113da5d78dcf81d0f7edc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108374
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/vcl/gradient.hxx b/include/vcl/gradient.hxx
index f2336d797703..59956138033b 100644
--- a/include/vcl/gradient.hxx
+++ b/include/vcl/gradient.hxx
@@ -56,24 +56,25 @@ public:
const Color& GetStartColor() const;
void SetEndColor( const Color& rColor );
const Color& GetEndColor() const;
+ void MakeGrayscale();
void SetAngle( Degree10 nAngle );
Degree10 GetAngle() const;
void SetBorder( sal_uInt16 nBorder );
- sal_uInt16 GetBorder() const;
+ sal_uInt16 GetBorder() const;
void SetOfsX( sal_uInt16 nOfsX );
- sal_uInt16 GetOfsX() const;
+ sal_uInt16 GetOfsX() const;
void SetOfsY( sal_uInt16 nOfsY );
- sal_uInt16 GetOfsY() const;
+ sal_uInt16 GetOfsY() const;
void SetStartIntensity( sal_uInt16 nIntens );
- sal_uInt16 GetStartIntensity() const;
+ sal_uInt16 GetStartIntensity() const;
void SetEndIntensity( sal_uInt16 nIntens );
- sal_uInt16 GetEndIntensity() const;
+ sal_uInt16 GetEndIntensity() const;
void SetSteps( sal_uInt16 nSteps );
- sal_uInt16 GetSteps() const;
+ sal_uInt16 GetSteps() const;
void GetBoundRect( const tools::Rectangle& rRect, tools::Rectangle &rBoundRect, Point& rCenter ) const;
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index b5885f4b2de2..a989522ec7b5 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -933,7 +933,6 @@ private:
SAL_DLLPRIVATE tools::Long GetGradientSteps( const Gradient& rGradient, const tools::Rectangle& rRect, bool bMtf, bool bComplex=false );
SAL_DLLPRIVATE Color GetSingleColorGradientFill();
- SAL_DLLPRIVATE void SetGrayscaleColors( Gradient &rGradient );
///@}
diff --git a/vcl/source/gdi/gradient.cxx b/vcl/source/gdi/gradient.cxx
index a3014abda46d..40a4f94d7204 100644
--- a/vcl/source/gdi/gradient.cxx
+++ b/vcl/source/gdi/gradient.cxx
@@ -273,6 +273,20 @@ void Gradient::GetBoundRect( const tools::Rectangle& rRect, tools::Rectangle& rB
}
}
+void Gradient::MakeGrayscale()
+{
+ Color aStartCol(GetStartColor());
+ Color aEndCol(GetEndColor());
+ sal_uInt8 cStartLum = aStartCol.GetLuminance();
+ sal_uInt8 cEndLum = aEndCol.GetLuminance();
+
+ aStartCol = Color(cStartLum, cStartLum, cStartLum);
+ aEndCol = Color(cEndLum, cEndLum, cEndLum);
+
+ SetStartColor(aStartCol);
+ SetEndColor(aEndCol);
+}
+
Gradient& Gradient::operator=( const Gradient& ) = default;
Gradient& Gradient::operator=( Gradient&& ) = default;
diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx
index c6940d8b5965..3ba80a0cdc2b 100644
--- a/vcl/source/outdev/gradient.cxx
+++ b/vcl/source/outdev/gradient.cxx
@@ -71,9 +71,7 @@ void OutputDevice::DrawGradient( const tools::PolyPolygon& rPolyPoly,
Gradient aGradient( rGradient );
if ( mnDrawMode & DrawModeFlags::GrayGradient )
- {
- SetGrayscaleColors( aGradient );
- }
+ aGradient.MakeGrayscale();
DrawGradientToMetafile( rPolyPoly, rGradient );
@@ -187,10 +185,8 @@ void OutputDevice::DrawGradientToMetafile ( const tools::PolyPolygon& rPolyPoly,
Gradient aGradient( rGradient );
- if ( mnDrawMode & DrawModeFlags::GrayGradient )
- {
- SetGrayscaleColors( aGradient );
- }
+ if (mnDrawMode & DrawModeFlags::GrayGradient)
+ aGradient.MakeGrayscale();
const tools::Rectangle aBoundRect( rPolyPoly.GetBoundRect() );
@@ -988,25 +984,6 @@ Color OutputDevice::GetSingleColorGradientFill()
return aColor;
}
-void OutputDevice::SetGrayscaleColors( Gradient &rGradient )
-{
- // this should only be called with the drawing mode is for grayscale gradients
- assert ( mnDrawMode & DrawModeFlags::GrayGradient );
-
- Color aStartCol( rGradient.GetStartColor() );
- Color aEndCol( rGradient.GetEndColor() );
-
- if ( mnDrawMode & DrawModeFlags::GrayGradient )
- {
- sal_uInt8 cStartLum = aStartCol.GetLuminance(), cEndLum = aEndCol.GetLuminance();
- aStartCol = Color( cStartLum, cStartLum, cStartLum );
- aEndCol = Color( cEndLum, cEndLum, cEndLum );
- }
-
- rGradient.SetStartColor( aStartCol );
- rGradient.SetEndColor( aEndCol );
-}
-
void OutputDevice::AddGradientActions( const tools::Rectangle& rRect, const Gradient& rGradient,
GDIMetaFile& rMtf )
{
More information about the Libreoffice-commits
mailing list