Commit b2f8f96c authored by jbroman@chromium.org's avatar jbroman@chromium.org

Consolidate Glyph and GlyphBufferGlyph.

These are always equivalent since the WinCE case was dropped over a year ago:
https://chromiumcodereview.appspot.com/13901012

BUG=383594

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

git-svn-id: svn://svn.chromium.org/blink/trunk@176039 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent eb2df272
...@@ -42,8 +42,6 @@ namespace WebCore { ...@@ -42,8 +42,6 @@ namespace WebCore {
class SimpleFontData; class SimpleFontData;
typedef Glyph GlyphBufferGlyph;
// CG uses CGSize instead of FloatSize so that the result of advances() // CG uses CGSize instead of FloatSize so that the result of advances()
// can be passed directly to CGContextShowGlyphsWithAdvances in FontMac.mm // can be passed directly to CGContextShowGlyphsWithAdvances in FontMac.mm
#if OS(MACOSX) #if OS(MACOSX)
...@@ -73,9 +71,9 @@ public: ...@@ -73,9 +71,9 @@ public:
m_advances.clear(); m_advances.clear();
} }
GlyphBufferGlyph* glyphs(unsigned from) { return m_glyphs.data() + from; } Glyph* glyphs(unsigned from) { return m_glyphs.data() + from; }
GlyphBufferAdvance* advances(unsigned from) { return m_advances.data() + from; } GlyphBufferAdvance* advances(unsigned from) { return m_advances.data() + from; }
const GlyphBufferGlyph* glyphs(unsigned from) const { return m_glyphs.data() + from; } const Glyph* glyphs(unsigned from) const { return m_glyphs.data() + from; }
const GlyphBufferAdvance* advances(unsigned from) const { return m_advances.data() + from; } const GlyphBufferAdvance* advances(unsigned from) const { return m_advances.data() + from; }
const SimpleFontData* fontDataAt(unsigned index) const { return m_fontData[index]; } const SimpleFontData* fontDataAt(unsigned index) const { return m_fontData[index]; }
...@@ -134,7 +132,7 @@ private: ...@@ -134,7 +132,7 @@ private:
m_fontData[index1] = m_fontData[index2]; m_fontData[index1] = m_fontData[index2];
m_fontData[index2] = f; m_fontData[index2] = f;
GlyphBufferGlyph g = m_glyphs[index1]; Glyph g = m_glyphs[index1];
m_glyphs[index1] = m_glyphs[index2]; m_glyphs[index1] = m_glyphs[index2];
m_glyphs[index2] = g; m_glyphs[index2] = g;
...@@ -144,7 +142,7 @@ private: ...@@ -144,7 +142,7 @@ private:
} }
Vector<const SimpleFontData*, 2048> m_fontData; Vector<const SimpleFontData*, 2048> m_fontData;
Vector<GlyphBufferGlyph, 2048> m_glyphs; Vector<Glyph, 2048> m_glyphs;
Vector<GlyphBufferAdvance, 2048> m_advances; Vector<GlyphBufferAdvance, 2048> m_advances;
}; };
......
...@@ -57,7 +57,7 @@ bool FontPlatformFeatures::canExpandAroundIdeographsInComplexText() ...@@ -57,7 +57,7 @@ bool FontPlatformFeatures::canExpandAroundIdeographsInComplexText()
} }
static void paintGlyphs(GraphicsContext* gc, const SimpleFontData* font, static void paintGlyphs(GraphicsContext* gc, const SimpleFontData* font,
const GlyphBufferGlyph* glyphs, unsigned numGlyphs, const Glyph* glyphs, unsigned numGlyphs,
SkPoint* pos, const FloatRect& textRect) SkPoint* pos, const FloatRect& textRect)
{ {
TextDrawingModeFlags textMode = gc->textDrawingMode(); TextDrawingModeFlags textMode = gc->textDrawingMode();
...@@ -69,7 +69,7 @@ static void paintGlyphs(GraphicsContext* gc, const SimpleFontData* font, ...@@ -69,7 +69,7 @@ static void paintGlyphs(GraphicsContext* gc, const SimpleFontData* font,
gc->adjustTextRenderMode(&paint); gc->adjustTextRenderMode(&paint);
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
gc->drawPosText(glyphs, numGlyphs << 1, pos, textRect, paint); gc->drawPosText(glyphs, numGlyphs * sizeof(Glyph), pos, textRect, paint);
} }
if ((textMode & TextModeStroke) if ((textMode & TextModeStroke)
...@@ -94,7 +94,7 @@ static void paintGlyphs(GraphicsContext* gc, const SimpleFontData* font, ...@@ -94,7 +94,7 @@ static void paintGlyphs(GraphicsContext* gc, const SimpleFontData* font,
paint.setLooper(0); paint.setLooper(0);
} }
gc->drawPosText(glyphs, numGlyphs << 1, pos, textRect, paint); gc->drawPosText(glyphs, numGlyphs * sizeof(Glyph), pos, textRect, paint);
} }
} }
...@@ -102,8 +102,6 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, ...@@ -102,8 +102,6 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs,
const FloatPoint& point, const FloatRect& textRect) const const FloatPoint& point, const FloatRect& textRect) const
{ {
SkASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t)); // compile-time assert
SkScalar x = SkFloatToScalar(point.x()); SkScalar x = SkFloatToScalar(point.x());
SkScalar y = SkFloatToScalar(point.y()); SkScalar y = SkFloatToScalar(point.y());
...@@ -127,7 +125,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, ...@@ -127,7 +125,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
while (glyphIndex < numGlyphs) { while (glyphIndex < numGlyphs) {
unsigned chunkLength = std::min(kMaxBufferLength, numGlyphs - glyphIndex); unsigned chunkLength = std::min(kMaxBufferLength, numGlyphs - glyphIndex);
const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from + glyphIndex); const Glyph* glyphs = glyphBuffer.glyphs(from + glyphIndex);
translations.resize(chunkLength); translations.resize(chunkLength);
verticalData->getVerticalTranslationsForGlyphs(font, &glyphs[0], chunkLength, reinterpret_cast<float*>(&translations[0])); verticalData->getVerticalTranslationsForGlyphs(font, &glyphs[0], chunkLength, reinterpret_cast<float*>(&translations[0]));
...@@ -162,7 +160,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, ...@@ -162,7 +160,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
y += SkFloatToScalar(adv[i].height()); y += SkFloatToScalar(adv[i].height());
} }
const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from); const Glyph* glyphs = glyphBuffer.glyphs(from);
paintGlyphs(gc, font, glyphs, numGlyphs, pos, textRect); paintGlyphs(gc, font, glyphs, numGlyphs, pos, textRect);
} }
......
...@@ -1001,7 +1001,7 @@ void HarfBuzzShaper::fillGlyphBufferForTextEmphasis(GlyphBuffer* glyphBuffer, Ha ...@@ -1001,7 +1001,7 @@ void HarfBuzzShaper::fillGlyphBufferForTextEmphasis(GlyphBuffer* glyphBuffer, Ha
float glyphAdvanceX = clusterAdvance / graphemesInCluster; float glyphAdvanceX = clusterAdvance / graphemesInCluster;
for (unsigned j = 0; j < graphemesInCluster; ++j) { for (unsigned j = 0; j < graphemesInCluster; ++j) {
// Do not put emphasis marks on space, separator, and control characters. // Do not put emphasis marks on space, separator, and control characters.
GlyphBufferGlyph glyphToAdd = Character::canReceiveTextEmphasis(m_run[currentCharacterIndex]) ? 1 : 0; Glyph glyphToAdd = Character::canReceiveTextEmphasis(m_run[currentCharacterIndex]) ? 1 : 0;
glyphBuffer->add(glyphToAdd, currentRun->fontData(), createGlyphBufferAdvance(glyphAdvanceX, 0)); glyphBuffer->add(glyphToAdd, currentRun->fontData(), createGlyphBufferAdvance(glyphAdvanceX, 0));
} }
clusterStart = clusterEnd; clusterStart = clusterEnd;
......
...@@ -83,8 +83,6 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, ...@@ -83,8 +83,6 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs,
const FloatPoint& point, const FloatRect& textRect) const const FloatPoint& point, const FloatRect& textRect) const
{ {
COMPILE_ASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t), GlyphBufferGlyphSize_equals_uint16_t);
bool shouldSmoothFonts = true; bool shouldSmoothFonts = true;
bool shouldAntialias = true; bool shouldAntialias = true;
...@@ -108,7 +106,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, ...@@ -108,7 +106,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
shouldAntialias = shouldAntialias && isFontAntialiasingEnabledForTest(); shouldAntialias = shouldAntialias && isFontAntialiasingEnabledForTest();
} }
const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from); const Glyph* glyphs = glyphBuffer.glyphs(from);
SkScalar x = SkFloatToScalar(point.x()); SkScalar x = SkFloatToScalar(point.x());
SkScalar y = SkFloatToScalar(point.y()); SkScalar y = SkFloatToScalar(point.y());
...@@ -147,7 +145,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, ...@@ -147,7 +145,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
gc->adjustTextRenderMode(&paint); gc->adjustTextRenderMode(&paint);
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
gc->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, textRect, paint); gc->drawPosText(glyphs, numGlyphs * sizeof(Glyph), pos, textRect, paint);
} }
if ((textMode & TextModeStroke) if ((textMode & TextModeStroke)
...@@ -165,7 +163,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, ...@@ -165,7 +163,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
paint.setLooper(0); paint.setLooper(0);
} }
gc->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, textRect, paint); gc->drawPosText(glyphs, numGlyphs * sizeof(Glyph), pos, textRect, paint);
} }
if (font->platformData().orientation() == Vertical) if (font->platformData().orientation() == Vertical)
gc->restore(); gc->restore();
......
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