vcl/inc/graphic/AnimationContainer.hxx | 2 vcl/inc/graphic/BitmapContainer.hxx | 2 vcl/inc/impgraph.hxx | 7 +- vcl/source/gdi/impgraph.cxx | 90 +++++++++++++++++---------------- 4 files changed, 57 insertions(+), 44 deletions(-)
New commits: commit 4575f033e58148ede7283ad2f3c4cd353e57022a Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Apr 10 15:17:22 2025 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Apr 14 02:47:40 2025 +0200 vcl: ImpGraphic - rearange code to keep each each type together Also implement getChecksum at the {Bitmap,Animation}Container and use that in ImpGraphic::getChecksum. Change-Id: I3dd4a0a80bd8f009919956548c049fde6b9df3b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184113 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Jenkins diff --git a/vcl/inc/graphic/AnimationContainer.hxx b/vcl/inc/graphic/AnimationContainer.hxx index 25cfa26bd766..115651d5a698 100644 --- a/vcl/inc/graphic/AnimationContainer.hxx +++ b/vcl/inc/graphic/AnimationContainer.hxx @@ -52,6 +52,8 @@ public: } sal_uInt32 getLoopCount() { return maAnimation.GetLoopCount(); } + + BitmapChecksum getChecksum() const { return maAnimation.GetChecksum(); } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/graphic/BitmapContainer.hxx b/vcl/inc/graphic/BitmapContainer.hxx index 010ac45c74bc..81a2a4e8db5f 100644 --- a/vcl/inc/graphic/BitmapContainer.hxx +++ b/vcl/inc/graphic/BitmapContainer.hxx @@ -51,6 +51,8 @@ public: } sal_uInt64 getSizeBytes() { return maBitmapEx.GetSizeBytes(); } + + BitmapChecksum getChecksum() const { return maBitmapEx.GetChecksum(); } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index e1c23e17c4e7..bf28040c18d3 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -797,37 +797,40 @@ Size ImpGraphic::getPrefSize() const { case GraphicType::Bitmap: { - if (maVectorGraphicData && maCachedBitmap.IsEmpty()) + if (maVectorGraphicData) { - if (!maExPrefSize.getWidth() || !maExPrefSize.getHeight()) + if (maCachedBitmap.IsEmpty()) { - // svg not yet buffered in maBitmapEx, return size derived from range - const basegfx::B2DRange& rRange = maVectorGraphicData->getRange(); - -#ifdef MACOSX - // tdf#157680 scale down estimated size of embedded PDF - // For some unknown reason, the embedded PDF sizes - // are 20x larger than expected. This only occurs on - // macOS so possibly there is some special conversion - // from MapUnit::MapPoint to MapUnit::MapTwip elsewhere - // in the code. - if (maVectorGraphicData->getType() == VectorGraphicDataType::Pdf) - aSize = Size(basegfx::fround(rRange.getWidth() / 20.0f), basegfx::fround(rRange.getHeight() / 20.0f)); + if (!maExPrefSize.getWidth() || !maExPrefSize.getHeight()) + { + // svg not yet buffered in maBitmapEx, return size derived from range + const basegfx::B2DRange& rRange = maVectorGraphicData->getRange(); + + #ifdef MACOSX + // tdf#157680 scale down estimated size of embedded PDF + // For some unknown reason, the embedded PDF sizes + // are 20x larger than expected. This only occurs on + // macOS so possibly there is some special conversion + // from MapUnit::MapPoint to MapUnit::MapTwip elsewhere + // in the code. + if (maVectorGraphicData->getType() == VectorGraphicDataType::Pdf) + aSize = Size(basegfx::fround(rRange.getWidth() / 20.0f), basegfx::fround(rRange.getHeight() / 20.0f)); + else + #endif + aSize = Size(basegfx::fround<tools::Long>(rRange.getWidth()), basegfx::fround<tools::Long>(rRange.getHeight())); + } else -#endif - aSize = Size(basegfx::fround<tools::Long>(rRange.getWidth()), basegfx::fround<tools::Long>(rRange.getHeight())); + { + aSize = maExPrefSize; + } } else { - aSize = maExPrefSize; - } - } - else if (maVectorGraphicData) - { - aSize = maCachedBitmap.GetPrefSize(); + aSize = maCachedBitmap.GetPrefSize(); - if (!aSize.Width() || !aSize.Height()) - aSize = maCachedBitmap.GetSizePixel(); + if (!aSize.Width() || !aSize.Height()) + aSize = maCachedBitmap.GetSizePixel(); + } } else if (mpBitmapContainer) { @@ -915,10 +918,19 @@ MapMode ImpGraphic::getPrefMapMode() const { case GraphicType::Bitmap: { - if (maVectorGraphicData && maCachedBitmap.IsEmpty()) + if (maVectorGraphicData) { - // svg not yet buffered in maBitmapEx, return default PrefMapMode - aMapMode = MapMode(MapUnit::Map100thMM); + if (maCachedBitmap.IsEmpty()) + { + // svg not yet buffered in maBitmapEx, return default PrefMapMode + aMapMode = MapMode(MapUnit::Map100thMM); + } + else + { + const Size aSize = maCachedBitmap.GetPrefSize(); + if (aSize.Width() && aSize.Height()) + aMapMode = maCachedBitmap.GetPrefMapMode(); + } } else if (mpBitmapContainer) { @@ -928,12 +940,6 @@ MapMode ImpGraphic::getPrefMapMode() const { aMapMode = mpAnimationContainer->getPrefMapMode(); } - else - { - const Size aSize = maCachedBitmap.GetPrefSize(); - if (aSize.Width() && aSize.Height()) - aMapMode = maCachedBitmap.GetPrefMapMode(); - } } break; @@ -1065,11 +1071,13 @@ void ImpGraphic::draw(OutputDevice& rOutDev, { mpAnimationContainer->maAnimation.Draw(rOutDev, rDestPt, rDestSize); } - else + else if (mpBitmapContainer) { - if (maVectorGraphicData) - updateBitmapFromVectorGraphic(rOutDev.LogicToPixel(rDestSize)); - + mpBitmapContainer->getBitmapExRef().Draw(&rOutDev, rDestPt, rDestSize); + } + else if (maVectorGraphicData) + { + updateBitmapFromVectorGraphic(rOutDev.LogicToPixel(rDestSize)); getBitmapExRef().Draw(&rOutDev, rDestPt, rDestSize); } } @@ -1746,9 +1754,9 @@ BitmapChecksum ImpGraphic::getChecksum() const if (maVectorGraphicData) mnChecksum = maVectorGraphicData->GetChecksum(); else if (mpAnimationContainer) - mnChecksum = mpAnimationContainer->maAnimation.GetChecksum(); + mnChecksum = mpAnimationContainer->getChecksum(); else if (mpBitmapContainer) - mnChecksum = mpBitmapContainer->maBitmapEx.GetChecksum(); + mnChecksum = mpBitmapContainer->getChecksum(); } break; commit 90fe4900037d741ef04bdf20fc2416eaaad719a6 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Apr 10 15:03:45 2025 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Apr 14 02:47:33 2025 +0200 vcl: make ImpGraphic::getBitmap private Change-Id: I576ef069e0cbbe9b8f6be004654687765acd3ac3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184112 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Jenkins diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx index 632e184d2265..ecaa22823c6d 100644 --- a/vcl/inc/impgraph.hxx +++ b/vcl/inc/impgraph.hxx @@ -145,7 +145,6 @@ private: bool isAvailable() const; bool makeAvailable(); - Bitmap getBitmap(const GraphicConversionParameters& rParameters) const; BitmapEx getBitmapEx(const GraphicConversionParameters& rParameters) const; /// Gives direct access to the contained BitmapEx. const BitmapEx& getBitmapExRef() const; @@ -190,6 +189,8 @@ private: bool swapOutGraphic(SvStream& rStream); // end swapping + Bitmap getBitmap(const GraphicConversionParameters& rParameters) const; + void setDummyContext( bool value ) { mbDummyContext = value; } bool isDummyContext() const { return mbDummyContext; } void setGfxLink( const std::shared_ptr<GfxLink>& ); commit 2d586cea07ec5d387976bbff0fac36233b84ea6c Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Apr 10 10:31:15 2025 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Apr 14 02:47:26 2025 +0200 vcl: ImpGraphic - use sal_Int64 for byte size Already used in memory manager anyway. Change-Id: I9edf79a4c021434f573301a8e47dc76ae542aa4a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184111 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx index 52cfd768f511..632e184d2265 100644 --- a/vcl/inc/impgraph.hxx +++ b/vcl/inc/impgraph.hxx @@ -78,7 +78,7 @@ private: std::shared_ptr<VectorGraphicData> maVectorGraphicData; GraphicType meType = GraphicType::NONE; - mutable sal_uLong mnSizeBytes = 0; + mutable sal_Int64 mnSizeBytes = 0; bool mbSwapOut = false; bool mbDummyContext = false; // cache checksum computation @@ -160,7 +160,7 @@ private: MapMode getPrefMapMode() const; void setPrefMapMode( const MapMode& rPrefMapMode ); - sal_uLong getSizeBytes() const; + sal_Int64 getSizeBytes() const; void ensureCurrentSizeInBytes(); diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index a7241eae8bc5..e1c23e17c4e7 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1004,7 +1004,7 @@ void ImpGraphic::ensureCurrentSizeInBytes() changeExisting(0); } -sal_uLong ImpGraphic::getSizeBytes() const +sal_Int64 ImpGraphic::getSizeBytes() const { if (mnSizeBytes > 0) return mnSizeBytes; @@ -1439,7 +1439,7 @@ void ImpGraphic::dumpState(rtl::OStringBuffer &rState) rState.append(static_cast<sal_Int32>(meType)); rState.append(" size: "); - rState.append(static_cast<sal_Int64>(mnSizeBytes)); + rState.append(mnSizeBytes); rState.append(" gfxl: "); rState.append(static_cast<sal_Int64>(mpGfxLink ? mpGfxLink->getSizeBytes() : -1)); rState.append(" ");