Commit 0d41b79c authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

Move unique font instantiation out to FontCache

As this helper function will be used by font_cache_skia_win.cc as well,
move it out to FontCache and share the implementation between backends.

Bug: 889864
Change-Id: Ic0d6c3eec1cd7689af7f2e394b9f83c8487dd22a
Reviewed-on: https://chromium-review.googlesource.com/c/1396020
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619981}
parent a6ff5bd4
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "third_party/blink/renderer/platform/fonts/font_global_context.h" #include "third_party/blink/renderer/platform/fonts/font_global_context.h"
#include "third_party/blink/renderer/platform/fonts/font_platform_data.h" #include "third_party/blink/renderer/platform/fonts/font_platform_data.h"
#include "third_party/blink/renderer/platform/fonts/font_smoothing_mode.h" #include "third_party/blink/renderer/platform/fonts/font_smoothing_mode.h"
#include "third_party/blink/renderer/platform/fonts/font_unique_name_lookup.h"
#include "third_party/blink/renderer/platform/fonts/shaping/shape_cache.h" #include "third_party/blink/renderer/platform/fonts/shaping/shape_cache.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h" #include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
#include "third_party/blink/renderer/platform/fonts/text_rendering_mode.h" #include "third_party/blink/renderer/platform/fonts/text_rendering_mode.h"
...@@ -440,4 +441,18 @@ void FontCache::DumpShapeResultCache( ...@@ -440,4 +441,18 @@ void FontCache::DumpShapeResultCache(
WTF::Partitions::kAllocatedObjectPoolName); WTF::Partitions::kAllocatedObjectPoolName);
} }
sk_sp<SkTypeface> FontCache::CreateTypefaceFromUniqueName(
const FontFaceCreationParams& creation_params,
CString& name) {
FontUniqueNameLookup* unique_name_lookup =
FontGlobalContext::Get()->GetFontUniqueNameLookup();
DCHECK(unique_name_lookup);
sk_sp<SkTypeface> uniquely_identified_font =
unique_name_lookup->MatchUniqueName(creation_params.Family());
if (uniquely_identified_font) {
return uniquely_identified_font;
}
return nullptr;
}
} // namespace blink } // namespace blink
...@@ -253,6 +253,9 @@ class PLATFORM_EXPORT FontCache { ...@@ -253,6 +253,9 @@ class PLATFORM_EXPORT FontCache {
UChar32, UChar32,
const SimpleFontData* font_data_to_substitute, const SimpleFontData* font_data_to_substitute,
FontFallbackPriority = FontFallbackPriority::kText); FontFallbackPriority = FontFallbackPriority::kText);
sk_sp<SkTypeface> CreateTypefaceFromUniqueName(
const FontFaceCreationParams& creation_params,
CString& name);
friend class FontGlobalContext; friend class FontGlobalContext;
FontCache(); FontCache();
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#include "third_party/blink/renderer/platform/fonts/font_description.h" #include "third_party/blink/renderer/platform/fonts/font_description.h"
#include "third_party/blink/renderer/platform/fonts/font_face_creation_params.h" #include "third_party/blink/renderer/platform/fonts/font_face_creation_params.h"
#include "third_party/blink/renderer/platform/fonts/font_global_context.h" #include "third_party/blink/renderer/platform/fonts/font_global_context.h"
#include "third_party/blink/renderer/platform/fonts/font_unique_name_lookup.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h" #include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
#include "third_party/blink/renderer/platform/fonts/skia/sktypeface_factory.h" #include "third_party/blink/renderer/platform/fonts/skia/sktypeface_factory.h"
#include "third_party/blink/renderer/platform/language.h" #include "third_party/blink/renderer/platform/language.h"
...@@ -57,25 +56,6 @@ ...@@ -57,25 +56,6 @@
namespace blink { namespace blink {
#if defined(OS_ANDROID) || defined(OS_LINUX)
namespace {
static sk_sp<SkTypeface> CreateTypefaceFromUniqueName(
const FontFaceCreationParams& creation_params,
CString& name) {
FontUniqueNameLookup* unique_name_lookup =
FontGlobalContext::Get()->GetFontUniqueNameLookup();
DCHECK(unique_name_lookup);
sk_sp<SkTypeface> uniquely_identified_font =
unique_name_lookup->MatchUniqueName(creation_params.Family());
if (uniquely_identified_font) {
return uniquely_identified_font;
}
return nullptr;
}
} // namespace
#endif
AtomicString ToAtomicString(const SkString& str) { AtomicString ToAtomicString(const SkString& str) {
return AtomicString::FromUTF8(str.c_str(), str.size()); return AtomicString::FromUTF8(str.c_str(), str.size());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment