diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-06-08 22:54:48 -0400 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2019-03-26 11:54:43 +0100 |
commit | c8f81dbb30e89a19bb7a82f8b52cc02b9049e717 (patch) | |
tree | 6db79c631157a12b99ed6bb2c0085ce501d82b24 /vcl/source/gdi/impgraph.cxx | |
parent | d2fd88f8fab892185ab0d845fdba6e8fac1ad1c5 (diff) |
vcl: share GfxLink
When importing PDF as images, we store the
PDF stream in the GfxLink. For large PDFs
storing a copy of the full PDF with each
page is overkill. For example a 10MB PDF
with 200 pages will consume 2GB of memory!
Change-Id: I99913514cf5c562683080bc817668095bee69427
Reviewed-on: https://gerrit.libreoffice.org/55571
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/69624
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'vcl/source/gdi/impgraph.cxx')
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 8027d0d85b1d..2d73357ec43d 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -115,6 +115,7 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic) , maSwapInfo(rImpGraphic.maSwapInfo) , mpContext(rImpGraphic.mpContext) , mpSwapFile(rImpGraphic.mpSwapFile) + , mpGfxLink(rImpGraphic.mpGfxLink) , meType(rImpGraphic.meType) , mnSizeBytes(rImpGraphic.mnSizeBytes) , mbSwapOut(rImpGraphic.mbSwapOut) @@ -124,9 +125,6 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic) , maGraphicExternalLink(rImpGraphic.maGraphicExternalLink) , mnPageNumber(rImpGraphic.mnPageNumber) { - if( rImpGraphic.mpGfxLink ) - mpGfxLink = o3tl::make_unique<GfxLink>( *rImpGraphic.mpGfxLink ); - if( rImpGraphic.mpAnimation ) { mpAnimation = o3tl::make_unique<Animation>( *rImpGraphic.mpAnimation ); @@ -239,10 +237,7 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic ) mbSwapOut = rImpGraphic.mbSwapOut; mpSwapFile = rImpGraphic.mpSwapFile; - mpGfxLink.reset(); - - if( rImpGraphic.mpGfxLink ) - mpGfxLink = o3tl::make_unique<GfxLink>( *rImpGraphic.mpGfxLink ); + mpGfxLink = rImpGraphic.mpGfxLink; maVectorGraphicData = rImpGraphic.maVectorGraphicData; mpPdfData = rImpGraphic.mpPdfData; @@ -1370,11 +1365,11 @@ bool ImpGraphic::ImplSwapIn( SvStream* xIStm ) return bRet; } -void ImpGraphic::ImplSetLink( const GfxLink& rGfxLink ) +void ImpGraphic::ImplSetLink(const GfxLink& rGfxLink) { - mpGfxLink = o3tl::make_unique<GfxLink>( rGfxLink ); + mpGfxLink = rGfxLink; - if( mpGfxLink->IsNative() ) + if (mpGfxLink && mpGfxLink->IsNative()) mpGfxLink->SwapOut(); } @@ -1489,7 +1484,7 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic ) // set dummy link to avoid creation of additional link after filtering; // we set a default link to avoid unnecessary swapping of native data - aGraphic.SetLink( GfxLink() ); + aGraphic.SetLink(GfxLink()); if( !rIStm.GetError() && aLink.LoadNative( aGraphic ) ) { @@ -1506,7 +1501,7 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic ) rImpGraphic.ImplSetPrefSize( aLink.GetPrefSize() ); if( bSetLink ) - rImpGraphic.ImplSetLink( aLink ); + rImpGraphic.ImplSetLink(aLink); } else { |