00001
00032 #ifndef LL_LLTEXTUREFETCH_H
00033 #define LL_LLTEXTUREFETCH_H
00034
00035 #include "lldir.h"
00036 #include "llimage.h"
00037 #include "lluuid.h"
00038 #include "llworkerthread.h"
00039
00040 class LLViewerImage;
00041 class LLTextureFetchWorker;
00042 class LLTextureCache;
00043 class LLHost;
00044
00045
00046 class LLTextureFetch : public LLWorkerThread
00047 {
00048 friend class LLTextureFetchWorker;
00049
00050 public:
00051 LLTextureFetch(LLTextureCache* cache, bool threaded);
00052 ~LLTextureFetch();
00053
00054 S32 update(U32 max_time_ms);
00055
00056 bool createRequest(const LLUUID& id, const LLHost& host, F32 priority,
00057 S32 w, S32 h, S32 c, S32 discard, bool needs_aux);
00058 void deleteRequest(const LLUUID& id, bool cancel);
00059 bool getRequestFinished(const LLUUID& id, S32& discard_level,
00060 LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux);
00061 bool updateRequestPriority(const LLUUID& id, F32 priority);
00062
00063 bool receiveImageHeader(const LLHost& host, const LLUUID& id, U8 codec, U16 packets, U32 totalbytes, U16 data_size, U8* data);
00064 bool receiveImagePacket(const LLHost& host, const LLUUID& id, U16 packet_num, U16 data_size, U8* data);
00065
00066
00067 S32 getFetchState(const LLUUID& id, F32& decode_progress_p, F32& requested_priority_p,
00068 U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p);
00069 void dump();
00070 S32 getNumRequests() { return mRequestMap.size(); }
00071
00072
00073 void lockQueue() { mQueueMutex.lock(); }
00074 void unlockQueue() { mQueueMutex.unlock(); }
00075 LLTextureFetchWorker* getWorker(const LLUUID& id);
00076
00077 protected:
00078 void addToNetworkQueue(LLTextureFetchWorker* worker);
00079 void removeFromNetworkQueue(LLTextureFetchWorker* worker);
00080 void removeRequest(LLTextureFetchWorker* worker, bool cancel);
00081
00082 private:
00083 void sendRequestListToSimulators();
00084
00085 public:
00086 LLUUID mDebugID;
00087 S32 mDebugCount;
00088 BOOL mDebugPause;
00089 S32 mPacketCount;
00090 S32 mBadPacketCount;
00091
00092 private:
00093 LLMutex mQueueMutex;
00094
00095 LLTextureCache* mTextureCache;
00096
00097
00098 typedef std::map<LLUUID,LLTextureFetchWorker*> map_t;
00099 map_t mRequestMap;
00100
00101
00102 typedef std::set<LLUUID> queue_t;
00103 queue_t mNetworkQueue;
00104 typedef std::map<LLHost,std::set<LLUUID> > cancel_queue_t;
00105 cancel_queue_t mCancelQueue;
00106
00107 LLFrameTimer mNetworkTimer;
00108 };
00109
00110 #endif // LL_LLTEXTUREFETCH_H