diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2015-08-27 22:57:15 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-09-01 16:28:46 +0100 |
commit | 209951a8ae71ae38d57457a5a85005be8f46dcdf (patch) | |
tree | 9bab49617fc392444cc74753d53312531cbe676f | |
parent | b545728fddad2e70b6a38515b60455fc229e63af (diff) |
switch to 64-bit checksum: conversion from BitmapChecksum to an octet array
Defined BitmapChecksumOctetArray which is an array of bytes whose size
is the same of BitmapChecksum.
Defined a routine for converting a BitmapChecksum into a
BitmapChecksumOctetArray.
Change-Id: I70d17ab8b841795ae27c60b418d6b090bff604bb
-rw-r--r-- | include/vcl/checksum.hxx | 21 | ||||
-rw-r--r-- | vcl/source/gdi/animate.cxx | 5 | ||||
-rw-r--r-- | vcl/source/gdi/bitmapex.cxx | 5 | ||||
-rw-r--r-- | vcl/source/gdi/gdimtf.cxx | 49 |
4 files changed, 50 insertions, 30 deletions
diff --git a/include/vcl/checksum.hxx b/include/vcl/checksum.hxx index 2987fdae4cc0..83facefd6c9e 100644 --- a/include/vcl/checksum.hxx +++ b/include/vcl/checksum.hxx @@ -26,6 +26,11 @@ #include <sal/types.h> #include <tools/solar.h> +#include <boost/preprocessor/arithmetic/inc.hpp> +#include <boost/preprocessor/arithmetic/mul.hpp> +#include <boost/preprocessor/repetition/repeat_from_to.hpp> + + /*======================================================================== * * vcl_crc64Table (CRC polynomial 0x95AC9329AC4BC9B5ULL). @@ -120,9 +125,21 @@ static const sal_uInt64 vcl_crc64Table[256] = { 0x29b7d047efec8728ULL }; -typedef sal_uLong BitmapChecksum; +#define BITMAP_CHECKSUM_SIZE 4 +#define BITMAP_CHECKSUM_BITS BOOST_PP_MUL(BITMAP_CHECKSUM_SIZE, 8) + +typedef sal_uLong BitmapChecksum; + +typedef sal_uInt8 BitmapChecksumOctetArray[BITMAP_CHECKSUM_SIZE]; -#define BITMAP_CHECKSUM_BITS (sizeof(BitmapChecksum) * 8) +#define BITMAP_CHECKSUM_SET_OCTET(z, i, unused) \ +p[i] = (sal_uInt8)(n >> BOOST_PP_MUL(8, i)); + + +inline void BCToBCOA( BitmapChecksum n , BitmapChecksumOctetArray p ) +{ + BOOST_PP_REPEAT(BITMAP_CHECKSUM_SIZE , BITMAP_CHECKSUM_SET_OCTET, unused) +} #ifdef __cplusplus extern "C" { diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx index c5803e4ca1ea..4e5b333a81d4 100644 --- a/vcl/source/gdi/animate.cxx +++ b/vcl/source/gdi/animate.cxx @@ -209,6 +209,7 @@ sal_uLong Animation::GetSizeBytes() const BitmapChecksum Animation::GetChecksum() const { SVBT32 aBT32; + BitmapChecksumOctetArray aBCOA; BitmapChecksum nCrc = GetBitmapEx().GetChecksum(); UInt32ToSVBT32( maList.size(), aBT32 ); @@ -225,8 +226,8 @@ BitmapChecksum Animation::GetChecksum() const for( size_t i = 0, nCount = maList.size(); i < nCount; i++ ) { - UInt32ToSVBT32( maList[ i ]->GetChecksum(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + BCToBCOA( maList[ i ]->GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); } return nCrc; diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index ab935d21bc9e..02c29e229b4a 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -312,6 +312,7 @@ BitmapChecksum BitmapEx::GetChecksum() const { BitmapChecksum nCrc = aBitmap.GetChecksum(); SVBT32 aBT32; + BitmapChecksumOctetArray aBCOA; UInt32ToSVBT32( (long) eTransparent, aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); @@ -321,8 +322,8 @@ BitmapChecksum BitmapEx::GetChecksum() const if( ( TRANSPARENT_BITMAP == eTransparent ) && !aMask.IsEmpty() ) { - UInt32ToSVBT32( aMask.GetChecksum(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + BCToBCOA( aMask.GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); } return nCrc; diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index d69914e699b0..3201a72cc859 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -2342,12 +2342,13 @@ GDIMetaFile GDIMetaFile::GetMonochromeMtf( const Color& rColor ) const BitmapChecksum GDIMetaFile::GetChecksum() const { - GDIMetaFile aMtf; - SvMemoryStream aMemStm( 65535, 65535 ); - ImplMetaWriteData aWriteData; - SVBT16 aBT16; - SVBT32 aBT32; - BitmapChecksum nCrc = 0; + GDIMetaFile aMtf; + SvMemoryStream aMemStm( 65535, 65535 ); + ImplMetaWriteData aWriteData; + SVBT16 aBT16; + SVBT32 aBT32; + BitmapChecksumOctetArray aBCOA; + BitmapChecksum nCrc = 0; aWriteData.meActualCharSet = aMemStm.GetStreamCharSet(); for( size_t i = 0, nObjCount = GetActionSize(); i < nObjCount; i++ ) @@ -2363,8 +2364,8 @@ BitmapChecksum GDIMetaFile::GetChecksum() const ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); @@ -2381,8 +2382,8 @@ BitmapChecksum GDIMetaFile::GetChecksum() const ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); @@ -2405,8 +2406,8 @@ BitmapChecksum GDIMetaFile::GetChecksum() const ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); UInt32ToSVBT32( pAct->GetDestPoint().X(), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); @@ -2441,8 +2442,8 @@ BitmapChecksum GDIMetaFile::GetChecksum() const ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - UInt32ToSVBT32( pAct->GetBitmapEx().GetChecksum(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); @@ -2459,8 +2460,8 @@ BitmapChecksum GDIMetaFile::GetChecksum() const ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - UInt32ToSVBT32( pAct->GetBitmapEx().GetChecksum(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); @@ -2483,8 +2484,8 @@ BitmapChecksum GDIMetaFile::GetChecksum() const ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - UInt32ToSVBT32( pAct->GetBitmapEx().GetChecksum(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); UInt32ToSVBT32( pAct->GetDestPoint().X(), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); @@ -2519,8 +2520,8 @@ BitmapChecksum GDIMetaFile::GetChecksum() const ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); UInt32ToSVBT32( pAct->GetColor().GetColor(), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); @@ -2540,8 +2541,8 @@ BitmapChecksum GDIMetaFile::GetChecksum() const ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); UInt32ToSVBT32( pAct->GetColor().GetColor(), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); @@ -2567,8 +2568,8 @@ BitmapChecksum GDIMetaFile::GetChecksum() const ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); UInt32ToSVBT32( pAct->GetColor().GetColor(), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); |