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

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

Issue 2066253002: Fix Refcount in FontDataCache for objects from FontFallbackIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 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
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/SegmentedFontData.cpp ('k') | no next file » | 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) 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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 // TODO: Check whether this treatAsZerowidthspace from the previous script 576 // TODO: Check whether this treatAsZerowidthspace from the previous script
577 // segmentation plays a role here, does the new scriptRuniterator handle tha t correctly? 577 // segmentation plays a role here, does the new scriptRuniterator handle tha t correctly?
578 while (runSegmenter.consume(&segmentRange)) { 578 while (runSegmenter.consume(&segmentRange)) {
579 RefPtr<FontFallbackIterator> fallbackIterator = 579 RefPtr<FontFallbackIterator> fallbackIterator =
580 m_font->createFontFallbackIterator( 580 m_font->createFontFallbackIterator(
581 segmentRange.fontFallbackPriority); 581 segmentRange.fontFallbackPriority);
582 582
583 appendToHolesQueue(HolesQueueNextFont, 0, 0); 583 appendToHolesQueue(HolesQueueNextFont, 0, 0);
584 appendToHolesQueue(HolesQueueRange, segmentRange.start, segmentRange.end - segmentRange.start); 584 appendToHolesQueue(HolesQueueRange, segmentRange.start, segmentRange.end - segmentRange.start);
585 585
586 const SimpleFontData* currentFont = nullptr; 586 RefPtr<FontDataForRangeSet> currentFontDataForRangeSet;
587 RefPtr<UnicodeRangeSet> currentFontRangeSet;
588 587
589 bool fontCycleQueued = false; 588 bool fontCycleQueued = false;
590 while (m_holesQueue.size()) { 589 while (m_holesQueue.size()) {
591 HolesQueueItem currentQueueItem = m_holesQueue.takeFirst(); 590 HolesQueueItem currentQueueItem = m_holesQueue.takeFirst();
592 591
593 if (currentQueueItem.m_action == HolesQueueNextFont) { 592 if (currentQueueItem.m_action == HolesQueueNextFont) {
594 // For now, we're building a character list with which we probe 593 // For now, we're building a character list with which we probe
595 // for needed fonts depending on the declared unicode-range of a 594 // for needed fonts depending on the declared unicode-range of a
596 // segmented CSS font. Alternatively, we can build a fake font 595 // segmented CSS font. Alternatively, we can build a fake font
597 // for the shaper and check whether any glyphs were found, or 596 // for the shaper and check whether any glyphs were found, or
598 // define a new API on the shaper which will give us coverage 597 // define a new API on the shaper which will give us coverage
599 // information? 598 // information?
600 if (!collectFallbackHintChars(fallbackCharsHint, fallbackIterato r->needsHintList())) { 599 if (!collectFallbackHintChars(fallbackCharsHint, fallbackIterato r->needsHintList())) {
601 // Give up shaping since we cannot retrieve a font fallback 600 // Give up shaping since we cannot retrieve a font fallback
602 // font without a hintlist. 601 // font without a hintlist.
603 m_holesQueue.clear(); 602 m_holesQueue.clear();
604 break; 603 break;
605 } 604 }
606 605
607 FontDataForRangeSet nextFontDataForRangeSet = fallbackIterator-> next(fallbackCharsHint); 606 currentFontDataForRangeSet = fallbackIterator->next(fallbackChar sHint);
608 currentFont = nextFontDataForRangeSet.fontData();
609 currentFontRangeSet = nextFontDataForRangeSet.ranges();
610 607
611 if (!currentFont) { 608 if (!currentFontDataForRangeSet->fontData()) {
612 ASSERT(!m_holesQueue.size()); 609 ASSERT(!m_holesQueue.size());
613 break; 610 break;
614 } 611 }
615 fontCycleQueued = false; 612 fontCycleQueued = false;
616 continue; 613 continue;
617 } 614 }
618 615
619 SmallCapsIterator::SmallCapsBehavior smallCapsBehavior = SmallCapsIt erator::SmallCapsSameCase; 616 SmallCapsIterator::SmallCapsBehavior smallCapsBehavior = SmallCapsIt erator::SmallCapsSameCase;
620 if (needsCapsHandling) { 617 if (needsCapsHandling) {
621 capsSupport = OpenTypeCapsSupport(currentFont->platformData().ha rfBuzzFace(), 618 capsSupport = OpenTypeCapsSupport(
619 currentFontDataForRangeSet->fontData()->platformData().harfB uzzFace(),
622 fontDescription.variantCaps(), 620 fontDescription.variantCaps(),
623 ICUScriptToHBScript(segmentRange.script)); 621 ICUScriptToHBScript(segmentRange.script));
624 if (capsSupport.needsRunCaseSplitting()) 622 if (capsSupport.needsRunCaseSplitting())
625 splitUntilNextCaseChange(currentQueueItem, smallCapsBehavior ); 623 splitUntilNextCaseChange(currentQueueItem, smallCapsBehavior );
626 } 624 }
627 625
628 ASSERT(currentQueueItem.m_numCharacters); 626 ASSERT(currentQueueItem.m_numCharacters);
629 627
630 const SimpleFontData* smallcapsAdjustedFont = needsCapsHandling 628 const SimpleFontData* smallcapsAdjustedFont = needsCapsHandling
631 && capsSupport.needsSyntheticFont(smallCapsBehavior) 629 && capsSupport.needsSyntheticFont(smallCapsBehavior)
632 ? currentFont->smallCapsFontData(fontDescription).get() 630 ? currentFontDataForRangeSet->fontData()->smallCapsFontData(font Description).get()
633 : currentFont; 631 : currentFontDataForRangeSet->fontData();
634 632
635 // Compatibility with SimpleFontData approach of keeping a flag for overriding drawing direction. 633 // Compatibility with SimpleFontData approach of keeping a flag for overriding drawing direction.
636 // TODO: crbug.com/506224 This should go away in favor of storing th at information elsewhere, for example in 634 // TODO: crbug.com/506224 This should go away in favor of storing th at information elsewhere, for example in
637 // ShapeResult. 635 // ShapeResult.
638 const SimpleFontData* directionAndSmallCapsAdjustedFont = fontDataAd justedForOrientation(smallcapsAdjustedFont, 636 const SimpleFontData* directionAndSmallCapsAdjustedFont = fontDataAd justedForOrientation(smallcapsAdjustedFont,
639 m_font->getFontDescription().orientation(), 637 m_font->getFontDescription().orientation(),
640 segmentRange.renderOrientation); 638 segmentRange.renderOrientation);
641 639
642 CaseMapIntend caseMapIntend = CaseMapIntend::KeepSameCase; 640 CaseMapIntend caseMapIntend = CaseMapIntend::KeepSameCase;
643 if (needsCapsHandling) { 641 if (needsCapsHandling) {
644 caseMapIntend = capsSupport.needsCaseChange(smallCapsBehavior); 642 caseMapIntend = capsSupport.needsCaseChange(smallCapsBehavior);
645 } 643 }
646 644
647 CaseMappingHarfBuzzBufferFiller( 645 CaseMappingHarfBuzzBufferFiller(
648 caseMapIntend, 646 caseMapIntend,
649 harfBuzzBuffer.get(), 647 harfBuzzBuffer.get(),
650 m_normalizedBuffer.get(), 648 m_normalizedBuffer.get(),
651 m_normalizedBufferLength, 649 m_normalizedBufferLength,
652 currentQueueItem.m_startIndex, 650 currentQueueItem.m_startIndex,
653 currentQueueItem.m_numCharacters); 651 currentQueueItem.m_numCharacters);
654 652
655 CapsFeatureSettingsScopedOverlay capsOverlay(m_features, capsSupport .fontFeatureToUse(smallCapsBehavior)); 653 CapsFeatureSettingsScopedOverlay capsOverlay(m_features, capsSupport .fontFeatureToUse(smallCapsBehavior));
656 654
657 if (!shapeRange(harfBuzzBuffer.get(), 655 if (!shapeRange(harfBuzzBuffer.get(),
658 currentQueueItem.m_startIndex, 656 currentQueueItem.m_startIndex,
659 currentQueueItem.m_numCharacters, 657 currentQueueItem.m_numCharacters,
660 directionAndSmallCapsAdjustedFont, 658 directionAndSmallCapsAdjustedFont,
661 currentFontRangeSet, 659 currentFontDataForRangeSet->ranges(),
662 segmentRange.script, 660 segmentRange.script,
663 language)) 661 language))
664 DLOG(ERROR) << "Shaping range failed."; 662 DLOG(ERROR) << "Shaping range failed.";
665 663
666 if (!extractShapeResults(harfBuzzBuffer.get(), 664 if (!extractShapeResults(harfBuzzBuffer.get(),
667 result.get(), 665 result.get(),
668 fontCycleQueued, 666 fontCycleQueued,
669 currentQueueItem, 667 currentQueueItem,
670 directionAndSmallCapsAdjustedFont, 668 directionAndSmallCapsAdjustedFont,
671 segmentRange.script, 669 segmentRange.script,
(...skipping 28 matching lines...) Expand all
700 result->m_width = run->m_width; 698 result->m_width = run->m_width;
701 result->m_numGlyphs = count; 699 result->m_numGlyphs = count;
702 ASSERT(result->m_numGlyphs == count); // no overflow 700 ASSERT(result->m_numGlyphs == count); // no overflow
703 result->m_hasVerticalOffsets = fontData->platformData().isVerticalAnyUpright (); 701 result->m_hasVerticalOffsets = fontData->platformData().isVerticalAnyUpright ();
704 result->m_runs.append(std::move(run)); 702 result->m_runs.append(std::move(run));
705 return result.release(); 703 return result.release();
706 } 704 }
707 705
708 706
709 } // namespace blink 707 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/SegmentedFontData.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698