Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/dom/DOMMatrix.h" | 5 #include "core/dom/DOMMatrix.h" |
| 6 #include "core/dom/DOMMatrixInit.h" | 6 #include "core/dom/DOMMatrixInit.h" |
| 7 #include "core/dom/DOMPoint.h" | |
| 8 #include "core/dom/DOMPointInit.h" | |
| 7 | 9 |
| 8 namespace blink { | 10 namespace blink { |
| 9 namespace { | 11 namespace { |
| 10 | 12 |
| 11 void setDictionaryMembers(DOMMatrixInit& other) { | 13 void setDictionaryMembers(DOMMatrixInit& other) { |
| 12 if (!other.hasM11()) | 14 if (!other.hasM11()) |
| 13 other.setM11(other.hasA() ? other.a() : 1); | 15 other.setM11(other.hasA() ? other.a() : 1); |
| 14 | 16 |
| 15 if (!other.hasM12()) | 17 if (!other.hasM12()) |
| 16 other.setM12(other.hasB() ? other.b() : 0); | 18 other.setM12(other.hasB() ? other.b() : 0); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 flipY->setM22(-this->m22()); | 205 flipY->setM22(-this->m22()); |
| 204 flipY->setM23(-this->m23()); | 206 flipY->setM23(-this->m23()); |
| 205 flipY->setM24(-this->m24()); | 207 flipY->setM24(-this->m24()); |
| 206 return flipY; | 208 return flipY; |
| 207 } | 209 } |
| 208 | 210 |
| 209 DOMMatrix* DOMMatrixReadOnly::inverse() { | 211 DOMMatrix* DOMMatrixReadOnly::inverse() { |
| 210 return DOMMatrix::create(this)->invertSelf(); | 212 return DOMMatrix::create(this)->invertSelf(); |
| 211 } | 213 } |
| 212 | 214 |
| 215 DOMPoint* DOMMatrixReadOnly::transformPoint(DOMPointInit& point) { | |
|
zino
2016/10/17 15:44:44
The spec says that "Even if is2D of the current ma
Hwanseung Lee
2016/10/17 23:47:30
Done.
| |
| 216 double x = point.x() * m11() + point.y() * m21() + point.z() * m31() + | |
| 217 point.w() * m41(); | |
| 218 double y = point.x() * m12() + point.y() * m22() + point.z() * m32() + | |
| 219 point.w() * m42(); | |
| 220 double z = point.x() * m13() + point.y() * m23() + point.z() * m33() + | |
| 221 point.w() * m43(); | |
| 222 double w = point.x() * m14() + point.y() * m24() + point.z() * m34() + | |
| 223 point.w() * m44(); | |
| 224 return DOMPoint::create(x, y, z, w); | |
| 225 } | |
| 226 | |
| 213 DOMFloat32Array* DOMMatrixReadOnly::toFloat32Array() const { | 227 DOMFloat32Array* DOMMatrixReadOnly::toFloat32Array() const { |
| 214 float array[] = { | 228 float array[] = { |
| 215 static_cast<float>(m_matrix->m11()), static_cast<float>(m_matrix->m12()), | 229 static_cast<float>(m_matrix->m11()), static_cast<float>(m_matrix->m12()), |
| 216 static_cast<float>(m_matrix->m13()), static_cast<float>(m_matrix->m14()), | 230 static_cast<float>(m_matrix->m13()), static_cast<float>(m_matrix->m14()), |
| 217 static_cast<float>(m_matrix->m21()), static_cast<float>(m_matrix->m22()), | 231 static_cast<float>(m_matrix->m21()), static_cast<float>(m_matrix->m22()), |
| 218 static_cast<float>(m_matrix->m23()), static_cast<float>(m_matrix->m24()), | 232 static_cast<float>(m_matrix->m23()), static_cast<float>(m_matrix->m24()), |
| 219 static_cast<float>(m_matrix->m31()), static_cast<float>(m_matrix->m32()), | 233 static_cast<float>(m_matrix->m31()), static_cast<float>(m_matrix->m32()), |
| 220 static_cast<float>(m_matrix->m33()), static_cast<float>(m_matrix->m34()), | 234 static_cast<float>(m_matrix->m33()), static_cast<float>(m_matrix->m34()), |
| 221 static_cast<float>(m_matrix->m41()), static_cast<float>(m_matrix->m42()), | 235 static_cast<float>(m_matrix->m41()), static_cast<float>(m_matrix->m42()), |
| 222 static_cast<float>(m_matrix->m43()), static_cast<float>(m_matrix->m44())}; | 236 static_cast<float>(m_matrix->m43()), static_cast<float>(m_matrix->m44())}; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 245 << m24() << ", " << m31() << ", " << m32() << ", " << m33() << ", " | 259 << m24() << ", " << m31() << ", " << m32() << ", " << m33() << ", " |
| 246 << m34() << ", " << m41() << ", " << m42() << ", " << m43() << ", " | 260 << m34() << ", " << m41() << ", " << m42() << ", " << m43() << ", " |
| 247 << m44(); | 261 << m44(); |
| 248 } | 262 } |
| 249 stream << ")"; | 263 stream << ")"; |
| 250 | 264 |
| 251 return String(stream.str().c_str()); | 265 return String(stream.str().c_str()); |
| 252 } | 266 } |
| 253 | 267 |
| 254 } // namespace blink | 268 } // namespace blink |
| OLD | NEW |