1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-10-13 19:02:06 +00:00
serenity/Userland/Libraries/LibGfx
Nico Weber f562c470e2 LibGfx+LibPDF: Simpler and faster N-D linear sampling
Previously, if we wanted to to e.g. do linear interpolation in 2-D,
we'd get a sample point like (1.3, 4.4), then get 4 samples around
it at (1, 4), (2, 4), (1, 5), (2, 5), then reduce the 4 samples
to 2 samples by computing the combined samples
`0.3 * f(1, 4) + 0.7 * f(2, 4)` and `0.3 * f(1, 5) + 0.8 * f(2, 5)`,
and then 1-D linearly blending between these two samples with the
factor 0.4. In the end we'd multiply the first value by 0.3 * 0.4,
the second by 0.7 * 0.4, the third by 0.3 * 0.6, and the third by
0.7 * 0.6, and then sum them all up.

This requires computing and storing 2**N samples, followed by
another 2**N iterations to combine the 2**N sampls to a single value.
(N is in practice either 4 or 3, so 2**N isn't super huge.)

Instead, for every sample we can directly compute the product of
weights and sum them up directly. This lets us omit the second loop
and storing 2**N values, in exchange for doing an additional O(n)
work to compute the product.

Takes

    Build/lagom/bin/image --no-output --invert-cmyk \
        --assign-color-profile \
            Build/lagom/Root/res/icc/Adobe/CMYK/USWebCoatedSWOP.icc \
        --convert-to-color-profile serenity-sRGB.icc \
        cmyk.jpg

form 3.42s to 3.08s on my machine, almost 10% faster (and less code).

Here cmyk.jpg is a 2253x3080 cmyk jpeg, and USWebCoatedSWOP.icc is an
mft2 profile with input tables with 256 samples and a 9x9x9x9 CLUT.

The LibPDF change is covered by TEST_CASE(sampled) in LibPDF.cpp,
and the LibGfx change is basically the same change as the one in
LibPDF (where the test results don't change) and the output
subjectively looks identical. So hopefully this causes indeed no
behavior change :^)
2024-02-04 21:49:23 +01:00
..
Filters AK: Add to_radians and to_degrees math functions 2023-09-10 08:38:29 +01:00
Font LibGfx+Userland: Move FontWeight enum into its own file 2024-01-21 09:32:10 -05:00
ICC LibGfx+LibPDF: Simpler and faster N-D linear sampling 2024-02-04 21:49:23 +01:00
ImageFormats LibGfx/PNM: Remove two fixmes 2024-02-02 08:26:40 +00:00
AffineTransform.cpp LibGfx: Add AffineTransform::determinant() 2023-07-14 06:51:05 +02:00
AffineTransform.h LibGfx: Add AffineTransform::determinant() 2023-07-14 06:51:05 +02:00
AntiAliasingPainter.cpp LibGfx: Only attempt to paint strokes with a width > 0 2023-07-16 18:52:38 +02:00
AntiAliasingPainter.h LibGfx+LibWeb: Do not ignore corner radius if it is defined in one axis 2024-01-15 15:21:17 +01:00
Bitmap.cpp Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Bitmap.h LibGfx: Add a .pam loader 2024-01-26 07:36:53 +01:00
BitmapMixer.cpp LibGfx: Add BitmapMixer 2022-01-04 21:41:14 +02:00
BitmapMixer.h LibGfx: Add BitmapMixer 2022-01-04 21:41:14 +02:00
BoundingBox.h LibGfx: Add BoundingBox helper class 2023-11-14 10:13:10 +01:00
CharacterBitmap.h Libraries: Make CharacterBitmap instances at compile-time 2022-03-04 17:41:08 +01:00
CIELAB.h LibGfx: Move CIELAB to its own file 2023-04-30 05:57:20 +02:00
ClassicStylePainter.cpp LibGfx+Userland: Remove dependency on GUI::TabWidget from StylePainter 2023-10-27 16:51:03 -06:00
ClassicStylePainter.h LibGfx+Userland: Remove dependency on GUI::TabWidget from StylePainter 2023-10-27 16:51:03 -06:00
ClassicWindowTheme.cpp LibGfx+Everywhere: Change Gfx::Rect to be endpoint exclusive 2023-05-23 12:35:42 +02:00
ClassicWindowTheme.h LibGfx: Make ClassicWindowTheme menubar heights respect the font size 2023-01-03 15:25:02 +01:00
CMakeLists.txt LibGfx: Add a .pam loader 2024-01-26 07:36:53 +01:00
CMYKBitmap.cpp LibGfx/JPEG+CMYKBitmap: Extract the CMYK to RGB conversion code 2024-01-24 22:16:22 -07:00
CMYKBitmap.h LibGfx: Add comparison operators to CMYK 2024-01-26 07:36:53 +01:00
Color.cpp Everywhere: Use to_number<T> instead of to_{int,uint,float,double} 2023-12-23 20:41:07 +01:00
Color.h LibGfx: Remove now-unused Color::from_cmyk() 2024-02-01 13:42:04 -07:00
CursorParams.cpp Everywhere: Use to_number<T> instead of to_{int,uint,float,double} 2023-12-23 20:41:07 +01:00
CursorParams.h Meta+Userland: Pass Gfx::IntPoint by value 2022-12-07 11:48:27 +01:00
DeltaE.cpp AK: Add to_radians and to_degrees math functions 2023-09-10 08:38:29 +01:00
DeltaE.h LibGfx: Add DeltaE() function 2023-04-30 05:57:20 +02:00
DisjointRectSet.h LibGfx+Everywhere: Make DisjointRectSet work for non-int Rects 2022-10-27 13:06:33 +02:00
EdgeFlagPathRasterizer.cpp LibGfx: Trim scanline to right clip in path rasterizer 2024-01-08 09:26:43 +01:00
EdgeFlagPathRasterizer.h LibGfx: Sprinkle some FLATTEN/hot attributes in the path rasterizer 2024-01-08 09:26:43 +01:00
FontCascadeList.cpp LibGfx: Don't clone fonts in FontCascadeList::extend() 2023-12-27 11:42:05 +01:00
FontCascadeList.h LibGfx+LibWeb: Produce font cascade list in CSS font matching algorithm 2023-12-10 17:32:04 +01:00
Forward.h LibGfx: Add CMYKBitmap 2024-01-10 09:39:00 +01:00
FourCC.h LibGfx: Make FourCC more useful 2023-11-24 08:42:46 +01:00
GradientPainting.cpp AK: Add to_radians and to_degrees math functions 2023-09-10 08:38:29 +01:00
Gradients.h AK: Add to_radians and to_degrees math functions 2023-09-10 08:38:29 +01:00
GrayscaleBitmap.h LibGfx: Add a simple GrayscaleBitmap class 2023-03-23 08:27:51 +00:00
ImmutableBitmap.cpp LibGfx+LibWeb: Add ImmutableBitmap for images bitmap caching in painter 2023-11-26 12:55:43 +01:00
ImmutableBitmap.h LibGfx+LibWeb: Add ImmutableBitmap for images bitmap caching in painter 2023-11-26 12:55:43 +01:00
Line.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Matrix.h LibGfx: Fix -Wdouble-promotion for float matrices 2023-05-02 17:15:48 +01:00
Matrix3x3.h LibGfx: Add Matrix3x3 2021-12-30 14:24:29 +01:00
Matrix4x4.h LibGfx: Add Gfx::extract_2d_affine_transform(Matrix4x4) helper 2023-11-18 19:32:31 +01:00
Orientation.h
Painter.cpp LibGfx: Remove Gamma.h 2024-01-30 10:02:33 +01:00
Painter.h LibGfx: Move Gfx::color_for_format() to header 2024-01-08 09:26:43 +01:00
PaintStyle.h LibGfx: Add RepeatingBitmapPaintStyle and OffsetPaintStyle 2023-12-10 16:44:24 +01:00
Palette.cpp Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Palette.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Path.cpp LibGfx: Decrease flatness a little in Path::stroke_to_fill() 2024-01-21 19:23:31 +01:00
Path.h LibGfx: Add Path::place_text_along(text, font) 2023-12-19 21:29:03 +01:00
Point.cpp Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Point.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Quad.h LibGfx: Add Gfx::Quad<T> to represent arbitrary quadrilaterals 2022-04-07 17:06:02 +02:00
Rect.cpp Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Rect.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
ShareableBitmap.cpp LibGfx: Remove indexed palette formats from Bitmap and Painter 2023-10-12 07:39:05 +02:00
ShareableBitmap.h LibIPC+Everywhere: Change IPC::encode's return type to ErrorOr 2023-01-04 11:49:15 +01:00
Size.cpp Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Size.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
StandardCursor.h Base+WindowServer+LibGfx: Add new DragCopy Cursor 2022-08-31 17:29:44 +01:00
StylePainter.cpp LibGfx+Userland: Remove dependency on GUI::TabWidget from StylePainter 2023-10-27 16:51:03 -06:00
StylePainter.h LibGfx+Userland: Remove dependency on GUI::TabWidget from StylePainter 2023-10-27 16:51:03 -06:00
SystemTheme.cpp Taskbar: Add hotkeys for theme selector menu 2024-01-14 15:16:45 -07:00
SystemTheme.h Taskbar: Add hotkeys for theme selector menu 2024-01-14 15:16:45 -07:00
TabPosition.h LibGfx+Userland: Remove dependency on GUI::TabWidget from StylePainter 2023-10-27 16:51:03 -06:00
TextAlignment.h Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
TextAttributes.h LibGfx+Userland: Make TextAttributes::underline_style optional 2023-03-15 14:55:49 +01:00
TextDirection.cpp
TextDirection.h Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
TextElision.h
TextLayout.cpp Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
TextLayout.h LibGfx: Take into account unicode ranges to find font for space glyph 2024-01-08 01:00:24 +01:00
TextWrapping.h
TIFFGenerator.py LibGfx/TIFF: Add support for Float and Double types 2024-01-22 20:50:06 -07:00
Triangle.cpp Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Triangle.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Vector2.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Vector3.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Vector4.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
VectorGraphic.cpp LibGfx+Userland: Rename Size::scaled_by to Size::scaled 2023-08-17 09:57:30 -04:00
VectorGraphic.h LibGfx: Add simple VectorGraphic abstract base class 2023-07-14 06:51:05 +02:00
VectorN.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
WindowTheme.cpp Libraries: Use default constructors/destructors in LibGfx 2022-03-17 17:23:49 +00:00
WindowTheme.h LibGfx+LibGUI+WindowServer+Apps+Demos: Replace ToolWindows 2022-08-25 13:28:50 +02:00