The upcoming WebXR API (Bug 1419190) requires intermediate calculations of real-world space coordinates to have more precision with larger ranges. I expect that double precision matrix and quaternions will also be useful in other graphics and layout work.
It would not be ideal to expand the existing classes to always use double precision, as it would incur a significant performance penalty on certain platforms (eg, Arm). The double-precision variants should be used only when required.
The existing gfx::Matrix4x4 and gfx::Quaternion implementation can be extended with templates to generate both single and double precision variants.
Differential Revision: https://phabricator.services.mozilla.com/D22010
--HG--
extra : moz-landing-system : lando
This patch was generated automatically by the "modeline.py" script, available
here: https://github.com/amccreight/moz-source-tools/blob/master/modeline.py
For every file that is modified in this patch, the changes are as follows:
(1) The patch changes the file to use the exact C++ mode lines from the
Mozilla coding style guide, available here:
https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Mode_Line
(2) The patch deletes any blank lines between the mode line & the MPL
boilerplate comment.
(3) If the file previously had the mode lines and MPL boilerplate in a
single contiguous C++ comment, then the patch splits them into
separate C++ comments, to match the boilerplate in the coding style.
MozReview-Commit-ID: 77D61xpSmIl
--HG--
extra : rebase_source : c6162fa3cf539a07177a19838324bf368faa162b
To allow MatrixDouble to be a drop-in replacement for gfxMatrix, it
needs to accept the "double" versions of Point, Rect, and Size. This
patch does that by adding some extra typedefs inside BaseMatrix to
abstract over that.
It also moves some function implementations into the .h file as they
don't need specialization. I left some function implementations in
the Matrix.cpp file:
- Rotation, because it is specialized for Float and Double, since it uses
sinf/cosf vs sin/cos in the two implementations.
- The Matrix4x4 multiplication operator overload, because if I put it
inside the BaseMatrix class declaration Matrix4x4 isn't defined yet
and the compiler doesn't like it.
MozReview-Commit-ID: K56dZjJhXWS
--HG--
extra : rebase_source : d009151942811a725ee6bf854238073e59665d5c
This extracts a BaseMatrix template of which Matrix is now a particular
specialization. The BaseMatrix allows us to reuse the same code for
floats and doubles, much like the other "base" classes (BasePoint,
BaseRect, etc.).
MozReview-Commit-ID: HO7bA83S9E0
--HG--
extra : rebase_source : dcd84d9a978cdea00bb54eb11eefcca9c6635901
Matrix4x4 remains a typedef for Matrix4x4Typed<UnknownUnits, UnknownUnits>.
No client code needed changing, except for forward-declarations of Matrix4x4
as a class (since it's now a typedef).
--HG--
extra : rebase_source : ecd9470b9defcc55cfb9e7dbd26e928a6219c3e5
extra : source : 0fc99b5490830953f37a4d8769e42dad2d10bc6e