summaryrefslogtreecommitdiff
path: root/basebmp
diff options
context:
space:
mode:
authorTsahi Glik <tsahi.glik@cloudon.com>2013-06-04 20:25:41 +0200
committerThorsten Behrens <tbehrens@suse.com>2013-06-04 20:38:09 +0200
commit31b35ed6bb7fe77f3f276b00fefce112a620b6ac (patch)
tree4527afa82e6b6eb0a14237881f4cfc97cff96a14 /basebmp
parentc32c11fbd49e0194534be9d21c22da6799728be3 (diff)
Detect copyArea trying to operate on overlapping memory.
Equality test also needs to check if disjunct BitmapDevice instances might not actually share the same memory buffer. Change-Id: I09a93cb092a0039353be211ed053e991e7fe66f0
Diffstat (limited to 'basebmp')
-rw-r--r--basebmp/source/bitmapdevice.cxx13
1 files changed, 9 insertions, 4 deletions
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index d1a19f938d07..ff017ec50e34 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -680,7 +680,7 @@ namespace
destIterRange(begin,
acc,
rDstRect),
- rSrcBitmap.get() == this );
+ isSharedBuffer(rSrcBitmap) );
damaged( rDstRect );
}
@@ -903,7 +903,7 @@ namespace
Masks::clipmask_polarity,
FastMask >::type(acc),
rDstRect),
- rSrcBitmap.get() == this);
+ isSharedBuffer(rSrcBitmap));
damaged( rDstRect );
}
@@ -1147,6 +1147,11 @@ PaletteMemorySharedVector BitmapDevice::getPalette() const
return mpImpl->mpPalette;
}
+bool BitmapDevice::isSharedBuffer( const BitmapDeviceSharedPtr& rOther ) const
+{
+ return rOther.get()->getBuffer().get() == getBuffer().get();
+}
+
void BitmapDevice::clear( Color fillColor )
{
clear_i( fillColor, mpImpl->maBounds );
@@ -1507,7 +1512,7 @@ void BitmapDevice::drawMaskedColor( Color aSrcColor,
assertImagePoint(aDestPoint,mpImpl->maBounds);
assertImageRange(aSrcRange,aSrcBounds);
- if( rAlphaMask.get() == this )
+ if( isSharedBuffer(rAlphaMask) )
{
// src == dest, copy rAlphaMask beforehand
// ---------------------------------------------------
@@ -1560,7 +1565,7 @@ void BitmapDevice::drawMaskedColor( Color aSrcColor,
if( isCompatibleClipMask( rClip ) )
{
- if( rAlphaMask.get() == this )
+ if( isSharedBuffer(rAlphaMask) )
{
// src == dest, copy rAlphaMask beforehand
// ---------------------------------------------------