Files
ladybird/Libraries/LibGfx/CMakeLists.txt
Lucas CHOLLET bd93285811 LibGfx+LibWeb: Do some color management on images with an ICC profile
This patch introduces the `Gfx::ColorSpace` class, this is basically a
serializable wrapper for skia's SkColorSpace. Creation of the instances
of this class (and thus ICC profiles parsing) is performed in the
ImageDecoder process. Then the object is serialized and sent through
IPC, to finally be handed to skia for rendering.

However, to make sure that we're not making all LibGfx's users dependent
on Skia as well, we need to ensure the `Gfx::ColorSpace` object has no
dependency on objects from Skia. To that end, the only member of the
`ColorSpace` class is the opaque `ColorSpaceImpl` struct. Though, there
is on issue with that design, the code in `DisplayListPlayer.cpp` needs
access to the underlying `sk_sp<SkColorSpace>`. It is provided by a
template function, that is only specialized for this type.

Doing this work allows us to pass the following WPT tests:
- https://wpt.live/css/css-color/tagged-images-001.html
- https://wpt.live/css/css-color/tagged-images-003.html
- https://wpt.live/css/css-color/tagged-images-004.html
- https://wpt.live/css/css-color/untagged-images-001.html

Other test cases can also be found here:
- https://github.com/svgeesus/PNG-ICC-tests

Note that SkColorSpace support quite a limited amount of color spaces,
so color profiles like the ones in [1] or the v4 profiles in [2] are not
supported yet. In fact, SkColorSpace only accepts skcms_ICCProfile with
a linear conversion to XYZ D50.

[1] https://www.color.org/browsertest.xalter
[2] https://www.color.org/version4html.xalter
2024-12-05 17:16:41 +01:00

149 lines
4.1 KiB
CMake

include(skia)
include(vulkan)
set(SOURCES
AffineTransform.cpp
Bitmap.cpp
BitmapSequence.cpp
CMYKBitmap.cpp
Color.cpp
ColorSpace.cpp
DeltaE.cpp
FontCascadeList.cpp
Font/Font.cpp
Font/FontData.cpp
Font/FontDatabase.cpp
Font/PathFontProvider.cpp
Font/ScaledFont.cpp
Font/ScaledFontSkia.cpp
Font/Typeface.cpp
Font/TypefaceSkia.cpp
Font/WOFF/Loader.cpp
Font/WOFF2/Loader.cpp
GradientPainting.cpp
ICC/BinaryWriter.cpp
ICC/Enums.cpp
ICC/Profile.cpp
ICC/Tags.cpp
ICC/TagTypes.cpp
ICC/WellKnownProfiles.cpp
ImageFormats/AnimationWriter.cpp
ImageFormats/BMPLoader.cpp
ImageFormats/BMPWriter.cpp
ImageFormats/BooleanDecoder.cpp
ImageFormats/CCITTDecoder.cpp
ImageFormats/GIFLoader.cpp
ImageFormats/ICOLoader.cpp
ImageFormats/ImageDecoder.cpp
ImageFormats/JPEGLoader.cpp
ImageFormats/JPEGXLLoader.cpp
ImageFormats/JPEGWriter.cpp
ImageFormats/PNGLoader.cpp
ImageFormats/PNGWriter.cpp
ImageFormats/TIFFLoader.cpp
ImageFormats/TinyVGLoader.cpp
ImageFormats/WebPLoader.cpp
ImageFormats/WebPSharedLossless.cpp
ImageFormats/WebPWriter.cpp
ImageFormats/WebPWriterLossless.cpp
ImageFormats/AVIFLoader.cpp
ImmutableBitmap.cpp
PaintingSurface.cpp
Palette.cpp
Path.cpp
PathSkia.cpp
Painter.cpp
PainterSkia.cpp
Point.cpp
Rect.cpp
ShareableBitmap.cpp
Size.cpp
SystemTheme.cpp
TextLayout.cpp
Triangle.cpp
VectorGraphic.cpp
SkiaBackendContext.cpp
)
set(SWIFT_EXCLUDE_HEADERS
MetalContext.h
VulkanContext.h
SkiaUtils.h
)
if (APPLE)
list(APPEND SOURCES MetalContext.mm)
endif()
if (HAS_VULKAN)
list(APPEND SOURCES VulkanContext.cpp)
endif()
serenity_lib(LibGfx gfx)
target_link_libraries(LibGfx PRIVATE LibCompress LibCore LibCrypto LibFileSystem LibRIFF LibTextCodec LibIPC LibUnicode LibURL)
set(generated_sources TIFFMetadata.h TIFFTagHandler.cpp)
list(TRANSFORM generated_sources PREPEND "ImageFormats/")
find_package(Python3 COMPONENTS Interpreter REQUIRED)
add_custom_command(
OUTPUT ${generated_sources}
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/TIFFGenerator.py" -o "${CMAKE_CURRENT_BINARY_DIR}/ImageFormats"
DEPENDS "TIFFGenerator.py"
VERBATIM
)
target_sources(LibGfx PRIVATE ${generated_sources})
add_custom_target(generate_tiff_files_handler DEPENDS ${generated_sources})
add_dependencies(all_generated generate_tiff_files_handler)
add_dependencies(LibGfx generate_tiff_files_handler)
set(generated_headers ${generated_sources})
list(FILTER generated_headers INCLUDE REGEX "\\.h$")
list(TRANSFORM generated_headers PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
if (ENABLE_INSTALL_HEADERS)
list(TRANSFORM generated_sources PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
install(FILES ${generated_sources} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibGfx/ImageFormats")
endif()
# Third-party
find_package(PkgConfig)
pkg_check_modules(WOFF2 REQUIRED IMPORTED_TARGET libwoff2dec)
find_package(JPEG REQUIRED)
find_package(PNG REQUIRED)
find_package(LIBAVIF REQUIRED)
find_package(WebP REQUIRED)
find_package(harfbuzz REQUIRED)
target_link_libraries(LibGfx PRIVATE PkgConfig::WOFF2 JPEG::JPEG PNG::PNG avif WebP::webp WebP::webpdecoder
WebP::webpdemux WebP::libwebpmux skia harfbuzz)
if (NOT ANDROID)
pkg_check_modules(Jxl REQUIRED IMPORTED_TARGET libjxl)
target_link_libraries(LibGfx PRIVATE PkgConfig::Jxl)
else()
find_package(libjxl REQUIRED)
find_package(hwy REQUIRED)
target_link_libraries(LibGfx PRIVATE libjxl::libjxl hwy::hwy)
endif()
if (ENABLE_SWIFT)
generate_clang_module_map(LibGfx GENERATED_FILES ${generated_headers} EXCLUDE_FILES ${SWIFT_EXCLUDE_HEADERS})
target_sources(LibGfx PRIVATE
Color.swift
)
target_link_libraries(LibGfx PRIVATE AK)
add_swift_target_properties(LibGfx LAGOM_LIBRARIES AK)
endif()
if (APPLE)
target_link_libraries(LibCore PUBLIC "-framework Metal")
endif()
if (HAS_VULKAN)
target_link_libraries(LibCore PUBLIC Vulkan::Vulkan Vulkan::Headers)
endif()