diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2014-11-14 11:56:46 +0000 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-11-15 13:51:36 +0100 |
commit | f5b3ea832e39da9bd70fa132699acb533f1e474f (patch) | |
tree | d8b5057672834c815b593c9488643774013ff253 | |
parent | c7d87b7224557d76d5741311b9c8af627a6ccc79 (diff) |
vcl: Fix palette modification during BitmapWriteAccess lifetime.
Change-Id: I8bdedd63895ff0b3245d996cf35ac92d9ab0ff9d
-rw-r--r-- | vcl/opengl/salbmp.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 2e197d320bf0..e411f2cde472 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -239,9 +239,12 @@ public: ImplPixelFormat8( const BitmapPalette& rPalette ) : mrPalette( rPalette ) { + if ( mrPalette.GetEntryCount() < 256 ) + SAL_WARN( "vcl.opengl", "Bad sign, if we get an OOB pixel we die" ); } virtual const BitmapColor& ReadPixel() SAL_OVERRIDE { + assert( mrPalette.GetEntryCount() > *mpData ); return mrPalette[ *mpData++ ]; } }; @@ -259,6 +262,8 @@ public: , mnX(0) , mnShift(4) { + if ( mrPalette.GetEntryCount() < 16 ) + SAL_WARN( "vcl.opengl", "Bad sign, if we get an OOB pixel we die" ); } virtual void StartLine( sal_uInt8* pLine ) SAL_OVERRIDE { @@ -268,7 +273,9 @@ public: } virtual const BitmapColor& ReadPixel() SAL_OVERRIDE { - const BitmapColor& rColor = mrPalette[( mpData[mnX >> 1] >> mnShift) & 0x0f]; + sal_uInt32 nIdx = ( mpData[mnX >> 1] >> mnShift) & 0x0f; + assert( mrPalette.GetEntryCount() > nIdx ); + const BitmapColor& rColor = mrPalette[nIdx]; mnX++; mnShift ^= 4; return rColor; @@ -517,6 +524,9 @@ void OpenGLSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) maTexture = OpenGLTexture(); mbDirtyTexture = true; } + // The palette is modified on read during the BitmapWriteAccess, + // but of course, often it is not modified; interesting. + maPalette = pBuffer->maPalette; delete pBuffer; } |