[webkit-changes] [WebKit/WebKit] 812ce3: ImageBufferIOSurfaceBackend should get and put dat...

Kimmo Kinnunen noreply at github.com
Fri Mar 3 02:20:32 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 812ce301dec978351734e9cd4f2b43a399599747
      https://github.com/WebKit/WebKit/commit/812ce301dec978351734e9cd4f2b43a399599747
  Author: Kimmo Kinnunen <kkinnunen at apple.com>
  Date:   2023-03-03 (Fri, 03 Mar 2023)

  Changed paths:
    M Source/WebCore/platform/graphics/ImageBuffer.cpp
    M Source/WebCore/platform/graphics/ImageBuffer.h
    M Source/WebCore/platform/graphics/ImageBufferBackend.cpp
    M Source/WebCore/platform/graphics/ImageBufferBackend.h
    M Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp
    M Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h
    M Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.cpp
    M Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h

  Log Message:
  -----------
  ImageBufferIOSurfaceBackend should get and put data in WP when in mapped mode
https://bugs.webkit.org/show_bug.cgi?id=252987
rdar://problem/105972277

Reviewed by Matt Woodrow.

Make putImageData(), getImageData() access the data directly from the
Web process when IOSurfaces are available there.

Avoids sending messages to GPU process and memcpying the contents
multiple times.

* Source/WebCore/platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::flushContext):
(WebCore::ImageBuffer::copyNativeImageForDrawing const):
(WebCore::ImageBuffer::draw):
(WebCore::ImageBuffer::getPixelBuffer const):
(WebCore::ImageBuffer::putPixelBuffer):
Before, the ImageBuffer would flush the drawing context,
e.g. the IPC commands to the GPUP and flush the draws there,
and then it would flush the backend context.
Move the backend maintainance into the backend functions, as it is
internal detail of the backend.
Instead just flush the drawing context, which on non-GPUP case
flushes the real IOSurface context and GPUP case flushes through
the IPC.

* Source/WebCore/platform/graphics/ImageBuffer.h:
* Source/WebCore/platform/graphics/ImageBufferBackend.cpp:
(WebCore::ImageBufferBackend::copyNativeImageForDrawing):
Provide the destination context to copyNativeImageForDrawing instead
of unused BackingStoreCopy argument.

* Source/WebCore/platform/graphics/ImageBufferBackend.h:
* Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
(WebCore::ImageBufferIOSurfaceBackend::invalidateCachedNativeImage):
(WebCore::ImageBufferIOSurfaceBackend::copyNativeImageForDrawing):
Fix the copyNativeImageForDrawing(). Before, it would return a CGImage
but not mark the m_mayHaveOutstandingBackingStoreReferences. The intention
was that instead, it would call invalidateCachedNativeImage() to cleanup
the bitmap cache from the cached CGImage. However, this would still leave
some backends, like display list and iosurface, to reference the IOSurface
without ImageBufferIOSurfaceBackend knowing about it. In these cases,
putImageData could change the underlying IOSurface before the display list
or iosurface renderer would have completed their use.

Instead, use CGIOSurfaceContextCreateImageReference which has the added
benefit of not needing the fixup case for cleaning up the memory footprint
after bitmap rendering.

(WebCore::ImageBufferIOSurfaceBackend::getPixelBuffer):
Flush the writes through the backends drawing context.

(WebCore::ImageBufferIOSurfaceBackend::putPixelBuffer):
Flush the writes through the drawing context and CGImage reads.

(WebCore::ImageBufferIOSurfaceBackend::surface):
(WebCore::ImageBufferIOSurfaceBackend::ensureNativeImagesHaveCopiedBackingStore):
(WebCore::ImageBufferIOSurfaceBackend::prepareForExternalRead):
(WebCore::ImageBufferIOSurfaceBackend::prepareForExternalWrite):
(WebCore::ImageBufferIOSurfaceBackend::invalidateCachedNativeImageIfNeeded): Deleted.
(WebCore::ImageBufferIOSurfaceBackend::finalizeDrawIntoContext): Deleted.
* Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h:

* Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.cpp:
(WebKit::RemoteImageBufferProxy::copyNativeImageForDrawing const):
(WebKit::RemoteImageBufferProxy::getPixelBuffer const):
(WebKit::RemoteImageBufferProxy::putPixelBuffer):
The remote proxy putPutlBuffer/getPixelBuffer can now directly call the
normal ImageBufferIOSurfaceBackend codepath for the put/get.
The IPC is flushed by the ImageBuffer calling flushDrawingContext()
The pending read references through the local iosurface are maintained
by the ImageBufferIOSurfaceBackend.
* Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
The m_needsFlush needs to be flipped to true, since now the first
command might be local putPixelBuffer. This needs to complete after
the initial CGContextFillRect that clears the IOSurface.
Before this was not needed, as all the commands were executed on GPUP
side.

Canonical link: https://commits.webkit.org/261130@main




More information about the webkit-changes mailing list