summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/chromium/FontChromiumWin.cpp')
-rw-r--r--WebCore/platform/graphics/chromium/FontChromiumWin.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/WebCore/platform/graphics/chromium/FontChromiumWin.cpp b/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
index 1b71946..4710245 100644
--- a/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
+++ b/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
@@ -249,10 +249,28 @@ bool TransparencyAwareGlyphPainter::drawGlyphs(int numGlyphs,
// to subtract off the font ascent to get it.
int x = lroundf(m_point.x() + startAdvance);
int y = lroundf(m_point.y() - m_font->ascent());
+
+ // If there is a non-blur shadow and both the fill color and shadow color
+ // are opaque, handle without skia.
+ IntSize shadowSize;
+ int shadowBlur;
+ Color shadowColor;
+ if (m_graphicsContext->getShadow(shadowSize, shadowBlur, shadowColor)) {
+ // If there is a shadow and this code is reached, windowsCanHandleDrawTextShadow()
+ // will have already returned true during the ctor initiatization of m_useGDI
+ ASSERT(shadowColor.alpha() == 255);
+ ASSERT(m_graphicsContext->fillColor().alpha() == 255);
+ ASSERT(shadowBlur == 0);
+ COLORREF textColor = skia::SkColorToCOLORREF(SkColorSetARGB(255, shadowColor.red(), shadowColor.green(), shadowColor.blue()));
+ COLORREF savedTextColor = GetTextColor(m_hdc);
+ SetTextColor(m_hdc, textColor);
+ ExtTextOut(m_hdc, x + shadowSize.width(), y + shadowSize.height(), ETO_GLYPH_INDEX, 0, reinterpret_cast<const wchar_t*>(&glyphs[0]), numGlyphs, &advances[0]);
+ SetTextColor(m_hdc, savedTextColor);
+ }
+
return !!ExtTextOut(m_hdc, x, y, ETO_GLYPH_INDEX, 0, reinterpret_cast<const wchar_t*>(&glyphs[0]), numGlyphs, &advances[0]);
}
-
class TransparencyAwareUniscribePainter : public TransparencyAwareFontPainter {
public:
TransparencyAwareUniscribePainter(GraphicsContext*,
@@ -305,6 +323,10 @@ IntRect TransparencyAwareUniscribePainter::estimateTextBounds()
UniscribeHelperTextRun state(m_run, *m_font);
int left = lroundf(m_point.x()) + state.characterToX(m_from);
int right = lroundf(m_point.x()) + state.characterToX(m_to);
+
+ // Adjust for RTL script since we just want to know the text bounds.
+ if (left > right)
+ std::swap(left, right);
// This algorithm for estimating how much extra space we need (the text may
// go outside the selection rect) is based roughly on
@@ -317,6 +339,11 @@ IntRect TransparencyAwareUniscribePainter::estimateTextBounds()
} // namespace
+bool Font::canReturnFallbackFontsForComplexText()
+{
+ return false;
+}
+
void Font::drawGlyphs(GraphicsContext* graphicsContext,
const SimpleFontData* font,
const GlyphBuffer& glyphBuffer,
@@ -416,6 +443,20 @@ void Font::drawComplexText(GraphicsContext* graphicsContext,
SetTextColor(hdc, skia::SkColorToCOLORREF(color));
SetBkMode(hdc, TRANSPARENT);
+ // If there is a non-blur shadow and both the fill color and shadow color
+ // are opaque, handle without skia.
+ IntSize shadowSize;
+ int shadowBlur;
+ Color shadowColor;
+ if (graphicsContext->getShadow(shadowSize, shadowBlur, shadowColor) && windowsCanHandleDrawTextShadow(graphicsContext)) {
+ COLORREF textColor = skia::SkColorToCOLORREF(SkColorSetARGB(255, shadowColor.red(), shadowColor.green(), shadowColor.blue()));
+ COLORREF savedTextColor = GetTextColor(hdc);
+ SetTextColor(hdc, textColor);
+ state.draw(graphicsContext, hdc, static_cast<int>(point.x()) + shadowSize.width(),
+ static_cast<int>(point.y() - ascent()) + shadowSize.height(), from, to);
+ SetTextColor(hdc, savedTextColor);
+ }
+
// Uniscribe counts the coordinates from the upper left, while WebKit uses
// the baseline, so we have to subtract off the ascent.
state.draw(graphicsContext, hdc, static_cast<int>(point.x()),
@@ -424,7 +465,7 @@ void Font::drawComplexText(GraphicsContext* graphicsContext,
context->canvas()->endPlatformPaint();
}
-float Font::floatWidthForComplexText(const TextRun& run) const
+float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* /* fallbackFonts */) const
{
UniscribeHelperTextRun state(run, *this);
return static_cast<float>(state.width());