2024-07-25 18:59:30 +00:00
|
|
|
include(skia)
|
2024-09-19 20:34:53 +00:00
|
|
|
include(vulkan)
|
2024-07-25 18:59:30 +00:00
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
set(SOURCES
|
|
|
|
AffineTransform.cpp
|
2021-09-17 07:31:48 +00:00
|
|
|
AntiAliasingPainter.cpp
|
2022-06-28 09:55:48 +00:00
|
|
|
Bitmap.cpp
|
2024-09-18 21:37:44 +00:00
|
|
|
BitmapSequence.cpp
|
2024-01-08 01:29:24 +00:00
|
|
|
CMYKBitmap.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Color.cpp
|
2023-04-30 00:35:57 +00:00
|
|
|
DeltaE.cpp
|
2024-07-05 08:40:29 +00:00
|
|
|
DeprecatedPainter.cpp
|
2024-08-08 08:22:03 +00:00
|
|
|
DeprecatedPath.cpp
|
2023-05-31 18:02:00 +00:00
|
|
|
EdgeFlagPathRasterizer.cpp
|
2023-12-09 22:42:02 +00:00
|
|
|
FontCascadeList.cpp
|
2023-01-02 19:10:00 +00:00
|
|
|
Font/Font.cpp
|
2024-07-22 11:03:58 +00:00
|
|
|
Font/FontData.cpp
|
2022-04-09 07:28:38 +00:00
|
|
|
Font/FontDatabase.cpp
|
2024-10-12 00:17:07 +00:00
|
|
|
Font/PathFontProvider.cpp
|
2022-04-09 08:14:58 +00:00
|
|
|
Font/ScaledFont.cpp
|
2024-07-25 18:59:30 +00:00
|
|
|
Font/ScaledFontSkia.cpp
|
2024-06-28 18:27:00 +00:00
|
|
|
Font/Typeface.cpp
|
2024-07-25 18:59:30 +00:00
|
|
|
Font/TypefaceSkia.cpp
|
2024-07-22 11:03:58 +00:00
|
|
|
Font/WOFF/Loader.cpp
|
|
|
|
Font/WOFF2/Loader.cpp
|
2023-01-10 01:07:06 +00:00
|
|
|
GradientPainting.cpp
|
2023-02-17 18:21:26 +00:00
|
|
|
ICC/BinaryWriter.cpp
|
2023-12-02 19:21:50 +00:00
|
|
|
ICC/Enums.cpp
|
2023-01-27 19:41:42 +00:00
|
|
|
ICC/Profile.cpp
|
2023-01-27 19:58:02 +00:00
|
|
|
ICC/Tags.cpp
|
|
|
|
ICC/TagTypes.cpp
|
2023-02-27 13:37:56 +00:00
|
|
|
ICC/WellKnownProfiles.cpp
|
2024-05-11 23:53:38 +00:00
|
|
|
ImageFormats/AnimationWriter.cpp
|
2023-03-21 18:58:06 +00:00
|
|
|
ImageFormats/BMPLoader.cpp
|
|
|
|
ImageFormats/BMPWriter.cpp
|
2023-05-26 19:04:31 +00:00
|
|
|
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
|
2023-03-21 18:58:06 +00:00
|
|
|
ImageFormats/GIFLoader.cpp
|
2024-05-03 13:57:07 +00:00
|
|
|
ImageFormats/GIFWriter.cpp
|
2023-03-21 18:58:06 +00:00
|
|
|
ImageFormats/ICOLoader.cpp
|
|
|
|
ImageFormats/ImageDecoder.cpp
|
|
|
|
ImageFormats/JPEGLoader.cpp
|
2023-07-04 04:13:34 +00:00
|
|
|
ImageFormats/JPEGXLLoader.cpp
|
2023-06-20 20:32:17 +00:00
|
|
|
ImageFormats/JPEGWriter.cpp
|
2023-03-21 18:58:06 +00:00
|
|
|
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
|
2023-07-02 21:24:01 +00:00
|
|
|
ImageFormats/TinyVGLoader.cpp
|
2023-03-21 18:58:06 +00:00
|
|
|
ImageFormats/WebPLoader.cpp
|
2024-05-08 11:57:53 +00:00
|
|
|
ImageFormats/WebPSharedLossless.cpp
|
2024-05-03 19:05:09 +00:00
|
|
|
ImageFormats/WebPWriter.cpp
|
2024-05-15 00:14:43 +00:00
|
|
|
ImageFormats/WebPWriterLossless.cpp
|
2024-07-06 07:33:38 +00:00
|
|
|
ImageFormats/AVIFLoader.cpp
|
2023-11-24 13:45:45 +00:00
|
|
|
ImmutableBitmap.cpp
|
2024-05-14 09:24:33 +00:00
|
|
|
MedianCut.cpp
|
2024-09-25 13:42:15 +00:00
|
|
|
PaintingSurface.cpp
|
2022-06-28 09:55:48 +00:00
|
|
|
Palette.cpp
|
2024-08-08 13:12:29 +00:00
|
|
|
Path.cpp
|
|
|
|
PathSkia.cpp
|
2024-07-05 13:36:55 +00:00
|
|
|
Painter.cpp
|
|
|
|
PainterSkia.cpp
|
2022-04-09 07:28:38 +00:00
|
|
|
Point.cpp
|
|
|
|
Rect.cpp
|
|
|
|
ShareableBitmap.cpp
|
|
|
|
Size.cpp
|
|
|
|
SystemTheme.cpp
|
|
|
|
TextLayout.cpp
|
|
|
|
Triangle.cpp
|
2023-07-05 18:02:00 +00:00
|
|
|
VectorGraphic.cpp
|
2024-09-19 20:34:53 +00:00
|
|
|
SkiaBackendContext.cpp
|
2022-04-09 07:28:38 +00:00
|
|
|
)
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2024-11-14 23:05:08 +00:00
|
|
|
set(SWIFT_EXCLUDE_HEADERS
|
|
|
|
MetalContext.h
|
|
|
|
VulkanContext.h
|
2024-11-10 19:42:27 +00:00
|
|
|
SkiaUtils.h
|
2024-11-14 23:05:08 +00:00
|
|
|
)
|
|
|
|
|
2024-09-26 15:01:07 +00:00
|
|
|
if (APPLE)
|
|
|
|
list(APPEND SOURCES MetalContext.mm)
|
|
|
|
endif()
|
|
|
|
|
2024-09-26 15:27:58 +00:00
|
|
|
if (HAS_VULKAN)
|
|
|
|
list(APPEND SOURCES VulkanContext.cpp)
|
|
|
|
endif()
|
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
serenity_lib(LibGfx gfx)
|
2024-07-25 18:59:30 +00:00
|
|
|
|
2024-08-27 01:02:23 +00:00
|
|
|
target_link_libraries(LibGfx PRIVATE LibCompress LibCore LibCrypto LibFileSystem LibRIFF LibTextCodec LibIPC LibUnicode LibURL)
|
2023-11-13 04:59:52 +00:00
|
|
|
|
|
|
|
set(generated_sources TIFFMetadata.h TIFFTagHandler.cpp)
|
|
|
|
list(TRANSFORM generated_sources PREPEND "ImageFormats/")
|
|
|
|
|
2024-02-16 18:59:57 +00:00
|
|
|
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
2023-11-13 04:59:52 +00:00
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${generated_sources}
|
2024-02-16 18:59:57 +00:00
|
|
|
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/TIFFGenerator.py" -o "${CMAKE_CURRENT_BINARY_DIR}/ImageFormats"
|
2023-11-13 04:59:52 +00:00
|
|
|
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}/")
|
|
|
|
|
2024-07-20 17:03:24 +00:00
|
|
|
if (ENABLE_INSTALL_HEADERS)
|
|
|
|
list(TRANSFORM generated_sources PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
|
|
|
|
install(FILES ${generated_sources} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibGfx/ImageFormats")
|
|
|
|
endif()
|
2024-06-16 14:08:31 +00:00
|
|
|
|
2024-06-24 19:08:41 +00:00
|
|
|
# Third-party
|
|
|
|
find_package(PkgConfig)
|
2024-06-18 19:06:15 +00:00
|
|
|
|
2024-06-24 19:08:41 +00:00
|
|
|
pkg_check_modules(WOFF2 REQUIRED IMPORTED_TARGET libwoff2dec)
|
|
|
|
find_package(JPEG REQUIRED)
|
2024-06-18 19:06:15 +00:00
|
|
|
find_package(PNG REQUIRED)
|
2024-07-06 07:33:38 +00:00
|
|
|
find_package(LIBAVIF REQUIRED)
|
2024-07-12 08:08:39 +00:00
|
|
|
find_package(WebP REQUIRED)
|
2024-08-27 01:02:23 +00:00
|
|
|
find_package(harfbuzz REQUIRED)
|
2024-06-24 19:08:41 +00:00
|
|
|
|
2024-08-07 18:28:42 +00:00
|
|
|
target_link_libraries(LibGfx PRIVATE PkgConfig::WOFF2 JPEG::JPEG PNG::PNG avif WebP::webp WebP::webpdecoder
|
2024-08-27 01:02:23 +00:00
|
|
|
WebP::webpdemux WebP::libwebpmux skia harfbuzz)
|
2024-07-25 00:58:00 +00:00
|
|
|
|
2024-08-07 18:28:42 +00:00
|
|
|
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()
|
|
|
|
|
2024-07-25 00:58:00 +00:00
|
|
|
if (ENABLE_SWIFT)
|
2024-11-14 23:05:08 +00:00
|
|
|
generate_clang_module_map(LibGfx GENERATED_FILES ${generated_headers} EXCLUDE_FILES ${SWIFT_EXCLUDE_HEADERS})
|
2024-07-25 00:58:00 +00:00
|
|
|
target_sources(LibGfx PRIVATE
|
|
|
|
Color.swift
|
|
|
|
)
|
2024-08-23 23:02:55 +00:00
|
|
|
target_link_libraries(LibGfx PRIVATE AK)
|
2024-08-27 01:04:05 +00:00
|
|
|
add_swift_target_properties(LibGfx LAGOM_LIBRARIES AK)
|
2024-07-25 00:58:00 +00:00
|
|
|
endif()
|
2024-09-26 15:01:07 +00:00
|
|
|
|
|
|
|
if (APPLE)
|
|
|
|
target_link_libraries(LibCore PUBLIC "-framework Metal")
|
|
|
|
endif()
|
2024-09-26 15:27:58 +00:00
|
|
|
|
|
|
|
if (HAS_VULKAN)
|
|
|
|
target_link_libraries(LibCore PUBLIC Vulkan::Vulkan Vulkan::Headers)
|
|
|
|
endif()
|