1 /************************************************************************/
4 /************************************************************************/
5 #ifndef __CACHE_MANAGER_H_310C134F_844C_4590_A4D2_AD30165AF10A__
6 #define __CACHE_MANAGER_H_310C134F_844C_4590_A4D2_AD30165AF10A__
10 class TextInfoCacheKey
15 bool operator==(const TextInfoCacheKey
& key
)const;
21 CWordCacheKey(const CWord
& word
);
22 CWordCacheKey(const CWordCacheKey
& key
);
23 CWordCacheKey(const FwSTSStyle
& style
, const CStringW
& str
, int ktype
, int kstart
, int kend
);
24 bool operator==(const CWordCacheKey
& key
)const;
25 bool operator==(const CWord
& key
)const;
29 int m_ktype
, m_kstart
, m_kend
;
32 class PathDataCacheKey
35 PathDataCacheKey(const CWord
& word
):m_str(word
.m_str
),m_style(word
.m_style
){}
36 PathDataCacheKey(const PathDataCacheKey
& key
):m_str(key
.m_str
),m_style(key
.m_style
){}
37 PathDataCacheKey(const FwSTSStyle
& style
, const CStringW
& str
):m_str(str
),m_style(style
){}
38 bool operator==(const PathDataCacheKey
& key
)const
40 return m_str
==key
.m_str
&& ( m_style
==key
.m_style
|| CompareSTSStyle(m_style
, key
.m_style
) );
42 bool operator==(const CWord
& key
)const
44 return m_str
==key
.m_str
&& ( m_style
==key
.m_style
|| CompareSTSStyle(m_style
.get(), key
.m_style
.get()) );
47 static bool CompareSTSStyle(const STSStyle
& lhs
, const STSStyle
& rhs
);
52 friend std::size_t hash_value(const PathDataCacheKey
& key
);
55 class ScanLineDataCacheKey
: public PathDataCacheKey
58 ScanLineDataCacheKey(const CWord
& word
, const POINT
& org
):PathDataCacheKey(word
),m_org(org
) { }
59 ScanLineDataCacheKey(const ScanLineDataCacheKey
& key
):PathDataCacheKey(key
),m_org(key
.m_org
) { }
60 ScanLineDataCacheKey(const FwSTSStyle
& style
, const CStringW
& str
, const POINT
& org
)
61 :PathDataCacheKey(style
, str
),m_org(org
) { }
62 bool operator==(const ScanLineDataCacheKey
& key
)const;
67 class OverlayNoBlurKey
: public ScanLineDataCacheKey
70 OverlayNoBlurKey(const CWord
& word
, const POINT
& p
, const POINT
& org
):ScanLineDataCacheKey(word
,org
),m_p(p
) { }
71 OverlayNoBlurKey(const OverlayNoBlurKey
& key
):ScanLineDataCacheKey(key
),m_p(key
.m_p
) { }
72 OverlayNoBlurKey(const FwSTSStyle
& style
, const CStringW
& str
, const POINT
& p
, const POINT
& org
)
73 :ScanLineDataCacheKey(style
, str
, org
),m_p(p
) { }
74 bool operator==(const OverlayNoBlurKey
& key
)const;
79 class OverlayKey
: public OverlayNoBlurKey
82 OverlayKey(const CWord
& word
, const POINT
& p
, const POINT
& org
):OverlayNoBlurKey(word
, p
, org
) { }
83 OverlayKey(const OverlayKey
& key
):OverlayNoBlurKey(key
){ }
85 bool operator==(const OverlayKey
& key
)const;
87 friend std::size_t hash_value(const OverlayKey
& key
);
90 std::size_t hash_value(const TextInfoCacheKey
& key
);
91 std::size_t hash_value(const CWord
& key
);
92 std::size_t hash_value(const PathDataCacheKey
& key
);
93 std::size_t hash_value(const ScanLineDataCacheKey
& key
);
94 std::size_t hash_value(const OverlayNoBlurKey
& key
);
95 std::size_t hash_value(const OverlayKey
& key
);
96 std::size_t hash_value(const CWordCacheKey
& key
);
98 //shouldn't use std::pair, or else VC complaining error C2440
99 //typedef std::pair<OverlayKey, SharedPtrOverlay> OverlayMruItem;
100 struct AssTagListMruItem
103 CRenderedTextSubtitle::SharedPtrConstAssTagList tag_list
;
106 struct OverlayMruItem
108 OverlayMruItem(const OverlayKey
& overlay_key_
, const SharedPtrOverlay
& overlay_
):overlay_key(overlay_key_
),overlay(overlay_
){}
110 OverlayKey overlay_key
;
111 SharedPtrOverlay overlay
;
114 struct TextInfoMruItem
116 TextInfoMruItem(const TextInfoCacheKey
& text_info_key_
, const CText::SharedPtrTextInfo
& text_info_
)
117 :text_info_key(text_info_key_
), text_info(text_info_
){}
119 TextInfoCacheKey text_info_key
;
120 CText::SharedPtrTextInfo text_info
;
125 CWordMruItem(const CWordCacheKey
& word_key_
, const SharedPtrCWord
& word_
):word_key(word_key_
),word(word_
){}
127 CWordCacheKey word_key
;
131 struct PathDataMruItem
133 PathDataMruItem(const PathDataCacheKey
& path_data_key_
, const SharedPtrConstPathData
& path_data_
):
134 path_data_key(path_data_key_
),path_data(path_data_
){}
136 PathDataCacheKey path_data_key
;
137 SharedPtrConstPathData path_data
;
140 struct ScanLineDataMruItem
142 ScanLineDataMruItem(const ScanLineDataCacheKey
& scan_line_data_key_
, const SharedPtrConstScanLineData
& scan_line_data_
):
143 scan_line_data_key(scan_line_data_key_
),scan_line_data(scan_line_data_
){}
145 ScanLineDataCacheKey scan_line_data_key
;
146 SharedPtrConstScanLineData scan_line_data
;
149 struct OverlayNoBlurMruItem
151 OverlayNoBlurMruItem(const OverlayNoBlurKey
& key_
, const SharedPtrOverlay
& overlay_
)
152 :key(key_
),overlay(overlay_
){}
154 OverlayNoBlurKey key
;
155 SharedPtrOverlay overlay
;
158 typedef enhanced_mru_list
<
160 boost::multi_index::member
<TextInfoMruItem
,
162 &TextInfoMruItem::text_info_key
166 typedef enhanced_mru_list
<
168 boost::multi_index::member
<AssTagListMruItem
,
170 &AssTagListMruItem::script
172 > AssTagListMruCache
;
174 typedef enhanced_mru_list
<
176 boost::multi_index::member
<OverlayMruItem
,
178 &OverlayMruItem::overlay_key
182 typedef enhanced_mru_list
<
184 boost::multi_index::member
<CWordMruItem
,
186 &CWordMruItem::word_key
190 typedef enhanced_mru_list
<
192 boost::multi_index::member
<PathDataMruItem
,
194 &PathDataMruItem::path_data_key
198 typedef enhanced_mru_list
<
200 boost::multi_index::member
<ScanLineDataMruItem
,
201 ScanLineDataCacheKey
,
202 &ScanLineDataMruItem::scan_line_data_key
204 > ScanLineDataMruCache
;
206 typedef enhanced_mru_list
<
207 OverlayNoBlurMruItem
,
208 boost::multi_index::member
<OverlayNoBlurMruItem
,
210 &OverlayNoBlurMruItem::key
212 > OverlayNoBlurMruCache
;
217 static const int TEXT_INFO_CACHE_ITEM_NUM
= 2048;
218 static const int ASS_TAG_LIST_CACHE_ITEM_NUM
= 256;
219 static const int SUBPIXEL_VARIANCE_CACHE_ITEM_NUM
= 256;
220 static const int OVERLAY_CACHE_ITEM_NUM
= 256;
222 static const int OVERLAY_NO_BLUR_CACHE_ITEM_NUM
= 256;
223 static const int SCAN_LINE_DATA_CACHE_ITEM_NUM
= 256;
224 static const int PATH_CACHE_ITEM_NUM
= 256;
225 static const int WORD_CACHE_ITEM_NUM
= 512;
227 static TextInfoMruCache
* GetTextInfoCache();
228 static AssTagListMruCache
* GetAssTagListMruCache();
229 static OverlayMruCache
* GetSubpixelVarianceCache();
230 static OverlayMruCache
* GetOverlayMruCache();
231 static OverlayNoBlurMruCache
* GetOverlayNoBlurMruCache();
232 static ScanLineDataMruCache
* GetScanLineDataMruCache();
233 static PathDataMruCache
* GetPathDataMruCache();
234 static CWordMruCache
* GetCWordMruCache();
236 static TextInfoMruCache
* s_text_info_cache
;
237 static AssTagListMruCache
* s_ass_tag_list_cache
;
238 static OverlayMruCache
* s_subpixel_variance_cache
;
239 static OverlayMruCache
* s_overlay_mru_cache
;
240 static OverlayNoBlurMruCache
* s_overlay_no_blur_mru_cache
;
241 static PathDataMruCache
* s_path_data_mru_cache
;
242 static ScanLineDataMruCache
* s_scan_line_data_mru_cache
;
243 static CWordMruCache
* s_word_mru_cache
;
246 #endif // end of __CACHE_MANAGER_H_310C134F_844C_4590_A4D2_AD30165AF10A__