office-gobmx/vcl/inc/graphic/Manager.hxx
Tomaž Vajngerl d7a201ee95 replace and remove VectorGraphicDataPtr typedef for the real type
There is no need to hide std::shared_ptr<VectorGraphicData> type
under an alias name. It doesn't make the code more understandble
and it usually is the exact opposite because we know with what
type we are dealing with.

Change-Id: Iec80ee99697ff2fe3a8275fc2787b5370510ebe6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92069
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2020-04-12 11:34:07 +02:00

76 lines
2.4 KiB
C++

/* -*- 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 <memory>
#include <mutex>
#include <chrono>
#include <o3tl/sorted_vector.hxx>
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<ImpGraphic*> m_pImpGraphicList;
std::chrono::seconds mnAllowedIdleTime;
bool mbSwapEnabled;
sal_Int64 mnMemoryLimit;
sal_Int64 mnUsedSize;
Timer maSwapOutTimer;
Manager();
void registerGraphic(const std::shared_ptr<ImpGraphic>& 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<ImpGraphic> copy(std::shared_ptr<ImpGraphic> const& pImpGraphic);
std::shared_ptr<ImpGraphic> newInstance();
std::shared_ptr<ImpGraphic> newInstance(const Bitmap& rBitmap);
std::shared_ptr<ImpGraphic> newInstance(const BitmapEx& rBitmapEx);
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: */