Kaydet (Commit) 3843a568 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

hidpi: Image is reference counted.

No need no schuffle with pointers to avoid copying :-)

Change-Id: I62757214db65af856e0c79f662d15938c0e9a675
üst 56d1b1cb
...@@ -1343,18 +1343,17 @@ void* ToolBox::GetItemData( sal_uInt16 nItemId ) const ...@@ -1343,18 +1343,17 @@ void* ToolBox::GetItemData( sal_uInt16 nItemId ) const
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rInputImage ) void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rImage )
{ {
sal_uInt16 nPos = GetItemPos( nItemId ); sal_uInt16 nPos = GetItemPos( nItemId );
if ( nPos != TOOLBOX_ITEM_NOTFOUND ) if ( nPos != TOOLBOX_ITEM_NOTFOUND )
{ {
const Image* pImage = &rInputImage; // Use the pointer to avoid unnecessary copying Image aImage(rImage);
Image aImage; // But we still need to keep the modified image alive if created.
if ( GetDPIScaleFactor() > 1) if ( GetDPIScaleFactor() > 1)
{ {
BitmapEx aBitmap = rInputImage.GetBitmapEx(); BitmapEx aBitmap(aImage.GetBitmapEx());
// Some code calls this twice, so add a sanity check // Some code calls this twice, so add a sanity check
// FIXME find out what that code is & fix accordingly // FIXME find out what that code is & fix accordingly
...@@ -1362,7 +1361,6 @@ void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rInputImage ) ...@@ -1362,7 +1361,6 @@ void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rInputImage )
{ {
aBitmap.Scale(GetDPIScaleFactor(), GetDPIScaleFactor()); aBitmap.Scale(GetDPIScaleFactor(), GetDPIScaleFactor());
aImage = Image(aBitmap); aImage = Image(aBitmap);
pImage = &aImage;
} }
} }
...@@ -1371,14 +1369,14 @@ void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rInputImage ) ...@@ -1371,14 +1369,14 @@ void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rInputImage )
if ( !mbCalc ) if ( !mbCalc )
{ {
Size aOldSize = pItem->maImage.GetSizePixel(); Size aOldSize = pItem->maImage.GetSizePixel();
pItem->maImage = *pImage; pItem->maImage = aImage;
if ( aOldSize != pItem->maImage.GetSizePixel() ) if ( aOldSize != pItem->maImage.GetSizePixel() )
ImplInvalidate( sal_True ); ImplInvalidate( sal_True );
else else
ImplUpdateItem( nPos ); ImplUpdateItem( nPos );
} }
else else
pItem->maImage = *pImage; pItem->maImage = aImage;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment