Changeset 68176 in webkit


Ignore:
Timestamp:
Sep 23, 2010 12:15:48 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-09-23 Matthew Delaney <mdelaney@apple.com>

Reviewed by Oliver Hunt.

context.drawImage with (source rect's height) = -(input image's native height) draws nothing
https://bugs.webkit.org/show_bug.cgi?id=46243

These test simply exercise using negative widths and heights for the source rect in ctx.drawImage calls.

  • canvas/philip/tests/2d.drawImage.negativeSourceHeight-expected.txt: Added.
  • canvas/philip/tests/2d.drawImage.negativeSourceHeight.html: Added.
  • canvas/philip/tests/2d.drawImage.negativeSourceHeight2-expected.txt: Added.
  • canvas/philip/tests/2d.drawImage.negativeSourceHeight2.html: Added.
  • canvas/philip/tests/2d.drawImage.negativeSourceHeightAndWidth-expected.txt: Added.
  • canvas/philip/tests/2d.drawImage.negativeSourceHeightAndWidth.html: Added.

2010-09-23 Matthew Delaney <mdelaney@apple.com>

Reviewed by Oliver Hunt.

context.drawImage with (source rect's height) = -(input image's native height) draws nothing
https://bugs.webkit.org/show_bug.cgi?id=46243

This patch changes canvasrenderingcontext2d's drawImage with an image element to
normalize the source and dest rects to acheive the desired canvas spec behavior
of allowing negative widths and heights that don't cause flipping and fix the
adverse behavior of specifying a source rect height of negative the source image's height

Tests: canvas/philip/tests/2d.drawImage.negativeSourceHeight.html

canvas/philip/tests/2d.drawImage.negativeSourceHeight2.html
canvas/philip/tests/2d.drawImage.negativeSourceHeightAndWidth.html

  • html/canvas/CanvasRenderingContext2D.cpp: Normalize rects in drawImage before calling lower level draw calls.
Location:
trunk
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r68174 r68176  
     12010-09-23  Matthew Delaney  <mdelaney@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        context.drawImage with (source rect's height) = -(input image's native height) draws nothing
     6        https://bugs.webkit.org/show_bug.cgi?id=46243
     7
     8        These test simply exercise using negative widths and heights for the source rect in ctx.drawImage calls.
     9
     10        * canvas/philip/tests/2d.drawImage.negativeSourceHeight-expected.txt: Added.
     11        * canvas/philip/tests/2d.drawImage.negativeSourceHeight.html: Added.
     12        * canvas/philip/tests/2d.drawImage.negativeSourceHeight2-expected.txt: Added.
     13        * canvas/philip/tests/2d.drawImage.negativeSourceHeight2.html: Added.
     14        * canvas/philip/tests/2d.drawImage.negativeSourceHeightAndWidth-expected.txt: Added.
     15        * canvas/philip/tests/2d.drawImage.negativeSourceHeightAndWidth.html: Added.
     16
    1172010-09-23  Nate Chapin  <japhet@chromium.org>
    218
  • trunk/WebCore/ChangeLog

    r68175 r68176  
     12010-09-23  Matthew Delaney  <mdelaney@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        context.drawImage with (source rect's height) = -(input image's native height) draws nothing
     6        https://bugs.webkit.org/show_bug.cgi?id=46243
     7
     8        This patch changes canvasrenderingcontext2d's drawImage with an image element to
     9        normalize the source and dest rects to acheive the desired canvas spec behavior
     10        of allowing negative widths and heights that don't cause flipping and fix the
     11        adverse behavior of specifying a source rect height of negative the source image's height
     12
     13        Tests: canvas/philip/tests/2d.drawImage.negativeSourceHeight.html
     14               canvas/philip/tests/2d.drawImage.negativeSourceHeight2.html
     15               canvas/philip/tests/2d.drawImage.negativeSourceHeightAndWidth.html
     16
     17        * html/canvas/CanvasRenderingContext2D.cpp: Normalize rects in drawImage before calling
     18        lower level draw calls.
     19
    1202010-09-23  Renata Hodovan  <reni@inf.u-szeged.hu>
    221
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r67574 r68176  
    11871187        return;
    11881188
     1189    if (!dstRect.width() || !dstRect.height())
     1190        return;
     1191
    11891192    if (!image->complete())
    11901193        return;
    11911194
     1195    FloatRect normalizedSrcRect = normalizeRect(srcRect);
     1196    FloatRect normalizedDstRect = normalizeRect(dstRect);
     1197
    11921198    FloatRect imageRect = FloatRect(FloatPoint(), size(image));
    1193     if (!imageRect.contains(normalizeRect(srcRect)) || !srcRect.width() || !srcRect.height()) {
     1199    if (!imageRect.contains(normalizedSrcRect) || !srcRect.width() || !srcRect.height()) {
    11941200        ec = INDEX_SIZE_ERR;
    11951201        return;
    11961202    }
    1197 
    1198     if (!dstRect.width() || !dstRect.height())
    1199         return;
    12001203
    12011204    GraphicsContext* c = drawingContext();
     
    12151218        canvas()->setOriginTainted();
    12161219
    1217     FloatRect sourceRect = c->roundToDevicePixels(srcRect);
    1218     FloatRect destRect = c->roundToDevicePixels(dstRect);
     1220    FloatRect sourceRect = c->roundToDevicePixels(normalizedSrcRect);
     1221    FloatRect destRect = c->roundToDevicePixels(normalizedDstRect);
    12191222    c->drawImage(cachedImage->image(), DeviceColorSpace, destRect, sourceRect, state().m_globalComposite);
    12201223    didDraw(destRect);
Note: See TracChangeset for help on using the changeset viewer.