[webkit-changes] [WebKit/WebKit] 9e8259: ImageBufferIOSurfaceBackend should flush only when...

Kimmo Kinnunen noreply at github.com
Thu Mar 23 01:58:23 PDT 2023


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

  Changed paths:
    M Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
    M Source/WebCore/platform/graphics/cg/GraphicsContextCG.h
    M Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp
    M Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h
    M Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h
    M Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/cg/GraphicsContextCGTests.mm

  Log Message:
  -----------
  ImageBufferIOSurfaceBackend should flush only when GraphicsContextCG has drawn
https://bugs.webkit.org/show_bug.cgi?id=253309
rdar://106192612

Reviewed by Simon Fraser.

Track draws in GraphicsContextCG. Currently it overestimates when the
draw happens.

Use this information in ImageBufferIOSurfaceBackend. The backend
needs to know if the surface has been drawn to before doing an external
operation. If draw to has happened, the drawing context needs to be
flushed before external operation can happen. Conversely, the flush
can be skipped if we know that there was no drawing.

Consider case:
i1.draw(something);   // Initial image
i1.getPixelBuffer();  // Flush
i1.putPixelBuffer();  // No flush needed, no draws since flush. <-- example of skipped flush.
i2.draw(i1);          // Creates an image from i1 (flushes currently).

i1.getPixelBuffer();  // No flush <-- example of skipped flush.
i1.putPixelBuffer();  // Invalidates, flush needed due to invalidate, no draws.
i2.draw(i1);          // Creates an image from i1 (flushes currently).

* Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContextCG::platformContext const):
(WebCore::GraphicsContextCG::contextForDraw):
(WebCore::GraphicsContextCG::contextForState const):
(WebCore::GraphicsContextCG::save):
(WebCore::GraphicsContextCG::restore):
(WebCore::GraphicsContextCG::consumeHasDrawn):
* Source/WebCore/platform/graphics/cg/GraphicsContextCG.h:
* Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
(WebCore::ImageBufferIOSurfaceBackend::context):
(WebCore::ImageBufferIOSurfaceBackend::flushContext):
(WebCore::ImageBufferIOSurfaceBackend::flushContextIfNeeded):
(WebCore::ImageBufferIOSurfaceBackend::invalidateCachedNativeImage):
(WebCore::ImageBufferIOSurfaceBackend::copyNativeImage):
(WebCore::ImageBufferIOSurfaceBackend::copyNativeImageForDrawing):
(WebCore::ImageBufferIOSurfaceBackend::prepareForExternalRead):
(WebCore::ImageBufferIOSurfaceBackend::prepareForExternalWrite):
(WebCore::ImageBufferIOSurfaceBackend::ensureSurfaceContext):
(WebCore::ImageBufferIOSurfaceBackend::createImage):
(WebCore::ImageBufferIOSurfaceBackend::createImageReference):
* Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h:
* Tools/TestWebKitAPI/Tests/WebCore/cg/GraphicsContextCGTests.mm:
(TestWebKitAPI::TEST):

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




More information about the webkit-changes mailing list