summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/qt
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/qt')
-rw-r--r--WebCore/platform/graphics/qt/ContextShadowQt.cpp33
-rw-r--r--WebCore/platform/graphics/qt/Extensions3DQt.cpp5
-rw-r--r--WebCore/platform/graphics/qt/Extensions3DQt.h1
-rw-r--r--WebCore/platform/graphics/qt/FontPlatformData.h10
-rw-r--r--WebCore/platform/graphics/qt/FontPlatformDataQt.cpp8
-rw-r--r--WebCore/platform/graphics/qt/FontQt.cpp55
-rw-r--r--WebCore/platform/graphics/qt/GraphicsContextQt.cpp348
-rw-r--r--WebCore/platform/graphics/qt/GraphicsLayerQt.cpp9
-rw-r--r--WebCore/platform/graphics/qt/GraphicsLayerQt.h1
-rw-r--r--WebCore/platform/graphics/qt/ImageBufferQt.cpp2
-rw-r--r--WebCore/platform/graphics/qt/ImageDecoderQt.cpp8
-rw-r--r--WebCore/platform/graphics/qt/ImageDecoderQt.h2
-rw-r--r--WebCore/platform/graphics/qt/ImageQt.cpp4
-rw-r--r--WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp5
-rw-r--r--WebCore/platform/graphics/qt/SimpleFontDataQt.cpp16
-rw-r--r--WebCore/platform/graphics/qt/StillImageQt.cpp33
-rw-r--r--WebCore/platform/graphics/qt/TransparencyLayer.h2
17 files changed, 260 insertions, 282 deletions
diff --git a/WebCore/platform/graphics/qt/ContextShadowQt.cpp b/WebCore/platform/graphics/qt/ContextShadowQt.cpp
index f7c70f6..cb53b24 100644
--- a/WebCore/platform/graphics/qt/ContextShadowQt.cpp
+++ b/WebCore/platform/graphics/qt/ContextShadowQt.cpp
@@ -100,10 +100,20 @@ void ShadowBuffer::timerEvent(QTimerEvent* event)
QObject::timerEvent(event);
}
+TransformationMatrix ContextShadow::getTransformationMatrixFromContext(PlatformContext context)
+{
+ const QTransform& transform = context->transform();
+ return TransformationMatrix(transform.m11(), transform.m12(), transform.m21(),
+ transform.m22(), transform.dx(), transform.dy());
+}
+
Q_GLOBAL_STATIC(ShadowBuffer, scratchShadowBuffer)
PlatformContext ContextShadow::beginShadowLayer(PlatformContext p, const FloatRect& layerArea)
{
+ // Set m_blurDistance.
+ adjustBlurDistance(p);
+
QRect clipRect;
if (p->hasClipping())
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
@@ -114,25 +124,22 @@ PlatformContext ContextShadow::beginShadowLayer(PlatformContext p, const FloatRe
else
clipRect = p->transform().inverted().mapRect(p->window());
- m_unscaledLayerRect = layerArea;
- calculateLayerBoundingRect(layerArea, IntRect(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height()));
+ // Set m_layerOrigin, m_layerContextTranslation, m_sourceRect.
+ IntRect clip(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
+ IntRect layerRect = calculateLayerBoundingRect(p, layerArea, clip);
// Don't paint if we are totally outside the clip region.
- if (m_layerRect.isEmpty())
+ if (layerRect.isEmpty())
return 0;
ShadowBuffer* shadowBuffer = scratchShadowBuffer();
- QImage* shadowImage = shadowBuffer->scratchImage(m_layerRect.size());
+ QImage* shadowImage = shadowBuffer->scratchImage(layerRect.size());
m_layerImage = QImage(*shadowImage);
m_layerContext = new QPainter;
m_layerContext->begin(&m_layerImage);
m_layerContext->setFont(p->font());
- m_layerContext->translate(m_offset.width(), m_offset.height());
-
- // The origin is now the top left corner of the scratch image.
- m_layerContext->translate(-m_layerRect.x(), -m_layerRect.y());
-
+ m_layerContext->translate(m_layerContextTranslation);
return m_layerContext;
}
@@ -155,13 +162,7 @@ void ContextShadow::endShadowLayer(PlatformContext p)
p.end();
}
- const QTransform transform = p->transform();
- if (transform.isScaling()) {
- qreal x = m_unscaledLayerRect.x() + m_offset.width() / transform.m11() - m_blurDistance;
- qreal y = m_unscaledLayerRect.y() + m_offset.height() / transform.m22() - m_blurDistance;
- p->drawImage(QPointF(x, y), m_layerImage);
- } else
- p->drawImage(m_layerRect.topLeft(), m_layerImage);
+ p->drawImage(m_layerOrigin, m_layerImage, m_sourceRect);
scratchShadowBuffer()->schedulePurge();
}
diff --git a/WebCore/platform/graphics/qt/Extensions3DQt.cpp b/WebCore/platform/graphics/qt/Extensions3DQt.cpp
index 6a34671..cd28f0e 100644
--- a/WebCore/platform/graphics/qt/Extensions3DQt.cpp
+++ b/WebCore/platform/graphics/qt/Extensions3DQt.cpp
@@ -46,6 +46,11 @@ bool Extensions3DQt::supports(const String&)
return false;
}
+void Extensions3DQt::ensureEnabled(const String& name)
+{
+ ASSERT(supports(name));
+}
+
int Extensions3DQt::getGraphicsResetStatusARB()
{
return GraphicsContext3D::NO_ERROR;
diff --git a/WebCore/platform/graphics/qt/Extensions3DQt.h b/WebCore/platform/graphics/qt/Extensions3DQt.h
index 29209ba..ae4b375 100644
--- a/WebCore/platform/graphics/qt/Extensions3DQt.h
+++ b/WebCore/platform/graphics/qt/Extensions3DQt.h
@@ -36,6 +36,7 @@ public:
// Extensions3D methods.
virtual bool supports(const String&);
+ virtual void ensureEnabled(const String&);
virtual int getGraphicsResetStatusARB();
private:
diff --git a/WebCore/platform/graphics/qt/FontPlatformData.h b/WebCore/platform/graphics/qt/FontPlatformData.h
index 2201f18..1c57e29 100644
--- a/WebCore/platform/graphics/qt/FontPlatformData.h
+++ b/WebCore/platform/graphics/qt/FontPlatformData.h
@@ -36,7 +36,7 @@ class FontPlatformDataPrivate : public Noncopyable {
public:
FontPlatformDataPrivate()
: refCount(1)
- , size(font.pointSizeF())
+ , size(font.pixelSize())
, bold(font.bold())
, oblique(false)
{}
@@ -49,7 +49,7 @@ public:
FontPlatformDataPrivate(const QFont& font)
: refCount(1)
, font(font)
- , size(font.pointSizeF())
+ , size(font.pixelSize())
, bold(font.bold())
, oblique(false)
{}
@@ -150,8 +150,12 @@ public:
int pixelSize() const
{
Q_ASSERT(m_data != reinterpret_cast<FontPlatformDataPrivate*>(-1));
- if (m_data)
+ if (m_data) {
+ // WebKit allows font size zero but QFont does not.
+ if (!m_data->size)
+ return m_data->size;
return m_data->font.pixelSize();
+ }
return 0;
}
diff --git a/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp b/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
index 35e9e0c..4c9eb32 100644
--- a/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
+++ b/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
@@ -50,8 +50,9 @@ FontPlatformData::FontPlatformData(const FontDescription& description, const Ato
: m_data(new FontPlatformDataPrivate())
{
QFont& font = m_data->font;
+ int requestedSize = qRound(description.computedPixelSize());
font.setFamily(familyName);
- font.setPixelSize(qRound(description.computedSize()));
+ font.setPixelSize(qRound(requestedSize));
font.setItalic(description.italic());
font.setWeight(toQFontWeight(description.weight()));
font.setWordSpacing(wordSpacing);
@@ -63,7 +64,10 @@ FontPlatformData::FontPlatformData(const FontDescription& description, const Ato
#endif
m_data->bold = font.bold();
- m_data->size = font.pointSizeF();
+ // WebKit allows font size zero but QFont does not. We will return
+ // m_data->size if a font size of zero is requested and pixelSize()
+ // otherwise.
+ m_data->size = (!requestedSize) ? requestedSize : font.pixelSize();
}
FontPlatformData::~FontPlatformData()
diff --git a/WebCore/platform/graphics/qt/FontQt.cpp b/WebCore/platform/graphics/qt/FontQt.cpp
index 89dfd00..131ae93 100644
--- a/WebCore/platform/graphics/qt/FontQt.cpp
+++ b/WebCore/platform/graphics/qt/FontQt.cpp
@@ -29,6 +29,7 @@
#include "FontSelector.h"
#include "Gradient.h"
#include "GraphicsContext.h"
+#include "NotImplemented.h"
#include "Pattern.h"
#include <QBrush>
@@ -79,7 +80,7 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float
QPainter *p = ctx->platformContext();
QPen textFillPen;
- if (ctx->textDrawingMode() & cTextFill) {
+ if (ctx->textDrawingMode() & TextModeFill) {
if (ctx->fillGradient()) {
QBrush brush(*ctx->fillGradient()->platformGradient());
brush.setTransform(ctx->fillGradient()->gradientSpaceTransform());
@@ -92,7 +93,7 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float
}
QPen textStrokePen;
- if (ctx->textDrawingMode() & cTextStroke) {
+ if (ctx->textDrawingMode() & TextModeStroke) {
if (ctx->strokeGradient()) {
QBrush brush(*ctx->strokeGradient()->platformGradient());
brush.setTransform(ctx->strokeGradient()->gradientSpaceTransform());
@@ -145,7 +146,7 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float
if (ctxShadow->m_type != ContextShadow::NoShadow) {
ContextShadow* ctxShadow = ctx->contextShadow();
- if (ctxShadow->m_type != ContextShadow::BlurShadow) {
+ if (!ctxShadow->mustUseContextShadow(p)) {
p->save();
p->setPen(ctxShadow->m_color);
p->translate(ctxShadow->offset());
@@ -179,17 +180,17 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float
int flags = run.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight;
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
// See QWebPagePrivate::QWebPagePrivate() where the default path is set to Complex for Qt 4.6 and earlier.
- if (!isComplexText && !(ctx->textDrawingMode() & cTextStroke))
+ if (!isComplexText && !(ctx->textDrawingMode() & TextModeStroke))
flags |= Qt::TextBypassShaping;
#endif
QPainterPath textStrokePath;
- if (ctx->textDrawingMode() & cTextStroke)
+ if (ctx->textDrawingMode() & TextModeStroke)
textStrokePath.addText(pt, font, string);
ContextShadow* ctxShadow = ctx->contextShadow();
if (ctxShadow->m_type != ContextShadow::NoShadow) {
- if (ctx->textDrawingMode() & cTextFill) {
+ if (ctx->textDrawingMode() & TextModeFill) {
if (ctxShadow->m_type != ContextShadow::BlurShadow) {
p->save();
p->setPen(ctxShadow->m_color);
@@ -212,7 +213,7 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float
ctxShadow->endShadowLayer(p);
}
}
- } else if (ctx->textDrawingMode() & cTextStroke) {
+ } else if (ctx->textDrawingMode() & TextModeStroke) {
if (ctxShadow->m_type != ContextShadow::BlurShadow) {
p->translate(ctxShadow->offset());
p->strokePath(textStrokePath, QPen(ctxShadow->m_color));
@@ -235,10 +236,10 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float
}
}
- if (ctx->textDrawingMode() & cTextStroke)
+ if (ctx->textDrawingMode() & TextModeStroke)
p->strokePath(textStrokePath, textStrokePen);
- if (ctx->textDrawingMode() & cTextFill) {
+ if (ctx->textDrawingMode() & TextModeFill) {
QPen previousPen = p->pen();
p->setPen(textFillPen);
p->drawText(pt, string, flags, run.padding());
@@ -260,8 +261,39 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float
drawTextCommon(ctx, run, point, from, to, font(), /* isComplexText = */true);
}
+int Font::emphasisMarkAscent(const AtomicString&) const
+{
+ notImplemented();
+ return 0;
+}
+
+int Font::emphasisMarkDescent(const AtomicString&) const
+{
+ notImplemented();
+ return 0;
+}
+
+int Font::emphasisMarkHeight(const AtomicString&) const
+{
+ notImplemented();
+ return 0;
+}
+
+void Font::drawEmphasisMarksForSimpleText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
+{
+ notImplemented();
+}
+
+void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
+{
+ notImplemented();
+}
+
float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
+ if (!primaryFont()->platformData().size())
+ return 0;
+
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
if (!run.length())
return 0;
@@ -278,12 +310,15 @@ float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer
return w + run.padding();
#else
Q_ASSERT(false);
- return 0.0f;
+ return 0;
#endif
}
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*, GlyphOverflow*) const
{
+ if (!primaryFont()->platformData().size())
+ return 0;
+
if (!run.length())
return 0;
diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index b399f4e..9dd38aa 100644
--- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -46,16 +46,13 @@
#include "ContextShadow.h"
#include "FloatConversion.h"
#include "Font.h"
-#include "GraphicsContextPrivate.h"
#include "ImageBuffer.h"
#include "NotImplemented.h"
#include "Path.h"
#include "Pattern.h"
-#include "Pen.h"
#include "TransparencyLayer.h"
#include <QBrush>
-#include <QDebug>
#include <QGradient>
#include <QPaintDevice>
#include <QPaintEngine>
@@ -200,9 +197,7 @@ public:
QBrush solidColor;
InterpolationQuality imageInterpolationQuality;
-
- // Only used by SVG for now.
- QPainterPath currentPath;
+ bool initialSmoothPixmapTransformHint;
ContextShadow shadow;
QStack<ContextShadow> shadowStack;
@@ -212,13 +207,6 @@ public:
return shadow.m_type != ContextShadow::NoShadow;
}
- inline void clearCurrentPath()
- {
- if (!currentPath.elementCount())
- return;
- currentPath = QPainterPath();
- }
-
QRectF clipBoundingRect() const
{
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
@@ -235,12 +223,12 @@ private:
bool platformContextIsOwned;
};
-
GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(QPainter* p, const QColor& initialSolidColor)
: antiAliasingForRectsAndLines(false)
, layerCount(0)
, solidColor(initialSolidColor)
, imageInterpolationQuality(InterpolationDefault)
+ , initialSmoothPixmapTransformHint(false)
, painter(p)
, platformContextIsOwned(false)
{
@@ -250,7 +238,10 @@ GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(QPainter* p, cons
// Use the default the QPainter was constructed with.
antiAliasingForRectsAndLines = painter->testRenderHint(QPainter::Antialiasing);
- painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true);
+ // Used for default image interpolation quality.
+ initialSmoothPixmapTransformHint = painter->testRenderHint(QPainter::SmoothPixmapTransform);
+
+ painter->setRenderHint(QPainter::Antialiasing, true);
}
GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
@@ -258,16 +249,16 @@ GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
if (!platformContextIsOwned)
return;
- painter->end();
QPaintDevice* device = painter->device();
+ painter->end();
delete painter;
delete device;
}
-GraphicsContext::GraphicsContext(PlatformGraphicsContext* painter)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate(painter, fillColor()))
+void GraphicsContext::platformInit(PlatformGraphicsContext* painter)
{
+ m_data = new GraphicsContextPlatformPrivate(painter, fillColor());
+
setPaintingDisabled(!painter);
if (!painter)
@@ -282,12 +273,11 @@ GraphicsContext::GraphicsContext(PlatformGraphicsContext* painter)
painter->setPen(pen);
}
-GraphicsContext::~GraphicsContext()
+void GraphicsContext::platformDestroy()
{
while (!m_data->layers.isEmpty())
endTransparencyLayer();
- destroyGraphicsContextPrivate(m_common);
delete m_data;
}
@@ -319,11 +309,6 @@ void GraphicsContext::restorePlatformState()
m_data->p()->restore();
- if (!m_data->currentPath.isEmpty() && m_common->state.pathTransform.isInvertible()) {
- QTransform matrix = m_common->state.pathTransform;
- m_data->currentPath = m_data->currentPath * matrix;
- }
-
if (m_data->shadowStack.isEmpty())
m_data->shadow = ContextShadow();
else
@@ -514,93 +499,88 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin
p->setRenderHint(QPainter::Antialiasing, painterWasAntialiased);
}
-void GraphicsContext::fillPath()
+void GraphicsContext::fillPath(const Path& path)
{
if (paintingDisabled())
return;
QPainter* p = m_data->p();
- QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath
- path.setFillRule(toQtFillRule(fillRule()));
+ QPainterPath platformPath = path.platformPath();
+ platformPath.setFillRule(toQtFillRule(fillRule()));
if (m_data->hasShadow()) {
ContextShadow* shadow = contextShadow();
- if (shadow->m_type != ContextShadow::BlurShadow
- && !m_common->state.fillPattern && !m_common->state.fillGradient)
+ if (shadow->mustUseContextShadow(p) || m_state.fillPattern || m_state.fillGradient)
{
- p->translate(m_data->shadow.offset());
- p->fillPath(path, QColor(m_data->shadow.m_color));
- p->translate(-m_data->shadow.offset());
- } else {
- QPainter* shadowPainter = shadow->beginShadowLayer(p, path.controlPointRect());
+ QPainter* shadowPainter = shadow->beginShadowLayer(p, platformPath.controlPointRect());
if (shadowPainter) {
shadowPainter->setCompositionMode(QPainter::CompositionMode_Source);
- shadowPainter->fillPath(path, QColor(m_data->shadow.m_color));
+ shadowPainter->fillPath(platformPath, QColor(m_data->shadow.m_color));
shadow->endShadowLayer(p);
}
+ } else {
+ QPointF offset = shadow->offset();
+ p->translate(offset);
+ p->fillPath(platformPath, QColor(shadow->m_color));
+ p->translate(-offset);
}
-
}
- if (m_common->state.fillPattern) {
+ if (m_state.fillPattern) {
AffineTransform affine;
- p->fillPath(path, QBrush(m_common->state.fillPattern->createPlatformPattern(affine)));
- } else if (m_common->state.fillGradient) {
- QBrush brush(*m_common->state.fillGradient->platformGradient());
- brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform());
- p->fillPath(path, brush);
+ p->fillPath(platformPath, QBrush(m_state.fillPattern->createPlatformPattern(affine)));
+ } else if (m_state.fillGradient) {
+ QBrush brush(*m_state.fillGradient->platformGradient());
+ brush.setTransform(m_state.fillGradient->gradientSpaceTransform());
+ p->fillPath(platformPath, brush);
} else
- p->fillPath(path, p->brush());
-
- m_data->clearCurrentPath();
+ p->fillPath(platformPath, p->brush());
}
-void GraphicsContext::strokePath()
+void GraphicsContext::strokePath(const Path& path)
{
if (paintingDisabled())
return;
QPainter* p = m_data->p();
QPen pen(p->pen());
- QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath
- path.setFillRule(toQtFillRule(fillRule()));
+ QPainterPath platformPath = path.platformPath();
+ platformPath.setFillRule(toQtFillRule(fillRule()));
if (m_data->hasShadow()) {
ContextShadow* shadow = contextShadow();
-
- if (shadow->m_type != ContextShadow::BlurShadow
- && !m_common->state.strokePattern && !m_common->state.strokeGradient)
+ if (shadow->mustUseContextShadow(p) || m_state.strokePattern || m_state.strokeGradient)
{
- QPen shadowPen(pen);
- shadowPen.setColor(m_data->shadow.m_color);
- p->translate(m_data->shadow.offset());
- p->strokePath(path, shadowPen);
- p->translate(-m_data->shadow.offset());
- } else {
- FloatRect boundingRect = path.controlPointRect();
+ FloatRect boundingRect = platformPath.controlPointRect();
boundingRect.inflate(pen.miterLimit() + pen.widthF());
QPainter* shadowPainter = shadow->beginShadowLayer(p, boundingRect);
if (shadowPainter) {
shadowPainter->setOpacity(static_cast<qreal>(m_data->shadow.m_color.alpha()) / 255);
- shadowPainter->strokePath(path, pen);
+ shadowPainter->strokePath(platformPath, pen);
shadow->endShadowLayer(p);
}
+ } else {
+ QPen shadowPen(pen);
+ shadowPen.setColor(m_data->shadow.m_color);
+ QPointF offset = shadow->offset();
+ p->translate(offset);
+ p->strokePath(platformPath, shadowPen);
+ p->translate(-offset);
}
}
- if (m_common->state.strokePattern) {
+ if (m_state.strokePattern) {
AffineTransform affine;
- pen.setBrush(QBrush(m_common->state.strokePattern->createPlatformPattern(affine)));
+ pen.setBrush(QBrush(m_state.strokePattern->createPlatformPattern(affine)));
p->setPen(pen);
- p->strokePath(path, pen);
- } else if (m_common->state.strokeGradient) {
- QBrush brush(*m_common->state.strokeGradient->platformGradient());
- brush.setTransform(m_common->state.strokeGradient->gradientSpaceTransform());
+ p->strokePath(platformPath, pen);
+ } else if (m_state.strokeGradient) {
+ QBrush brush(*m_state.strokeGradient->platformGradient());
+ brush.setTransform(m_state.strokeGradient->gradientSpaceTransform());
pen.setBrush(brush);
p->setPen(pen);
- p->strokePath(path, pen);
+ p->strokePath(platformPath, pen);
} else
- p->strokePath(path, pen);
- m_data->clearCurrentPath();
+ p->strokePath(platformPath, pen);
}
static inline void drawRepeatPattern(QPainter* p, QPixmap* image, const FloatRect& rect, const bool repeatX, const bool repeatY)
@@ -679,21 +659,21 @@ void GraphicsContext::fillRect(const FloatRect& rect)
QRectF normalizedRect = rect.normalized();
ContextShadow* shadow = contextShadow();
- if (m_common->state.fillPattern) {
+ if (m_state.fillPattern) {
AffineTransform affine;
- QBrush brush(m_common->state.fillPattern->createPlatformPattern(affine));
- QPixmap* image = m_common->state.fillPattern->tileImage()->nativeImageForCurrentFrame();
+ QBrush brush(m_state.fillPattern->createPlatformPattern(affine));
+ QPixmap* image = m_state.fillPattern->tileImage()->nativeImageForCurrentFrame();
QPainter* shadowPainter = m_data->hasShadow() ? shadow->beginShadowLayer(p, normalizedRect) : 0;
if (shadowPainter) {
- drawRepeatPattern(shadowPainter, image, normalizedRect, m_common->state.fillPattern->repeatX(), m_common->state.fillPattern->repeatY());
+ drawRepeatPattern(shadowPainter, image, normalizedRect, m_state.fillPattern->repeatX(), m_state.fillPattern->repeatY());
shadowPainter->setCompositionMode(QPainter::CompositionMode_SourceIn);
shadowPainter->fillRect(normalizedRect, shadow->m_color);
shadow->endShadowLayer(p);
}
- drawRepeatPattern(p, image, normalizedRect, m_common->state.fillPattern->repeatX(), m_common->state.fillPattern->repeatY());
- } else if (m_common->state.fillGradient) {
- QBrush brush(*m_common->state.fillGradient->platformGradient());
- brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform());
+ drawRepeatPattern(p, image, normalizedRect, m_state.fillPattern->repeatX(), m_state.fillPattern->repeatY());
+ } else if (m_state.fillGradient) {
+ QBrush brush(*m_state.fillGradient->platformGradient());
+ brush.setTransform(m_state.fillGradient->gradientSpaceTransform());
QPainter* shadowPainter = m_data->hasShadow() ? shadow->beginShadowLayer(p, normalizedRect) : 0;
if (shadowPainter) {
shadowPainter->fillRect(normalizedRect, brush);
@@ -704,7 +684,7 @@ void GraphicsContext::fillRect(const FloatRect& rect)
p->fillRect(normalizedRect, brush);
} else {
if (m_data->hasShadow()) {
- if (shadow->m_type == ContextShadow::BlurShadow) {
+ if (shadow->mustUseContextShadow(p)) {
QPainter* shadowPainter = shadow->beginShadowLayer(p, normalizedRect);
if (shadowPainter) {
shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255);
@@ -712,17 +692,11 @@ void GraphicsContext::fillRect(const FloatRect& rect)
shadow->endShadowLayer(p);
}
} else {
- // Solid rectangle fill with no blur shadow can be done faster
- // without using the shadow layer at all.
+ // Solid rectangle fill with no blur shadow or transformations applied can be done
+ // faster without using the shadow layer at all.
QColor shadowColor = shadow->m_color;
shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF());
- const QTransform transform = p->transform();
- if (transform.isScaling()) {
- p->fillRect(normalizedRect.translated(static_cast<qreal>(shadow->offset().x()) / transform.m11(),
- static_cast<qreal>(shadow->offset().y() / transform.m22())),
- shadowColor);
- } else
- p->fillRect(normalizedRect.translated(shadow->offset()), shadowColor);
+ p->fillRect(normalizedRect.translated(shadow->offset()), shadowColor);
}
}
@@ -742,18 +716,15 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS
if (m_data->hasShadow()) {
ContextShadow* shadow = contextShadow();
-
- if (shadow->m_type != ContextShadow::BlurShadow) {
- // We do not need any layer for simple shadow.
- p->fillRect(normalizedRect.translated(shadow->offset()), shadow->m_color);
- } else {
+ if (shadow->mustUseContextShadow(p)) {
QPainter* shadowPainter = shadow->beginShadowLayer(p, normalizedRect);
if (shadowPainter) {
shadowPainter->setCompositionMode(QPainter::CompositionMode_Source);
shadowPainter->fillRect(normalizedRect, shadow->m_color);
shadow->endShadowLayer(p);
}
- }
+ } else
+ p->fillRect(normalizedRect.translated(shadow->offset()), shadow->m_color);
}
p->fillRect(normalizedRect, m_data->solidColor);
@@ -769,48 +740,27 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef
QPainter* p = m_data->p();
if (m_data->hasShadow()) {
ContextShadow* shadow = contextShadow();
-
- if (shadow->m_type != ContextShadow::BlurShadow) {
- // We do not need any layer for simple shadow.
- p->translate(m_data->shadow.offset());
- p->fillPath(path.platformPath(), QColor(m_data->shadow.m_color));
- p->translate(-m_data->shadow.offset());
- } else {
+ if (shadow->mustUseContextShadow(p)) {
QPainter* shadowPainter = shadow->beginShadowLayer(p, rect);
if (shadowPainter) {
shadowPainter->setCompositionMode(QPainter::CompositionMode_Source);
shadowPainter->fillPath(path.platformPath(), QColor(m_data->shadow.m_color));
shadow->endShadowLayer(p);
}
+ } else {
+ p->translate(m_data->shadow.offset());
+ p->fillPath(path.platformPath(), QColor(m_data->shadow.m_color));
+ p->translate(-m_data->shadow.offset());
}
}
p->fillPath(path.platformPath(), QColor(color));
}
-void GraphicsContext::beginPath()
-{
- m_data->clearCurrentPath();
-}
-
-void GraphicsContext::addPath(const Path& path)
-{
- if (!m_data->currentPath.elementCount()) {
- m_data->currentPath = path.platformPath();
- return;
- }
- m_data->currentPath.addPath(path.platformPath());
-}
-
bool GraphicsContext::inTransparencyLayer() const
{
return m_data->layerCount;
}
-PlatformPath* GraphicsContext::currentPath()
-{
- return &m_data->currentPath;
-}
-
ContextShadow* GraphicsContext::contextShadow()
{
return &m_data->shadow;
@@ -824,47 +774,54 @@ void GraphicsContext::clip(const FloatRect& rect)
m_data->p()->setClipRect(rect, Qt::IntersectClip);
}
-void GraphicsContext::clipPath(WindRule clipRule)
+void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
{
if (paintingDisabled())
return;
QPainter* p = m_data->p();
- QPainterPath newPath = m_data->currentPath;
- newPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
- p->setClipPath(newPath, Qt::IntersectClip);
+ QPainterPath platformPath = path.platformPath();
+ platformPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
+ p->setClipPath(platformPath, Qt::IntersectClip);
}
-void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color)
+void drawFocusRingForPath(QPainter* p, const QPainterPath& path, int width, const Color& color, bool antiAliasing)
{
- // FIXME: Use 'width' and 'offset' for something? http://webkit.org/b/49909
-
- if (paintingDisabled() || !color.isValid())
- return;
-
- QPainter* p = m_data->p();
const bool antiAlias = p->testRenderHint(QPainter::Antialiasing);
- p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines);
+ p->setRenderHint(QPainter::Antialiasing, antiAliasing);
+ const QPen oldPen = p->pen();
const QBrush oldBrush = p->brush();
QPen nPen = p->pen();
- nPen.setColor(color);
+ nPen.setColor(QColor(color.red(), color.green(), color.blue(), 127));
+ nPen.setWidth(width);
p->setBrush(Qt::NoBrush);
- nPen.setStyle(Qt::DotLine);
+ nPen.setStyle(Qt::SolidLine);
- p->strokePath(path.platformPath(), nPen);
+ p->strokePath(path, nPen);
p->setBrush(oldBrush);
+ p->setPen(oldPen);
p->setRenderHint(QPainter::Antialiasing, antiAlias);
}
+void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color)
+{
+ // FIXME: Use 'offset' for something? http://webkit.org/b/49909
+
+ if (paintingDisabled() || !color.isValid())
+ return;
+
+ drawFocusRingForPath(m_data->p(), path.platformPath(), width, color, m_data->antiAliasingForRectsAndLines);
+}
+
/**
* Focus ring handling for form controls is not handled here. Qt style in
* RenderTheme handles drawing focus on widgets which
* need it. It is still handled here for links.
*/
-void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width */, int /* offset */, const Color& color)
+void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
{
if (paintingDisabled() || !color.isValid())
return;
@@ -874,34 +831,18 @@ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width *
if (!rects.size())
return;
- QPainter* p = m_data->p();
- const bool antiAlias = p->testRenderHint(QPainter::Antialiasing);
- p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines);
-
- const QPen oldPen = p->pen();
- const QBrush oldBrush = p->brush();
-
- QPen nPen = p->pen();
- nPen.setColor(color);
- p->setBrush(Qt::NoBrush);
- nPen.setStyle(Qt::DotLine);
- p->setPen(nPen);
-#if 0
- // FIXME How do we do a bounding outline with Qt?
+ int radius = (width - 1) / 2;
QPainterPath path;
- for (int i = 0; i < rectCount; ++i)
- path.addRect(QRectF(rects[i]));
- QPainterPathStroker stroker;
- QPainterPath newPath = stroker.createStroke(path);
- p->strokePath(newPath, nPen);
-#else
- for (unsigned i = 0; i < rectCount; ++i)
- p->drawRect(QRectF(rects[i]));
-#endif
- p->setPen(oldPen);
- p->setBrush(oldBrush);
+ for (unsigned i = 0; i < rectCount; ++i) {
+ QRect rect = QRect((rects[i])).adjusted(-offset - radius, -offset - radius, offset + radius, offset + radius);
+ // This is not the most efficient way to add a rect to a path, but if we don't create the tmpPath,
+ // we will end up with ugly lines in between rows of text on anchors with multiple lines.
+ QPainterPath tmpPath;
+ tmpPath.addRoundedRect(rect, radius, radius);
+ path = path.united(tmpPath);
+ }
- p->setRenderHint(QPainter::Antialiasing, antiAlias);
+ drawFocusRingForPath(m_data->p(), path, width, color, m_data->antiAliasingForRectsAndLines);
}
void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool)
@@ -974,14 +915,15 @@ void GraphicsContext::setPlatformShadow(const FloatSize& size, float blur, const
// Qt doesn't support shadows natively, they are drawn manually in the draw*
// functions
- if (m_common->state.shadowsIgnoreTransforms) {
+ if (m_state.shadowsIgnoreTransforms) {
// Meaning that this graphics context is associated with a CanvasRenderingContext
// We flip the height since CG and HTML5 Canvas have opposite Y axis
- m_common->state.shadowOffset = FloatSize(size.width(), -size.height());
+ m_state.shadowOffset = FloatSize(size.width(), -size.height());
m_data->shadow = ContextShadow(color, blur, FloatSize(size.width(), -size.height()));
- } else {
+ } else
m_data->shadow = ContextShadow(color, blur, FloatSize(size.width(), size.height()));
- }
+
+ m_data->shadow.setShadowsIgnoreTransforms(m_state.shadowsIgnoreTransforms);
}
void GraphicsContext::clearPlatformShadow()
@@ -991,7 +933,8 @@ void GraphicsContext::clearPlatformShadow()
void GraphicsContext::pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask)
{
- m_data->layers.push(new TransparencyLayer(m_data->p(), m_data->p()->transform().mapRect(rect), 1.0, alphaMask));
+ QPainter* p = m_data->p();
+ m_data->layers.push(new TransparencyLayer(p, p->transform().mapRect(rect), 1.0, alphaMask));
}
void GraphicsContext::beginTransparencyLayer(float opacity)
@@ -1014,7 +957,7 @@ void GraphicsContext::beginTransparencyLayer(float opacity)
h = int(qBound(qreal(0), deviceClip.height(), (qreal)h) + 2);
QPixmap emptyAlphaMask;
- m_data->layers.push(new TransparencyLayer(m_data->p(), QRect(x, y, w, h), opacity, emptyAlphaMask));
+ m_data->layers.push(new TransparencyLayer(p, QRect(x, y, w, h), opacity, emptyAlphaMask));
++m_data->layerCount;
}
@@ -1056,17 +999,23 @@ void GraphicsContext::clearRect(const FloatRect& rect)
p->setCompositionMode(currentCompositionMode);
}
-void GraphicsContext::strokeRect(const FloatRect& rect, float width)
+void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
{
if (paintingDisabled())
return;
- QPainterPath path;
+ Path path;
path.addRect(rect);
- setStrokeThickness(width);
- m_data->currentPath = path;
- strokePath();
+ float previousStrokeThickness = strokeThickness();
+
+ if (lineWidth != previousStrokeThickness)
+ setStrokeThickness(lineWidth);
+
+ strokePath(path);
+
+ if (lineWidth != previousStrokeThickness)
+ setStrokeThickness(previousStrokeThickness);
}
void GraphicsContext::setLineCap(LineCap lc)
@@ -1132,24 +1081,20 @@ void GraphicsContext::setAlpha(float opacity)
p->setOpacity(opacity);
}
-void GraphicsContext::setCompositeOperation(CompositeOperator op)
+void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op)
{
if (paintingDisabled())
return;
- if (m_data->p()->paintEngine()->hasFeature(QPaintEngine::PorterDuff))
- m_data->p()->setCompositionMode(toQtCompositionMode(op));
-}
+ QPainter* painter = m_data->p();
-void GraphicsContext::clip(const Path& path)
-{
- if (paintingDisabled())
+ if (!painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff))
return;
- m_data->p()->setClipPath(path.platformPath(), Qt::IntersectClip);
+ painter->setCompositionMode(toQtCompositionMode(op));
}
-void GraphicsContext::canvasClip(const Path& path)
+void GraphicsContext::clip(const Path& path)
{
if (paintingDisabled())
return;
@@ -1159,6 +1104,11 @@ void GraphicsContext::canvasClip(const Path& path)
m_data->p()->setClipPath(clipPath, Qt::IntersectClip);
}
+void GraphicsContext::canvasClip(const Path& path)
+{
+ clip(path);
+}
+
void GraphicsContext::clipOut(const Path& path)
{
if (paintingDisabled())
@@ -1186,12 +1136,6 @@ void GraphicsContext::translate(float x, float y)
return;
m_data->p()->translate(x, y);
-
- if (!m_data->currentPath.isEmpty()) {
- QTransform matrix;
- m_data->currentPath = m_data->currentPath * matrix.translate(-x, -y);
- m_common->state.pathTransform.translate(x, y);
- }
}
void GraphicsContext::rotate(float radians)
@@ -1200,12 +1144,6 @@ void GraphicsContext::rotate(float radians)
return;
m_data->p()->rotate(180 / M_PI*radians);
-
- if (!m_data->currentPath.isEmpty()) {
- QTransform matrix;
- m_data->currentPath = m_data->currentPath * matrix.rotate(-180 / M_PI*radians);
- m_common->state.pathTransform.rotate(radians);
- }
}
void GraphicsContext::scale(const FloatSize& s)
@@ -1214,12 +1152,6 @@ void GraphicsContext::scale(const FloatSize& s)
return;
m_data->p()->scale(s.width(), s.height());
-
- if (!m_data->currentPath.isEmpty()) {
- QTransform matrix;
- m_data->currentPath = m_data->currentPath * matrix.scale(1 / s.width(), 1 / s.height());
- m_common->state.pathTransform.scaleNonUniform(s.width(), s.height());
- }
}
void GraphicsContext::clipOut(const IntRect& rect)
@@ -1276,15 +1208,6 @@ void GraphicsContext::concatCTM(const AffineTransform& transform)
return;
m_data->p()->setWorldTransform(transform, true);
-
- // Transformations to the context shouldn't transform the currentPath.
- // We have to undo every change made to the context from the currentPath
- // to avoid wrong drawings.
- if (!m_data->currentPath.isEmpty() && transform.isInvertible()) {
- QTransform matrix = transform.inverse();
- m_data->currentPath = m_data->currentPath * matrix;
- m_common->state.pathTransform.multiply(transform.toTransformationMatrix());
- }
}
void GraphicsContext::setURLForRect(const KURL&, const IntRect&)
@@ -1437,13 +1360,16 @@ void GraphicsContext::setImageInterpolationQuality(InterpolationQuality quality)
m_data->p()->setRenderHint(QPainter::SmoothPixmapTransform, false);
break;
- case InterpolationDefault:
case InterpolationMedium:
case InterpolationHigh:
- default:
// use the filter
m_data->p()->setRenderHint(QPainter::SmoothPixmapTransform, true);
break;
+
+ case InterpolationDefault:
+ default:
+ m_data->p()->setRenderHint(QPainter::SmoothPixmapTransform, m_data->initialSmoothPixmapTransformHint);
+ break;
};
}
diff --git a/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp b/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp
index 49387a2..f31844a 100644
--- a/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp
+++ b/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp
@@ -686,7 +686,7 @@ void GraphicsLayerQtImpl::flushChanges(bool recursive, bool forceUpdateTransform
// try to snatch that ownership.
if (!m_layer->parent() && !parentItem())
setParentItem(0);
- else if (m_layer && m_layer->parent() && m_layer->parent()->nativeLayer() != parentItem())
+ else if (m_layer && m_layer->parent() && m_layer->parent()->platformLayer() != parentItem())
setParentItem(m_layer->parent()->platformLayer());
}
@@ -1318,13 +1318,6 @@ void GraphicsLayerQt::syncCompositingStateForThisLayerOnly()
}
/* \reimp (GraphicsLayer.h)
- */
-NativeLayer GraphicsLayerQt::nativeLayer() const
-{
- return m_impl.get();
-}
-
-/* \reimp (GraphicsLayer.h)
*/
PlatformLayer* GraphicsLayerQt::platformLayer() const
{
diff --git a/WebCore/platform/graphics/qt/GraphicsLayerQt.h b/WebCore/platform/graphics/qt/GraphicsLayerQt.h
index ed535eb..b1692d2 100644
--- a/WebCore/platform/graphics/qt/GraphicsLayerQt.h
+++ b/WebCore/platform/graphics/qt/GraphicsLayerQt.h
@@ -38,7 +38,6 @@ public:
virtual ~GraphicsLayerQt();
// reimps from GraphicsLayer.h
- virtual NativeLayer nativeLayer() const;
virtual PlatformLayer* platformLayer() const;
virtual void setNeedsDisplay();
virtual void setNeedsDisplayInRect(const FloatRect&);
diff --git a/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/WebCore/platform/graphics/qt/ImageBufferQt.cpp
index de23297..1652b5b 100644
--- a/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -80,7 +80,7 @@ ImageBufferData::ImageBufferData(const IntSize& size)
m_image = StillImage::createForRendering(&m_pixmap);
}
-ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace, RenderingMode, bool& success)
: m_data(size)
, m_size(size)
{
diff --git a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
index 2dd239f..2bbb9ce 100644
--- a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
@@ -37,17 +37,17 @@
namespace WebCore {
-ImageDecoder* ImageDecoder::create(const SharedBuffer& data, bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
+ImageDecoder* ImageDecoder::create(const SharedBuffer& data, ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption)
{
// We need at least 4 bytes to figure out what kind of image we're dealing with.
if (data.size() < 4)
return 0;
- return new ImageDecoderQt(premultiplyAlpha, ignoreGammaAndColorProfile);
+ return new ImageDecoderQt(alphaOption, gammaAndColorProfileOption);
}
-ImageDecoderQt::ImageDecoderQt(bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
- : ImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile)
+ImageDecoderQt::ImageDecoderQt(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption)
+ : ImageDecoder(alphaOption, gammaAndColorProfileOption)
, m_repetitionCount(cAnimationNone)
{
}
diff --git a/WebCore/platform/graphics/qt/ImageDecoderQt.h b/WebCore/platform/graphics/qt/ImageDecoderQt.h
index 914c020..23fb79a 100644
--- a/WebCore/platform/graphics/qt/ImageDecoderQt.h
+++ b/WebCore/platform/graphics/qt/ImageDecoderQt.h
@@ -41,7 +41,7 @@ namespace WebCore {
class ImageDecoderQt : public ImageDecoder
{
public:
- ImageDecoderQt(bool premultiplyAlpha, bool ignoreGammaAndColorProfile);
+ ImageDecoderQt(ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption);
~ImageDecoderQt();
virtual void setData(SharedBuffer* data, bool allDataReceived);
diff --git a/WebCore/platform/graphics/qt/ImageQt.cpp b/WebCore/platform/graphics/qt/ImageQt.cpp
index 3611308..f713d37 100644
--- a/WebCore/platform/graphics/qt/ImageQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageQt.cpp
@@ -114,7 +114,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
if (tr.x() || tr.y() || tr.width() != pixmap.width() || tr.height() != pixmap.height())
pixmap = pixmap.copy(tr);
- ctxt->save();
+ CompositeOperator previousOperator = ctxt->compositeOperation();
ctxt->setCompositeOperation(op);
QPainter* p = ctxt->platformContext();
@@ -130,7 +130,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
b.setTransform(transform);
p->fillRect(dr, b);
- ctxt->restore();
+ ctxt->setCompositeOperation(previousOperator);
if (imageObserver())
imageObserver()->didDraw(this);
diff --git a/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
index 962c931..dd4b6e6 100644
--- a/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
+++ b/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
@@ -25,6 +25,7 @@
#include "GraphicsContext.h"
#include "HTMLMediaElement.h"
#include "HTMLVideoElement.h"
+#include "QtNAMThreadSafeProxy.h"
#include "NetworkingContext.h"
#include "NotImplemented.h"
#include "RenderVideo.h"
@@ -209,8 +210,8 @@ void MediaPlayerPrivateQt::commitLoad(const String& url)
if (document && manager) {
// Set the cookies
- QNetworkCookieJar* jar = manager->cookieJar();
- QList<QNetworkCookie> cookies = jar->cookiesForUrl(rUrl);
+ QtNAMThreadSafeProxy managerProxy(manager);
+ QList<QNetworkCookie> cookies = managerProxy.cookiesForUrl(rUrl);
// Don't set the header if there are no cookies.
// This prevents a warning from being emitted.
diff --git a/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp b/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
index f093d7d..47ddf02 100644
--- a/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
+++ b/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
@@ -40,6 +40,18 @@ bool SimpleFontData::containsCharacters(const UChar*, int) const
void SimpleFontData::platformInit()
{
+ if (!m_platformData.size()) {
+ m_ascent = 0;
+ m_descent = 0;
+ m_lineGap = 0;
+ m_lineSpacing = 0;
+ m_avgCharWidth = 0;
+ m_maxCharWidth = 0;
+ m_xHeight = 0;
+ m_unitsPerEm = 0;
+ return;
+ }
+
QFontMetrics fm(m_platformData.font());
m_ascent = fm.ascent();
@@ -52,6 +64,8 @@ void SimpleFontData::platformInit()
void SimpleFontData::platformGlyphInit()
{
+ if (!m_platformData.size())
+ return;
m_spaceGlyph = 0;
m_adjustedSpaceWidth = m_spaceWidth;
determinePitch();
@@ -61,6 +75,8 @@ void SimpleFontData::platformGlyphInit()
void SimpleFontData::platformCharWidthInit()
{
+ if (!m_platformData.size())
+ return;
QFontMetrics fm(m_platformData.font());
m_avgCharWidth = fm.averageCharWidth();
m_maxCharWidth = fm.maxWidth();
diff --git a/WebCore/platform/graphics/qt/StillImageQt.cpp b/WebCore/platform/graphics/qt/StillImageQt.cpp
index 3038356..51c9499 100644
--- a/WebCore/platform/graphics/qt/StillImageQt.cpp
+++ b/WebCore/platform/graphics/qt/StillImageQt.cpp
@@ -28,6 +28,7 @@
#include "config.h"
#include "StillImageQt.h"
+#include "ContextShadow.h"
#include "GraphicsContext.h"
#include "IntSize.h"
@@ -67,34 +68,26 @@ void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
if (m_pixmap->isNull())
return;
-
FloatRect normalizedSrc = src.normalized();
FloatRect normalizedDst = dst.normalized();
- QPainter* painter = ctxt->platformContext();
- QPainter::CompositionMode oldCompositionMode = painter->compositionMode();
-
+ CompositeOperator previousOperator = ctxt->compositeOperation();
ctxt->setCompositeOperation(op);
- FloatSize shadowOffset;
- float shadowBlur;
- Color shadowColor;
- if (ctxt->getShadow(shadowOffset, shadowBlur, shadowColor)) {
- FloatRect shadowImageRect(normalizedDst);
- shadowImageRect.move(shadowOffset.width(), shadowOffset.height());
-
- QImage shadowImage(QSize(static_cast<int>(normalizedSrc.width()), static_cast<int>(normalizedSrc.height())), QImage::Format_ARGB32_Premultiplied);
- QPainter p(&shadowImage);
- p.setCompositionMode(QPainter::CompositionMode_Source);
- p.fillRect(shadowImage.rect(), shadowColor);
- p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- p.drawPixmap(QRect(0, 0, normalizedDst.width(), normalizedDst.height()), *m_pixmap, normalizedSrc);
- p.end();
- painter->drawImage(shadowImageRect, shadowImage, normalizedSrc);
+ QPainter* painter = ctxt->platformContext();
+
+ ContextShadow* shadow = ctxt->contextShadow();
+ if (shadow->m_type != ContextShadow::NoShadow) {
+ QPainter* shadowPainter = shadow->beginShadowLayer(painter, normalizedDst);
+ if (shadowPainter) {
+ shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255);
+ shadowPainter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
+ shadow->endShadowLayer(painter);
+ }
}
painter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
- painter->setCompositionMode(oldCompositionMode);
+ ctxt->setCompositeOperation(previousOperator);
}
}
diff --git a/WebCore/platform/graphics/qt/TransparencyLayer.h b/WebCore/platform/graphics/qt/TransparencyLayer.h
index 6bdfb39..5b2f8b2 100644
--- a/WebCore/platform/graphics/qt/TransparencyLayer.h
+++ b/WebCore/platform/graphics/qt/TransparencyLayer.h
@@ -52,7 +52,7 @@ struct TransparencyLayer : FastAllocBase {
offset = rect.topLeft();
pixmap.fill(Qt::transparent);
painter.begin(&pixmap);
- painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
+ painter.setRenderHints(p->renderHints());
painter.translate(-offset);
painter.setPen(p->pen());
painter.setBrush(p->brush());