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

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

Issue 627273003: Carry advances between runs in HarfBuzzShaper.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Have Linux baseline be generated by the bot Created 6 years, 2 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 | « 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 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y()); 941 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y());
942 m_glyphBoundingBox.unite(glyphBounds); 942 m_glyphBoundingBox.unite(glyphBounds);
943 glyphOrigin += FloatSize(advance + offsetX, offsetY); 943 glyphOrigin += FloatSize(advance + offsetX, offsetY);
944 944
945 totalAdvance += advance; 945 totalAdvance += advance;
946 } 946 }
947 currentRun->setWidth(totalAdvance > 0.0 ? totalAdvance : 0.0); 947 currentRun->setWidth(totalAdvance > 0.0 ? totalAdvance : 0.0);
948 m_totalWidth += currentRun->width(); 948 m_totalWidth += currentRun->width();
949 } 949 }
950 950
951 void HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBufferWithOffsets* glyp hBuffer, HarfBuzzRun* currentRun) 951 void HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBufferWithOffsets* glyp hBuffer, HarfBuzzRun* currentRun, float& carryAdvance)
952 { 952 {
953 FloatSize* offsets = currentRun->offsets(); 953 FloatSize* offsets = currentRun->offsets();
954 uint16_t* glyphs = currentRun->glyphs(); 954 uint16_t* glyphs = currentRun->glyphs();
955 float* advances = currentRun->advances(); 955 float* advances = currentRun->advances();
956 unsigned numGlyphs = currentRun->numGlyphs(); 956 unsigned numGlyphs = currentRun->numGlyphs();
957 uint16_t* glyphToCharacterIndexes = currentRun->glyphToCharacterIndexes(); 957 uint16_t* glyphToCharacterIndexes = currentRun->glyphToCharacterIndexes();
958 float advanceSoFar = 0; 958 FloatSize runStartOffset = FloatSize();
959 if (m_run.rtl()) { 959 if (m_run.rtl()) {
960 for (unsigned i = 0; i < numGlyphs; ++i) { 960 for (unsigned i = 0; i < numGlyphs; ++i) {
961 uint16_t currentCharacterIndex = currentRun->startIndex() + glyphToC haracterIndexes[i]; 961 uint16_t currentCharacterIndex = currentRun->startIndex() + glyphToC haracterIndexes[i];
962 if (currentCharacterIndex >= m_toIndex) 962 if (currentCharacterIndex >= m_toIndex) {
963 advanceSoFar += advances[i]; 963 carryAdvance += advances[i];
964 else if (currentCharacterIndex >= m_fromIndex) 964 } else if (currentCharacterIndex >= m_fromIndex) {
965 glyphBuffer->add(glyphs[i], currentRun->fontData(), offsets[i] + FloatSize(advanceSoFar, 0), advances[i]); 965 runStartOffset = HB_DIRECTION_IS_HORIZONTAL(currentRun->directio n()) ? FloatSize(carryAdvance, 0) : FloatSize(0, carryAdvance);
966 glyphBuffer->add(glyphs[i], currentRun->fontData(), runStartOffs et + offsets[i], carryAdvance + advances[i]);
967 carryAdvance = 0;
968 }
966 } 969 }
967 } else { 970 } else {
968 for (unsigned i = 0; i < numGlyphs; ++i) { 971 for (unsigned i = 0; i < numGlyphs; ++i) {
969 uint16_t currentCharacterIndex = currentRun->startIndex() + glyphToC haracterIndexes[i]; 972 uint16_t currentCharacterIndex = currentRun->startIndex() + glyphToC haracterIndexes[i];
970 if (currentCharacterIndex < m_fromIndex) 973 if (currentCharacterIndex < m_fromIndex) {
971 advanceSoFar += advances[i]; 974 carryAdvance += advances[i];
972 else if (currentCharacterIndex < m_toIndex) 975 } else if (currentCharacterIndex < m_toIndex) {
973 glyphBuffer->add(glyphs[i], currentRun->fontData(), offsets[i] + FloatSize(advanceSoFar, 0), advances[i]); 976 runStartOffset = HB_DIRECTION_IS_HORIZONTAL(currentRun->directio n()) ? FloatSize(carryAdvance, 0) : FloatSize(0, carryAdvance);
977 glyphBuffer->add(glyphs[i], currentRun->fontData(), runStartOffs et + offsets[i], carryAdvance + advances[i]);
978 carryAdvance = 0;
979 }
974 } 980 }
975 } 981 }
976 } 982 }
977 983
978 void HarfBuzzShaper::fillGlyphBufferForTextEmphasis(GlyphBuffer* glyphBuffer, Ha rfBuzzRun* currentRun) 984 void HarfBuzzShaper::fillGlyphBufferForTextEmphasis(GlyphBuffer* glyphBuffer, Ha rfBuzzRun* currentRun)
979 { 985 {
980 // FIXME: Instead of generating a synthetic GlyphBuffer here which is then u sed by the 986 // FIXME: Instead of generating a synthetic GlyphBuffer here which is then u sed by the
981 // drawEmphasisMarks method of FontFastPath, we should roll our own emphasis mark drawing function. 987 // drawEmphasisMarks method of FontFastPath, we should roll our own emphasis mark drawing function.
982 988
983 float* advances = currentRun->advances(); 989 float* advances = currentRun->advances();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 } 1031 }
1026 clusterStart = clusterEnd; 1032 clusterStart = clusterEnd;
1027 clusterAdvance = 0; 1033 clusterAdvance = 0;
1028 } 1034 }
1029 } 1035 }
1030 } 1036 }
1031 1037
1032 bool HarfBuzzShaper::fillGlyphBuffer(GlyphBuffer* glyphBuffer) 1038 bool HarfBuzzShaper::fillGlyphBuffer(GlyphBuffer* glyphBuffer)
1033 { 1039 {
1034 unsigned numRuns = m_harfBuzzRuns.size(); 1040 unsigned numRuns = m_harfBuzzRuns.size();
1041 float carryAdvance = 0;
1035 if (m_run.rtl()) { 1042 if (m_run.rtl()) {
1036 for (int runIndex = numRuns - 1; runIndex >= 0; --runIndex) { 1043 for (int runIndex = numRuns - 1; runIndex >= 0; --runIndex) {
1037 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get(); 1044 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get();
1038 if (!currentRun->hasGlyphToCharacterIndexes()) { 1045 if (!currentRun->hasGlyphToCharacterIndexes()) {
1039 // FIXME: bug 337886, 359664 1046 // FIXME: bug 337886, 359664
1040 continue; 1047 continue;
1041 } 1048 }
1042 if (m_forTextEmphasis == ForTextEmphasis) { 1049 if (m_forTextEmphasis == ForTextEmphasis) {
1043 ASSERT(!glyphBuffer->hasOffsets()); 1050 ASSERT(!glyphBuffer->hasOffsets());
1044 fillGlyphBufferForTextEmphasis(glyphBuffer, currentRun); 1051 fillGlyphBufferForTextEmphasis(glyphBuffer, currentRun);
1045 } else { 1052 } else {
1046 ASSERT(glyphBuffer->hasOffsets()); 1053 ASSERT(glyphBuffer->hasOffsets());
1047 fillGlyphBufferFromHarfBuzzRun( 1054 fillGlyphBufferFromHarfBuzzRun(
1048 static_cast<GlyphBufferWithOffsets*>(glyphBuffer), currentRu n); 1055 static_cast<GlyphBufferWithOffsets*>(glyphBuffer), currentRu n, carryAdvance);
1049 } 1056 }
1050 } 1057 }
1051 } else { 1058 } else {
1052 for (unsigned runIndex = 0; runIndex < numRuns; ++runIndex) { 1059 for (unsigned runIndex = 0; runIndex < numRuns; ++runIndex) {
1053 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get(); 1060 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get();
1054 if (!currentRun->hasGlyphToCharacterIndexes()) { 1061 if (!currentRun->hasGlyphToCharacterIndexes()) {
1055 // FIXME: bug 337886, 359664 1062 // FIXME: bug 337886, 359664
1056 continue; 1063 continue;
1057 } 1064 }
1058 if (m_forTextEmphasis == ForTextEmphasis) { 1065 if (m_forTextEmphasis == ForTextEmphasis) {
1059 ASSERT(!glyphBuffer->hasOffsets()); 1066 ASSERT(!glyphBuffer->hasOffsets());
1060 fillGlyphBufferForTextEmphasis(glyphBuffer, currentRun); 1067 fillGlyphBufferForTextEmphasis(glyphBuffer, currentRun);
1061 } else { 1068 } else {
1062 ASSERT(glyphBuffer->hasOffsets()); 1069 ASSERT(glyphBuffer->hasOffsets());
1063 fillGlyphBufferFromHarfBuzzRun( 1070 fillGlyphBufferFromHarfBuzzRun(
1064 static_cast<GlyphBufferWithOffsets*>(glyphBuffer), currentRu n); 1071 static_cast<GlyphBufferWithOffsets*>(glyphBuffer), currentRu n, carryAdvance);
1065 } 1072 }
1066 } 1073 }
1067 } 1074 }
1068 return glyphBuffer->size(); 1075 return glyphBuffer->size();
1069 } 1076 }
1070 1077
1071 int HarfBuzzShaper::offsetForPosition(float targetX) 1078 int HarfBuzzShaper::offsetForPosition(float targetX)
1072 { 1079 {
1073 int charactersSoFar = 0; 1080 int charactersSoFar = 0;
1074 float currentX = 0; 1081 float currentX = 0;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 point.x() + fromX, point.x() + toX, 1152 point.x() + fromX, point.x() + toX,
1146 point.y(), height); 1153 point.y(), height);
1147 } 1154 }
1148 1155
1149 return Font::pixelSnappedSelectionRect( 1156 return Font::pixelSnappedSelectionRect(
1150 point.x() + toX, point.x() + fromX, 1157 point.x() + toX, point.x() + fromX,
1151 point.y(), height); 1158 point.y(), height);
1152 } 1159 }
1153 1160
1154 } // namespace blink 1161 } // namespace blink
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