Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 23d9fb2bf1504bff9a298b56181a4da23c4b5ed8
https://github.com/WebKit/WebKit/commit/23d9fb2bf1504bff9a298b56181a4da23c4b5ed8
Author: Gerald Squelart <[email protected]>
Date: 2026-08-27 (Thu, 27 Aug 2026)
Changed paths:
M Source/WTF/wtf/StdLibExtras.h
M Source/WebCore/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations
M Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations
M Source/WebCore/platform/graphics/PixelBufferConversion.cpp
M Source/WebCore/platform/graphics/PixelFormat.h
M Tools/TestWebKitAPI/Tests/WebCore/PixelBufferConversionTests.cpp
Log Message:
-----------
Use a compile-time table of un/accelerated convertImagePixels functions, fix
BGRX8
https://bugs.webkit.org/show_bug.cgi?id=322666
rdar://185939202
Reviewed by Mike Wyrzykowski.
Instead of a full run-time sequence of decisions to determine which CG
accelerated functions to use for different sets of pixel formats and
alpha un/premultiplications, create a compile-time table pointing at
simple functions, or at a templated special-case function that can
be statically tailored (with `if constexpr` tests) to precise inputs.
E.g.:
- Same -> same: copyImagePixels().
- Premul -> Unpremul: Special case that will only do CG unpremul.
- RGB -> BGR: Only CG permute channels.
- Anything more complicated: CG any-to-any.
- If anything goes wrong, ensure that the destination buffer is zeroed.
This function table currently requires specific numeric values of
PixelFormat and AlphaPremultiplication enums so that they can be
efficiently used as indices; that's why RGBA16F was moved to 4th
position. These constraints are statically checked.
Use a similar set of template functions for the unaccelerated path.
And use the same premultiply and unpremultiply formulas as vImage
functions, for consistent results across platforms and easier testing.
Also properly handle BGRX8, always treating it as effectively
premultiplied, and avoiding incorrect channel permutations.
Test: Tools/TestWebKitAPI/Tests/WebCore/PixelBufferConversionTests.cpp
* Source/WebCore/platform/graphics/PixelBufferConversion.cpp:
(WebCore::copyImagePixels):
(WebCore::makeVImageCGImageFormat):
(WebCore::convertImagePixelsAcceleratedAnyToAny):
(WebCore::convertImagePixelsAccelerated4DifferentFormats):
(WebCore::ConvertImagePixelsFunctionTable::ConvertImagePixelsFunctionTable):
(WebCore::ConvertImagePixelsFunctionTable::get const):
(WebCore::ConvertImagePixelsFunctionTable::CountPackedEnums::static_assert):
(WebCore::ConvertImagePixelsFunctionTable::convertImagePixels4Function):
(WebCore::ConvertImagePixelsFunctionTable::createConvertImagePixels4FunctionTable4):
(WebCore::ConvertImagePixelsFunctionTable::createConvertImagePixels4FunctionTable3):
(WebCore::ConvertImagePixelsFunctionTable::createConvertImagePixels4FunctionTable2):
(WebCore::ConvertImagePixelsFunctionTable::createConvertImagePixels4FunctionTable1):
(WebCore::ConvertImagePixelsFunctionTable::createConvertImagePixels4FunctionTable):
(WebCore::convertImagePixelsAccelerated):
(WebCore::convertImagePixels):
(WebCore::makeVImageBuffer):
(WebCore::convertImagePixelsUnaccelerated4):
(WebCore::convertImagePixelsUnaccelerated3):
(WebCore::convertImagePixelsUnaccelerated2):
(WebCore::convertImagePixelsUnaccelerated1):
(WebCore::convertImagePixelsUnaccelerated):
(WebCore::hasEnoughBytesForConversion):
(WebCore::zeroImagePixels):
(WebCore::convertSinglePixelPremultipliedToPremultiplied): Deleted.
(WebCore::convertSinglePixelPremultipliedToUnpremultiplied): Deleted.
(WebCore::convertSinglePixelUnpremultipliedToPremultiplied): Deleted.
(WebCore::convertSinglePixelUnpremultipliedToUnpremultiplied): Deleted.
(WebCore::convertFunctor): Deleted.
(WebCore::premultiply):
(WebCore::unpremultiply):
(WebCore::CountPackedEnums::static_assert):
(WebCore::ConvertImagePixelsFunctionTable::getTableFunction):
(WebCore::ConvertImagePixelsFunctionTable::createTableDepth4):
(WebCore::ConvertImagePixelsFunctionTable::createTableDepth3):
(WebCore::ConvertImagePixelsFunctionTable::createTableDepth2):
(WebCore::ConvertImagePixelsFunctionTable::createTableDepth1):
(WebCore::ConvertImagePixelsFunctionTable::createTable):
(WebCore::convertImagePixelsAcceleratedDifferentFormats):
(WebCore::ConvertImagePixelsAcceleratedFunctions::get):
(WebCore::convertImagePixelsUnacceleratedFunction):
(WebCore::ConvertImagePixelsUnacceleratedFunctions::get):
(WebCore::ConvertImagePixelsFunctionTable::invoke const):
(WebCore::ConvertImagePixelsFunctionTable::selectTableFunction):
(WebCore::ConvertImagePixelsAcceleratedFunctions::selectFunction):
(WebCore::ConvertImagePixelsUnacceleratedFunctions::selectFunction):
* Source/WebCore/platform/graphics/PixelFormat.h:
(WebCore::pixelComponentOrder):
* Tools/TestWebKitAPI/Tests/WebCore/PixelBufferConversionTests.cpp:
(TestWebKitAPI::TEST(PixelBufferConversionTests, convertImagePixels)):
(TestWebKitAPI::TEST(PixelBufferConversionTests, convertImagePixels2)):
* Source/WTF/wtf/StdLibExtras.h:
(WTF::memcpySpan):
* Source/WebCore/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations:
* Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations:
Canonical link: https://commits.webkit.org/320005@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications