6 #ifndef TB_IMAGE_MANAGER_H
7 #define TB_IMAGE_MANAGER_H
13 #include "tb_linklist.h"
14 #include "tb_hashtable.h"
15 #include "tb_bitmap_fragment.h"
16 #include "tb_renderer.h"
26 friend class TBImageManager;
29 TBImageRep(TBImageManager *image_manager, TBBitmapFragment *fragment, uint32_t hash_key);
36 TBImageManager *image_manager;
37 TBBitmapFragment *fragment;
49 TBImage() : m_image_rep(nullptr) {}
50 TBImage(TBImageRep *rep);
51 TBImage(
const TBImage &image);
64 TBBitmapFragment *GetBitmap()
const;
66 const TBImage& operator = (
const TBImage &image) { SetImageRep(image.m_image_rep);
return *
this; }
67 bool operator == (
const TBImage &image)
const {
return m_image_rep == image.m_image_rep; }
68 bool operator != (
const TBImage &image)
const {
return m_image_rep != image.m_image_rep; }
70 void SetImageRep(TBImageRep *image_rep);
71 TBImageRep *m_image_rep;
82 class TBImageManager :
private TBRendererListener
90 TBImage GetImage(
const char *filename);
92 #ifdef TB_RUNTIME_DEBUG_INFO
94 void Debug() { m_frag_manager.Debug(); }
98 virtual void OnContextLost();
99 virtual void OnContextRestored();
101 TBBitmapFragmentManager m_frag_manager;
102 TBHashTableOf<TBImageRep> m_image_rep_hash;
104 friend class TBImageRep;
105 void RemoveImageRep(TBImageRep *image_rep);
109 extern TBImageManager *g_image_manager;
114 #endif // TB_IMAGE_MANAGER_H