Changeset 139911 in webkit


Ignore:
Timestamp:
Jan 16, 2013 12:25:06 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

inconsistency in drawImage with target rect negative dimensions.
https://bugs.webkit.org/show_bug.cgi?id=100026

Patch by Arnaud Renevier <a.renevier@sisa.samsung.com> on 2013-01-16
Reviewed by Dean Jackson.

PerformanceTests:

Create a drawImage performance test. There is no significative change
in performance: 27144.6851528 runs/s without the patch; 27153.517612
runs/s with the patch. Test is currently skipped.

  • Canvas/drawimage.html: Added.
  • Skipped:

Source/WebCore:

Remove -1, -1 special case in drawImage and drawImageBuffer. Replace
all -1 -1 arguments calls to with the correct rectangle dimensions.

Remove FloatRect(0, 0, -1, -1) default argument for srcRect, and
instead, add new overloaded functions to create a FloatRect from image
size.

Replace -1 -1 arguments calls in FEComposite::platformApplySoftware
with correct rectangle dimensions.

Replace ImageGStreamer rect method (which may return -1 -1 rectangle)
with cropRect method, and make caller check for rectangle emptiness.

  • fast/canvas/drawImage-with-negative-source-destination-expected.txt:
  • fast/canvas/drawImage-with-negative-source-destination.js:
  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::drawImage):
(WebCore):
(WebCore::GraphicsContext::drawImageBuffer):

  • platform/graphics/GraphicsContext.h:

(GraphicsContext):

  • platform/graphics/filters/FEComposite.cpp:

(WebCore::FEComposite::platformApplySoftware):

  • platform/graphics/gstreamer/ImageGStreamer.h:

(WebCore::ImageGStreamer::rect):

LayoutTests:

