Bug 1236750 - Add a ViewAs() overload for casting (with a justification) one typed matrix to another. r=kats

--HG--
extra : source : 3a05e621ef86bff180ecb76592d24aee5000c1eb
This commit is contained in:
Botond Ballo 2016-01-06 18:55:06 -05:00
Родитель b6ced4a261
Коммит 7715b8dfd0
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -92,6 +92,19 @@ gfx::ScaleFactor<SourceUnits, NewTargetUnits> ViewTargetAs(
PixelCastJustification) {
return gfx::ScaleFactor<SourceUnits, NewTargetUnits>(aScaleFactor.scale);
}
// Unlike the other functions in this category, this function takes the
// target matrix type, rather than its source and target unit types, as
// the explicit template argument, so an example invocation is:
// ViewAs<ScreenToLayerMatrix4x4>(otherTypedMatrix, justification)
// The reason is that if it took the source and target unit types as two
// template arguments, there may be some confusion as to which is the
// source and which is the target.
template <class TargetMatrix, class SourceMatrixSourceUnits, class SourceMatrixTargetUnits>
TargetMatrix ViewAs(
const gfx::Matrix4x4Typed<SourceMatrixSourceUnits, SourceMatrixTargetUnits>& aMatrix,
PixelCastJustification) {
return TargetMatrix::FromUnknownMatrix(aMatrix.ToUnknownMatrix());
}
// Convenience functions for casting untyped entities to typed entities.
// Using these functions does not require a justification, but once we convert