mirror of
https://github.com/servo/servo.git
synced 2025-10-01 00:59:15 +01:00
Add FFI for calling Servo's add and accumulate methods on animation values
This commit is contained in:
parent
34556f7769
commit
6491509f87
2 changed files with 40 additions and 0 deletions
|
@ -2185,6 +2185,17 @@ extern "C" {
|
||||||
RawServoAnimationValueBorrowed)
|
RawServoAnimationValueBorrowed)
|
||||||
-> bool;
|
-> bool;
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_AnimationValues_Add(a: RawServoAnimationValueBorrowed,
|
||||||
|
b: RawServoAnimationValueBorrowed)
|
||||||
|
-> RawServoAnimationValueStrong;
|
||||||
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_AnimationValues_Accumulate(a: RawServoAnimationValueBorrowed,
|
||||||
|
b: RawServoAnimationValueBorrowed,
|
||||||
|
count: u64)
|
||||||
|
-> RawServoAnimationValueStrong;
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_AnimationValues_GetZeroValue(value_to_match:
|
pub fn Servo_AnimationValues_GetZeroValue(value_to_match:
|
||||||
RawServoAnimationValueBorrowed)
|
RawServoAnimationValueBorrowed)
|
||||||
|
|
|
@ -313,6 +313,35 @@ pub extern "C" fn Servo_AnimationValues_IsInterpolable(from: RawServoAnimationVa
|
||||||
from_value.interpolate(to_value, 0.5).is_ok()
|
from_value.interpolate(to_value, 0.5).is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_AnimationValues_Add(a: RawServoAnimationValueBorrowed,
|
||||||
|
b: RawServoAnimationValueBorrowed)
|
||||||
|
-> RawServoAnimationValueStrong
|
||||||
|
{
|
||||||
|
let a_value = AnimationValue::as_arc(&a);
|
||||||
|
let b_value = AnimationValue::as_arc(&b);
|
||||||
|
if let Ok(value) = a_value.add(b_value) {
|
||||||
|
Arc::new(value).into_strong()
|
||||||
|
} else {
|
||||||
|
RawServoAnimationValueStrong::null()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_AnimationValues_Accumulate(a: RawServoAnimationValueBorrowed,
|
||||||
|
b: RawServoAnimationValueBorrowed,
|
||||||
|
count: u64)
|
||||||
|
-> RawServoAnimationValueStrong
|
||||||
|
{
|
||||||
|
let a_value = AnimationValue::as_arc(&a);
|
||||||
|
let b_value = AnimationValue::as_arc(&b);
|
||||||
|
if let Ok(value) = a_value.accumulate(b_value, count) {
|
||||||
|
Arc::new(value).into_strong()
|
||||||
|
} else {
|
||||||
|
RawServoAnimationValueStrong::null()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValues_GetZeroValue(
|
pub extern "C" fn Servo_AnimationValues_GetZeroValue(
|
||||||
value_to_match: RawServoAnimationValueBorrowed)
|
value_to_match: RawServoAnimationValueBorrowed)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue