summaryrefslogtreecommitdiff
path: root/vcl/inc/salbmp.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/inc/salbmp.hxx')
-rw-r--r--vcl/inc/salbmp.hxx51
1 files changed, 49 insertions, 2 deletions
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index f89f4171072e..b91687da27bc 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -25,6 +25,8 @@
#include <vcl/dllapi.h>
#include <vcl/salbtype.hxx>
+#include <checksum.hxx>
+
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
struct BitmapBuffer;
@@ -37,8 +39,11 @@ enum class BmpScaleFlag;
class VCL_PLUGIN_PUBLIC SalBitmap
{
public:
- SalBitmap() {}
- virtual ~SalBitmap();
+
+ typedef sal_uInt64 ChecksumType;
+
+ SalBitmap() : mbChecksumValid(false) {}
+ virtual ~SalBitmap();
virtual bool Create( const Size& rSize,
sal_uInt16 nBitCount,
@@ -63,6 +68,48 @@ 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();
+ assert(mbChecksumValid);
+ rChecksum = maChecksum;
+ return mbChecksumValid;
+ }
+
+ virtual void InvalidateChecksum()
+ {
+ mbChecksumValid = false;
+ }
+
+protected:
+ ChecksumType maChecksum;
+ 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)
+ {
+ pThis->ReleaseBuffer(pBuf, BITMAP_READ_ACCESS);
+ nCrc = vcl_crc64(0, pBuf->mpBits, pBuf->mnScanlineSize * pBuf->mnHeight);
+ pThis->maChecksum = nCrc;
+ pThis->mbChecksumValid = true;
+ }
+ else
+ {
+ pThis->mbChecksumValid = false;
+ }
+ }
+
+
};
#endif