Skip to content
Permalink
Browse files
FontCascade cleanup: Remove ::drawSimpleText and ::drawComplexText.
https://bugs.webkit.org/show_bug.cgi?id=152323

Reviewed by Myles C. Maxfield.

Platform code for ::drawComplexText() is redundant and has
no platform dependent logic. Move it all to ::drawText()

No change in functionality.

* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::glyphBufferForTextRun):
(WebCore::FontCascade::drawText):
(WebCore::FontCascade::drawSimpleText): Deleted.
* platform/graphics/FontCascade.h:
* platform/graphics/cairo/FontCairoHarfbuzzNG.cpp:
(WebCore::FontCascade::drawComplexText): Deleted.
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::FontCascade::drawComplexText): Deleted.
* platform/graphics/win/FontWin.cpp:
(WebCore::FontCascade::drawComplexText): Deleted.


Canonical link: https://commits.webkit.org/170436@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194132 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Dec 16, 2015
1 parent 94bde51 commit 8bf4ca250dd6cdd0d39b27c4bb5d8029a5a84574
@@ -1,3 +1,27 @@
2015-12-15 Zalan Bujtas <zalan@apple.com>

FontCascade cleanup: Remove ::drawSimpleText and ::drawComplexText.
https://bugs.webkit.org/show_bug.cgi?id=152323

Reviewed by Myles C. Maxfield.

Platform code for ::drawComplexText() is redundant and has
no platform dependent logic. Move it all to ::drawText()

No change in functionality.

* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::glyphBufferForTextRun):
(WebCore::FontCascade::drawText):
(WebCore::FontCascade::drawSimpleText): Deleted.
* platform/graphics/FontCascade.h:
* platform/graphics/cairo/FontCairoHarfbuzzNG.cpp:
(WebCore::FontCascade::drawComplexText): Deleted.
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::FontCascade::drawComplexText): Deleted.
* platform/graphics/win/FontWin.cpp:
(WebCore::FontCascade::drawComplexText): Deleted.

2015-12-15 Tim Horton <timothy_horton@apple.com>

[Mac] Gesture Events should not have negative scale
@@ -306,6 +306,13 @@ void FontCascade::update(RefPtr<FontSelector>&& fontSelector) const
m_requiresShaping = computeRequiresShaping();
}

float FontCascade::glyphBufferForTextRun(CodePath codePathToUse, const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer) const
{
if (codePathToUse != Complex)
return getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer);
return getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer);
}

float FontCascade::drawText(GraphicsContext& context, const TextRun& run, const FloatPoint& point, int from, int to, CustomFontNotReadyAction customFontNotReadyAction) const
{
// Don't draw anything while we are using custom fonts that are in the process of loading,
@@ -321,10 +328,15 @@ float FontCascade::drawText(GraphicsContext& context, const TextRun& run, const
if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
codePathToUse = Complex;

if (codePathToUse != Complex)
return drawSimpleText(context, run, point, from, to);

return drawComplexText(context, run, point, from, to);
GlyphBuffer glyphBuffer;
float startX = point.x() + glyphBufferForTextRun(codePathToUse, run, from, to, glyphBuffer);
// We couldn't generate any glyphs for the run. Give up.
if (glyphBuffer.isEmpty())
return 0;
// Draw the glyph buffer now at the starting point returned in startX.
FloatPoint startPoint(startX, point.y());
drawGlyphBuffer(context, run, glyphBuffer, startPoint);
return startPoint.x() - startX;
}

void FontCascade::drawEmphasisMarks(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
@@ -1292,22 +1304,6 @@ float FontCascade::getGlyphsAndAdvancesForSimpleText(const TextRun& run, int fro
return initialAdvance;
}

float FontCascade::drawSimpleText(GraphicsContext& context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
// This glyph buffer holds our glyphs+advances+font data for each glyph.
GlyphBuffer glyphBuffer;

float startX = point.x() + getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer);

if (glyphBuffer.isEmpty())
return 0;

FloatPoint startPoint(startX, point.y());
drawGlyphBuffer(context, run, glyphBuffer, startPoint);

return startPoint.x() - startX;
}

void FontCascade::drawEmphasisMarksForSimpleText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
{
GlyphBuffer glyphBuffer;
@@ -222,9 +222,9 @@ class FontCascade {
private:
enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis };

float glyphBufferForTextRun(CodePath, const TextRun&, int from, int to, GlyphBuffer&) const;
// Returns the initial in-stream advance.
float getGlyphsAndAdvancesForSimpleText(const TextRun&, int from, int to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;
float drawSimpleText(GraphicsContext&, const TextRun&, const FloatPoint&, int from, int to) const;
void drawEmphasisMarksForSimpleText(GraphicsContext&, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, int to) const;
void drawGlyphBuffer(GraphicsContext&, const TextRun&, const GlyphBuffer&, FloatPoint&) const;
void drawEmphasisMarks(GraphicsContext&, const TextRun&, const GlyphBuffer&, const AtomicString&, const FloatPoint&) const;
@@ -239,7 +239,6 @@ class FontCascade {

// Returns the initial in-stream advance.
float getGlyphsAndAdvancesForComplexText(const TextRun&, int from, int to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;
float drawComplexText(GraphicsContext&, const TextRun&, const FloatPoint&, int from, int to) const;
void drawEmphasisMarksForComplexText(GraphicsContext&, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, int to) const;
float floatWidthForComplexText(const TextRun&, HashSet<const Font*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
int offsetForPositionForComplexText(const TextRun&, float position, bool includePartialGlyphs) const;
@@ -52,24 +52,6 @@ float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, int, i
return 0;
}

float FontCascade::drawComplexText(GraphicsContext& context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
// This glyph buffer holds our glyphs + advances + font data for each glyph.
GlyphBuffer glyphBuffer;

float startX = point.x() + getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer);

// We couldn't generate any glyphs for the run. Give up.
if (glyphBuffer.isEmpty())
return 0;

// Draw the glyph buffer now at the starting point returned in startX.
FloatPoint startPoint(startX, point.y());
drawGlyphBuffer(context, run, glyphBuffer, startPoint);

return startPoint.x() - startX;
}

void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
{
notImplemented();
@@ -642,24 +642,6 @@ virtual bool containsMorePaths() override
return initialAdvance;
}

float FontCascade::drawComplexText(GraphicsContext& context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
// This glyph buffer holds our glyphs + advances + font data for each glyph.
GlyphBuffer glyphBuffer;

float startX = point.x() + getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer);

// We couldn't generate any glyphs for the run. Give up.
if (glyphBuffer.isEmpty())
return 0;

// Draw the glyph buffer now at the starting point returned in startX.
FloatPoint startPoint(startX, point.y());
drawGlyphBuffer(context, run, glyphBuffer, startPoint);

return startPoint.x() - startX;
}

void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
{
GlyphBuffer glyphBuffer;
@@ -91,23 +91,6 @@ float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, int fr
return beforeWidth;
}

float FontCascade::drawComplexText(GraphicsContext& context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
// This glyph buffer holds our glyphs + advances + font data for each glyph.
GlyphBuffer glyphBuffer;

float startX = point.x() + getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer);

// We couldn't generate any glyphs for the run. Give up.
if (glyphBuffer.isEmpty())
return 0;

// Draw the glyph buffer now at the starting point returned in startX.
FloatPoint startPoint(startX, point.y());
drawGlyphBuffer(context, run, glyphBuffer, startPoint);
return startPoint.x() - startX;
}

void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
{
GlyphBuffer glyphBuffer;

0 comments on commit 8bf4ca2

Please sign in to comment.