ASSIGNED 227539
PixelBufferConversion.h functions should be tested so they can be modified
https://bugs.webkit.org/show_bug.cgi?id=227539
Summary PixelBufferConversion.h functions should be tested so they can be modified
Kimmo Kinnunen
Reported 2021-06-30 11:03:11 PDT
PixelBufferConversion.h functions should be tested so they can be modified more easily
Attachments
Patch (18.51 KB, patch)
2021-06-30 11:09 PDT, Kimmo Kinnunen
no flags
Patch (18.80 KB, patch)
2021-07-01 01:16 PDT, Kimmo Kinnunen
no flags
Kimmo Kinnunen
Comment 1 2021-06-30 11:09:08 PDT
Kenneth Russell
Comment 2 2021-06-30 17:24:15 PDT
Comment on attachment 432611 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=432611&action=review Looks good overall; couple of tiny questions. Setting r+ to allow this to be landed asynchronously. One question: on which EWS bot did the new test run? Looked through a few, but didn't find it. > Source/WebCore/WebCore.xcodeproj/project.pbxproj:5526 > + FD3160BF12B0272A00C1A359 /* (null) in Headers */ = {isa = PBXBuildFile; }; This change looks wrong. > Source/WebCore/WebCore.xcodeproj/project.pbxproj:31778 > + FD3160BF12B0272A00C1A359 /* (null) in Headers */, Similarly here. > Tools/TestWebKitAPI/Tests/WebCore/PixelBufferConversionTest.cpp:111 > + v = v * 255 / alpha; Here and in the premultiply routine: I never remember what intermediate types C++ promotes these mathematical expressions to. Is there a need to upcast to floating-point before dividing by alpha or 255, and then downcast back to uint8_t? > Tools/TestWebKitAPI/Tests/WebCore/PixelBufferConversionTest.cpp:228 > + EXPECT_EQ(expectedPixels, resultPixels); No tolerance necessary?
Kimmo Kinnunen
Comment 3 2021-07-01 01:16:53 PDT
Kimmo Kinnunen
Comment 4 2021-07-01 08:51:53 PDT
(In reply to Kenneth Russell from comment #2) > Comment on attachment 432611 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=432611&action=review > > Looks good overall; couple of tiny questions. Setting r+ to allow this to be > landed asynchronously. Thanks for looking and commenting! I'll revise the patch a bit later, intending to add few more test-cases. > /Tests/WebCore/PixelBufferConversionTest.cpp:111 > > + v = v * 255 / alpha; > > Here and in the premultiply routine: I never remember what intermediate > types C++ promotes these mathematical expressions to. Is there a need to > upcast to floating-point before dividing by alpha or 255, and then downcast > back to uint8_t? Not in the sense that if the definition of the premultiplication equation is in ints, these should be in ints. The equations in the test-case are intended to replicate the "this is the equation webkit uses for premultiplication" exactly. > > > Tools/TestWebKitAPI/Tests/WebCore/PixelBufferConversionTest.cpp:228 > > + EXPECT_EQ(expectedPixels, resultPixels); > > No tolerance necessary? The idea is that the premultiplication should be deterministic.
Kimmo Kinnunen
Comment 5 2021-07-01 09:01:53 PDT
> v = v * 255 / alpha; > > Here and in the premultiply routine: I never remember what intermediate > types C++ promotes these mathematical expressions to. And the types are (as far as I understand the C++ type promotion): uint8_t v int 255 uint8_t alpha Promotes v to int to do the multiplication. Promotes alpha to int to do the division. Casts the result to uint8_t for the assignment. All of the promotions in the equations just use the "int promotion rule", where types smaller than int are promoted to int to do any arithmetic.
Radar WebKit Bug Importer
Comment 6 2021-07-07 11:04:17 PDT
Note You need to log in before you can comment on or make changes to this bug.