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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/platform/fonts/opentype/OpenTypeVerticalData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // for only 128 out of 256 characters. 207 // for only 128 out of 256 characters.
208 bool haveGlyphs; 208 bool haveGlyphs;
209 if (!fontData->isSegmented()) { 209 if (!fontData->isSegmented()) {
210 m_page = GlyphPage::createForSingleFontData(this, static_cast<co nst SimpleFontData*>(fontData)); 210 m_page = GlyphPage::createForSingleFontData(this, static_cast<co nst SimpleFontData*>(fontData));
211 haveGlyphs = fill(m_page.get(), 0, GlyphPage::size, buffer, buff erLength, static_cast<const SimpleFontData*>(fontData)); 211 haveGlyphs = fill(m_page.get(), 0, GlyphPage::size, buffer, buff erLength, static_cast<const SimpleFontData*>(fontData));
212 } else { 212 } else {
213 m_page = GlyphPage::createForMixedFontData(this); 213 m_page = GlyphPage::createForMixedFontData(this);
214 haveGlyphs = false; 214 haveGlyphs = false;
215 215
216 const SegmentedFontData* segmentedFontData = static_cast<const S egmentedFontData*>(fontData); 216 const SegmentedFontData* segmentedFontData = static_cast<const S egmentedFontData*>(fontData);
217 unsigned numRanges = segmentedFontData->numRanges(); 217 for (int i = segmentedFontData->numRanges() - 1; i >= 0; i--) {
218 bool zeroFilled = false;
219 RefPtr<GlyphPage> scratchPage;
220 GlyphPage* pageToFill = m_page.get();
221 for (unsigned i = 0; i < numRanges; i++) {
222 const FontDataRange& range = segmentedFontData->rangeAt(i); 218 const FontDataRange& range = segmentedFontData->rangeAt(i);
223 // all this casting is to ensure all the parameters to min a nd max have the same type, 219 // all this casting is to ensure all the parameters to min a nd max have the same type,
224 // to avoid ambiguous template parameter errors on Windows 220 // to avoid ambiguous template parameter errors on Windows
225 int from = max(0, static_cast<int>(range.from()) - static_ca st<int>(start)); 221 int from = max(0, static_cast<int>(range.from()) - static_ca st<int>(start));
226 int to = 1 + min(static_cast<int>(range.to()) - static_cast< int>(start), static_cast<int>(GlyphPage::size) - 1); 222 int to = 1 + min(static_cast<int>(range.to()) - static_cast< int>(start), static_cast<int>(GlyphPage::size) - 1);
227 if (from < static_cast<int>(GlyphPage::size) && to > 0) { 223 if (from >= static_cast<int>(GlyphPage::size) || to <= 0)
228 // If this is a custom font needs to be loaded, kick off 224 continue;
229 // the load here, and do not fill the page so that
230 // font fallback is used while loading.
231 RefPtr<CustomFontData> customData = range.fontData()->cu stomFontData();
232 if (customData && customData->isLoadingFallback()) {
233 customData->beginLoadIfNeeded();
234 continue;
235 }
236 225
237 if (haveGlyphs && !scratchPage) { 226 // If this is a custom font needs to be loaded, kick off
238 scratchPage = GlyphPage::createForMixedFontData(this ); 227 // the load here, and do not fill the page so that
239 pageToFill = scratchPage.get(); 228 // font fallback is used while loading.
240 } 229 RefPtr<CustomFontData> customData = range.fontData()->custom FontData();
230 if (customData && customData->isLoadingFallback()) {
231 customData->beginLoadIfNeeded();
232 continue;
233 }
241 234
242 if (!zeroFilled) { 235 haveGlyphs |= fill(m_page.get(), from, to - from, buffer + f rom * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range. fontData().get());
243 if (from > 0 || to < static_cast<int>(GlyphPage::siz e)) {
244 for (unsigned i = 0; i < GlyphPage::size; i++)
245 pageToFill->setGlyphDataForIndex(i, 0, 0);
246 }
247 zeroFilled = true;
248 }
249 haveGlyphs |= fill(pageToFill, from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), rang e.fontData().get());
250 if (scratchPage) {
251 ASSERT_WITH_SECURITY_IMPLICATION(to <= static_cast< int>(GlyphPage::size));
252 for (int j = from; j < to; j++) {
253 if (!m_page->glyphAt(j) && pageToFill->glyphAt(j ))
254 m_page->setGlyphDataForIndex(j, pageToFill-> glyphDataForIndex(j));
255 }
256 }
257 }
258 } 236 }
259 } 237 }
260 238
261 if (!haveGlyphs) 239 if (!haveGlyphs)
262 m_page = nullptr; 240 m_page = nullptr;
263 } else if (parentPage && parentPage->owner() != m_parent) { 241 } else if (parentPage && parentPage->owner() != m_parent) {
264 // The page we're overriding may not be owned by our parent node. 242 // The page we're overriding may not be owned by our parent node.
265 // This happens when our parent node provides no useful overrides 243 // This happens when our parent node provides no useful overrides
266 // and just copies the pointer to an already-existing page (see 244 // and just copies the pointer to an already-existing page (see
267 // below). 245 // below).
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 printf("\nPage %d:\n", it->key); 406 printf("\nPage %d:\n", it->key);
429 showGlyphPageTree(it->key); 407 showGlyphPageTree(it->key);
430 } 408 }
431 } 409 }
432 410
433 void showGlyphPageTree(unsigned pageNumber) 411 void showGlyphPageTree(unsigned pageNumber)
434 { 412 {
435 WebCore::GlyphPageTreeNode::getRoot(pageNumber)->showSubtree(); 413 WebCore::GlyphPageTreeNode::getRoot(pageNumber)->showSubtree();
436 } 414 }
437 #endif 415 #endif
OLDNEW
« 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