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

Side by Side Diff: Source/platform/fonts/Font.cpp

Issue 362963003: Encapsulate FontFallbackList's page access logic. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } else { 407 } else {
408 variant = NormalVariant; 408 variant = NormalVariant;
409 } 409 }
410 } 410 }
411 411
412 if (mirror) 412 if (mirror)
413 c = mirroredChar(c); 413 c = mirroredChar(c);
414 414
415 unsigned pageNumber = (c / GlyphPage::size); 415 unsigned pageNumber = (c / GlyphPage::size);
416 416
417 GlyphPageTreeNode* node = pageNumber ? m_fontFallbackList->m_pages.get(pageN umber) : m_fontFallbackList->m_pageZero; 417 GlyphPageTreeNode* node = m_fontFallbackList->getPageNode(pageNumber);
418 if (!node) { 418 if (!node) {
419 node = GlyphPageTreeNode::getRootChild(fontDataAt(0), pageNumber); 419 node = GlyphPageTreeNode::getRootChild(fontDataAt(0), pageNumber);
420 if (pageNumber) 420 m_fontFallbackList->setPageNode(pageNumber, node);
421 m_fontFallbackList->m_pages.set(pageNumber, node);
422 else
423 m_fontFallbackList->m_pageZero = node;
424 } 421 }
425 422
426 GlyphPage* page = 0; 423 GlyphPage* page = 0;
427 if (variant == NormalVariant) { 424 if (variant == NormalVariant) {
428 // Fastest loop, for the common case (normal variant). 425 // Fastest loop, for the common case (normal variant).
429 while (true) { 426 while (true) {
430 page = node->page(); 427 page = node->page();
431 if (page) { 428 if (page) {
432 GlyphData data = page->glyphDataForCharacter(c); 429 GlyphData data = page->glyphDataForCharacter(c);
433 if (data.fontData && (data.fontData->platformData().orientation( ) == Horizontal || data.fontData->isTextOrientationFallback())) 430 if (data.fontData && (data.fontData->platformData().orientation( ) == Horizontal || data.fontData->isTextOrientationFallback()))
(...skipping 13 matching lines...) Expand all
447 444
448 return make_pair(data, page); 445 return make_pair(data, page);
449 } 446 }
450 447
451 if (node->isSystemFallback()) 448 if (node->isSystemFallback())
452 break; 449 break;
453 } 450 }
454 451
455 // Proceed with the fallback list. 452 // Proceed with the fallback list.
456 node = node->getChild(fontDataAt(node->level()), pageNumber); 453 node = node->getChild(fontDataAt(node->level()), pageNumber);
457 if (pageNumber) 454 m_fontFallbackList->setPageNode(pageNumber, node);
458 m_fontFallbackList->m_pages.set(pageNumber, node);
459 else
460 m_fontFallbackList->m_pageZero = node;
461 } 455 }
462 } 456 }
463 if (variant != NormalVariant) { 457 if (variant != NormalVariant) {
464 while (true) { 458 while (true) {
465 page = node->page(); 459 page = node->page();
466 if (page) { 460 if (page) {
467 GlyphData data = page->glyphDataForCharacter(c); 461 GlyphData data = page->glyphDataForCharacter(c);
468 if (data.fontData) { 462 if (data.fontData) {
469 // The variantFontData function should not normally return 0 . 463 // The variantFontData function should not normally return 0 .
470 // But if it does, we will just render the capital letter bi g. 464 // But if it does, we will just render the capital letter bi g.
(...skipping 13 matching lines...) Expand all
484 // a font has the lowercase character but the small caps fon t does not have its uppercase version. 478 // a font has the lowercase character but the small caps fon t does not have its uppercase version.
485 return make_pair(variantFontData->missingGlyphData(), page); 479 return make_pair(variantFontData->missingGlyphData(), page);
486 } 480 }
487 481
488 if (node->isSystemFallback()) 482 if (node->isSystemFallback())
489 break; 483 break;
490 } 484 }
491 485
492 // Proceed with the fallback list. 486 // Proceed with the fallback list.
493 node = node->getChild(fontDataAt(node->level()), pageNumber); 487 node = node->getChild(fontDataAt(node->level()), pageNumber);
494 if (pageNumber) 488 m_fontFallbackList->setPageNode(pageNumber, node);
495 m_fontFallbackList->m_pages.set(pageNumber, node);
496 else
497 m_fontFallbackList->m_pageZero = node;
498 } 489 }
499 } 490 }
500 491
501 ASSERT(page); 492 ASSERT(page);
502 ASSERT(node->isSystemFallback()); 493 ASSERT(node->isSystemFallback());
503 494
504 // System fallback is character-dependent. When we get here, we 495 // System fallback is character-dependent. When we get here, we
505 // know that the character in question isn't in the system fallback 496 // know that the character in question isn't in the system fallback
506 // font's glyph page. Try to lazily create it here. 497 // font's glyph page. Try to lazily create it here.
507 498
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 if (delta <= 0) 843 if (delta <= 0)
853 break; 844 break;
854 } 845 }
855 } 846 }
856 } 847 }
857 848
858 return offset; 849 return offset;
859 } 850 }
860 851
861 } 852 }
OLDNEW
« no previous file with comments | « no previous file | Source/platform/fonts/FontFallbackList.h » ('j') | Source/platform/fonts/FontFallbackList.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698