summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2012-10-02 16:53:55 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-02 16:53:55 -0700
commite70c8a5ad2ef1ce0804b27608fd96b825fc4ee95 (patch)
treeeb1b7657722eff7f3def50a687872b7b68f0986c
parent42326004062d6b846c3050ad03a1e80fa9db425c (diff)
parent85fb59060a0fdfcff93ae1c70dd49e0f93e55ab6 (diff)
downloadexternal_webkit-e70c8a5ad2ef1ce0804b27608fd96b825fc4ee95.zip
external_webkit-e70c8a5ad2ef1ce0804b27608fd96b825fc4ee95.tar.gz
external_webkit-e70c8a5ad2ef1ce0804b27608fd96b825fc4ee95.tar.bz2
Merge "Compensate for canvas-side vertical text translation in bounding box computation" into jb-mr1-dev
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h1
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h2
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h1
-rw-r--r--Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp10
5 files changed, 14 insertions, 2 deletions
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h
index 56aceff..14537c8 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h
@@ -148,6 +148,7 @@ public:
const IntRect& thumb = IntRect()) = 0;
virtual SkCanvas* recordingCanvas() = 0;
+ virtual void setTextOffset(FloatSize offset) = 0;
void setRawState(State* state) { m_state = state; }
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
index c865a54..a410ba9 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
@@ -917,6 +917,8 @@ void PlatformGraphicsContextRecording::drawPosText(const void* inText, size_t by
return;
}
FloatRect bounds = approximateTextBounds(byteLength / sizeof(uint16_t), inPos, inPaint);
+ bounds.move(m_textOffset); // compensate font rendering-side translates
+
const SkPaint* paint = mRecording->recording()->getSkPaint(inPaint);
size_t posSize = sizeof(SkPoint) * paint->countText(inText, byteLength);
void* text = heap()->alloc(byteLength);
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
index 930f1f2..a8e69f5 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
@@ -64,6 +64,7 @@ public:
virtual bool isPaintingDisabled();
virtual SkCanvas* recordingCanvas();
+ virtual void setTextOffset(FloatSize offset) { m_textOffset = offset; }
virtual ContextType type() { return RecordingContext; }
@@ -209,6 +210,7 @@ private:
float m_maxZoomScale;
bool m_isEmpty;
RecordingContextCanvasProxy m_canvasProxy;
+ FloatSize m_textOffset;
};
}
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h
index 6bf53d7..2c1d8cb 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h
@@ -39,6 +39,7 @@ public:
virtual ContextType type() { return PaintingContext; }
virtual SkCanvas* recordingCanvas() { return mCanvas; }
+ virtual void setTextOffset(FloatSize offset) {}
// FIXME: This is used by ImageBufferAndroid, which should really be
// managing the canvas lifecycle itself
diff --git a/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp
index fcb78ed..03d2fb2 100644
--- a/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp
@@ -218,8 +218,11 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
point.xy + [width, height, width, height, ...], so we have to convert
*/
- if (font->platformData().orientation() == Vertical)
- y += SkFloatToScalar(font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent());
+ if (font->platformData().orientation() == Vertical) {
+ float yOffset = SkFloatToScalar(font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent());
+ gc->platformContext()->setTextOffset(FloatSize(0.0f, -yOffset)); // compensate for offset in bounds calculation
+ y += yOffset;
+ }
if (EmojiFont::IsAvailable()) {
// set filtering, to make scaled images look nice(r)
@@ -272,6 +275,9 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
if (font->platformData().orientation() == Vertical)
canvas->restore();
}
+
+ if (font->platformData().orientation() == Vertical)
+ gc->platformContext()->setTextOffset(FloatSize()); // reset to undo above
}
void Font::drawEmphasisMarksForComplexText(WebCore::GraphicsContext*, WebCore::TextRun const&, WTF::AtomicString const&, WebCore::FloatPoint const&, int, int) const