summaryrefslogtreecommitdiff
path: root/core/fxge/ge
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-08-17 13:22:16 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-17 13:22:16 -0700
commitd691899dbff8a8aa024596302fcea1f7d7935252 (patch)
tree6f94904e752a859614da0edc5c2bd84184909bbb /core/fxge/ge
parent260f5fbf3553a96fa49b029cc050220039c30e2a (diff)
downloadpdfium-d691899dbff8a8aa024596302fcea1f7d7935252.tar.xz
Split fx_font into multiple files, part 1.
Moved classes CFX_FontCache and CFX_AutoFontCache into a separate file. Review-Url: https://codereview.chromium.org/2246223002
Diffstat (limited to 'core/fxge/ge')
-rw-r--r--core/fxge/ge/cfx_autofontcache.cpp17
-rw-r--r--core/fxge/ge/cfx_fontcache.cpp78
-rw-r--r--core/fxge/ge/cfx_gemodule.cpp1
-rw-r--r--core/fxge/ge/cfx_renderdevice.cpp2
-rw-r--r--core/fxge/ge/fx_ge_text.cpp66
5 files changed, 98 insertions, 66 deletions
diff --git a/core/fxge/ge/cfx_autofontcache.cpp b/core/fxge/ge/cfx_autofontcache.cpp
new file mode 100644
index 0000000000..871f207c17
--- /dev/null
+++ b/core/fxge/ge/cfx_autofontcache.cpp
@@ -0,0 +1,17 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fxge/include/cfx_autofontcache.h"
+
+#include "core/fxge/include/cfx_fontcache.h"
+#include "core/fxge/include/fx_font.h"
+
+CFX_AutoFontCache::CFX_AutoFontCache(CFX_FontCache* pFontCache, CFX_Font* pFont)
+ : m_pFontCache(pFontCache), m_pFont(pFont) {}
+
+CFX_AutoFontCache::~CFX_AutoFontCache() {
+ m_pFontCache->ReleaseCachedFace(m_pFont);
+}
diff --git a/core/fxge/ge/cfx_fontcache.cpp b/core/fxge/ge/cfx_fontcache.cpp
new file mode 100644
index 0000000000..a183711a18
--- /dev/null
+++ b/core/fxge/ge/cfx_fontcache.cpp
@@ -0,0 +1,78 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fxge/include/cfx_fontcache.h"
+
+#include "core/fxge/include/fx_font.h"
+#include "core/fxge/include/fx_freetype.h"
+
+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);
+}
+#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);
+ }
+ }
+}
diff --git a/core/fxge/ge/cfx_gemodule.cpp b/core/fxge/ge/cfx_gemodule.cpp
index 73189b75d5..4eb4094304 100644
--- a/core/fxge/ge/cfx_gemodule.cpp
+++ b/core/fxge/ge/cfx_gemodule.cpp
@@ -8,6 +8,7 @@
#include "core/fxge/ge/cfx_folderfontinfo.h"
#include "core/fxge/ge/fx_text_int.h"
+#include "core/fxge/include/cfx_fontcache.h"
#include "core/fxge/include/cfx_fontmgr.h"
namespace {
diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp
index fcb99f79c2..1890b52021 100644
--- a/core/fxge/ge/cfx_renderdevice.cpp
+++ b/core/fxge/ge/cfx_renderdevice.cpp
@@ -7,6 +7,8 @@
#include "core/fxge/include/cfx_renderdevice.h"
#include "core/fxcrt/include/fx_safe_types.h"
+#include "core/fxge/include/cfx_autofontcache.h"
+#include "core/fxge/include/cfx_fontcache.h"
#include "core/fxge/include/cfx_fxgedevice.h"
#include "core/fxge/include/cfx_graphstatedata.h"
#include "core/fxge/include/cfx_pathdata.h"
diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp
index 9ed751b708..8e16c17784 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_