Bug 1193062 - Fix UntransformVector w coordinate checks. r=kip

It shouldn't be checking the w coordinate of the difference of two Point4Ds. The 4D difference isn't really meaningful. Instead, it should be checking each point's w coordinate individually.
This commit is contained in:
Markus Stange 2015-08-07 14:36:04 -04:00
parent ee7c0dada9
commit eaad5c9458

View File

@ -184,12 +184,12 @@ template <typename TargetUnits, typename SourceUnits>
static Maybe<gfx::PointTyped<TargetUnits>> UntransformVector(const gfx::Matrix4x4& aTransform,
const gfx::PointTyped<SourceUnits>& aVector,
const gfx::PointTyped<SourceUnits>& aAnchor) {
gfx::Point4D point = aTransform.ProjectPoint(aAnchor.ToUnknownPoint() + aVector.ToUnknownPoint())
- aTransform.ProjectPoint(aAnchor.ToUnknownPoint());
if (!point.HasPositiveWCoord()){
gfx::Point4D projectedAnchor = aTransform.ProjectPoint(aAnchor.ToUnknownPoint());
gfx::Point4D projectedTarget = aTransform.ProjectPoint(aAnchor.ToUnknownPoint() + aVector.ToUnknownPoint());
if (!projectedAnchor.HasPositiveWCoord() || !projectedTarget.HasPositiveWCoord()){
return Nothing();
}
return Some(ViewAs<TargetUnits>(point.As2DPoint()));
return Some(ViewAs<TargetUnits>(projectedAnchor.As2DPoint() - projectedTarget.As2DPoint()));
}
} // namespace mozilla