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

Unified Diff: third_party/WebKit/Source/platform/fonts/FontPlatformData.cpp

Issue 1931393002: Introduce typeface cache in blink::FontCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip: others 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
Index: third_party/WebKit/Source/platform/fonts/FontPlatformData.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/FontPlatformData.cpp b/third_party/WebKit/Source/platform/fonts/FontPlatformData.cpp
index 209c675cf33455b896ed1e8ba11d0e09eb68a670..0c30ba212460dc9edf9162aecb08e04e129459f5 100644
--- a/third_party/WebKit/Source/platform/fonts/FontPlatformData.cpp
+++ b/third_party/WebKit/Source/platform/fonts/FontPlatformData.cpp
@@ -44,7 +44,6 @@ FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
#if !OS(WIN)
, m_family(CString())
#endif
- , m_textSize(0)
, m_syntheticBold(false)
, m_syntheticItalic(false)
, m_orientation(FontOrientation::Horizontal)
@@ -65,7 +64,6 @@ FontPlatformData::FontPlatformData()
#if !OS(WIN)
, m_family(CString())
#endif
- , m_textSize(0)
, m_syntheticBold(false)
, m_syntheticItalic(false)
, m_orientation(FontOrientation::Horizontal)
@@ -81,12 +79,11 @@ FontPlatformData::FontPlatformData()
{
}
-FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheticItalic, FontOrientation orientation)
+FontPlatformData::FontPlatformData(bool syntheticBold, bool syntheticItalic, FontOrientation orientation)
: m_typeface(nullptr)
#if !OS(WIN)
, m_family(CString())
#endif
- , m_textSize(size)
, m_syntheticBold(syntheticBold)
, m_syntheticItalic(syntheticItalic)
, m_orientation(orientation)
@@ -107,7 +104,6 @@ FontPlatformData::FontPlatformData(const FontPlatformData& source)
#if !OS(WIN)
, m_family(source.m_family)
#endif
- , m_textSize(source.m_textSize)
, m_syntheticBold(source.m_syntheticBold)
, m_syntheticItalic(source.m_syntheticItalic)
, m_orientation(source.m_orientation)
@@ -124,39 +120,13 @@ FontPlatformData::FontPlatformData(const FontPlatformData& source)
{
}
-FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
- : m_typeface(src.m_typeface)
-#if !OS(WIN)
- , m_family(src.m_family)
-#endif
- , m_textSize(textSize)
- , m_syntheticBold(src.m_syntheticBold)
- , m_syntheticItalic(src.m_syntheticItalic)
- , m_orientation(src.m_orientation)
-#if !OS(MACOSX)
- , m_style(src.m_style)
-#endif
- , m_harfBuzzFace(nullptr)
- , m_isHashTableDeletedValue(false)
-#if OS(WIN)
- , m_paintTextFlags(src.m_paintTextFlags)
- , m_minSizeForAntiAlias(src.m_minSizeForAntiAlias)
- , m_minSizeForSubpixel(src.m_minSizeForSubpixel)
-#endif
-{
-#if !OS(MACOSX)
- querySystemForRenderStyle();
-#endif
-}
-
FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf,
- const char* family, float textSize, bool syntheticBold,
+ const char* family, bool syntheticBold,
bool syntheticItalic, FontOrientation orientation)
: m_typeface(tf)
#if !OS(WIN)
, m_family(family)
#endif
- , m_textSize(textSize)
, m_syntheticBold(syntheticBold)
, m_syntheticItalic(syntheticItalic)
, m_orientation(orientation)
@@ -167,9 +137,6 @@ FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf,
, m_minSizeForSubpixel(0)
#endif
{
-#if !OS(MACOSX)
- querySystemForRenderStyle();
-#endif
}
FontPlatformData::~FontPlatformData()
@@ -198,7 +165,6 @@ const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& othe
#if !OS(WIN)
m_family = other.m_family;
#endif
- m_textSize = other.m_textSize;
m_syntheticBold = other.m_syntheticBold;
m_syntheticItalic = other.m_syntheticItalic;
m_harfBuzzFace = nullptr;
@@ -227,7 +193,6 @@ bool FontPlatformData::operator==(const FontPlatformData& a) const
typefacesEqual = SkTypeface::Equal(typeface(), a.typeface());
return typefacesEqual
- && m_textSize == a.m_textSize
&& m_isHashTableDeletedValue == a.m_isHashTableDeletedValue
&& m_syntheticBold == a.m_syntheticBold
&& m_syntheticItalic == a.m_syntheticItalic
@@ -279,6 +244,8 @@ static inline bool tableHasSpace(hb_face_t* face, hb_set_t* glyphs,
}
bool FontPlatformData::hasSpaceInLigaturesOrKerning(
+ float fontSize,
+ const FontRenderStyle& style,
TypesettingFeatures features) const
{
const HarfBuzzFace* hbFace = harfBuzzFace();
@@ -287,7 +254,7 @@ bool FontPlatformData::hasSpaceInLigaturesOrKerning(
hb_face_t* face = hbFace->face();
ASSERT(face);
- OwnPtr<hb_font_t> font = adoptPtr(hbFace->createFont());
+ OwnPtr<hb_font_t> font = adoptPtr(hbFace->createFont(fontSize, style));
ASSERT(font);
hb_codepoint_t space;
@@ -318,14 +285,6 @@ unsigned FontPlatformData::hash() const
{
unsigned h = SkTypeface::UniqueID(typeface());
h ^= 0x01010101 * ((static_cast<int>(m_isHashTableDeletedValue) << 3) | (static_cast<int>(m_orientation) << 2) | (static_cast<int>(m_syntheticBold) << 1) | static_cast<int>(m_syntheticItalic));
-
- // This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing
- // rules. Memcpy is generally optimized enough so that performance doesn't
- // matter here.
- uint32_t textSizeBytes;
- memcpy(&textSizeBytes, &m_textSize, sizeof(uint32_t));
- h ^= textSizeBytes;
-
return h;
}

Powered by Google App Engine
This is Rietveld 408576698