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

Feature/wechat mini program #90

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
*.dll filter=lfs diff=lfs merge=lfs -text
*.lib filter=lfs diff=lfs merge=lfs -text
*.so filter=lfs diff=lfs merge=lfs -text
*.lzma2 filter=lfs diff=lfs merge=lfs -text
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -441,18 +441,21 @@ if (PAG_BUILD_TESTS)
file(GLOB PAG_TEST_FILES
test/*.*
test/framework/*.*
test/framework/lzma/*.*
test/framework/utils/*.*)

file(GLOB PAG_SMOKE_TEST_FILES
test/PAGSmokeTest.cpp
test/TestUtils.cpp
test/framework/*.cpp
test/framework/lzma/*.*
test/framework/utils/*.cpp)

file(GLOB PAG_PERFORMANCE_TEST_FILES
test/PAGPerformanceTest.cpp
test/TestUtils.cpp
test/framework/*.cpp
test/framework/lzma/*.*
test/framework/utils/*.cpp)

file(GLOB FFAVC_LIB vendor/ffavc/${LIBRARY_ENTRY}/*${CMAKE_SHARED_LIBRARY_SUFFIX})
Expand All @@ -461,8 +464,8 @@ if (PAG_BUILD_TESTS)

add_executable(PAGUnitTest ${Test_VENDOR_TARGET} ${PAG_TEST_FILES})
target_include_directories(PAGUnitTest PUBLIC ${TEST_INCLUDES})
# skip all File MD5 check in PAGUnitTest
target_compile_definitions(PAGUnitTest PUBLIC SKIP_FILE_MD5)
# skip the PAGCompareFrameTest test case in PAGUnitTest
target_compile_definitions(PAGUnitTest PUBLIC SKIP_FRAME_COMPARE)
target_link_libraries(PAGUnitTest ${TEST_PLATFORM_LIBS})
set_target_properties(PAGUnitTest PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -fno-access-control")

Expand All @@ -474,7 +477,7 @@ if (PAG_BUILD_TESTS)
add_executable(PAGSmokeTest ${Test_VENDOR_TARGET} ${PAG_SMOKE_TEST_FILES})
target_include_directories(PAGSmokeTest PUBLIC ${TEST_INCLUDES})
target_link_libraries(PAGSmokeTest ${TEST_PLATFORM_LIBS})
target_compile_definitions(PAGSmokeTest PUBLIC SMOKE_TEST SKIP_FILE_MD5)
target_compile_definitions(PAGSmokeTest PUBLIC SMOKE_TEST SKIP_FRAME_COMPARE)

add_executable(PAGPerformanceTest ${Test_VENDOR_TARGET} ${PAG_PERFORMANCE_TEST_FILES})
target_include_directories(PAGPerformanceTest PUBLIC ${TEST_INCLUDES})
Expand Down
12 changes: 12 additions & 0 deletions ios/PAGViewer/Full/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,21 @@
<view key="view" contentMode="scaleToFill" id="uj1-cN-Dw3">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<slider opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="90I-D8-65R">
<rect key="frame" x="18" y="790" width="378" height="30"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<connections>
<action selector="sliderValueChanged:" destination="8H2-fb-z0E" eventType="valueChanged" id="6IN-My-6Ls"/>
</connections>
</slider>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<navigationItem key="navigationItem" id="41h-G7-5WM"/>
<connections>
<outlet property="progressSlider" destination="90I-D8-65R" id="uGK-Ju-fah"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="HWY-gf-anI" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
Expand Down
28 changes: 21 additions & 7 deletions ios/PAGViewer/Full/ViewController/PixelBufferDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ @interface PixelBufferDemoViewController ()

@property (nonatomic, strong) PAGPlayer* player;

@property (nonatomic, strong) UIImageView* imageView;

@property (weak, nonatomic) IBOutlet UISlider *progressSlider;

@end


Expand All @@ -38,17 +42,27 @@ - (void)viewDidLoad {
//初始化PAG组件
[self initPAG];
//替换数据demo方法
[self replaceImageAndText];
// [self replaceImageAndText];
//进度控制和渲染,result为渲染结果
CVPixelBufferRef result = [self presentOnce];
CVPixelBufferRef result = [self presentOnceWithProgress:0.5f];
UIImage* image = [self.class imageFromCVPixelBufferRef:result];
UIImageView* imageView = [[UIImageView alloc] initWithImage:image];
[self.view addSubview:imageView];
self.imageView = [[UIImageView alloc] initWithImage:image];
[self.view addSubview:self.imageView];
[self.view bringSubviewToFront:self.progressSlider];
}

- (IBAction)sliderValueChanged:(id)sender {
float value = ((UISlider *)sender).value;
__weak typeof(self) weakself = self;
dispatch_async(dispatch_get_main_queue(), ^{
CVPixelBufferRef result = [weakself presentOnceWithProgress:value];
weakself.imageView.image = [weakself.class imageFromCVPixelBufferRef:result];
});
}

- (void)initPAG {
//文件加载
NSString* path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pag"];
NSString* path = [[NSBundle mainBundle] pathForResource:@"replacement" ofType:@"pag"];
self.file = [PAGFile Load:path];
//player是libpag3.0中的控制器,用于播放进度控制,与surface为一一对应的关系。
//render之中的功能转移到了PAGPlayer和PAGFile中。如果需要绘制多个File的内容,可以使用PAGComposition组装PAGFile。具体请看{@link CombinePAGViewController}
Expand All @@ -60,8 +74,8 @@ - (void)initPAG {
[self.player setComposition:self.file];
}

- (CVPixelBufferRef)presentOnce {
[self.player setProgress:0.5];
- (CVPixelBufferRef)presentOnceWithProgress:(float)value {
[self.player setProgress:value];
[self.player flush];
return [self.surface getCVPixelBuffer];
}
Expand Down
2 changes: 1 addition & 1 deletion linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (APPLE)
find_library(VIDEOTOOLBOX VideoToolbox)
list(APPEND libs ${VIDEOTOOLBOX})

list(APPEND libs ${CMAKE_CURRENT_SOURCE_DIR}/vendor/pag/mac/x64/libpag.dylib)
list(APPEND libs ${CMAKE_CURRENT_SOURCE_DIR}/vendor/pag/mac/x64/libpag.a)
list(APPEND libs ${CMAKE_CURRENT_SOURCE_DIR}/vendor/swiftshader/mac/x64/libEGL.dylib)
list(APPEND libs ${CMAKE_CURRENT_SOURCE_DIR}/vendor/swiftshader/mac/x64/libGLESv2.dylib)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/base/utils/TimeUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ inline double FrameToProgress(Frame currentFrame, Frame totalFrames) {
if (currentFrame >= totalFrames - 1) {
return 1;
}
return currentFrame * 1.0 / totalFrames;
// todo(partyhuang): figure out which one is best for offsetting, 0.1 or 0.5?
return (currentFrame * 1.0 + 0.1) / totalFrames;
}

inline int64_t ProgressToTime(double progress, int64_t totalTime) {
Expand Down
6 changes: 4 additions & 2 deletions src/rendering/filters/BulgeFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ static const char BULGE_FRAGMENT_SHADER[] = R"(
vec2 point = target - bulgeCenter;

float distance = pow(point.x, 2.0) / pow(uHorizontalRadius, 2.0) + pow(point.y, 2.0) / pow(uVerticalRadius, 2.0);
float isInside = step(1.0, distance);

float len = length(point);
float radius = atan(point.y, point.x);
float weight = (1.0 - distance) * atan(len, sqrt(1.0 - sqrt(len))) / PI;
vec2 newPoint = point - uBulgeHeight * weight * vec2(cos(radius), sin(radius));

target = mix(newPoint + bulgeCenter, vertexColor, isInside);
// TODO: 在swiftshader上,此处使用mix来减少分支语句会引起画面异常,待排查
if (distance <= 1.0) {
target = newPoint + bulgeCenter;
}

if(uPinning) {
target.x = clamp(target.x, edge, 1.0 - edge);
Expand Down
2 changes: 1 addition & 1 deletion test/MultiThreadCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void mockPAGView() {
long time = file->duration() * i / num;
file->setCurrentTime(time);
player->flush();
DumpMD5(surface);
MakeSnapshot(surface);
std::this_thread::sleep_for(std::chrono::milliseconds(20));
}
}
Expand Down
47 changes: 10 additions & 37 deletions test/PAGBlendTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ PAG_TEST_CASE(PAGBlendTest)
/**
* 用例描述: 测试基础混合模式
*/
PAG_TEST_F(PAGBlendTest, Blend_ID83348933) {
PAG_TEST_F(PAGBlendTest, Blend) {
std::vector<std::string> files;
GetAllPAGFiles("../resources/blend", files);
auto pagSurface = PAGSurface::MakeOffscreen(400, 400);
Expand All @@ -42,16 +42,10 @@ PAG_TEST_F(PAGBlendTest, Blend_ID83348933) {
pagPlayer->setMatrix(Matrix::I());
pagPlayer->setProgress(0.5);
pagPlayer->flush();
auto md5 = DumpMD5(pagSurface);
auto found = file.find_last_of("/\\");
auto fileName = file.substr(found + 1);
PAGTestEnvironment::DumpJson["PAGBlendTest"]["base"][fileName] = md5;
#ifdef COMPARE_JSON_PATH
auto compareMD5 = PAGTestEnvironment::CompareJson["PAGBlendTest"]["base"][fileName];
auto path = "../test/out/blend_" + fileName + ".png";
TraceIf(pagSurface, path, compareMD5.get<std::string>() != md5);
EXPECT_EQ(compareMD5.get<std::string>(), md5);
#endif
auto suffixIndex = file.rfind('.');
auto fileName = file.substr(found + 1, suffixIndex - found - 1);
EXPECT_TRUE(Baseline::Compare(pagSurface, "PAGBlendTest/Blend_"+ fileName));
}
}

Expand All @@ -77,7 +71,7 @@ GLTextureInfo GetBottomLeftImage(std::shared_ptr<Device> device, int width, int
/**
* 用例描述: 使用blend时,如果当前的frameBuffer是BottomLeft的,复制逻辑验证
*/
PAG_TEST_F(PAGBlendTest, CopyDstTexture_ID83384135) {
PAG_TEST_F(PAGBlendTest, CopyDstTexture) {
auto width = 400;
auto height = 400;
auto device = NativeGLDevice::Make();
Expand All @@ -96,14 +90,7 @@ PAG_TEST_F(PAGBlendTest, CopyDstTexture_ID83384135) {
pagPlayer->setMatrix(Matrix::I());
pagPlayer->setProgress(0.5);
pagPlayer->flush();
auto md5 = DumpMD5(pagSurface);
PAGTestEnvironment::DumpJson["PAGBlendTest"]["CopyDstTexture_ID83384135"] = md5;
#ifdef COMPARE_JSON_PATH
auto compareMD5 = PAGTestEnvironment::CompareJson["PAGBlendTest"]["CopyDstTexture_ID83384135"];
auto path = "../test/out/blend_Multiply_CopyDstTexture.png";
TraceIf(pagSurface, path, compareMD5.get<std::string>() != md5);
EXPECT_EQ(compareMD5.get<std::string>(), md5);
#endif
EXPECT_TRUE(Baseline::Compare(pagSurface, "PAGBlendTest/CopyDstTexture"));

context = device->lockContext();
gl = GLContext::Unwrap(context);
Expand All @@ -114,7 +101,7 @@ PAG_TEST_F(PAGBlendTest, CopyDstTexture_ID83384135) {
/**
* 用例描述: 替换的texture是BottomLeft,renderTarget是TopLeft
*/
PAG_TEST_F(PAGBlendTest, TextureBottomLeft_ID83721303) {
PAG_TEST_F(PAGBlendTest, TextureBottomLeft) {
auto width = 720;
auto height = 1280;
auto device = NativeGLDevice::Make();
Expand All @@ -138,14 +125,7 @@ PAG_TEST_F(PAGBlendTest, TextureBottomLeft_ID83721303) {
pagPlayer->setMatrix(Matrix::I());
pagPlayer->setProgress(0.34);
pagPlayer->flush();
auto md5 = DumpMD5(pagSurface);
PAGTestEnvironment::DumpJson["PAGBlendTest"]["TextureBottomLeft_ID83721303"] = md5;
#ifdef COMPARE_JSON_PATH
auto compareMD5 = PAGTestEnvironment::CompareJson["PAGBlendTest"]["TextureBottomLeft_ID83721303"];
auto path = "../test/out/TextureBottomLeft_ID83721303.png";
TraceIf(pagSurface, path, compareMD5.get<std::string>() != md5);
EXPECT_EQ(compareMD5.get<std::string>(), md5);
#endif
EXPECT_TRUE(Baseline::Compare(pagSurface, "PAGBlendTest/TextureBottomLeft"));

context = device->lockContext();
gl = GLContext::Unwrap(context);
Expand All @@ -157,7 +137,7 @@ PAG_TEST_F(PAGBlendTest, TextureBottomLeft_ID83721303) {
/**
* 用例描述: 替换的texture和renderTarget都是BottomLeft
*/
PAG_TEST_F(PAGBlendTest, BothBottomLeft_ID83721689) {
PAG_TEST_F(PAGBlendTest, BothBottomLeft) {
auto width = 720;
auto height = 1280;
auto device = NativeGLDevice::Make();
Expand Down Expand Up @@ -186,14 +166,7 @@ PAG_TEST_F(PAGBlendTest, BothBottomLeft_ID83721689) {
pagPlayer->setMatrix(Matrix::I());
pagPlayer->setProgress(0.3);
pagPlayer->flush();
auto md5 = DumpMD5(pagSurface);
PAGTestEnvironment::DumpJson["PAGBlendTest"]["BothBottomLeft_ID83721689"] = md5;
#ifdef COMPARE_JSON_PATH
auto compareMD5 = PAGTestEnvironment::CompareJson["PAGBlendTest"]["BothBottomLeft_ID83721689"];
auto path = "../test/out/BothBottomLeft_ID83721689.png";
TraceIf(pagSurface, path, compareMD5.get<std::string>() != md5);
EXPECT_EQ(compareMD5.get<std::string>(), md5);
#endif
EXPECT_TRUE(Baseline::Compare(pagSurface, "PAGBlendTest/BothBottomLeft"));

context = device->lockContext();
ASSERT_TRUE(context != nullptr);
Expand Down
Loading