Skip to content
Permalink
Browse files
2010-07-19 Andreas Kling <andreas.kling@nokia.com>
        Reviewed by Kenneth Rohde Christiansen.

        [Qt] Render shadow when drawing one canvas onto another
        https://bugs.webkit.org/show_bug.cgi?id=42508

        * platform/graphics/qt/StillImageQt.cpp:
        (WebCore::StillImage::draw):
2010-07-19  Andreas Kling  <andreas.kling@nokia.com>

        Reviewed by Kenneth Rohde Christiansen.

        [Qt] Render shadow when drawing one canvas onto another
        https://bugs.webkit.org/show_bug.cgi?id=42508

        Unskip:
        - canvas/philip/tests/2d.shadow.canvas.basic.html

        Reskip (bug now exposed):
        - canvas/philip/tests/2d.shadow.canvas.transparent.1.html

        * platform/qt/Skipped:


Canonical link: https://commits.webkit.org/54496@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63656 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Jul 19, 2010
1 parent 3932996 commit 8465a6f42338eb6ce7dca9d9fb16860d1f89a3d2
Showing with 48 additions and 35 deletions.
  1. +15 −0 LayoutTests/ChangeLog
  2. +1 −1 LayoutTests/platform/qt/Skipped
  3. +10 −0 WebCore/ChangeLog
  4. +22 −34 WebCore/platform/graphics/qt/StillImageQt.cpp
@@ -1,3 +1,18 @@
2010-07-19 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

[Qt] Render shadow when drawing one canvas onto another
https://bugs.webkit.org/show_bug.cgi?id=42508

Unskip:
- canvas/philip/tests/2d.shadow.canvas.basic.html

Reskip (bug now exposed):
- canvas/philip/tests/2d.shadow.canvas.transparent.1.html

* platform/qt/Skipped:

2010-07-19 Csaba Osztrogonác <ossy@webkit.org>

Unreviewed.
@@ -5288,7 +5288,7 @@ canvas/philip/tests/2d.pattern.image.incomplete.html
canvas/philip/tests/2d.pattern.image.null.html
canvas/philip/tests/2d.pattern.image.undefined.html
canvas/philip/tests/2d.shadow.canvas.alpha.html
canvas/philip/tests/2d.shadow.canvas.basic.html
canvas/philip/tests/2d.shadow.canvas.transparent.1.html
canvas/philip/tests/2d.shadow.canvas.transparent.2.html
canvas/philip/tests/2d.shadow.image.alpha.html
canvas/philip/tests/2d.shadow.image.transparent.1.html
@@ -1,3 +1,13 @@
2010-07-19 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

[Qt] Render shadow when drawing one canvas onto another
https://bugs.webkit.org/show_bug.cgi?id=42508

* platform/graphics/qt/StillImageQt.cpp:
(WebCore::StillImage::draw):

2010-07-19 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Kenneth Rohde Christiansen.
@@ -67,46 +67,34 @@ void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
if (m_pixmap->isNull())
return;

ctxt->save();
ctxt->setCompositeOperation(op);

// To support width or height is negative
float sx = src.x();
float sy = src.y();
float sw = src.width();
float sh = src.height();

if (sw < 0) {
sx = sx + sw;
sw = -sw;
}

if (sh < 0) {
sy = sy + sh;
sh = -sh;
}
FloatRect normalizedSrc = src.normalized();
FloatRect normalizedDst = dst.normalized();

float dx = dst.x();
float dy = dst.y();
float dw = dst.width();
float dh = dst.height();
QPainter* painter = ctxt->platformContext();
QPainter::CompositionMode oldCompositionMode = painter->compositionMode();

if (dw < 0) {
dx = dx + dw;
dw = -dw;
}
ctxt->setCompositeOperation(op);

if (dh < 0) {
dy = dy + dh;
dh = -dh;
FloatSize shadowSize;
float shadowBlur;
Color shadowColor;
if (ctxt->getShadow(shadowSize, shadowBlur, shadowColor)) {
FloatRect shadowImageRect(normalizedDst);
shadowImageRect.move(shadowSize.width(), shadowSize.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(normalizedDst, *m_pixmap, normalizedSrc);
p.end();
painter->drawImage(shadowImageRect, shadowImage, normalizedSrc);
}

FloatRect srcM(sx, sy, sw, sh);
FloatRect dstM(dx, dy, dw, dh);
QPainter* painter(ctxt->platformContext());

painter->drawPixmap(dstM, *m_pixmap, srcM);
ctxt->restore();
painter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
painter->setCompositionMode(oldCompositionMode);
}

}

0 comments on commit 8465a6f

Please sign in to comment.