Bump version to 5.0-14
[LibreOffice.git] / svtools / source / graphic / grfcache.hxx
blob6164cb2b00859c9ddf1b66d41e47f7cecbce2114
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVTOOLS_SOURCE_GRAPHIC_GRFCACHE_HXX
21 #define INCLUDED_SVTOOLS_SOURCE_GRAPHIC_GRFCACHE_HXX
23 #include <vcl/graph.hxx>
24 #include <vcl/timer.hxx>
25 #include <list>
28 // - GraphicManagerCache -
31 class GraphicAttr;
32 class GraphicCacheEntry;
33 class GraphicDisplayCacheEntry;
34 class GraphicObject;
36 class GraphicCache
38 private:
39 typedef std::list< GraphicCacheEntry* > GraphicCacheEntryList;
40 typedef std::list< GraphicDisplayCacheEntry* > GraphicDisplayCacheEntryList;
42 Timer maReleaseTimer;
43 GraphicCacheEntryList maGraphicCache;
44 GraphicDisplayCacheEntryList maDisplayCache;
45 sal_uLong mnReleaseTimeoutSeconds;
46 sal_uLong mnMaxDisplaySize;
47 sal_uLong mnMaxObjDisplaySize;
48 sal_uLong mnUsedDisplaySize;
50 bool ImplFreeDisplayCacheSpace( sal_uLong nSizeToFree );
51 GraphicCacheEntry* ImplGetCacheEntry( const GraphicObject& rObj );
54 DECL_LINK_TYPED( ReleaseTimeoutHdl, Timer* pTimer, void );
56 public:
58 GraphicCache(
59 sal_uLong nDisplayCacheSize = 10000000UL,
60 sal_uLong nMaxObjDisplayCacheSize = 2400000UL
63 ~GraphicCache();
65 public:
67 void AddGraphicObject(
68 const GraphicObject& rObj,
69 Graphic& rSubstitute,
70 const OString* pID,
71 const GraphicObject* pCopyObj
74 void ReleaseGraphicObject( const GraphicObject& rObj );
76 void GraphicObjectWasSwappedOut( const GraphicObject& rObj );
77 void GraphicObjectWasSwappedIn( const GraphicObject& rObj );
79 OString GetUniqueID( const GraphicObject& rObj ) const;
81 public:
83 void SetMaxDisplayCacheSize( sal_uLong nNewCacheSize );
84 sal_uLong GetMaxDisplayCacheSize() const { return mnMaxDisplaySize; };
86 void SetMaxObjDisplayCacheSize(
87 sal_uLong nNewMaxObjSize,
88 bool bDestroyGreaterCached = false
91 sal_uLong GetMaxObjDisplayCacheSize() const { return mnMaxObjDisplaySize; }
93 sal_uLong GetUsedDisplayCacheSize() const { return mnUsedDisplaySize; }
94 sal_uLong GetFreeDisplayCacheSize() const { return( mnMaxDisplaySize - mnUsedDisplaySize ); }
96 void SetCacheTimeout( sal_uLong nTimeoutSeconds );
97 sal_uLong GetCacheTimeout() const { return mnReleaseTimeoutSeconds; }
99 bool IsDisplayCacheable(
100 OutputDevice* pOut,
101 const Point& rPt,
102 const Size& rSz,
103 const GraphicObject& rObj,
104 const GraphicAttr& rAttr
105 ) const;
107 bool IsInDisplayCache(
108 OutputDevice* pOut,
109 const Point& rPt,
110 const Size& rSz,
111 const GraphicObject& rObj,
112 const GraphicAttr& rAttr
113 ) const;
115 bool CreateDisplayCacheObj(
116 OutputDevice* pOut,
117 const Point& rPt,
118 const Size& rSz,
119 const GraphicObject& rObj,
120 const GraphicAttr& rAttr,
121 const BitmapEx& rBmpEx
124 bool CreateDisplayCacheObj(
125 OutputDevice* pOut,
126 const Point& rPt,
127 const Size& rSz,
128 const GraphicObject& rObj,
129 const GraphicAttr& rAttr,
130 const GDIMetaFile& rMtf
133 bool DrawDisplayCacheObj(
134 OutputDevice* pOut,
135 const Point& rPt,
136 const Size& rSz,
137 const GraphicObject& rObj,
138 const GraphicAttr& rAttr
142 #endif // INCLUDED_SVTOOLS_SOURCE_GRAPHIC_GRFCACHE_HXX
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */