summaryrefslogtreecommitdiff
path: root/vcl/inc
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-04-14 09:07:33 +0200
committerCaolán McNamara <caolanm@redhat.com>2020-04-25 17:51:20 +0200
commit983a92f697fc6399ad52dd1e757a88e8736bfdf2 (patch)
tree7c2cdde251161859aea330a500cae478f4ebc952 /vcl/inc
parent6ae88e7b2711321783fb756a4796c89b70497db5 (diff)
tdf#131496 vcl image lazy load: speed up vector images with custom pref size
This speeds up the loading of the bugdoc: - old cost: 6378 ms - new cost: 1891 ms (30% of baseline) Images were initially loaded at import time, but commit acb803b730f2c6bd82e39beab58949ec14f85eb0 (tdf#125591 DOC import: lazy-load metafiles with explicit size, 2019-06-11) changed this, so that they are lazy-loaded. That improved performance, but sometimes gave incorrect results. Then commit d8371cdfd092c6426c01aae130ea4eaa6d627a6f (tdf#127446 vcl image lazy-load: fix custom size handling of metafiles, 2019-09-30) fixed the correctness problem, but the loading was no longer lazy in the tdf#131496 case. This is an attempt to bring back lazy-loading for vector-based images, while maintaining the correct preferred size. The problem was that the PPT import triggered a vector -> bitmap conversion during load: #0 0x00007ffff03c7e36 in ImpGraphic::loadPrepared() (this=this@entry=0x1f88a90) at vcl/source/gdi/impgraph.cxx:1424 #1 0x00007ffff03c72c7 in ImpGraphic::ImplSwapIn() (this=0x1f88a90) at vcl/source/gdi/impgraph.cxx:1444 #2 0x00007ffff03c7535 in ImpGraphic::ensureAvailable() const (this=this@entry=0x1f88a90) at vcl/source/gdi/impgraph.cxx:1402 #3 0x00007ffff03c9481 in ImpGraphic::ImplExportNative(SvStream&) const (this=0x1f88a90, rOStm=...) at vcl/source/gdi/impgraph.cxx:1590 #4 0x00007ffff03bf9a8 in Graphic::ExportNative(SvStream&) const (this=this@entry=0x20534e0, rOStream=...) at vcl/source/gdi/graph.cxx:544 #5 0x00007ffff1c79a28 in svt::EmbeddedObjectRef::SetGraphicToContainer(Graphic const&, comphelper::EmbeddedObjectContainer&, rtl::OUString const&, rtl::OUString const&) (rGraphic=..., aContainer=..., aName="Object 1", aMediaType="") at svtools/source/misc/embedhlp.cxx:773 #6 0x00007ffff1c79b6f in svt::EmbeddedObjectRef::AssignToContainer(comphelper::EmbeddedObjectContainer*, rtl::OUString const&) (this=0x207ae90, pContainer=pContainer@entry=0x1f8de40, rPersistName=...) at svtools/source/misc/embedhlp.cxx:369 #7 0x00007ffff239f736 in SdrOle2Obj::Connect_Impl() (this=this@entry=0x20734f0) at svx/source/svdraw/svdoole2.cxx:984 #8 0x00007ffff23a6310 in SdrOle2Obj::Init() (this=this@entry=0x20734f0) at svx/source/svdraw/svdoole2.cxx:695 Try to defer that conversion by not doing a maVectorGraphicData->getReplacement() in ImpGraphic::ImplSetPrefSize(), rather just store the preferred size and apply it later when getReplacement() is called. This helps, because the above OLE-from-PPT case loads the graphic, but only to export it as SVM, so it doesn't need a vector -> bitmap conversion otherwise. (cherry picked from commit 952cc68929f863784c6b01c9dc071494892877d1) Change-Id: I24790c0a3e298d5fbb3faff35d529e79cc72845a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92156 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/inc')
-rw-r--r--vcl/inc/impgraph.hxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 90e658c67308..159b70a691e0 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -75,6 +75,8 @@ private:
GDIMetaFile maMetaFile;
BitmapEx maEx;
+ /// If maEx is empty, this preferred size will be set on it when it gets initialized.
+ Size maExPrefSize;
ImpSwapInfo maSwapInfo;
std::unique_ptr<Animation> mpAnimation;
std::shared_ptr<GraphicReader> mpContext;
@@ -232,6 +234,9 @@ private:
void setPdfData(const std::shared_ptr<std::vector<sal_Int8>>& rPdfData);
+ /// Gets the bitmap replacement for a vector graphic.
+ BitmapEx getVectorGraphicReplacement() const;
+
bool ensureAvailable () const;
bool loadPrepared();