diff options
author | Jan Holesovsky <kendy@collabora.com> | 2018-06-21 21:33:56 +0200 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2018-06-22 14:26:04 +0200 |
commit | 121052be218f15d81772a1cbb2208189563a8aa6 (patch) | |
tree | 990fc4a0071b4bd2d604acf61cca92361009d109 /vcl/source | |
parent | 121ba866e0d4cc9d4e7e51546aeda561f4267cd3 (diff) |
pdfium: Share the GfxLink for PDF files.
Partially based on work by Ashod Nakashian, thanks!
Change-Id: Id7e8c4543368b0caf3e459abaff8c53997779c83
Reviewed-on: https://gerrit.libreoffice.org/56265
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/graph.cxx | 6 | ||||
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 30 |
2 files changed, 31 insertions, 5 deletions
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index cbdf5df56ea5..cbf28e755c8f 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -552,6 +552,12 @@ void Graphic::SetLink( const GfxLink& rGfxLink ) mxImpGraphic->ImplSetLink( rGfxLink ); } +void Graphic::SetSharedLink(const std::shared_ptr<GfxLink>& pGfxLink) +{ + ImplTestRefCount(); + mxImpGraphic->ImplSetSharedLink(pGfxLink); +} + GfxLink Graphic::GetLink() const { return mxImpGraphic->ImplGetLink(); diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 798b7c85f745..9332af115ece 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -125,7 +125,12 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic) , mnPageNumber(rImpGraphic.mnPageNumber) { if( rImpGraphic.mpGfxLink ) - mpGfxLink = o3tl::make_unique<GfxLink>( *rImpGraphic.mpGfxLink ); + { + if (rImpGraphic.mpGfxLink->GetType() == GfxLinkType::NativePdf) + mpGfxLink = rImpGraphic.mpGfxLink; + else + mpGfxLink = std::make_shared<GfxLink>(*rImpGraphic.mpGfxLink); + } if( rImpGraphic.mpAnimation ) { @@ -239,10 +244,17 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic ) mbSwapOut = rImpGraphic.mbSwapOut; mpSwapFile = rImpGraphic.mpSwapFile; - mpGfxLink.reset(); + if (rImpGraphic.mpGfxLink) + { + if (rImpGraphic.mpGfxLink->GetType() == GfxLinkType::NativePdf) + mpGfxLink = rImpGraphic.mpGfxLink; + else + { + mpGfxLink.reset(); - if( rImpGraphic.mpGfxLink ) - mpGfxLink = o3tl::make_unique<GfxLink>( *rImpGraphic.mpGfxLink ); + mpGfxLink = std::make_shared<GfxLink>(*rImpGraphic.mpGfxLink); + } + } maSvgData = rImpGraphic.maSvgData; mpPdfData = rImpGraphic.mpPdfData; @@ -1347,12 +1359,20 @@ bool ImpGraphic::ImplSwapIn( SvStream* xIStm ) void ImpGraphic::ImplSetLink( const GfxLink& rGfxLink ) { - mpGfxLink = o3tl::make_unique<GfxLink>( rGfxLink ); + mpGfxLink = std::make_shared<GfxLink>( rGfxLink ); if( mpGfxLink->IsNative() ) mpGfxLink->SwapOut(); } +void ImpGraphic::ImplSetSharedLink(const std::shared_ptr<GfxLink>& pGfxLink) +{ + mpGfxLink = pGfxLink; + + if (mpGfxLink->IsNative()) + mpGfxLink->SwapOut(); +} + GfxLink ImpGraphic::ImplGetLink() { return( mpGfxLink ? *mpGfxLink : GfxLink() ); |