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

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

Issue 2230233002: Skip redundant fonts returned by FontFallbackIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Logging removed Created 4 years, 4 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) 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 if (!isVerticalBaseline(runOrientation)) 489 if (!isVerticalBaseline(runOrientation))
490 return originalFont; 490 return originalFont;
491 491
492 if (runOrientation == FontOrientation::VerticalRotated 492 if (runOrientation == FontOrientation::VerticalRotated
493 || (runOrientation == FontOrientation::VerticalMixed && renderOrientatio n == OrientationIterator::OrientationRotateSideways)) 493 || (runOrientation == FontOrientation::VerticalMixed && renderOrientatio n == OrientationIterator::OrientationRotateSideways))
494 return originalFont->verticalRightOrientationFontData().get(); 494 return originalFont->verticalRightOrientationFontData().get();
495 495
496 return originalFont; 496 return originalFont;
497 } 497 }
498 498
499 bool HarfBuzzShaper::collectFallbackHintChars(Vector<UChar32>& hint, bool needsL ist) 499 bool HarfBuzzShaper::collectFallbackHintChars(Vector<UChar32>& hint)
500 { 500 {
501 if (!m_holesQueue.size()) 501 if (!m_holesQueue.size())
502 return false; 502 return false;
503 503
504 hint.clear(); 504 hint.clear();
505 505
506 size_t numCharsAdded = 0; 506 size_t numCharsAdded = 0;
507 for (auto it = m_holesQueue.begin(); it != m_holesQueue.end(); ++it) { 507 for (auto it = m_holesQueue.begin(); it != m_holesQueue.end(); ++it) {
508 if (it->m_action == HolesQueueNextFont) 508 if (it->m_action == HolesQueueNextFont)
509 break; 509 break;
510 510
511 UChar32 hintChar; 511 UChar32 hintChar;
512 RELEASE_ASSERT(it->m_startIndex + it->m_numCharacters <= m_normalizedBuf ferLength); 512 RELEASE_ASSERT(it->m_startIndex + it->m_numCharacters <= m_normalizedBuf ferLength);
513 UTF16TextIterator iterator(m_normalizedBuffer.get() + it->m_startIndex, it->m_numCharacters); 513 UTF16TextIterator iterator(m_normalizedBuffer.get() + it->m_startIndex, it->m_numCharacters);
514 while (iterator.consume(hintChar)) { 514 while (iterator.consume(hintChar)) {
515 hint.append(hintChar); 515 hint.append(hintChar);
516 numCharsAdded++; 516 numCharsAdded++;
517 if (!needsList)
518 break;
519 iterator.advance(); 517 iterator.advance();
520 } 518 }
521 } 519 }
522 return numCharsAdded > 0; 520 return numCharsAdded > 0;
523 } 521 }
524 522
525 void HarfBuzzShaper::appendToHolesQueue(HolesQueueItemAction action, 523 void HarfBuzzShaper::appendToHolesQueue(HolesQueueItemAction action,
526 unsigned startIndex, 524 unsigned startIndex,
527 unsigned numCharacters) 525 unsigned numCharacters)
528 { 526 {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 while (m_holesQueue.size()) { 590 while (m_holesQueue.size()) {
593 HolesQueueItem currentQueueItem = m_holesQueue.takeFirst(); 591 HolesQueueItem currentQueueItem = m_holesQueue.takeFirst();
594 592
595 if (currentQueueItem.m_action == HolesQueueNextFont) { 593 if (currentQueueItem.m_action == HolesQueueNextFont) {
596 // For now, we're building a character list with which we probe 594 // For now, we're building a character list with which we probe
597 // for needed fonts depending on the declared unicode-range of a 595 // for needed fonts depending on the declared unicode-range of a
598 // segmented CSS font. Alternatively, we can build a fake font 596 // segmented CSS font. Alternatively, we can build a fake font
599 // for the shaper and check whether any glyphs were found, or 597 // for the shaper and check whether any glyphs were found, or
600 // define a new API on the shaper which will give us coverage 598 // define a new API on the shaper which will give us coverage
601 // information? 599 // information?
602 if (!collectFallbackHintChars(fallbackCharsHint, fallbackIterato r->needsHintList())) { 600 if (!collectFallbackHintChars(fallbackCharsHint)) {
603 // Give up shaping since we cannot retrieve a font fallback 601 // Give up shaping since we cannot retrieve a font fallback
604 // font without a hintlist. 602 // font without a hintlist.
605 m_holesQueue.clear(); 603 m_holesQueue.clear();
606 break; 604 break;
607 } 605 }
608 606
609 currentFontDataForRangeSet = fallbackIterator->next(fallbackChar sHint); 607 currentFontDataForRangeSet = fallbackIterator->next(fallbackChar sHint);
610 608
611 if (!currentFontDataForRangeSet->fontData()) { 609 if (!currentFontDataForRangeSet->fontData()) {
612 ASSERT(!m_holesQueue.size()); 610 ASSERT(!m_holesQueue.size());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 result->m_width = run->m_width; 700 result->m_width = run->m_width;
703 result->m_numGlyphs = count; 701 result->m_numGlyphs = count;
704 ASSERT(result->m_numGlyphs == count); // no overflow 702 ASSERT(result->m_numGlyphs == count); // no overflow
705 result->m_hasVerticalOffsets = fontData->platformData().isVerticalAnyUpright (); 703 result->m_hasVerticalOffsets = fontData->platformData().isVerticalAnyUpright ();
706 result->m_runs.append(std::move(run)); 704 result->m_runs.append(std::move(run));
707 return result.release(); 705 return result.release();
708 } 706 }
709 707
710 708
711 } // namespace blink 709 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698