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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/GlyphPageTreeNode.cpp

Issue 1806653002: Shape unicode-range: font faces in only one iteration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update UnicodeRangeSetTests to RefPtrtr, rm copy constructor and test Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // for only 128 out of 256 characters. 238 // for only 128 out of 256 characters.
239 bool haveGlyphs; 239 bool haveGlyphs;
240 if (!fontData->isSegmented()) { 240 if (!fontData->isSegmented()) {
241 m_page = GlyphPage::createForSingleFontData(this, toSimpleFontData(fontD ata)); 241 m_page = GlyphPage::createForSingleFontData(this, toSimpleFontData(fontD ata));
242 haveGlyphs = fill(m_page.get(), 0, GlyphPage::size, buffer, bufferLength , toSimpleFontData(fontData)); 242 haveGlyphs = fill(m_page.get(), 0, GlyphPage::size, buffer, bufferLength , toSimpleFontData(fontData));
243 } else { 243 } else {
244 m_page = GlyphPage::createForMixedFontData(this); 244 m_page = GlyphPage::createForMixedFontData(this);
245 haveGlyphs = false; 245 haveGlyphs = false;
246 246
247 const SegmentedFontData* segmentedFontData = toSegmentedFontData(fontDat a); 247 const SegmentedFontData* segmentedFontData = toSegmentedFontData(fontDat a);
248 for (int i = segmentedFontData->numRanges() - 1; i >= 0; i--) { 248 for (int i = segmentedFontData->numFaces() - 1; i >= 0; i--) {
249 const FontDataRange& range = segmentedFontData->rangeAt(i); 249 const FontDataForRangeSet& fontDataForRangeSet = segmentedFontData-> faceAt(i);
250 // all this casting is to ensure all the parameters to min and max h ave the same type, 250 RefPtr<UnicodeRangeSet> ranges = fontDataForRangeSet.ranges();
251 // to avoid ambiguous template parameter errors on Windows 251 for (size_t i = 0; i < ranges->size(); ++i) {
252 int from = max(0, static_cast<int>(range.from()) - static_cast<int>( start)); 252 const UnicodeRange& range = ranges->rangeAt(i);
253 int to = 1 + min(static_cast<int>(range.to()) - static_cast<int>(sta rt), static_cast<int>(GlyphPage::size) - 1); 253 // all this casting is to ensure all the parameters to min and m ax have the same type,
254 if (from >= static_cast<int>(GlyphPage::size) || to <= 0) 254 // to avoid ambiguous template parameter errors on Windows
255 continue; 255 int from = max(0, static_cast<int>(range.from()) - static_cast<i nt>(start));
256 int to = 1 + min(static_cast<int>(range.to()) - static_cast<int> (start), static_cast<int>(GlyphPage::size) - 1);
257 if (from >= static_cast<int>(GlyphPage::size) || to <= 0)
258 continue;
256 259
257 // If this is a custom font needs to be loaded, do not fill 260 // If this is a custom font needs to be loaded, do not fill
258 // the page so that font fallback is used while loading. 261 // the page so that font fallback is used while loading.
259 RefPtr<CustomFontData> customData = range.fontData()->customFontData (); 262 RefPtr<CustomFontData> customData = fontDataForRangeSet.fontData ()->customFontData();
260 if (customData && customData->isLoadingFallback()) { 263 if (customData && customData->isLoadingFallback()) {
261 for (int j = from; j < to; j++) { 264 for (int j = from; j < to; j++) {
262 m_page->setCustomFontToLoad(j, customData.get()); 265 m_page->setCustomFontToLoad(j, customData.get());
263 haveGlyphs = true; 266 haveGlyphs = true;
267 }
268 continue;
264 } 269 }
265 continue; 270
271 haveGlyphs |= fill(m_page.get(), from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), fontDataFo rRangeSet.fontData().get());
266 } 272 }
267
268 haveGlyphs |= fill(m_page.get(), from, to - from, buffer + from * (s tart < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range.fontData ().get());
269 } 273 }
270 } 274 }
271 275
272 if (!haveGlyphs) 276 if (!haveGlyphs)
273 m_page = nullptr; 277 m_page = nullptr;
274 } 278 }
275 279
276 void GlyphPageTreeNode::initializeOverridePage(const FontData* fontData, unsigne d pageNumber) 280 void GlyphPageTreeNode::initializeOverridePage(const FontData* fontData, unsigne d pageNumber)
277 { 281 {
278 GlyphPage* parentPage = m_parent->page(); 282 GlyphPage* parentPage = m_parent->page();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // entries may use different fonts depending on character. If the Font 441 // entries may use different fonts depending on character. If the Font
438 // ever finds it needs a glyph out of the system fallback page, it will 442 // ever finds it needs a glyph out of the system fallback page, it will
439 // ask the system for the best font to use and fill that glyph in for us. 443 // ask the system for the best font to use and fill that glyph in for us.
440 if (GlyphPage* parentPage = m_parent->page()) 444 if (GlyphPage* parentPage = m_parent->page())
441 return parentPage->createCopiedSystemFallbackPage(this); 445 return parentPage->createCopiedSystemFallbackPage(this);
442 return GlyphPage::createForMixedFontData(this); 446 return GlyphPage::createForMixedFontData(this);
443 } 447 }
444 448
445 } // namespace blink 449 } // namespace blink
446 450
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698