Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: de2a960750b443dee78aa7eb332f9e3d899d40ff
https://github.com/WebKit/WebKit/commit/de2a960750b443dee78aa7eb332f9e3d899d40ff
Author: Kimmo Kinnunen <[email protected]>
Date: 2026-08-31 (Mon, 31 Aug 2026)
Changed paths:
A
LayoutTests/fast/canvas/webgl/lost-context-canvas-image-source-expected.txt
A LayoutTests/fast/canvas/webgl/lost-context-canvas-image-source.html
M PerformanceTests/Canvas/drawImageSourceCanvas2D.html
A PerformanceTests/Canvas/drawImageSourceCanvas2DSelf.html
M Source/WebCore/html/CanvasBase.cpp
M Source/WebCore/html/CanvasBase.h
M Source/WebCore/html/HTMLCanvasElement.cpp
M Source/WebCore/html/OffscreenCanvas.cpp
M Source/WebCore/html/canvas/CanvasRenderingContext.h
M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h
M Source/WebCore/html/canvas/GPUCanvasContextCocoa.h
M Source/WebCore/html/canvas/GPUCanvasContextCocoa.mm
M Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp
M Source/WebCore/html/canvas/ImageBitmapRenderingContext.h
M Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp
M Source/WebCore/html/canvas/PlaceholderRenderingContext.cpp
M Source/WebCore/html/canvas/PlaceholderRenderingContext.h
M Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
M Source/WebCore/html/canvas/WebGLRenderingContextBase.h
M Source/WebCore/platform/graphics/skia/GraphicsContextGLSkia.cpp
Log Message:
-----------
Use copyNativeImage in 2D context drawImage
https://bugs.webkit.org/show_bug.cgi?id=322254
rdar://185487825
Reviewed by Dan Glastonbury.
Reland: original 319967@main
Fixes perf problem by adding the self-copy workaround for all codepaths
of Canvas as drawImage source. Adds a perf test.
Obtain the draw source as NativeImage in
CanvasRenderingContext2DBase::drawImage(). This continues the refactor
to use NativeImages as the only draw source, removing ImageBuffers.
Implements the fast path for WebGL as an example: WebGL provides
the GPUP side NativeImage as the result.
Later commits will modify other canvas rendering contexts to obtain
the image directly as a NativeImage.
Fixes Skia GraphicsContextGLImageExtractor to not assume
NativeImages are BGRA. The below
GraphicsContextGL::createNativeImageFromPixelBuffer already produces
RGBA images.
* LayoutTests/fast/canvas/webgl/lost-context-canvas-image-source-expected.txt:
Added.
* LayoutTests/fast/canvas/webgl/lost-context-canvas-image-source.html: Added.
* PerformanceTests/Canvas/drawImageSourceCanvas2D.html:
* PerformanceTests/Canvas/drawImageSourceCanvas2DSelf.html: Copied from
PerformanceTests/Canvas/drawImageSourceCanvas2D.html.
* Source/WebCore/html/CanvasBase.cpp:
(WebCore::CanvasBase::copyNativeImage const):
* Source/WebCore/html/CanvasBase.h:
* Source/WebCore/html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::copiedImage const):
* Source/WebCore/html/OffscreenCanvas.cpp:
(WebCore::OffscreenCanvas::copiedImage const):
* Source/WebCore/html/canvas/CanvasRenderingContext.h:
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::surfaceBufferToNativeImage):
(WebCore::CanvasRenderingContext2DBase::didUpdateCanvasSizeProperties):
(WebCore::CanvasRenderingContext2DBase::setLineCap):
(WebCore::CanvasRenderingContext2DBase::drawImage):
(WebCore::drawImageToContext):
(WebCore::CanvasRenderingContext2DBase::createPattern):
(WebCore::CanvasRenderingContext2DBase::willUpdateContents):
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h:
* Source/WebCore/html/canvas/GPUCanvasContextCocoa.h:
* Source/WebCore/html/canvas/GPUCanvasContextCocoa.mm:
(WebCore::GPUCanvasContextCocoa::didUpdateCanvasSizeProperties):
(WebCore::GPUCanvasContextCocoa::surfaceBufferToNativeImage):
(WebCore::GPUCanvasContextCocoa::transferToImageBuffer):
(WebCore::GPUCanvasContextCocoa::unconfigure):
(WebCore::GPUCanvasContextCocoa::prepareForDisplay):
(WebCore::GPUCanvasContextCocoa::willUpdateDisplayBufferContents):
(WebCore::GPUCanvasContextCocoa::updateMemoryCost const):
* Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp:
(WebCore::ImageBitmapRenderingContext::transferFromImageBitmap):
(WebCore::ImageBitmapRenderingContext::transferToImageBuffer):
(WebCore::ImageBitmapRenderingContext::surfaceBufferToNativeImage):
* Source/WebCore/html/canvas/ImageBitmapRenderingContext.h:
* Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp:
(WebCore::OffscreenCanvasRenderingContext2D::transferToImageBuffer):
* Source/WebCore/html/canvas/PlaceholderRenderingContext.cpp:
(WebCore::PlaceholderRenderingContext::setPlaceholderBuffer):
(WebCore::PlaceholderRenderingContext::surfaceBufferToNativeImage):
* Source/WebCore/html/canvas/PlaceholderRenderingContext.h:
* Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::initializeContextState):
(WebCore::WebGLRenderingContextBase::willUpdateDrawingBufferContents):
(WebCore::WebGLRenderingContextBase::ReadSurfaceBuffer::clear):
(WebCore::WebGLRenderingContextBase::ReadSurfaceBuffer::memoryCost const):
(WebCore::WebGLRenderingContextBase::readSurfaceBuffer):
(WebCore::WebGLRenderingContextBase::surfaceBufferToNativeImage):
(WebCore::WebGLRenderingContextBase::surfaceBufferToImageBuffer):
(WebCore::WebGLRenderingContextBase::didUpdateCanvasSizeProperties):
(WebCore::WebGLRenderingContextBase::prepareForDisplay):
(WebCore::WebGLRenderingContextBase::updateMemoryCost const):
* Source/WebCore/html/canvas/WebGLRenderingContextBase.h:
(WebCore::WebGLRenderingContextBase::ReadSurfaceBuffer::isEmpty const):
* Source/WebCore/platform/graphics/skia/GraphicsContextGLSkia.cpp:
(WebCore::dataFormatForColorType):
(WebCore::GraphicsContextGLImageExtractor::extractImage):
Canonical link: https://commits.webkit.org/320153@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications