Skip to content

Commit

Permalink
Merge r228553 - HarfBuzzFace should operate with a FontPlatformData r…
Browse files Browse the repository at this point in the history
…eference

https://bugs.webkit.org/show_bug.cgi?id=182863

Reviewed by Carlos Garcia Campos.

Instead of keeping a never-null pointer to FontPlatformData,
HarfBuzzFace should operate with a FontPlatformData reference.

* platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::FontPlatformData::harfBuzzFace const):
* platform/graphics/harfbuzz/HarfBuzzFace.cpp:
(WebCore::HarfBuzzFace::HarfBuzzFace):
* platform/graphics/harfbuzz/HarfBuzzFace.h:
* platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp:
(WebCore::HarfBuzzFace::createFace):
(WebCore::HarfBuzzFace::createFont):
  • Loading branch information
zdobersek authored and carlosgcampos committed Feb 20, 2018
1 parent 2bca24b commit 62517ca
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
19 changes: 19 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,22 @@
2018-02-16 Zan Dobersek <zdobersek@igalia.com>

HarfBuzzFace should operate with a FontPlatformData reference
https://bugs.webkit.org/show_bug.cgi?id=182863

Reviewed by Carlos Garcia Campos.

Instead of keeping a never-null pointer to FontPlatformData,
HarfBuzzFace should operate with a FontPlatformData reference.

* platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::FontPlatformData::harfBuzzFace const):
* platform/graphics/harfbuzz/HarfBuzzFace.cpp:
(WebCore::HarfBuzzFace::HarfBuzzFace):
* platform/graphics/harfbuzz/HarfBuzzFace.h:
* platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp:
(WebCore::HarfBuzzFace::createFace):
(WebCore::HarfBuzzFace::createFont):

2018-02-15 Zalan Bujtas <zalan@apple.com>

[RenderTreeBuilder] parent.Render*::addChild() cleanup
Expand Down
Expand Up @@ -241,7 +241,7 @@ FontPlatformData FontPlatformData::cloneWithSize(const FontPlatformData& source,
HarfBuzzFace& FontPlatformData::harfBuzzFace() const
{
if (!m_harfBuzzFace)
m_harfBuzzFace = std::make_unique<HarfBuzzFace>(const_cast<FontPlatformData*>(this), hash());
m_harfBuzzFace = std::make_unique<HarfBuzzFace>(const_cast<FontPlatformData&>(*this), hash());
return *m_harfBuzzFace;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.cpp
Expand Up @@ -64,7 +64,7 @@ HarfBuzzFace::Cache& HarfBuzzFace::cache()
return s_cache;
}

HarfBuzzFace::HarfBuzzFace(FontPlatformData* platformData, uint64_t uniqueID)
HarfBuzzFace::HarfBuzzFace(FontPlatformData& platformData, uint64_t uniqueID)
: m_platformData(platformData)
, m_uniqueID(uniqueID)
, m_scriptForVerticalText(HB_SCRIPT_INVALID)
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.h
Expand Up @@ -50,7 +50,7 @@ class HarfBuzzFace {
static const hb_tag_t vrt2Tag;
static const hb_tag_t kernTag;

HarfBuzzFace(FontPlatformData*, uint64_t);
HarfBuzzFace(FontPlatformData&, uint64_t);
~HarfBuzzFace();

hb_font_t* createFont();
Expand Down Expand Up @@ -83,7 +83,7 @@ class HarfBuzzFace {

hb_face_t* createFace();

FontPlatformData* m_platformData;
FontPlatformData& m_platformData;
uint64_t m_uniqueID;
RefPtr<CacheEntry> m_cacheEntry;

Expand Down
Expand Up @@ -187,7 +187,7 @@ static hb_blob_t* harfBuzzCairoGetTable(hb_face_t*, hb_tag_t tag, void* userData

hb_face_t* HarfBuzzFace::createFace()
{
auto* scaledFont = m_platformData->scaledFont();
auto* scaledFont = m_platformData.scaledFont();
cairo_scaled_font_reference(scaledFont);

hb_face_t* face = hb_face_create_for_tables(harfBuzzCairoGetTable, scaledFont,
Expand All @@ -202,13 +202,13 @@ hb_face_t* HarfBuzzFace::createFace()
hb_font_t* HarfBuzzFace::createFont()
{
hb_font_t* font = hb_font_create(m_cacheEntry->face());
hb_font_set_funcs(font, harfBuzzCairoTextGetFontFuncs(), new HarfBuzzFontData { m_cacheEntry->glyphCache(), m_platformData->scaledFont() },
hb_font_set_funcs(font, harfBuzzCairoTextGetFontFuncs(), new HarfBuzzFontData { m_cacheEntry->glyphCache(), m_platformData.scaledFont() },
[](void* data)
{
delete static_cast<HarfBuzzFontData*>(data);
});

const float size = m_platformData->size();
const float size = m_platformData.size();
if (floorf(size) == size)
hb_font_set_ppem(font, size, size);
int scale = floatToHarfBuzzPosition(size);
Expand Down

0 comments on commit 62517ca

Please sign in to comment.