[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl2' - 3 commits - include/vcl vcl/generic vcl/headless vcl/inc vcl/opengl vcl/quartz vcl/source vcl/unx vcl/win

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Wed Dec 3 14:09:55 PST 2014


 include/vcl/bitmap.hxx                   |    4 
 include/vcl/bmpacc.hxx                   |  120 ++++++++++++++++----------
 include/vcl/salbtype.hxx                 |   10 ++
 vcl/generic/print/genpspgraphics.cxx     |    4 
 vcl/headless/svpbmp.cxx                  |    6 -
 vcl/inc/headless/svpbmp.hxx              |    4 
 vcl/inc/impbmp.hxx                       |    5 -
 vcl/inc/opengl/salbmp.hxx                |    4 
 vcl/inc/quartz/salbmp.h                  |    4 
 vcl/inc/salbmp.hxx                       |    5 -
 vcl/inc/unx/salbmp.h                     |    4 
 vcl/inc/win/salbmp.h                     |    4 
 vcl/opengl/salbmp.cxx                    |   32 ++++---
 vcl/opengl/scale.cxx                     |    2 
 vcl/quartz/salbmp.cxx                    |    6 -
 vcl/source/gdi/bitmap.cxx                |   23 ++++-
 vcl/source/gdi/bmpacc.cxx                |  138 ++++++++++++++++++-------------
 vcl/source/gdi/impbmp.cxx                |   10 +-
 vcl/unx/generic/gdi/gdiimpl.cxx          |   12 +-
 vcl/unx/generic/gdi/salbmp.cxx           |    6 -
 vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx |   11 +-
 vcl/unx/gtk/window/gtksalframe.cxx       |    8 -
 vcl/win/source/gdi/gdiimpl.cxx           |    3 
 vcl/win/source/gdi/salbmp.cxx            |   24 ++---
 24 files changed, 267 insertions(+), 182 deletions(-)

New commits:
commit f5b314cf64e9037aade80c64f0ce6b90e78a3bbb
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Wed Dec 3 17:05:01 2014 -0500

    vcl: Reset data buffer after resizing bitmap on GPU
    
    Change-Id: I516cdbc466f3d6427e36fea8c5cdbe718ce7d0ea

diff --git a/vcl/opengl/scale.cxx b/vcl/opengl/scale.cxx
index 7bcf7c0..4703c1f 100644
--- a/vcl/opengl/scale.cxx
+++ b/vcl/opengl/scale.cxx
@@ -192,6 +192,7 @@ bool OpenGLSalBitmap::ImplScale( const double& rScaleX, const double& rScaleY, s
 {
     SAL_INFO( "vcl.opengl", "::ImplScale" );
 
+    maUserBuffer.reset();
     makeCurrent();
 
     if( nScaleFlag == BMP_SCALE_FAST )
@@ -253,7 +254,6 @@ bool OpenGLSalBitmap::Scale( const double& rScaleX, const double& rScaleY, sal_u
         nScaleFlag == BMP_SCALE_SUPER ||
         nScaleFlag == BMP_SCALE_LANCZOS )
     {
-        //TODO maUserBuffer.reset();
         makeCurrent();
         if( mpContext == NULL )
         {
commit efdc26f77cdb142651fea0044b5bf3a1d0ab1a44
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Wed Dec 3 17:04:15 2014 -0500

    vcl: Use right size to draw native GTK window background
    
    Change-Id: Id446d20599f072f657c6106d6c6457fce08830e6

diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index f3b1ecf6..2c6036b 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -1551,13 +1551,11 @@ bool GtkSalGraphics::NWPaintGTKFrame(
 bool GtkSalGraphics::NWPaintGTKWindowBackground(
             GdkDrawable* gdkDrawable,
             ControlType, ControlPart,
-            const Rectangle& /* rControlRectangle */,
+            const Rectangle& rControlRectangle,
             const clipList& rClipList,
             ControlState /* nState */, const ImplControlValue&,
             const OUString& )
 {
-    int w,h;
-    gtk_window_get_size(GTK_WINDOW(m_pWindow),&w,&h);
     GdkRectangle clipRect;
     for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
     {
@@ -1566,7 +1564,12 @@ bool GtkSalGraphics::NWPaintGTKWindowBackground(
         clipRect.width = it->GetWidth();
         clipRect.height = it->GetHeight();
 
-        gtk_paint_flat_box(m_pWindow->style,gdkDrawable,GTK_STATE_NORMAL,GTK_SHADOW_NONE,&clipRect,m_pWindow,"base",0,0,w,h);
+        gtk_paint_flat_box(m_pWindow->style,gdkDrawable,GTK_STATE_NORMAL,GTK_SHADOW_NONE,&clipRect,
+                           m_pWindow,"base",
+                           rControlRectangle.Left(),
+                           rControlRectangle.Top(),
+                           rControlRectangle.GetWidth(),
+                           rControlRectangle.GetHeight());
     }
 
     return true;
commit 046a4884082f9a030c2fe095f455c6e72fa5434a
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Wed Dec 3 17:02:37 2014 -0500

    vcl: Add BitmapInfoAccess for bitmaps' metadata access
    
    Change-Id: Iec9f8c7d8f7cded0aef9e017373e44387dc0b05c

diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index accb763..7675418 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -294,6 +294,7 @@ private:
     }
 };
 
+class   BitmapInfoAccess;
 class   BitmapReadAccess;
 class   BitmapWriteAccess;
 class   BitmapPalette;
@@ -850,9 +851,10 @@ public:
 
 public:
 
+    BitmapInfoAccess*       AcquireInfoAccess();
     BitmapReadAccess*       AcquireReadAccess();
     BitmapWriteAccess*      AcquireWriteAccess();
-    void                    ReleaseAccess( BitmapReadAccess* pAccess );
+    void                    ReleaseAccess( BitmapInfoAccess* pAccess );
 
     typedef vcl::ScopedBitmapAccess< BitmapReadAccess, Bitmap, &Bitmap::AcquireReadAccess >
         ScopedReadAccess;
diff --git a/include/vcl/bmpacc.hxx b/include/vcl/bmpacc.hxx
index 252599b..bc43dbf 100644
--- a/include/vcl/bmpacc.hxx
+++ b/include/vcl/bmpacc.hxx
@@ -62,14 +62,14 @@ typedef BitmapColor (*FncGetPixel)( ConstScanline pScanline, long nX, const Colo
 typedef void (*FncSetPixel)( Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask );
 
 
-// - BitmapReadAccess -
-class VCL_DLLPUBLIC BitmapReadAccess
+// - BitmapInfoAccess -
+class VCL_DLLPUBLIC BitmapInfoAccess
 {
-    friend class BitmapWriteAccess;
+    friend class BitmapReadAccess;
 
 public:
-                                BitmapReadAccess( Bitmap& rBitmap );
-    virtual                     ~BitmapReadAccess();
+                                BitmapInfoAccess( Bitmap& rBitmap );
+    virtual                     ~BitmapInfoAccess();
 
     inline bool                 operator!() const;
 
@@ -87,9 +87,6 @@ public:
     inline sal_uInt16           GetBitCount() const;
     inline BitmapColor          GetBestMatchingColor( const BitmapColor& rBitmapColor );
 
-    inline Scanline             GetBuffer() const;
-    inline Scanline             GetScanline( long nY ) const;
-
     inline bool                 HasPalette() const;
     inline const BitmapPalette& GetPalette() const;
     inline sal_uInt16           GetPaletteEntryCount() const;
@@ -100,6 +97,38 @@ public:
     inline bool                 HasColorMask() const;
     inline ColorMask&           GetColorMask() const;
 
+private:
+
+                                BitmapInfoAccess() {}
+                                BitmapInfoAccess( const BitmapInfoAccess& ) {}
+    BitmapInfoAccess&           operator=( const BitmapInfoAccess& ) { return *this; }
+
+protected:
+    Bitmap                      maBitmap;
+    BitmapBuffer*               mpBuffer;
+    ColorMask                   maColorMask;
+    BitmapAccessMode            mnAccessMode;
+
+    SAL_DLLPRIVATE  void        ImplCreate( Bitmap& rBitmap );
+    SAL_DLLPRIVATE  void        ImplDestroy();
+
+protected:
+                                BitmapInfoAccess( Bitmap& rBitmap, BitmapAccessMode nMode );
+
+};
+
+// - BitmapReadAccess -
+class VCL_DLLPUBLIC BitmapReadAccess : public BitmapInfoAccess
+{
+    friend class BitmapWriteAccess;
+
+public:
+                                BitmapReadAccess( Bitmap& rBitmap );
+    virtual                     ~BitmapReadAccess();
+
+    inline Scanline             GetBuffer() const;
+    inline Scanline             GetScanline( long nY ) const;
+
     inline BitmapColor          GetPixelFromData( const sal_uInt8* pData, long nX ) const;
     inline void                 SetPixelOnData( sal_uInt8* pData, long nX, const BitmapColor& rBitmapColor );
     inline BitmapColor          GetPixel( long nY, long nX ) const;
@@ -117,21 +146,16 @@ public:
 private:
 
                                 BitmapReadAccess() {}
-                                BitmapReadAccess( const BitmapReadAccess& ) {}
+                                BitmapReadAccess( const BitmapReadAccess& ) : BitmapInfoAccess() {}
     BitmapReadAccess&           operator=( const BitmapReadAccess& ) { return *this; }
 
 protected:
-    Bitmap                      maBitmap;
-    BitmapBuffer*               mpBuffer;
     Scanline*                   mpScanBuf;
-    ColorMask                   maColorMask;
     FncGetPixel                 mFncGetPixel;
     FncSetPixel                 mFncSetPixel;
-    bool                        mbModify;
-
 
-    SAL_DLLPRIVATE  void        ImplCreate( Bitmap& rBitmap );
-    SAL_DLLPRIVATE  void        ImplDestroy();
+    SAL_DLLPRIVATE  void        ImplInitScanBuffer( Bitmap& rBitmap );
+    SAL_DLLPRIVATE  void        ImplClearScanBuffer();
     SAL_DLLPRIVATE  bool        ImplSetAccessPointers( sal_uLong nFormat );
 
 public:
@@ -158,7 +182,7 @@ public:
                                 DECL_FORMAT( _32BIT_TC_MASK )
 
 protected:
-                                BitmapReadAccess( Bitmap& rBitmap, bool bModify );
+                                BitmapReadAccess( Bitmap& rBitmap, BitmapAccessMode nMode );
 
 };
 
@@ -206,61 +230,61 @@ private:
 };
 
 // - Inlines -
-inline bool BitmapReadAccess::operator!() const
+inline bool BitmapInfoAccess::operator!() const
 {
     return( mpBuffer == NULL );
 }
 
-inline long BitmapReadAccess::Width() const
+inline long BitmapInfoAccess::Width() const
 {
     return( mpBuffer ? mpBuffer->mnWidth : 0L );
 }
 
-inline long BitmapReadAccess::Height() const
+inline long BitmapInfoAccess::Height() const
 {
     return( mpBuffer ? mpBuffer->mnHeight : 0L );
 }
 
-inline Point BitmapReadAccess::TopLeft() const
+inline Point BitmapInfoAccess::TopLeft() const
 {
     return Point();
 }
 
-inline Point BitmapReadAccess::BottomRight() const
+inline Point BitmapInfoAccess::BottomRight() const
 {
     return Point( Width() - 1L, Height() - 1L );
 }
 
-inline bool BitmapReadAccess::IsTopDown() const
+inline bool BitmapInfoAccess::IsTopDown() const
 {
     assert(mpBuffer && "Access is not valid!");
     return mpBuffer && ( BMP_SCANLINE_ADJUSTMENT( mpBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN );
 }
 
-inline bool BitmapReadAccess::IsBottomUp() const
+inline bool BitmapInfoAccess::IsBottomUp() const
 {
     return !IsTopDown();
 }
 
-inline sal_uLong BitmapReadAccess::GetScanlineFormat() const
+inline sal_uLong BitmapInfoAccess::GetScanlineFormat() const
 {
     assert(mpBuffer && "Access is not valid!");
     return( mpBuffer ? BMP_SCANLINE_FORMAT( mpBuffer->mnFormat ) : 0UL );
 }
 
-inline sal_uLong BitmapReadAccess::GetScanlineSize() const
+inline sal_uLong BitmapInfoAccess::GetScanlineSize() const
 {
     assert(mpBuffer && "Access is not valid!");
     return( mpBuffer ? mpBuffer->mnScanlineSize : 0UL );
 }
 
-inline sal_uInt16  BitmapReadAccess::GetBitCount() const
+inline sal_uInt16  BitmapInfoAccess::GetBitCount() const
 {
     assert(mpBuffer && "Access is not valid!");
     return( mpBuffer ? mpBuffer->mnBitCount : 0 );
 }
 
-inline BitmapColor BitmapReadAccess::GetBestMatchingColor( const BitmapColor& rBitmapColor )
+inline BitmapColor BitmapInfoAccess::GetBestMatchingColor( const BitmapColor& rBitmapColor )
 {
     if( HasPalette() )
         return BitmapColor( (sal_uInt8) GetBestPaletteIndex( rBitmapColor ) );
@@ -268,50 +292,37 @@ inline BitmapColor BitmapReadAccess::GetBestMatchingColor( const BitmapColor& rB
         return rBitmapColor;
 }
 
-inline Scanline BitmapReadAccess::GetBuffer() const
-{
-    assert(mpBuffer && "Access is not valid!");
-    return( mpBuffer ? mpBuffer->mpBits : NULL );
-}
-
-inline Scanline BitmapReadAccess::GetScanline( long nY ) const
-{
-    assert(mpBuffer && "Access is not valid!");
-    assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
-    return( mpBuffer ? mpScanBuf[ nY ] : NULL );
-}
-
-inline bool BitmapReadAccess::HasPalette() const
+inline bool BitmapInfoAccess::HasPalette() const
 {
     assert(mpBuffer && "Access is not valid!");
     return( mpBuffer && !!mpBuffer->maPalette );
 }
 
-inline const BitmapPalette& BitmapReadAccess::GetPalette() const
+inline const BitmapPalette& BitmapInfoAccess::GetPalette() const
 {
     assert(mpBuffer && "Access is not valid!");
     return mpBuffer->maPalette;
 }
 
-inline sal_uInt16 BitmapReadAccess::GetPaletteEntryCount() const
+inline sal_uInt16 BitmapInfoAccess::GetPaletteEntryCount() const
 {
     assert(HasPalette() && "Bitmap has no palette!");
     return( HasPalette() ? mpBuffer->maPalette.GetEntryCount() : 0 );
 }
 
-inline const BitmapColor& BitmapReadAccess::GetPaletteColor( sal_uInt16 nColor ) const
+inline const BitmapColor& BitmapInfoAccess::GetPaletteColor( sal_uInt16 nColor ) const
 {
     assert(mpBuffer && "Access is not valid!");
     assert(HasPalette() && "Bitmap has no palette!");
     return mpBuffer->maPalette[ nColor ];
 }
 
-inline const BitmapColor& BitmapReadAccess::GetBestPaletteColor( const BitmapColor& rBitmapColor ) const
+inline const BitmapColor& BitmapInfoAccess::GetBestPaletteColor( const BitmapColor& rBitmapColor ) const
 {
     return GetPaletteColor( GetBestPaletteIndex( rBitmapColor ) );
 }
 
-inline bool BitmapReadAccess::HasColorMask() const
+inline bool BitmapInfoAccess::HasColorMask() const
 {
     assert(mpBuffer && "Access is not valid!");
     const sal_uLong nFormat = BMP_SCANLINE_FORMAT( mpBuffer->mnFormat );
@@ -323,12 +334,25 @@ inline bool BitmapReadAccess::HasColorMask() const
             nFormat == BMP_FORMAT_32BIT_TC_MASK );
 }
 
-inline ColorMask& BitmapReadAccess::GetColorMask() const
+inline ColorMask& BitmapInfoAccess::GetColorMask() const
 {
     assert(mpBuffer && "Access is not valid!");
     return mpBuffer->maColorMask;
 }
 
+inline Scanline BitmapReadAccess::GetBuffer() const
+{
+    assert(mpBuffer && "Access is not valid!");
+    return( mpBuffer ? mpBuffer->mpBits : NULL );
+}
+
+inline Scanline BitmapReadAccess::GetScanline( long nY ) const
+{
+    assert(mpBuffer && "Access is not valid!");
+    assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
+    return( mpBuffer ? mpScanBuf[ nY ] : NULL );
+}
+
 inline BitmapColor BitmapReadAccess::GetPixel( long nY, long nX ) const
 {
     assert(mpBuffer && "Access is not valid!");
diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx
index 9859aa3..d4ccb94 100644
--- a/include/vcl/salbtype.hxx
+++ b/include/vcl/salbtype.hxx
@@ -268,6 +268,16 @@ struct VCL_DLLPUBLIC BitmapBuffer
 };
 
 
+// - Access modes -
+typedef enum
+{
+    BITMAP_INFO_ACCESS,
+    BITMAP_READ_ACCESS,
+    BITMAP_WRITE_ACCESS
+}
+BitmapAccessMode;
+
+
 // - StretchAndConvert -
 
 
diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx
index f548cee..1e63ab0 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 014b0e9..bc2b2b9 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 61672fc..cb3336d 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 de70989..5e4586d 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 2a30764..200698f 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 6b1fa04..1bef240 100644
--- a/vcl/inc/quartz/salbmp.h
+++ b/vcl/inc/quartz/salbmp.h
@@ -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/salbmp.hxx b/vcl/inc/salbmp.hxx
index 9760bc6..0020a28 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -22,6 +22,7 @@
 
 #include <tools/gen.hxx>
 #include <vcl/dllapi.h>
+#include <vcl/salbtype.hxx>
 
 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
 
@@ -52,8 +53,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 089f7d8..e7d0953 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 12fd4ca..c1db93b 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 94c0c87..20ef2c4 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 fab5f13..35fb010 100644
--- a/vcl/quartz/salbmp.cxx
+++ b/vcl/quartz/salbmp.cxx
@@ -706,7 +706,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()) )
@@ -745,10 +745,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 e9e5fd6..daee333 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 134764b..a77f33e 100644
--- a/vcl/source/gdi/bmpacc.cxx
+++ b/vcl/source/gdi/bmpacc.cxx
@@ -25,32 +25,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();
 
@@ -58,18 +52,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 )
         {
@@ -79,59 +74,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;
@@ -271,11 +302,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
@@ -384,7 +410,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 5a47845..4f4684d 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 28beaf4..14a4c28 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);
         }
     }
 }
@@ -715,11 +715,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 );
     }
