fix logic
[personal-kdelibs.git] / khtml / imload / imagemanager.h
blobce2edce8a0bab45884634ef5f743bfd947577cdf
1 /*
2 Large image displaying library.
4 Copyright (C) 2004 Maks Orlovich (maksim@kde.org)
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef IMAGE_MANAGER_H
26 #define IMAGE_MANAGER_H
28 #include "animtimer.h"
29 #include "loaderdatabase.h"
30 #include "tilecache.h"
31 #include "updater.h"
33 class QPixmap;
35 namespace khtmlImLoad {
37 class ImageManager
39 private:
40 static AnimTimer* anmTimer;
41 static TileCache* imgCache;
42 static TileCache* pixCache;
43 static LoaderDatabase* loaderDB;
44 static Updater* theUpdater;
45 static QPixmap* emptyPix;
47 static unsigned int pixmapCacheSize();
48 static unsigned int imageCacheSize();
50 static void initLoaders();
51 public:
52 // IMPORTANT: Don't even think about changing these to signed; it's security-critical
53 // This method determines whether we'll ever accept an image so large
54 static bool isAcceptableSize(unsigned width, unsigned height);
56 // IMPORTANT: Don't even think about changing these to signed; it's security-critical
57 // Says whether the target size is OK to scale an image too. This is much
58 // bigger than the above, as we store the actual data in the tile cache, so
59 // we just need some control information, which is much smaller
60 static bool isAcceptableScaleSize(unsigned width, unsigned height);
62 static AnimTimer* animTimer()
64 if (!anmTimer)
65 anmTimer = new AnimTimer();
66 return anmTimer;
69 static TileCache* imageCache()
71 if (!imgCache)
72 imgCache = new TileCache(imageCacheSize());
73 return imgCache;
76 static TileCache* pixmapCache()
78 if (!pixCache)
79 pixCache = new TileCache(pixmapCacheSize());
80 return pixCache;
83 static Updater* updater()
85 if (!theUpdater)
86 theUpdater = new Updater();
87 return theUpdater;
90 static LoaderDatabase* loaderDatabase()
92 if (!loaderDB)
94 loaderDB = new LoaderDatabase();
95 initLoaders(); //Register built-in decoders
97 return loaderDB;
103 #endif
104 // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;