mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGfx: Simplify some excessive use of pow() in scanline unfiltering
This commit is contained in:
parent
d9f933df7b
commit
0b1a40a6fe
Notes:
sideshowbarker
2024-07-19 04:34:00 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0b1a40a6fe8
1 changed files with 4 additions and 3 deletions
|
@ -364,6 +364,7 @@ NEVER_INLINE FLATTEN static void unfilter(PNGLoadingContext& context)
|
|||
} else if (context.bit_depth == 16) {
|
||||
unpack_grayscale_without_alpha<u16>(context);
|
||||
} else if (context.bit_depth == 1 || context.bit_depth == 2 || context.bit_depth == 4) {
|
||||
auto bit_depth_squared = context.bit_depth = context.bit_depth;
|
||||
auto pixels_per_byte = 8 / context.bit_depth;
|
||||
auto mask = (1 << context.bit_depth) - 1;
|
||||
for (int y = 0; y < context.height; ++y) {
|
||||
|
@ -372,9 +373,9 @@ NEVER_INLINE FLATTEN static void unfilter(PNGLoadingContext& context)
|
|||
auto bit_offset = (8 - context.bit_depth) - (context.bit_depth * (x % pixels_per_byte));
|
||||
auto value = (gray_values[x / pixels_per_byte] >> bit_offset) & mask;
|
||||
auto& pixel = (Pixel&)context.bitmap->scanline(y)[x];
|
||||
pixel.r = value * (0xff / pow(context.bit_depth, 2));
|
||||
pixel.g = value * (0xff / pow(context.bit_depth, 2));
|
||||
pixel.b = value * (0xff / pow(context.bit_depth, 2));
|
||||
pixel.r = value * (0xff / bit_depth_squared);
|
||||
pixel.g = value * (0xff / bit_depth_squared);
|
||||
pixel.b = value * (0xff / bit_depth_squared);
|
||||
pixel.a = 0xff;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue