summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/source/flash/swfexporter.cxx14
-rw-r--r--filter/source/flash/swfexporter.hxx7
-rw-r--r--filter/source/flash/swfwriter.hxx3
-rw-r--r--filter/source/flash/swfwriter1.cxx2
-rw-r--r--filter/source/svg/svgexport.cxx10
-rw-r--r--filter/source/svg/svgwriter.cxx6
-rw-r--r--filter/source/svg/svgwriter.hxx2
-rw-r--r--include/vcl/alpha.hxx2
-rw-r--r--include/vcl/animate.hxx4
-rw-r--r--include/vcl/bitmap.hxx3
-rw-r--r--include/vcl/bitmapex.hxx2
-rw-r--r--include/vcl/checksum.hxx92
-rw-r--r--include/vcl/gdimtf.hxx2
-rw-r--r--include/vcl/graph.hxx4
-rw-r--r--svtools/source/graphic/grfcache.cxx8
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx2
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/Package_opengl.mk1
-rw-r--r--vcl/inc/impbmp.hxx7
-rw-r--r--vcl/inc/impgraph.hxx2
-rw-r--r--vcl/inc/opengl/program.hxx2
-rw-r--r--vcl/inc/opengl/salbmp.hxx3
-rw-r--r--vcl/inc/salbmp.hxx52
-rw-r--r--vcl/opengl/areaHashCRC64TFragmentShader.glsl87
-rw-r--r--vcl/opengl/program.cxx2
-rw-r--r--vcl/opengl/salbmp.cxx101
-rw-r--r--vcl/source/bitmap/checksum.cxx154
-rw-r--r--vcl/source/gdi/animate.cxx35
-rw-r--r--vcl/source/gdi/bitmap.cxx54
-rw-r--r--vcl/source/gdi/bitmapex.cxx13
-rw-r--r--vcl/source/gdi/gdimtf.cxx179
-rw-r--r--vcl/source/gdi/graph.cxx2
-rw-r--r--vcl/source/gdi/impbmp.cxx26
-rw-r--r--vcl/source/gdi/impgraph.cxx4
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx2
-rw-r--r--vcl/source/gdi/pdfwriter_impl.hxx4
-rw-r--r--vcl/unx/gtk/app/gtkinst.cxx2
37 files changed, 681 insertions, 215 deletions
diff --git a/filter/source/flash/swfexporter.cxx b/filter/source/flash/swfexporter.cxx
index f7e5250102de..b9bd58dd39c0 100644
--- a/filter/source/flash/swfexporter.cxx
+++ b/filter/source/flash/swfexporter.cxx
@@ -431,8 +431,8 @@ sal_uInt16 FlashExporter::exportDrawPageBackground(sal_uInt16 nPage, Reference<
getMetaFile( xCompMaster, aMtfMaster, true );
getMetaFile( xComponent, aMtfPrivate, true );
- sal_uInt32 masterchecksum = aMtfMaster.GetChecksum();
- sal_uInt32 privatechecksum = aMtfPrivate.GetChecksum();
+ BitmapChecksum masterchecksum = aMtfMaster.GetChecksum();
+ BitmapChecksum privatechecksum = aMtfPrivate.GetChecksum();
// AS: If the slide has its own background
if (privatechecksum)
@@ -484,7 +484,7 @@ sal_uInt16 FlashExporter::exportMasterPageObjects(sal_uInt16 nPage, Reference< X
{
Reference< XShapes > xShapes( xMasterPage, UNO_QUERY );
- sal_uInt32 shapesum = ActionSummer(xShapes);
+ BitmapChecksum shapesum = ActionSummer(xShapes);
ChecksumCache::iterator it = gObjectCache.find(shapesum);
@@ -631,7 +631,7 @@ void FlashExporter::exportShape( const Reference< XShape >& xShape, bool bMaster
getMetaFile( xComponent, aMtf, false, true );
sal_uInt16 nID;
- sal_uInt32 checksum = aMtf.GetChecksum();
+ BitmapChecksum checksum = aMtf.GetChecksum();
ChecksumCache::iterator it = gMetafileCache.find(checksum);
@@ -748,7 +748,7 @@ bool FlashExporter::getMetaFile( Reference< XComponent >&xComponent, GDIMetaFile
return rMtf.GetActionSize() != 0;
}
-sal_uInt32 FlashExporter::ActionSummer(Reference< XShape >& xShape)
+BitmapChecksum FlashExporter::ActionSummer(Reference< XShape >& xShape)
{
Reference< XShapes > xShapes( xShape, UNO_QUERY );
@@ -767,10 +767,10 @@ sal_uInt32 FlashExporter::ActionSummer(Reference< XShape >& xShape)
}
}
-sal_uInt32 FlashExporter::ActionSummer(Reference< XShapes >& xShapes)
+BitmapChecksum FlashExporter::ActionSummer(Reference< XShapes >& xShapes)
{
sal_uInt32 nShapeCount = xShapes->getCount();
- sal_uInt32 shapecount = 0;
+ BitmapChecksum shapecount = 0;
Reference< XShape > xShape2;
diff --git a/filter/source/flash/swfexporter.hxx b/filter/source/flash/swfexporter.hxx
index 2e78abdf7031..bfad3eecac4f 100644
--- a/filter/source/flash/swfexporter.hxx
+++ b/filter/source/flash/swfexporter.hxx
@@ -29,11 +29,12 @@
#include <com/sun/star/presentation/ClickAction.hpp>
#include <com/sun/star/presentation/FadeEffect.hpp>
#include <osl/file.hxx>
+#include <vcl/checksum.hxx>
#include <vector>
#include <map>
-typedef ::std::map<sal_uInt32, sal_uInt16> ChecksumCache;
+typedef ::std::map<BitmapChecksum, sal_uInt16> ChecksumCache;
class GDIMetaFile;
@@ -185,8 +186,8 @@ private:
void exportShapes( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes, bool bStream, bool bMaster );
void exportShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, bool bMaster);
- sal_uInt32 ActionSummer(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape);
- sal_uInt32 ActionSummer(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes);
+ BitmapChecksum ActionSummer(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape);
+ BitmapChecksum ActionSummer(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes);
void animateShape( ShapeAnimationInfo& rAnimInfo );
void animatePage( PageInfo* pPageInfo );
diff --git a/filter/source/flash/swfwriter.hxx b/filter/source/flash/swfwriter.hxx
index be08fb2fab43..215777bfef26 100644
--- a/filter/source/flash/swfwriter.hxx
+++ b/filter/source/flash/swfwriter.hxx
@@ -23,6 +23,7 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <vcl/checksum.hxx>
#include <vcl/font.hxx>
#include <vcl/gradient.hxx>
#include <vcl/vclptr.hxx>
@@ -106,7 +107,7 @@ sal_uInt32 getFixed( double fValue );
-typedef ::std::map<sal_uInt32, sal_uInt16> ChecksumCache;
+typedef ::std::map<BitmapChecksum, sal_uInt16> ChecksumCache;
/** unsigned int 16 compare operation for stl */
struct ltuint16
diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx
index 1ffdd486c003..e901529ce8ab 100644
--- a/filter/source/flash/swfwriter1.cxx
+++ b/filter/source/flash/swfwriter1.cxx
@@ -787,7 +787,7 @@ void getBitmapData( const BitmapEx& aBmpEx, sal_uInt8*& tgadata, sal_uInt8*& tga
sal_uInt16 Writer::defineBitmap( const BitmapEx &bmpSource, sal_Int32 nJPEGQualityLevel )
{
- sal_uLong bmpChecksum = bmpSource.GetChecksum();
+ BitmapChecksum bmpChecksum = bmpSource.GetChecksum();
ChecksumCache::iterator it = mBitmapCache.find(bmpChecksum);
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index a697793e5473..794c71342091 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -422,9 +422,9 @@ bool ObjectRepresentation::operator==( const ObjectRepresentation& rPresentation
-sal_uLong GetBitmapChecksum( const MetaAction* pAction )
+BitmapChecksum GetBitmapChecksum( const MetaAction* pAction )
{
- sal_uLong nChecksum = 0;
+ BitmapChecksum nChecksum = 0;
const MetaActionType nType = pAction->GetType();
switch( nType )
@@ -506,8 +506,8 @@ bool EqualityBitmap::operator()( const ObjectRepresentation& rObjRep1,
const GDIMetaFile& aMtf2 = rObjRep2.GetRepresentation();
if( aMtf1.GetActionSize() == 1 && aMtf2.GetActionSize() == 1 )
{
- sal_uLong nChecksum1 = GetBitmapChecksum( aMtf1.GetAction( 0 ) );
- sal_uLong nChecksum2 = GetBitmapChecksum( aMtf2.GetAction( 0 ) );
+ BitmapChecksum nChecksum1 = GetBitmapChecksum( aMtf1.GetAction( 0 ) );
+ BitmapChecksum nChecksum2 = GetBitmapChecksum( aMtf2.GetAction( 0 ) );
return ( nChecksum1 == nChecksum2 );
}
else
@@ -1301,7 +1301,7 @@ bool SVGFilter::implExportTextEmbeddedBitmaps()
MetaAction* pAction = aMtf.GetAction( 0 );
if( pAction )
{
- sal_uLong nId = GetBitmapChecksum( pAction );
+ BitmapChecksum nId = GetBitmapChecksum( pAction );
sId = "bitmap(" + OUString::number( nId ) + ")";
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sId );
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 56c5f76199e3..98e8484ff5c1 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -1361,7 +1361,7 @@ void SVGTextWriter::writeBitmapPlaceholder( const MetaBitmapActionType* pAction
}
// bitmap placeholder element
- sal_uLong nId = SVGActionWriter::GetChecksum( pAction );
+ BitmapChecksum nId = SVGActionWriter::GetChecksum( pAction );
OUString sId = "bitmap-placeholder(" + msShapeId + "." +
OUString::number( nId ) + ")";
@@ -1383,7 +1383,7 @@ void SVGTextWriter::implWriteEmbeddedBitmaps()
const GDIMetaFile& rMtf = *mpTextEmbeddedBitmapMtf;
OUString sId, sRefId;
- sal_uLong nId, nChecksum = 0;
+ BitmapChecksum nId, nChecksum = 0;
Point aPt;
Size aSz;
sal_uLong nCount = rMtf.GetActionSize();
@@ -1781,7 +1781,7 @@ OUString SVGActionWriter::GetPathString( const tools::PolyPolygon& rPolyPoly, bo
return aPathData;
}
-sal_uLong SVGActionWriter::GetChecksum( const MetaAction* pAction )
+BitmapChecksum SVGActionWriter::GetChecksum( const MetaAction* pAction )
{
GDIMetaFile aMtf;
MetaAction* pA = const_cast<MetaAction*>(pAction);
diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx
index 42efe63add03..c99e4cbbd6b0 100644
--- a/filter/source/svg/svgwriter.hxx
+++ b/filter/source/svg/svgwriter.hxx
@@ -371,7 +371,7 @@ private:
public:
static OUString GetPathString( const tools::PolyPolygon& rPolyPoly, bool bLine );
- static sal_uLong GetChecksum( const MetaAction* pAction );
+ static BitmapChecksum GetChecksum( const MetaAction* pAction );
public:
diff --git a/include/vcl/alpha.hxx b/include/vcl/alpha.hxx
index ec89be425e12..89b6996f18e5 100644
--- a/include/vcl/alpha.hxx
+++ b/include/vcl/alpha.hxx
@@ -52,7 +52,7 @@ public:
Size GetSizePixel() const { return Bitmap::GetSizePixel(); }
sal_uLong GetSizeBytes() const { return Bitmap::GetSizeBytes(); }
- sal_uLong GetChecksum() const { return Bitmap::GetChecksum(); }
+ BitmapChecksum GetChecksum() const { return Bitmap::GetChecksum(); }
Bitmap GetBitmap() const;
diff --git a/include/vcl/animate.hxx b/include/vcl/animate.hxx
index 1f2a6b8b3920..db62836225b9 100644
--- a/include/vcl/animate.hxx
+++ b/include/vcl/animate.hxx
@@ -97,7 +97,7 @@ struct VCL_DLLPUBLIC AnimationBitmap
rAnimBmp.aBmpEx.IsEqual( aBmpEx ) );
}
- sal_uLong GetChecksum() const;
+ BitmapChecksum GetChecksum() const;
};
struct AInfo
@@ -173,7 +173,7 @@ public:
void Replace( const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation );
sal_uLong GetSizeBytes() const;
- sal_uLong GetChecksum() const;
+ BitmapChecksum GetChecksum() const;
public:
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index a9f2146280c7..e9800a02b864 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -24,6 +24,7 @@
#include <tools/color.hxx>
#include <tools/link.hxx>
#include <tools/solar.h>
+#include <vcl/checksum.hxx>
#include <vcl/dllapi.h>
#include <vcl/mapmod.hxx>
#include <vcl/region.hxx>
@@ -386,7 +387,7 @@ public:
*/
bool GetSystemData( BitmapSystemData& rData ) const;
- sal_uLong GetChecksum() const;
+ BitmapChecksum GetChecksum() const;
Bitmap CreateDisplayBitmap( OutputDevice* pDisplay );
Bitmap GetColorTransformedBitmap() const;
diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx
index 096e2a050905..d609d8944532 100644
--- a/include/vcl/bitmapex.hxx
+++ b/include/vcl/bitmapex.hxx
@@ -96,7 +96,7 @@ public:
sal_uInt16 GetBitCount() const { return aBitmap.GetBitCount(); }
sal_uLong GetSizeBytes() const;
- sal_uLong GetChecksum() const;
+ BitmapChecksum GetChecksum() const;
public:
diff --git a/include/vcl/checksum.hxx b/include/vcl/checksum.hxx
new file mode 100644
index 000000000000..7e1076fb3139
--- /dev/null
+++ b/include/vcl/checksum.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#ifndef INCLUDED_VCL_INC_CHECKSUM_HXX
+#define INCLUDED_VCL_INC_CHECKSUM_HXX
+
+#include <sal/config.h>
+#include <sal/types.h>
+#include <tools/solar.h>
+#include <vcl/dllapi.h>
+
+#include <boost/preprocessor/arithmetic/inc.hpp>
+#include <boost/preprocessor/arithmetic/mul.hpp>
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+
+#define BITMAP_CHECKSUM_SIZE 8
+#define BITMAP_CHECKSUM_BITS BOOST_PP_MUL(BITMAP_CHECKSUM_SIZE, 8)
+
+typedef sal_uInt64 BitmapChecksum;
+typedef sal_uInt8 BitmapChecksumOctetArray[BITMAP_CHECKSUM_SIZE];
+
+#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" {
+#endif
+
+/*========================================================================
+ *
+ * vcl_crc64 interface.
+ *
+ *======================================================================*/
+/** Evaluate CRC64 over given data.
+
+ This function evaluates the CRC polynomial 0xEDB88320.
+
+ @param Crc [in] CRC64 over previous data or zero.
+ @param Data [in] data buffer.
+ @param DatLen [in] data buffer length.
+ @return new CRC64 value.
+ */
+VCL_DLLPUBLIC sal_uInt64 SAL_CALL vcl_crc64 (
+ sal_uInt64 Crc,
+ const void *Data, sal_uInt32 DatLen
+) SAL_THROW_EXTERN_C();
+
+
+
+VCL_DLLPUBLIC const sal_uInt64* vcl_get_crc64_table();
+
+
+#ifdef __cplusplus
+}
+#endif
+
+inline BitmapChecksum vcl_get_checksum (
+ BitmapChecksum Checksum,
+ const void *Data,
+ sal_uInt32 DatLen
+)
+{
+ return (BitmapChecksum)(vcl_crc64( Checksum, Data, DatLen ));
+}
+
+
+#endif // INCLUDED_VCL_INC_CHECKSUM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx
index 8baa116eea95..28075dcf1607 100644
--- a/include/vcl/gdimtf.hxx
+++ b/include/vcl/gdimtf.hxx
@@ -198,7 +198,7 @@ public:
void SetHookHdl( const Link<>& rLink ) { aHookHdlLink = rLink; }
const Link<>& GetHookHdl() const { return aHookHdlLink; }
- sal_uLong GetChecksum() const;
+ BitmapChecksum GetChecksum() const;
sal_uLong GetSizeBytes() const;
// Methods for reading and writing the new formats;
diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index 778c6719c4c7..929daf8ee1fb 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -161,9 +161,9 @@ public:
void SetAnimationNotifyHdl( const Link<>& rLink );
Link<> GetAnimationNotifyHdl() const;
- sal_uLong GetAnimationLoopCount() const;
+ sal_uLong GetAnimationLoopCount() const;
- sal_uLong GetChecksum() const;
+ BitmapChecksum GetChecksum() const;
public:
diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx
index 05c1f98c5cf5..28e4ab0a457e 100644
--- a/svtools/source/graphic/grfcache.cxx
+++ b/svtools/source/graphic/grfcache.cxx
@@ -43,7 +43,7 @@ private:
sal_uInt32 mnID1;
sal_uInt32 mnID2;
sal_uInt32 mnID3;
- sal_uInt32 mnID4;
+ BitmapChecksum mnID4;
public:
@@ -79,7 +79,7 @@ GraphicID::GraphicID( const GraphicObject& rObj )
mnID1 |= rSvgDataPtr->getSvgDataArrayLength();
mnID2 = basegfx::fround(rRange.getWidth());
mnID3 = basegfx::fround(rRange.getHeight());
- mnID4 = rtl_crc32(0, rSvgDataPtr->getSvgDataArray().get(), rSvgDataPtr->getSvgDataArrayLength());
+ mnID4 = vcl_get_checksum(0, rSvgDataPtr->getSvgDataArray().get(), rSvgDataPtr->getSvgDataArrayLength());
}
else if( rGraphic.IsAnimated() )
{
@@ -123,7 +123,7 @@ OString GraphicID::GetIDString() const
{
OStringBuffer aHexStr;
sal_Int32 nShift, nIndex = 0;
- aHexStr.setLength(32);
+ aHexStr.setLength(24 + (2 * BITMAP_CHECKSUM_SIZE));
for( nShift = 28; nShift >= 0; nShift -= 4 )
aHexStr[nIndex++] = aHexData[ ( mnID1 >> (sal_uInt32) nShift ) & 0xf ];
@@ -134,7 +134,7 @@ OString GraphicID::GetIDString() const
for( nShift = 28; nShift >= 0; nShift -= 4 )
aHexStr[nIndex++] = aHexData[ ( mnID3 >> (sal_uInt32) nShift ) & 0xf ];
- for( nShift = 28; nShift >= 0; nShift -= 4 )
+ for( nShift = BITMAP_CHECKSUM_BITS - 4; nShift >= 0; nShift -= 4 )
aHexStr[nIndex++] = aHexData[ ( mnID4 >> (sal_uInt32) nShift ) & 0xf ];
return aHexStr.makeStringAndClear();
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 291d9826ea5a..98ce91a1802d 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -750,7 +750,7 @@ DECLARE_OOXMLIMPORT_TEST(testN777345, "n777345.docx")
Graphic aGraphic(xGraphic);
// If this changes later, feel free to update it, but make sure it's not
// the checksum of a white/transparent placeholder rectangle.
- CPPUNIT_ASSERT_EQUAL(sal_uLong(2529763117U), aGraphic.GetChecksum());
+ CPPUNIT_ASSERT_EQUAL(BitmapChecksum(3652741777587093783), aGraphic.GetChecksum());
#endif
}
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 56231d0e689d..c6b33e64272d 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -318,6 +318,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/bitmap/bitmapscalesuper \
vcl/source/bitmap/BitmapSymmetryCheck \
vcl/source/bitmap/BitmapFilterStackBlur \
+ vcl/source/bitmap/checksum \
vcl/source/helper/canvasbitmap \
vcl/source/helper/canvastools \
vcl/source/helper/evntpost \
diff --git a/vcl/Package_opengl.mk b/vcl/Package_opengl.mk
index 2628dcd5d0bb..df3520c8483f 100644
--- a/vcl/Package_opengl.mk
+++ b/vcl/Package_opengl.mk
@@ -10,6 +10,7 @@
$(eval $(call gb_Package_Package,vcl_opengl_shader,$(SRCDIR)/vcl/opengl))
$(eval $(call gb_Package_add_files,vcl_opengl_shader,$(LIBO_ETC_FOLDER)/opengl,\
+ areaHashCRC64TFragmentShader.glsl \
areaScaleFastFragmentShader.glsl \
areaScaleFragmentShader.glsl \
blendedTextureFragmentShader.glsl \
diff --git a/vcl/inc/impbmp.hxx b/vcl/inc/impbmp.hxx
index 0dc9ec8bc974..cc09181b1cd2 100644
--- a/vcl/inc/impbmp.hxx
+++ b/vcl/inc/impbmp.hxx
@@ -34,7 +34,6 @@ class ImpBitmap
{
private:
sal_uLong mnRefCount;
- sal_uLong mnChecksum;
SalBitmap* mpSalBitmap;
public:
@@ -45,6 +44,8 @@ public:
ImpBitmap(SalBitmap* pBitmap);
~ImpBitmap();
+ bool ImplIsEqual(const ImpBitmap& rBmp) const;
+
SalBitmap* ImplGetSalBitmap() const { return mpSalBitmap; }
bool ImplCreate( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal );
@@ -62,8 +63,8 @@ public:
void ImplIncRefCount() { mnRefCount++; }
void ImplDecRefCount() { mnRefCount--; }
- inline void ImplSetChecksum( sal_uLong nChecksum ) { mnChecksum = nChecksum; }
- inline sal_uLong ImplGetChecksum() const { return mnChecksum; }
+ BitmapChecksum ImplGetChecksum() const;
+ void ImplInvalidateChecksum();
bool ImplScale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag );
bool ImplReplace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol );
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 6baed716244b..51937b5e9349 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -145,7 +145,7 @@ private:
GfxLink ImplGetLink();
bool ImplIsLink() const;
- sal_uLong ImplGetChecksum() const;
+ BitmapChecksum ImplGetChecksum() const;
bool ImplExportNative( SvStream& rOStm ) const;
diff --git a/vcl/inc/opengl/program.hxx b/vcl/inc/opengl/program.hxx
index 8289a56de4bf..7bdd43d3d51c 100644
--- a/vcl/inc/opengl/program.hxx
+++ b/vcl/inc/opengl/program.hxx
@@ -76,7 +76,7 @@ public:
void ApplyMatrix(float fWidth, float fHeight, float fPixelOffset = 0.0f);
- bool DrawTexture( OpenGLTexture& rTexture );
+ bool DrawTexture( const OpenGLTexture& rTexture );
protected:
void SetVertexAttrib( GLuint& rAttrib, const OString& rName, const GLvoid* pData );
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 15ff571756b1..53d8957a9469 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -53,6 +53,9 @@ private:
std::deque< OpenGLSalBitmapOp* > maPendingOps;
void makeCurrent();
+ virtual void updateChecksum() const;
+
+ bool calcChecksumGL(OpenGLTexture& rInputTexture, ChecksumType& rChecksum) const;
public:
OpenGLSalBitmap();
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index f89f4171072e..bbd0ee13cac3 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -23,6 +23,7 @@
#include <tools/gen.hxx>
#include <tools/solar.h>
#include <vcl/dllapi.h>
+#include <vcl/checksum.hxx>
#include <vcl/salbtype.hxx>
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
@@ -37,8 +38,11 @@ enum class BmpScaleFlag;
class VCL_PLUGIN_PUBLIC SalBitmap
{
public:
- SalBitmap() {}
- virtual ~SalBitmap();
+
+ typedef BitmapChecksum ChecksumType;
+
+ SalBitmap() : mbChecksumValid(false) {}
+ virtual ~SalBitmap();
virtual bool Create( const Size& rSize,
sal_uInt16 nBitCount,
@@ -63,6 +67,50 @@ public:
virtual bool Erase( const Color& rFillColor ) = 0;
virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) = 0;
virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) = 0;
+
+
+ virtual bool GetChecksum(ChecksumType& rChecksum) const
+ {
+ updateChecksum();
+ if (!mbChecksumValid)
+ rChecksum = 0;
+ else
+ rChecksum = mnChecksum;
+ return mbChecksumValid;
+ }
+
+ virtual void InvalidateChecksum()
+ {
+ mbChecksumValid = false;
+ }
+
+protected:
+ ChecksumType mnChecksum;
+ bool mbChecksumValid;
+
+protected:
+ virtual void updateChecksum() const
+ {
+ if (mbChecksumValid)
+ return;
+
+ ChecksumType nCrc = 0;
+ SalBitmap* pThis = const_cast<SalBitmap*>(this);
+ BitmapBuffer* pBuf = pThis->AcquireBuffer(BITMAP_READ_ACCESS);
+ if (pBuf)
+ {
+ nCrc = vcl_get_checksum(0, pBuf->mpBits, pBuf->mnScanlineSize * pBuf->mnHeight);
+ pThis->ReleaseBuffer(pBuf, BITMAP_READ_ACCESS);
+ pThis->mnChecksum = nCrc;
+ pThis->mbChecksumValid = true;
+ }
+ else
+ {
+ pThis->mbChecksumValid = false;
+ }
+ }
+
+
};
#endif
diff --git a/vcl/opengl/areaHashCRC64TFragmentShader.glsl b/vcl/opengl/areaHashCRC64TFragmentShader.glsl
new file mode 100644
index 000000000000..901b481d8081
--- /dev/null
+++ b/vcl/opengl/areaHashCRC64TFragmentShader.glsl
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+/* TODO Use textureOffset for newest version of GLSL */
+
+
+#version 130
+
+uniform sampler2D crc_table;
+uniform sampler2D sampler;
+uniform float xstep;
+uniform float ystep;
+
+varying vec2 tex_coord;
+
+const int scale = 4;
+const float ratio = 16.0;
+
+
+ivec2 crc64( ivec2 hval, int color )
+{
+ int dx = 2 * ((hval[0] ^ color) & 0xff);
+ float s = dx / 255.0;
+ vec4 table_value_lo = round(texture2D( crc_table, vec2( s, 0.0 ) ) * 255.0);
+ s = (dx+1) / 255.0;
+ vec4 table_value_hi = round(texture2D( crc_table, vec2( s, 0.0 ) ) * 255.0);
+
+ int tvalue_lo = int(table_value_lo[0]) | (int(table_value_lo[1]) << 8) | (int(table_value_lo[2]) << 16) | (int(table_value_lo[3]) << 24);
+ int tvalue_hi = int(table_value_hi[0]) | (int(table_value_hi[1]) << 8) | (int(table_value_hi[2]) << 16) | (int(table_value_hi[3]) << 24);
+
+ hval[1] = tvalue_hi ^ (hval[1] >> 8);
+ hval[0] = tvalue_lo ^ ( (hval[1] << 24) | (hval[0] >> 8) );
+
+ return hval;
+}
+
+
+void main(void)
+{
+ ivec2 Crc = ivec2( 0xffffffff, 0xffffffff );
+ vec2 offset = vec2( 0.0, 0.0 );
+ vec2 next_coord = tex_coord.st;
+ for( int y = 0; y < scale && next_coord.y <= 1.0; ++y )
+ {
+ for( int x = 0; x < scale && next_coord.x <= 1.0; ++x )
+ {
+ vec4 pixel = round(texture2D( sampler, next_coord ) * 255.0);
+
+ int r = int(pixel.r); // 0..255
+ int g = int(pixel.g); // 0..255
+ int b = int(pixel.b); // 0..255
+ int a = int(pixel.a); // 0..255
+
+ Crc = crc64( Crc, r );
+ Crc = crc64( Crc, g );
+ Crc = crc64( Crc, b );
+ Crc = crc64( Crc, a );
+
+ offset.x += xstep;
+ next_coord = tex_coord.st + offset;
+ }
+ offset.y += ystep;
+ offset.x = 0.0;
+ next_coord = tex_coord.st + offset;
+ }
+
+ Crc[0] = ~Crc[0];
+ Crc[1] = ~Crc[1];
+
+ int Hash = Crc[0] ^ Crc[1];
+
+ float fr = ( Hash & 0xff) / 255.0;
+ float fg = ((Hash >> 8) & 0xff) / 255.0;
+ float fb = ((Hash >> 16) & 0xff) / 255.0;
+ float fa = ((Hash >> 24) & 0xff) / 255.0;
+
+
+ gl_FragColor = vec4(fr, fg, fb, fa);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/opengl/program.cxx b/vcl/opengl/program.cxx
index b1d3cfe8291d..eec4e92bad98 100644
--- a/vcl/opengl/program.cxx
+++ b/vcl/opengl/program.cxx
@@ -276,7 +276,7 @@ void OpenGLProgram::SetBlendMode( GLenum nSFactor, GLenum nDFactor )
mbBlending = true;
}
-bool OpenGLProgram::DrawTexture( OpenGLTexture& rTexture )
+bool OpenGLProgram::DrawTexture( const OpenGLTexture& rTexture )
{
if (!rTexture)
return false;
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 527a19888c0c..3f049b459e65 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -22,6 +22,7 @@
#include <vcl/opengl/OpenGLHelper.hxx>
#include "vcl/bitmap.hxx"
+#include "vcl/checksum.hxx"
#include "vcl/outdev.hxx"
#include "vcl/salbtype.hxx"
#include "svdata.hxx"
@@ -508,6 +509,105 @@ sal_uInt16 OpenGLSalBitmap::GetBitCount() const
return mnBits;
}
+bool OpenGLSalBitmap::calcChecksumGL(OpenGLTexture& rInputTexture, ChecksumType& rChecksum) const
+{
+ OUString FragShader("areaHashCRC64TFragmentShader");
+
+ static const OpenGLTexture aCRCTableTexture(512, 1, GL_RGBA, GL_UNSIGNED_BYTE,
+ (sal_uInt8*)(vcl_get_crc64_table()));
+
+ // First Pass
+
+ int nWidth = rInputTexture.GetWidth();
+ int nHeight = rInputTexture.GetHeight();
+
+ OpenGLProgram* pProgram = mpContext->UseProgram("textureVertexShader", FragShader);
+ if (pProgram == 0)
+ return false;
+
+ int nNewWidth = ceil( nWidth / 4.0 );
+ int nNewHeight = ceil( nHeight / 4.0 );
+
+ OpenGLTexture aFirstPassTexture = OpenGLTexture(nNewWidth, nNewHeight);
+ OpenGLFramebuffer* pFramebuffer = mpContext->AcquireFramebuffer(aFirstPassTexture);
+
+ pProgram->SetUniform1f( "xstep", 1.0 / mnWidth );
+ pProgram->SetUniform1f( "ystep", 1.0 / mnHeight );
+
+ pProgram->SetTexture("crc_table", (OpenGLTexture&)(aCRCTableTexture));
+ pProgram->SetTexture("sampler", rInputTexture);
+ pProgram->DrawTexture(rInputTexture);
+ pProgram->Clean();
+
+ OpenGLContext::ReleaseFramebuffer(pFramebuffer);
+
+ CHECK_GL_ERROR();
+
+
+ // Second Pass
+
+ nWidth = aFirstPassTexture.GetWidth();
+ nHeight = aFirstPassTexture.GetHeight();
+
+ pProgram = mpContext->UseProgram("textureVertexShader", FragShader);
+ if (pProgram == 0)
+ return false;
+
+ nNewWidth = ceil( nWidth / 4.0 );
+ nNewHeight = ceil( nHeight / 4.0 );
+
+ OpenGLTexture aSecondPassTexture = OpenGLTexture(nNewWidth, nNewHeight);
+ pFramebuffer = mpContext->AcquireFramebuffer(aSecondPassTexture);
+
+ pProgram->SetUniform1f( "xstep", 1.0 / mnWidth );
+ pProgram->SetUniform1f( "ystep", 1.0 / mnHeight );
+
+ pProgram->SetTexture("crc_table", (OpenGLTexture&)(aCRCTableTexture));
+ pProgram->SetTexture("sampler", aFirstPassTexture);
+ pProgram->DrawTexture(aFirstPassTexture);
+ pProgram->Clean();
+
+ OpenGLContext::ReleaseFramebuffer(pFramebuffer);
+
+ CHECK_GL_ERROR();
+
+ // Final CRC on CPU
+ OpenGLTexture& aFinalTexture = aSecondPassTexture;
+ std::vector<sal_uInt8> aBuf( aFinalTexture.GetWidth() * aFinalTexture.GetHeight() * 4 );
+ aFinalTexture.Read(GL_RGBA, GL_UNSIGNED_BYTE, aBuf.data());
+
+ ChecksumType nCrc = vcl_get_checksum(0, aBuf.data(), aBuf.size());
+
+ rChecksum = nCrc;
+ return true;
+}
+
+void OpenGLSalBitmap::updateChecksum() const
+{
+ if (mbChecksumValid)
+ return;
+
+ OpenGLSalBitmap* pThis = const_cast<OpenGLSalBitmap*>(this);
+
+ if (!mpContext)
+ {
+ pThis->CreateTexture();
+ }
+
+ OpenGLTexture& rInputTexture = pThis->maTexture;
+ int nWidth = rInputTexture.GetWidth();
+ int nHeight = rInputTexture.GetHeight();
+
+ if( (nWidth * nHeight) < (1024*768) || nWidth < 128 || nHeight < 128 )
+ {
+ SalBitmap::updateChecksum();
+ }
+ else
+ {
+ pThis->mbChecksumValid = calcChecksumGL(rInputTexture, pThis->mnChecksum);
+ }
+}
+
OpenGLContext* OpenGLSalBitmap::GetBitmapContext()
{
return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
@@ -581,6 +681,7 @@ void OpenGLSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMo
{
maTexture = OpenGLTexture();
mbDirtyTexture = true;
+ mbChecksumValid = false;
}
// The palette is modified on read during the BitmapWriteAccess,
// but of course, often it is not modified; interesting.
diff --git a/vcl/source/bitmap/checksum.cxx b/vcl/source/bitmap/checksum.cxx
new file mode 100644
index 000000000000..3c9a8a6f1656
--- /dev/null
+++ b/vcl/source/bitmap/checksum.cxx
@@ -0,0 +1,154 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/types.h>
+#include <vcl/checksum.hxx>
+
+
+/*========================================================================
+ *
+ * vcl_crc64Table (CRC polynomial 0x95AC9329AC4BC9B5ULL).
+ *
+ *======================================================================*/
+static const sal_uInt64 vcl_crc64Table[256] = {
+ 0x0000000000000000ULL, 0x7ad870c830358979ULL, 0xf5b0e190606b12f2ULL,
+ 0x8f689158505e9b8bULL, 0xc038e5739841b68fULL, 0xbae095bba8743ff6ULL,
+ 0x358804e3f82aa47dULL, 0x4f50742bc81f2d04ULL, 0xab28ecb46814fe75ULL,
+ 0xd1f09c7c5821770cULL, 0x5e980d24087fec87ULL, 0x24407dec384a65feULL,
+ 0x6b1009c7f05548faULL, 0x11c8790fc060c183ULL, 0x9ea0e857903e5a08ULL,
+ 0xe478989fa00bd371ULL, 0x7d08ff3b88be6f81ULL, 0x07d08ff3b88be6f8ULL,
+ 0x88b81eabe8d57d73ULL, 0xf2606e63d8e0f40aULL, 0xbd301a4810ffd90eULL,
+ 0xc7e86a8020ca5077ULL, 0x4880fbd87094cbfcULL, 0x32588b1040a14285ULL,
+ 0xd620138fe0aa91f4ULL, 0xacf86347d09f188dULL, 0x2390f21f80c18306ULL,
+ 0x594882d7b0f40a7fULL, 0x1618f6fc78eb277bULL, 0x6cc0863448deae02ULL,
+ 0xe3a8176c18803589ULL, 0x997067a428b5bcf0ULL, 0xfa11fe77117cdf02ULL,
+ 0x80c98ebf2149567bULL, 0x0fa11fe77117cdf0ULL, 0x75796f2f41224489ULL,
+ 0x3a291b04893d698dULL, 0x40f16bccb908e0f4ULL, 0xcf99fa94e9567b7fULL,
+ 0xb5418a5cd963f206ULL, 0x513912c379682177ULL, 0x2be1620b495da80eULL,
+ 0xa489f35319033385ULL, 0xde51839b2936bafcULL, 0x9101f7b0e12997f8ULL,
+ 0xebd98778d11c1e81ULL, 0x64b116208142850aULL, 0x1e6966e8b1770c73ULL,
+ 0x8719014c99c2b083ULL, 0xfdc17184a9f739faULL, 0x72a9e0dcf9a9a271ULL,
+ 0x08719014c99c2b08ULL, 0x4721e43f0183060cULL, 0x3df994f731b68f75ULL,
+ 0xb29105af61e814feULL, 0xc849756751dd9d87ULL, 0x2c31edf8f1d64ef6ULL,
+ 0x56e99d30c1e3c78fULL, 0xd9810c6891bd5c04ULL, 0xa3597ca0a188d57dULL,
+ 0xec09088b6997f879ULL, 0x96d1784359a27100ULL, 0x19b9e91b09fcea8bULL,
+ 0x636199d339c963f2ULL, 0xdf7adabd7a6e2d6fULL, 0xa5a2aa754a5ba416ULL,
+ 0x2aca3b2d1a053f9dULL, 0x50124be52a30b6e4ULL, 0x1f423fcee22f9be0ULL,
+ 0x659a4f06d21a1299ULL, 0xeaf2de5e82448912ULL, 0x902aae96b271006bULL,
+ 0x74523609127ad31aULL, 0x0e8a46c1224f5a63ULL, 0x81e2d7997211c1e8ULL,
+ 0xfb3aa75142244891ULL, 0xb46ad37a8a3b6595ULL, 0xceb2a3b2ba0eececULL,
+ 0x41da32eaea507767ULL, 0x3b024222da65fe1eULL, 0xa2722586f2d042eeULL,
+ 0xd8aa554ec2e5cb97ULL, 0x57c2c41692bb501cULL, 0x2d1ab4dea28ed965ULL,
+ 0x624ac0f56a91f461ULL, 0x1892b03d5aa47d18ULL, 0x97fa21650afae693ULL,
+ 0xed2251ad3acf6feaULL, 0x095ac9329ac4bc9bULL, 0x7382b9faaaf135e2ULL,
+ 0xfcea28a2faafae69ULL, 0x8632586aca9a2710ULL, 0xc9622c4102850a14ULL,
+ 0xb3ba5c8932b0836dULL, 0x3cd2cdd162ee18e6ULL, 0x460abd1952db919fULL,
+ 0x256b24ca6b12f26dULL, 0x5fb354025b277b14ULL, 0xd0dbc55a0b79e09fULL,
+ 0xaa03b5923b4c69e6ULL, 0xe553c1b9f35344e2ULL, 0x9f8bb171c366cd9bULL,
+ 0x10e3202993385610ULL, 0x6a3b50e1a30ddf69ULL, 0x8e43c87e03060c18ULL,
+ 0xf49bb8b633338561ULL, 0x7bf329ee636d1eeaULL, 0x012b592653589793ULL,
+ 0x4e7b2d0d9b47ba97ULL, 0x34a35dc5ab7233eeULL, 0xbbcbcc9dfb2ca865ULL,
+ 0xc113bc55cb19211cULL, 0x5863dbf1e3ac9decULL, 0x22bbab39d3991495ULL,
+ 0xadd33a6183c78f1eULL, 0xd70b4aa9b3f20667ULL, 0x985b3e827bed2b63ULL,
+ 0xe2834e4a4bd8a21aULL, 0x6debdf121b863991ULL, 0x1733afda2bb3b0e8ULL,
+ 0xf34b37458bb86399ULL, 0x8993478dbb8deae0ULL, 0x06fbd6d5ebd3716bULL,
+ 0x7c23a61ddbe6f812ULL, 0x3373d23613f9d516ULL, 0x49aba2fe23cc5c6fULL,
+ 0xc6c333a67392c7e4ULL, 0xbc1b436e43a74e9dULL, 0x95ac9329ac4bc9b5ULL,
+ 0xef74e3e19c7e40ccULL, 0x601c72b9cc20db47ULL, 0x1ac40271fc15523eULL,
+ 0x5594765a340a7f3aULL, 0x2f4c0692043ff643ULL, 0xa02497ca54616dc8ULL,
+ 0xdafce7026454e4b1ULL, 0x3e847f9dc45f37c0ULL, 0x445c0f55f46abeb9ULL,
+ 0xcb349e0da4342532ULL, 0xb1eceec59401ac4bULL, 0xfebc9aee5c1e814fULL,
+ 0x8464ea266c2b0836ULL, 0x0b0c7b7e3c7593bdULL, 0x71d40bb60c401ac4ULL,
+ 0xe8a46c1224f5a634ULL, 0x927c1cda14c02f4dULL, 0x1d148d82449eb4c6ULL,
+ 0x67ccfd4a74ab3dbfULL, 0x289c8961bcb410bbULL, 0x5244f9a98c8199c2ULL,
+ 0xdd2c68f1dcdf0249ULL, 0xa7f41839ecea8b30ULL, 0x438c80a64ce15841ULL,
+ 0x3954f06e7cd4d138ULL, 0xb63c61362c8a4ab3ULL, 0xcce411fe1cbfc3caULL,
+ 0x83b465d5d4a0eeceULL, 0xf96c151de49567b7ULL, 0x76048445b4cbfc3cULL,
+ 0x0cdcf48d84fe7545ULL, 0x6fbd6d5ebd3716b7ULL, 0x15651d968d029fceULL,
+ 0x9a0d8ccedd5c0445ULL, 0xe0d5fc06ed698d3cULL, 0xaf85882d2576a038ULL,
+ 0xd55df8e515432941ULL, 0x5a3569bd451db2caULL, 0x20ed197575283bb3ULL,
+ 0xc49581ead523e8c2ULL, 0xbe4df122e51661bbULL, 0x3125607ab548fa30ULL,
+ 0x4bfd10b2857d7349ULL, 0x04ad64994d625e4dULL, 0x7e7514517d57d734ULL,
+ 0xf11d85092d094cbfULL, 0x8bc5f5c11d3cc5c6ULL, 0x12b5926535897936ULL,
+ 0x686de2ad05bcf04fULL, 0xe70573f555e26bc4ULL, 0x9ddd033d65d7e2bdULL,
+ 0xd28d7716adc8cfb9ULL, 0xa85507de9dfd46c0ULL, 0x273d9686cda3dd4bULL,
+ 0x5de5e64efd965432ULL, 0xb99d7ed15d9d8743ULL, 0xc3450e196da80e3aULL,
+ 0x4c2d9f413df695b1ULL, 0x36f5ef890dc31cc8ULL, 0x79a59ba2c5dc31ccULL,
+ 0x037deb6af5e9b8b5ULL, 0x8c157a32a5b7233eULL, 0xf6cd0afa9582aa47ULL,
+ 0x4ad64994d625e4daULL, 0x300e395ce6106da3ULL, 0xbf66a804b64ef628ULL,
+ 0xc5bed8cc867b7f51ULL, 0x8aeeace74e645255ULL, 0xf036dc2f7e51db2cULL,
+ 0x7f5e4d772e0f40a7ULL, 0x05863dbf1e3ac9deULL, 0xe1fea520be311aafULL,
+ 0x9b26d5e88e0493d6ULL, 0x144e44b0de5a085dULL, 0x6e963478ee6f8124ULL,
+ 0x21c640532670ac20ULL, 0x5b1e309b16452559ULL, 0xd476a1c3461bbed2ULL,
+ 0xaeaed10b762e37abULL, 0x37deb6af5e9b8b5bULL, 0x4d06c6676eae0222ULL,
+ 0xc26e573f3ef099a9ULL, 0xb8b627f70ec510d0ULL, 0xf7e653dcc6da3dd4ULL,
+ 0x8d3e2314f6efb4adULL, 0x0256b24ca6b12f26ULL, 0x788ec2849684a65fULL,
+ 0x9cf65a1b368f752eULL, 0xe62e2ad306bafc57ULL, 0x6946bb8b56e467dcULL,
+ 0x139ecb4366d1eea5ULL, 0x5ccebf68aecec3a1ULL, 0x2616cfa09efb4ad8ULL,
+ 0xa97e5ef8cea5d153ULL, 0xd3a62e30fe90582aULL, 0xb0c7b7e3c7593bd8ULL,
+ 0xca1fc72bf76cb2a1ULL, 0x45775673a732292aULL, 0x3faf26bb9707a053ULL,
+ 0x70ff52905f188d57ULL, 0x0a2722586f2d042eULL, 0x854fb3003f739fa5ULL,
+ 0xff97c3c80f4616dcULL, 0x1bef5b57af4dc5adULL, 0x61372b9f9f784cd4ULL,
+ 0xee5fbac7cf26d75fULL, 0x9487ca0fff135e26ULL, 0xdbd7be24370c7322ULL,
+ 0xa10fceec0739fa5bULL, 0x2e675fb4576761d0ULL, 0x54bf2f7c6752e8a9ULL,
+ 0xcdcf48d84fe75459ULL, 0xb71738107fd2dd20ULL, 0x387fa9482f8c46abULL,
+ 0x42a7d9801fb9cfd2ULL, 0x0df7adabd7a6e2d6ULL, 0x772fdd63e7936bafULL,
+ 0xf8474c3bb7cdf024ULL, 0x829f3cf387f8795dULL, 0x66e7a46c27f3aa2cULL,
+ 0x1c3fd4a417c62355ULL, 0x935745fc4798b8deULL, 0xe98f353477ad31a7ULL,
+ 0xa6df411fbfb21ca3ULL, 0xdc0731d78f8795daULL, 0x536fa08fdfd90e51ULL,
+ 0x29b7d047efec8728ULL
+};
+
+/*========================================================================
+ *
+ * vcl_crc64 implementation.
+ *
+ *======================================================================*/
+#define UPDCRC64(crc, octet) \
+ (vcl_crc64Table[((crc) ^ (octet)) & 0xff] ^ ((crc) >> 8))
+
+/*
+ * vcl_crc64.
+ */
+sal_uInt64 SAL_CALL vcl_crc64 (
+ sal_uInt64 Crc,
+ const void *Data, sal_uInt32 DatLen) SAL_THROW_EXTERN_C()
+{
+ if (Data)
+ {
+ const sal_uInt8 *p = static_cast<const sal_uInt8 *>(Data);
+ const sal_uInt8 *q = p + DatLen;
+
+ Crc = ~Crc;
+ while (p < q)
+ Crc = UPDCRC64(Crc, *(p++));
+ Crc = ~Crc;
+ }
+ return Crc;
+}
+
+/*
+ * vcl_get_crc64_table.
+ */
+const sal_uInt64* vcl_get_crc64_table()
+{
+ return vcl_crc64Table;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx
index 4dd37f8381e2..8e76d7e29cf3 100644
--- a/vcl/source/gdi/animate.cxx
+++ b/vcl/source/gdi/animate.cxx
@@ -31,31 +31,31 @@
sal_uLong Animation::mnAnimCount = 0UL;
-sal_uLong AnimationBitmap::GetChecksum() const
+BitmapChecksum AnimationBitmap::GetChecksum() const
{
- sal_uInt32 nCrc = aBmpEx.GetChecksum();
+ BitmapChecksum nCrc = aBmpEx.GetChecksum();
SVBT32 aBT32;
UInt32ToSVBT32( aPosPix.X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( aPosPix.Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( aSizePix.Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( aSizePix.Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( (long) nWait, aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( (long) eDisposal, aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( (long) bUserInput, aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
return nCrc;
}
@@ -206,27 +206,28 @@ sal_uLong Animation::GetSizeBytes() const
return nSizeBytes;
}
-sal_uLong Animation::GetChecksum() const
+BitmapChecksum Animation::GetChecksum() const
{
SVBT32 aBT32;
- sal_uInt32 nCrc = GetBitmapEx().GetChecksum();
+ BitmapChecksumOctetArray aBCOA;
+ BitmapChecksum nCrc = GetBitmapEx().GetChecksum();
UInt32ToSVBT32( maList.size(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( maGlobalSize.Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( maGlobalSize.Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( (long) meCycleMode, aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
for( size_t i = 0, nCount = maList.size(); i < nCount; i++ )
{
- UInt32ToSVBT32( maList[ i ]->GetChecksum(), aBT32 );
- nCrc = rtl_crc32( 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/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index 51e5db80924f..45ecf09c124a 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -245,10 +245,8 @@ Bitmap& Bitmap::operator=( const Bitmap& rBitmap )
bool Bitmap::IsEqual( const Bitmap& rBmp ) const
{
- return( IsSameInstance( rBmp ) ||
- ( rBmp.GetSizePixel() == GetSizePixel() &&
- rBmp.GetBitCount() == GetBitCount() &&
- rBmp.GetChecksum() == GetChecksum() ) );
+ return(IsSameInstance(rBmp) || // Includes both are nullptr
+ (rBmp.mpImpBmp && mpImpBmp && mpImpBmp->ImplIsEqual(*rBmp.mpImpBmp)));
}
void Bitmap::SetEmpty()
@@ -286,56 +284,13 @@ bool Bitmap::HasGreyPalette() const
return bRet;
}
-sal_uLong Bitmap::GetChecksum() const
+BitmapChecksum Bitmap::GetChecksum() const
{
- sal_uLong nRet = 0UL;
+ BitmapChecksum nRet = 0;
if( mpImpBmp )
{
nRet = mpImpBmp->ImplGetChecksum();
-
- if( !nRet )
- {
- BitmapReadAccess* pRAcc = const_cast<Bitmap*>(this)->AcquireReadAccess();
-
- if( pRAcc && pRAcc->Width() && pRAcc->Height() )
- {
- sal_uInt32 nCrc = 0;
- SVBT32 aBT32;
-
- pRAcc->ImplZeroInitUnusedBits();
-
- UInt32ToSVBT32( pRAcc->Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
-
- UInt32ToSVBT32( pRAcc->Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
-
- UInt32ToSVBT32( pRAcc->GetBitCount(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
-
- UInt32ToSVBT32( pRAcc->GetColorMask().GetRedMask(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
-
- UInt32ToSVBT32( pRAcc->GetColorMask().GetGreenMask(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
-
- UInt32ToSVBT32( pRAcc->GetColorMask().GetBlueMask(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
-
- if( pRAcc->HasPalette() )
- {
- nCrc = rtl_crc32( nCrc, pRAcc->GetPalette().ImplGetColorBuffer(),
- pRAcc->GetPaletteEntryCount() * sizeof( BitmapColor ) );
- }
-
- nCrc = rtl_crc32( nCrc, pRAcc->GetBuffer(), pRAcc->GetScanlineSize() * pRAcc->Height() );
-
- mpImpBmp->ImplSetChecksum( nRet = nCrc );
- }
-
- if (pRAcc) ReleaseAccess( pRAcc );
- }
}
return nRet;
@@ -549,6 +504,7 @@ bool Bitmap::Invert()
pAcc->SetPixel( nY, nX, pAcc->GetPixel( nY, nX ).Invert() );
}
+ mpImpBmp->ImplInvalidateChecksum();
ReleaseAccess( pAcc );
bRet = true;
}
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index e6fa951a0927..768cd749e995 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -316,21 +316,22 @@ sal_uLong BitmapEx::GetSizeBytes() const
return nSizeBytes;
}
-sal_uLong BitmapEx::GetChecksum() const
+BitmapChecksum BitmapEx::GetChecksum() const
{
- sal_uInt32 nCrc = aBitmap.GetChecksum();
+ BitmapChecksum nCrc = aBitmap.GetChecksum();
SVBT32 aBT32;
+ BitmapChecksumOctetArray aBCOA;
UInt32ToSVBT32( (long) eTransparent, aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( (long) bAlpha, aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
if( ( TRANSPARENT_BITMAP == eTransparent ) && !aMask.IsEmpty() )
{
- UInt32ToSVBT32( aMask.GetChecksum(), aBT32 );
- nCrc = rtl_crc32( 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 94be557415aa..8d283dff051a 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -2340,14 +2340,15 @@ GDIMetaFile GDIMetaFile::GetMonochromeMtf( const Color& rColor ) const
return aRet;
}
-sal_uLong GDIMetaFile::GetChecksum() const
+BitmapChecksum GDIMetaFile::GetChecksum() const
{
- GDIMetaFile aMtf;
- SvMemoryStream aMemStm( 65535, 65535 );
- ImplMetaWriteData aWriteData;
- SVBT16 aBT16;
- SVBT32 aBT32;
- sal_uLong 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++ )
@@ -2361,16 +2362,16 @@ sal_uLong GDIMetaFile::GetChecksum() const
MetaBmpAction* pAct = static_cast<MetaBmpAction*>(pAction);
ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
- nCrc = rtl_crc32( nCrc, aBT16, 2 );
+ nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
- UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
+ nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2379,22 +2380,22 @@ sal_uLong GDIMetaFile::GetChecksum() const
MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction);
ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
- nCrc = rtl_crc32( nCrc, aBT16, 2 );
+ nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
- UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
+ nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2403,34 +2404,34 @@ sal_uLong GDIMetaFile::GetChecksum() const
MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction);
ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
- nCrc = rtl_crc32( nCrc, aBT16, 2 );
+ nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
- UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
+ nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2439,16 +2440,16 @@ sal_uLong GDIMetaFile::GetChecksum() const
MetaBmpExAction* pAct = static_cast<MetaBmpExAction*>(pAction);
ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
- nCrc = rtl_crc32( nCrc, aBT16, 2 );
+ nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
- UInt32ToSVBT32( pAct->GetBitmapEx().GetChecksum(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA );
+ nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2457,22 +2458,22 @@ sal_uLong GDIMetaFile::GetChecksum() const
MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pAction);
ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
- nCrc = rtl_crc32( nCrc, aBT16, 2 );
+ nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
- UInt32ToSVBT32( pAct->GetBitmapEx().GetChecksum(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA );
+ nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2481,34 +2482,34 @@ sal_uLong GDIMetaFile::GetChecksum() const
MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pAction);
ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
- nCrc = rtl_crc32( nCrc, aBT16, 2 );
+ nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
- UInt32ToSVBT32( pAct->GetBitmapEx().GetChecksum(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA );
+ nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2517,19 +2518,19 @@ sal_uLong GDIMetaFile::GetChecksum() const
MetaMaskAction* pAct = static_cast<MetaMaskAction*>(pAction);
ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
- nCrc = rtl_crc32( nCrc, aBT16, 2 );
+ nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
- UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
+ nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetColor().GetColor(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2538,25 +2539,25 @@ sal_uLong GDIMetaFile::GetChecksum() const
MetaMaskScaleAction* pAct = static_cast<MetaMaskScaleAction*>(pAction);
ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
- nCrc = rtl_crc32( nCrc, aBT16, 2 );
+ nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
- UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
+ nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetColor().GetColor(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2565,44 +2566,44 @@ sal_uLong GDIMetaFile::GetChecksum() const
MetaMaskScalePartAction* pAct = static_cast<MetaMaskScalePartAction*>(pAction);
ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
- nCrc = rtl_crc32( nCrc, aBT16, 2 );
+ nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
- UInt32ToSVBT32( pAct->GetBitmap().GetChecksum(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
+ nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetColor().GetColor(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
- nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
case MetaActionType::EPS :
{
MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pAction);
- nCrc = rtl_crc32( nCrc, pAct->GetLink().GetData(), pAct->GetLink().GetDataSize() );
+ nCrc = vcl_get_checksum( nCrc, pAct->GetLink().GetData(), pAct->GetLink().GetDataSize() );
}
break;
@@ -2631,9 +2632,9 @@ sal_uLong GDIMetaFile::GetChecksum() const
const basegfx::B2DPoint aPoint(aPolygon.getB2DPoint(b));
DoubleToSVBT64(aPoint.getX(), aSVBT64);
- nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+ nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
DoubleToSVBT64(aPoint.getY(), aSVBT64);
- nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+ nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
if(bControl)
{
@@ -2642,9 +2643,9 @@ sal_uLong GDIMetaFile::GetChecksum() const
const basegfx::B2DPoint aCtrl(aPolygon.getPrevControlPoint(b));
DoubleToSVBT64(aCtrl.getX(), aSVBT64);
- nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+ nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
DoubleToSVBT64(aCtrl.getY(), aSVBT64);
- nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+ nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
}
if(aPolygon.isNextControlPointUsed(b))
@@ -2652,21 +2653,21 @@ sal_uLong GDIMetaFile::GetChecksum() const
const basegfx::B2DPoint aCtrl(aPolygon.getNextControlPoint(b));
DoubleToSVBT64(aCtrl.getX(), aSVBT64);
- nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+ nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
DoubleToSVBT64(aCtrl.getY(), aSVBT64);
- nCrc = rtl_crc32(nCrc, aSVBT64, 8);
+ nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
}
}
}
}
sal_uInt8 tmp = (sal_uInt8)rAct.IsClipping();
- nCrc = rtl_crc32(nCrc, &tmp, 1);
+ nCrc = vcl_get_checksum(nCrc, &tmp, 1);
}
else
{
pAction->Write( aMemStm, &aWriteData );
- nCrc = rtl_crc32( nCrc, aMemStm.GetData(), aMemStm.Tell() );
+ nCrc = vcl_get_checksum( nCrc, aMemStm.GetData(), aMemStm.Tell() );
aMemStm.Seek( 0 );
}
}
@@ -2675,7 +2676,7 @@ sal_uLong GDIMetaFile::GetChecksum() const
default:
{
pAction->Write( aMemStm, &aWriteData );
- nCrc = rtl_crc32( nCrc, aMemStm.GetData(), aMemStm.Tell() );
+ nCrc = vcl_get_checksum( nCrc, aMemStm.GetData(), aMemStm.Tell() );
aMemStm.Seek( 0 );
}
break;
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index 40bd87c8ffca..dc4de009768f 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -552,7 +552,7 @@ bool Graphic::IsLink() const
return mpImpGraphic->ImplIsLink();
}
-sal_uLong Graphic::GetChecksum() const
+BitmapChecksum Graphic::GetChecksum() const
{
return mpImpGraphic->ImplGetChecksum();
}
diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx
index 298bfaa1cd0f..b79b0d446aca 100644
--- a/vcl/source/gdi/impbmp.cxx
+++ b/vcl/source/gdi/impbmp.cxx
@@ -26,14 +26,12 @@
ImpBitmap::ImpBitmap() :
mnRefCount ( 1 ),
- mnChecksum ( 0 ),
mpSalBitmap ( ImplGetSVData()->mpDefInst->CreateSalBitmap() )
{
}
ImpBitmap::ImpBitmap(SalBitmap* pBitmap) :
mnRefCount ( 1 ),
- mnChecksum ( 0 ),
mpSalBitmap ( pBitmap )
{
}
@@ -43,14 +41,20 @@ ImpBitmap::~ImpBitmap()
delete mpSalBitmap;
}
-bool ImpBitmap::ImplCreate( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal )
+bool ImpBitmap::ImplIsEqual(const ImpBitmap& rBmp) const
+{
+ return (rBmp.ImplGetSize() == ImplGetSize() &&
+ rBmp.ImplGetBitCount() == ImplGetBitCount() &&
+ rBmp.ImplGetChecksum() == ImplGetChecksum());
+}
+
+bool ImpBitmap::ImplCreate(const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal)
{
return mpSalBitmap->Create( rSize, nBitCount, rPal );
}
bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap )
{
- mnChecksum = rImpBitmap.mnChecksum;
return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap );
}
@@ -85,7 +89,19 @@ void ImpBitmap::ImplReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode
mpSalBitmap->ReleaseBuffer( pBuffer, nMode );
if( nMode == BITMAP_WRITE_ACCESS )
- mnChecksum = 0;
+ ImplInvalidateChecksum();
+}
+
+BitmapChecksum ImpBitmap::ImplGetChecksum() const
+{
+ SalBitmap::ChecksumType aChecksum;
+ mpSalBitmap->GetChecksum(aChecksum);
+ return aChecksum;
+}
+
+void ImpBitmap::ImplInvalidateChecksum()
+{
+ mpSalBitmap->InvalidateChecksum();
}
bool ImpBitmap::ImplScale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag )
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 1c62ab03e4cc..a49100208a06 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1360,9 +1360,9 @@ bool ImpGraphic::ImplIsLink() const
return ( mpGfxLink != NULL );
}
-sal_uLong ImpGraphic::ImplGetChecksum() const
+BitmapChecksum ImpGraphic::ImplGetChecksum() const
{
- sal_uLong nRet = 0;
+ BitmapChecksum nRet = 0;
if( ImplIsSupportedGraphic() && !ImplIsSwapOut() )
{
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index f6ff40f752af..0b7fa46b446c 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -11516,7 +11516,7 @@ void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const
aID.m_aPixelSize = rSizePixel;
aID.m_nSize = pStream->Tell();
pStream->Seek( STREAM_SEEK_TO_BEGIN );
- aID.m_nChecksum = rtl_crc32( 0, pStream->GetData(), aID.m_nSize );
+ aID.m_nChecksum = vcl_get_checksum( 0, pStream->GetData(), aID.m_nSize );
if( ! rMask.IsEmpty() )
aID.m_nMaskChecksum = rMask.GetChecksum();
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index ccd8ada7ce18..cf389051dc76 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -177,8 +177,8 @@ public:
{
Size m_aPixelSize;
sal_Int32 m_nSize;
- sal_Int32 m_nChecksum;
- sal_Int32 m_nMaskChecksum;
+ BitmapChecksum m_nChecksum;
+ BitmapChecksum m_nMaskChecksum;
BitmapID() : m_nSize( 0 ), m_nChecksum( 0 ), m_nMaskChecksum( 0 ) {}
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx
index dcd9ff335ee3..601fd2152d1d 100644
--- a/vcl/unx/gtk/app/gtkinst.cxx
+++ b/vcl/unx/gtk/app/gtkinst.cxx
@@ -341,7 +341,7 @@ SalBitmap* GtkInstance::CreateSalBitmap()
{
EnsureInit();
#if GTK_CHECK_VERSION(3,0,0)
- return new SvpSalBitmap();
+ return SvpSalInstance::CreateSalBitmap();//new SvpSalBitmap();
#else
return X11SalInstance::CreateSalBitmap();
#endif