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

Side by Side Diff: Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp

Issue 205553003: Invalidation not taking glyph bounds into account on HarfBuzz path (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/fonts/harfbuzz/HarfBuzzShaper.h ('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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 , m_normalizedBufferLength(0) 375 , m_normalizedBufferLength(0)
376 , m_run(run) 376 , m_run(run)
377 , m_wordSpacingAdjustment(font->fontDescription().wordSpacing()) 377 , m_wordSpacingAdjustment(font->fontDescription().wordSpacing())
378 , m_padding(0) 378 , m_padding(0)
379 , m_padPerWordBreak(0) 379 , m_padPerWordBreak(0)
380 , m_padError(0) 380 , m_padError(0)
381 , m_letterSpacing(font->fontDescription().letterSpacing()) 381 , m_letterSpacing(font->fontDescription().letterSpacing())
382 , m_fromIndex(0) 382 , m_fromIndex(0)
383 , m_toIndex(m_run.length()) 383 , m_toIndex(m_run.length())
384 , m_forTextEmphasis(forTextEmphasis) 384 , m_forTextEmphasis(forTextEmphasis)
385 , m_minGlyphBoundingBoxX(std::numeric_limits<float>::max())
386 , m_maxGlyphBoundingBoxX(std::numeric_limits<float>::min())
387 , m_minGlyphBoundingBoxY(std::numeric_limits<float>::max())
388 , m_maxGlyphBoundingBoxY(std::numeric_limits<float>::min())
385 { 389 {
386 m_normalizedBuffer = adoptArrayPtr(new UChar[m_run.length() + 1]); 390 m_normalizedBuffer = adoptArrayPtr(new UChar[m_run.length() + 1]);
387 normalizeCharacters(m_run, m_run.length(), m_normalizedBuffer.get(), &m_norm alizedBufferLength); 391 normalizeCharacters(m_run, m_run.length(), m_normalizedBuffer.get(), &m_norm alizedBufferLength);
388 setPadding(m_run.expansion()); 392 setPadding(m_run.expansion());
389 setFontFeatures(); 393 setFontFeatures();
390 } 394 }
391 395
392 bool HarfBuzzShaper::isWordEnd(unsigned index) 396 bool HarfBuzzShaper::isWordEnd(unsigned index)
393 { 397 {
394 // This could refer a high-surrogate, but should work. 398 // This could refer a high-surrogate, but should work.
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 862
859 if (!currentRun->hasGlyphToCharacterIndexes()) { 863 if (!currentRun->hasGlyphToCharacterIndexes()) {
860 // FIXME: https://crbug.com/337886 864 // FIXME: https://crbug.com/337886
861 ASSERT_NOT_REACHED(); 865 ASSERT_NOT_REACHED();
862 return; 866 return;
863 } 867 }
864 868
865 unsigned numGlyphs = currentRun->numGlyphs(); 869 unsigned numGlyphs = currentRun->numGlyphs();
866 uint16_t* glyphToCharacterIndexes = currentRun->glyphToCharacterIndexes(); 870 uint16_t* glyphToCharacterIndexes = currentRun->glyphToCharacterIndexes();
867 float totalAdvance = 0; 871 float totalAdvance = 0;
872 FloatPoint glyphOrigin;
868 873
869 // HarfBuzz returns the shaping result in visual order. We need not to flip for RTL. 874 // HarfBuzz returns the shaping result in visual order. We need not to flip for RTL.
870 for (size_t i = 0; i < numGlyphs; ++i) { 875 for (size_t i = 0; i < numGlyphs; ++i) {
871 bool runEnd = i + 1 == numGlyphs; 876 bool runEnd = i + 1 == numGlyphs;
872 uint16_t glyph = glyphInfos[i].codepoint; 877 uint16_t glyph = glyphInfos[i].codepoint;
873 float offsetX = harfBuzzPositionToFloat(glyphPositions[i].x_offset); 878 float offsetX = harfBuzzPositionToFloat(glyphPositions[i].x_offset);
874 float offsetY = -harfBuzzPositionToFloat(glyphPositions[i].y_offset); 879 float offsetY = -harfBuzzPositionToFloat(glyphPositions[i].y_offset);
875 float advance = harfBuzzPositionToFloat(glyphPositions[i].x_advance); 880 float advance = harfBuzzPositionToFloat(glyphPositions[i].x_advance);
876 881
877 unsigned currentCharacterIndex = currentRun->startIndex() + glyphInfos[i ].cluster; 882 unsigned currentCharacterIndex = currentRun->startIndex() + glyphInfos[i ].cluster;
(...skipping 16 matching lines...) Expand all
894 advance += spacing; 899 advance += spacing;
895 if (m_run.rtl()) { 900 if (m_run.rtl()) {
896 // In RTL, spacing should be added to left side of glyphs. 901 // In RTL, spacing should be added to left side of glyphs.
897 offsetX += spacing; 902 offsetX += spacing;
898 if (!isClusterEnd) 903 if (!isClusterEnd)
899 offsetX += m_letterSpacing; 904 offsetX += m_letterSpacing;
900 } 905 }
901 906
902 currentRun->setGlyphAndPositions(i, glyph, advance, offsetX, offsetY); 907 currentRun->setGlyphAndPositions(i, glyph, advance, offsetX, offsetY);
903 908
909 FloatRect glyphBounds = currentFontData->boundsForGlyph(glyph);
910 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y());
911 m_minGlyphBoundingBoxX = std::min(m_minGlyphBoundingBoxX, glyphBounds.x( ));
912 m_maxGlyphBoundingBoxX = std::max(m_maxGlyphBoundingBoxX, glyphBounds.ma xX());
913 m_minGlyphBoundingBoxY = std::min(m_minGlyphBoundingBoxY, glyphBounds.y( ));
914 m_maxGlyphBoundingBoxY = std::max(m_maxGlyphBoundingBoxY, glyphBounds.ma xY());
915 glyphOrigin += FloatSize(advance + offsetX, offsetY);
916
904 totalAdvance += advance; 917 totalAdvance += advance;
905 } 918 }
906 currentRun->setWidth(totalAdvance > 0.0 ? totalAdvance : 0.0); 919 currentRun->setWidth(totalAdvance > 0.0 ? totalAdvance : 0.0);
907 m_totalWidth += currentRun->width(); 920 m_totalWidth += currentRun->width();
908 } 921 }
909 922
910 void HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBuffer* glyphBuffer, Ha rfBuzzRun* currentRun, FloatPoint& firstOffsetOfNextRun) 923 void HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBuffer* glyphBuffer, Ha rfBuzzRun* currentRun, FloatPoint& firstOffsetOfNextRun)
911 { 924 {
912 FloatPoint* offsets = currentRun->offsets(); 925 FloatPoint* offsets = currentRun->offsets();
913 uint16_t* glyphs = currentRun->glyphs(); 926 uint16_t* glyphs = currentRun->glyphs();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 if (!foundToX) 1100 if (!foundToX)
1088 toX = m_run.rtl() ? 0 : m_totalWidth; 1101 toX = m_run.rtl() ? 0 : m_totalWidth;
1089 1102
1090 // Using floorf() and roundf() as the same as mac port. 1103 // Using floorf() and roundf() as the same as mac port.
1091 if (fromX < toX) 1104 if (fromX < toX)
1092 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from X), height); 1105 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from X), height);
1093 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he ight); 1106 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he ight);
1094 } 1107 }
1095 1108
1096 } // namespace WebCore 1109 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/fonts/harfbuzz/HarfBuzzShaper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698