summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/win
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/win')
-rw-r--r--WebCore/platform/graphics/win/FontCGWin.cpp24
-rw-r--r--WebCore/platform/graphics/win/FontWin.cpp51
-rw-r--r--WebCore/platform/graphics/win/GraphicsContextCGWin.cpp9
-rw-r--r--WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp10
-rw-r--r--WebCore/platform/graphics/win/GraphicsLayerCACF.cpp5
-rw-r--r--WebCore/platform/graphics/win/GraphicsLayerCACF.h3
-rw-r--r--WebCore/platform/graphics/win/SimpleFontDataWin.cpp46
-rw-r--r--WebCore/platform/graphics/win/UniscribeController.cpp2
-rw-r--r--WebCore/platform/graphics/win/cairo/FontPlatformData.h8
9 files changed, 107 insertions, 51 deletions
diff --git a/WebCore/platform/graphics/win/FontCGWin.cpp b/WebCore/platform/graphics/win/FontCGWin.cpp
index 2f1fb41..8012722 100644
--- a/WebCore/platform/graphics/win/FontCGWin.cpp
+++ b/WebCore/platform/graphics/win/FontCGWin.cpp
@@ -133,8 +133,8 @@ static void drawGDIGlyphs(GraphicsContext* graphicsContext, const SimpleFontData
Color fillColor = graphicsContext->fillColor();
bool drawIntoBitmap = false;
- int drawingMode = graphicsContext->textDrawingMode();
- if (drawingMode == cTextFill) {
+ TextDrawingModeFlags drawingMode = graphicsContext->textDrawingMode();
+ if (drawingMode == TextModeFill) {
if (!fillColor.alpha())
return;
@@ -143,7 +143,9 @@ static void drawGDIGlyphs(GraphicsContext* graphicsContext, const SimpleFontData
FloatSize offset;
float blur;
Color color;
- graphicsContext->getShadow(offset, blur, color);
+ ColorSpace shadowColorSpace;
+
+ graphicsContext->getShadow(offset, blur, color, shadowColorSpace);
drawIntoBitmap = offset.width() || offset.height() || blur;
}
}
@@ -205,7 +207,7 @@ static void drawGDIGlyphs(GraphicsContext* graphicsContext, const SimpleFontData
ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY);
}
- if (drawingMode == cTextFill) {
+ if (drawingMode == TextModeFill) {
XFORM xform;
xform.eM11 = 1.0;
xform.eM12 = 0;
@@ -247,7 +249,7 @@ static void drawGDIGlyphs(GraphicsContext* graphicsContext, const SimpleFontData
CGContextSaveGState(cgContext);
CGContextConcatCTM(cgContext, initialGlyphTransform);
- if (drawingMode & cTextFill) {
+ if (drawingMode & TextModeFill) {
CGContextAddPath(cgContext, glyphPath.get());
CGContextFillPath(cgContext);
if (font->syntheticBoldOffset()) {
@@ -257,7 +259,7 @@ static void drawGDIGlyphs(GraphicsContext* graphicsContext, const SimpleFontData
CGContextTranslateCTM(cgContext, -font->syntheticBoldOffset(), 0);
}
}
- if (drawingMode & cTextStroke) {
+ if (drawingMode & TextModeStroke) {
CGContextAddPath(cgContext, glyphPath.get());
CGContextStrokePath(cgContext);
if (font->syntheticBoldOffset()) {
@@ -352,16 +354,20 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* fo
FloatSize shadowOffset;
float shadowBlur;
Color shadowColor;
- graphicsContext->getShadow(shadowOffset, shadowBlur, shadowColor);
+ ColorSpace shadowColorSpace;
+ graphicsContext->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
- bool hasSimpleShadow = graphicsContext->textDrawingMode() == cTextFill && shadowColor.isValid() && !shadowBlur;
+ bool hasSimpleShadow = graphicsContext->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && (!graphicsContext->shadowsIgnoreTransforms() || graphicsContext->getCTM().isIdentityOrTranslationOrFlipped());
if (hasSimpleShadow) {
// Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
graphicsContext->clearShadow();
Color fillColor = graphicsContext->fillColor();
Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
graphicsContext->setFillColor(shadowFillColor, ColorSpaceDeviceRGB);
- CGContextSetTextPosition(cgContext, point.x() + translation.width() + shadowOffset.width(), point.y() + translation.height() + shadowOffset.height());
+ float shadowTextX = point.x() + translation.width() + shadowOffset.width();
+ // If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative.
+ float shadowTextY = point.y() + translation.height() + shadowOffset.height() * (graphicsContext->shadowsIgnoreTransforms() ? -1 : 1);
+ CGContextSetTextPosition(cgContext, shadowTextX, shadowTextY);
CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
if (font->syntheticBoldOffset()) {
CGContextSetTextPosition(cgContext, point.x() + translation.width() + shadowOffset.width() + font->syntheticBoldOffset(), point.y() + translation.height() + shadowOffset.height());
diff --git a/WebCore/platform/graphics/win/FontWin.cpp b/WebCore/platform/graphics/win/FontWin.cpp
index 97971dc..2170954 100644
--- a/WebCore/platform/graphics/win/FontWin.cpp
+++ b/WebCore/platform/graphics/win/FontWin.cpp
@@ -30,6 +30,7 @@
#include "GlyphBuffer.h"
#include "GraphicsContext.h"
#include "IntRect.h"
+#include "Logging.h"
#include "SimpleFontData.h"
#include "UniscribeController.h"
#include <wtf/MathExtras.h>
@@ -62,33 +63,57 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint
return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
}
-void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point,
- int from, int to) const
+float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
{
- // This glyph buffer holds our glyphs + advances + font data for each glyph.
- GlyphBuffer glyphBuffer;
+ if (forTextEmphasis) {
+ // FIXME: Add forTextEmphasis paremeter to UniscribeController and use it.
+ LOG_ERROR("Not implemented for text emphasis.");
+ return 0;
+ }
- float startX = point.x();
UniscribeController controller(this, run);
controller.advance(from);
float beforeWidth = controller.runWidthSoFar();
controller.advance(to, &glyphBuffer);
-
- // We couldn't generate any glyphs for the run. Give up.
+
if (glyphBuffer.isEmpty())
- return;
-
+ return 0;
+
float afterWidth = controller.runWidthSoFar();
if (run.rtl()) {
controller.advance(run.length());
- startX += controller.runWidthSoFar() - afterWidth;
- } else
- startX += beforeWidth;
+ return controller.runWidthSoFar() - afterWidth;
+ }
+ return beforeWidth;
+}
+
+void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point,
+ int from, int to) const
+{
+ // This glyph buffer holds our glyphs + advances + font data for each glyph.
+ GlyphBuffer glyphBuffer;
+
+ float startX = point.x() + getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer);
+
+ // We couldn't generate any glyphs for the run. Give up.
+ if (glyphBuffer.isEmpty())
+ return;
// Draw the glyph buffer now at the starting point returned in startX.
FloatPoint startPoint(startX, point.y());
- drawGlyphBuffer(context, glyphBuffer, run, startPoint);
+ drawGlyphBuffer(context, glyphBuffer, startPoint);
+}
+
+void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
+{
+ GlyphBuffer glyphBuffer;
+ float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis);
+
+ if (glyphBuffer.isEmpty())
+ return;
+
+ drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
}
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
diff --git a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
index 1ad6bc1..b42e51c 100644
--- a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
+++ b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
@@ -62,9 +62,14 @@ static CGContextRef CGContextWithHDC(HDC hdc, bool hasAlpha)
}
GraphicsContext::GraphicsContext(HDC hdc, bool hasAlpha)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate(CGContextWithHDC(hdc, hasAlpha)))
+ : m_updatingControlTints(false)
{
+ platformInit(hdc, hasAlpha);
+}
+
+void GraphicsContext::platformInit(HDC hdc, bool hasAlpha)
+{
+ m_data = new GraphicsContextPlatformPrivate(CGContextWithHDC(hdc, hasAlpha));
CGContextRelease(m_data->m_cgContext.get());
m_data->m_hdc = hdc;
setPaintingDisabled(!m_data->m_cgContext);
diff --git a/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp b/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
index a989c24..b2c702f 100644
--- a/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
+++ b/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
@@ -65,9 +65,15 @@ static cairo_t* createCairoContextWithHDC(HDC hdc, bool hasAlpha)
}
GraphicsContext::GraphicsContext(HDC dc, bool hasAlpha)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate)
+ : m_updatingControlTints(false)
{
+ platformInit(dc, hasAlpha);
+}
+
+void GraphicsContext::platformInit(HDC dc, bool hasAlpha)
+{
+ m_data = new GraphicsContextPlatformPrivate;
+
if (dc) {
m_data->cr = createCairoContextWithHDC(dc, hasAlpha);
m_data->m_hdc = dc;
diff --git a/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp b/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp
index f7674db..984fd3f 100644
--- a/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp
+++ b/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp
@@ -153,11 +153,6 @@ void GraphicsLayerCACF::setName(const String& name)
m_layer->setName(longName);
}
-NativeLayer GraphicsLayerCACF::nativeLayer() const
-{
- return m_layer.get();
-}
-
bool GraphicsLayerCACF::setChildren(const Vector<GraphicsLayer*>& children)
{
bool childrenChanged = GraphicsLayer::setChildren(children);
diff --git a/WebCore/platform/graphics/win/GraphicsLayerCACF.h b/WebCore/platform/graphics/win/GraphicsLayerCACF.h
index c18a6e9..23f36b2 100644
--- a/WebCore/platform/graphics/win/GraphicsLayerCACF.h
+++ b/WebCore/platform/graphics/win/GraphicsLayerCACF.h
@@ -44,9 +44,6 @@ public:
virtual void setName(const String& inName);
- // for hosting this GraphicsLayer in a native layer hierarchy
- virtual NativeLayer nativeLayer() const;
-
virtual bool setChildren(const Vector<GraphicsLayer*>&);
virtual void addChild(GraphicsLayer *layer);
virtual void addChildAtIndex(GraphicsLayer *layer, int index);
diff --git a/WebCore/platform/graphics/win/SimpleFontDataWin.cpp b/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
index 6d1d777..60afe6a 100644
--- a/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
+++ b/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
@@ -110,24 +110,40 @@ void SimpleFontData::platformDestroy()
delete m_scriptFontProperties;
}
-SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
+SimpleFontData* SimpleFontData::scaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
- if (!m_smallCapsFontData) {
- float smallCapsHeight = cSmallCapsFontSizeMultiplier * m_platformData.size();
+ float scaledSize = scaleFactor * m_platformData.size();
if (isCustomFont()) {
- FontPlatformData smallCapsFontData(m_platformData);
- smallCapsFontData.setSize(smallCapsHeight);
- m_smallCapsFontData = new SimpleFontData(smallCapsFontData, true, false);
- } else {
- LOGFONT winfont;
- GetObject(m_platformData.hfont(), sizeof(LOGFONT), &winfont);
- winfont.lfHeight = -lroundf(smallCapsHeight * (m_platformData.useGDI() ? 1 : 32));
- HFONT hfont = CreateFontIndirect(&winfont);
- m_smallCapsFontData = new SimpleFontData(FontPlatformData(hfont, smallCapsHeight, m_platformData.syntheticBold(), m_platformData.syntheticOblique(), m_platformData.useGDI()),
- isCustomFont(), false);
+ FontPlatformData scaledFont(m_platformData);
+ scaledFont.setSize(scaledSize);
+ return new SimpleFontData(scaledFont, true, false);
}
- }
- return m_smallCapsFontData;
+
+ LOGFONT winfont;
+ GetObject(m_platformData.hfont(), sizeof(LOGFONT), &winfont);
+ winfont.lfHeight = -lroundf(scaledSize * (m_platformData.useGDI() ? 1 : 32));
+ HFONT hfont = CreateFontIndirect(&winfont);
+ return new SimpleFontData(FontPlatformData(hfont, scaledSize, m_platformData.syntheticBold(), m_platformData.syntheticOblique(), m_platformData.useGDI()), isCustomFont(), false);
+}
+
+SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
+{
+ if (!m_derivedFontData)
+ m_derivedFontData = DerivedFontData::create(isCustomFont());
+ if (!m_derivedFontData->smallCaps)
+ m_derivedFontData->smallCaps = scaledFontData(fontDescription, cSmallCapsFontSizeMultiplier);
+
+ return m_derivedFontData->smallCaps.get();
+}
+
+SimpleFontData* SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
+{
+ if (!m_derivedFontData)
+ m_derivedFontData = DerivedFontData::create(isCustomFont());
+ if (!m_derivedFontData->emphasisMark)
+ m_derivedFontData->emphasisMark = scaledFontData(fontDescription, .5);
+
+ return m_derivedFontData->emphasisMark.get();
}
bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
diff --git a/WebCore/platform/graphics/win/UniscribeController.cpp b/WebCore/platform/graphics/win/UniscribeController.cpp
index d0acac2..ab32150 100644
--- a/WebCore/platform/graphics/win/UniscribeController.cpp
+++ b/WebCore/platform/graphics/win/UniscribeController.cpp
@@ -145,7 +145,7 @@ void UniscribeController::advance(unsigned offset, GlyphBuffer* glyphBuffer)
UChar c = *curr;
bool forceSmallCaps = isSmallCaps && (U_GET_GC_MASK(c) & U_GC_M_MASK);
- nextFontData = m_font.glyphDataForCharacter(*curr, false, forceSmallCaps).fontData;
+ nextFontData = m_font.glyphDataForCharacter(*curr, false, forceSmallCaps ? SmallCapsVariant : AutoVariant).fontData;
if (m_font.isSmallCaps()) {
nextIsSmallCaps = forceSmallCaps || (newC = u_toupper(c)) != c;
if (nextIsSmallCaps)
diff --git a/WebCore/platform/graphics/win/cairo/FontPlatformData.h b/WebCore/platform/graphics/win/cairo/FontPlatformData.h
index 05f9eab..d8f538a 100644
--- a/WebCore/platform/graphics/win/cairo/FontPlatformData.h
+++ b/WebCore/platform/graphics/win/cairo/FontPlatformData.h
@@ -3,6 +3,7 @@
* Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
* Copyright (C) 2007 Holger Hans Peter Freyther
* Copyright (C) 2007 Pioneer Research Center USA, Inc.
+ * Copyright (C) 2010 Brent Fulgham <bfulgham@webkit.org>
* All rights reserved.
*
* This library is free software; you can redistribute it and/or
@@ -25,7 +26,7 @@
#ifndef FontPlatformDataCairoWin_h
#define FontPlatformDataCairoWin_h
-#include "FontDescription.h"
+#include "FontOrientation.h"
#include "GlyphBuffer.h"
#include "RefCountedGDIHandle.h"
#include "StringImpl.h"
@@ -37,6 +38,8 @@ typedef struct HFONT__* HFONT;
namespace WebCore {
+class FontDescription;
+
class FontPlatformData {
public:
FontPlatformData(WTF::HashTableDeletedValueType)
@@ -73,6 +76,9 @@ public:
void setSize(float size) { m_size = size; }
bool syntheticBold() const { return m_syntheticBold; }
bool syntheticOblique() const { return m_syntheticOblique; }
+
+ FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
+
cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
unsigned hash() const