mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Implement an FFI and matrix conversions for matrix decomposition/interpolation/recomposition.
We use Servo backend to decompose/interpolate/recompose matrices on both main thread and compositor thread.
This commit is contained in:
parent
1a3845b719
commit
1d44c273d3
5 changed files with 4392 additions and 4010 deletions
|
@ -1,6 +1,7 @@
|
|||
/* automatically generated by rust-bindgen */
|
||||
|
||||
pub use nsstring::{nsACString, nsAString, nsString, nsStringRepr};
|
||||
use gecko_bindings::structs::nsStyleTransformMatrix;
|
||||
use gecko_bindings::structs::nsTArray;
|
||||
type nsACString_internal = nsACString;
|
||||
type nsAString_internal = nsAString;
|
||||
|
@ -209,6 +210,10 @@ use gecko_bindings::structs::ParsingMode;
|
|||
use gecko_bindings::structs::InheritTarget;
|
||||
use gecko_bindings::structs::URLMatchingFunction;
|
||||
use gecko_bindings::structs::StyleRuleInclusion;
|
||||
use gecko_bindings::structs::nsStyleTransformMatrix::MatrixTransformOperator;
|
||||
unsafe impl Send for nsStyleTransformMatrix::MatrixTransformOperator {}
|
||||
unsafe impl Sync for nsStyleTransformMatrix::MatrixTransformOperator {}
|
||||
use gecko_bindings::structs::RawGeckoGfxMatrix4x4;
|
||||
pub type nsTArrayBorrowed_uintptr_t<'a> = &'a mut ::gecko_bindings::structs::nsTArray<usize>;
|
||||
pub type RawServoStyleSetOwned = ::gecko_bindings::sugar::ownership::Owned<RawServoStyleSet>;
|
||||
pub type RawServoStyleSetOwnedOrNull = ::gecko_bindings::sugar::ownership::OwnedOrNull<RawServoStyleSet>;
|
||||
|
@ -2183,6 +2188,15 @@ extern "C" {
|
|||
arg3:
|
||||
nsCSSPropertyIDSetBorrowedMut);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_MatrixTransform_Operate(matrix_operator:
|
||||
MatrixTransformOperator,
|
||||
from: *const RawGeckoGfxMatrix4x4,
|
||||
to: *const RawGeckoGfxMatrix4x4,
|
||||
progress: f64,
|
||||
result:
|
||||
*mut RawGeckoGfxMatrix4x4);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_AnimationValues_Interpolate(from:
|
||||
RawServoAnimationValueBorrowed,
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -10,6 +10,7 @@ use app_units::Au;
|
|||
use cssparser::{Color as CSSParserColor, Parser, RGBA, serialize_identifier};
|
||||
use euclid::{Point2D, Size2D};
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::bindings::RawServoAnimationValueMap;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::RawGeckoGfxMatrix4x4;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::sugar::ownership::{HasFFI, HasSimpleFFI};
|
||||
#[cfg(feature = "gecko")] use gecko_string_cache::Atom;
|
||||
|
@ -2056,6 +2057,28 @@ impl From<MatrixDecomposed2D> for ComputedMatrix {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl<'a> From< &'a RawGeckoGfxMatrix4x4> for ComputedMatrix {
|
||||
fn from(m: &'a RawGeckoGfxMatrix4x4) -> ComputedMatrix {
|
||||
ComputedMatrix {
|
||||
m11: m[0], m12: m[1], m13: m[2], m14: m[3],
|
||||
m21: m[4], m22: m[5], m23: m[6], m24: m[7],
|
||||
m31: m[8], m32: m[9], m33: m[10], m34: m[11],
|
||||
m41: m[12], m42: m[13], m43: m[14], m44: m[15],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl From<ComputedMatrix> for RawGeckoGfxMatrix4x4 {
|
||||
fn from(matrix: ComputedMatrix) -> RawGeckoGfxMatrix4x4 {
|
||||
[ matrix.m11, matrix.m12, matrix.m13, matrix.m14,
|
||||
matrix.m21, matrix.m22, matrix.m23, matrix.m24,
|
||||
matrix.m31, matrix.m32, matrix.m33, matrix.m34,
|
||||
matrix.m41, matrix.m42, matrix.m43, matrix.m44 ]
|
||||
}
|
||||
}
|
||||
|
||||
/// A 3d translation.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -2640,11 +2663,7 @@ impl Animatable for TransformList {
|
|||
let result = vec![TransformOperation::AccumulateMatrix {
|
||||
from_list: self.clone(),
|
||||
to_list: other.clone(),
|
||||
// For accumulation, we need to increase accumulation count for |other| if
|
||||
// we do matrix decomposition/interpolation/recomposition on Gecko. After
|
||||
// changing to Servo matrix decomposition/interpolation/recomposition, we
|
||||
// don't need to increase one. I will remove this in the patch series.
|
||||
count: cmp::min(count + 1, i32::MAX as u64) as i32
|
||||
count: cmp::min(count, i32::MAX as u64) as i32
|
||||
}];
|
||||
Ok(TransformList(Some(result)))
|
||||
}
|
||||
|
|
|
@ -72,12 +72,14 @@ use style::gecko_bindings::structs::{nsCSSFontFaceRule, nsCSSCounterStyleRule};
|
|||
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair};
|
||||
use style::gecko_bindings::structs::IterationCompositeOperation;
|
||||
use style::gecko_bindings::structs::MallocSizeOf;
|
||||
use style::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
|
||||
use style::gecko_bindings::structs::RawGeckoPresContextOwned;
|
||||
use style::gecko_bindings::structs::ServoElementSnapshotTable;
|
||||
use style::gecko_bindings::structs::StyleRuleInclusion;
|
||||
use style::gecko_bindings::structs::URLExtraData;
|
||||
use style::gecko_bindings::structs::nsCSSValueSharedList;
|
||||
use style::gecko_bindings::structs::nsCompatibility;
|
||||
use style::gecko_bindings::structs::nsStyleTransformMatrix::MatrixTransformOperator;
|
||||
use style::gecko_bindings::structs::nsresult;
|
||||
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasFFI, HasArcFFI, HasBoxFFI};
|
||||
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
|
||||
|
@ -1594,6 +1596,28 @@ pub extern "C" fn Servo_GetProperties_Overriding_Animation(element: RawGeckoElem
|
|||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_MatrixTransform_Operate(matrix_operator: MatrixTransformOperator,
|
||||
from: *const RawGeckoGfxMatrix4x4,
|
||||
to: *const RawGeckoGfxMatrix4x4,
|
||||
progress: f64,
|
||||
output: *mut RawGeckoGfxMatrix4x4) {
|
||||
use self::MatrixTransformOperator::{Accumulate, Interpolate};
|
||||
use style::properties::longhands::transform::computed_value::ComputedMatrix;
|
||||
|
||||
let from = ComputedMatrix::from(unsafe { from.as_ref() }.expect("not a valid 'from' matrix"));
|
||||
let to = ComputedMatrix::from(unsafe { to.as_ref() }.expect("not a valid 'to' matrix"));
|
||||
let result = match matrix_operator {
|
||||
Interpolate => from.interpolate(&to, progress),
|
||||
Accumulate => from.accumulate(&to, progress as u64),
|
||||
};
|
||||
|
||||
let output = unsafe { output.as_mut() }.expect("not a valid 'output' matrix");
|
||||
if let Ok(result) = result {
|
||||
*output = result.into();
|
||||
};
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ParseStyleAttribute(data: *const nsACString,
|
||||
raw_extra_data: *mut URLExtraData,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue