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

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

Issue 519373002: Return width from drawText to stop re-measure in Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updating Test Expectation file Created 6 years, 3 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/Font.cpp ('k') | Source/platform/fonts/mac/FontComplexTextMac.cpp » ('j') | 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) 2007, 2008, 2010 Google Inc. All rights reserved. 2 * Copyright (c) 2007, 2008, 2010 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if ((textMode & TextModeStroke) && gc->hasStroke()) { 216 if ((textMode & TextModeStroke) && gc->hasStroke()) {
217 SkPaint paint = gc->strokePaint(); 217 SkPaint paint = gc->strokePaint();
218 gc->adjustTextRenderMode(&paint); 218 gc->adjustTextRenderMode(&paint);
219 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 219 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
220 if (textMode & TextModeFill) 220 if (textMode & TextModeFill)
221 paint.setLooper(0); 221 paint.setLooper(0);
222 gc->drawTextBlob(blob, origin, paint); 222 gc->drawTextBlob(blob, origin, paint);
223 } 223 }
224 } 224 }
225 225
226 void Font::drawComplexText(GraphicsContext* gc, const TextRunPaintInfo& runInfo, const FloatPoint& point) const 226 float Font::drawComplexText(GraphicsContext* gc, const TextRunPaintInfo& runInfo , const FloatPoint& point) const
227 { 227 {
228 if (!runInfo.run.length()) 228 if (!runInfo.run.length())
229 return; 229 return 0;
230 230
231 TextDrawingModeFlags textMode = gc->textDrawingMode(); 231 TextDrawingModeFlags textMode = gc->textDrawingMode();
232 bool fill = textMode & TextModeFill; 232 bool fill = textMode & TextModeFill;
233 bool stroke = (textMode & TextModeStroke) && gc->hasStroke(); 233 bool stroke = (textMode & TextModeStroke) && gc->hasStroke();
234 234
235 if (!fill && !stroke) 235 if (!fill && !stroke)
236 return; 236 return 0;
237 237
238 GlyphBuffer glyphBuffer; 238 GlyphBuffer glyphBuffer;
239 HarfBuzzShaper shaper(this, runInfo.run); 239 HarfBuzzShaper shaper(this, runInfo.run);
240 shaper.setDrawRange(runInfo.from, runInfo.to); 240 shaper.setDrawRange(runInfo.from, runInfo.to);
241 if (!shaper.shape(&glyphBuffer) || glyphBuffer.isEmpty()) 241 if (!shaper.shape(&glyphBuffer) || glyphBuffer.isEmpty())
242 return; 242 return 0;
243 FloatPoint adjustedPoint = shaper.adjustStartPoint(point); 243 FloatPoint adjustedPoint = shaper.adjustStartPoint(point);
244 drawGlyphBuffer(gc, runInfo, glyphBuffer, adjustedPoint); 244 return drawGlyphBuffer(gc, runInfo, glyphBuffer, adjustedPoint);
245 } 245 }
246 246
247 void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextR unPaintInfo& runInfo, const AtomicString& mark, const FloatPoint& point) const 247 void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextR unPaintInfo& runInfo, const AtomicString& mark, const FloatPoint& point) const
248 { 248 {
249 GlyphBuffer glyphBuffer; 249 GlyphBuffer glyphBuffer;
250 250
251 float initialAdvance = getGlyphsAndAdvancesForComplexText(runInfo, glyphBuff er, ForTextEmphasis); 251 float initialAdvance = getGlyphsAndAdvancesForComplexText(runInfo, glyphBuff er, ForTextEmphasis);
252 252
253 if (glyphBuffer.isEmpty()) 253 if (glyphBuffer.isEmpty())
254 return; 254 return;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 FloatRect Font::selectionRectForComplexText(const TextRun& run, 292 FloatRect Font::selectionRectForComplexText(const TextRun& run,
293 const FloatPoint& point, int height, 293 const FloatPoint& point, int height,
294 int from, int to) const 294 int from, int to) const
295 { 295 {
296 HarfBuzzShaper shaper(this, run); 296 HarfBuzzShaper shaper(this, run);
297 if (!shaper.shape()) 297 if (!shaper.shape())
298 return FloatRect(); 298 return FloatRect();
299 return shaper.selectionRect(point, height, from, to); 299 return shaper.selectionRect(point, height, from, to);
300 } 300 }
301 301
302 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, float initia lAdvance, const FloatRect& bounds) const 302 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, float initia lAdvance, const FloatRect& bounds, float& advance) const
303 { 303 {
304 // FIXME: Except for setupPaint, this is not specific to FontHarfBuzz. 304 // FIXME: Except for setupPaint, this is not specific to FontHarfBuzz.
305 // FIXME: Also implement the more general full-positioning path. 305 // FIXME: Also implement the more general full-positioning path.
306 ASSERT(!glyphBuffer.hasVerticalAdvances()); 306 ASSERT(!glyphBuffer.hasVerticalAdvances());
307 307
308 SkTextBlobBuilder builder; 308 SkTextBlobBuilder builder;
309 SkScalar x = SkFloatToScalar(initialAdvance); 309 SkScalar x = SkFloatToScalar(initialAdvance);
310 SkRect skBounds = bounds; 310 SkRect skBounds = bounds;
311 311
312 unsigned i = 0; 312 unsigned i = 0;
(...skipping 25 matching lines...) Expand all
338 const uint16_t* glyphs = glyphBuffer.glyphs(start); 338 const uint16_t* glyphs = glyphBuffer.glyphs(start);
339 std::copy(glyphs, glyphs + count, buffer.glyphs); 339 std::copy(glyphs, glyphs + count, buffer.glyphs);
340 340
341 const FloatSize* advances = glyphBuffer.advances(start); 341 const FloatSize* advances = glyphBuffer.advances(start);
342 for (unsigned j = 0; j < count; j++) { 342 for (unsigned j = 0; j < count; j++) {
343 buffer.pos[j] = x; 343 buffer.pos[j] = x;
344 x += SkFloatToScalar(advances[j].width()); 344 x += SkFloatToScalar(advances[j].width());
345 } 345 }
346 } 346 }
347 347
348 advance = x;
348 return adoptRef(builder.build()); 349 return adoptRef(builder.build());
349 } 350 }
350 351
351 } // namespace blink 352 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/Font.cpp ('k') | Source/platform/fonts/mac/FontComplexTextMac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698