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 <list>
00041 #include <set>
00042
00043 const U32 LL_IMAGE_REZ_LOSSLESS_CUTOFF = 128;
00044
00045 const BOOL MIPMAP_YES = TRUE;
00046 const BOOL MIPMAP_NO = FALSE;
00047
00048 const BOOL GL_TEXTURE_YES = TRUE;
00049 const BOOL GL_TEXTURE_NO = FALSE;
00050
00051 const BOOL IMMEDIATE_YES = TRUE;
00052 const BOOL IMMEDIATE_NO = FALSE;
00053
00054 class LLViewerImage;
00055 class LLTextureView;
00056
00057 typedef void (*LLImageCallback)(BOOL success,
00058 LLViewerImage *src_vi,
00059 LLImageRaw* src,
00060 LLImageRaw* src_aux,
00061 S32 discard_level,
00062 BOOL final,
00063 void* userdata);
00064
00065 class LLViewerImageList : public LLImageProviderInterface
00066 {
00067 LOG_CLASS(LLViewerImageList);
00068
00069 friend class LLTextureView;
00070
00071 public:
00072 static BOOL createUploadFile(const LLString& filename, const LLString& out_filename, const U8 codec);
00073 static LLPointer<LLImageJ2C> convertToUploadFile(LLPointer<LLImageRaw> raw_image);
00074 static void processImageNotInDatabase( LLMessageSystem *msg, void **user_data );
00075 static S32 calcMaxTextureRAM();
00076 static void receiveImageHeader(LLMessageSystem *msg, void **user_data);
00077 static void receiveImagePacket(LLMessageSystem *msg, void **user_data);
00078
00079 public:
00080 LLViewerImageList();
00081 ~LLViewerImageList();
00082
00083
00084 LLImageGL* getUIImageByID(const LLUUID& id, BOOL clamped = TRUE);
00085
00086 void init();
00087 void shutdown();
00088 void dump();
00089 void destroyGL(BOOL save_state = TRUE);
00090 void restoreGL();
00091
00092 LLViewerImage * getImage(const LLString& filename,
00093 const LLUUID &image_id,
00094 BOOL usemipmap = TRUE,
00095 BOOL level_immediate = FALSE
00096 );
00097 LLViewerImage * getImage(const LLUUID &image_id,
00098 BOOL usemipmap = TRUE,
00099 BOOL level_immediate = FALSE
00100 );
00101
00102 LLViewerImage * getImageFromFile(const LLString& filename,
00103 const LLUUID &image_id,
00104 BOOL usemipmap,
00105 BOOL level_immediate,
00106 LLGLint internal_format,
00107 LLGLenum primary_format
00108 );
00109
00110 LLViewerImage * getImageFromUUID(const LLUUID &image_id,
00111 BOOL usemipmap,
00112 BOOL level_immediate,
00113 LLGLint internal_format,
00114 LLGLenum primary_format,
00115 LLHost request_from_host = LLHost()
00116 );
00117
00118
00119
00120 LLViewerImage* getImageFromHost(const LLUUID& image_id, LLHost host)
00121 { return getImageFromUUID(image_id, TRUE, FALSE, 0, 0, host); }
00122
00123 LLViewerImage *hasImage(const LLUUID &image_id);
00124 void addImage(LLViewerImage *image);
00125 void deleteImage(LLViewerImage *image);
00126
00127 void addImageToList(LLViewerImage *image);
00128 void removeImageFromList(LLViewerImage *image);
00129
00130 void updateMovieImage(const LLUUID& image_id, BOOL active);
00131 void dirtyImage(LLViewerImage *image);
00132
00133
00134 void updateImages(F32 max_time);
00135
00136
00137 void decodeAllImages(F32 max_decode_time);
00138
00139 void handleIRCallback(void **data, const S32 number);
00140
00141 void setUpdateStats(BOOL b) { mUpdateStats = b; }
00142
00143 S32 getMaxResidentTexMem() const { return mMaxResidentTexMem; }
00144 S32 getVideoMemorySetting() const { return mVideoMemorySetting; }
00145 S32 getNumImages() { return mImageList.size(); }
00146
00147 static S32 getMaxVideoRamSetting(S32 max = -1);
00148 void updateMaxResidentTexMem(S32 max = -1, U32 fudge = 0);
00149
00150 void doPreloadImages();
00151 void doPrefetchImages();
00152
00153 private:
00154 LLViewerImage* preloadImage(const LLString& filename, const LLUUID &image_set_id, BOOL use_mips);
00155 void updateImagesDecodePriorities();
00156 F32 updateImagesCreateTextures(F32 max_time);
00157 F32 updateImagesFetchTextures(F32 max_time);
00158 void updateImagesMediaStreams();
00159 void updateImagesUpdateStats();
00160
00161 public:
00162 typedef std::set<LLPointer<LLViewerImage> > image_list_t;
00163 image_list_t mLoadingStreamList;
00164 image_list_t mCreateTextureList;
00165 image_list_t mCallbackList;
00166
00167
00168 std::set<LLViewerImage*> mDirtyTextureList;
00169
00170 BOOL mForceResetTextureStats;
00171
00172 private:
00173 typedef std::map< LLUUID, LLPointer<LLViewerImage> > uuid_map_t;
00174 uuid_map_t mUUIDMap;
00175 LLUUID mLastUpdateUUID;
00176 LLUUID mLastFetchUUID;
00177
00178 typedef std::set<LLPointer<LLViewerImage>, LLViewerImage::Compare> image_priority_list_t;
00179 image_priority_list_t mImageList;
00180
00181 typedef std::vector<LLPointer<LLViewerImage> > callback_data_t;
00182 typedef std::set< callback_data_t* > callback_data_list_t;
00183 callback_data_list_t mIRCallbackData;
00184
00185 BOOL mUpdateStats;
00186 S32 mMaxResidentTexMem;
00187 S32 mVideoMemorySetting;
00188 LLFrameTimer mForceDecodeTimer;
00189
00190 LLUUID mMovieImageUUID;
00191 U8 mMovieImageHasMips;
00192
00193 std::vector<LLPointer<LLViewerImage> > mPreloadedImages;
00194
00195 public:
00196 static U32 sTextureBits;
00197 static U32 sTexturePackets;
00198
00199 static LLStat sNumImagesStat;
00200 static LLStat sNumRawImagesStat;
00201 static LLStat sGLTexMemStat;
00202 static LLStat sGLBoundMemStat;
00203 static LLStat sRawMemStat;
00204 static LLStat sFormattedMemStat;
00205
00206 private:
00207 static S32 sNumImages;
00208 static void (*sUUIDCallback)(void**, const LLUUID &);
00209 };
00210
00211 const BOOL GLTEXTURE_TRUE = TRUE;
00212 const BOOL GLTEXTURE_FALSE = FALSE;
00213 const BOOL MIPMAP_TRUE = TRUE;
00214 const BOOL MIPMAP_FALSE = FALSE;
00215
00216 extern LLViewerImageList gImageList;
00217
00218 #endif