summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-07-10 10:37:08 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-07-10 10:37:24 +0200
commitf136890dc01260bde611b4c121ddf119281cf5b4 (patch)
treeca50d042c8c2b54b614e50abc877aadb36d4930b
parente842914ae3ec6109e889cfc4d0387192a68d2907 (diff)
Clean up AlphaMask::CopyPixel "override" hack
...that required undefined downcasts of Bitmap objects that are not actually AlphaMasks. Change-Id: I629f4a81d40a2a85cd877ffec13445786ef58187
-rw-r--r--include/vcl/alpha.hxx3
-rw-r--r--include/vcl/bitmap.hxx3
-rw-r--r--vcl/source/gdi/alpha.cxx108
-rw-r--r--vcl/source/gdi/bitmap.cxx108
-rw-r--r--vcl/source/gdi/bitmapex.cxx2
5 files changed, 112 insertions, 112 deletions
diff --git a/include/vcl/alpha.hxx b/include/vcl/alpha.hxx
index 483f7492a9ae..de3b4513e4f8 100644
--- a/include/vcl/alpha.hxx
+++ b/include/vcl/alpha.hxx
@@ -105,9 +105,6 @@ public:
Bitmap GetBitmap() const;
- bool CopyPixel( const Rectangle& rRectDst, const Rectangle& rRectSrc,
- const AlphaMask* pAlphaSrc = NULL);
-
bool Erase( sal_uInt8 cTransparency );
bool Replace( const Bitmap& rMask, sal_uInt8 rReplaceTransparency );
bool Replace( sal_uInt8 cSearchTransparency, sal_uInt8 cReplaceTransparency,
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index 8dd71252a9c8..d2f0cac3bcde 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -512,6 +512,9 @@ public:
const Rectangle& rRectSrc,
const Bitmap* pBmpSrc = NULL );
+ bool CopyPixel_AlphaOptimized( const Rectangle& rRectDst, const Rectangle& rRectSrc,
+ const Bitmap* pBmpSrc = NULL);
+
/** Perform boolean operations with another bitmap
@param rMask
diff --git a/vcl/source/gdi/alpha.cxx b/vcl/source/gdi/alpha.cxx
index 32c42d0d0742..1a26072df8b8 100644
--- a/vcl/source/gdi/alpha.cxx
+++ b/vcl/source/gdi/alpha.cxx
@@ -76,114 +76,6 @@ Bitmap AlphaMask::GetBitmap() const
return ImplGetBitmap();
}
-bool AlphaMask::CopyPixel( const Rectangle& rRectDst, const Rectangle& rRectSrc,
- const AlphaMask* pAlphaSrc )
-{
- // Note: this code is copied from Bitmap::CopyPixel but avoids any palette lookups
- // This optimization is possible because the palettes of AlphaMasks are always identical (8bit GreyPalette, see ctor)
- const Size aSizePix( GetSizePixel() );
- Rectangle aRectDst( rRectDst );
- bool bRet = false;
-
- aRectDst.Intersection( Rectangle( Point(), aSizePix ) );
-
- if( !aRectDst.IsEmpty() )
- {
- if( pAlphaSrc && ( *pAlphaSrc != *this ) )
- {
- Bitmap* pSrc = (Bitmap*) pAlphaSrc;
- const Size aCopySizePix( pSrc->GetSizePixel() );
- Rectangle aRectSrc( rRectSrc );
-
- aRectSrc.Intersection( Rectangle( Point(), aCopySizePix ) );
-
- if( !aRectSrc.IsEmpty() )
- {
- BitmapReadAccess* pReadAcc = pSrc->AcquireReadAccess();
-
- if( pReadAcc )
- {
- BitmapWriteAccess* pWriteAcc = AcquireWriteAccess();
-
- if( pWriteAcc )
- {
- const long nWidth = std::min( aRectSrc.GetWidth(), aRectDst.GetWidth() );
- const long nHeight = std::min( aRectSrc.GetHeight(), aRectDst.GetHeight() );
- const long nSrcEndX = aRectSrc.Left() + nWidth;
- const long nSrcEndY = aRectSrc.Top() + nHeight;
- long nDstY = aRectDst.Top();
-
- for( long nSrcY = aRectSrc.Top(); nSrcY < nSrcEndY; nSrcY++, nDstY++ )
- for( long nSrcX = aRectSrc.Left(), nDstX = aRectDst.Left(); nSrcX < nSrcEndX; nSrcX++, nDstX++ )
- pWriteAcc->SetPixel( nDstY, nDstX, pReadAcc->GetPixel( nSrcY, nSrcX ) );
-
- ReleaseAccess( pWriteAcc );
- bRet = ( nWidth > 0L ) && ( nHeight > 0L );
- }
-
- pSrc->ReleaseAccess( pReadAcc );
- }
- }
- }
- else
- {
- Rectangle aRectSrc( rRectSrc );
-
- aRectSrc.Intersection( Rectangle( Point(), aSizePix ) );
-
- if( !aRectSrc.IsEmpty() && ( aRectSrc != aRectDst ) )
- {
- BitmapWriteAccess* pWriteAcc = AcquireWriteAccess();
-
- if( pWriteAcc )
- {
- const long nWidth = std::min( aRectSrc.GetWidth(), aRectDst.GetWidth() );
- const long nHeight = std::min( aRectSrc.GetHeight(), aRectDst.GetHeight() );
- const long nSrcX = aRectSrc.Left();
- const long nSrcY = aRectSrc.Top();
- const long nSrcEndX1 = nSrcX + nWidth - 1L;
- const long nSrcEndY1 = nSrcY + nHeight - 1L;
- const long nDstX = aRectDst.Left();
- const long nDstY = aRectDst.Top();
- const long nDstEndX1 = nDstX + nWidth - 1L;
- const long nDstEndY1 = nDstY + nHeight - 1L;
-
- if( ( nDstX <= nSrcX ) && ( nDstY <= nSrcY ) )
- {
- for( long nY = nSrcY, nYN = nDstY; nY <= nSrcEndY1; nY++, nYN++ )
- for( long nX = nSrcX, nXN = nDstX; nX <= nSrcEndX1; nX++, nXN++ )
- pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) );
- }
- else if( ( nDstX <= nSrcX ) && ( nDstY >= nSrcY ) )
- {
- for( long nY = nSrcEndY1, nYN = nDstEndY1; nY >= nSrcY; nY--, nYN-- )
- for( long nX = nSrcX, nXN = nDstX; nX <= nSrcEndX1; nX++, nXN++ )
- pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) );
- }
- else if( ( nDstX >= nSrcX ) && ( nDstY <= nSrcY ) )
- {
- for( long nY = nSrcY, nYN = nDstY; nY <= nSrcEndY1; nY++, nYN++ )
- for( long nX = nSrcEndX1, nXN = nDstEndX1; nX >= nSrcX; nX--, nXN-- )
- pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) );
- }
- else
- {
- for( long nY = nSrcEndY1, nYN = nDstEndY1; nY >= nSrcY; nY--, nYN-- )
- for( long nX = nSrcEndX1, nXN = nDstEndX1; nX >= nSrcX; nX--, nXN-- )
- pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) );
- }
-
- ReleaseAccess( pWriteAcc );
- bRet = true;
- }
- }
- }
- }
-
- return bRet;
-
-}
-
bool AlphaMask::Erase( sal_uInt8 cTransparency )
{
return Bitmap::Erase( Color( cTransparency, cTransparency, cTransparency ) );
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index 361276727dad..24fd842036a2 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -1004,6 +1004,114 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst,
return bRet;
}
+bool Bitmap::CopyPixel_AlphaOptimized( const Rectangle& rRectDst, const Rectangle& rRectSrc,
+ const Bitmap* pBmpSrc )
+{
+ // Note: this code is copied from Bitmap::CopyPixel but avoids any palette lookups
+ // This optimization is possible because the palettes of AlphaMasks are always identical (8bit GreyPalette, see ctor)
+ const Size aSizePix( GetSizePixel() );
+ Rectangle aRectDst( rRectDst );
+ bool bRet = false;
+
+ aRectDst.Intersection( Rectangle( Point(), aSizePix ) );
+
+ if( !aRectDst.IsEmpty() )
+ {
+ if( pBmpSrc && ( *pBmpSrc != *this ) )
+ {
+ Bitmap* pSrc = (Bitmap*) pBmpSrc;
+ const Size aCopySizePix( pSrc->GetSizePixel() );
+ Rectangle aRectSrc( rRectSrc );
+
+ aRectSrc.Intersection( Rectangle( Point(), aCopySizePix ) );
+
+ if( !aRectSrc.IsEmpty() )
+ {
+ BitmapReadAccess* pReadAcc = pSrc->AcquireReadAccess();
+
+ if( pReadAcc )
+ {
+ BitmapWriteAccess* pWriteAcc = AcquireWriteAccess();
+
+ if( pWriteAcc )
+ {
+ const long nWidth = std::min( aRectSrc.GetWidth(), aRectDst.GetWidth() );
+ const long nHeight = std::min( aRectSrc.GetHeight(), aRectDst.GetHeight() );
+ const long nSrcEndX = aRectSrc.Left() + nWidth;
+ const long nSrcEndY = aRectSrc.Top() + nHeight;
+ long nDstY = aRectDst.Top();
+
+ for( long nSrcY = aRectSrc.Top(); nSrcY < nSrcEndY; nSrcY++, nDstY++ )
+ for( long nSrcX = aRectSrc.Left(), nDstX = aRectDst.Left(); nSrcX < nSrcEndX; nSrcX++, nDstX++ )
+ pWriteAcc->SetPixel( nDstY, nDstX, pReadAcc->GetPixel( nSrcY, nSrcX ) );
+
+ ReleaseAccess( pWriteAcc );
+ bRet = ( nWidth > 0L ) && ( nHeight > 0L );
+ }
+
+ pSrc->ReleaseAccess( pReadAcc );
+ }
+ }
+ }
+ else
+ {
+ Rectangle aRectSrc( rRectSrc );
+
+ aRectSrc.Intersection( Rectangle( Point(), aSizePix ) );
+
+ if( !aRectSrc.IsEmpty() && ( aRectSrc != aRectDst ) )
+ {
+ BitmapWriteAccess* pWriteAcc = AcquireWriteAccess();
+
+ if( pWriteAcc )
+ {
+ const long nWidth = std::min( aRectSrc.GetWidth(), aRectDst.GetWidth() );
+ const long nHeight = std::min( aRectSrc.GetHeight(), aRectDst.GetHeight() );
+ const long nSrcX = aRectSrc.Left();
+ const long nSrcY = aRectSrc.Top();
+ const long nSrcEndX1 = nSrcX + nWidth - 1L;
+ const long nSrcEndY1 = nSrcY + nHeight - 1L;
+ const long nDstX = aRectDst.Left();
+ const long nDstY = aRectDst.Top();
+ const long nDstEndX1 = nDstX + nWidth - 1L;
+ const long nDstEndY1 = nDstY + nHeight - 1L;
+
+ if( ( nDstX <= nSrcX ) && ( nDstY <= nSrcY ) )
+ {
+ for( long nY = nSrcY, nYN = nDstY; nY <= nSrcEndY1; nY++, nYN++ )
+ for( long nX = nSrcX, nXN = nDstX; nX <= nSrcEndX1; nX++, nXN++ )
+ pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) );
+ }
+ else if( ( nDstX <= nSrcX ) && ( nDstY >= nSrcY ) )
+ {
+ for( long nY = nSrcEndY1, nYN = nDstEndY1; nY >= nSrcY; nY--, nYN-- )
+ for( long nX = nSrcX, nXN = nDstX; nX <= nSrcEndX1; nX++, nXN++ )
+ pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) );
+ }
+ else if( ( nDstX >= nSrcX ) && ( nDstY <= nSrcY ) )
+ {
+ for( long nY = nSrcY, nYN = nDstY; nY <= nSrcEndY1; nY++, nYN++ )
+ for( long nX = nSrcEndX1, nXN = nDstEndX1; nX >= nSrcX; nX--, nXN-- )
+ pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) );
+ }
+ else
+ {
+ for( long nY = nSrcEndY1, nYN = nDstEndY1; nY >= nSrcY; nY--, nYN-- )
+ for( long nX = nSrcEndX1, nXN = nDstEndX1; nX >= nSrcX; nX--, nXN-- )
+ pWriteAcc->SetPixel( nYN, nXN, pWriteAcc->GetPixel( nY, nX ) );
+ }
+
+ ReleaseAccess( pWriteAcc );
+ bRet = true;
+ }
+ }
+ }
+ }
+
+ return bRet;
+
+}
+
bool Bitmap::Expand( sal_uLong nDX, sal_uLong nDY, const Color* pInitColor )
{
bool bRet = false;
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index bc25f0490dba..7673f0b3f333 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -525,7 +525,7 @@ bool BitmapEx::CopyPixel( const Rectangle& rRectDst, const Rectangle& rRectSrc,
{
if( IsAlpha() )
// cast to use the optimized AlphaMask::CopyPixel
- ((AlphaMask*) &aMask)->CopyPixel( rRectDst, rRectSrc, (AlphaMask*)&pBmpExSrc->aMask );
+ aMask.CopyPixel_AlphaOptimized( rRectDst, rRectSrc, &pBmpExSrc->aMask );
else if( IsTransparent() )
{
AlphaMask* pAlpha = new AlphaMask( aMask );