ladybird/Libraries/LibGfx/CMakeLists.txt

154 lines
4.2 KiB
Text
Raw Normal View History

include(skia)
include(vulkan)
set(SOURCES
AffineTransform.cpp
AntiAliasingPainter.cpp
Bitmap.cpp
BitmapSequence.cpp
CMYKBitmap.cpp
Color.cpp
2023-04-30 00:35:57 +00:00
DeltaE.cpp
DeprecatedPainter.cpp
2024-08-08 08:22:03 +00:00
DeprecatedPath.cpp
EdgeFlagPathRasterizer.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
LibGfx/TIFF: Add support for images with CCITT3 1D compression This compression (tag Compression=2) is not very popular on its own, but a base to implement CCITT3 2D and CCITT4 compressions. As the format has no real benefits, it is quite hard to find an app that accepts tho encode that for you. So I used the following program that calls `libtiff` directly: ```cpp #include <vector> #include <cstdlib> #include <iostream> #include <tiffio.h> // An array containing 0 and 1 of length width * height. extern std::vector<uint8_t> array; int main() { // From: https://stackoverflow.com/a/34257789 TIFF *image = TIFFOpen("input.tif", "w"); int const width = 400; int const height = 300; TIFFSetField(image, TIFFTAG_IMAGEWIDTH, width); TIFFSetField(image, TIFFTAG_IMAGELENGTH, height); TIFFSetField(image, TIFFTAG_PHOTOMETRIC, 0); TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_CCITTRLE); TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, 1); std::vector<uint8_t> scan_line(width / 8 + 8, 0); int count = 0; for (int i = 0; i < height; i++) { std::fill(scan_line.begin(), scan_line.end(), 0); for (int x = 0; x < width; ++x) { uint8_t eight_pixels = scan_line.at(x / 8); eight_pixels = eight_pixels << 1; eight_pixels |= !array.at(i * width + x); scan_line.at(x / 8) = eight_pixels; } int bytes = int(width / 8.0 + 0.5); if (TIFFWriteScanline(image, scan_line.data(), i, bytes) != 1) std::cerr << "Something went wrong\n"; } TIFFClose(image); } ```
2023-11-25 21:34:56 +00:00
ImageFormats/CCITTDecoder.cpp
ImageFormats/GIFLoader.cpp
ImageFormats/GIFWriter.cpp
ImageFormats/ICOLoader.cpp
ImageFormats/ImageDecoder.cpp
ImageFormats/JPEGLoader.cpp
ImageFormats/JPEGXLLoader.cpp
ImageFormats/JPEGWriter.cpp
ImageFormats/PNGLoader.cpp
ImageFormats/PNGWriter.cpp
LibGfx/TIFF: Add support for images with CCITT3 1D compression This compression (tag Compression=2) is not very popular on its own, but a base to implement CCITT3 2D and CCITT4 compressions. As the format has no real benefits, it is quite hard to find an app that accepts tho encode that for you. So I used the following program that calls `libtiff` directly: ```cpp #include <vector> #include <cstdlib> #include <iostream> #include <tiffio.h> // An array containing 0 and 1 of length width * height. extern std::vector<uint8_t> array; int main() { // From: https://stackoverflow.com/a/34257789 TIFF *image = TIFFOpen("input.tif", "w"); int const width = 400; int const height = 300; TIFFSetField(image, TIFFTAG_IMAGEWIDTH, width); TIFFSetField(image, TIFFTAG_IMAGELENGTH, height); TIFFSetField(image, TIFFTAG_PHOTOMETRIC, 0); TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_CCITTRLE); TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, 1); std::vector<uint8_t> scan_line(width / 8 + 8, 0); int count = 0; for (int i = 0; i < height; i++) { std::fill(scan_line.begin(), scan_line.end(), 0); for (int x = 0; x < width; ++x) { uint8_t eight_pixels = scan_line.at(x / 8); eight_pixels = eight_pixels << 1; eight_pixels |= !array.at(i * width + x); scan_line.at(x / 8) = eight_pixels; } int bytes = int(width / 8.0 + 0.5); if (TIFFWriteScanline(image, scan_line.data(), i, bytes) != 1) std::cerr << "Something went wrong\n"; } TIFFClose(image); } ```
2023-11-25 21:34:56 +00:00
ImageFormats/TIFFLoader.cpp
ImageFormats/TinyVGLoader.cpp
ImageFormats/WebPLoader.cpp
ImageFormats/WebPSharedLossless.cpp
ImageFormats/WebPWriter.cpp
ImageFormats/WebPWriterLossless.cpp
ImageFormats/AVIFLoader.cpp
ImmutableBitmap.cpp
MedianCut.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
2024-11-10 19:42:27 +00:00
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)
2024-08-06 02:46:26 +00:00
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()