haikuwebkit/Source/WebCore/platform/graphics/coreimage
Kimmo Kinnunen 4b52f436ac AcceleratedImageBuffer not instantiated but objects are punned to the type
https://bugs.webkit.org/show_bug.cgi?id=226917

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-06-14
Reviewed by Said Abou-Hallawa.

Source/WebCore:

AcceleratedImageBuffer::create would create instance
of ConcreteImageBuffer, not AcceleratedImageBuffer.

Fix by adding a correct create static function.

Tested by new test:
TestWebKitAPI.ImageBufferTests.ImageBufferSubTypeCreateCreatesSubtypes

* platform/graphics/PlatformImageBuffer.h:
(WebCore::IOSurfaceImageBuffer::create):
(WebCore::IOSurfaceImageBuffer::IOSurfaceImageBuffer):
Add the correct factory functions and public constructors.

* platform/graphics/cg/ImageBufferCGBitmapBackend.h:
Add export statements that are needed for the added test.

* platform/graphics/coreimage/FilterEffectRendererCoreImage.mm:
(WebCore::FilterEffectRendererCoreImage::imageForSourceGraphic):
(WebCore::FilterEffectRendererCoreImage::renderToImageBuffer):
Change the image creation site to create the explicit IOSurfaceImageBuffer
since that's what it's trying to create.
Change the type-punning call sites to use explicit
IOSurfaceImageBuffer name, as that's what the call site
is intending to use.

Tools:

Add new test
TestWebKitAPI.ImageBufferTests.ImageBufferSubTypeCreateCreatesSubtypes
to test that the code compiles.
Before, it would fail with:
  `error: cannot initialize a member subobject of type 'typename PtrTraits::StorageType' (aka 'WebCore::AcceleratedImageBuffer *') with an
   rvalue of type 'WebCore::ConcreteImageBuffer<WebCore::ImageBufferIOSurfaceBackend> *'`

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp: Added.
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/238783@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278832 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-14 17:27:47 +00:00
..
FilterEffectRendererCoreImage.h AcceleratedImageBuffer not instantiated but objects are punned to the type 2021-06-14 17:27:47 +00:00
FilterEffectRendererCoreImage.mm AcceleratedImageBuffer not instantiated but objects are punned to the type 2021-06-14 17:27:47 +00:00