summaryrefslogtreecommitdiff
path: root/sd
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 /sd
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 'sd')
-rw-r--r--sd/inc/sdpage.hxx7
-rw-r--r--sd/source/core/sdpage2.cxx11
-rw-r--r--sd/source/ui/slidesorter/view/SlideSorterView.cxx14
3 files changed, 32 insertions, 0 deletions
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 4c4c3b9ca88a..a70fbf61be8a 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -48,6 +48,7 @@ class SfxItemSet;
class Paragraph;
class Outliner;
class SdStyleSheet;
+class Graphic;
namespace sd
{
@@ -377,6 +378,12 @@ public:
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
sal_uInt16 getPageId() const { return mnPageId; }
+ /**
+ Returns graphics objects from the page that can be prefetched before it's painted.
+ The pointers are temporary and should not be kept.
+ */
+ void getGraphicsForPrefetch(std::vector<Graphic*>& graphics) const;
+
static sal_uInt16 mnLastPageId;
private:
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index 2f8f36c2b682..089712ab2693 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -29,6 +29,7 @@
#include <tools/debug.hxx>
#include <svx/svddef.hxx>
#include <rtl/math.hxx>
+#include <svx/svdograf.hxx>
#include <Annotation.hxx>
#include <notifydocumentevent.hxx>
@@ -609,6 +610,16 @@ void SdPage::removeAnnotation( const Reference< XAnnotation >& xAnnotation )
Reference<XInterface>( xAnnotation, UNO_QUERY ) );
}
+void SdPage::getGraphicsForPrefetch(std::vector<Graphic*>& graphics) const
+{
+ for( size_t i = 0; i < GetObjCount(); ++i)
+ {
+ if( SdrGrafObj* grafObj = dynamic_cast<SdrGrafObj*>(GetObj(i)))
+ if(!grafObj->GetGraphic().isAvailable())
+ graphics.push_back( const_cast<Graphic*>(&grafObj->GetGraphic()));
+ }
+}
+
void SdPage::dumpAsXml(xmlTextWriterPtr pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("SdPage"));
diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
index 46f1c00435ce..f6a6a1786e05 100644
--- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx
+++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
@@ -45,6 +45,7 @@
#include <vcl/svapp.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/settings.hxx>
+#include <vcl/graphicfilter.hxx>
#include <algorithm>
@@ -644,6 +645,19 @@ void SlideSorterView::Paint (
// Paint all page objects that are fully or partially inside the
// repaint region.
const Range aRange (mpLayouter->GetRangeOfVisiblePageObjects(rRepaintArea));
+ // Try to prefetch all graphics from the pages to paint. This will be done
+ // in threads to be more efficient than loading them on-demand one by one.
+ std::vector<Graphic*> graphics;
+ for (long nIndex=aRange.Min(); nIndex<=aRange.Max(); ++nIndex)
+ {
+ model::SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nIndex));
+ if (!pDescriptor || ! pDescriptor->HasState(PageDescriptor::ST_Visible))
+ continue;
+ pDescriptor->GetPage()->getGraphicsForPrefetch(graphics);
+ }
+ if(graphics.size() > 1) // threading does not help with loading just one
+ GraphicFilter::GetGraphicFilter().MakeGraphicsAvailableThreaded(graphics);
+
for (long nIndex=aRange.Min(); nIndex<=aRange.Max(); ++nIndex)
{
model::SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nIndex));