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
This commit is contained in:
Tsahi Glik
2013-06-04 20:25:41 +02:00
committed by Thorsten Behrens
parent c32c11fbd4
commit 31b35ed6bb
2 changed files with 12 additions and 4 deletions

View File

@@ -680,7 +680,7 @@ namespace
destIterRange(begin, destIterRange(begin,
acc, acc,
rDstRect), rDstRect),
rSrcBitmap.get() == this ); isSharedBuffer(rSrcBitmap) );
damaged( rDstRect ); damaged( rDstRect );
} }
@@ -903,7 +903,7 @@ namespace
Masks::clipmask_polarity, Masks::clipmask_polarity,
FastMask >::type(acc), FastMask >::type(acc),
rDstRect), rDstRect),
rSrcBitmap.get() == this); isSharedBuffer(rSrcBitmap));
damaged( rDstRect ); damaged( rDstRect );
} }
@@ -1147,6 +1147,11 @@ PaletteMemorySharedVector BitmapDevice::getPalette() const
return mpImpl->mpPalette; return mpImpl->mpPalette;
} }
bool BitmapDevice::isSharedBuffer( const BitmapDeviceSharedPtr& rOther ) const
{
return rOther.get()->getBuffer().get() == getBuffer().get();
}
void BitmapDevice::clear( Color fillColor ) void BitmapDevice::clear( Color fillColor )
{ {
clear_i( fillColor, mpImpl->maBounds ); clear_i( fillColor, mpImpl->maBounds );
@@ -1507,7 +1512,7 @@ void BitmapDevice::drawMaskedColor( Color aSrcColor,
assertImagePoint(aDestPoint,mpImpl->maBounds); assertImagePoint(aDestPoint,mpImpl->maBounds);
assertImageRange(aSrcRange,aSrcBounds); assertImageRange(aSrcRange,aSrcBounds);
if( rAlphaMask.get() == this ) if( isSharedBuffer(rAlphaMask) )
{ {
// src == dest, copy rAlphaMask beforehand // src == dest, copy rAlphaMask beforehand
// --------------------------------------------------- // ---------------------------------------------------
@@ -1560,7 +1565,7 @@ void BitmapDevice::drawMaskedColor( Color aSrcColor,
if( isCompatibleClipMask( rClip ) ) if( isCompatibleClipMask( rClip ) )
{ {
if( rAlphaMask.get() == this ) if( isSharedBuffer(rAlphaMask) )
{ {
// src == dest, copy rAlphaMask beforehand // src == dest, copy rAlphaMask beforehand
// --------------------------------------------------- // ---------------------------------------------------

View File

@@ -140,6 +140,9 @@ public:
*/ */
PaletteMemorySharedVector getPalette() const; PaletteMemorySharedVector getPalette() const;
/// Check if this and the other BitmapDevice share a buffer
bool isSharedBuffer( const BitmapDeviceSharedPtr& rOther ) const;
/** Clear whole device with given color /** Clear whole device with given color
This method works like a fill with the given color value, This method works like a fill with the given color value,