Commit 96e2b7d0 authored by Fernando Serboncini's avatar Fernando Serboncini Committed by Commit Bot

Adds FontGlobalContext to store static objects of platform/font

Currently only being used on FontCache, to be used on other Font-related
classes.

Bug: 730692
Change-Id: I58f66d6cf59dca83be5133fc273136ce408e5b2e
Reviewed-on: https://chromium-review.googlesource.com/531753
Commit-Queue: Fernando Serboncini <fserb@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#478802}
parent 7b56a573
......@@ -674,6 +674,8 @@ component("platform") {
"fonts/FontFallbackPriority.h",
"fonts/FontFamily.cpp",
"fonts/FontFamily.h",
"fonts/FontGlobalContext.cpp",
"fonts/FontGlobalContext.h",
"fonts/FontMetrics.h",
"fonts/FontOrientation.h",
"fonts/FontPlatformData.cpp",
......
......@@ -40,6 +40,7 @@
#include "platform/fonts/FontCacheKey.h"
#include "platform/fonts/FontDataCache.h"
#include "platform/fonts/FontDescription.h"
#include "platform/fonts/FontGlobalContext.h"
#include "platform/fonts/FontPlatformData.h"
#include "platform/fonts/FontSmoothingMode.h"
#include "platform/fonts/SimpleFontData.h"
......@@ -96,8 +97,7 @@ bool FontCache::use_skia_font_fallback_ = false;
#endif // OS(WIN)
FontCache* FontCache::GetFontCache() {
DEFINE_STATIC_LOCAL(FontCache, global_font_cache, ());
return &global_font_cache;
return &FontGlobalContext::GetFontCache();
}
#if !OS(MACOSX)
......
......@@ -61,6 +61,7 @@ namespace blink {
class FontCacheClient;
class FontFaceCreationParams;
class FontGlobalContext;
class FontPlatformData;
class FontDescription;
class OpenTypeVerticalData;
......@@ -221,8 +222,8 @@ class PLATFORM_EXPORT FontCache {
void DumpShapeResultCache(base::trace_event::ProcessMemoryDump*);
private:
friend class FontGlobalContext;
FontCache();
~FontCache();
void Purge(PurgeSeverity = kPurgeIfNeeded);
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "platform/fonts/FontGlobalContext.h"
#include "platform/fonts/FontCache.h"
#include "platform/wtf/StdLibExtras.h"
#include "platform/wtf/ThreadSpecific.h"
namespace blink {
FontGlobalContext& FontGlobalContext::Get() {
DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<FontGlobalContext>,
font_persistent, ());
return *font_persistent;
}
FontGlobalContext::FontGlobalContext() {}
} // namespace blink
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FontGlobalContext_h
#define FontGlobalContext_h
#include "platform/PlatformExport.h"
#include "platform/fonts/FontCache.h"
#include "platform/wtf/StdLibExtras.h"
namespace blink {
// FontGlobalContext contains non-thread-safe, thread-specific data used for
// font formatting.
class PLATFORM_EXPORT FontGlobalContext {
WTF_MAKE_NONCOPYABLE(FontGlobalContext);
public:
static FontGlobalContext& Get();
static inline FontCache& GetFontCache() { return Get().font_cache; }
private:
friend class WTF::ThreadSpecific<FontGlobalContext>;
FontGlobalContext();
FontCache font_cache;
};
} // namespace blink
#endif
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