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

Unified Diff: third_party/WebKit/Source/platform/fonts/SimpleFontData.h

Issue 1980913002: Unify glyph metrics to use the same Skia API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed a spurious header line Created 4 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 side-by-side diff with in-line comments
Download patch
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..75ca7335ffe4d19c8961bac297a4dd47d06ae58d 100644
--- a/third_party/WebKit/Source/platform/fonts/SimpleFontData.h
+++ b/third_party/WebKit/Source/platform/fonts/SimpleFontData.h
@@ -37,6 +37,7 @@
#include "platform/geometry/FloatRect.h"
#include "wtf/PtrUtil.h"
#include "wtf/text/StringHash.h"
+#include <SkPaint.h>
#include <memory>
namespace blink {
@@ -95,8 +96,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 +144,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 +183,35 @@ private:
RefPtr<CustomFontData> m_customFontData;
};
+
ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const
{
- FloatRect bounds;
+ if (!m_platformData.size())
+ return FloatRect();
+
+ static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated.");
+
+ 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;
+ static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated.");
+
float width = m_glyphToWidthMap.metricsForGlyph(glyph);
if (width != cGlyphSizeUnknown)
return width;
« no previous file with comments | « third_party/WebKit/Source/platform/blink_platform.gypi ('k') | third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698