summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-01-15 12:43:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-01-15 14:33:52 +0100
commit52fece12345161911da2a531213b7d5541192aad (patch)
treefd27e700dc56ca5293e88746dbeed7cc08a57f3a /vcl
parent0a76eb059a77c799e6ce8400c558fc4dd1d866aa (diff)
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@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/canvasbitmaptest.cxx6
-rw-r--r--vcl/source/bitmap/bitmap.cxx2
-rw-r--r--vcl/source/filter/graphicfilter.cxx4
-rw-r--r--vcl/source/gdi/bitmap3.cxx2
-rw-r--r--vcl/source/gdi/bitmapex.cxx16
-rw-r--r--vcl/source/gdi/dibtools.cxx2
-rw-r--r--vcl/source/graphic/UnoGraphicTransformer.cxx6
-rw-r--r--vcl/source/treelist/transfer.cxx4
8 files changed, 20 insertions, 22 deletions
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() );