Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upstylo: Bug 1362896 - Implement ComputeSquaredDistance for TransformList #18086
Conversation
highfive
commented
Aug 15, 2017
|
Heads up! This PR modifies the following files:
|
highfive
commented
Aug 15, 2017
|
r?@nox |
|
Most parts are also reviewed by @birtles. |
|
@bors-servo try |
stylo: Bug 1362896 - Implement ComputeSquaredDistance for TransformList We implement ComputeSquaredDistance for TransformList. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix [Bug 1362896](https://bugzilla.mozilla.org/show_bug.cgi?id=1362896). - [X] These changes do not require tests because Gecko has related tests. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18086) <!-- Reviewable:end -->
|
|
|
Hi @emilio, it seems nox is on PTO in these days? Could you please take a look at these patches? Thanks. |
|
@nox should be back, yesterday was holiday in France. I can take a look if he can't, though. |
| fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> { | ||
| // If possible, we should convert the InnerMatrix2D into types with physical meaning. | ||
| // Therefore, we compute the squared distance from each matrix item, and this makes the | ||
| // result different from that in Gecko if we have skew/shear factor in the ComputedMatrix. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
BorisChiou
Aug 17, 2017
Author
Contributor
Shear is used in Gecko. I think I should remove this word to avoid confusing people.
| impl ComputeSquaredDistance for InnerMatrix2D { | ||
| #[inline] | ||
| fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> { | ||
| // If possible, we should convert the InnerMatrix2D into types with physical meaning. |
This comment has been minimized.
This comment has been minimized.
nox
Aug 16, 2017
Member
Is that something that should be done? If yes, add "FIXME: " before the comment.
This comment has been minimized.
This comment has been minimized.
| @@ -1563,6 +1563,19 @@ impl Animatable for InnerMatrix2D { | |||
| } | |||
| } | |||
|
|
|||
| impl ComputeSquaredDistance for InnerMatrix2D { | |||
This comment has been minimized.
This comment has been minimized.
| @@ -1572,6 +1585,14 @@ impl Animatable for Translate2D { | |||
| } | |||
| } | |||
|
|
|||
| impl ComputeSquaredDistance for Translate2D { | |||
This comment has been minimized.
This comment has been minimized.
| @@ -1581,6 +1602,14 @@ impl Animatable for Scale2D { | |||
| } | |||
| } | |||
|
|
|||
| impl ComputeSquaredDistance for Scale2D { | |||
This comment has been minimized.
This comment has been minimized.
| @@ -2104,6 +2271,18 @@ impl Animatable for MatrixDecomposed3D { | |||
| } | |||
| } | |||
|
|
|||
| impl ComputeSquaredDistance for MatrixDecomposed3D { | |||
This comment has been minimized.
This comment has been minimized.
nox
Aug 16, 2017
Member
This implementation can be derived if you implement that trait for Quaternion, which you should instead of having an intrinsic distance method.
This comment has been minimized.
This comment has been minimized.
| // FIXME: This should be implemented. | ||
| Err(()) | ||
| fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> { | ||
| match (&self.0, &other.0) { |
This comment has been minimized.
This comment has been minimized.
| @@ -78,7 +78,8 @@ impl ComputeSquaredDistance for CalcLengthOrPercentage { | |||
| // FIXME(nox): This looks incorrect to me, to add a distance between lengths | |||
| // with a distance between percentages. | |||
| Ok( | |||
| self.unclamped_length().compute_squared_distance(&other.unclamped_length())? + | |||
| self.unclamped_length().to_f64_px().compute_squared_distance( | |||
| &other.unclamped_length().to_f64_px())? + | |||
This comment has been minimized.
This comment has been minimized.
nox
Aug 16, 2017
Member
Why is it correct at all to mix lengths and percentages? Cf. the FIXME I left just above that change.
This comment has been minimized.
This comment has been minimized.
BorisChiou
Aug 17, 2017
Author
Contributor
Actually, this doesn't make any sense. However, while computing the distance or doing interpolation, we only have computed values (i.e. we shouldn't use used values), so this is a temporary? way to define its distance, and the test cases in Gecko use this way to produce the expected values.
We should keep the "FIXME:" because I hope one day we could use a better way to define the distance.
This comment has been minimized.
This comment has been minimized.
| fn add_assign(&mut self, rhs: Self) { | ||
| *self = *self + rhs; | ||
| } | ||
| } |
This comment has been minimized.
This comment has been minimized.
| to_list: &[TransformOperation]) | ||
| -> Result<SquaredDistance, ()> { | ||
| let mut squared_distance = SquaredDistance::Value(0.); | ||
| for (from, to) in from_list.iter().zip(to_list.iter()) { |
This comment has been minimized.
This comment has been minimized.
nox
Aug 16, 2017
Member
You don't need a for loop at all here, just map on the iterator and sum it at the end.
|
"Tweak CalcLengthOrPerecentage to use pixel value." fix that typo. |
7285b51
to
e8fad23
| @@ -2013,6 +2162,15 @@ impl Animatable for Skew { | |||
| } | |||
| } | |||
|
|
|||
| impl ComputeSquaredDistance for Skew { | |||
This comment has been minimized.
This comment has been minimized.
| @@ -78,7 +78,8 @@ impl ComputeSquaredDistance for CalcLengthOrPercentage { | |||
| // FIXME(nox): This looks incorrect to me, to add a distance between lengths | |||
| // with a distance between percentages. | |||
| Ok( | |||
| self.unclamped_length().compute_squared_distance(&other.unclamped_length())? + | |||
| self.unclamped_length().to_f64_px().compute_squared_distance( | |||
| &other.unclamped_length().to_f64_px())? + | |||
This comment has been minimized.
This comment has been minimized.
|
r=me if the geckotry failures are unrelated. |
|
|
|
@bors-servo r=nox,birtles Thanks, nox. Those geckotry failures are intermittents. |
|
|
|
|
|
|
|
|
|
…tles stylo: Bug 1362896 - Implement ComputeSquaredDistance for TransformList We implement ComputeSquaredDistance for TransformList. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix [Bug 1362896](https://bugzilla.mozilla.org/show_bug.cgi?id=1362896). - [X] These changes do not require tests because Gecko has related tests. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18086) <!-- Reviewable:end -->
|
|
BorisChiou commentedAug 15, 2017
•
edited by SimonSapin
We implement ComputeSquaredDistance for TransformList.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is