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

Unified Diff: Source/platform/fonts/GlyphBuffer.h

Issue 645363003: Consolidate most simple vs. complex Font methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: minor cleanup Created 6 years, 2 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
« no previous file with comments | « Source/platform/fonts/Font.cpp ('k') | Source/platform/fonts/GlyphBufferTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/GlyphBuffer.h
diff --git a/Source/platform/fonts/GlyphBuffer.h b/Source/platform/fonts/GlyphBuffer.h
index 5f8d2b48782bd4071d25ef88537484a8823002c1..9ccd92ab1c360e70a8bd603f02ea2b9397178215 100644
--- a/Source/platform/fonts/GlyphBuffer.h
+++ b/Source/platform/fonts/GlyphBuffer.h
@@ -43,12 +43,17 @@ class GlyphBuffer {
STACK_ALLOCATED();
public:
bool isEmpty() const { return m_fontData.isEmpty(); }
- virtual bool hasOffsets() const { return false; }
+ bool hasOffsets() const { return !m_offsets.isEmpty(); }
unsigned size() const { return m_fontData.size(); }
const Glyph* glyphs(unsigned from) const { return m_glyphs.data() + from; }
const float* advances(unsigned from) const { return m_advances.data() + from; }
- const SimpleFontData* fontDataAt(unsigned index) const { return m_fontData[index]; }
+ const FloatSize* offsets(unsigned from) const { return m_offsets.data() + from; }
+
+ const SimpleFontData* fontDataAt(unsigned index) const
+ {
+ return m_fontData[index];
+ }
Glyph glyphAt(unsigned index) const
{
@@ -62,11 +67,25 @@ public:
void add(Glyph glyph, const SimpleFontData* font, float width)
{
+ // should not mix offset/advance-only glyphs
+ ASSERT(!hasOffsets());
+
m_fontData.append(font);
m_glyphs.append(glyph);
m_advances.append(width);
}
+ void add(Glyph glyph, const SimpleFontData* font, const FloatSize& offset, float advance)
+ {
+ // should not mix offset/advance-only glyphs
+ ASSERT(size() == m_offsets.size());
+
+ m_fontData.append(font);
+ m_glyphs.append(glyph);
+ m_offsets.append(offset);
+ m_advances.append(advance);
+ }
+
void reverse()
{
m_fontData.reverse();
@@ -85,39 +104,6 @@ protected:
Vector<const SimpleFontData*, 2048> m_fontData;
Vector<Glyph, 2048> m_glyphs;
Vector<float, 2048> m_advances;
-};
-
-
-class GlyphBufferWithOffsets : public GlyphBuffer {
-public:
- virtual bool hasOffsets() const override { return true; }
-
- const FloatSize* offsets(unsigned from) const { return m_offsets.data() + from; }
-
- FloatSize offsetAt(unsigned index) const
- {
- return m_offsets[index];
- }
-
- void add(Glyph glyph, const SimpleFontData* font, const FloatSize& offset, float advance)
- {
- m_fontData.append(font);
- m_glyphs.append(glyph);
- m_offsets.append(offset);
- m_advances.append(advance);
- }
-
-private:
- void add(Glyph glyph, const SimpleFontData* font, float width)
- {
- ASSERT_NOT_REACHED();
- }
-
- void reverse()
- {
- ASSERT_NOT_REACHED();
- }
-
Vector<FloatSize, 1024> m_offsets;
};
« no previous file with comments | « Source/platform/fonts/Font.cpp ('k') | Source/platform/fonts/GlyphBufferTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698