Changeset 73889 in webkit


Ignore:
Timestamp:
Dec 13, 2010 12:56:31 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2010-12-13 Helder Correia <helder@sencha.com>

Reviewed by Eric Seidel.

[Qt] StillImage::draw() should use ContextShadow
https://bugs.webkit.org/show_bug.cgi?id=50849

The branch that checks for a shadow requirement in StillImage::draw()
is executed when drawing a canvas onto a canvas with
ctx1.drawImage(canvas2, x, y). The current implementation supports
solid shadows only. And if transformations are present, the offset gets
transformed as well. Thus, ContextShadow must be used instead in order
to support blur and correct offset transformations.

  • fast/canvas/canvas-draw-canvas-on-canvas-shadow-expected.txt: Added.
  • fast/canvas/canvas-draw-canvas-on-canvas-shadow.html: Added.
  • fast/canvas/script-tests/canvas-draw-canvas-on-canvas-shadow.js: Added.

2010-12-13 Helder Correia <helder@sencha.com>

Reviewed by Eric Seidel.

[Qt] StillImage::draw() should use ContextShadow
https://bugs.webkit.org/show_bug.cgi?id=50849

The branch that checks for a shadow requirement in StillImage::draw()
is executed when drawing a canvas onto a canvas with
ctx1.drawImage(canvas2, x, y). The current implementation supports
solid shadows only. And if transformations are present, the offset gets
transformed as well. Thus, ContextShadow must be used instead in order
to support blur and correct offset transformations.

Test: fast/canvas/canvas-draw-canvas-on-canvas-shadow.html

  • platform/graphics/qt/StillImageQt.cpp: (WebCore::StillImage::draw):
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r73886 r73889  
     12010-12-13  Helder Correia  <helder@sencha.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        [Qt] StillImage::draw() should use ContextShadow
     6        https://bugs.webkit.org/show_bug.cgi?id=50849
     7
     8        The branch that checks for a shadow requirement in StillImage::draw()
     9        is executed when drawing a canvas onto a canvas with
     10        ctx1.drawImage(canvas2, x, y). The current implementation supports
     11        solid shadows only. And if transformations are present, the offset gets
     12        transformed as well. Thus, ContextShadow must be used instead in order
     13        to support blur and correct offset transformations.
     14
     15        * fast/canvas/canvas-draw-canvas-on-canvas-shadow-expected.txt: Added.
     16        * fast/canvas/canvas-draw-canvas-on-canvas-shadow.html: Added.
     17        * fast/canvas/script-tests/canvas-draw-canvas-on-canvas-shadow.js: Added.
     18
    1192010-10-28  MORITA Hajime  <morrita@google.com>
    220
  • trunk/WebCore/ChangeLog

    r73888 r73889  
     12010-12-13  Helder Correia  <helder@sencha.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        [Qt] StillImage::draw() should use ContextShadow
     6        https://bugs.webkit.org/show_bug.cgi?id=50849
     7
     8        The branch that checks for a shadow requirement in StillImage::draw()
     9        is executed when drawing a canvas onto a canvas with
     10        ctx1.drawImage(canvas2, x, y). The current implementation supports
     11        solid shadows only. And if transformations are present, the offset gets
     12        transformed as well. Thus, ContextShadow must be used instead in order
     13        to support blur and correct offset transformations.
     14
     15        Test: fast/canvas/canvas-draw-canvas-on-canvas-shadow.html
     16
     17        * platform/graphics/qt/StillImageQt.cpp:
     18        (WebCore::StillImage::draw):
     19
    1202010-12-12  Jon Honeycutt  <jhoneycutt@apple.com>
    221
  • trunk/WebCore/platform/graphics/qt/StillImageQt.cpp

    r66082 r73889  
    2929#include "StillImageQt.h"
    3030
     31#include "ContextShadow.h"
    3132#include "GraphicsContext.h"
    3233#include "IntSize.h"
     
    6869        return;
    6970
    70 
    7171    FloatRect normalizedSrc = src.normalized();
    7272    FloatRect normalizedDst = dst.normalized();
     
    7777    ctxt->setCompositeOperation(op);
    7878
    79     FloatSize shadowOffset;
    80     float shadowBlur;
    81     Color shadowColor;
    82     if (ctxt->getShadow(shadowOffset, shadowBlur, shadowColor)) {
    83         FloatRect shadowImageRect(normalizedDst);
    84         shadowImageRect.move(shadowOffset.width(), shadowOffset.height());
    85 
    86         QImage shadowImage(QSize(static_cast<int>(normalizedSrc.width()), static_cast<int>(normalizedSrc.height())), QImage::Format_ARGB32_Premultiplied);
    87         QPainter p(&shadowImage);
    88         p.setCompositionMode(QPainter::CompositionMode_Source);
    89         p.fillRect(shadowImage.rect(), shadowColor);
    90         p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
    91         p.drawPixmap(QRect(0, 0, normalizedDst.width(), normalizedDst.height()), *m_pixmap, normalizedSrc);
    92         p.end();
    93         painter->drawImage(shadowImageRect, shadowImage, normalizedSrc);
     79    ContextShadow* shadow = ctxt->contextShadow();
     80    if (shadow->m_type != ContextShadow::NoShadow) {
     81        QPainter* shadowPainter = shadow->beginShadowLayer(painter, normalizedDst);
     82        if (shadowPainter) {
     83            shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255);
     84            shadowPainter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
     85            shadow->endShadowLayer(painter);
     86        }
    9487    }
    9588
Note: See TracChangeset for help on using the changeset viewer.