summaryrefslogtreecommitdiffstats
path: root/vcl/inc/graphic/Manager.hxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /vcl/inc/graphic/Manager.hxx
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/inc/graphic/Manager.hxx')
-rw-r--r--vcl/inc/graphic/Manager.hxx78
1 files changed, 78 insertions, 0 deletions
diff --git a/vcl/inc/graphic/Manager.hxx b/vcl/inc/graphic/Manager.hxx
new file mode 100644
index 000000000..6324ff89a
--- /dev/null
+++ b/vcl/inc/graphic/Manager.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_VCL_INC_GRAPHIC_MANAGER_HXX
+#define INCLUDED_VCL_INC_GRAPHIC_MANAGER_HXX
+
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/animate/Animation.hxx>
+#include <vcl/vectorgraphicdata.hxx>
+#include <vcl/timer.hxx>
+#include <vcl/GraphicExternalLink.hxx>
+#include <vcl/gfxlink.hxx>
+
+#include <memory>
+#include <mutex>
+#include <chrono>
+#include <o3tl/sorted_vector.hxx>
+
+class ImpGraphic;
+
+namespace vcl::graphic
+{
+class Manager final
+{
+private:
+ std::mutex maMutex; // instead of SolarMutex because graphics can live past vcl main
+ o3tl::sorted_vector<ImpGraphic*> m_pImpGraphicList;
+ std::chrono::seconds mnAllowedIdleTime;
+ bool mbSwapEnabled;
+ bool mbReducingGraphicMemory;
+ sal_Int64 mnMemoryLimit;
+ sal_Int64 mnUsedSize;
+ Timer maSwapOutTimer;
+
+ Manager();
+
+ void registerGraphic(const std::shared_ptr<ImpGraphic>& rImpGraphic);
+ void loopGraphicsAndSwapOut(std::unique_lock<std::mutex>& rGuard);
+
+ DECL_LINK(SwapOutTimerHandler, Timer*, void);
+
+ static sal_Int64 getGraphicSizeBytes(const ImpGraphic* pImpGraphic);
+ void reduceGraphicMemory(std::unique_lock<std::mutex>& rGuard);
+
+public:
+ static Manager& get();
+
+ void swappedIn(const ImpGraphic* pImpGraphic, sal_Int64 nSizeBytes);
+ void swappedOut(const ImpGraphic* pImpGraphic, sal_Int64 nSizeBytes);
+
+ void changeExisting(const ImpGraphic* pImpGraphic, sal_Int64 nOldSize);
+ void unregisterGraphic(ImpGraphic* pImpGraphic);
+
+ std::shared_ptr<ImpGraphic> copy(std::shared_ptr<ImpGraphic> const& pImpGraphic);
+ std::shared_ptr<ImpGraphic> newInstance();
+ std::shared_ptr<ImpGraphic> newInstance(const BitmapEx& rBitmapEx);
+ std::shared_ptr<ImpGraphic> newInstance(std::shared_ptr<GfxLink> const& rLink,
+ sal_Int32 nPageIndex = 0);
+ std::shared_ptr<ImpGraphic>
+ newInstance(const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr);
+ std::shared_ptr<ImpGraphic> newInstance(const Animation& rAnimation);
+ std::shared_ptr<ImpGraphic> newInstance(const GDIMetaFile& rMtf);
+ std::shared_ptr<ImpGraphic> newInstance(const GraphicExternalLink& rGraphicLink);
+};
+
+} // end namespace vcl::graphic
+
+#endif // INCLUDED_VCL_INC_GRAPHIC_MANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */