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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/Font.cpp

Issue 2718043003: Refactor InspectorCSSAgent to avoid an intermediate GlyphBuffer (Closed)
Patch Set: cleanup Created 3 years, 9 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // rectified by using RefPtrs for Fonts themselves. 102 // rectified by using RefPtrs for Fonts themselves.
103 if (!m_fontFallbackList) 103 if (!m_fontFallbackList)
104 m_fontFallbackList = FontFallbackList::create(); 104 m_fontFallbackList = FontFallbackList::create();
105 m_fontFallbackList->invalidate(fontSelector); 105 m_fontFallbackList->invalidate(fontSelector);
106 } 106 }
107 107
108 float Font::buildGlyphBuffer(const TextRunPaintInfo& runInfo, 108 float Font::buildGlyphBuffer(const TextRunPaintInfo& runInfo,
109 GlyphBuffer& glyphBuffer, 109 GlyphBuffer& glyphBuffer,
110 const GlyphData* emphasisData) const { 110 const GlyphData* emphasisData) const {
111 float width; 111 float width;
112 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription)); 112 CachingWordShaper shaper(*this);
113 if (emphasisData) { 113 if (emphasisData) {
114 width = shaper.fillGlyphBufferForTextEmphasis(this, runInfo.run, 114 width = shaper.fillGlyphBufferForTextEmphasis(runInfo.run,
115 emphasisData, &glyphBuffer, 115 emphasisData, &glyphBuffer,
116 runInfo.from, runInfo.to); 116 runInfo.from, runInfo.to);
117 } else { 117 } else {
118 width = shaper.fillGlyphBuffer(this, runInfo.run, nullptr, &glyphBuffer, 118 width = shaper.fillGlyphBuffer(runInfo.run, &glyphBuffer,
119 runInfo.from, runInfo.to); 119 runInfo.from, runInfo.to);
120 } 120 }
121 return width; 121 return width;
122 } 122 }
123 123
124 bool Font::drawText(PaintCanvas* canvas, 124 bool Font::drawText(PaintCanvas* canvas,
125 const TextRunPaintInfo& runInfo, 125 const TextRunPaintInfo& runInfo,
126 const FloatPoint& point, 126 const FloatPoint& point,
127 float deviceScaleFactor, 127 float deviceScaleFactor,
128 const PaintFlags& flags) const { 128 const PaintFlags& flags) const {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 if (glyphBuffer.isEmpty()) 217 if (glyphBuffer.isEmpty())
218 return; 218 return;
219 219
220 drawGlyphBuffer(canvas, flags, glyphBuffer, point, deviceScaleFactor); 220 drawGlyphBuffer(canvas, flags, glyphBuffer, point, deviceScaleFactor);
221 } 221 }
222 222
223 float Font::width(const TextRun& run, 223 float Font::width(const TextRun& run,
224 HashSet<const SimpleFontData*>* fallbackFonts, 224 HashSet<const SimpleFontData*>* fallbackFonts,
225 FloatRect* glyphBounds) const { 225 FloatRect* glyphBounds) const {
226 FontCachePurgePreventer purgePreventer; 226 FontCachePurgePreventer purgePreventer;
227 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription)); 227 CachingWordShaper shaper(*this);
228 float width = shaper.width(this, run, fallbackFonts, glyphBounds); 228 return shaper.width(run, fallbackFonts, glyphBounds);
229 return width;
230 } 229 }
231 230
232 namespace { 231 namespace {
233 232
234 enum BlobRotation { 233 enum BlobRotation {
235 NoRotation, 234 NoRotation,
236 CCWRotation, 235 CCWRotation,
237 }; 236 };
238 237
239 class GlyphBufferBloberizer { 238 class GlyphBufferBloberizer {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 int to, 430 int to,
432 bool accountForGlyphBounds) const { 431 bool accountForGlyphBounds) const {
433 to = (to == -1 ? run.length() : to); 432 to = (to == -1 ? run.length() : to);
434 433
435 TextRunPaintInfo runInfo(run); 434 TextRunPaintInfo runInfo(run);
436 runInfo.from = from; 435 runInfo.from = from;
437 runInfo.to = to; 436 runInfo.to = to;
438 437
439 FontCachePurgePreventer purgePreventer; 438 FontCachePurgePreventer purgePreventer;
440 439
441 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription)); 440 CachingWordShaper shaper(*this);
442 CharacterRange range = shaper.getCharacterRange(this, run, from, to); 441 CharacterRange range = shaper.getCharacterRange(run, from, to);
443 442
444 return pixelSnappedSelectionRect( 443 return pixelSnappedSelectionRect(
445 FloatRect(point.x() + range.start, point.y(), range.width(), height)); 444 FloatRect(point.x() + range.start, point.y(), range.width(), height));
446 } 445 }
447 446
448 int Font::offsetForPosition(const TextRun& run, 447 int Font::offsetForPosition(const TextRun& run,
449 float xFloat, 448 float xFloat,
450 bool includePartialGlyphs) const { 449 bool includePartialGlyphs) const {
451 FontCachePurgePreventer purgePreventer; 450 FontCachePurgePreventer purgePreventer;
452 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription)); 451 CachingWordShaper shaper(*this);
453 return shaper.offsetForPosition(this, run, xFloat, includePartialGlyphs); 452 return shaper.offsetForPosition(run, xFloat, includePartialGlyphs);
454 } 453 }
455 454
456 ShapeCache* Font::shapeCache() const { 455 ShapeCache* Font::shapeCache() const {
457 return m_fontFallbackList->shapeCache(m_fontDescription); 456 return m_fontFallbackList->shapeCache(m_fontDescription);
458 } 457 }
459 458
460 bool Font::canShapeWordByWord() const { 459 bool Font::canShapeWordByWord() const {
461 if (!m_shapeWordByWordComputed) { 460 if (!m_shapeWordByWordComputed) {
462 m_canShapeWordByWord = computeCanShapeWordByWord(); 461 m_canShapeWordByWord = computeCanShapeWordByWord();
463 m_shapeWordByWordComputed = true; 462 m_shapeWordByWordComputed = true;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 if (!markFontData) 553 if (!markFontData)
555 return 0; 554 return 0;
556 555
557 return markFontData->getFontMetrics().height(); 556 return markFontData->getFontMetrics().height();
558 } 557 }
559 558
560 CharacterRange Font::getCharacterRange(const TextRun& run, 559 CharacterRange Font::getCharacterRange(const TextRun& run,
561 unsigned from, 560 unsigned from,
562 unsigned to) const { 561 unsigned to) const {
563 FontCachePurgePreventer purgePreventer; 562 FontCachePurgePreventer purgePreventer;
564 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription)); 563 CachingWordShaper shaper(*this);
565 return shaper.getCharacterRange(this, run, from, to); 564 return shaper.getCharacterRange(run, from, to);
566 } 565 }
567 566
568 Vector<CharacterRange> Font::individualCharacterRanges( 567 Vector<CharacterRange> Font::individualCharacterRanges(
569 const TextRun& run) const { 568 const TextRun& run) const {
570 FontCachePurgePreventer purgePreventer; 569 FontCachePurgePreventer purgePreventer;
571 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription)); 570 CachingWordShaper shaper(*this);
572 auto ranges = shaper.individualCharacterRanges(this, run); 571 auto ranges = shaper.individualCharacterRanges(run);
573 // The shaper should return ranges.size == run.length but on some platforms 572 // The shaper should return ranges.size == run.length but on some platforms
574 // (OSX10.9.5) we are seeing cases in the upper end of the unicode range 573 // (OSX10.9.5) we are seeing cases in the upper end of the unicode range
575 // where this is not true (see: crbug.com/620952). To catch these cases on 574 // where this is not true (see: crbug.com/620952). To catch these cases on
576 // more popular platforms, and to protect users, we are using a CHECK here. 575 // more popular platforms, and to protect users, we are using a CHECK here.
577 CHECK_EQ(ranges.size(), run.length()); 576 CHECK_EQ(ranges.size(), run.length());
578 return ranges; 577 return ranges;
579 } 578 }
580 579
581 bool Font::loadingCustomFonts() const { 580 bool Font::loadingCustomFonts() const {
582 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); 581 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts();
583 } 582 }
584 583
585 bool Font::isFallbackValid() const { 584 bool Font::isFallbackValid() const {
586 return !m_fontFallbackList || m_fontFallbackList->isValid(); 585 return !m_fontFallbackList || m_fontFallbackList->isValid();
587 } 586 }
588 587
589 } // namespace blink 588 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/Font.h ('k') | third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698