Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _GRFCACHE_HXX
30 : : #define _GRFCACHE_HXX
31 : :
32 : : #include <vcl/graph.hxx>
33 : : #include <vcl/timer.hxx>
34 : : #include <list>
35 : :
36 : : // -----------------------
37 : : // - GraphicManagerCache -
38 : : // -----------------------
39 : :
40 : : class GraphicAttr;
41 : : class GraphicCacheEntry;
42 : : class GraphicDisplayCacheEntry;
43 : : class GraphicObject;
44 : :
45 : : class GraphicCache
46 : : {
47 : : private:
48 : : typedef std::list< GraphicCacheEntry* > GraphicCacheEntryList;
49 : : typedef std::list< GraphicDisplayCacheEntry* > GraphicDisplayCacheEntryList;
50 : :
51 : : Timer maReleaseTimer;
52 : : GraphicCacheEntryList maGraphicCache;
53 : : GraphicDisplayCacheEntryList maDisplayCache;
54 : : sal_uLong mnReleaseTimeoutSeconds;
55 : : sal_uLong mnMaxDisplaySize;
56 : : sal_uLong mnMaxObjDisplaySize;
57 : : sal_uLong mnUsedDisplaySize;
58 : :
59 : : sal_Bool ImplFreeDisplayCacheSpace( sal_uLong nSizeToFree );
60 : : GraphicCacheEntry* ImplGetCacheEntry( const GraphicObject& rObj );
61 : :
62 : :
63 : : DECL_LINK( ReleaseTimeoutHdl, Timer* pTimer );
64 : :
65 : : public:
66 : :
67 : : GraphicCache(
68 : : sal_uLong nDisplayCacheSize = 10000000UL,
69 : : sal_uLong nMaxObjDisplayCacheSize = 2400000UL
70 : : );
71 : :
72 : : ~GraphicCache();
73 : :
74 : : public:
75 : :
76 : : void AddGraphicObject(
77 : : const GraphicObject& rObj,
78 : : Graphic& rSubstitute,
79 : : const rtl::OString* pID,
80 : : const GraphicObject* pCopyObj
81 : : );
82 : :
83 : : void ReleaseGraphicObject( const GraphicObject& rObj );
84 : :
85 : : void GraphicObjectWasSwappedOut( const GraphicObject& rObj );
86 : : sal_Bool FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
87 : : void GraphicObjectWasSwappedIn( const GraphicObject& rObj );
88 : :
89 : : rtl::OString GetUniqueID( const GraphicObject& rObj ) const;
90 : :
91 : : public:
92 : :
93 : : void SetMaxDisplayCacheSize( sal_uLong nNewCacheSize );
94 : 0 : sal_uLong GetMaxDisplayCacheSize() const { return mnMaxDisplaySize; };
95 : :
96 : : void SetMaxObjDisplayCacheSize(
97 : : sal_uLong nNewMaxObjSize,
98 : : sal_Bool bDestroyGreaterCached = sal_False
99 : : );
100 : :
101 : 35068 : sal_uLong GetMaxObjDisplayCacheSize() const { return mnMaxObjDisplaySize; }
102 : :
103 : 0 : sal_uLong GetUsedDisplayCacheSize() const { return mnUsedDisplaySize; }
104 : 17534 : sal_uLong GetFreeDisplayCacheSize() const { return( mnMaxDisplaySize - mnUsedDisplaySize ); }
105 : :
106 : : void SetCacheTimeout( sal_uLong nTimeoutSeconds );
107 : 35070 : sal_uLong GetCacheTimeout() const { return mnReleaseTimeoutSeconds; }
108 : :
109 : : sal_Bool IsDisplayCacheable(
110 : : OutputDevice* pOut,
111 : : const Point& rPt,
112 : : const Size& rSz,
113 : : const GraphicObject& rObj,
114 : : const GraphicAttr& rAttr
115 : : ) const;
116 : :
117 : : sal_Bool IsInDisplayCache(
118 : : OutputDevice* pOut,
119 : : const Point& rPt,
120 : : const Size& rSz,
121 : : const GraphicObject& rObj,
122 : : const GraphicAttr& rAttr
123 : : ) const;
124 : :
125 : : sal_Bool CreateDisplayCacheObj(
126 : : OutputDevice* pOut,
127 : : const Point& rPt,
128 : : const Size& rSz,
129 : : const GraphicObject& rObj,
130 : : const GraphicAttr& rAttr,
131 : : const BitmapEx& rBmpEx
132 : : );
133 : :
134 : : sal_Bool CreateDisplayCacheObj(
135 : : OutputDevice* pOut,
136 : : const Point& rPt,
137 : : const Size& rSz,
138 : : const GraphicObject& rObj,
139 : : const GraphicAttr& rAttr,
140 : : const GDIMetaFile& rMtf
141 : : );
142 : :
143 : : sal_Bool DrawDisplayCacheObj(
144 : : OutputDevice* pOut,
145 : : const Point& rPt,
146 : : const Size& rSz,
147 : : const GraphicObject& rObj,
148 : : const GraphicAttr& rAttr
149 : : );
150 : : };
151 : :
152 : : #endif // _GRFCACHE_HXX
153 : :
154 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|