Changeset 241840 in webkit
- Timestamp:
- Feb 20, 2019 2:28:13 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r241836 r241840 1 2019-02-20 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 drawImage() clears the canvas if it's the source of the image and globalCompositeOperation is "copy" 4 https://bugs.webkit.org/show_bug.cgi?id=194746 5 6 Reviewed by Dean Jackson. 7 8 * fast/canvas/canvas-drawImage-composite-copy-expected.html: Added. 9 * fast/canvas/canvas-drawImage-composite-copy.html: Added. 10 1 11 2019-02-20 Shawn Roberts <sroberts@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r241830 r241840 1 2019-02-20 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 drawImage() clears the canvas if it's the source of the image and globalCompositeOperation is "copy" 4 https://bugs.webkit.org/show_bug.cgi?id=194746 5 6 Reviewed by Dean Jackson. 7 8 Test: fast/canvas/canvas-drawImage-composite-copy.html 9 10 If the source canvas of drawImage() is the same as the destination and 11 globalCompositeOperation is set to "copy", copy the srcRect from the 12 canvas to a temporary buffer before calling clearCanvas() then drawImage 13 from this temporary buffer. 14 15 * html/canvas/CanvasRenderingContext2DBase.cpp: 16 (WebCore::CanvasRenderingContext2DBase::drawImage): 17 * platform/graphics/ImageBuffer.cpp: 18 (WebCore::ImageBuffer::copyRectToBuffer): 19 * platform/graphics/ImageBuffer.h: 20 1 21 2019-02-20 Simon Fraser <simon.fraser@apple.com> 2 22 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
r239461 r241840 1644 1644 didDrawEntireCanvas(); 1645 1645 } else if (state().globalComposite == CompositeCopy) { 1646 clearCanvas(); 1647 c->drawImageBuffer(*buffer, dstRect, srcRect, ImagePaintingOptions(state().globalComposite, state().globalBlend)); 1646 if (&sourceCanvas == &canvasBase()) { 1647 if (auto copy = buffer->copyRectToBuffer(srcRect, ColorSpaceSRGB, *c)) { 1648 clearCanvas(); 1649 c->drawImageBuffer(*copy, dstRect, { { }, srcRect.size() }, ImagePaintingOptions(state().globalComposite, state().globalBlend)); 1650 } 1651 } else { 1652 clearCanvas(); 1653 c->drawImageBuffer(*buffer, dstRect, srcRect, ImagePaintingOptions(state().globalComposite, state().globalBlend)); 1654 } 1648 1655 didDrawEntireCanvas(); 1649 1656 } else { -
trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp
r237977 r241840 195 195 #endif 196 196 197 std::unique_ptr<ImageBuffer> ImageBuffer::copyRectToBuffer(const FloatRect& rect, ColorSpace colorSpace, const GraphicsContext& context) 198 { 199 if (rect.isEmpty()) 200 return nullptr; 201 202 IntSize scaledSize = ImageBuffer::compatibleBufferSize(rect.size(), context); 203 204 auto buffer = ImageBuffer::createCompatibleBuffer(scaledSize, 1, colorSpace, context); 205 if (!buffer) 206 return nullptr; 207 208 buffer->context().drawImageBuffer(*this, -rect.location()); 209 return buffer; 210 } 211 197 212 std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, ColorSpace colorSpace, const GraphicsContext& context) 198 213 { -
trunk/Source/WebCore/platform/graphics/ImageBuffer.h
r239427 r241840 71 71 WEBCORE_EXPORT static std::unique_ptr<ImageBuffer> create(const FloatSize&, RenderingMode, const GraphicsContext*, float resolutionScale = 1, ColorSpace = ColorSpaceSRGB, const HostWindow* = nullptr); 72 72 #endif 73 74 // Create an image buffer compatible with the context and copy rect from this buffer into this new one. 75 std::unique_ptr<ImageBuffer> copyRectToBuffer(const FloatRect&, ColorSpace, const GraphicsContext&); 73 76 74 77 // Create an image buffer compatible with the context, with suitable resolution for drawing into the buffer and then into this context.
Note: See TracChangeset
for help on using the changeset viewer.