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 SD_SLIDESORTER_CACHE_COMPACTOR_HXX
30 : : #define SD_SLIDESORTER_CACHE_COMPACTOR_HXX
31 : :
32 : : #include <sal/types.h>
33 : : #include <vcl/timer.hxx>
34 : : #include <memory>
35 : :
36 : : namespace sd { namespace slidesorter { namespace cache {
37 : :
38 : : class BitmapCache;
39 : :
40 : : /** This is an interface class whose implementations are created via the
41 : : Create() factory method.
42 : : */
43 : : class CacheCompactor
44 : : {
45 : : public:
46 [ - + ]: 126 : virtual ~CacheCompactor (void) {};
47 : :
48 : : /** Create a new instance of the CacheCompactor interface class. The
49 : : type of compaction algorithm used depends on values from the
50 : : configuration: the SlideSorter/PreviewCache/CompactionPolicy
51 : : property of the Impress.xcs file currently supports the values
52 : : "None" and "Compress". With the later the CompressionPolicy
53 : : property is evaluated which implementation of the BitmapCompress
54 : : interface class to use as bitmap compressor.
55 : : @param rCache
56 : : The bitmap cache on which to operate.
57 : : @param nMaximalCacheSize
58 : : The total number of bytes the off-screen bitmaps in the cache
59 : : may have. When the Run() method is (indirectly) called the
60 : : compactor tries to reduce that summed size of off-screen bitmaps
61 : : under this number. However, it is not guaranteed that this
62 : : works in all cases.
63 : : */
64 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
65 : : static ::std::auto_ptr<CacheCompactor> Create (
66 : : BitmapCache& rCache,
67 : : sal_Int32 nMaximalCacheSize);
68 : : SAL_WNODEPRECATED_DECLARATIONS_POP
69 : :
70 : : /** Request a compaction of the off-screen previews in the bitmap
71 : : cache. This calls via a timer the Run() method.
72 : : */
73 : : virtual void RequestCompaction (void);
74 : :
75 : : protected:
76 : : BitmapCache& mrCache;
77 : : sal_Int32 mnMaximalCacheSize;
78 : :
79 : : CacheCompactor(
80 : : BitmapCache& rCache,
81 : : sal_Int32 nMaximalCacheSize);
82 : :
83 : : /** This method actually tries to reduce the total number of bytes used
84 : : by the off-screen preview bitmaps.
85 : : */
86 : : virtual void Run (void) = 0;
87 : :
88 : : private:
89 : : /** This timer is used to collect calles to RequestCompaction() and
90 : : eventually call Run().
91 : : */
92 : : Timer maCompactionTimer;
93 : : bool mbIsCompactionRunning;
94 : : DECL_LINK(CompactionCallback, void *);
95 : : };
96 : :
97 : :
98 : :
99 : :
100 : : } } } // end of namespace ::sd::slidesorter::cache
101 : :
102 : : #endif
103 : :
104 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|