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

Unified Diff: Source/platform/fonts/shaping/CachingWordShapeIterator.h

Issue 1239603002: Revert of Change fallback font collection in HarfBuzzShaper (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « Source/platform/fonts/Font.cpp ('k') | Source/platform/fonts/shaping/CachingWordShaper.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/shaping/CachingWordShapeIterator.h
diff --git a/Source/platform/fonts/shaping/CachingWordShapeIterator.h b/Source/platform/fonts/shaping/CachingWordShapeIterator.h
index 526c7e397483827ef471c7de46bed6ec12342215..e004766e5a721191ff7c02ed99683d620eb8d260 100644
--- a/Source/platform/fonts/shaping/CachingWordShapeIterator.h
+++ b/Source/platform/fonts/shaping/CachingWordShapeIterator.h
@@ -36,9 +36,10 @@
class CachingWordShapeIterator {
public:
- CachingWordShapeIterator(ShapeCache* cache, const TextRun& run
- , const Font* font)
- : m_shapeCache(cache), m_textRun(run), m_font(font), m_startIndex(0)
+ CachingWordShapeIterator(ShapeCache* cache, const TextRun& run,
+ const Font* font, HashSet<const SimpleFontData*>* fallbackFonts)
+ : m_shapeCache(cache), m_textRun(run), m_font(font)
+ , m_fallbackFonts(fallbackFonts), m_startIndex(0)
{
ASSERT(font);
const FontDescription& fontDescription = font->fontDescription();
@@ -62,7 +63,7 @@
if (!m_shapeByWord) {
if (m_startIndex)
return false;
- *wordResult = shapeWord(m_textRun, m_font);
+ *wordResult = shapeWord(m_textRun, m_font, m_fallbackFonts);
m_startIndex = 1;
return *wordResult;
}
@@ -71,7 +72,7 @@
if (m_startIndex < length) {
if (m_textRun[m_startIndex] == spaceCharacter) {
TextRun wordRun = m_textRun.subRun(m_startIndex, 1);
- *wordResult = shapeWord(wordRun, m_font);
+ *wordResult = shapeWord(wordRun, m_font, m_fallbackFonts);
m_startIndex++;
return true;
}
@@ -80,7 +81,7 @@
if (i == length || m_textRun[i] == spaceCharacter) {
TextRun wordRun = m_textRun.subRun(m_startIndex,
i - m_startIndex);
- *wordResult = shapeWord(wordRun, m_font);
+ *wordResult = shapeWord(wordRun, m_font, m_fallbackFonts);
m_startIndex = i;
return true;
}
@@ -90,15 +91,31 @@
}
private:
- PassRefPtr<ShapeResult> shapeWord(const TextRun& wordRun, const Font* font)
+ void setFallbackFonts(const ShapeResult* wordResult,
+ HashSet<const SimpleFontData*>* fallbackFonts)
+ {
+ if (fallbackFonts) {
+ const HashSet<const SimpleFontData*>* fontsForWord =
+ wordResult->fallbackFonts();
+ HashSet<const SimpleFontData*>::const_iterator it;
+ for (it = fontsForWord->begin(); it != fontsForWord->end(); ++it)
+ fallbackFonts->add(*it);
+ }
+ }
+
+ PassRefPtr<ShapeResult> shapeWord(const TextRun& wordRun,
+ const Font* font, HashSet<const SimpleFontData*>* fallbackFonts)
{
ShapeCacheEntry* cacheEntry = m_wordResultCachable
? m_shapeCache->add(wordRun, ShapeCacheEntry())
: nullptr;
- if (cacheEntry && cacheEntry->m_shapeResult)
+ if (cacheEntry && cacheEntry->m_shapeResult) {
+ setFallbackFonts(cacheEntry->m_shapeResult.get(), fallbackFonts);
return cacheEntry->m_shapeResult;
+ }
- HarfBuzzShaper shaper(font, wordRun);
+ HashSet<const SimpleFontData*> fallbackFontsForWord;
+ HarfBuzzShaper shaper(font, wordRun, &fallbackFontsForWord);
RefPtr<ShapeResult> shapeResult = shaper.shapeResult();
if (!shapeResult)
return nullptr;
@@ -106,12 +123,14 @@
if (cacheEntry)
cacheEntry->m_shapeResult = shapeResult;
+ setFallbackFonts(shapeResult.get(), fallbackFonts);
return shapeResult.release();
}
ShapeCache* m_shapeCache;
const TextRun& m_textRun;
const Font* m_font;
+ HashSet<const SimpleFontData*>* m_fallbackFonts;
unsigned m_startIndex : 30;
unsigned m_wordResultCachable : 1;
unsigned m_shapeByWord : 1;
« no previous file with comments | « Source/platform/fonts/Font.cpp ('k') | Source/platform/fonts/shaping/CachingWordShaper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698