diff options
author | panoskorovesis <panoskorovesis@outlook.com> | 2021-08-10 14:30:10 +0300 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-08-17 04:42:31 +0200 |
commit | 9bd336d6566897a6d2238bf38f927a20ae981da9 (patch) | |
tree | 3aacd1a35f87b00ea0259fb1638f204467ad5c8c /vcl/source/gdi | |
parent | 20d48960d7c6d1fda499983853c9c4e4c9b3f9e1 (diff) |
Move GDIMetaFile::GetChecksum to SvmWriter::GetChecksum
Move the method and update all the method calls from
GDIMetaFile::GetChecksum -> SvmWriter::GetChecksum
Remove the method from gdimtf
Change-Id: I68e2b3cf99178947ac4f1474810dd5568f07e122
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120414
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r-- | vcl/source/gdi/gdimtf.cxx | 343 | ||||
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 2 |
2 files changed, 1 insertions, 344 deletions
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 60e3ec0f293d..cfeaf1d0a4b3 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -2212,349 +2212,6 @@ GDIMetaFile GDIMetaFile::GetMonochromeMtf( const Color& rColor ) const return aRet; } -BitmapChecksum GDIMetaFile::GetChecksum() const -{ - 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++ ) - { - MetaAction* pAction = GetAction( i ); - - switch( pAction->GetType() ) - { - case MetaActionType::BMP: - { - MetaBmpAction* pAct = static_cast<MetaBmpAction*>(pAction); - - ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); - nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - - BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); - nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); - - Int32ToSVBT32( pAct->GetPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - } - break; - - case MetaActionType::BMPSCALE: - { - MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction); - - ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); - nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - - BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); - nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); - - Int32ToSVBT32( pAct->GetPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSize().Width(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSize().Height(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - } - break; - - case MetaActionType::BMPSCALEPART: - { - MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction); - - ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); - nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - - BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); - nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); - - Int32ToSVBT32( pAct->GetDestPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetDestSize().Width(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetDestSize().Height(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - } - break; - - case MetaActionType::BMPEX: - { - MetaBmpExAction* pAct = static_cast<MetaBmpExAction*>(pAction); - - ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); - nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - - BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA ); - nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); - - Int32ToSVBT32( pAct->GetPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - } - break; - - case MetaActionType::BMPEXSCALE: - { - MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pAction); - - ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); - nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - - BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA ); - nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); - - Int32ToSVBT32( pAct->GetPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSize().Width(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSize().Height(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - } - break; - - case MetaActionType::BMPEXSCALEPART: - { - MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pAction); - - ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); - nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - - BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA ); - nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); - - Int32ToSVBT32( pAct->GetDestPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetDestSize().Width(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetDestSize().Height(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - } - break; - - case MetaActionType::MASK: - { - MetaMaskAction* pAct = static_cast<MetaMaskAction*>(pAction); - - ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); - nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - - BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); - nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); - - UInt32ToSVBT32( sal_uInt32(pAct->GetColor()), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - } - break; - - case MetaActionType::MASKSCALE: - { - MetaMaskScaleAction* pAct = static_cast<MetaMaskScaleAction*>(pAction); - - ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); - nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - - BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); - nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); - - UInt32ToSVBT32( sal_uInt32(pAct->GetColor()), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSize().Width(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSize().Height(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - } - break; - - case MetaActionType::MASKSCALEPART: - { - MetaMaskScalePartAction* pAct = static_cast<MetaMaskScalePartAction*>(pAction); - - ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 ); - nCrc = vcl_get_checksum( nCrc, aBT16, 2 ); - - BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA ); - nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); - - UInt32ToSVBT32( sal_uInt32(pAct->GetColor()), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetDestPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetDestSize().Width(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetDestSize().Height(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - } - break; - - case MetaActionType::EPS : - { - MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pAction); - nCrc = vcl_get_checksum( nCrc, pAct->GetLink().GetData(), pAct->GetLink().GetDataSize() ); - } - break; - - case MetaActionType::CLIPREGION : - { - MetaClipRegionAction& rAct = static_cast<MetaClipRegionAction&>(*pAction); - const vcl::Region& rRegion = rAct.GetRegion(); - - if(rRegion.HasPolyPolygonOrB2DPolyPolygon()) - { - // It has shown that this is a possible bottleneck for checksum calculation. - // In worst case a very expensive RegionHandle representation gets created. - // In this case it's cheaper to use the PolyPolygon - const basegfx::B2DPolyPolygon aPolyPolygon(rRegion.GetAsB2DPolyPolygon()); - SVBT64 aSVBT64; - - for(auto const& rPolygon : aPolyPolygon) - { - const sal_uInt32 nPointCount(rPolygon.count()); - const bool bControl(rPolygon.areControlPointsUsed()); - - for(sal_uInt32 b(0); b < nPointCount; b++) - { - const basegfx::B2DPoint aPoint(rPolygon.getB2DPoint(b)); - - DoubleToSVBT64(aPoint.getX(), aSVBT64); - nCrc = vcl_get_checksum(nCrc, aSVBT64, 8); - DoubleToSVBT64(aPoint.getY(), aSVBT64); - nCrc = vcl_get_checksum(nCrc, aSVBT64, 8); - - if(bControl) - { - if(rPolygon.isPrevControlPointUsed(b)) - { - const basegfx::B2DPoint aCtrl(rPolygon.getPrevControlPoint(b)); - - DoubleToSVBT64(aCtrl.getX(), aSVBT64); - nCrc = vcl_get_checksum(nCrc, aSVBT64, 8); - DoubleToSVBT64(aCtrl.getY(), aSVBT64); - nCrc = vcl_get_checksum(nCrc, aSVBT64, 8); - } - - if(rPolygon.isNextControlPointUsed(b)) - { - const basegfx::B2DPoint aCtrl(rPolygon.getNextControlPoint(b)); - - DoubleToSVBT64(aCtrl.getX(), aSVBT64); - nCrc = vcl_get_checksum(nCrc, aSVBT64, 8); - DoubleToSVBT64(aCtrl.getY(), aSVBT64); - nCrc = vcl_get_checksum(nCrc, aSVBT64, 8); - } - } - } - } - - sal_uInt8 tmp = static_cast<sal_uInt8>(rAct.IsClipping()); - nCrc = vcl_get_checksum(nCrc, &tmp, 1); - } - else - { - pAction->Write( aMemStm, &aWriteData ); - nCrc = vcl_get_checksum( nCrc, aMemStm.GetData(), aMemStm.Tell() ); - aMemStm.Seek( 0 ); - } - } - break; - - default: - { - pAction->Write( aMemStm, &aWriteData ); - nCrc = vcl_get_checksum( nCrc, aMemStm.GetData(), aMemStm.Tell() ); - aMemStm.Seek( 0 ); - } - break; - } - } - - return nCrc; -} - sal_uLong GDIMetaFile::GetSizeBytes() const { sal_uLong nSizeBytes = 0; diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 6e4416935100..ae3f2209a8a8 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1742,7 +1742,7 @@ BitmapChecksum ImpGraphic::getChecksum() const case GraphicType::GdiMetafile: { - mnChecksum = maMetaFile.GetChecksum(); + mnChecksum = SvmWriter::GetChecksum(maMetaFile); } break; } |