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

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

Issue 1244973003: Reland "Change fallback font collection in HarfBuzzShaper" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase (resolved conflicts) Created 5 years, 4 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 { 47 {
48 m_shapeCache->clear(); 48 m_shapeCache->clear();
49 } 49 }
50 50
51 float CachingWordShaper::width(const Font* font, const TextRun& run, 51 float CachingWordShaper::width(const Font* font, const TextRun& run,
52 HashSet<const SimpleFontData*>* fallbackFonts, 52 HashSet<const SimpleFontData*>* fallbackFonts,
53 FloatRect* glyphBounds) 53 FloatRect* glyphBounds)
54 { 54 {
55 float width = 0; 55 float width = 0;
56 RefPtr<ShapeResult> wordResult; 56 RefPtr<ShapeResult> wordResult;
57 CachingWordShapeIterator iterator(m_shapeCache.get(), run, font, fallbackFon ts); 57 CachingWordShapeIterator iterator(m_shapeCache.get(), run, font);
58 while (iterator.next(&wordResult)) { 58 while (iterator.next(&wordResult)) {
59 if (wordResult) { 59 if (wordResult) {
60 width += wordResult->width(); 60 width += wordResult->width();
61 if (glyphBounds) 61 if (glyphBounds)
62 glyphBounds->unite(wordResult->bounds()); 62 glyphBounds->unite(wordResult->bounds());
63 if (fallbackFonts)
64 wordResult->fallbackFonts(fallbackFonts);
63 } 65 }
64 } 66 }
65 67
66 return width; 68 return width;
67 } 69 }
68 70
69 static inline float shapeResultsForRun(ShapeCache* shapeCache, const Font* font, 71 static inline float shapeResultsForRun(ShapeCache* shapeCache, const Font* font,
70 const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, 72 const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts,
71 Vector<RefPtr<ShapeResult>>* results) 73 Vector<RefPtr<ShapeResult>>* results)
72 { 74 {
73 CachingWordShapeIterator iterator(shapeCache, run, font, fallbackFonts); 75 CachingWordShapeIterator iterator(shapeCache, run, font);
74 RefPtr<ShapeResult> wordResult; 76 RefPtr<ShapeResult> wordResult;
75 float totalWidth = 0; 77 float totalWidth = 0;
76 while (iterator.next(&wordResult)) { 78 while (iterator.next(&wordResult)) {
77 if (wordResult) { 79 if (wordResult) {
78 results->append(wordResult); 80 results->append(wordResult);
79 totalWidth += wordResult->width(); 81 totalWidth += wordResult->width();
82 if (fallbackFonts)
83 wordResult->fallbackFonts(fallbackFonts);
80 } 84 }
81 } 85 }
82 return totalWidth; 86 return totalWidth;
83 } 87 }
84 88
85 float CachingWordShaper::fillGlyphBuffer(const Font* font, const TextRun& run, 89 float CachingWordShaper::fillGlyphBuffer(const Font* font, const TextRun& run,
86 HashSet<const SimpleFontData*>* fallbackFonts, 90 HashSet<const SimpleFontData*>* fallbackFonts,
87 GlyphBuffer* glyphBuffer, unsigned from, unsigned to) 91 GlyphBuffer* glyphBuffer, unsigned from, unsigned to)
88 { 92 {
89 Vector<RefPtr<ShapeResult>> results; 93 Vector<RefPtr<ShapeResult>> results;
(...skipping 18 matching lines...) Expand all
108 { 112 {
109 Vector<RefPtr<ShapeResult>> results; 113 Vector<RefPtr<ShapeResult>> results;
110 float totalWidth = shapeResultsForRun(m_shapeCache.get(), font, run, nullptr , 114 float totalWidth = shapeResultsForRun(m_shapeCache.get(), font, run, nullptr ,
111 &results); 115 &results);
112 116
113 return ShapeResult::selectionRect(results, run.direction(), totalWidth, 117 return ShapeResult::selectionRect(results, run.direction(), totalWidth,
114 point, height, from, to); 118 point, height, from, to);
115 } 119 }
116 120
117 }; // namespace blink 121 }; // 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