[Libreoffice-commits] core.git: drawinglayer/source emfio/source filter/source include/vcl sc/source slideshow/source svx/source vcl/qa vcl/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jan 15 13:34:29 UTC 2020
drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx | 12 ++++----
emfio/source/reader/mtftools.cxx | 8 ++---
filter/source/msfilter/mstoolbar.cxx | 6 ++--
include/vcl/bitmap.hxx | 2 -
include/vcl/bitmapex.hxx | 5 +--
sc/source/filter/excel/xiescher.cxx | 2 -
slideshow/source/engine/shapes/gdimtftools.cxx | 6 ++--
svx/source/dialog/_contdlg.cxx | 6 ++--
vcl/qa/cppunit/canvasbitmaptest.cxx | 6 ++--
vcl/source/bitmap/bitmap.cxx | 2 -
vcl/source/filter/graphicfilter.cxx | 4 +-
vcl/source/gdi/bitmap3.cxx | 2 -
vcl/source/gdi/bitmapex.cxx | 16 +++++------
vcl/source/gdi/dibtools.cxx | 2 -
vcl/source/graphic/UnoGraphicTransformer.cxx | 6 +---
vcl/source/treelist/transfer.cxx | 4 --
16 files changed, 43 insertions(+), 46 deletions(-)
New commits:
commit 52fece12345161911da2a531213b7d5541192aad
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jan 15 12:43:19 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jan 15 14:33:52 2020 +0100
tweak GetBitmap methods in BitmapEx
so we return a const& for the normal case, just like other methods,
which reduces copying.
This revealed that CreateDisplayBitmap in Bitmap can be const.
Change-Id: I9f9b9ff0c52d7e95eaae62af152218be8847dd63
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86836
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
index ca607a0145f7..aad16e06165c 100644
--- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
+++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
@@ -261,22 +261,22 @@ namespace drawinglayer
case Disposal::Back:
{
// #i70772# react on no mask, for primitives, too.
- const Bitmap aMask(rAnimationBitmap.maBitmapEx.GetMask());
- const Bitmap aContent(rAnimationBitmap.maBitmapEx.GetBitmap());
+ const Bitmap & rMask(rAnimationBitmap.maBitmapEx.GetMask());
+ const Bitmap & rContent(rAnimationBitmap.maBitmapEx.GetBitmap());
maVirtualDeviceMask->Erase();
- maVirtualDevice->DrawBitmap(rAnimationBitmap.maPositionPixel, aContent);
+ maVirtualDevice->DrawBitmap(rAnimationBitmap.maPositionPixel, rContent);
- if (aMask.IsEmpty())
+ if (rMask.IsEmpty())
{
- const ::tools::Rectangle aRect(rAnimationBitmap.maPositionPixel, aContent.GetSizePixel());
+ const ::tools::Rectangle aRect(rAnimationBitmap.maPositionPixel, rContent.GetSizePixel());
maVirtualDeviceMask->SetFillColor(COL_BLACK);
maVirtualDeviceMask->SetLineColor();
maVirtualDeviceMask->DrawRect(aRect);
}
else
{
- BitmapEx aExpandVisibilityMask(aMask, aMask);
+ BitmapEx aExpandVisibilityMask(rMask, rMask);
maVirtualDeviceMask->DrawBitmapEx(rAnimationBitmap.maPositionPixel, aExpandVisibilityMask);
}
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 669585526918..461109067f66 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -1720,8 +1720,8 @@ namespace emfio
// is inverted
else if ( ( nWinRop == SRCAND ) && ( pSave2->nWinRop == SRCPAINT ) )
{
- Bitmap aMask( pSave->aBmpEx.GetBitmap() );
- BitmapEx aBmpEx( pSave2->aBmpEx.GetBitmap(), aMask );
+ const Bitmap & rMask( pSave->aBmpEx.GetBitmap() );
+ BitmapEx aBmpEx( pSave2->aBmpEx.GetBitmap(), rMask );
ImplDrawBitmap( aPos, aSize, aBmpEx );
bDrawn = true;
i++;
@@ -1729,8 +1729,8 @@ namespace emfio
// tdf#90539
else if ( ( nWinRop == SRCAND ) && ( pSave2->nWinRop == SRCINVERT ) )
{
- Bitmap aMask( pSave->aBmpEx.GetBitmap() );
- BitmapEx aBmpEx( pSave2->aBmpEx.GetBitmap(), aMask );
+ const Bitmap & rMask( pSave->aBmpEx.GetBitmap() );
+ BitmapEx aBmpEx( pSave2->aBmpEx.GetBitmap(), rMask );
ImplDrawBitmap( aPos, aSize, aBmpEx );
bDrawn = true;
i++;
diff --git a/filter/source/msfilter/mstoolbar.cxx b/filter/source/msfilter/mstoolbar.cxx
index ee872866ddb3..ab11ba739ade 100644
--- a/filter/source/msfilter/mstoolbar.cxx
+++ b/filter/source/msfilter/mstoolbar.cxx
@@ -291,14 +291,14 @@ void TBCData::ImportToolBarControl( CustomToolBarImportHelper& helper, std::vect
TBCBitMap* pIconMask = pSpecificInfo->getIconMask();
if (pIconMask)
{
- Bitmap aMaskBase(pIconMask->getBitMap().GetBitmap());
- Size aMaskSize = aMaskBase.GetSizePixel();
+ const Bitmap& rMaskBase(pIconMask->getBitMap().GetBitmap());
+ Size aMaskSize = rMaskBase.GetSizePixel();
if (aMaskSize.Width() && aMaskSize.Height())
{
// according to the spec:
// "the iconMask is white in all the areas in which the icon is
// displayed as transparent and is black in all other areas."
- aBitEx = BitmapEx(aBitEx.GetBitmap(), aMaskBase.CreateMask(COL_WHITE));
+ aBitEx = BitmapEx(aBitEx.GetBitmap(), rMaskBase.CreateMask(COL_WHITE));
}
}
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index 329a40ec6ef1..2b97bded06d1 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -145,7 +145,7 @@ public:
BitmapChecksum GetChecksum() const;
- Bitmap CreateDisplayBitmap( OutputDevice* pDisplay );
+ Bitmap CreateDisplayBitmap( OutputDevice* pDisplay ) const;
static const BitmapPalette&
GetGreyPalette( int nEntries );
diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx
index 1070ff220b47..c2916bf6356d 100644
--- a/include/vcl/bitmapex.hxx
+++ b/include/vcl/bitmapex.hxx
@@ -20,7 +20,6 @@
#ifndef INCLUDED_VCL_BITMAPEX_HXX
#define INCLUDED_VCL_BITMAPEX_HXX
-#include <o3tl/optional.hxx>
#include <vcl/dllapi.h>
#include <vcl/alpha.hxx>
#include <vcl/Scanline.hxx>
@@ -73,9 +72,9 @@ public:
bool IsTransparent() const;
TransparentType GetTransparentType() const { return meTransparent; }
- Bitmap GetBitmap( o3tl::optional<Color> xTransparentReplaceColor = o3tl::optional<Color>() ) const;
+ Bitmap GetBitmap( Color aTransparentReplaceColor ) const;
/// Gives direct access to the contained bitmap.
- const Bitmap& GetBitmapRef() const;
+ const Bitmap& GetBitmap() const;
Bitmap GetMask() const;
bool IsAlpha() const;
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 82e4ac0ddccb..c8478931c4e9 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -749,7 +749,7 @@ void XclImpDrawObjBase::ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillDa
aXOBitmap.SetPixelColor( aPattColor );
aXOBitmap.SetBackgroundColor( aBackColor );
aXOBitmap.Array2Bitmap();
- aBitmap = aXOBitmap.GetBitmap().GetBitmapRef();
+ aBitmap = aXOBitmap.GetBitmap().GetBitmap();
rSdrObj.SetMergedItem(XFillStyleItem(drawing::FillStyle_BITMAP));
rSdrObj.SetMergedItem(XFillBitmapItem(EMPTY_OUSTRING, Graphic(aBitmap)));
diff --git a/slideshow/source/engine/shapes/gdimtftools.cxx b/slideshow/source/engine/shapes/gdimtftools.cxx
index 19ea3d4f51b7..2a7bb51a4ae8 100644
--- a/slideshow/source/engine/shapes/gdimtftools.cxx
+++ b/slideshow/source/engine/shapes/gdimtftools.cxx
@@ -315,14 +315,14 @@ bool getAnimationFromGraphic( VectorOfMtfAnimationFrames& o_rFrames,
{
// #i70772# react on no mask
const Bitmap aMask(rAnimationBitmap.maBitmapEx.GetMask());
- const Bitmap aContent(rAnimationBitmap.maBitmapEx.GetBitmap());
+ const Bitmap & rContent(rAnimationBitmap.maBitmapEx.GetBitmap());
pVDevMask->Erase();
- pVDev->DrawBitmap(rAnimationBitmap.maPositionPixel, aContent);
+ pVDev->DrawBitmap(rAnimationBitmap.maPositionPixel, rContent);
if(aMask.IsEmpty())
{
- const tools::Rectangle aRect(rAnimationBitmap.maPositionPixel, aContent.GetSizePixel());
+ const tools::Rectangle aRect(rAnimationBitmap.maPositionPixel, rContent.GetSizePixel());
pVDevMask->SetFillColor( COL_BLACK);
pVDevMask->SetLineColor();
pVDevMask->DrawRect(aRect);
diff --git a/svx/source/dialog/_contdlg.cxx b/svx/source/dialog/_contdlg.cxx
index 53b22432171b..dcd85e1e75e3 100644
--- a/svx/source/dialog/_contdlg.cxx
+++ b/svx/source/dialog/_contdlg.cxx
@@ -635,10 +635,10 @@ IMPL_LINK( SvxSuperContourDlg, PipetteClickHdl, ContourWindow&, rWnd, void )
if( aGraphic.GetType() == GraphicType::Bitmap )
{
- Bitmap aBmp( aGraphic.GetBitmapEx().GetBitmap() );
+ const Bitmap & rBmp( aGraphic.GetBitmapEx().GetBitmap() );
const long nTol = static_cast<long>(m_xMtfTolerance->get_value(FieldUnit::PERCENT) * 255L / 100L);
- aMask = aBmp.CreateMask( rColor, nTol );
+ aMask = rBmp.CreateMask( rColor, nTol );
if( aGraphic.IsTransparent() )
aMask.CombineSimple( aGraphic.GetBitmapEx().GetMask(), BmpCombine::Or );
@@ -652,7 +652,7 @@ IMPL_LINK( SvxSuperContourDlg, PipetteClickHdl, ContourWindow&, rWnd, void )
aRedoGraphic = Graphic();
aUndoGraphic = aGraphic;
- aGraphic = Graphic( BitmapEx( aBmp, aMask ) );
+ aGraphic = Graphic( BitmapEx( rBmp, aMask ) );
mnGrfChanged++;
bNewContour = (xQBox->run() == RET_YES);
diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx
index 48514580104b..69971210db92 100644
--- a/vcl/qa/cppunit/canvasbitmaptest.cxx
+++ b/vcl/qa/cppunit/canvasbitmaptest.cxx
@@ -711,7 +711,8 @@ void CanvasBitmapTest::runTest()
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have bitcount of 8",
static_cast<sal_uInt16>(8), aBmp.GetBitCount());
{
- BitmapReadAccess* pBmpAcc = aBmp.GetBitmap().AcquireReadAccess();
+ Bitmap aBitmap = aBmp.GetBitmap();
+ BitmapReadAccess* pBmpAcc = aBitmap.AcquireReadAccess();
CPPUNIT_ASSERT_MESSAGE( "Bitmap has invalid BitmapReadAccess",
pBmpAcc );
@@ -738,7 +739,8 @@ void CanvasBitmapTest::runTest()
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap has bitcount of 24",
static_cast<sal_uInt16>(24), aBmp.GetBitCount());
{
- BitmapReadAccess* pBmpAcc = aBmp.GetBitmap().AcquireReadAccess();
+ Bitmap aBitmap = aBmp.GetBitmap();
+ BitmapReadAccess* pBmpAcc = aBitmap.AcquireReadAccess();
BitmapReadAccess* pAlphaAcc = aBmp.GetAlpha().AcquireReadAccess();
CPPUNIT_ASSERT_MESSAGE( "Bitmap has invalid BitmapReadAccess",
diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx
index a24fddf31023..af559769836c 100644
--- a/vcl/source/bitmap/bitmap.cxx
+++ b/vcl/source/bitmap/bitmap.cxx
@@ -845,7 +845,7 @@ bool Bitmap::Expand( sal_uLong nDX, sal_uLong nDY, const Color* pInitColor )
return bRet;
}
-Bitmap Bitmap::CreateDisplayBitmap( OutputDevice* pDisplay )
+Bitmap Bitmap::CreateDisplayBitmap( OutputDevice* pDisplay ) const
{
Bitmap aDispBmp( *this );
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index a0d64ddf2907..20dd734bb30c 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1133,7 +1133,7 @@ void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGra
rContext.m_nStatus = ERRCODE_GRFILTER_FILTERERROR;
else
{
- Bitmap& rBitmap = const_cast<Bitmap&>(rContext.m_pGraphic->GetBitmapExRef().GetBitmapRef());
+ Bitmap& rBitmap = const_cast<Bitmap&>(rContext.m_pGraphic->GetBitmapExRef().GetBitmap());
rContext.m_pAccess = std::make_unique<BitmapScopedWriteAccess>(rBitmap);
rContext.m_pStream->Seek(rContext.m_nStreamBegin);
if (bThreads)
@@ -1616,7 +1616,7 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
nStatus = ERRCODE_GRFILTER_FILTERERROR;
else
{
- Bitmap& rBitmap = const_cast<Bitmap&>(rGraphic.GetBitmapExRef().GetBitmapRef());
+ Bitmap& rBitmap = const_cast<Bitmap&>(rGraphic.GetBitmapExRef().GetBitmap());
BitmapScopedWriteAccess pWriteAccess(rBitmap);
rIStream.Seek(nPosition);
if( !ImportJPEG( rIStream, rGraphic, nImportFlags | GraphicFilterImportFlags::UseExistingBitmap, &pWriteAccess ) )
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index 0ee707089f26..a22f77431257 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -819,7 +819,7 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag n
}
if (bRetval)
- *this = aBmpEx.GetBitmapRef();
+ *this = aBmpEx.GetBitmap();
OSL_ENSURE(!bRetval || nStartCount == GetBitCount(), "Bitmap::Scale has changed the ColorDepth, this should *not* happen (!)");
return bRetval;
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index b8a20fcefe61..2e767e39bc1e 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -228,16 +228,16 @@ bool BitmapEx::IsAlpha() const
return( IsTransparent() && mbAlpha );
}
-const Bitmap& BitmapEx::GetBitmapRef() const
+const Bitmap& BitmapEx::GetBitmap() const
{
return maBitmap;
}
-Bitmap BitmapEx::GetBitmap( o3tl::optional<Color> xTransparentReplaceColor ) const
+Bitmap BitmapEx::GetBitmap( Color aTransparentReplaceColor ) const
{
Bitmap aRetBmp( maBitmap );
- if( xTransparentReplaceColor && ( meTransparent != TransparentType::NONE ) )
+ if( meTransparent != TransparentType::NONE )
{
Bitmap aTempMask;
@@ -247,9 +247,9 @@ Bitmap BitmapEx::GetBitmap( o3tl::optional<Color> xTransparentReplaceColor ) con
aTempMask = maMask;
if( !IsAlpha() )
- aRetBmp.Replace( aTempMask, *xTransparentReplaceColor );
+ aRetBmp.Replace( aTempMask, aTransparentReplaceColor );
else
- aRetBmp.Replace( GetAlpha(), *xTransparentReplaceColor );
+ aRetBmp.Replace( GetAlpha(), aTransparentReplaceColor );
}
return aRetBmp;
@@ -915,7 +915,7 @@ BitmapEx BitmapEx::TransformBitmapEx(
// force destination to 24 bit, we want to smooth output
const Size aDestinationSize(basegfx::fround(fWidth), basegfx::fround(fHeight));
bool bSmooth = implTransformNeedsSmooth(rTransformation);
- const Bitmap aDestination(impTransformBitmap(GetBitmapRef(), aDestinationSize, rTransformation, bSmooth));
+ const Bitmap aDestination(impTransformBitmap(GetBitmap(), aDestinationSize, rTransformation, bSmooth));
// create mask
if(IsTransparent())
@@ -1018,7 +1018,7 @@ BitmapEx BitmapEx::getTransformed(
BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorModifierStack) const
{
- Bitmap aChangedBitmap(GetBitmapRef());
+ Bitmap aChangedBitmap(GetBitmap());
bool bDone(false);
for(sal_uInt32 a(rBColorModifierStack.count()); a && !bDone; )
@@ -1616,7 +1616,7 @@ void BitmapEx::AdjustTransparency(sal_uInt8 cTrans)
}
}
}
- *this = BitmapEx( GetBitmapRef(), aAlpha );
+ *this = BitmapEx( GetBitmap(), aAlpha );
}
// AS: Because JPEGs require the alpha channel provided separately (JPEG does not
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index ce1df4a68a65..6c29bc325397 100644
--- a/vcl/source/gdi/dibtools.cxx
+++ b/vcl/source/gdi/dibtools.cxx
@@ -1865,7 +1865,7 @@ bool WriteDIB(
SvStream& rOStm,
bool bCompressed)
{
- return ImplWriteDIB(rSource.GetBitmapRef(), rOStm, bCompressed, /*bFileHeader*/true);
+ return ImplWriteDIB(rSource.GetBitmap(), rOStm, bCompressed, /*bFileHeader*/true);
}
bool WriteDIBBitmapEx(
diff --git a/vcl/source/graphic/UnoGraphicTransformer.cxx b/vcl/source/graphic/UnoGraphicTransformer.cxx
index 30fd389b9485..2a7f6eef5a42 100644
--- a/vcl/source/graphic/UnoGraphicTransformer.cxx
+++ b/vcl/source/graphic/UnoGraphicTransformer.cxx
@@ -112,13 +112,11 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::applyDuotone(
BitmapEx aBitmapEx( aGraphic.GetBitmapEx() );
AlphaMask aMask( aBitmapEx.GetAlpha() );
- Bitmap aBitmap( aBitmapEx.GetBitmap() );
- BitmapEx aTmpBmpEx(aBitmap);
+ BitmapEx aTmpBmpEx(aBitmapEx.GetBitmap());
BitmapFilter::Filter(aTmpBmpEx, BitmapDuoToneFilter(static_cast<sal_uLong>(nColorOne), static_cast<sal_uLong>(nColorTwo)));
- aBitmap = aTmpBmpEx.GetBitmap();
- aReturnGraphic = ::Graphic( BitmapEx( aBitmap, aMask ) );
+ aReturnGraphic = ::Graphic( BitmapEx( aTmpBmpEx.GetBitmap(), aMask ) );
aReturnGraphic.setOriginURL(aGraphic.getOriginURL());
return aReturnGraphic.GetXGraphic();
}
diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx
index 445e0d2da5aa..6383e43e0c70 100644
--- a/vcl/source/treelist/transfer.cxx
+++ b/vcl/source/treelist/transfer.cxx
@@ -702,10 +702,8 @@ bool TransferableHelper::SetBitmapEx( const BitmapEx& rBitmapEx, const DataFlavo
}
else
{
- const Bitmap aBitmap(rBitmapEx.GetBitmap());
-
// explicitly use Bitmap::Write with bCompressed = sal_False and bFileHeader = sal_True
- WriteDIB(aBitmap, aMemStm, false, true);
+ WriteDIB(rBitmapEx.GetBitmap(), aMemStm, false, true);
}
maAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.TellEnd() );
More information about the Libreoffice-commits
mailing list