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

Unified Diff: Source/platform/fonts/GlyphPageTreeNode.cpp

Issue 235863018: Simplify GlyphPage initialization for SegmentedFontData (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 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
« no previous file with comments | « no previous file | Source/platform/fonts/opentype/OpenTypeVerticalData.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/GlyphPageTreeNode.cpp
diff --git a/Source/platform/fonts/GlyphPageTreeNode.cpp b/Source/platform/fonts/GlyphPageTreeNode.cpp
index 5c045b69d465b193bde315465aa03866545134bd..8cab69833f934eff37e1a8b27303bcc50550a7c6 100644
--- a/Source/platform/fonts/GlyphPageTreeNode.cpp
+++ b/Source/platform/fonts/GlyphPageTreeNode.cpp
@@ -214,47 +214,25 @@ void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNu
haveGlyphs = false;
const SegmentedFontData* segmentedFontData = static_cast<const SegmentedFontData*>(fontData);
- unsigned numRanges = segmentedFontData->numRanges();
- bool zeroFilled = false;
- RefPtr<GlyphPage> scratchPage;
- GlyphPage* pageToFill = m_page.get();
- for (unsigned i = 0; i < numRanges; i++) {
+ for (int i = segmentedFontData->numRanges() - 1; i >= 0; i--) {
const FontDataRange& range = segmentedFontData->rangeAt(i);
// all this casting is to ensure all the parameters to min and max have the same type,
// to avoid ambiguous template parameter errors on Windows
int from = max(0, static_cast<int>(range.from()) - static_cast<int>(start));
int to = 1 + min(static_cast<int>(range.to()) - static_cast<int>(start), static_cast<int>(GlyphPage::size) - 1);
- if (from < static_cast<int>(GlyphPage::size) && to > 0) {
- // If this is a custom font needs to be loaded, kick off
- // the load here, and do not fill the page so that
- // font fallback is used while loading.
- RefPtr<CustomFontData> customData = range.fontData()->customFontData();
- if (customData && customData->isLoadingFallback()) {
- customData->beginLoadIfNeeded();
- continue;
- }
-
- if (haveGlyphs && !scratchPage) {
- scratchPage = GlyphPage::createForMixedFontData(this);
- pageToFill = scratchPage.get();
- }
-
- if (!zeroFilled) {
- if (from > 0 || to < static_cast<int>(GlyphPage::size)) {
- for (unsigned i = 0; i < GlyphPage::size; i++)
- pageToFill->setGlyphDataForIndex(i, 0, 0);
- }
- zeroFilled = true;
- }
- haveGlyphs |= fill(pageToFill, from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range.fontData().get());
- if (scratchPage) {
- ASSERT_WITH_SECURITY_IMPLICATION(to <= static_cast<int>(GlyphPage::size));
- for (int j = from; j < to; j++) {
- if (!m_page->glyphAt(j) && pageToFill->glyphAt(j))
- m_page->setGlyphDataForIndex(j, pageToFill->glyphDataForIndex(j));
- }
- }
+ if (from >= static_cast<int>(GlyphPage::size) || to <= 0)
+ continue;
+
+ // If this is a custom font needs to be loaded, kick off
+ // the load here, and do not fill the page so that
+ // font fallback is used while loading.
+ RefPtr<CustomFontData> customData = range.fontData()->customFontData();
+ if (customData && customData->isLoadingFallback()) {
+ customData->beginLoadIfNeeded();
+ continue;
}
+
+ haveGlyphs |= fill(m_page.get(), from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range.fontData().get());
}
}
« no previous file with comments | « no previous file | Source/platform/fonts/opentype/OpenTypeVerticalData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698