vcl/qa/cppunit/svm/svmtest.cxx | 8 ++++---- vcl/source/bitmap/salbmp.cxx | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-)
New commits: commit b1c119679700630d16bcf76d96a99e3a39908914 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Tue Jun 30 09:38:43 2020 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Wed Jul 1 07:35:25 2020 +0200 do not use scanline padding for computing vcl bitmap checksum This idea of checksums is still kind of broken (different RGB order or different scaling algorithm make the checksum different between different VCL backends). But at least don't include undefined garbage. Change-Id: Ia03bb960c50d3da51dad9b37de7a4f709d8ee206 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97484 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx index 413c3b7f69f4..9deed5e13c10 100644 --- a/vcl/qa/cppunit/svm/svmtest.cxx +++ b/vcl/qa/cppunit/svm/svmtest.cxx @@ -1012,10 +1012,10 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile) "281fc589", "5e01ddcc", "4df0e464", - "34434a50", - "d1736327", - "b37875c2", - "a85d44b8", + "6c1263f9", + "747e8dfb", + "3c80d829", + "71efc447", }); } diff --git a/vcl/source/bitmap/salbmp.cxx b/vcl/source/bitmap/salbmp.cxx index 3932c12b8ce7..6d955b6aa4d3 100644 --- a/vcl/source/bitmap/salbmp.cxx +++ b/vcl/source/bitmap/salbmp.cxx @@ -30,7 +30,20 @@ void SalBitmap::updateChecksum() const if (pBuf) { nCrc = pBuf->maPalette.GetChecksum(); - nCrc = vcl_get_checksum(nCrc, pBuf->mpBits, pBuf->mnScanlineSize * pBuf->mnHeight); + const int bytesPerPixel = ( pBuf->mnBitCount + 7 ) / 8; + if( pBuf->mnFormat & ScanlineFormat::TopDown ) + { + if( pBuf->mnScanlineSize == pBuf->mnWidth * bytesPerPixel ) + nCrc = vcl_get_checksum(nCrc, pBuf->mpBits, pBuf->mnScanlineSize * pBuf->mnHeight); + else // Do not include padding with undefined content in the checksum. + for( long y = 0; y < pBuf->mnHeight; ++y ) + nCrc = vcl_get_checksum(nCrc, pBuf->mpBits + y * pBuf->mnScanlineSize, pBuf->mnWidth * bytesPerPixel); + } + else // Compute checksum in the order of scanlines, to make it consistent between different bitmap implementations. + { + for( long y = pBuf->mnHeight - 1; y >= 0; --y ) + nCrc = vcl_get_checksum(nCrc, pBuf->mpBits + y * pBuf->mnScanlineSize, pBuf->mnWidth * bytesPerPixel); + } pThis->ReleaseBuffer(pBuf, BitmapAccessMode::Read); pThis->mnChecksum = nCrc; pThis->mbChecksumValid = true; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits