diff options
Diffstat (limited to 'WebCore/platform/graphics')
-rw-r--r-- | WebCore/platform/graphics/Font.cpp | 11 | ||||
-rw-r--r-- | WebCore/platform/graphics/GlyphBuffer.h | 22 | ||||
-rw-r--r-- | WebCore/platform/graphics/WidthIterator.cpp | 24 | ||||
-rw-r--r-- | WebCore/platform/graphics/WidthIterator.h | 4 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/AffineTransformAndroid.cpp | 6 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/FontAndroid.cpp | 38 |
6 files changed, 19 insertions, 86 deletions
diff --git a/WebCore/platform/graphics/Font.cpp b/WebCore/platform/graphics/Font.cpp index a78d27b..138e322 100644 --- a/WebCore/platform/graphics/Font.cpp +++ b/WebCore/platform/graphics/Font.cpp @@ -417,9 +417,6 @@ void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const Fl WidthIterator it(this, run); it.advance(from); float beforeWidth = it.m_runWidthSoFar; -#ifdef ANDROID_GLYPHBUFFER_HAS_ADJUSTED_WIDTHS - bool adjustedWidths = -#endif it.advance(to, &glyphBuffer); // We couldn't generate any glyphs for the run. Give up. @@ -432,9 +429,6 @@ void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const Fl float finalRoundingWidth = it.m_finalRoundingWidth; it.advance(run.length()); startX += finalRoundingWidth + it.m_runWidthSoFar - afterWidth; -#ifdef ANDROID_GLYPHBUFFER_HAS_ADJUSTED_WIDTHS - adjustedWidths = true; // give up on simple/fast case -#endif } else startX += beforeWidth; @@ -443,11 +437,6 @@ void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const Fl for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end) glyphBuffer.swap(i, end); -#ifdef ANDROID_GLYPHBUFFER_HAS_ADJUSTED_WIDTHS - // mark the GlyphBuffer as having adjusted widths or not - // used by drawGlyph as an optimization hint - glyphBuffer.setHasAdjustedWidths(adjustedWidths); -#endif // Calculate the starting point of the glyphs to be displayed by adding // all the advances up to the first glyph. FloatPoint startPoint(startX, point.y()); diff --git a/WebCore/platform/graphics/GlyphBuffer.h b/WebCore/platform/graphics/GlyphBuffer.h index 110b3c2..18957d5 100644 --- a/WebCore/platform/graphics/GlyphBuffer.h +++ b/WebCore/platform/graphics/GlyphBuffer.h @@ -61,10 +61,6 @@ typedef FloatSize GlyphBufferAdvance; class GlyphBuffer { public: -#ifdef ANDROID_GLYPHBUFFER_HAS_ADJUSTED_WIDTHS - GlyphBuffer() : m_hasAdjustedWidths(true) {} -#endif - bool isEmpty() const { return m_fontData.isEmpty(); } int size() const { return m_fontData.size(); } @@ -159,18 +155,6 @@ public: #endif } -#ifdef ANDROID_GLYPHBUFFER_HAS_ADJUSTED_WIDTHS - void setHasAdjustedWidths(bool adjustedWidths) { - m_hasAdjustedWidths = adjustedWidths; - } - /** Returns true in the general case, which means that one or more of the - glyphs may have a width or height that has been changed from the raw - value returned by the font. If this returns false, then the drawing - code can use that as a hint if it means it can draw the run faster. - */ - bool hasAdjustedWidths() const { return m_hasAdjustedWidths; } -#endif - void add(Glyph glyph, const SimpleFontData* font, GlyphBufferAdvance advance) { m_fontData.append(font); @@ -192,12 +176,6 @@ private: #if PLATFORM(WIN) Vector<FloatSize, 2048> m_offsets; #endif -#ifdef ANDROID_GLYPHBUFFER_HAS_ADJUSTED_WIDTHS - // defaults to true for general case. Set to false sometimes in - // drawSimpleText as a hint to drawGlphs that the widths are exactly those - // from the font (i.e. no tweaks for rounding or CSS styling - bool m_hasAdjustedWidths; -#endif }; } diff --git a/WebCore/platform/graphics/WidthIterator.cpp b/WebCore/platform/graphics/WidthIterator.cpp index a66b234..a16d739 100644 --- a/WebCore/platform/graphics/WidthIterator.cpp +++ b/WebCore/platform/graphics/WidthIterator.cpp @@ -65,13 +65,7 @@ WidthIterator::WidthIterator(const Font* font, const TextRun& run) } } -#ifdef ANDROID_GLYPHBUFFER_HAS_ADJUSTED_WIDTHS -#define SIGNAL_ADJUSTED_WIDTHS() adjustedWidths = true -bool WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) -#else -#define SIGNAL_ADJUSTED_WIDTHS() void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) -#endif { if (offset > m_end) offset = m_end; @@ -85,9 +79,6 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) float runWidthSoFar = m_runWidthSoFar; float lastRoundingWidth = m_finalRoundingWidth; -#ifdef ANDROID_GLYPHBUFFER_HAS_ADJUSTED_WIDTHS - bool adjustedWidths = false; -#endif while (currentCharacter < offset) { UChar32 c = *cp; unsigned clusterLength = 1; @@ -129,26 +120,21 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) if (c == '\t' && m_run.allowTabs()) { float tabWidth = m_font->tabWidth(); width = tabWidth - fmodf(m_run.xPos() + runWidthSoFar, tabWidth); - SIGNAL_ADJUSTED_WIDTHS(); } else { width = fontData->widthForGlyph(glyph); -#ifndef ANDROID_NEVER_ROUND_FONT_METRICS // We special case spaces in two ways when applying word rounding. // First, we round spaces to an adjusted width in all fonts. // Second, in fixed-pitch fonts we ensure that all characters that // match the width of the space character have the same width as the space character. if (width == fontData->m_spaceWidth && (fontData->m_treatAsFixedPitch || glyph == fontData->m_spaceGlyph) && m_run.applyWordRounding()) { width = fontData->m_adjustedSpaceWidth; - SIGNAL_ADJUSTED_WIDTHS(); } -#endif } if (hasExtraSpacing) { // Account for letter-spacing. if (width && m_font->letterSpacing()) { width += m_font->letterSpacing(); - SIGNAL_ADJUSTED_WIDTHS(); } if (Font::treatAsSpace(c)) { @@ -163,14 +149,12 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) width += m_padPerSpace; m_padding -= m_padPerSpace; } - SIGNAL_ADJUSTED_WIDTHS(); } // Account for word spacing. // We apply additional space between "words" by adding width to the space character. if (currentCharacter != 0 && !Font::treatAsSpace(cp[-1]) && m_font->wordSpacing()) { width += m_font->wordSpacing(); - SIGNAL_ADJUSTED_WIDTHS(); } } } @@ -186,12 +170,10 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) float oldWidth = width; -#ifndef ANDROID_NEVER_ROUND_FONT_METRICS // Force characters that are used to determine word boundaries for the rounding hack // to be integer width, so following words will start on an integer boundary. if (m_run.applyWordRounding() && Font::isRoundingHackCharacter(c)) { width = ceilf(width); - SIGNAL_ADJUSTED_WIDTHS(); } // Check to see if the next character is a "rounding hack character", if so, adjust @@ -200,9 +182,7 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) || (m_run.applyRunRounding() && currentCharacter >= m_end)) { float totalWidth = runWidthSoFar + width; width += ceilf(totalWidth) - totalWidth; - SIGNAL_ADJUSTED_WIDTHS(); } -#endif runWidthSoFar += width; @@ -215,10 +195,6 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) m_currentCharacter = currentCharacter; m_runWidthSoFar = runWidthSoFar; m_finalRoundingWidth = lastRoundingWidth; - -#ifdef ANDROID_GLYPHBUFFER_HAS_ADJUSTED_WIDTHS - return adjustedWidths; -#endif } bool WidthIterator::advanceOneCharacter(float& width, GlyphBuffer* glyphBuffer) diff --git a/WebCore/platform/graphics/WidthIterator.h b/WebCore/platform/graphics/WidthIterator.h index a0eb26d..5706d1e 100644 --- a/WebCore/platform/graphics/WidthIterator.h +++ b/WebCore/platform/graphics/WidthIterator.h @@ -33,11 +33,7 @@ class TextRun; struct WidthIterator { WidthIterator(const Font*, const TextRun&); -#ifdef ANDROID_GLYPHBUFFER_HAS_ADJUSTED_WIDTHS - bool advance(int to, GlyphBuffer* = 0); -#else void advance(int to, GlyphBuffer* = 0); -#endif bool advanceOneCharacter(float& width, GlyphBuffer* = 0); const Font* m_font; diff --git a/WebCore/platform/graphics/android/AffineTransformAndroid.cpp b/WebCore/platform/graphics/android/AffineTransformAndroid.cpp index 6c5abae..712dea5 100644 --- a/WebCore/platform/graphics/android/AffineTransformAndroid.cpp +++ b/WebCore/platform/graphics/android/AffineTransformAndroid.cpp @@ -195,8 +195,7 @@ bool AffineTransform::operator==(const AffineTransform &m2) const AffineTransform &AffineTransform::operator*= (const AffineTransform &m2) { - // is this the correct order??? - m_transform.setConcat(m_transform, m2.m_transform); + m_transform.setConcat(m2.m_transform, m_transform); return *this; } @@ -204,8 +203,7 @@ AffineTransform AffineTransform::operator* (const AffineTransform &m2) { AffineTransform cat; - // is this the correct order??? - cat.m_transform.setConcat(m_transform, m2.m_transform); + cat.m_transform.setConcat(m2.m_transform, m_transform); return cat; } diff --git a/WebCore/platform/graphics/android/FontAndroid.cpp b/WebCore/platform/graphics/android/FontAndroid.cpp index d53c3ea..569e8db 100644 --- a/WebCore/platform/graphics/android/FontAndroid.cpp +++ b/WebCore/platform/graphics/android/FontAndroid.cpp @@ -107,35 +107,31 @@ static bool setupForText(SkPaint* paint, GraphicsContext* gc, void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const { - SkPaint paint; + SkASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t)); // compile-time assert + SkPaint paint; if (!setupForText(&paint, gc, font)) { return; } - SkCanvas* canvas = gc->platformContext()->mCanvas; - - SkASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t)); // compile-time assert - - const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from); SkScalar x = SkFloatToScalar(point.x()); SkScalar y = SkFloatToScalar(point.y()); + const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from); + const GlyphBufferAdvance* adv = glyphBuffer.advances(from); + SkAutoSTMalloc<32, SkPoint> storage(numGlyphs); + SkPoint* pos = storage.get(); + + /* We need an array of [x,y,x,y,x,y,...], but webkit is giving us + point.xy + [width, height, width, height, ...], so we have to convert + */ + for (int i = 0; i < numGlyphs; i++) { + pos[i].set(x, y); + x += SkFloatToScalar(adv[i].width()); + y += SkFloatToScalar(adv[i].height()); + } -#ifdef ANDROID_GLYPHBUFFER_HAS_ADJUSTED_WIDTHS - if (glyphBuffer.hasAdjustedWidths()) { - const GlyphBufferAdvance* adv = glyphBuffer.advances(from); - SkAutoSTMalloc<32, SkPoint> storage(numGlyphs); - SkPoint* pos = storage.get(); - - for (int i = 0; i < numGlyphs; i++) { - pos[i].set(x, y); - x += SkFloatToScalar(adv[i].width()); - y += SkFloatToScalar(adv[i].height()); - } - canvas->drawPosText(glyphs, numGlyphs << 1, pos, paint); - } else -#endif - canvas->drawText(glyphs, numGlyphs << 1, x, y, paint); + SkCanvas* canvas = gc->platformContext()->mCanvas; + canvas->drawPosText(glyphs, numGlyphs * sizeof(*glyphs), pos, paint); } FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int, int) const |