Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the inconsistency issue of LZ4 performance across different hardware during autotest. #2473

Merged
merged 4 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
set(PAG_USE_SYSTEM_LZ4 ON)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你要加的是Option默认值,不能是Set,否则外部传入的就被你覆盖了。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

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