Commit d941089b authored by fmalita@chromium.org's avatar fmalita@chromium.org

Consolidate Font::codePath kerning & ligatures exceptions

Currently, we tweak the computed code path in several places to force
kerning & ligatures handling via the complex path. These checks
are identical and can be handled in codePath() instead.

The refactoring preserves existing logic.

R=eae@chromium.org,jbroman@chromium.org,dominik.rottsches@intel.com

Review URL: https://codereview.chromium.org/642863005

git-svn-id: svn://svn.chromium.org/blink/trunk@183562 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 26b33307
......@@ -79,7 +79,7 @@ SVGTextMetricsCalculator::SVGTextMetricsCalculator(RenderSVGInlineText* text)
, m_totalWidth(0)
{
const Font& scaledFont = text->scaledFont();
CodePath codePath = scaledFont.codePath(m_run);
CodePath codePath = scaledFont.codePath(TextRunPaintInfo(m_run));
m_isComplexText = codePath == ComplexPath;
m_run.setCharacterScanForCodePath(!m_isComplexText);
m_run.setUseComplexCodePath(m_isComplexText);
......
......@@ -50,8 +50,6 @@ using namespace Unicode;
namespace blink {
CodePath Font::s_codePath = AutoPath;
Font::Font()
{
}
......@@ -110,12 +108,7 @@ float Font::drawText(GraphicsContext* context, const TextRunPaintInfo& runInfo,
if (shouldSkipDrawing() && customFontNotReadyAction == DoNotPaintIfFontNotReady)
return 0;
CodePath codePathToUse = codePath(runInfo.run);
// FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
if (codePathToUse != ComplexPath && fontDescription().typesettingFeatures() && (runInfo.from || runInfo.to != runInfo.run.length()))
codePathToUse = ComplexPath;
if (codePathToUse != ComplexPath)
if (codePath(runInfo) != ComplexPath)
return drawSimpleText(context, runInfo, point);
return drawComplexText(context, runInfo, point);
......@@ -126,12 +119,7 @@ void Font::drawEmphasisMarks(GraphicsContext* context, const TextRunPaintInfo& r
if (shouldSkipDrawing())
return;
CodePath codePathToUse = codePath(runInfo.run);
// FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
if (codePathToUse != ComplexPath && fontDescription().typesettingFeatures() && (runInfo.from || runInfo.to != runInfo.run.length()))
codePathToUse = ComplexPath;
if (codePathToUse != ComplexPath)
if (codePath(runInfo) != ComplexPath)
drawEmphasisMarksForSimpleText(context, runInfo, mark, point);
else
drawEmphasisMarksForComplexText(context, runInfo, mark, point);
......@@ -150,7 +138,7 @@ static inline void updateGlyphOverflowFromBounds(const IntRectExtent& glyphBound
float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
CodePath codePathToUse = codePath(run);
CodePath codePathToUse = codePath(TextRunPaintInfo(run));
if (codePathToUse != ComplexPath) {
// The simple path can optimize the case where glyph overflow is not observable.
if (codePathToUse != SimpleWithGlyphOverflowPath && (glyphOverflow && !glyphOverflow->computeBounds))
......@@ -211,12 +199,7 @@ PassTextBlobPtr Font::buildTextBlob(const TextRunPaintInfo& runInfo, const Float
if (shouldSkipDrawing() && customFontNotReadyAction == DoNotPaintIfFontNotReady)
return nullptr;
CodePath codePathToUse = codePath(runInfo.run);
// FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
if (codePathToUse != ComplexPath && fontDescription().typesettingFeatures() && (runInfo.from || runInfo.to != runInfo.run.length()))
codePathToUse = ComplexPath;
if (codePathToUse != ComplexPath)
if (codePath(runInfo) != ComplexPath)
return buildTextBlobForSimpleText(runInfo, textOrigin, couldUseLCDRenderedText);
return nullptr;
......@@ -297,12 +280,11 @@ FloatRect Font::selectionRectForText(const TextRun& run, const FloatPoint& point
{
to = (to == -1 ? run.length() : to);
CodePath codePathToUse = codePath(run);
// FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
if (codePathToUse != ComplexPath && fontDescription().typesettingFeatures() && (from || to != run.length()))
codePathToUse = ComplexPath;
TextRunPaintInfo runInfo(run);
runInfo.from = from;
runInfo.to = to;
if (codePathToUse != ComplexPath)
if (codePath(runInfo) != ComplexPath)
return selectionRectForSimpleText(run, point, h, from, to, accountForGlyphBounds);
return selectionRectForComplexText(run, point, h, from, to);
......@@ -310,27 +292,18 @@ FloatRect Font::selectionRectForText(const TextRun& run, const FloatPoint& point
int Font::offsetForPosition(const TextRun& run, float x, bool includePartialGlyphs) const
{
// FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
if (codePath(run) != ComplexPath && !fontDescription().typesettingFeatures())
if (codePath(TextRunPaintInfo(run)) != ComplexPath && !fontDescription().typesettingFeatures())
return offsetForPositionForSimpleText(run, x, includePartialGlyphs);
return offsetForPositionForComplexText(run, x, includePartialGlyphs);
}
void Font::setCodePath(CodePath p)
{
s_codePath = p;
}
CodePath Font::codePath()
CodePath Font::codePath(const TextRunPaintInfo& runInfo) const
{
return s_codePath;
}
const TextRun& run = runInfo.run;
CodePath Font::codePath(const TextRun& run) const
{
if (s_codePath != AutoPath)
return s_codePath;
if (fontDescription().typesettingFeatures() && (runInfo.from || runInfo.to != run.length()))
return ComplexPath;
#if ENABLE(SVG_FONTS)
if (run.renderingContext())
......
......@@ -131,7 +131,7 @@ public:
std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(UChar32&, bool mirror, bool normalizeSpace = false, FontDataVariant = AutoVariant) const;
bool primaryFontHasGlyphForCharacter(UChar32) const;
CodePath codePath(const TextRun&) const;
CodePath codePath(const TextRunPaintInfo&) const;
PassTextBlobPtr buildTextBlob(const TextRunPaintInfo&, const FloatPoint& textOrigin, bool couldUseLCDRenderedText, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const;
void drawTextBlob(GraphicsContext*, const SkTextBlob*, const SkPoint& origin) const;
......@@ -167,11 +167,6 @@ private:
friend class SVGTextRunRenderingContext;
public:
// Useful for debugging the different font rendering code paths.
static void setCodePath(CodePath);
static CodePath codePath();
static CodePath s_codePath;
FontSelector* fontSelector() const;
FontFallbackList* fontList() const { return m_fontFallbackList.get(); }
......
......@@ -33,7 +33,7 @@
namespace blink {
enum CodePath { AutoPath, SimplePath, ComplexPath, SimpleWithGlyphOverflowPath };
enum CodePath { SimplePath, ComplexPath, SimpleWithGlyphOverflowPath };
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment