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

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

Issue 1241613006: Reland "Change fallback font collection in HarfBuzzShaper" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 if (m_shapeCache) 49 if (m_shapeCache)
50 m_shapeCache->clear(); 50 m_shapeCache->clear();
51 } 51 }
52 52
53 float CachingWordShaper::width(const Font* font, const TextRun& run, 53 float CachingWordShaper::width(const Font* font, const TextRun& run,
54 HashSet<const SimpleFontData*>* fallbackFonts, 54 HashSet<const SimpleFontData*>* fallbackFonts,
55 FloatRect* glyphBounds) 55 FloatRect* glyphBounds)
56 { 56 {
57 float width = 0; 57 float width = 0;
58 RefPtr<ShapeResult> wordResult; 58 RefPtr<ShapeResult> wordResult;
59 CachingWordShapeIterator iterator(m_shapeCache, run, font, fallbackFonts); 59 CachingWordShapeIterator iterator(m_shapeCache, run, font);
60 while (iterator.next(&wordResult)) { 60 while (iterator.next(&wordResult)) {
61 if (wordResult) { 61 if (wordResult) {
62 width += wordResult->width(); 62 width += wordResult->width();
63 if (glyphBounds) 63 if (glyphBounds)
64 glyphBounds->unite(wordResult->bounds()); 64 glyphBounds->unite(wordResult->bounds());
65 if (fallbackFonts)
66 wordResult->fallbackFonts(fallbackFonts);
65 } 67 }
66 } 68 }
67 69
68 return width; 70 return width;
69 } 71 }
70 72
71 static inline float shapeResultsForRun(ShapeCache* shapeCache, const Font* font, 73 static inline float shapeResultsForRun(ShapeCache* shapeCache, const Font* font,
72 const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, 74 const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts,
73 Vector<RefPtr<ShapeResult>>* results) 75 Vector<RefPtr<ShapeResult>>* results)
74 { 76 {
75 CachingWordShapeIterator iterator(shapeCache, run, font, fallbackFonts); 77 CachingWordShapeIterator iterator(shapeCache, run, font);
76 RefPtr<ShapeResult> wordResult; 78 RefPtr<ShapeResult> wordResult;
77 float totalWidth = 0; 79 float totalWidth = 0;
78 while (iterator.next(&wordResult)) { 80 while (iterator.next(&wordResult)) {
79 if (wordResult) { 81 if (wordResult) {
80 results->append(wordResult); 82 results->append(wordResult);
81 totalWidth += wordResult->width(); 83 totalWidth += wordResult->width();
84 if (fallbackFonts)
85 wordResult->fallbackFonts(fallbackFonts);
82 } 86 }
83 } 87 }
84 return totalWidth; 88 return totalWidth;
85 } 89 }
86 90
87 float CachingWordShaper::fillGlyphBuffer(const Font* font, const TextRun& run, 91 float CachingWordShaper::fillGlyphBuffer(const Font* font, const TextRun& run,
88 HashSet<const SimpleFontData*>* fallbackFonts, 92 HashSet<const SimpleFontData*>* fallbackFonts,
89 GlyphBuffer* glyphBuffer, unsigned from, unsigned to) 93 GlyphBuffer* glyphBuffer, unsigned from, unsigned to)
90 { 94 {
91 Vector<RefPtr<ShapeResult>> results; 95 Vector<RefPtr<ShapeResult>> results;
(...skipping 18 matching lines...) Expand all
110 { 114 {
111 Vector<RefPtr<ShapeResult>> results; 115 Vector<RefPtr<ShapeResult>> results;
112 float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr, 116 float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr,
113 &results); 117 &results);
114 118
115 return ShapeResult::selectionRect(results, run.direction(), totalWidth, 119 return ShapeResult::selectionRect(results, run.direction(), totalWidth,
116 point, height, from, to); 120 point, height, from, to);
117 } 121 }
118 122
119 }; // namespace blink 123 }; // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/shaping/CachingWordShapeIterator.h ('k') | Source/platform/fonts/shaping/CachingWordShaperTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698