Skip to content

Commit

Permalink
Fix the autotest failure caused by inconsistent outputs of the system…
Browse files Browse the repository at this point in the history
… LZ4 library. (#2473)
  • Loading branch information
Hparty authored and kevingpqi123 committed Sep 19, 2024
1 parent b026bf7 commit 05e5763
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 21 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions resources/disk/libpag/files/2.bin
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/disk/libpag/files/3.bin
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/disk/libpag/files/4.bin
Git LFS file not shown
4 changes: 2 additions & 2 deletions src/rendering/utils/LZ4Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

#include "LZ4Decoder.h"

#ifdef __APPLE__
#ifdef PAG_USE_SYSTEM_LZ4
#include <compression.h>
#else
#include "lz4.h"
#endif

namespace pag {
#ifdef __APPLE__
#ifdef PAG_USE_SYSTEM_LZ4
class AppleLZ4Decoder : public LZ4Decoder {
public:
AppleLZ4Decoder() {
Expand Down
4 changes: 2 additions & 2 deletions src/rendering/utils/LZ4Encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
/////////////////////////////////////////////////////////////////////////////////////////////////

#include "LZ4Encoder.h"
#ifdef __APPLE__
#ifdef PAG_USE_SYSTEM_LZ4
#include <compression.h>
#else
#include "lz4.h"
#endif

namespace pag {
#ifdef __APPLE__
#ifdef PAG_USE_SYSTEM_LZ4
class AppleLZ4Encoder : public LZ4Encoder {
public:
AppleLZ4Encoder() {
Expand Down
4 changes: 2 additions & 2 deletions test/baseline/version.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions test/src/PAGDiskCacheTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
// pagPlayer->setComposition(pagFile);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 05e5763

Please sign in to comment.