diff options
Diffstat (limited to 'WebCore/platform/graphics/qt/ContextShadowQt.cpp')
-rw-r--r-- | WebCore/platform/graphics/qt/ContextShadowQt.cpp | 33 |
1 files changed, 17 insertions, 16 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(); } |