drawImage() clears the canvas if it's the source of the image and globalCompositeOper...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2019 22:28:13 +0000 (22:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2019 22:28:13 +0000 (22:28 +0000)
commit75e3f1f02f7fad033f36bd6a402f8d12fca3f4af
tree64e442965eb9d4318587882c9b5f242fdd696987
parentd5d4953b9a36872d4a69c3c43df0bc96321db893
drawImage() clears the canvas if it's the source of the image and globalCompositeOperation is "copy"
https://bugs.webkit.org/show_bug.cgi?id=194746

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-02-20
Reviewed by Dean Jackson.

Source/WebCore:

Test: fast/canvas/canvas-drawImage-composite-copy.html

If the source canvas of drawImage() is the same as the destination and
globalCompositeOperation is set to "copy", copy the srcRect from the
canvas to a temporary buffer before calling clearCanvas() then drawImage
from this temporary buffer.

* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::drawImage):
* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::copyRectToBuffer):
* platform/graphics/ImageBuffer.h:

LayoutTests:

* fast/canvas/canvas-drawImage-composite-copy-expected.html: Added.
* fast/canvas/canvas-drawImage-composite-copy.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241840 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/canvas/canvas-drawImage-composite-copy-expected.html [new file with mode: 0644]
LayoutTests/fast/canvas/canvas-drawImage-composite-copy.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
Source/WebCore/platform/graphics/ImageBuffer.cpp
Source/WebCore/platform/graphics/ImageBuffer.h