[webkit-changes] [WebKit/WebKit] a4350b: MotionMark Images subtest rendering is incorrect o...

Kimmo Kinnunen noreply at github.com
Mon Feb 27 23:59:14 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a4350b5e3b698b76790a7e2c9cc0f58f5ee66fcc
      https://github.com/WebKit/WebKit/commit/a4350b5e3b698b76790a7e2c9cc0f58f5ee66fcc
  Author: Kimmo Kinnunen <kkinnunen at apple.com>
  Date:   2023-02-27 (Mon, 27 Feb 2023)

  Changed paths:
    A LayoutTests/fast/canvas/small-canvas-layer-putImageData-expected.html
    A LayoutTests/fast/canvas/small-canvas-layer-putImageData.html
    M Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h
    M Source/WebCore/WebCore.order
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp
    M Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h
    M Source/WebCore/platform/graphics/GraphicsContext.h
    M Source/WebCore/platform/graphics/NullGraphicsContext.h
    M Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm
    M Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
    M Source/WebCore/platform/graphics/cg/GraphicsContextCG.h
    R Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
    M Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp
    M Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm
    M Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp
    M Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h
    M Source/WebCore/platform/graphics/mac/WebLayer.mm
    M Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
    M Source/WebKitLegacy/mac/WebView/WebFrame.mm
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp
    A Tools/TestWebKitAPI/Tests/WebCore/cg/GraphicsContextCGTests.mm
    R Tools/TestWebKitAPI/Tests/WebCore/cg/GraphicsContextTestsCG.cpp

  Log Message:
  -----------
  MotionMark Images subtest rendering is incorrect on ASi (no dissolve effect)
https://bugs.webkit.org/show_bug.cgi?id=252482
rdar://problem/105606592

Reviewed by Simon Fraser.

Fix rendering of accelerated canvas elements into small layer tiles
after putImageData.

ImageBufferIOSurfaceBackend::putPixelBuffer would clean the CGImage
cache, if there's possibility that the cache exists.

ImageBufferIOSurfaceBackend::copyNativeImageForDrawing() does not
currently mark the cache as being active. Instead, it relies on
after-the-fact cleanup via
ImageBufferIOSurfaceBackend::finalizeDrawIntoContext().

ImageBufferIOSurfaceBackend::finalizeDrawIntoContext() would only
cleanup if the draw happened on an non-accelerated context.

Accelerated context status would be determined by whether WebKit
requested the layer to be accelerated.

In case the layer is small, CoreAnimation might give a bitmap-backed
CGContext for the drawing context, even though WebKit
requested an accelerated context. WebKit would
mark the context as accelerated, even when it was not.

This would lead into scenario where the CGImage cache would not be
cleaned after each draw, and hence putImageData would not be visible.

Fix by removing the GraphicsContextCG::setIsAcceleratedContext().
Instead, query the actual state from the CGContext.

Adds a test in ImageBufferTests that tests the code paths. This test
would not have caught the issue, since the bug as incorrect use of
setIsAcceleratedContext() rooted from PlatformCALayer::drawLayerContents.
Nevertheless, the test would have given a bit more confidence that the
complicated invalidation logic was correct in the specific case.

Adds a trivial test for the acceleration status query based on the
CGContext.

* Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp:
(WebCore::BifurcatedGraphicsContext::setIsAcceleratedContext): Deleted.
* Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h:
* Source/WebCore/platform/graphics/GraphicsContext.h:
* Source/WebCore/platform/graphics/NullGraphicsContext.h:
* Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(WebCore::PlatformCALayer::drawLayerContents):
* Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContextCG::renderingMode const):
(WebCore::GraphicsContextCG::setIsAcceleratedContext): Deleted.
* Source/WebCore/platform/graphics/cg/GraphicsContextCG.h:
* Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
* Source/WebCore/platform/graphics/cocoa/IOSurface.mm:
(WebCore::IOSurface::ensureGraphicsContext):
* Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h:
* Source/WebCore/platform/graphics/mac/WebLayer.mm:
(-[WebSimpleLayer drawInContext:]):
* Source/WebKitLegacy/mac/WebView/WebFrame.mm:
(-[WebFrame _drawRect:contentsOnly:]):
* Tools/TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp:
(TestWebKitAPI::imageBufferPixelIs):
(TestWebKitAPI::hasTestPattern):
(TestWebKitAPI::drawTestPattern):
(TestWebKitAPI::createPixelBufferTestPattern):
(TestWebKitAPI::toImageBufferOptions):
(TestWebKitAPI::PreserveResolutionOperationTest::imageBufferOptions const):
(TestWebKitAPI::TEST_P):
(TestWebKitAPI::AnyScaleTest::imageBufferOptions const):
(TestWebKitAPI::AnyTwoImageBufferOptionsTest::imageBufferOptions0 const):
(TestWebKitAPI::AnyTwoImageBufferOptionsTest::imageBufferOptions1 const):
* Tools/TestWebKitAPI/Tests/WebCore/cg/GraphicsContextTestsCG.cpp:
(TestWebKitAPI::TEST):
* LayoutTests/fast/canvas/small-canvas-layer-putImageData-expected.html:
* LayoutTests/fast/canvas/small-canvas-layer-putImageData.html:
  Added.

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




More information about the webkit-changes mailing list