diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2020-12-28 01:37:59 +1100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-01-13 10:47:01 +0100 |
commit | 19c4014c57c059b08cb7e90d3c9aef9d458fe774 (patch) | |
tree | 9535a35091ad3991c18f0c3b707cf731c92cf60a /vcl/source | |
parent | edb2724623e58cd8c9a5d3a85e8ee5d3858872d5 (diff) |
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@gmail.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/gradient.cxx | 14 | ||||
-rw-r--r-- | vcl/source/outdev/gradient.cxx | 29 |
2 files changed, 17 insertions, 26 deletions
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 ) { |