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

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

Issue 1136303003: Move hb_language_t determination outside of for loop (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | 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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 811 }
812 812
813 bool HarfBuzzShaper::shapeHarfBuzzRuns() 813 bool HarfBuzzShaper::shapeHarfBuzzRuns()
814 { 814 {
815 HarfBuzzScopedPtr<hb_buffer_t> harfBuzzBuffer(hb_buffer_create(), hb_buffer_ destroy); 815 HarfBuzzScopedPtr<hb_buffer_t> harfBuzzBuffer(hb_buffer_create(), hb_buffer_ destroy);
816 816
817 HarfBuzzRunCache& runCache = harfBuzzRunCache(); 817 HarfBuzzRunCache& runCache = harfBuzzRunCache();
818 const FontDescription& fontDescription = m_font->fontDescription(); 818 const FontDescription& fontDescription = m_font->fontDescription();
819 const String& localeString = fontDescription.locale(); 819 const String& localeString = fontDescription.locale();
820 CString locale = localeString.latin1(); 820 CString locale = localeString.latin1();
821 const hb_language_t language = hb_language_from_string(locale.data(), locale .length());
821 HarfBuzzRun* previousRun = nullptr; 822 HarfBuzzRun* previousRun = nullptr;
822 823
823 for (unsigned i = 0; i < m_harfBuzzRuns.size(); ++i) { 824 for (unsigned i = 0; i < m_harfBuzzRuns.size(); ++i) {
824 unsigned runIndex = m_run.rtl() ? m_harfBuzzRuns.size() - i - 1 : i; 825 unsigned runIndex = m_run.rtl() ? m_harfBuzzRuns.size() - i - 1 : i;
825 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get(); 826 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get();
826 827
827 const SimpleFontData* currentFontData = currentRun->fontData(); 828 const SimpleFontData* currentFontData = currentRun->fontData();
828 FontPlatformData* platformData = const_cast<FontPlatformData*>(&currentF ontData->platformData()); 829 FontPlatformData* platformData = const_cast<FontPlatformData*>(&currentF ontData->platformData());
829 HarfBuzzFace* face = platformData->harfBuzzFace(); 830 HarfBuzzFace* face = platformData->harfBuzzFace();
830 if (!face) 831 if (!face)
831 return false; 832 return false;
832 833
833 hb_buffer_set_language(harfBuzzBuffer.get(), hb_language_from_string(loc ale.data(), locale.length())); 834 hb_buffer_set_language(harfBuzzBuffer.get(), language);
834 hb_buffer_set_script(harfBuzzBuffer.get(), currentRun->script()); 835 hb_buffer_set_script(harfBuzzBuffer.get(), currentRun->script());
835 hb_buffer_set_direction(harfBuzzBuffer.get(), currentRun->direction()); 836 hb_buffer_set_direction(harfBuzzBuffer.get(), currentRun->direction());
836 837
837 const UChar* src = m_normalizedBuffer.get() + currentRun->startIndex(); 838 const UChar* src = m_normalizedBuffer.get() + currentRun->startIndex();
838 std::wstring key(src, src + currentRun->numCharacters()); 839 std::wstring key(src, src + currentRun->numCharacters());
839 840
840 CachedShapingResults* cachedResults = runCache.find(key); 841 CachedShapingResults* cachedResults = runCache.find(key);
841 if (cachedResults) { 842 if (cachedResults) {
842 if (isValidCachedResult(m_font, currentRun->direction(), 843 if (isValidCachedResult(m_font, currentRun->direction(),
843 localeString, cachedResults)) { 844 localeString, cachedResults)) {
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 // possibly invalid from, to arguments. 1207 // possibly invalid from, to arguments.
1207 if (!foundToX && !foundFromX) 1208 if (!foundToX && !foundFromX)
1208 fromX = toX = 0; 1209 fromX = toX = 0;
1209 1210
1210 if (fromX < toX) 1211 if (fromX < toX)
1211 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); 1212 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height);
1212 return FloatRect(point.x() + toX, point.y(), fromX - toX, height); 1213 return FloatRect(point.x() + toX, point.y(), fromX - toX, height);
1213 } 1214 }
1214 1215
1215 } // namespace blink 1216 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698