Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ef17f9b10e301dea11025d6d1cb0c8cdb0573328
      
https://github.com/WebKit/WebKit/commit/ef17f9b10e301dea11025d6d1cb0c8cdb0573328
  Author: Kimmo Kinnunen <[email protected]>
  Date:   2026-08-27 (Thu, 27 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 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.

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.

* 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::drawImage):
(WebCore::CanvasRenderingContext2DBase::clearCanvas):
(WebCore::drawImageToContext):
(WebCore::CanvasRenderingContext2DBase::drawSourceImage):
(WebCore::CanvasRenderingContext2DBase::didDraw):
* 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::markContextChangedAndNotifyCanvasObservers):
(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/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::markContextChangedAndNotifyCanvasObserver):
(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/319967@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to