summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-12-03 17:02:37 -0500
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-12-11 07:57:27 +0100
commit83861ce123c2d7b1ce9c6acfbc0e457662eac944 (patch)
tree18ca72332f1a6dbd7b601d8829bc4b988ed97235 /vcl
parent9f839e9b3cbdca1511961a85b40d1c6825e43ba1 (diff)
vcl: Add BitmapInfoAccess for bitmaps' metadata access
Change-Id: Iec9f8c7d8f7cded0aef9e017373e44387dc0b05c
Diffstat (limited to 'vcl')
-rw-r--r--vcl/generic/print/genpspgraphics.cxx4
-rw-r--r--vcl/headless/svpbmp.cxx6
-rw-r--r--vcl/inc/headless/svpbmp.hxx4
-rw-r--r--vcl/inc/impbmp.hxx5
-rw-r--r--vcl/inc/opengl/salbmp.hxx4
-rw-r--r--vcl/inc/quartz/salbmp.h4
-rw-r--r--vcl/inc/salbmp.hxx5
-rw-r--r--vcl/inc/unx/salbmp.h4
-rw-r--r--vcl/inc/win/salbmp.h4
-rw-r--r--vcl/opengl/salbmp.cxx32
-rw-r--r--vcl/quartz/salbmp.cxx6
-rw-r--r--vcl/source/gdi/bitmap.cxx23
-rw-r--r--vcl/source/gdi/bmpacc.cxx138
-rw-r--r--vcl/source/gdi/impbmp.cxx10
-rw-r--r--vcl/unx/generic/gdi/gdiimpl.cxx12
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx6
-rw-r--r--vcl/unx/gtk/window/gtksalframe.cxx8
-rw-r--r--vcl/win/source/gdi/gdiimpl.cxx3
-rw-r--r--vcl/win/source/gdi/salbmp.cxx24
19 files changed, 174 insertions, 128 deletions
diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx
index f548cee834dc..1e63ab0faf31 100644
--- a/vcl/generic/print/genpspgraphics.cxx
+++ b/vcl/generic/print/genpspgraphics.cxx
@@ -509,12 +509,12 @@ void GenPspGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSa
Rectangle aDst (Point(rPosAry.mnDestX, rPosAry.mnDestY),
Size(rPosAry.mnDestWidth, rPosAry.mnDestHeight));
- BitmapBuffer* pBuffer= const_cast<SalBitmap&>(rSalBitmap).AcquireBuffer(true);
+ BitmapBuffer* pBuffer= const_cast<SalBitmap&>(rSalBitmap).AcquireBuffer(BITMAP_READ_ACCESS);
SalPrinterBmp aBmp (pBuffer);
m_pPrinterGfx->DrawBitmap (aDst, aSrc, aBmp);
- const_cast<SalBitmap&>(rSalBitmap).ReleaseBuffer (pBuffer, true);
+ const_cast<SalBitmap&>(rSalBitmap).ReleaseBuffer (pBuffer, BITMAP_READ_ACCESS);
}
void GenPspGraphics::drawBitmap( const SalTwoRect&,
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index 014b0e92c90a..bc2b2b90d8b8 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -133,7 +133,7 @@ sal_uInt16 SvpSalBitmap::GetBitCount() const
return nDepth;
}
-BitmapBuffer* SvpSalBitmap::AcquireBuffer( bool )
+BitmapBuffer* SvpSalBitmap::AcquireBuffer( BitmapAccessMode )
{
BitmapBuffer* pBuf = NULL;
if( m_aBitmap.get() )
@@ -268,9 +268,9 @@ BitmapBuffer* SvpSalBitmap::AcquireBuffer( bool )
return pBuf;
}
-void SvpSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly )
+void SvpSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode )
{
- if( !bReadOnly && pBuffer->maPalette.GetEntryCount() )
+ if( nMode == BITMAP_WRITE_ACCESS && pBuffer->maPalette.GetEntryCount() )
{
// palette might have changed, clone device (but recycle
// memory)
diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx
index 61672fc1f136..cb3336d9dd00 100644
--- a/vcl/inc/headless/svpbmp.hxx
+++ b/vcl/inc/headless/svpbmp.hxx
@@ -55,8 +55,8 @@ public:
virtual Size GetSize() const SAL_OVERRIDE;
virtual sal_uInt16 GetBitCount() const SAL_OVERRIDE;
- virtual BitmapBuffer* AcquireBuffer( bool bReadOnly ) SAL_OVERRIDE;
- virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) SAL_OVERRIDE;
+ virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) SAL_OVERRIDE;
+ virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) SAL_OVERRIDE;
virtual bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE;
virtual bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
diff --git a/vcl/inc/impbmp.hxx b/vcl/inc/impbmp.hxx
index de709893cf69..5e4586d97113 100644
--- a/vcl/inc/impbmp.hxx
+++ b/vcl/inc/impbmp.hxx
@@ -20,6 +20,7 @@
#ifndef INCLUDED_VCL_INC_IMPBMP_HXX
#define INCLUDED_VCL_INC_IMPBMP_HXX
+#include <vcl/salbtype.hxx>
#include <tools/gen.hxx>
#include <tools/solar.h>
@@ -58,8 +59,8 @@ public:
Size ImplGetSize() const;
sal_uInt16 ImplGetBitCount() const;
- BitmapBuffer* ImplAcquireBuffer( bool bReadOnly );
- void ImplReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
+ BitmapBuffer* ImplAcquireBuffer( BitmapAccessMode nMode );
+ void ImplReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode );
sal_uLong ImplGetRefCount() const { return mnRefCount; }
void ImplIncRefCount() { mnRefCount++; }
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 2a3076433803..200698f7c828 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -74,8 +74,8 @@ public:
Size GetSize() const SAL_OVERRIDE;
sal_uInt16 GetBitCount() const SAL_OVERRIDE;
- BitmapBuffer *AcquireBuffer( bool bReadOnly ) SAL_OVERRIDE;
- void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) SAL_OVERRIDE;
+ BitmapBuffer *AcquireBuffer( BitmapAccessMode nMode ) SAL_OVERRIDE;
+ void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) SAL_OVERRIDE;
bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE;
diff --git a/vcl/inc/quartz/salbmp.h b/vcl/inc/quartz/salbmp.h
index b871ffbc5571..1be7b0da5cd9 100644
--- a/vcl/inc/quartz/salbmp.h
+++ b/vcl/inc/quartz/salbmp.h
@@ -70,8 +70,8 @@ public:
Size GetSize() const SAL_OVERRIDE;
sal_uInt16 GetBitCount() const SAL_OVERRIDE;
- BitmapBuffer *AcquireBuffer( bool bReadOnly ) SAL_OVERRIDE;
- void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) SAL_OVERRIDE;
+ BitmapBuffer *AcquireBuffer( BitmapAccessMode nMode ) SAL_OVERRIDE;
+ void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) SAL_OVERRIDE;
bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE;
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index 16c47e7a4bfe..b450594f17f4 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -23,6 +23,7 @@
#include <tools/gen.hxx>
#include <tools/solar.h>
#include <vcl/dllapi.h>
+#include <vcl/salbtype.hxx>
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
@@ -53,8 +54,8 @@ public:
virtual Size GetSize() const = 0;
virtual sal_uInt16 GetBitCount() const = 0;
- virtual BitmapBuffer* AcquireBuffer( bool bReadOnly ) = 0;
- virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) = 0;
+ virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) = 0;
+ virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) = 0;
virtual bool GetSystemData( BitmapSystemData& rData ) = 0;
virtual bool Crop( const Rectangle& rRectPixel ) = 0;
diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h
index 0b5cbc7b7944..d840aee6c115 100644
--- a/vcl/inc/unx/salbmp.h
+++ b/vcl/inc/unx/salbmp.h
@@ -142,8 +142,8 @@ public:
virtual Size GetSize() const SAL_OVERRIDE;
virtual sal_uInt16 GetBitCount() const SAL_OVERRIDE;
- virtual BitmapBuffer* AcquireBuffer( bool bReadOnly ) SAL_OVERRIDE;
- virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) SAL_OVERRIDE;
+ virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) SAL_OVERRIDE;
+ virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) SAL_OVERRIDE;
virtual bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE;
virtual bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h
index 12fd4ca35dea..c1db93bc10d5 100644
--- a/vcl/inc/win/salbmp.h
+++ b/vcl/inc/win/salbmp.h
@@ -93,8 +93,8 @@ public:
virtual Size GetSize() const { return maSize; }
virtual sal_uInt16 GetBitCount() const { return mnBitCount; }
- virtual BitmapBuffer* AcquireBuffer( bool bReadOnly );
- virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
+ virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode );
+ virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode );
virtual bool GetSystemData( BitmapSystemData& rData );
virtual bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 94c0c870ae76..20ef2c434caf 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -477,21 +477,25 @@ void OpenGLSalBitmap::makeCurrent()
mpContext->makeCurrent();
}
-BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
+BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode )
{
- if( !maUserBuffer.get() )
- {
- if( !AllocateUserData() )
- return NULL;
- if( maTexture && !ReadTexture() )
- return NULL;
- }
- if( !maPendingOps.empty() )
+ if( nMode != BITMAP_INFO_ACCESS )
{
- SAL_INFO( "vcl.opengl", "** Creating texture and reading it back immediatly" );
- if( !CreateTexture() || !AllocateUserData() || !ReadTexture() )
- return NULL;
+ if( !maUserBuffer.get() )
+ {
+ if( !AllocateUserData() )
+ return NULL;
+ if( maTexture && !ReadTexture() )
+ return NULL;
+ }
+
+ if( !maPendingOps.empty() )
+ {
+ SAL_INFO( "vcl.opengl", "** Creating texture and reading it back immediatly" );
+ if( !CreateTexture() || !AllocateUserData() || !ReadTexture() )
+ return NULL;
+ }
}
BitmapBuffer* pBuffer = new BitmapBuffer;
@@ -518,9 +522,9 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
return pBuffer;
}
-void OpenGLSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly )
+void OpenGLSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode )
{
- if( !bReadOnly )
+ if( nMode == BITMAP_WRITE_ACCESS )
{
maTexture = OpenGLTexture();
mbDirtyTexture = true;
diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx
index d3fc899108c7..78064c210d14 100644
--- a/vcl/quartz/salbmp.cxx
+++ b/vcl/quartz/salbmp.cxx
@@ -702,7 +702,7 @@ const BitmapPalette& GetDefaultPalette( int mnBits, bool bMonochrome )
return aEmptyPalette;
}
-BitmapBuffer* QuartzSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
+BitmapBuffer* QuartzSalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ )
{
if( !maUserBuffer.get() )
// || maContextBuffer.get() && (maUserBuffer.get() != maContextBuffer.get()) )
@@ -741,10 +741,10 @@ BitmapBuffer* QuartzSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
return pBuffer;
}
-void QuartzSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly )
+void QuartzSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode )
{
// invalidate graphic context if we have different data
- if( !bReadOnly )
+ if( nMode == BITMAP_WRITE_ACCESS )
{
maPalette = pBuffer->maPalette;
if( mxGraphicContext )
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index 9915125cfd8d..050eaa5ea18f 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -275,12 +275,12 @@ bool Bitmap::HasGreyPalette() const
const sal_uInt16 nBitCount = GetBitCount();
bool bRet = nBitCount == 1;
- BitmapReadAccess* pRAcc = ( (Bitmap*) this )->AcquireReadAccess();
+ BitmapInfoAccess* pIAcc = ( (Bitmap*) this )->AcquireInfoAccess();
- if( pRAcc )
+ if( pIAcc )
{
- bRet = pRAcc->HasPalette() && pRAcc->GetPalette().IsGreyPalette();
- ( (Bitmap*) this )->ReleaseAccess( pRAcc );
+ bRet = pIAcc->HasPalette() && pIAcc->GetPalette().IsGreyPalette();
+ ( (Bitmap*) this )->ReleaseAccess( pIAcc );
}
return bRet;
@@ -399,6 +399,19 @@ void Bitmap::ImplSetImpBitmap( ImpBitmap* pImpBmp )
}
}
+BitmapInfoAccess* Bitmap::AcquireInfoAccess()
+{
+ BitmapInfoAccess* pInfoAccess = new BitmapInfoAccess( *this );
+
+ if( !*pInfoAccess )
+ {
+ delete pInfoAccess;
+ pInfoAccess = NULL;
+ }
+
+ return pInfoAccess;
+}
+
BitmapReadAccess* Bitmap::AcquireReadAccess()
{
BitmapReadAccess* pReadAccess = new BitmapReadAccess( *this );
@@ -425,7 +438,7 @@ BitmapWriteAccess* Bitmap::AcquireWriteAccess()
return pWriteAccess;
}
-void Bitmap::ReleaseAccess( BitmapReadAccess* pBitmapAccess )
+void Bitmap::ReleaseAccess( BitmapInfoAccess* pBitmapAccess )
{
delete pBitmapAccess;
}
diff --git a/vcl/source/gdi/bmpacc.cxx b/vcl/source/gdi/bmpacc.cxx
index 0b6a48b2406e..9e4994c5dda4 100644
--- a/vcl/source/gdi/bmpacc.cxx
+++ b/vcl/source/gdi/bmpacc.cxx
@@ -27,32 +27,26 @@
#include <string.h>
-BitmapReadAccess::BitmapReadAccess( Bitmap& rBitmap, bool bModify ) :
+BitmapInfoAccess::BitmapInfoAccess( Bitmap& rBitmap, BitmapAccessMode nMode ) :
mpBuffer ( NULL ),
- mpScanBuf ( NULL ),
- mFncGetPixel ( NULL ),
- mFncSetPixel ( NULL ),
- mbModify ( bModify )
+ mnAccessMode ( nMode )
{
ImplCreate( rBitmap );
}
-BitmapReadAccess::BitmapReadAccess( Bitmap& rBitmap ) :
+BitmapInfoAccess::BitmapInfoAccess( Bitmap& rBitmap ) :
mpBuffer ( NULL ),
- mpScanBuf ( NULL ),
- mFncGetPixel ( NULL ),
- mFncSetPixel ( NULL ),
- mbModify ( false )
+ mnAccessMode ( BITMAP_INFO_ACCESS )
{
ImplCreate( rBitmap );
}
-BitmapReadAccess::~BitmapReadAccess()
+BitmapInfoAccess::~BitmapInfoAccess()
{
ImplDestroy();
}
-void BitmapReadAccess::ImplCreate( Bitmap& rBitmap )
+void BitmapInfoAccess::ImplCreate( Bitmap& rBitmap )
{
ImpBitmap* pImpBmp = rBitmap.ImplGetImpBitmap();
@@ -60,18 +54,19 @@ void BitmapReadAccess::ImplCreate( Bitmap& rBitmap )
if( pImpBmp )
{
- if( mbModify && !maBitmap.ImplGetImpBitmap() )
+ if( mnAccessMode == BITMAP_WRITE_ACCESS && !maBitmap.ImplGetImpBitmap() )
{
rBitmap.ImplMakeUnique();
pImpBmp = rBitmap.ImplGetImpBitmap();
}
else
{
- DBG_ASSERT( !mbModify || pImpBmp->ImplGetRefCount() == 2,
+ DBG_ASSERT( mnAccessMode != BITMAP_WRITE_ACCESS ||
+ pImpBmp->ImplGetRefCount() == 2,
"Unpredictable results: bitmap is referenced more than once!" );
}
- mpBuffer = pImpBmp->ImplAcquireBuffer( !mbModify );
+ mpBuffer = pImpBmp->ImplAcquireBuffer( mnAccessMode );
if( !mpBuffer )
{
@@ -81,59 +76,95 @@ void BitmapReadAccess::ImplCreate( Bitmap& rBitmap )
{
pImpBmp = pNewImpBmp;
rBitmap.ImplSetImpBitmap( pImpBmp );
- mpBuffer = pImpBmp->ImplAcquireBuffer( !mbModify );
+ mpBuffer = pImpBmp->ImplAcquireBuffer( mnAccessMode );
}
else
delete pNewImpBmp;
}
- if( mpBuffer )
- {
- const long nHeight = mpBuffer->mnHeight;
- Scanline pTmpLine = mpBuffer->mpBits;
+ maBitmap = rBitmap;
+ }
+}
- mpScanBuf = new Scanline[ nHeight ];
- maColorMask = mpBuffer->maColorMask;
+void BitmapInfoAccess::ImplDestroy()
+{
+ ImpBitmap* pImpBmp = maBitmap.ImplGetImpBitmap();
- if( BMP_SCANLINE_ADJUSTMENT( mpBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN )
- {
- for( long nY = 0L; nY < nHeight; nY++, pTmpLine += mpBuffer->mnScanlineSize )
- mpScanBuf[ nY ] = pTmpLine;
- }
- else
- {
- for( long nY = nHeight - 1; nY >= 0; nY--, pTmpLine += mpBuffer->mnScanlineSize )
- mpScanBuf[ nY ] = pTmpLine;
- }
+ if( mpBuffer && pImpBmp )
+ {
+ pImpBmp->ImplReleaseBuffer( mpBuffer, mnAccessMode );
+ mpBuffer = NULL;
+ }
+}
- if( !ImplSetAccessPointers( BMP_SCANLINE_FORMAT( mpBuffer->mnFormat ) ) )
- {
- delete[] mpScanBuf;
- mpScanBuf = NULL;
+sal_uInt16 BitmapInfoAccess::GetBestPaletteIndex( const BitmapColor& rBitmapColor ) const
+{
+ return( HasPalette() ? mpBuffer->maPalette.GetBestIndex( rBitmapColor ) : 0 );
+}
- pImpBmp->ImplReleaseBuffer( mpBuffer, !mbModify );
- mpBuffer = NULL;
- }
- else
- maBitmap = rBitmap;
- }
- }
+BitmapReadAccess::BitmapReadAccess( Bitmap& rBitmap, BitmapAccessMode nMode ) :
+ BitmapInfoAccess( rBitmap, nMode ),
+ mpScanBuf ( NULL ),
+ mFncGetPixel ( NULL ),
+ mFncSetPixel ( NULL )
+{
+ ImplInitScanBuffer( rBitmap );
}
-void BitmapReadAccess::ImplDestroy()
+BitmapReadAccess::BitmapReadAccess( Bitmap& rBitmap ) :
+ BitmapInfoAccess( rBitmap, BITMAP_READ_ACCESS ),
+ mpScanBuf ( NULL ),
+ mFncGetPixel ( NULL ),
+ mFncSetPixel ( NULL )
{
- ImpBitmap* pImpBmp = maBitmap.ImplGetImpBitmap();
+ ImplInitScanBuffer( rBitmap );
+}
- delete[] mpScanBuf;
- mpScanBuf = NULL;
+BitmapReadAccess::~BitmapReadAccess()
+{
+ ImplClearScanBuffer();
+}
- if( mpBuffer && pImpBmp )
+void BitmapReadAccess::ImplInitScanBuffer( Bitmap& rBitmap )
+{
+ ImpBitmap* pImpBmp = rBitmap.ImplGetImpBitmap();
+
+ if( pImpBmp && mpBuffer )
{
- pImpBmp->ImplReleaseBuffer( mpBuffer, !mbModify );
- mpBuffer = NULL;
+ const long nHeight = mpBuffer->mnHeight;
+ Scanline pTmpLine = mpBuffer->mpBits;
+
+ mpScanBuf = new Scanline[ nHeight ];
+ maColorMask = mpBuffer->maColorMask;
+
+ if( BMP_SCANLINE_ADJUSTMENT( mpBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN )
+ {
+ for( long nY = 0L; nY < nHeight; nY++, pTmpLine += mpBuffer->mnScanlineSize )
+ mpScanBuf[ nY ] = pTmpLine;
+ }
+ else
+ {
+ for( long nY = nHeight - 1; nY >= 0; nY--, pTmpLine += mpBuffer->mnScanlineSize )
+ mpScanBuf[ nY ] = pTmpLine;
+ }
+
+ if( !ImplSetAccessPointers( BMP_SCANLINE_FORMAT( mpBuffer->mnFormat ) ) )
+ {
+ delete[] mpScanBuf;
+ mpScanBuf = NULL;
+
+ pImpBmp->ImplReleaseBuffer( mpBuffer, mnAccessMode );
+ mpBuffer = NULL;
+ }
}
}
+void BitmapReadAccess::ImplClearScanBuffer()
+{
+ delete[] mpScanBuf;
+ mpScanBuf = NULL;
+}
+
bool BitmapReadAccess::ImplSetAccessPointers( sal_uLong nFormat )
{
bool bRet = true;
@@ -273,11 +304,6 @@ void BitmapReadAccess::ImplZeroInitUnusedBits()
}
}
-sal_uInt16 BitmapReadAccess::GetBestPaletteIndex( const BitmapColor& rBitmapColor ) const
-{
- return( HasPalette() ? mpBuffer->maPalette.GetBestIndex( rBitmapColor ) : 0 );
-}
-
BitmapColor BitmapReadAccess::GetInterpolatedColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const
{
// ask directly doubles >= 0.0 here to avoid rounded values of 0 at small negative
@@ -386,7 +412,7 @@ BitmapColor BitmapReadAccess::GetColorWithFallback( double fY, double fX, const
}
BitmapWriteAccess::BitmapWriteAccess( Bitmap& rBitmap ) :
- BitmapReadAccess( rBitmap, true ),
+ BitmapReadAccess( rBitmap, BITMAP_WRITE_ACCESS ),
mpLineColor ( NULL ),
mpFillColor ( NULL )
{
diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx
index 5a478453f684..4f4684d98e57 100644
--- a/vcl/source/gdi/impbmp.cxx
+++ b/vcl/source/gdi/impbmp.cxx
@@ -80,16 +80,16 @@ sal_uInt16 ImpBitmap::ImplGetBitCount() const
return( ( nBitCount <= 1 ) ? 1 : ( nBitCount <= 4 ) ? 4 : ( nBitCount <= 8 ) ? 8 : 24 );
}
-BitmapBuffer* ImpBitmap::ImplAcquireBuffer( bool bReadOnly )
+BitmapBuffer* ImpBitmap::ImplAcquireBuffer( BitmapAccessMode nMode )
{
- return mpSalBitmap->AcquireBuffer( bReadOnly );
+ return mpSalBitmap->AcquireBuffer( nMode );
}
-void ImpBitmap::ImplReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly )
+void ImpBitmap::ImplReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode )
{
- mpSalBitmap->ReleaseBuffer( pBuffer, bReadOnly );
+ mpSalBitmap->ReleaseBuffer( pBuffer, nMode );
- if( !bReadOnly )
+ if( nMode == BITMAP_WRITE_ACCESS )
mnChecksum = 0;
}
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index f2f909c96142..5e084ceafb36 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -105,7 +105,7 @@ namespace
//fdo#33455 and fdo#80160 handle 1 bit depth pngs with palette entries
//to set fore/back colors
SalBitmap& rBitmap = const_cast<SalBitmap&>(rSalBitmap);
- if (BitmapBuffer* pBitmapBuffer = rBitmap.AcquireBuffer(true))
+ if (BitmapBuffer* pBitmapBuffer = rBitmap.AcquireBuffer(BITMAP_READ_ACCESS))
{
const BitmapPalette& rPalette = pBitmapBuffer->maPalette;
if (rPalette.GetEntryCount() == 2)
@@ -116,7 +116,7 @@ namespace
const BitmapColor aBlack(rPalette[rPalette.GetBestIndex(Color(COL_BLACK))]);
rValues.background = rColMap.GetPixel(ImplColorToSal(aBlack));
}
- rBitmap.ReleaseBuffer(pBitmapBuffer, true);
+ rBitmap.ReleaseBuffer(pBitmapBuffer, BITMAP_READ_ACCESS);
}
}
}
@@ -704,11 +704,11 @@ void X11SalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry,
DBG_ASSERT( !mrParent.bPrinter_, "Drawing of transparent bitmaps on printer devices is strictly forbidden" );
// decide if alpha masking or transparency masking is needed
- BitmapBuffer* pAlphaBuffer = const_cast<SalBitmap&>(rMaskBitmap).AcquireBuffer( true );
+ BitmapBuffer* pAlphaBuffer = const_cast<SalBitmap&>(rMaskBitmap).AcquireBuffer( BITMAP_READ_ACCESS );
if( pAlphaBuffer != NULL )
{
int nMaskFormat = pAlphaBuffer->mnFormat;
- const_cast<SalBitmap&>(rMaskBitmap).ReleaseBuffer( pAlphaBuffer, true );
+ const_cast<SalBitmap&>(rMaskBitmap).ReleaseBuffer( pAlphaBuffer, BITMAP_READ_ACCESS );
if( nMaskFormat == BMP_FORMAT_8BIT_PAL )
drawAlphaBitmap( rPosAry, rSrcBitmap, rMaskBitmap );
}
@@ -882,7 +882,7 @@ bool X11SalGraphicsImpl::drawAlphaBitmap( const SalTwoRect& rTR,
// TODO: use SalX11Bitmap functionality and caching for the Alpha Pixmap
// problem is that they don't provide an 8bit Pixmap on a non-8bit display
- BitmapBuffer* pAlphaBuffer = const_cast<SalBitmap&>(rAlphaBmp).AcquireBuffer( true );
+ BitmapBuffer* pAlphaBuffer = const_cast<SalBitmap&>(rAlphaBmp).AcquireBuffer( BITMAP_READ_ACCESS );
// an XImage needs its data top_down
// TODO: avoid wrongly oriented images in upper layers!
@@ -927,7 +927,7 @@ bool X11SalGraphicsImpl::drawAlphaBitmap( const SalTwoRect& rTR,
if( pAlphaBits != (char*)pAlphaBuffer->mpBits )
delete[] pAlphaBits;
- const_cast<SalBitmap&>(rAlphaBmp).ReleaseBuffer( pAlphaBuffer, true );
+ const_cast<SalBitmap&>(rAlphaBmp).ReleaseBuffer( pAlphaBuffer, BITMAP_READ_ACCESS );
XRenderPictureAttributes aAttr;
aAttr.repeat = int(true);
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index e4437a7c31b1..f6ac7369eeb7 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -814,7 +814,7 @@ sal_uInt16 X11SalBitmap::GetBitCount() const
return nBitCount;
}
-BitmapBuffer* X11SalBitmap::AcquireBuffer( bool )
+BitmapBuffer* X11SalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ )
{
if( !mpDIB && mpDDB )
{
@@ -832,9 +832,9 @@ BitmapBuffer* X11SalBitmap::AcquireBuffer( bool )
return mpDIB;
}
-void X11SalBitmap::ReleaseBuffer( BitmapBuffer*, bool bReadOnly )
+void X11SalBitmap::ReleaseBuffer( BitmapBuffer*, BitmapAccessMode nMode )
{
- if( !bReadOnly )
+ if( nMode == BITMAP_WRITE_ACCESS )
{
if( mpDDB )
delete mpDDB, mpDDB = NULL;
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
index f1065be1eaa3..c840cbf91174 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -1558,11 +1558,11 @@ bitmapToPixbuf( SalBitmap *pSalBitmap, SalBitmap *pSalAlpha )
g_return_val_if_fail( pSalBitmap != NULL, NULL );
g_return_val_if_fail( pSalAlpha != NULL, NULL );
- BitmapBuffer *pBitmap = pSalBitmap->AcquireBuffer( true );
+ BitmapBuffer *pBitmap = pSalBitmap->AcquireBuffer( BITMAP_READ_ACCESS );
g_return_val_if_fail( pBitmap != NULL, NULL );
g_return_val_if_fail( pBitmap->mnBitCount == 24, NULL );
- BitmapBuffer *pAlpha = pSalAlpha->AcquireBuffer( true );
+ BitmapBuffer *pAlpha = pSalAlpha->AcquireBuffer( BITMAP_READ_ACCESS );
g_return_val_if_fail( pAlpha != NULL, NULL );
g_return_val_if_fail( pAlpha->mnBitCount == 8, NULL );
@@ -1597,8 +1597,8 @@ bitmapToPixbuf( SalBitmap *pSalBitmap, SalBitmap *pSalAlpha )
}
}
- pSalBitmap->ReleaseBuffer( pBitmap, true );
- pSalAlpha->ReleaseBuffer( pAlpha, true );
+ pSalBitmap->ReleaseBuffer( pBitmap, BITMAP_READ_ACCESS );
+ pSalAlpha->ReleaseBuffer( pAlpha, BITMAP_READ_ACCESS );
return gdk_pixbuf_new_from_data( pPixbufData,
GDK_COLORSPACE_RGB, true, 8,
diff --git a/vcl/win/source/gdi/gdiimpl.cxx b/vcl/win/source/gdi/gdiimpl.cxx
index e17b3e11eead..6e6361a230bc 100644
--- a/vcl/win/source/gdi/gdiimpl.cxx
+++ b/vcl/win/source/gdi/gdiimpl.cxx
@@ -633,7 +633,7 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, const WinSalBitmap& rSa
COLORREF nTextColor = RGB( 0x00, 0x00, 0x00 );
//fdo#33455 handle 1 bit depth pngs with palette entries
//to set fore/back colors
- if (const BitmapBuffer* pBitmapBuffer = const_cast<WinSalBitmap&>(rSalBitmap).AcquireBuffer(true))
+ if (const BitmapBuffer* pBitmapBuffer = const_cast<WinSalBitmap&>(rSalBitmap).AcquireBuffer(BITMAP_INFO_ACCESS))
{
const BitmapPalette& rPalette = pBitmapBuffer->maPalette;
if (rPalette.GetEntryCount() == 2)
@@ -644,6 +644,7 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, const WinSalBitmap& rSa
nCol = ImplColorToSal(rPalette[1]);
nBkColor = RGB( SALCOLOR_RED(nCol), SALCOLOR_GREEN(nCol), SALCOLOR_BLUE(nCol) );
}
+ const_cast<WinSalBitmap&>(rSalBitmap).ReleaseBuffer(pBitmapBuffer, BITMAP_INFO_ACCESS);
}
nOldBkColor = SetBkColor( hDC, nBkColor );
nOldTextColor = ::SetTextColor( hDC, nTextColor );
diff --git a/vcl/win/source/gdi/salbmp.cxx b/vcl/win/source/gdi/salbmp.cxx
index b32067d2d5d8..5ec4c104c8f5 100644
--- a/vcl/win/source/gdi/salbmp.cxx
+++ b/vcl/win/source/gdi/salbmp.cxx
@@ -270,7 +270,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
pSalRGB = pExtraWinSalRGB;
}
- BitmapBuffer* pRGB = pSalRGB->AcquireBuffer(true);
+ BitmapBuffer* pRGB = pSalRGB->AcquireBuffer(BITMAP_READ_ACCESS);
BitmapBuffer* pExtraRGB = 0;
if(pRGB && BMP_FORMAT_24BIT_TC_BGR != (pRGB->mnFormat & ~BMP_FORMAT_TOP_DOWN))
@@ -283,7 +283,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
BMP_FORMAT_24BIT_TC_BGR,
0);
- pSalRGB->ReleaseBuffer(pRGB, true);
+ pSalRGB->ReleaseBuffer(pRGB, BITMAP_WRITE_ACCESS);
pRGB = pExtraRGB;
}
@@ -337,7 +337,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
}
else
{
- pSalRGB->ReleaseBuffer(pRGB, true);
+ pSalRGB->ReleaseBuffer(pRGB, BITMAP_READ_ACCESS);
}
if(pExtraWinSalRGB)
@@ -362,7 +362,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
pSalRGB = pExtraWinSalRGB;
}
- BitmapBuffer* pRGB = pSalRGB->AcquireBuffer(true);
+ BitmapBuffer* pRGB = pSalRGB->AcquireBuffer(BITMAP_READ_ACCESS);
BitmapBuffer* pExtraRGB = 0;
if(pRGB && BMP_FORMAT_24BIT_TC_BGR != (pRGB->mnFormat & ~BMP_FORMAT_TOP_DOWN))
@@ -375,7 +375,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
BMP_FORMAT_24BIT_TC_BGR,
0);
- pSalRGB->ReleaseBuffer(pRGB, true);
+ pSalRGB->ReleaseBuffer(pRGB, BITMAP_READ_ACCESS);
pRGB = pExtraRGB;
}
@@ -390,7 +390,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
pSalA = pExtraWinSalA;
}
- BitmapBuffer* pA = pSalA->AcquireBuffer(true);
+ BitmapBuffer* pA = pSalA->AcquireBuffer(BITMAP_READ_ACCESS);
BitmapBuffer* pExtraA = 0;
if(pA && BMP_FORMAT_8BIT_PAL != (pA->mnFormat & ~BMP_FORMAT_TOP_DOWN))
@@ -405,7 +405,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
BMP_FORMAT_8BIT_PAL,
&rTargetPalette);
- pSalA->ReleaseBuffer(pA, true);
+ pSalA->ReleaseBuffer(pA, BITMAP_READ_ACCESS);
pA = pExtraA;
}
@@ -475,7 +475,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
}
else
{
- pSalA->ReleaseBuffer(pA, true);
+ pSalA->ReleaseBuffer(pA, BITMAP_READ_ACCESS);
}
if(pExtraWinSalA)
@@ -492,7 +492,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
}
else
{
- pSalRGB->ReleaseBuffer(pRGB, true);
+ pSalRGB->ReleaseBuffer(pRGB, BITMAP_READ_ACCESS);
}
if(pExtraWinSalRGB)
@@ -835,7 +835,7 @@ HANDLE WinSalBitmap::ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB )
return hCopy;
}
-BitmapBuffer* WinSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
+BitmapBuffer* WinSalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ )
{
BitmapBuffer* pBuffer = NULL;
@@ -932,13 +932,13 @@ BitmapBuffer* WinSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
return pBuffer;
}
-void WinSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly )
+void WinSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode )
{
if( pBuffer )
{
if( mhDIB )
{
- if( !bReadOnly && !!pBuffer->maPalette )
+ if( nMode == BITMAP_WRITE_ACCESS && !!pBuffer->maPalette )
{
PBITMAPINFO pBI = (PBITMAPINFO) GlobalLock( mhDIB );
const sal_uInt16 nCount = pBuffer->maPalette.GetEntryCount();