Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: core/fxge/ge/fx_ge_text.cpp

Issue 2246223002: Refactor fx_font part 1 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: CFX_AutoFontCache to own class, fixes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fxge/ge/cfx_renderdevice.cpp ('k') | core/fxge/ifx_renderdevicedriver.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxge/ge/fx_ge_text.cpp
diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp
index 9ed751b70860bbf182ee012da1a68b2a18e6f300..8e16c177846dc07209b6caf9789c04dd399838ea 100644
--- a/core/fxge/ge/fx_ge_text.cpp
+++ b/core/fxge/ge/fx_ge_text.cpp
@@ -106,36 +106,7 @@ FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs,
return rect;
}
-CFX_FontCache::CFX_FontCache() {}
-
-CFX_FontCache::~CFX_FontCache() {
- FreeCache(TRUE);
-}
-
-CFX_FaceCache* CFX_FontCache::GetCachedFace(CFX_Font* pFont) {
- FXFT_Face face = pFont->GetFace();
- const bool bExternal = !face;
- CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap;
- auto it = map.find(face);
- if (it != map.end()) {
- CFX_CountedFaceCache* counted_face_cache = it->second;
- counted_face_cache->m_nCount++;
- return counted_face_cache->m_Obj;
- }
-
- CFX_FaceCache* face_cache = new CFX_FaceCache(bExternal ? nullptr : face);
- CFX_CountedFaceCache* counted_face_cache = new CFX_CountedFaceCache;
- counted_face_cache->m_nCount = 2;
- counted_face_cache->m_Obj = face_cache;
- map[face] = counted_face_cache;
- return face_cache;
-}
-
#ifdef _SKIA_SUPPORT_
-CFX_TypeFace* CFX_FontCache::GetDeviceCache(CFX_Font* pFont) {
- return GetCachedFace(pFont)->GetDeviceCache(pFont);
-}
-
CFX_TypeFace* CFX_FaceCache::GetDeviceCache(CFX_Font* pFont) {
if (!m_pTypeface) {
m_pTypeface =
@@ -147,43 +118,6 @@ CFX_TypeFace* CFX_FaceCache::GetDeviceCache(CFX_Font* pFont) {
}
#endif
-void CFX_FontCache::ReleaseCachedFace(CFX_Font* pFont) {
- FXFT_Face face = pFont->GetFace();
- const bool bExternal = !face;
- CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap;
-
- auto it = map.find(face);
- if (it == map.end())
- return;
-
- CFX_CountedFaceCache* counted_face_cache = it->second;
- if (counted_face_cache->m_nCount > 1) {
- counted_face_cache->m_nCount--;
- }
-}
-
-void CFX_FontCache::FreeCache(FX_BOOL bRelease) {
- for (auto it = m_FTFaceMap.begin(); it != m_FTFaceMap.end();) {
- auto curr_it = it++;
- CFX_CountedFaceCache* cache = curr_it->second;
- if (bRelease || cache->m_nCount < 2) {
- delete cache->m_Obj;
- delete cache;
- m_FTFaceMap.erase(curr_it);
- }
- }
-
- for (auto it = m_ExtFaceMap.begin(); it != m_ExtFaceMap.end();) {
- auto curr_it = it++;
- CFX_CountedFaceCache* cache = curr_it->second;
- if (bRelease || cache->m_nCount < 2) {
- delete cache->m_Obj;
- delete cache;
- m_ExtFaceMap.erase(curr_it);
- }
- }
-}
-
CFX_FaceCache::CFX_FaceCache(FXFT_Face face)
: m_Face(face)
#ifdef _SKIA_SUPPORT_
« no previous file with comments | « core/fxge/ge/cfx_renderdevice.cpp ('k') | core/fxge/ifx_renderdevicedriver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698