summaryrefslogtreecommitdiff
path: root/slideshow
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-10-06 20:23:46 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-10-16 10:10:53 +0200
commit8062e88e73acd8d1f9a62b0bd519b499693285e3 (patch)
tree17cf711f457a17dc6b6b27f8f8b9dd00321927c5 /slideshow
parent40d74f2def9e2255f2a7b85b3c30f76d0a0bd44e (diff)
try to make available all slide images using threads
Graphic::makeAvailable() is not thread-safe, but the jpeg loader is capable of that, and the graphic can be loaded using the stream data (which is what ultimately makeAvailable() will do anyway). This loads all images faster using threads instead of them being loaded one by one on-demand. Change-Id: Ifc39a2757834a9fb0dbafa61f13f5454e69af330 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104082 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/slide/slideimpl.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx
index 569b7fea09a9..4adc0ce37e7c 100644
--- a/slideshow/source/engine/slide/slideimpl.cxx
+++ b/slideshow/source/engine/slide/slideimpl.cxx
@@ -48,6 +48,9 @@
#include "targetpropertiescreator.hxx"
#include <tools.hxx>
#include <box2dtools.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/unoshape.hxx>
using namespace ::com::sun::star;
@@ -387,6 +390,23 @@ void SlideImpl::prefetch()
if( !mxRootNode.is() )
return;
+ // Try to prefetch all graphics from the page. This will be done
+ // in threads to be more efficient than loading them on-demand one by one.
+ std::vector<Graphic*> graphics;
+ for (sal_Int32 i = 0; i < mxDrawPage->getCount(); i++)
+ {
+ com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape(mxDrawPage->getByIndex(i), com::sun::star::uno::UNO_QUERY_THROW);
+ SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
+ SdrObject* pObj = pShape ? pShape->GetSdrObject() : nullptr;
+ if (!pObj)
+ continue;
+ if( SdrGrafObj* grafObj = dynamic_cast<SdrGrafObj*>(pObj))
+ if( !grafObj->GetGraphic().isAvailable())
+ graphics.push_back( const_cast<Graphic*>(&grafObj->GetGraphic()));
+ }
+ if(graphics.size() > 1) // threading does not help with loading just one
+ GraphicFilter::GetGraphicFilter().MakeGraphicsAvailableThreaded( graphics );
+
applyInitialShapeAttributes(mxRootNode);
}