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 bool createRequest(const LLString& filename, const LLUUID& id, const LLHost& host, F32 priority,
00059 S32 w, S32 h, S32 c, S32 discard, bool needs_aux);
00060 void deleteRequest(const LLUUID& id, bool cancel);
00061 bool getRequestFinished(const LLUUID& id, S32& discard_level,
00062 LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux);
00063 bool updateRequestPriority(const LLUUID& id, F32 priority);
00064
00065 bool receiveImageHeader(const LLHost& host, const LLUUID& id, U8 codec, U16 packets, U32 totalbytes, U16 data_size, U8* data);
00066 bool receiveImagePacket(const LLHost& host, const LLUUID& id, U16 packet_num, U16 data_size, U8* data);
00067
00068
00069 S32 getFetchState(const LLUUID& id, F32& decode_progress_p, F32& requested_priority_p,
00070 U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p);
00071 void dump();
00072 S32 getNumRequests() { return mRequestMap.size(); }
00073
00074
00075 void lockQueue() { mQueueMutex.lock(); }
00076 void unlockQueue() { mQueueMutex.unlock(); }
00077 LLTextureFetchWorker* getWorker(const LLUUID& id);
00078
00079 protected:
00080 void addToNetworkQueue(LLTextureFetchWorker* worker);
00081 void removeFromNetworkQueue(LLTextureFetchWorker* worker);
00082 void removeRequest(LLTextureFetchWorker* worker, bool cancel);
00083
00084 private:
00085 void sendRequestListToSimulators();
00086
00087 public:
00088 LLUUID mDebugID;
00089 S32 mDebugCount;
00090 BOOL mDebugPause;
00091 S32 mPacketCount;
00092 S32 mBadPacketCount;
00093
00094 private:
00095 LLMutex mQueueMutex;
00096
00097 LLTextureCache* mTextureCache;
00098
00099
00100 typedef std::map<LLUUID,LLTextureFetchWorker*> map_t;
00101 map_t mRequestMap;
00102
00103
00104 typedef std::set<LLUUID> queue_t;
00105 queue_t mNetworkQueue;
00106 typedef std::map<LLHost,std::set<LLUUID> > cancel_queue_t;
00107 cancel_queue_t mCancelQueue;
00108
00109 LLFrameTimer mNetworkTimer;
00110 };
00111
00112 #endif // LL_LLTEXTUREFETCH_H