1 /************************************************************************/
4 /************************************************************************/
6 #include "cache_manager.h"
8 std::size_t hash_value(const CWord
& key
)
10 return( CStringElementTraits
<CString
>::Hash(key
.m_str
) );
13 std::size_t hash_value(const CWordCacheKey
& key
)
15 return( CStringElementTraits
<CString
>::Hash(key
.m_str
) );
18 std::size_t hash_value(const OverlayKey
& key
)
20 return( CStringElementTraits
<CString
>::Hash(key
.m_str
) ^ key
.m_p
.x
^ key
.m_p
.y
);
23 std::size_t hash_value( const PathDataCacheKey
& key
)
25 return( CStringElementTraits
<CString
>::Hash(key
.m_str
) );
28 std::size_t hash_value( const ScanLineDataCacheKey
& key
)
30 return hash_value(static_cast<PathDataCacheKey
>(key
)) ^ key
.m_org
.x
^ key
.m_org
.y
;
33 std::size_t hash_value( const OverlayNoBlurKey
& key
)
35 return hash_value(static_cast<ScanLineDataCacheKey
>(key
)) ^ key
.m_p
.x
^ key
.m_p
.y
;
38 CWordCacheKey::CWordCacheKey( const CWord
& word
)
41 m_style
= word
.m_style
;
42 m_ktype
= word
.m_ktype
;
43 m_kstart
= word
.m_kstart
;
47 CWordCacheKey::CWordCacheKey( const CWordCacheKey
& key
)
50 m_style
= key
.m_style
;
51 m_ktype
= key
.m_ktype
;
52 m_kstart
= key
.m_kstart
;
56 CWordCacheKey::CWordCacheKey( const FwSTSStyle
& style
, const CStringW
& str
, int ktype
, int kstart
, int kend
)
57 :m_style(style
),m_str(str
),m_ktype(ktype
),m_kstart(kstart
),m_kend(m_kend
)
62 bool CWordCacheKey::operator==( const CWordCacheKey
& key
) const
64 return (m_str
== key
.m_str
&&
65 m_style
== key
.m_style
&&
66 m_ktype
== key
.m_ktype
&&
67 m_kstart
== key
.m_kstart
&&
68 m_kend
== key
.m_kend
);
71 bool CWordCacheKey::operator==(const CWord
& key
)const
73 return (m_str
== key
.m_str
&&
74 m_style
== key
.m_style
&&
75 m_ktype
== key
.m_ktype
&&
76 m_kstart
== key
.m_kstart
&&
77 m_kend
== key
.m_kend
);
80 //////////////////////////////////////////////////////////////////////////////////////////////
84 bool PathDataCacheKey::CompareSTSStyle( const STSStyle
& lhs
, const STSStyle
& rhs
)
86 return lhs
.charSet
==rhs
.charSet
&&
87 lhs
.fontName
==rhs
.fontName
&&
88 lhs
.fontSize
==rhs
.fontSize
&&
89 lhs
.fontWeight
==rhs
.fontWeight
&&
90 lhs
.fItalic
==rhs
.fItalic
&&
91 lhs
.fUnderline
==rhs
.fUnderline
&&
92 lhs
.fStrikeOut
==rhs
.fStrikeOut
;
95 //////////////////////////////////////////////////////////////////////////////////////////////
97 // ScanLineDataCacheKey
99 bool ScanLineDataCacheKey::operator==( const ScanLineDataCacheKey
& key
) const
101 return (static_cast<PathDataCacheKey
>(*this)==static_cast<PathDataCacheKey
>(key
))
102 && this->m_style
.get().borderStyle
== key
.m_style
.get().borderStyle
103 && fabs(this->m_style
.get().outlineWidthX
- key
.m_style
.get().outlineWidthX
) < 0.000001
104 && fabs(this->m_style
.get().outlineWidthY
- key
.m_style
.get().outlineWidthY
) < 0.000001
105 && fabs(this->m_style
.get().fontScaleX
- key
.m_style
.get().fontScaleX
) < 0.000001
106 && fabs(this->m_style
.get().fontScaleY
- key
.m_style
.get().fontScaleY
) < 0.000001
107 && fabs(this->m_style
.get().fontAngleX
- key
.m_style
.get().fontAngleX
) < 0.000001
108 && fabs(this->m_style
.get().fontAngleY
- key
.m_style
.get().fontAngleY
) < 0.000001
109 && fabs(this->m_style
.get().fontAngleZ
- key
.m_style
.get().fontAngleZ
) < 0.000001
110 && fabs(this->m_style
.get().fontShiftX
- key
.m_style
.get().fontShiftX
) < 0.000001
111 && fabs(this->m_style
.get().fontShiftY
- key
.m_style
.get().fontShiftY
) < 0.000001
112 && (m_org
.x
==key
.m_org
.x
) && (m_org
.y
==key
.m_org
.y
);
115 //////////////////////////////////////////////////////////////////////////////////////////////
119 bool OverlayNoBlurKey::operator==( const OverlayNoBlurKey
& key
) const
121 return (static_cast<ScanLineDataCacheKey
>(*this)==static_cast<ScanLineDataCacheKey
>(key
))
122 && (m_p
.x
==key
.m_p
.x
) && (m_p
.y
==key
.m_p
.y
);
125 //////////////////////////////////////////////////////////////////////////////////////////////
129 CWordMruCache
* CacheManager::s_word_mru_cache
= NULL
;
130 PathDataMruCache
* CacheManager::s_path_data_mru_cache
= NULL
;
131 ScanLineDataMruCache
* CacheManager::s_scan_line_data_mru_cache
= NULL
;
132 OverlayNoBlurMruCache
* CacheManager::s_overlay_no_blur_mru_cache
= NULL
;
133 OverlayMruCache
* CacheManager::s_overlay_mru_cache
= NULL
;
135 OverlayMruCache
* CacheManager::GetOverlayMruCache()
137 if(s_overlay_mru_cache
==NULL
)
139 s_overlay_mru_cache
= new OverlayMruCache(OVERLAY_CACHE_ITEM_NUM
);
141 return s_overlay_mru_cache
;
144 PathDataMruCache
* CacheManager::GetPathDataMruCache()
146 if (s_path_data_mru_cache
==NULL
)
148 s_path_data_mru_cache
= new PathDataMruCache(PATH_CACHE_ITEM_NUM
);
150 return s_path_data_mru_cache
;
153 CWordMruCache
* CacheManager::GetCWordMruCache()
155 if(s_word_mru_cache
==NULL
)
157 s_word_mru_cache
= new CWordMruCache(WORD_CACHE_ITEM_NUM
);
159 return s_word_mru_cache
;
162 OverlayNoBlurMruCache
* CacheManager::GetOverlayNoBlurMruCache()
164 if(s_overlay_no_blur_mru_cache
==NULL
)
166 s_overlay_no_blur_mru_cache
= new OverlayNoBlurMruCache(OVERLAY_NO_BLUR_CACHE_ITEM_NUM
);
168 return s_overlay_no_blur_mru_cache
;
171 ScanLineDataMruCache
* CacheManager::GetScanLineDataMruCache()
173 if(s_scan_line_data_mru_cache
==NULL
)
175 s_scan_line_data_mru_cache
= new ScanLineDataMruCache(SCAN_LINE_DATA_CACHE_ITEM_NUM
);
177 return s_scan_line_data_mru_cache
;