| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/cssom/MatrixTransformComponent.h" | 5 #include "core/css/cssom/MatrixTransformComponent.h" |
| 6 | 6 |
| 7 #include "core/css/CSSPrimitiveValue.h" | 7 #include "core/css/CSSPrimitiveValue.h" |
| 8 #include "core/css/CSSValuePool.h" | 8 #include "core/css/CSSValuePool.h" |
| 9 #include "wtf/MathExtras.h" | 9 #include "wtf/MathExtras.h" |
| 10 #include <cmath> | 10 #include <cmath> |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 RawPtr<CSSFunctionValue> MatrixTransformComponent::toCSSValue() const | 14 CSSFunctionValue* MatrixTransformComponent::toCSSValue() const |
| 15 { | 15 { |
| 16 RawPtr<CSSFunctionValue> result = CSSFunctionValue::create(m_is2D ? CSSValue
Matrix : CSSValueMatrix3d); | 16 CSSFunctionValue* result = CSSFunctionValue::create(m_is2D ? CSSValueMatrix
: CSSValueMatrix3d); |
| 17 | 17 |
| 18 if (m_is2D) { | 18 if (m_is2D) { |
| 19 double values[6] = {a(), b(), c(), d(), e(), f()}; | 19 double values[6] = {a(), b(), c(), d(), e(), f()}; |
| 20 for (double value : values) { | 20 for (double value : values) { |
| 21 result->append(cssValuePool().createValue(value, CSSPrimitiveValue::
UnitType::Number)); | 21 result->append(cssValuePool().createValue(value, CSSPrimitiveValue::
UnitType::Number)); |
| 22 } | 22 } |
| 23 } else { | 23 } else { |
| 24 double values[16] = {m11(), m12(), m13(), m14(), m21(), m22(), m23(), m2
4(), | 24 double values[16] = {m11(), m12(), m13(), m14(), m21(), m22(), m23(), m2
4(), |
| 25 m31(), m32(), m33(), m34(), m41(), m42(), m43(), m44()}; | 25 m31(), m32(), m33(), m34(), m41(), m42(), m43(), m44()}; |
| 26 for (double value : values) { | 26 for (double value : values) { |
| 27 result->append(cssValuePool().createValue(value, CSSPrimitiveValue::
UnitType::Number)); | 27 result->append(cssValuePool().createValue(value, CSSPrimitiveValue::
UnitType::Number)); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 return result.release(); | 31 return result; |
| 32 } | 32 } |
| 33 | 33 |
| 34 MatrixTransformComponent* MatrixTransformComponent::perspective(double length) | 34 MatrixTransformComponent* MatrixTransformComponent::perspective(double length) |
| 35 { | 35 { |
| 36 OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create(); | 36 OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create(); |
| 37 if (length != 0) | 37 if (length != 0) |
| 38 matrix->setM34(-1 / length); | 38 matrix->setM34(-1 / length); |
| 39 return new MatrixTransformComponent(matrix.release(), PerspectiveType); | 39 return new MatrixTransformComponent(matrix.release(), PerspectiveType); |
| 40 } | 40 } |
| 41 | 41 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 MatrixTransformComponent* MatrixTransformComponent::translate3d(double x, double
y, double z) | 92 MatrixTransformComponent* MatrixTransformComponent::translate3d(double x, double
y, double z) |
| 93 { | 93 { |
| 94 OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create(); | 94 OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create(); |
| 95 matrix->setM41(x); | 95 matrix->setM41(x); |
| 96 matrix->setM42(y); | 96 matrix->setM42(y); |
| 97 matrix->setM43(z); | 97 matrix->setM43(z); |
| 98 return new MatrixTransformComponent(matrix.release(), Translation3DType); | 98 return new MatrixTransformComponent(matrix.release(), Translation3DType); |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace blink | 101 } // namespace blink |
| OLD | NEW |