1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #ifndef INCLUDED_VCL_INC_GRAPHIC_MANAGER_HXX
11 #define INCLUDED_VCL_INC_GRAPHIC_MANAGER_HXX
13 #include <sal/types.h>
14 #include <rtl/strbuf.hxx>
15 #include <vcl/bitmapex.hxx>
16 #include <vcl/animate/Animation.hxx>
17 #include <vcl/vectorgraphicdata.hxx>
18 #include <vcl/timer.hxx>
19 #include <vcl/GraphicExternalLink.hxx>
20 #include <vcl/gfxlink.hxx>
25 #include <o3tl/sorted_vector.hxx>
29 namespace vcl::graphic
34 std::mutex maMutex
; // instead of SolarMutex because graphics can live past vcl main
35 o3tl::sorted_vector
<ImpGraphic
*> m_pImpGraphicList
;
36 std::chrono::seconds mnAllowedIdleTime
;
38 bool mbReducingGraphicMemory
;
39 sal_Int64 mnMemoryLimit
;
45 void registerGraphic(const std::shared_ptr
<ImpGraphic
>& rImpGraphic
);
46 void loopGraphicsAndSwapOut(std::unique_lock
<std::mutex
>& rGuard
, bool bDropAll
);
48 DECL_LINK(SwapOutTimerHandler
, Timer
*, void);
50 static sal_Int64
getGraphicSizeBytes(const ImpGraphic
* pImpGraphic
);
51 void reduceGraphicMemory(std::unique_lock
<std::mutex
>& rGuard
, bool bDropAll
= false);
54 static Manager
& get();
57 void dumpState(rtl::OStringBuffer
& rState
);
59 void swappedIn(const ImpGraphic
* pImpGraphic
, sal_Int64 nSizeBytes
);
60 void swappedOut(const ImpGraphic
* pImpGraphic
, sal_Int64 nSizeBytes
);
62 void changeExisting(const ImpGraphic
* pImpGraphic
, sal_Int64 nOldSize
);
63 void unregisterGraphic(ImpGraphic
* pImpGraphic
);
65 std::shared_ptr
<ImpGraphic
> copy(std::shared_ptr
<ImpGraphic
> const& pImpGraphic
);
66 std::shared_ptr
<ImpGraphic
> newInstance();
67 std::shared_ptr
<ImpGraphic
> newInstance(const BitmapEx
& rBitmapEx
);
68 std::shared_ptr
<ImpGraphic
> newInstance(std::shared_ptr
<GfxLink
> const& rLink
,
69 sal_Int32 nPageIndex
= 0);
70 std::shared_ptr
<ImpGraphic
>
71 newInstance(const std::shared_ptr
<VectorGraphicData
>& rVectorGraphicDataPtr
);
72 std::shared_ptr
<ImpGraphic
> newInstance(const Animation
& rAnimation
);
73 std::shared_ptr
<ImpGraphic
> newInstance(const GDIMetaFile
& rMtf
);
74 std::shared_ptr
<ImpGraphic
> newInstance(const GraphicExternalLink
& rGraphicLink
);
77 } // end namespace vcl::graphic
79 #endif // INCLUDED_VCL_INC_GRAPHIC_MANAGER_HXX
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */