summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-01-31 10:32:11 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-01-31 14:48:54 +0100
commita3251b83e3fb49b5dc28dde8825f71d0e468f4bb (patch)
treee85ed4c859a898e374d011829be65546298f02a8 /vcl/source
parent96ae2a3300811897c24cccb20f8c2faf382483df (diff)
ofz: speed up bitmap image fuzzing
Change-Id: I73c9ee7aef7062e3cb025c6ae0f3bb6a91485330 Reviewed-on: https://gerrit.libreoffice.org/48983 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/filter/ixbm/xbmread.cxx3
-rw-r--r--vcl/source/filter/ixpm/xpmread.cxx10
-rw-r--r--vcl/source/gdi/dibtools.cxx44
3 files changed, 34 insertions, 23 deletions
diff --git a/vcl/source/filter/ixbm/xbmread.cxx b/vcl/source/filter/ixbm/xbmread.cxx
index 9cbfd4ad4b46..916318f2a2af 100644
--- a/vcl/source/filter/ixbm/xbmread.cxx
+++ b/vcl/source/filter/ixbm/xbmread.cxx
@@ -241,8 +241,9 @@ bool XBMReader::ParseData( SvStream* pInStm, const OString& aLastLine, XBMFormat
if( bProcessed )
{
+ Scanline pScanline = pAcc1->GetScanline(nRow);
while( ( nCol < nWidth ) && ( nBit < nBits ) )
- pAcc1->SetPixel( nRow, nCol++, ( nValue & ( 1 << nBit++ ) ) ? aBlack : aWhite );
+ pAcc1->SetPixelOnData(pScanline, nCol++, ( nValue & ( 1 << nBit++ ) ) ? aBlack : aWhite);
if( nCol == nWidth )
{
diff --git a/vcl/source/filter/ixpm/xpmread.cxx b/vcl/source/filter/ixpm/xpmread.cxx
index 1770a37b0b47..b7f01276bbdf 100644
--- a/vcl/source/filter/ixpm/xpmread.cxx
+++ b/vcl/source/filter/ixpm/xpmread.cxx
@@ -305,6 +305,8 @@ bool XPMReader::ImplGetScanLine( sal_uLong nY )
bStatus = false;
else
{
+ Scanline pScanline = mpAcc->GetScanline(nY);
+ Scanline pMaskScanline = mpMaskAcc ? mpMaskAcc->GetScanline(nY) : nullptr;
for (sal_uLong i = 0; i < mnWidth; ++i)
{
OString aKey(reinterpret_cast<sal_Char*>(pString), mnCpp);
@@ -312,11 +314,11 @@ bool XPMReader::ImplGetScanLine( sal_uLong nY )
if (it != maColMap.end())
{
if (mnColors > 256)
- mpAcc->SetPixel(nY, i, Color(it->second[1], it->second[2], it->second[3]));
+ mpAcc->SetPixelOnData(pScanline, i, Color(it->second[1], it->second[2], it->second[3]));
else
- mpAcc->SetPixel(nY, i, BitmapColor(it->second[1]));
- if (mpMaskAcc)
- mpMaskAcc->SetPixel(nY, i, it->second[0] ? aWhite : aBlack);
+ mpAcc->SetPixelOnData(pScanline, i, BitmapColor(it->second[1]));
+ if (pMaskScanline)
+ mpMaskAcc->SetPixelOnData(pMaskScanline, i, it->second[0] ? aWhite : aBlack);
}
pString += mnCpp;
}
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index a8fee2ad85e4..bebee1458e9e 100644
--- a/vcl/source/gdi/dibtools.cxx
+++ b/vcl/source/gdi/dibtools.cxx
@@ -376,6 +376,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
if( nRunByte > 2 )
{
+ Scanline pScanline = rAcc.GetScanline(nY);
if( bRLE4 )
{
nCountByte = nRunByte >> 1;
@@ -388,10 +389,10 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
cTmp = *pRLE++;
if( nX < nWidth )
- rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)));
if( nX < nWidth )
- rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp & 0x0f, rPalette, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp & 0x0f, rPalette, bForceToMonoWhileReading)));
}
if( nRunByte & 1 )
@@ -400,7 +401,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
return false;
if( nX < nWidth )
- rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(*pRLE >> 4, rPalette, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(*pRLE >> 4, rPalette, bForceToMonoWhileReading)));
pRLE++;
}
@@ -421,7 +422,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
return false;
if( nX < nWidth )
- rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(*pRLE, rPalette, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(*pRLE, rPalette, bForceToMonoWhileReading)));
pRLE++;
}
@@ -461,6 +462,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
return false;
cTmp = *pRLE++;
+ Scanline pScanline = rAcc.GetScanline(nY);
if( bRLE4 )
{
nRunByte = nCountByte >> 1;
@@ -468,19 +470,19 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
for( sal_uLong i = 0; i < nRunByte; i++ )
{
if( nX < nWidth )
- rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)));
if( nX < nWidth )
- rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp & 0x0f, rPalette, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp & 0x0f, rPalette, bForceToMonoWhileReading)));
}
if( ( nCountByte & 1 ) && ( nX < nWidth ) )
- rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)));
}
else
{
for( sal_uLong i = 0; ( i < nCountByte ) && ( nX < nWidth ); i++ )
- rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp, rPalette, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp, rPalette, bForceToMonoWhileReading)));
}
}
}
@@ -584,7 +586,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false;
}
sal_uInt8 cTmp = *pTmp++;
-
+ Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0, nShift = 8; nX < nWidth; nX++ )
{
if( !nShift )
@@ -594,7 +596,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
}
auto nIndex = (cTmp >> --nShift) & 1;
- rAcc.SetPixelIndex(nY, nX, SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX, BitmapColor(SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)));
}
}
}
@@ -611,7 +613,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false;
}
sal_uInt8 cTmp = *pTmp++;
-
+ Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0, nShift = 2; nX < nWidth; nX++ )
{
if( !nShift )
@@ -621,7 +623,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
}
auto nIndex = (cTmp >> ( --nShift << 2 ) ) & 0x0f;
- rAcc.SetPixelIndex(nY, nX, SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX, BitmapColor(SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)));
}
}
}
@@ -638,10 +640,11 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false;
}
+ Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0; nX < nWidth; nX++ )
{
auto nIndex = *pTmp++;
- rAcc.SetPixelIndex(nY, nX, SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX, BitmapColor(SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)));
}
}
}
@@ -671,10 +674,11 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false;
}
+ Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0; nX < nWidth; nX++ )
{
aMask.GetColorFor16BitLSB( aColor, reinterpret_cast<sal_uInt8*>(pTmp16++) );
- rAcc.SetPixel(nY, nX, SanitizeColor(aColor, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, bForceToMonoWhileReading));
}
}
}
@@ -693,12 +697,13 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false;
}
+ Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0; nX < nWidth; nX++ )
{
aPixelColor.SetBlue( *pTmp++ );
aPixelColor.SetGreen( *pTmp++ );
aPixelColor.SetRed( *pTmp++ );
- rAcc.SetPixel(nY, nX, SanitizeColor(aPixelColor, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aPixelColor, bForceToMonoWhileReading));
}
}
}
@@ -733,11 +738,13 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false;
}
+ Scanline pScanline = rAcc.GetScanline(nY);
+ Scanline pAlphaScanline = pAccAlpha->GetScanline(nY);
for( long nX = 0; nX < nWidth; nX++ )
{
aMask.GetColorAndAlphaFor32Bit( aColor, aAlpha, reinterpret_cast<sal_uInt8*>(pTmp32++) );
- rAcc.SetPixel(nY, nX, SanitizeColor(aColor, bForceToMonoWhileReading));
- pAccAlpha->SetPixelIndex(nY, nX, sal_uInt8(0xff) - aAlpha);
+ rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, bForceToMonoWhileReading));
+ pAccAlpha->SetPixelOnData(pAlphaScanline, nX, BitmapColor(sal_uInt8(0xff) - aAlpha));
rAlphaUsed |= 0xff != aAlpha;
}
}
@@ -753,10 +760,11 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false;
}
+ Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0; nX < nWidth; nX++ )
{
aMask.GetColorFor32Bit( aColor, reinterpret_cast<sal_uInt8*>(pTmp32++) );
- rAcc.SetPixel(nY, nX, SanitizeColor(aColor, bForceToMonoWhileReading));
+ rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, bForceToMonoWhileReading));
}
}
}