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

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

Issue 645363003: Consolidate most simple vs. complex Font methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: minor cleanup 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 | Annotate | Revision Log
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 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y()); 943 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y());
944 m_glyphBoundingBox.unite(glyphBounds); 944 m_glyphBoundingBox.unite(glyphBounds);
945 glyphOrigin += FloatSize(advance + offsetX, offsetY); 945 glyphOrigin += FloatSize(advance + offsetX, offsetY);
946 946
947 totalAdvance += advance; 947 totalAdvance += advance;
948 } 948 }
949 currentRun->setWidth(totalAdvance > 0.0 ? totalAdvance : 0.0); 949 currentRun->setWidth(totalAdvance > 0.0 ? totalAdvance : 0.0);
950 m_totalWidth += currentRun->width(); 950 m_totalWidth += currentRun->width();
951 } 951 }
952 952
953 void HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBufferWithOffsets* glyp hBuffer, HarfBuzzRun* currentRun, float& carryAdvance) 953 void HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBuffer* glyphBuffer,
954 HarfBuzzRun* currentRun, float& carryAdvance)
954 { 955 {
955 FloatSize* offsets = currentRun->offsets(); 956 FloatSize* offsets = currentRun->offsets();
956 uint16_t* glyphs = currentRun->glyphs(); 957 uint16_t* glyphs = currentRun->glyphs();
957 float* advances = currentRun->advances(); 958 float* advances = currentRun->advances();
958 unsigned numGlyphs = currentRun->numGlyphs(); 959 unsigned numGlyphs = currentRun->numGlyphs();
959 uint16_t* glyphToCharacterIndexes = currentRun->glyphToCharacterIndexes(); 960 uint16_t* glyphToCharacterIndexes = currentRun->glyphToCharacterIndexes();
960 FloatSize runStartOffset = FloatSize(); 961 FloatSize runStartOffset = FloatSize();
961 if (m_run.rtl()) { 962 if (m_run.rtl()) {
962 for (unsigned i = 0; i < numGlyphs; ++i) { 963 for (unsigned i = 0; i < numGlyphs; ++i) {
963 uint16_t currentCharacterIndex = currentRun->startIndex() + glyphToC haracterIndexes[i]; 964 uint16_t currentCharacterIndex = currentRun->startIndex() + glyphToC haracterIndexes[i];
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 unsigned numRuns = m_harfBuzzRuns.size(); 1043 unsigned numRuns = m_harfBuzzRuns.size();
1043 float carryAdvance = 0; 1044 float carryAdvance = 0;
1044 if (m_run.rtl()) { 1045 if (m_run.rtl()) {
1045 for (int runIndex = numRuns - 1; runIndex >= 0; --runIndex) { 1046 for (int runIndex = numRuns - 1; runIndex >= 0; --runIndex) {
1046 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get(); 1047 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get();
1047 if (!currentRun->hasGlyphToCharacterIndexes()) { 1048 if (!currentRun->hasGlyphToCharacterIndexes()) {
1048 // FIXME: bug 337886, 359664 1049 // FIXME: bug 337886, 359664
1049 continue; 1050 continue;
1050 } 1051 }
1051 if (m_forTextEmphasis == ForTextEmphasis) { 1052 if (m_forTextEmphasis == ForTextEmphasis) {
1052 ASSERT(!glyphBuffer->hasOffsets());
1053 fillGlyphBufferForTextEmphasis(glyphBuffer, currentRun); 1053 fillGlyphBufferForTextEmphasis(glyphBuffer, currentRun);
1054 } else { 1054 } else {
1055 ASSERT(glyphBuffer->hasOffsets()); 1055 fillGlyphBufferFromHarfBuzzRun(glyphBuffer, currentRun, carryAdv ance);
1056 fillGlyphBufferFromHarfBuzzRun(
1057 static_cast<GlyphBufferWithOffsets*>(glyphBuffer), currentRu n, carryAdvance);
1058 } 1056 }
1059 } 1057 }
1060 } else { 1058 } else {
1061 for (unsigned runIndex = 0; runIndex < numRuns; ++runIndex) { 1059 for (unsigned runIndex = 0; runIndex < numRuns; ++runIndex) {
1062 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get(); 1060 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get();
1063 if (!currentRun->hasGlyphToCharacterIndexes()) { 1061 if (!currentRun->hasGlyphToCharacterIndexes()) {
1064 // FIXME: bug 337886, 359664 1062 // FIXME: bug 337886, 359664
1065 continue; 1063 continue;
1066 } 1064 }
1067 if (m_forTextEmphasis == ForTextEmphasis) { 1065 if (m_forTextEmphasis == ForTextEmphasis) {
1068 ASSERT(!glyphBuffer->hasOffsets());
1069 fillGlyphBufferForTextEmphasis(glyphBuffer, currentRun); 1066 fillGlyphBufferForTextEmphasis(glyphBuffer, currentRun);
1070 } else { 1067 } else {
1071 ASSERT(glyphBuffer->hasOffsets()); 1068 fillGlyphBufferFromHarfBuzzRun(glyphBuffer, currentRun, carryAdv ance);
1072 fillGlyphBufferFromHarfBuzzRun(
1073 static_cast<GlyphBufferWithOffsets*>(glyphBuffer), currentRu n, carryAdvance);
1074 } 1069 }
1075 } 1070 }
1076 } 1071 }
1077 return glyphBuffer->size(); 1072 return glyphBuffer->size();
1078 } 1073 }
1079 1074
1080 int HarfBuzzShaper::offsetForPosition(float targetX) 1075 int HarfBuzzShaper::offsetForPosition(float targetX)
1081 { 1076 {
1082 int charactersSoFar = 0; 1077 int charactersSoFar = 0;
1083 float currentX = 0; 1078 float currentX = 0;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 point.x() + fromX, point.x() + toX, 1151 point.x() + fromX, point.x() + toX,
1157 point.y(), height); 1152 point.y(), height);
1158 } 1153 }
1159 1154
1160 return Font::pixelSnappedSelectionRect( 1155 return Font::pixelSnappedSelectionRect(
1161 point.x() + toX, point.x() + fromX, 1156 point.x() + toX, point.x() + fromX,
1162 point.y(), height); 1157 point.y(), height);
1163 } 1158 }
1164 1159
1165 } // namespace blink 1160 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/shaping/HarfBuzzShaper.h ('k') | Source/platform/graphics/GraphicsContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698