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

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

Issue 1837113004: Support the device font cache (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: address comments Created 4 years, 8 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/DEPS ('k') | core/fxge/skia/fx_skia_device.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 1d18ecd3779b21bfe99a72681011334a9601017b..0815bfaa67655a3b1aaaeddf3593601b2abf1be6 100644
--- a/core/fxge/ge/fx_ge_text.cpp
+++ b/core/fxge/ge/fx_ge_text.cpp
@@ -9,6 +9,11 @@
#include "core/include/fxge/fx_freetype.h"
#include "core/include/fxge/fx_ge.h"
+#ifdef _SKIA_SUPPORT_
+#include "third_party/skia/include/core/SkStream.h"
+#include "third_party/skia/include/core/SkTypeface.h"
+#endif
+
#undef FX_GAMMA
#undef FX_GAMMA_INVERSE
#define FX_GAMMA(value) (value)
@@ -1198,6 +1203,20 @@ CFX_FaceCache* CFX_FontCache::GetCachedFace(CFX_Font* pFont) {
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 = SkTypeface::CreateFromStream(
+ new SkMemoryStream(pFont->GetFontData(), pFont->GetSize()));
+ }
+ return m_pTypeface;
+}
+#endif
+
void CFX_FontCache::ReleaseCachedFace(CFX_Font* pFont) {
FXFT_Face internal_face = pFont->GetFace();
const bool bExternal = !internal_face;
@@ -1237,7 +1256,14 @@ void CFX_FontCache::FreeCache(FX_BOOL bRelease) {
}
}
-CFX_FaceCache::CFX_FaceCache(FXFT_Face face) : m_Face(face) {}
+CFX_FaceCache::CFX_FaceCache(FXFT_Face face)
+ : m_Face(face)
+#ifdef _SKIA_SUPPORT_
+ ,
+ m_pTypeface(nullptr)
+#endif
+{
+}
CFX_FaceCache::~CFX_FaceCache() {
for (const auto& pair : m_SizeMap) {
@@ -1248,7 +1274,11 @@ CFX_FaceCache::~CFX_FaceCache() {
delete pair.second;
}
m_PathMap.clear();
+#ifdef _SKIA_SUPPORT_
+ SkSafeUnref(m_pTypeface);
+#endif
}
+
#if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
void CFX_FaceCache::InitPlatform() {}
#endif
« no previous file with comments | « core/fxge/ge/DEPS ('k') | core/fxge/skia/fx_skia_device.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698