Chromium Code Reviews| Index: third_party/WebKit/Source/platform/fonts/SimpleFontData.h |
| diff --git a/third_party/WebKit/Source/platform/fonts/SimpleFontData.h b/third_party/WebKit/Source/platform/fonts/SimpleFontData.h |
| index 9cbeb8b371988ab6d39cf1ab155293a2773d26e4..5d304f3746e83a6eb228b05f862a7782b67571be 100644 |
| --- a/third_party/WebKit/Source/platform/fonts/SimpleFontData.h |
| +++ b/third_party/WebKit/Source/platform/fonts/SimpleFontData.h |
| @@ -32,11 +32,13 @@ |
| #include "platform/fonts/FontPlatformData.h" |
| #include "platform/fonts/GlyphMetricsMap.h" |
| #include "platform/fonts/GlyphPageTreeNode.h" |
| +#include "platform/fonts/SimpleFontDataInlineHeaders.h" |
| #include "platform/fonts/TypesettingFeatures.h" |
| #include "platform/fonts/opentype/OpenTypeVerticalData.h" |
| #include "platform/geometry/FloatRect.h" |
| #include "wtf/PtrUtil.h" |
| #include "wtf/text/StringHash.h" |
| +#include <SkPaint.h> |
| #include <memory> |
| namespace blink { |
| @@ -95,8 +97,8 @@ public: |
| void setAvgCharWidth(float avgCharWidth) { m_avgCharWidth = avgCharWidth; } |
| FloatRect boundsForGlyph(Glyph) const; |
| - float widthForGlyph(Glyph glyph) const; |
| FloatRect platformBoundsForGlyph(Glyph) const; |
| + float widthForGlyph(Glyph) const; |
| float platformWidthForGlyph(Glyph) const; |
| float spaceWidth() const { return m_spaceWidth; } |
| @@ -143,9 +145,9 @@ private: |
| float m_avgCharWidth; |
| FontPlatformData m_platformData; |
| - |
| mutable std::unique_ptr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap; |
| mutable GlyphMetricsMap<float> m_glyphToWidthMap; |
| + SkPaint m_paint; |
| bool m_isTextOrientationFallback; |
| RefPtr<OpenTypeVerticalData> m_verticalData; |
| @@ -182,24 +184,35 @@ private: |
| RefPtr<CustomFontData> m_customFontData; |
| }; |
| + |
| ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const |
| { |
| - FloatRect bounds; |
| + if (!m_platformData.size()) |
| + return FloatRect(); |
| + |
| + SkASSERT(sizeof(glyph) == 2); // compile-time assert |
| + |
| + FloatRect boundsResult; |
| if (m_glyphToBoundsMap) { |
| - bounds = m_glyphToBoundsMap->metricsForGlyph(glyph); |
| - if (bounds.width() != cGlyphSizeUnknown) |
| - return bounds; |
| + boundsResult = m_glyphToBoundsMap->metricsForGlyph(glyph); |
| + if (boundsResult.width() != cGlyphSizeUnknown) |
| + return boundsResult; |
| } |
| - bounds = platformBoundsForGlyph(glyph); |
| + boundsResult = platformBoundsForGlyph(glyph); |
| if (!m_glyphToBoundsMap) |
| m_glyphToBoundsMap = wrapUnique(new GlyphMetricsMap<FloatRect>); |
| - m_glyphToBoundsMap->setMetricsForGlyph(glyph, bounds); |
| - return bounds; |
| + m_glyphToBoundsMap->setMetricsForGlyph(glyph, boundsResult); |
| + |
| + return boundsResult; |
| } |
| ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const |
| { |
| + if (!m_platformData.size()) |
| + return 0; |
| + SkASSERT(sizeof(glyph) == 2); // compile-time assert |
|
kojii
2016/07/25 16:36:28
Our current style guide allows the use of static_a
drott
2016/07/26 07:49:35
Thanks, updated.
|
| + |
| float width = m_glyphToWidthMap.metricsForGlyph(glyph); |
| if (width != cGlyphSizeUnknown) |
| return width; |