Skip to content

Commit 7e2564a

Browse files
committed
add layer c++ interface setAlpha to ios and android
1 parent 6c308db commit 7e2564a

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

android/libpag/src/main/java/org/libpag/PAGLayer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ public Matrix getTotalMatrix() {
172172
*/
173173
public native void setExcludedFromTimeline(boolean value);
174174

175+
/**
176+
* Set the alpha of the layer, which will be concatenated to the current animation opacity for
177+
* displaying.
178+
*/
179+
public native void setAlpha(float value);
180+
175181
private native void nativeRelease();
176182

177183
protected long nativeContext;

src/platform/android/JPAGLayer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,14 @@ PAG_API void Java_org_libpag_PAGLayer_setExcludedFromTimeline(JNIEnv* env, jobje
297297

298298
pagLayer->setExcludedFromTimeline(value);
299299
}
300+
301+
PAG_API void Java_org_libpag_PAGLayer_setAlpha(JNIEnv* env, jobject thiz,
302+
jfloat value){
303+
auto pagLayer = GetPAGLayer(env, thiz);
304+
if(pagLayer == nullptr){
305+
return;
306+
}
307+
308+
pagLayer->setAlpha(value);
309+
}
300310
}

src/platform/cocoa/PAGLayer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,10 @@ PAG_API @interface PAGLayer : NSObject
165165
*/
166166
- (void)setExcludedFromTimeline:(BOOL)value;
167167

168+
/**
169+
* Set the alpha of the layer, which will be concatenated to the current animation opacity for
170+
* displaying.
171+
*/
172+
- (void)setAlpha:(float)value;
173+
168174
@end

src/platform/cocoa/PAGLayer.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ - (void)setExcludedFromTimeline:(BOOL)value {
133133
[(PAGLayerImpl*)_impl setExcludedFromTimeline:value];
134134
}
135135

136+
- (void)setAlpha:(float)value{
137+
[(PAGLayerImpl*)_impl setAlpha:value];
138+
}
139+
136140
- (void)dealloc {
137141
[_impl release];
138142
[super dealloc];

src/platform/cocoa/private/PAGLayerImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,6 @@
7272

7373
- (void)setExcludedFromTimeline:(BOOL)value;
7474

75+
- (void)setAlpha:(float)value;
76+
7577
@end

src/platform/cocoa/private/PAGLayerImpl.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,8 @@ - (void)setExcludedFromTimeline:(BOOL)value {
254254
_pagLayer->setExcludedFromTimeline(value);
255255
}
256256

257+
- (void)setAlpha:(float)value {
258+
_pagLayer->setAlpha(value);
259+
}
260+
257261
@end

0 commit comments

Comments
 (0)