File indexing completed on 2025-02-16 09:59:25
0001 /* 0002 Large image displaying library. 0003 0004 Copyright (C) 2004 Maks Orlovich (maksim@kde.org) 0005 0006 Permission is hereby granted, free of charge, to any person obtaining a copy 0007 of this software and associated documentation files (the "Software"), to deal 0008 in the Software without restriction, including without limitation the rights 0009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 0010 copies of the Software, and to permit persons to whom the Software is 0011 furnished to do so, subject to the following conditions: 0012 0013 The above copyright notice and this permission notice shall be included in 0014 all copies or substantial portions of the Software. 0015 0016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0019 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 0020 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 0021 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 0022 0023 */ 0024 0025 #ifndef IMAGE_MANAGER_H 0026 #define IMAGE_MANAGER_H 0027 0028 #include "animtimer.h" 0029 #include "loaderdatabase.h" 0030 #include "tilecache.h" 0031 #include "updater.h" 0032 0033 class QPixmap; 0034 0035 namespace khtmlImLoad 0036 { 0037 0038 class ImageManager 0039 { 0040 private: 0041 static AnimTimer *anmTimer; 0042 static TileCache *imgCache; 0043 static TileCache *pixCache; 0044 static LoaderDatabase *loaderDB; 0045 static Updater *theUpdater; 0046 static QPixmap *emptyPix; 0047 0048 static unsigned int pixmapCacheSize(); 0049 static unsigned int imageCacheSize(); 0050 0051 static void initLoaders(); 0052 public: 0053 // IMPORTANT: Don't even think about changing these to signed; it's security-critical 0054 // This method determines whether we'll ever accept an image so large 0055 static bool isAcceptableSize(unsigned width, unsigned height); 0056 0057 // IMPORTANT: Don't even think about changing these to signed; it's security-critical 0058 // Says whether the target size is OK to scale an image too. This is much 0059 // bigger than the above, as we store the actual data in the tile cache, so 0060 // we just need some control information, which is much smaller 0061 static bool isAcceptableScaleSize(unsigned width, unsigned height); 0062 0063 static AnimTimer *animTimer() 0064 { 0065 if (!anmTimer) { 0066 anmTimer = new AnimTimer(); 0067 } 0068 return anmTimer; 0069 } 0070 0071 static TileCache *imageCache() 0072 { 0073 if (!imgCache) { 0074 imgCache = new TileCache(imageCacheSize()); 0075 } 0076 return imgCache; 0077 } 0078 0079 static TileCache *pixmapCache() 0080 { 0081 if (!pixCache) { 0082 pixCache = new TileCache(pixmapCacheSize()); 0083 } 0084 return pixCache; 0085 } 0086 0087 static Updater *updater() 0088 { 0089 if (!theUpdater) { 0090 theUpdater = new Updater(); 0091 } 0092 return theUpdater; 0093 } 0094 0095 static LoaderDatabase *loaderDatabase() 0096 { 0097 if (!loaderDB) { 0098 loaderDB = new LoaderDatabase(); 0099 initLoaders(); //Register built-in decoders 0100 } 0101 return loaderDB; 0102 } 0103 }; 0104 0105 } 0106 0107 #endif