Skip to content

Commit

Permalink
Avoid GraphicsContext calls during GlyphDisplayListCache shared entry…
Browse files Browse the repository at this point in the history
… lookup

https://bugs.webkit.org/show_bug.cgi?id=274958
rdar://129056751

Reviewed by Simon Fraser.

Obtain the values needed for translation lookup key before lookup begins.

* Source/WebCore/rendering/GlyphDisplayListCache.cpp:
(WebCore::GlyphDisplayListCacheKey::GlyphDisplayListCacheKey):
(WebCore::add):
(WebCore::GlyphDisplayListCacheKeyTranslator::equal):

Canonical link: https://commits.webkit.org/279582@main
  • Loading branch information
kkinnunen-apple committed May 31, 2024
1 parent 1f4e157 commit c803b13
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Source/WebCore/rendering/GlyphDisplayListCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,23 @@
namespace WebCore {

struct GlyphDisplayListCacheKey {
GlyphDisplayListCacheKey(const TextRun& textRun, const FontCascade& font, const GraphicsContext& context)
: textRun(textRun)
, scaleFactor(context.scaleFactor())
, fontCascadeGeneration(font.generation())
, shouldSubpixelQuantizeFonts(context.shouldSubpixelQuantizeFonts())
{
}

const TextRun& textRun;
const FontCascade& font;
GraphicsContext& context;
const FloatSize scaleFactor;
const unsigned fontCascadeGeneration;
const bool shouldSubpixelQuantizeFonts;
};

static void add(Hasher& hasher, const GlyphDisplayListCacheKey& key)
{
add(hasher, key.textRun, key.context.scaleFactor().width(), key.context.scaleFactor().height(), key.font.generation(), key.context.shouldSubpixelQuantizeFonts());
add(hasher, key.textRun, key.scaleFactor.width(), key.scaleFactor.height(), key.fontCascadeGeneration, key.shouldSubpixelQuantizeFonts);
}

struct GlyphDisplayListCacheKeyTranslator {
Expand All @@ -56,9 +65,9 @@ struct GlyphDisplayListCacheKeyTranslator {
{
auto& entry = entryRef.get();
return entry.m_textRun == key.textRun
&& entry.m_scaleFactor == key.context.scaleFactor()
&& entry.m_fontCascadeGeneration == key.font.generation()
&& entry.m_shouldSubpixelQuantizeFont == key.context.shouldSubpixelQuantizeFonts();
&& entry.m_scaleFactor == key.scaleFactor
&& entry.m_fontCascadeGeneration == key.fontCascadeGeneration
&& entry.m_shouldSubpixelQuantizeFont == key.shouldSubpixelQuantizeFonts;
}
};

Expand Down

0 comments on commit c803b13

Please sign in to comment.