From 6810d0f5b61a779588261e8ff848b9274a4cec98 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Mon, 3 Apr 2023 09:34:54 +0100 Subject: BinaryDataContainer: account for in-memory size of un-compressed image. Change-Id: Ia86d4dda706959bb58e941e65f2b2f7fffa8dc3d Signed-off-by: Michael Meeks --- include/vcl/BinaryDataContainer.hxx | 3 +++ include/vcl/gfxlink.hxx | 3 +++ vcl/source/gdi/impgraph.cxx | 5 +++++ vcl/source/graphic/BinaryDataContainer.cxx | 2 ++ 4 files changed, 13 insertions(+) diff --git a/include/vcl/BinaryDataContainer.hxx b/include/vcl/BinaryDataContainer.hxx index e9e46a04e667..e178ad6c4d62 100644 --- a/include/vcl/BinaryDataContainer.hxx +++ b/include/vcl/BinaryDataContainer.hxx @@ -53,6 +53,9 @@ public: /// writes the contents to the given stream std::size_t writeToStream(SvStream& rStream) const; + /// return the in-memory size in bytes as of now. + std::size_t getSizeBytes() const; + size_t calculateHash() const; }; diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx index 8c0f5fd32b05..531633b3f738 100644 --- a/include/vcl/gfxlink.hxx +++ b/include/vcl/gfxlink.hxx @@ -85,6 +85,9 @@ public: sal_uInt32 GetDataSize() const { return maDataContainer.getSize(); } const sal_uInt8* GetData() const; + /// return the in-memory size as of now. + size_t getSizeBytes() const { return maDataContainer.getSizeBytes(); } + const BinaryDataContainer& getDataContainer() const { return maDataContainer; diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 84df1765569c..76598c9945e1 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -999,6 +999,9 @@ sal_uLong ImpGraphic::getSizeBytes() const break; } + if (mpGfxLink) + mnSizeBytes += mpGfxLink->getSizeBytes(); + return mnSizeBytes; } @@ -1431,6 +1434,8 @@ void ImpGraphic::dumpState(rtl::OStringBuffer &rState) rState.append(static_cast(meType)); rState.append("\tsize:\t"); rState.append(static_cast(mnSizeBytes)); + rState.append("\tgfxl:\t"); + rState.append(static_cast(mpGfxLink ? mpGfxLink->getSizeBytes() : -1)); rState.append("\t"); rState.append(static_cast(maSwapInfo.maSizePixel.Width())); rState.append("x"); diff --git a/vcl/source/graphic/BinaryDataContainer.cxx b/vcl/source/graphic/BinaryDataContainer.cxx index b35195b7d27e..31561d9e16e3 100644 --- a/vcl/source/graphic/BinaryDataContainer.cxx +++ b/vcl/source/graphic/BinaryDataContainer.cxx @@ -74,6 +74,8 @@ std::size_t BinaryDataContainer::writeToStream(SvStream& rStream) const size_t BinaryDataContainer::getSize() const { return mpData ? mpData->size() : 0; } +size_t BinaryDataContainer::getSizeBytes() const { return getSize(); } + bool BinaryDataContainer::isEmpty() const { return !mpData || mpData->empty(); } const sal_uInt8* BinaryDataContainer::getData() const { return mpData ? mpData->data() : nullptr; } -- cgit