don't include "cvs" in the version (not using cvs anymore :D)
[blackbox.git] / lib / PixmapCache.hh
blobf2da8050d2a8b442bed2d7113535e57b39c01ed3
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // PixmapCache.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000, 2002 - 2005
5 // Bradley T Hughes <bhughes at trolltech.com>
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a
8 // copy of this software and associated documentation files (the "Software"),
9 // to deal in the Software without restriction, including without limitation
10 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 // and/or sell copies of the Software, and to permit persons to whom the
12 // Software is furnished to do so, subject to the following conditions:
14 // The above copyright notice and this permission notice shall be included in
15 // all copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 // DEALINGS IN THE SOFTWARE.
25 #ifndef __PixmapCache_hh
26 #define __PixmapCache_hh
28 #include "Util.hh"
30 namespace bt {
32 // forward declarations
33 class Texture;
35 class PixmapCache : public NoCopy {
36 public:
38 Returns the cache limit in kilobytes. The default is one
39 megabyte (1024 kilobytes).
41 When this limit is reached, the cache will automatically free
42 unused pixmaps to reduce the amount of server side memory used.
44 NOTE: This limit is not a hard limit. The cache will never free
45 a pixmap that is in use. This means it is possible that the
46 PixmapCache memory usage can exceed this limit.
48 static unsigned long cacheLimit(void);
51 Set the cache limit to the specified value (in kilobytes).
53 static void setCacheLimit(unsigned long limit);
56 Returns the current amount of memory in kilobytes used by the X
57 server for the pixmaps in the cache.
59 static unsigned long memoryUsage(void);
62 Returns a pixmap matching the specified texture and size on the
63 specified screen. The pixmap will be rendered if necessary.
65 If old_pixmap is non-zero, PixmapCache::release(old_pixmap) will
66 be called immediately after finding the requested pixmap.
68 static Pixmap find(unsigned int screen,
69 const Texture &texture,
70 unsigned int width, unsigned int height,
71 Pixmap old_pixmap = 0ul);
74 Indicates that the specified pixmap is no longer needed.
75 Pixmaps contained in the cache are reference counted, so you
76 should call this function once for each time you call
77 PixmapCache::find().
79 static void release(Pixmap pixmap);
82 Free all unused pixmaps in the cache.
84 static void clearCache(void);
86 private:
87 // static only interface
88 PixmapCache();
91 } // namespace bt
93 #endif // __PixmapCache_hh