1 diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp
2 index d0b747fff..9ec629285 100644
3 --- a/gfx/thebes/gfxFont.cpp
4 +++ b/gfx/thebes/gfxFont.cpp
5 @@ -2535,85 +2535,6 @@ IsBoundarySpace(char16_t aChar, char16_t aNextChar)
10 -#define GFX_MAYBE_UNUSED __attribute__((unused))
12 -#define GFX_MAYBE_UNUSED
17 -gfxFont::GetShapedWord(DrawTarget *aDrawTarget,
23 - int32_t aAppUnitsPerDevUnit,
25 - gfxTextPerfMetrics *aTextPerf GFX_MAYBE_UNUSED)
27 - // if the cache is getting too big, flush it and start over
28 - uint32_t wordCacheMaxEntries =
29 - gfxPlatform::GetPlatform()->WordCacheMaxEntries();
30 - if (mWordCache->Count() > wordCacheMaxEntries) {
31 - NS_WARNING("flushing shaped-word cache");
35 - // if there's a cached entry for this word, just return it
36 - CacheHashKey key(aText, aLength, aHash,
38 - aAppUnitsPerDevUnit,
41 - CacheHashEntry *entry = mWordCache->PutEntry(key);
43 - NS_WARNING("failed to create word cache entry - expect missing text");
46 - gfxShapedWord* sw = entry->mShapedWord.get();
48 - bool isContent = !mStyle.systemFont;
52 - Telemetry::Accumulate((isContent ? Telemetry::WORD_CACHE_HITS_CONTENT :
53 - Telemetry::WORD_CACHE_HITS_CHROME),
55 -#ifndef RELEASE_OR_BETA
57 - aTextPerf->current.wordCacheHit++;
63 - Telemetry::Accumulate((isContent ? Telemetry::WORD_CACHE_MISSES_CONTENT :
64 - Telemetry::WORD_CACHE_MISSES_CHROME),
66 -#ifndef RELEASE_OR_BETA
68 - aTextPerf->current.wordCacheMiss++;
72 - sw = gfxShapedWord::Create(aText, aLength, aRunScript, aAppUnitsPerDevUnit,
74 - entry->mShapedWord.reset(sw);
76 - NS_WARNING("failed to create gfxShapedWord - expect missing text");
80 - DebugOnly<bool> ok =
81 - ShapeText(aDrawTarget, aText, 0, aLength, aRunScript, aVertical, sw);
83 - NS_WARNING_ASSERTION(ok, "failed to shape word - expect garbled text");
89 gfxFont::CacheHashEntry::KeyEquals(const KeyTypePointer aKey) const
91 diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h
92 index ead0b7666..c38d06675 100644
93 --- a/gfx/thebes/gfxFont.h
94 +++ b/gfx/thebes/gfxFont.h
95 @@ -2220,4 +2220,88 @@ struct EmphasisMarkDrawParams {
99 +#include "mozilla/Telemetry.h"
100 +#include "mozilla/DebugOnly.h"
103 +#define GFX_MAYBE_UNUSED __attribute__((unused))
105 +#define GFX_MAYBE_UNUSED
108 +template<typename T>
110 +gfxFont::GetShapedWord(DrawTarget *aDrawTarget,
116 + int32_t aAppUnitsPerDevUnit,
118 + gfxTextPerfMetrics *aTextPerf GFX_MAYBE_UNUSED)
120 + using namespace mozilla;
122 + // if the cache is getting too big, flush it and start over
123 + uint32_t wordCacheMaxEntries =
124 + gfxPlatform::GetPlatform()->WordCacheMaxEntries();
125 + if (mWordCache->Count() > wordCacheMaxEntries) {
126 + NS_WARNING("flushing shaped-word cache");
127 + ClearCachedWords();
130 + // if there's a cached entry for this word, just return it
131 + CacheHashKey key(aText, aLength, aHash,
133 + aAppUnitsPerDevUnit,
136 + CacheHashEntry *entry = mWordCache->PutEntry(key);
138 + NS_WARNING("failed to create word cache entry - expect missing text");
141 + gfxShapedWord* sw = entry->mShapedWord.get();
143 + bool isContent = !mStyle.systemFont;
147 + Telemetry::Accumulate((isContent ? Telemetry::WORD_CACHE_HITS_CONTENT :
148 + Telemetry::WORD_CACHE_HITS_CHROME),
150 +#ifndef RELEASE_OR_BETA
152 + aTextPerf->current.wordCacheHit++;
158 + Telemetry::Accumulate((isContent ? Telemetry::WORD_CACHE_MISSES_CONTENT :
159 + Telemetry::WORD_CACHE_MISSES_CHROME),
161 +#ifndef RELEASE_OR_BETA
163 + aTextPerf->current.wordCacheMiss++;
167 + sw = gfxShapedWord::Create(aText, aLength, aRunScript, aAppUnitsPerDevUnit,
169 + entry->mShapedWord.reset(sw);
171 + NS_WARNING("failed to create gfxShapedWord - expect missing text");
175 + DebugOnly<bool> ok =
176 + ShapeText(aDrawTarget, aText, 0, aLength, aRunScript, aVertical, sw);
178 + NS_WARNING_ASSERTION(ok, "failed to shape word - expect garbled text");