diff --git a/CMakeLists.txt b/CMakeLists.txt index 9802b82faa..b8724a8d23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,8 +53,10 @@ endif () if (MACOS OR IOS) option(PAG_BUILD_FRAMEWORK "Allow build framework" ON) + option(PAG_USE_SYSTEM_LZ4 "Allow use of system lz4 library" ON) else () set(PAG_BUILD_FRAMEWORK OFF) + set(PAG_USE_SYSTEM_LZ4 OFF) endif () if ($ENV{CLION_IDE}) @@ -85,12 +87,14 @@ endif () if (PAG_BUILD_TESTS) set(PAG_USE_FREETYPE ON) set(PAG_USE_HARFBUZZ ON) + set(PAG_USE_SYSTEM_LZ4 OFF) set(PAG_BUILD_SHARED OFF) endif () message("PAG_USE_LIBAVC: ${PAG_USE_LIBAVC}") message("PAG_USE_RTTR: ${PAG_USE_RTTR}") message("PAG_USE_HARFBUZZ: ${PAG_USE_HARFBUZZ}") +message("PAG_USE_SYSTEM_LZ4: ${PAG_USE_SYSTEM_LZ4}") message("PAG_USE_C: ${PAG_USE_C}") message("PAG_BUILD_SHARED: ${PAG_BUILD_SHARED}") message("PAG_BUILD_FRAMEWORK: ${PAG_BUILD_FRAMEWORK}") @@ -396,7 +400,8 @@ elseif (OHOS) endif () endif () -if (MACOS OR IOS) +if (PAG_USE_SYSTEM_LZ4) + add_definitions(-DPAG_USE_SYSTEM_LZ4) find_library(COMPRESSION_LIBRARIES NAMES compression) list(APPEND PAG_SHARED_LIBS ${COMPRESSION_LIBRARIES}) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/ios/libpag.lds") diff --git a/resources/disk/libpag/files/2.bin b/resources/disk/libpag/files/2.bin index 2ef5f5f6c6..177356fdc6 100644 --- a/resources/disk/libpag/files/2.bin +++ b/resources/disk/libpag/files/2.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:128fbe19ed534e11de84d7a502ea4b30aecc583f56a21f288b47932ab02480ce -size 308925 +oid sha256:31b047ddff90c8473c0df535d7f8cb118001d7b98f7e1a1912f442b3f36d487c +size 254984 diff --git a/resources/disk/libpag/files/3.bin b/resources/disk/libpag/files/3.bin index a381e6db97..604ff2b1fe 100644 --- a/resources/disk/libpag/files/3.bin +++ b/resources/disk/libpag/files/3.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4c040affff0b072c9a86e674dae60d42c245a9277c40e4bcfbcebde7ce260a71 -size 338703 +oid sha256:a42f3c72d912bd499e27296c37cc9a0017863a7d2823c07ef1f3152cd7583334 +size 313931 diff --git a/resources/disk/libpag/files/4.bin b/resources/disk/libpag/files/4.bin index a381e6db97..604ff2b1fe 100644 --- a/resources/disk/libpag/files/4.bin +++ b/resources/disk/libpag/files/4.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4c040affff0b072c9a86e674dae60d42c245a9277c40e4bcfbcebde7ce260a71 -size 338703 +oid sha256:a42f3c72d912bd499e27296c37cc9a0017863a7d2823c07ef1f3152cd7583334 +size 313931 diff --git a/src/rendering/utils/LZ4Decoder.cpp b/src/rendering/utils/LZ4Decoder.cpp index d6da86c083..1fee10b15a 100644 --- a/src/rendering/utils/LZ4Decoder.cpp +++ b/src/rendering/utils/LZ4Decoder.cpp @@ -18,14 +18,14 @@ #include "LZ4Decoder.h" -#ifdef __APPLE__ +#ifdef PAG_USE_SYSTEM_LZ4 #include #else #include "lz4.h" #endif namespace pag { -#ifdef __APPLE__ +#ifdef PAG_USE_SYSTEM_LZ4 class AppleLZ4Decoder : public LZ4Decoder { public: AppleLZ4Decoder() { diff --git a/src/rendering/utils/LZ4Encoder.cpp b/src/rendering/utils/LZ4Encoder.cpp index 2a21c0b840..c9bfd5f1c6 100644 --- a/src/rendering/utils/LZ4Encoder.cpp +++ b/src/rendering/utils/LZ4Encoder.cpp @@ -17,14 +17,14 @@ ///////////////////////////////////////////////////////////////////////////////////////////////// #include "LZ4Encoder.h" -#ifdef __APPLE__ +#ifdef PAG_USE_SYSTEM_LZ4 #include #else #include "lz4.h" #endif namespace pag { -#ifdef __APPLE__ +#ifdef PAG_USE_SYSTEM_LZ4 class AppleLZ4Encoder : public LZ4Encoder { public: AppleLZ4Encoder() { diff --git a/test/baseline/version.json b/test/baseline/version.json index 3724b31d30..e9dfc0a6b8 100644 --- a/test/baseline/version.json +++ b/test/baseline/version.json @@ -8281,9 +8281,9 @@ "composition_swapLayerAt": "6a420423" }, "PAGDiskCacheTest": { - "SequenceFile_10": "0e678d2f", + "SequenceFile_10": "30b3b683", "SequenceFile_15": "088c7e93", - "SequenceFile_20": "0e678d2f", + "SequenceFile_20": "30b3b683", "SequenceFile_22": "088c7e93", "decoder_Image_0": "0e678d2f", "decoder_Image_11": "0e678d2f", diff --git a/test/src/PAGDiskCacheTest.cpp b/test/src/PAGDiskCacheTest.cpp index a65af5ac66..0d9489cc1b 100644 --- a/test/src/PAGDiskCacheTest.cpp +++ b/test/src/PAGDiskCacheTest.cpp @@ -30,7 +30,7 @@ namespace pag { // auto cacheDir = Platform::Current()->getCacheDir(); // std::filesystem::remove_all(cacheDir); // auto pagFile = LoadPAGFile("resources/apitest/ZC2.pag"); -// tgfx::Bitmap bitmap(pagFile->width(), pagFile->height()); +// tgfx::Bitmap bitmap.allocPixels(info.width(), info.height(), false, false); // tgfx::Pixmap pixmap(bitmap); // auto pagPlayer = std::make_shared(); // pagPlayer->setComposition(pagFile); @@ -46,13 +46,13 @@ namespace pag { // pagPlayer->flush(); // pagSurface->readPixels(ColorType::RGBA_8888, AlphaType::Premultiplied, pixmap.writablePixels(), // pixmap.rowBytes()); -// sequenceFile->writeFrame(i, pixmap.pixels()); +// sequenceFile->writeFrame(i, BitmapBuffer::Wrap(pixmap.info(), pixmap.writablePixels())); // pagPlayer->nextFrame(); // } // // info = tgfx::ImageInfo::Make(360, 640, tgfx::ColorType::RGBA_8888); // pixmap.reset(); -// bitmap.allocPixels(info.width(), info.height()); +// bitmap.allocPixels(info.width(), info.height(), false, false); // pixmap.reset(bitmap); // pagSurface = OffscreenSurface::Make(info.width(), info.height()); // pagPlayer->setSurface(pagSurface); @@ -63,12 +63,12 @@ namespace pag { // pagPlayer->flush(); // pagSurface->readPixels(ColorType::RGBA_8888, AlphaType::Premultiplied, pixmap.writablePixels(), // pixmap.rowBytes()); -// sequenceFile->writeFrame(i, pixmap.pixels()); +// sequenceFile->writeFrame(i, BitmapBuffer::Wrap(pixmap.info(), pixmap.writablePixels())); // pagPlayer->nextFrame(); // } // sequenceFile = nullptr; // -// auto diskDir = TestConstants::PAG_ROOT + "resources/disk/libpag"; +// auto diskDir = ProjectPath::Absolute("resources/disk/libpag"); // std::filesystem::remove_all(diskDir); // std::filesystem::create_directories(diskDir); // std::filesystem::copy(cacheDir, diskDir, std::filesystem::copy_options::recursive); @@ -105,7 +105,7 @@ PAG_TEST(PAGDiskCacheTest, SequenceFile) { EXPECT_TRUE(diskCache->cachedFileInfos.size() == 2); EXPECT_EQ(diskCache->cachedFiles.size(), 2u); EXPECT_EQ(diskCache->fileIDCount, 4u); - const auto InitialDiskSize = 647628u; + const auto InitialDiskSize = 568915u; EXPECT_EQ(diskCache->totalDiskSize, InitialDiskSize); tgfx::Bitmap bitmap(pagFile->width(), pagFile->height(), false, false); @@ -174,8 +174,8 @@ PAG_TEST(PAGDiskCacheTest, SequenceFile) { const auto lastTotalDiskSize = diskCache->totalDiskSize; - PAGDiskCache::SetMaxDiskSize(1800000u); - EXPECT_EQ(PAGDiskCache::MaxDiskSize(), 1800000u); + PAGDiskCache::SetMaxDiskSize(1500000u); + EXPECT_EQ(PAGDiskCache::MaxDiskSize(), 1500000u); sequenceFile = DiskCache::OpenSequence("resources/apitest/ZC2.pag.540x960", info, 30, pagFile->frameRate()); pagPlayer->setProgress(0);