Commit 2b00cd1d authored by Fernando Serboncini's avatar Fernando Serboncini Committed by Commit Bot

Adds FontCache to OffscreenFontSelector

Also makes FontFaceInvalidated a virtual on FontSelector.

Bug: 722511
Change-Id: I6144965b1d559bb418d2b823b4d6486e5769d8bc
Reviewed-on: https://chromium-review.googlesource.com/702684
Commit-Queue: Fernando Serboncini <fserb@chromium.org>
Reviewed-by: default avatarJustin Novosad <junov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506898}
parent 258cfcba
...@@ -62,7 +62,7 @@ class CORE_EXPORT CSSFontSelector : public FontSelector { ...@@ -62,7 +62,7 @@ class CORE_EXPORT CSSFontSelector : public FontSelector {
bool IsPlatformFamilyMatchAvailable(const FontDescription&, bool IsPlatformFamilyMatchAvailable(const FontDescription&,
const AtomicString& family); const AtomicString& family);
void FontFaceInvalidated(); void FontFaceInvalidated() override;
// FontCacheClient implementation // FontCacheClient implementation
void FontCacheInvalidated() override; void FontCacheInvalidated() override;
......
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
namespace blink { namespace blink {
OffscreenFontSelector::OffscreenFontSelector() {} OffscreenFontSelector::OffscreenFontSelector() {
FontCache::GetFontCache()->AddClient(this);
}
OffscreenFontSelector::~OffscreenFontSelector() {} OffscreenFontSelector::~OffscreenFontSelector() {}
...@@ -37,6 +39,11 @@ void OffscreenFontSelector::UnregisterForInvalidationCallbacks( ...@@ -37,6 +39,11 @@ void OffscreenFontSelector::UnregisterForInvalidationCallbacks(
RefPtr<FontData> OffscreenFontSelector::GetFontData( RefPtr<FontData> OffscreenFontSelector::GetFontData(
const FontDescription& font_description, const FontDescription& font_description,
const AtomicString& family_name) { const AtomicString& family_name) {
if (CSSSegmentedFontFace* face =
font_face_cache_.Get(font_description, family_name)) {
return face->GetFontData(font_description);
}
AtomicString settings_family_name = FamilyNameFromSettings( AtomicString settings_family_name = FamilyNameFromSettings(
generic_font_family_settings_, font_description, family_name); generic_font_family_settings_, font_description, family_name);
if (settings_family_name.IsEmpty()) if (settings_family_name.IsEmpty())
...@@ -49,18 +56,44 @@ RefPtr<FontData> OffscreenFontSelector::GetFontData( ...@@ -49,18 +56,44 @@ RefPtr<FontData> OffscreenFontSelector::GetFontData(
void OffscreenFontSelector::WillUseFontData( void OffscreenFontSelector::WillUseFontData(
const FontDescription& font_description, const FontDescription& font_description,
const AtomicString& family, const AtomicString& family,
const String& text) {} const String& text) {
CSSSegmentedFontFace* face = font_face_cache_.Get(font_description, family);
if (face)
face->WillUseFontData(font_description, text);
}
void OffscreenFontSelector::WillUseRange( void OffscreenFontSelector::WillUseRange(
const FontDescription& font_description, const FontDescription& font_description,
const AtomicString& family, const AtomicString& family,
const FontDataForRangeSet& range_set) {} const FontDataForRangeSet& range_set) {
CSSSegmentedFontFace* face = font_face_cache_.Get(font_description, family);
if (face)
face->WillUseRange(font_description, range_set);
}
bool OffscreenFontSelector::IsPlatformFamilyMatchAvailable(
const FontDescription& font_description,
const AtomicString& passed_family) {
AtomicString family = FamilyNameFromSettings(generic_font_family_settings_,
font_description, passed_family);
if (family.IsEmpty())
family = passed_family;
return FontCache::GetFontCache()->IsPlatformFamilyMatchAvailable(
font_description, family);
}
void OffscreenFontSelector::ReportNotDefGlyph() const {} void OffscreenFontSelector::ReportNotDefGlyph() const {}
void OffscreenFontSelector::FontCacheInvalidated() {} void OffscreenFontSelector::FontCacheInvalidated() {
font_face_cache_.IncrementVersion();
}
void OffscreenFontSelector::FontFaceInvalidated() {
FontCacheInvalidated();
}
DEFINE_TRACE(OffscreenFontSelector) { DEFINE_TRACE(OffscreenFontSelector) {
visitor->Trace(font_face_cache_);
FontSelector::Trace(visitor); FontSelector::Trace(visitor);
} }
......
...@@ -44,9 +44,15 @@ class CORE_EXPORT OffscreenFontSelector : public FontSelector { ...@@ -44,9 +44,15 @@ class CORE_EXPORT OffscreenFontSelector : public FontSelector {
} }
void FontCacheInvalidated() override; void FontCacheInvalidated() override;
void FontFaceInvalidated() override;
void UpdateGenericFontFamilySettings(const GenericFontFamilySettings&); void UpdateGenericFontFamilySettings(const GenericFontFamilySettings&);
FontFaceCache* GetFontFaceCache() { return &font_face_cache_; }
bool IsPlatformFamilyMatchAvailable(const FontDescription&,
const AtomicString& passed_family);
DECLARE_VIRTUAL_TRACE(); DECLARE_VIRTUAL_TRACE();
protected: protected:
...@@ -56,6 +62,8 @@ class CORE_EXPORT OffscreenFontSelector : public FontSelector { ...@@ -56,6 +62,8 @@ class CORE_EXPORT OffscreenFontSelector : public FontSelector {
private: private:
GenericFontFamilySettings generic_font_family_settings_; GenericFontFamilySettings generic_font_family_settings_;
FontFaceCache font_face_cache_;
}; };
} // namespace blink } // namespace blink
......
...@@ -380,6 +380,7 @@ void FontCache::AddClient(FontCacheClient* client) { ...@@ -380,6 +380,7 @@ void FontCache::AddClient(FontCacheClient* client) {
CHECK(client); CHECK(client);
if (!font_cache_clients_) { if (!font_cache_clients_) {
font_cache_clients_ = new HeapHashSet<WeakMember<FontCacheClient>>(); font_cache_clients_ = new HeapHashSet<WeakMember<FontCacheClient>>();
font_cache_clients_.RegisterAsStaticReference();
} }
DCHECK(!font_cache_clients_->Contains(client)); DCHECK(!font_cache_clients_->Contains(client));
font_cache_clients_->insert(client); font_cache_clients_->insert(client);
......
...@@ -62,6 +62,8 @@ class PLATFORM_EXPORT FontSelector : public FontCacheClient { ...@@ -62,6 +62,8 @@ class PLATFORM_EXPORT FontSelector : public FontCacheClient {
virtual void RegisterForInvalidationCallbacks(FontSelectorClient*) = 0; virtual void RegisterForInvalidationCallbacks(FontSelectorClient*) = 0;
virtual void UnregisterForInvalidationCallbacks(FontSelectorClient*) = 0; virtual void UnregisterForInvalidationCallbacks(FontSelectorClient*) = 0;
virtual void FontFaceInvalidated(){};
protected: protected:
static AtomicString FamilyNameFromSettings( static AtomicString FamilyNameFromSettings(
const GenericFontFamilySettings&, const GenericFontFamilySettings&,
......
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