llviewerimagelist.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLVIEWERIMAGELIST_H                                  
00033 #define LL_LLVIEWERIMAGELIST_H
00034 
00035 #include "lluuid.h"
00036 //#include "message.h"
00037 #include "llgl.h"
00038 #include "llstat.h"
00039 #include "llviewerimage.h"
00040 #include "llui.h"
00041 #include <list>
00042 #include <set>
00043 
00044 const U32 LL_IMAGE_REZ_LOSSLESS_CUTOFF = 128;
00045 
00046 const BOOL MIPMAP_YES = TRUE;
00047 const BOOL MIPMAP_NO = FALSE;
00048 
00049 const BOOL GL_TEXTURE_YES = TRUE;
00050 const BOOL GL_TEXTURE_NO = FALSE;
00051 
00052 const BOOL IMMEDIATE_YES = TRUE;
00053 const BOOL IMMEDIATE_NO = FALSE;
00054 
00055 class LLMessageSystem;
00056 class LLViewerImage;
00057 class LLTextureView;
00058 
00059 typedef void (*LLImageCallback)(BOOL success,
00060                                                                 LLViewerImage *src_vi,
00061                                                                 LLImageRaw* src,
00062                                                                 LLImageRaw* src_aux,
00063                                                                 S32 discard_level,
00064                                                                 BOOL final,
00065                                                                 void* userdata);
00066 
00067 class LLViewerImageList
00068 {
00069         LOG_CLASS(LLViewerImageList);
00070 
00071         friend class LLTextureView;
00072         
00073 public:
00074         static BOOL createUploadFile(const LLString& filename, const LLString& out_filename, const U8 codec);
00075         static LLPointer<LLImageJ2C> convertToUploadFile(LLPointer<LLImageRaw> raw_image);
00076         static void processImageNotInDatabase( LLMessageSystem *msg, void **user_data );
00077         static S32 calcMaxTextureRAM();
00078         static void receiveImageHeader(LLMessageSystem *msg, void **user_data);
00079         static void receiveImagePacket(LLMessageSystem *msg, void **user_data);
00080 
00081 public:
00082         LLViewerImageList();
00083         ~LLViewerImageList();
00084 
00085         void init();
00086         void shutdown();
00087         void dump();
00088         void destroyGL(BOOL save_state = TRUE);
00089         void restoreGL();
00090 
00091         LLViewerImage * getImage(const LLUUID &image_id,
00092                                                                          BOOL usemipmap = TRUE,
00093                                                                          BOOL level_immediate = FALSE,          // Get the requested level immediately upon creation.
00094                                                                          LLGLint internal_format = 0,
00095                                                                          LLGLenum primary_format = 0,
00096                                                                          LLHost request_from_host = LLHost()
00097                                                                          );
00098         
00099         LLViewerImage * getImageFromFile(const LLString& filename,
00100                                                                          BOOL usemipmap = TRUE,
00101                                                                          BOOL level_immediate = FALSE,          // Get the requested level immediately upon creation.
00102                                                                          LLGLint internal_format = 0,
00103                                                                          LLGLenum primary_format = 0,
00104                                                                          const LLUUID& force_id = LLUUID::null
00105                                                                          );
00106 
00107         // Request image from a specific host, used for baked avatar textures.
00108         // Implemented in header in case someone changes default params above. JC
00109         LLViewerImage* getImageFromHost(const LLUUID& image_id, LLHost host)
00110                 { return getImage(image_id, TRUE, FALSE, 0, 0, host); }
00111 
00112         LLViewerImage *hasImage(const LLUUID &image_id);
00113         void addImage(LLViewerImage *image);
00114         void deleteImage(LLViewerImage *image);
00115 
00116         void addImageToList(LLViewerImage *image);
00117         void removeImageFromList(LLViewerImage *image);
00118 
00119         void dirtyImage(LLViewerImage *image);
00120         
00121         // Using image stats, determine what images are necessary, and perform image updates.
00122         void updateImages(F32 max_time);
00123 
00124         // Decode and create textures for all images currently in list.
00125         void decodeAllImages(F32 max_decode_time); 
00126 
00127         void handleIRCallback(void **data, const S32 number);
00128 
00129         void setUpdateStats(BOOL b)                     { mUpdateStats = b; }
00130 
00131         S32     getMaxResidentTexMem() const    { return mMaxResidentTexMem; }
00132         S32 getNumImages()                                      { return mImageList.size(); }
00133 
00134         void updateMaxResidentTexMem(S32 mem);
00135         
00136         void doPreloadImages();
00137         void doPrefetchImages();
00138 
00139         static S32 getMinVideoRamSetting();
00140         static S32 getMaxVideoRamSetting(bool get_recommended = false);
00141         
00142 private:
00143         void updateImagesDecodePriorities();
00144         F32  updateImagesCreateTextures(F32 max_time);
00145         F32  updateImagesFetchTextures(F32 max_time);
00146         void updateImagesUpdateStats();
00147         
00148 public:
00149         typedef std::set<LLPointer<LLViewerImage> > image_list_t;       
00150         image_list_t mLoadingStreamList;
00151         image_list_t mCreateTextureList;
00152         image_list_t mCallbackList;
00153 
00154         // Note: just raw pointers because they are never referenced, just compared against
00155         std::set<LLViewerImage*> mDirtyTextureList;
00156         
00157         BOOL mForceResetTextureStats;
00158     
00159 private:
00160         typedef std::map< LLUUID, LLPointer<LLViewerImage> > uuid_map_t;
00161         uuid_map_t mUUIDMap;
00162         LLUUID mLastUpdateUUID;
00163         LLUUID mLastFetchUUID;
00164         
00165         typedef std::set<LLPointer<LLViewerImage>, LLViewerImage::Compare> image_priority_list_t;       
00166         image_priority_list_t mImageList;
00167 
00168         // simply holds on to LLViewerImage references to stop them from being purged too soon
00169         std::set<LLPointer<LLViewerImage> > mImagePreloads;
00170 
00171         typedef std::vector<LLPointer<LLViewerImage> > callback_data_t;
00172         typedef std::set< callback_data_t* > callback_data_list_t;
00173         callback_data_list_t mIRCallbackData;
00174 
00175         BOOL mUpdateStats;
00176         S32     mMaxResidentTexMem;
00177         LLFrameTimer mForceDecodeTimer;
00178         
00179 public:
00180         static U32 sTextureBits;
00181         static U32 sTexturePackets;
00182 
00183         static LLStat sNumImagesStat;
00184         static LLStat sNumRawImagesStat;
00185         static LLStat sGLTexMemStat;
00186         static LLStat sGLBoundMemStat;
00187         static LLStat sRawMemStat;
00188         static LLStat sFormattedMemStat;
00189 
00190 private:
00191         static S32 sNumImages;
00192         static void (*sUUIDCallback)(void**, const LLUUID &);
00193 };
00194 
00195 class LLUIImageList : public LLImageProviderInterface, public LLSingleton<LLUIImageList>
00196 {
00197 public:
00198         // LLImageProviderInterface
00199         LLUIImagePtr getUIImageByID(const LLUUID& id);
00200         LLUIImagePtr getUIImage(const LLString& name);
00201         void cleanUp();
00202 
00203         bool initFromFile(const LLString& filename);
00204 
00205         LLUIImagePtr preloadUIImage(const LLString& name, const LLString& filename, BOOL use_mips, const LLRect& scale_rect);
00206         
00207         static void onUIImageLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata );
00208 private:
00209         LLUIImagePtr loadUIImageByName(const LLString& name, const LLString& filename, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null);
00210         LLUIImagePtr loadUIImageByID(const LLUUID& id, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null);
00211 
00212         LLUIImagePtr loadUIImage(LLViewerImage* imagep, const LLString& name, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null);
00213 
00214 
00215         struct LLUIImageLoadData
00216         {
00217                 LLString mImageName;
00218                 LLRect mImageScaleRegion;
00219         };
00220 
00221         typedef std::map< LLString, LLPointer<LLUIImage> > uuid_ui_image_map_t;
00222         uuid_ui_image_map_t mUIImages;
00223 };
00224 
00225 const BOOL GLTEXTURE_TRUE = TRUE;
00226 const BOOL GLTEXTURE_FALSE = FALSE;
00227 const BOOL MIPMAP_TRUE = TRUE;
00228 const BOOL MIPMAP_FALSE = FALSE;
00229 
00230 extern LLViewerImageList gImageList;
00231 
00232 #endif

Generated on Fri May 16 08:34:09 2008 for SecondLife by  doxygen 1.5.5