mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +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)))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue