Changeset 75469 in webkit


Ignore:
Timestamp:
Jan 10, 2011 7:29:15 PM (13 years ago)
Author:
senorblanco@chromium.org
Message:

2011-01-10 Stephen White <senorblanco@chromium.org>

Reviewed by James Robinson.

Fix canvas->canvas draws on the GPU path.
https://bugs.webkit.org/show_bug.cgi?id=52141


Two problems: according to the canvas spec, both source and
destination rects can have negative width or height, but this shouldn't
cause the image to be flipped. So we need to normalize the rects (in
the software path, this is done by BitmapImage*::draw). Secondly, in
the FBO->FBO path, the image needs to be flipped vertically, since it
is drawn upside down. We were doing this by flipping the destination
rect, but this doesn't work if the source rect is not the entire image,
since we extract the wrong part of the image. Fixed by flipping the
source rect instead (and flipping it within the image buffer's height,
not the source rect's height).

Covered by fast/canvas/drawImage-with-negative-source-destination.html.

  • platform/graphics/skia/BitmapImageSingleFrameSkia.h: Put normalizeRect() in global scope.
  • platform/graphics/skia/ImageBufferSkia.cpp: (WebCore::ImageBuffer::draw): Fix as above: normalize both source and dest rects, and flip the source rect instead of the dest rect.
  • platform/graphics/skia/ImageSkia.cpp: (WebCore::normalizeRect): Put normalizeRect() in global scope.
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r75467 r75469  
     12011-01-10  Stephen White  <senorblanco@chromium.org>
     2
     3        Reviewed by James Robinson.
     4
     5        Fix canvas->canvas draws on the GPU path.
     6        https://bugs.webkit.org/show_bug.cgi?id=52141
     7       
     8        Two problems:  according to the canvas spec, both source and
     9        destination rects can have negative width or height, but this shouldn't
     10        cause the image to be flipped.  So we need to normalize the rects (in
     11        the software path, this is done by BitmapImage*::draw).  Secondly, in
     12        the FBO->FBO path, the image needs to be flipped vertically, since it
     13        is drawn upside down.  We were doing this by flipping the destination
     14        rect, but this doesn't work if the source rect is not the entire image,
     15        since we extract the wrong part of the image.  Fixed by flipping the
     16        source rect instead (and flipping it within the image buffer's height,
     17        not the source rect's height).
     18
     19        Covered by fast/canvas/drawImage-with-negative-source-destination.html.
     20
     21
     22        * platform/graphics/skia/BitmapImageSingleFrameSkia.h:
     23        Put normalizeRect() in global scope.
     24        * platform/graphics/skia/ImageBufferSkia.cpp:
     25        (WebCore::ImageBuffer::draw):
     26        Fix as above:  normalize both source and dest rects, and flip the
     27        source rect instead of the dest rect.
     28        * platform/graphics/skia/ImageSkia.cpp:
     29        (WebCore::normalizeRect):
     30        Put normalizeRect() in global scope.
     31
    1322011-01-10  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
    233
  • trunk/Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.h

    r65617 r75469  
    8383};
    8484
     85FloatRect normalizeRect(const FloatRect&);
     86
    8587} // namespace WebCore
    8688
  • trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

    r74868 r75469  
    115115            DrawingBuffer* sourceDrawingBuffer = m_data.m_platformContext.gpuCanvas()->drawingBuffer();
    116116            unsigned sourceTexture = static_cast<unsigned>(sourceDrawingBuffer->platformColorBuffer());
    117             FloatRect destRectFlipped(destRect);
    118             destRectFlipped.setY(destRect.y() + destRect.height());
    119             destRectFlipped.setHeight(-destRect.height());
     117            FloatRect destRectNormalized(normalizeRect(destRect));
     118            FloatRect srcRectFlipped(normalizeRect(srcRect));
     119            srcRectFlipped.setY(m_size.height() - srcRect.y());
     120            srcRectFlipped.setHeight(-srcRect.height());
    120121            context->platformContext()->prepareForHardwareDraw();
    121             context->platformContext()->gpuCanvas()->drawTexturedRect(sourceTexture, m_size, srcRect, destRectFlipped, styleColorSpace, op);
     122            context->platformContext()->gpuCanvas()->drawTexturedRect(sourceTexture, m_size, srcRectFlipped, destRectNormalized, styleColorSpace, op);
    122123            return;
    123124        }
  • trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp

    r73169 r75469  
    299299
    300300// A helper method for translating negative width and height values.
    301 static FloatRect normalizeRect(const FloatRect& rect)
     301FloatRect normalizeRect(const FloatRect& rect)
    302302{
    303303    FloatRect norm = rect;
Note: See TracChangeset for help on using the changeset viewer.