未验证 提交 aaf98fbf 编写于 作者: G Gary Qian 提交者: GitHub

Use double multiplication by a scale instead of 3 divides for speed. (#6154)

上级 593ed591
......@@ -28,12 +28,13 @@ static inline SkVector3 SkVector3Cross(const SkVector3& a, const SkVector3& b) {
MatrixDecomposition::MatrixDecomposition(const SkMatrix& matrix)
: MatrixDecomposition(SkMatrix44{matrix}) {}
// TODO(garyq): use skia row[x].normalize() when skia fixes it
// Use custom normalize to avoid skia precision loss/normalize() privatization.
static inline void SkVector3Normalize(SkVector3& v) {
float mag = sqrt(v.fX * v.fX + v.fY * v.fY + v.fZ * v.fZ);
v.fX /= mag;
v.fY /= mag;
v.fZ /= mag;
double mag = sqrt(v.fX * v.fX + v.fY * v.fY + v.fZ * v.fZ);
double scale = 1.0 / mag;
v.fX *= scale;
v.fY *= scale;
v.fZ *= scale;
}
MatrixDecomposition::MatrixDecomposition(SkMatrix44 matrix) : valid_(false) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册