From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- vcl/inc/graphic/Manager.hxx | 76 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 vcl/inc/graphic/Manager.hxx (limited to 'vcl/inc/graphic/Manager.hxx') diff --git a/vcl/inc/graphic/Manager.hxx b/vcl/inc/graphic/Manager.hxx new file mode 100644 index 000000000..bb52a0cfc --- /dev/null +++ b/vcl/inc/graphic/Manager.hxx @@ -0,0 +1,76 @@ +/* -*- 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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +class ImpGraphic; + +namespace vcl +{ +namespace graphic +{ +class Manager final +{ +private: + std::recursive_mutex maMutex; // instead of SolarMutex because graphics can live past vcl main + o3tl::sorted_vector m_pImpGraphicList; + std::chrono::seconds mnAllowedIdleTime; + bool mbSwapEnabled; + sal_Int64 mnMemoryLimit; + sal_Int64 mnUsedSize; + Timer maSwapOutTimer; + + Manager(); + + void registerGraphic(const std::shared_ptr& rImpGraphic, OUString const& rsContext); + + DECL_LINK(SwapOutTimerHandler, Timer*, void); + + static sal_Int64 getGraphicSizeBytes(const ImpGraphic* pImpGraphic); + +public: + static Manager& get(); + + void swappedIn(const ImpGraphic* pImpGraphic); + void swappedOut(const ImpGraphic* pImpGraphic); + + void reduceGraphicMemory(); + void changeExisting(const ImpGraphic* pImpGraphic, sal_Int64 nOldSize); + void unregisterGraphic(ImpGraphic* pImpGraphic); + + std::shared_ptr copy(std::shared_ptr const& pImpGraphic); + std::shared_ptr newInstance(); + std::shared_ptr newInstance(const Bitmap& rBitmap); + std::shared_ptr newInstance(const BitmapEx& rBitmapEx); + std::shared_ptr + newInstance(const std::shared_ptr& rVectorGraphicDataPtr); + std::shared_ptr newInstance(const Animation& rAnimation); + std::shared_ptr newInstance(const GDIMetaFile& rMtf); + std::shared_ptr newInstance(const GraphicExternalLink& rGraphicLink); +}; +} +} // end namespace vcl::graphic + +#endif // INCLUDED_VCL_INC_GRAPHIC_MANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3