Add a drawImage check for a destination rectangle with -1px
width/height. When drawing to (1, 1, -1, -1) rectangle, first
(top-left) pixel should have been and been the only one drawn into.

  • fast/canvas/drawImage-with-negative-source-destination-expected.txt:
  • fast/canvas/drawImage-with-negative-source-destination.js:
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r139904 r139911  
     12013-01-16  Arnaud Renevier  <a.renevier@sisa.samsung.com>
     2
     3        inconsistency in drawImage with target rect negative dimensions.
     4        https://bugs.webkit.org/show_bug.cgi?id=100026
     5
     6        Reviewed by Dean Jackson.
     7
     8        Add a drawImage check for a destination rectangle with -1px
     9        width/height. When drawing to (1, 1, -1, -1) rectangle, first
     10        (top-left) pixel should have been and been the only one drawn into.
     11
     12        * fast/canvas/drawImage-with-negative-source-destination-expected.txt:
     13        * fast/canvas/drawImage-with-negative-source-destination.js:
     14
    1152013-01-16  W. James MacLean  <wjmaclean@chromium.org>
    216
  • trunk/LayoutTests/fast/canvas/drawImage-with-negative-source-destination-expected.txt

    r36075 r139911  
    77PASS imgdata[5] is 255
    88PASS imgdata[6] is 0
     9PASS imgdata[0] is 255
     10PASS imgdata[1] is 0
     11PASS imgdata[2] is 0
     12PASS imgdata[4] is 0
     13PASS imgdata[5] is 0
     14PASS imgdata[6] is 0
    915PASS successfullyParsed is true
    1016
  • trunk/LayoutTests/fast/canvas/drawImage-with-negative-source-destination.js

    r98407 r139911  
    2020shouldBe("imgdata[5]", "255");
    2121shouldBe("imgdata[6]", "0");
     22
     23// test width or height -1
     24canvas.fillStyle = '#000';
     25canvas.fillRect(0, 0, 1, 2);
     26canvas.drawImage(canvas2, 0, 0, 1, 1, 1, 1, -1, -1);
     27var imageData = canvas.getImageData(0, 0, 1, 2);
     28var imgdata = imageData.data;
     29shouldBe("imgdata[0]", "255");
     30shouldBe("imgdata[1]", "0");
     31shouldBe("imgdata[2]", "0");
     32shouldBe("imgdata[4]", "0");
     33shouldBe("imgdata[5]", "0");
     34shouldBe("imgdata[6]", "0");
  • trunk/PerformanceTests/ChangeLog

    r139728 r139911  
     12013-01-16  Arnaud Renevier  <a.renevier@sisa.samsung.com>
     2
     3        inconsistency in drawImage with target rect negative dimensions.
     4        https://bugs.webkit.org/show_bug.cgi?id=100026
     5
     6        Reviewed by Dean Jackson.
     7
     8        Create a drawImage performance test. There is no significative change
     9        in performance: 27144.6851528 runs/s without the patch; 27153.517612
     10        runs/s with the patch. Test is currently skipped.
     11
     12        * Canvas/drawimage.html: Added.
     13        * Skipped:
     14
    1152013-01-15  Dominic Cooney  <dominicc@chromium.org>
    216
  • trunk/PerformanceTests/Skipped

    r136120 r139911  
    6363# Bug 102646 - ShadowDOM is not enabled in some ports.
    6464ShadowDOM
     65
     66Canvas/drawimage.html
  • trunk/Source/WebCore/ChangeLog

    r139908 r139911  
     12013-01-16  Arnaud Renevier  <a.renevier@sisa.samsung.com>
     2
     3        inconsistency in drawImage with target rect negative dimensions.
     4        https://bugs.webkit.org/show_bug.cgi?id=100026
     5
     6        Reviewed by Dean Jackson.
     7
     8        Remove -1, -1 special case in drawImage and drawImageBuffer. Replace
     9        all -1 -1 arguments calls to with the correct rectangle dimensions.
     10
     11        Remove FloatRect(0, 0, -1, -1) default argument for srcRect, and
     12        instead, add new overloaded functions to create a FloatRect from image
     13        size.
     14
     15        Replace -1 -1 arguments calls in FEComposite::platformApplySoftware
     16        with correct rectangle dimensions.
     17
     18        Replace ImageGStreamer rect method (which may return -1 -1 rectangle)
     19        with cropRect method, and make caller check for rectangle emptiness.
     20
     21        * fast/canvas/drawImage-with-negative-source-destination-expected.txt:
     22        * fast/canvas/drawImage-with-negative-source-destination.js:
     23
     24        * platform/graphics/GraphicsContext.cpp:
     25        (WebCore::GraphicsContext::drawImage):
     26        (WebCore):
     27        (WebCore::GraphicsContext::drawImageBuffer):
     28        * platform/graphics/GraphicsContext.h:
     29        (GraphicsContext):
     30        * platform/graphics/filters/FEComposite.cpp:
     31        (WebCore::FEComposite::platformApplySoftware):
     32        * platform/graphics/gstreamer/ImageGStreamer.h:
     33        (WebCore::ImageGStreamer::rect):
     34
    1352013-01-16  Simon Fraser  <simon.fraser@apple.com>
    236
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r139353 r139911  
    449449void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntPoint& p, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageOrientation)
    450450{
    451     drawImage(image, styleColorSpace, p, IntRect(0, 0, -1, -1), op, shouldRespectImageOrientation);
     451    if (!image)
     452        return;
     453    drawImage(image, styleColorSpace, p, IntRect(IntPoint(), image->size()), op, shouldRespectImageOrientation);
    452454}
    453455
    454456void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntRect& r, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageOrientation, bool useLowQualityScale)
    455457{
    456     drawImage(image, styleColorSpace, r, IntRect(0, 0, -1, -1), op, shouldRespectImageOrientation, useLowQualityScale);
     458    if (!image)
     459        return;
     460    drawImage(image, styleColorSpace, r, IntRect(IntPoint(), image->size()), op, shouldRespectImageOrientation, useLowQualityScale);
    457461}
    458462
     
    470474{
    471475    drawImage(image, styleColorSpace, FloatRect(dest), src, op, BlendModeNormal, shouldRespectImageOrientation, useLowQualityScale);
     476}
     477
     478void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const FloatRect& dest)
     479{
     480    if (!image)
     481        return;
     482    drawImage(image, styleColorSpace, dest, FloatRect(IntRect(IntPoint(), image->size())));
    472483}
    473484
     
    475486{    if (paintingDisabled() || !image)
    476487        return;
    477 
    478     float tsw = src.width();
    479     float tsh = src.height();
    480     float tw = dest.width();
    481     float th = dest.height();
    482 
    483     if (tsw == -1)
    484         tsw = image->width();
    485     if (tsh == -1)
    486         tsh = image->height();
    487 
    488     if (tw == -1)
    489         tw = image->width();
    490     if (th == -1)
    491         th = image->height();
    492488
    493489    InterpolationQuality previousInterpolationQuality = InterpolationDefault;
     
    503499    }
    504500
    505     image->draw(this, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), styleColorSpace, op, blendMode, shouldRespectImageOrientation);
     501    image->draw(this, dest, src, styleColorSpace, op, blendMode, shouldRespectImageOrientation);
    506502
    507503    if (useLowQualityScale)
     
    546542void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const IntPoint& p, CompositeOperator op, BlendMode blendMode)
    547543{
    548     drawImageBuffer(image, styleColorSpace, p, IntRect(0, 0, -1, -1), op, blendMode);
     544    if (!image)
     545        return;
     546    drawImageBuffer(image, styleColorSpace, p, IntRect(IntPoint(), image->logicalSize()), op, blendMode);
    549547}
    550548
    551549void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const IntRect& r, CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
    552550{
    553     drawImageBuffer(image, styleColorSpace, r, IntRect(0, 0, -1, -1), op, blendMode, useLowQualityScale);
     551    if (!image)
     552        return;
     553    drawImageBuffer(image, styleColorSpace, r, IntRect(IntPoint(), image->logicalSize()), op, blendMode, useLowQualityScale);
    554554}
    555555
     
    564564}
    565565
     566void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const FloatRect& dest)
     567{
     568    if (!image)
     569        return;
     570    drawImageBuffer(image, styleColorSpace, dest, FloatRect(IntRect(IntPoint(), image->logicalSize())));
     571}
     572
    566573void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const FloatRect& dest, const FloatRect& src, CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
    567574{
    568575    if (paintingDisabled() || !image)
    569576        return;
    570 
    571     float tsw = src.width();
    572     float tsh = src.height();
    573     float tw = dest.width();
    574     float th = dest.height();
    575 
    576     if (tsw == -1)
    577         tsw = image->logicalSize().width();
    578     if (tsh == -1)
    579         tsh = image->logicalSize().height();
    580 
    581     if (tw == -1)
    582         tw = image->logicalSize().width();
    583     if (th == -1)
    584         th = image->logicalSize().height();
    585577
    586578    if (useLowQualityScale) {
     
    592584        setImageInterpolationQuality(InterpolationNone);
    593585#endif
    594         image->draw(this, styleColorSpace, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), op, blendMode, useLowQualityScale);
     586        image->draw(this, styleColorSpace, dest, src, op, blendMode, useLowQualityScale);
    595587        setImageInterpolationQuality(previousInterpolationQuality);
    596588    } else
    597         image->draw(this, styleColorSpace, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), op, blendMode, useLowQualityScale);
     589        image->draw(this, styleColorSpace, dest, src, op, blendMode, useLowQualityScale);
    598590}
    599591
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r139353 r139911  
    323323        void drawImage(Image*, ColorSpace styleColorSpace, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation);
    324324        void drawImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation, bool useLowQualityScale = false);
    325         void drawImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1),
    326                       CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation, bool useLowQualityScale = false);
     325        void drawImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect);
     326        void drawImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation, bool useLowQualityScale = false);
    327327        void drawImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator, BlendMode, RespectImageOrientationEnum = DoNotRespectImageOrientation, bool useLowQualityScale = false);
    328328       
     
    337337        void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal);
    338338        void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
    339         void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
     339        void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const FloatRect& destRect);
     340        void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
    340341
    341342        void setImageInterpolationQuality(InterpolationQuality);
  • trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp

    r123605 r139911  
    275275    GraphicsContext* filterContext = resultImage->context();
    276276
    277     FloatRect srcRect = FloatRect(0, 0, -1, -1);
     277    ImageBuffer* imageBuffer = in->asImageBuffer();
     278    ImageBuffer* imageBuffer2 = in2->asImageBuffer();
     279    ASSERT(imageBuffer);
     280    ASSERT(imageBuffer2);
     281
    278282    switch (m_type) {
    279283    case FECOMPOSITE_OPERATOR_OVER:
    280         filterContext->drawImageBuffer(in2->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
    281         filterContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()));
     284        filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
     285        filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()));
    282286        break;
    283287    case FECOMPOSITE_OPERATOR_IN: {
     
    293297        IntRect source2Rect(IntPoint(destinationRect.x() - in2->absolutePaintRect().x(),
    294298                                     destinationRect.y() - in2->absolutePaintRect().y()), destinationRect.size());
    295         filterContext->drawImageBuffer(in2->asImageBuffer(), ColorSpaceDeviceRGB, destinationPoint, source2Rect);
    296         filterContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, destinationPoint, sourceRect, CompositeSourceIn);
     299        filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, destinationPoint, source2Rect);
     300        filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, destinationPoint, sourceRect, CompositeSourceIn);
    297301        break;
    298302    }
    299303    case FECOMPOSITE_OPERATOR_OUT:
    300         filterContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()));
    301         filterContext->drawImageBuffer(in2->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()), srcRect, CompositeDestinationOut);
     304        filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()));
     305        filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()), IntRect(IntPoint(), imageBuffer2->logicalSize()), CompositeDestinationOut);
    302306        break;
    303307    case FECOMPOSITE_OPERATOR_ATOP:
    304         filterContext->drawImageBuffer(in2->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
    305         filterContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()), srcRect, CompositeSourceAtop);
     308        filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
     309        filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeSourceAtop);
    306310        break;
    307311    case FECOMPOSITE_OPERATOR_XOR:
    308         filterContext->drawImageBuffer(in2->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
    309         filterContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()), srcRect, CompositeXOR);
     312        filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
     313        filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeXOR);
    310314        break;
    311315    default:
  • trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h

    r139896 r139911  
    5252            if (!m_cropRect.isEmpty())
    5353                return FloatRect(m_cropRect);
    54 
    55             // Default rectangle used by GraphicsContext::drawImage().
    56             return FloatRect(0, 0, -1, -1);
     54            ASSERT(m_image);
     55            return FloatRect(0, 0, m_image->size().width(), m_image->size().height());
    5756        }
    5857
Note: See TracChangeset for help on using the changeset viewer.