@@ -893,7 +893,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!
@@ -938,7 +938,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 818cdee..14df493 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 c7c8024..9a2397b 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -1565,11 +1565,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 );
 
@@ -1604,8 +1604,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 e17b3e1..6e6361a 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 15ab284..209c18d 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))
@@ -288,7 +288,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
             BMP_FORMAT_24BIT_TC_BGR,
             0);
 
-        pSalRGB->ReleaseBuffer(pRGB, true);
+        pSalRGB->ReleaseBuffer(pRGB, BITMAP_WRITE_ACCESS);
         pRGB = pExtraRGB;
     }
 
@@ -342,7 +342,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
     }
     else
     {
-        pSalRGB->ReleaseBuffer(pRGB, true);
+        pSalRGB->ReleaseBuffer(pRGB, BITMAP_READ_ACCESS);
     }
 
     if(pExtraWinSalRGB)
@@ -367,7 +367,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))
@@ -385,7 +385,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;
     }
 
@@ -400,7 +400,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))
@@ -419,7 +419,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;
     }
 
@@ -489,7 +489,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
     }
     else
     {
-        pSalA->ReleaseBuffer(pA, true);
+        pSalA->ReleaseBuffer(pA, BITMAP_READ_ACCESS);
     }
 
     if(pExtraWinSalA)
@@ -506,7 +506,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
     }
     else
     {
-        pSalRGB->ReleaseBuffer(pRGB, true);
+        pSalRGB->ReleaseBuffer(pRGB, BITMAP_READ_ACCESS);
     }
 
     if(pExtraWinSalRGB)
@@ -849,7 +849,7 @@ HANDLE WinSalBitmap::ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB )
     return hCopy;
 }
 
-BitmapBuffer* WinSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
+BitmapBuffer* WinSalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ )
 {
     BitmapBuffer* pBuffer = NULL;
 
@@ -946,13 +946,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();


More information about the Libreoffice-commits mailing list