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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 flipY->setM22(-this->m22()); | 221 flipY->setM22(-this->m22()); |
| 220 flipY->setM23(-this->m23()); | 222 flipY->setM23(-this->m23()); |
| 221 flipY->setM24(-this->m24()); | 223 flipY->setM24(-this->m24()); |
| 222 return flipY; | 224 return flipY; |
| 223 } | 225 } |
| 224 | 226 |
| 225 DOMMatrix* DOMMatrixReadOnly::inverse() { | 227 DOMMatrix* DOMMatrixReadOnly::inverse() { |
| 226 return DOMMatrix::create(this)->invertSelf(); | 228 return DOMMatrix::create(this)->invertSelf(); |
| 227 } | 229 } |
| 228 | 230 |
| 231 DOMPoint* DOMMatrixReadOnly::transformPoint(const DOMPointInit& point) { | |
|
dominicc (has gone to gerrit)
2016/11/08 08:55:34
I'm curious but what's the efficiency in our bindi
Hwanseung Lee
2016/11/13 02:47:10
i think it is almost same.
DOMPointInit have all a
| |
| 232 if (is2D() && point.z() == 0 && point.w() == 1) { | |
| 233 double x = point.x() * m11() + point.y() * m12() + m41(); | |
| 234 double y = point.x() * m12() + point.y() * m22() + m42(); | |
| 235 return DOMPoint::create(x, y, 0, 1); | |
| 236 } | |
| 237 | |
| 238 double x = point.x() * m11() + point.y() * m21() + point.z() * m31() + | |
| 239 point.w() * m41(); | |
| 240 double y = point.x() * m12() + point.y() * m22() + point.z() * m32() + | |
| 241 point.w() * m42(); | |
| 242 double z = point.x() * m13() + point.y() * m23() + point.z() * m33() + | |
| 243 point.w() * m43(); | |
| 244 double w = point.x() * m14() + point.y() * m24() + point.z() * m34() + | |
| 245 point.w() * m44(); | |
| 246 return DOMPoint::create(x, y, z, w); | |
| 247 } | |
| 248 | |
| 229 DOMFloat32Array* DOMMatrixReadOnly::toFloat32Array() const { | 249 DOMFloat32Array* DOMMatrixReadOnly::toFloat32Array() const { |
| 230 float array[] = { | 250 float array[] = { |
| 231 static_cast<float>(m_matrix->m11()), static_cast<float>(m_matrix->m12()), | 251 static_cast<float>(m_matrix->m11()), static_cast<float>(m_matrix->m12()), |
| 232 static_cast<float>(m_matrix->m13()), static_cast<float>(m_matrix->m14()), | 252 static_cast<float>(m_matrix->m13()), static_cast<float>(m_matrix->m14()), |
| 233 static_cast<float>(m_matrix->m21()), static_cast<float>(m_matrix->m22()), | 253 static_cast<float>(m_matrix->m21()), static_cast<float>(m_matrix->m22()), |
| 234 static_cast<float>(m_matrix->m23()), static_cast<float>(m_matrix->m24()), | 254 static_cast<float>(m_matrix->m23()), static_cast<float>(m_matrix->m24()), |
| 235 static_cast<float>(m_matrix->m31()), static_cast<float>(m_matrix->m32()), | 255 static_cast<float>(m_matrix->m31()), static_cast<float>(m_matrix->m32()), |
| 236 static_cast<float>(m_matrix->m33()), static_cast<float>(m_matrix->m34()), | 256 static_cast<float>(m_matrix->m33()), static_cast<float>(m_matrix->m34()), |
| 237 static_cast<float>(m_matrix->m41()), static_cast<float>(m_matrix->m42()), | 257 static_cast<float>(m_matrix->m41()), static_cast<float>(m_matrix->m42()), |
| 238 static_cast<float>(m_matrix->m43()), static_cast<float>(m_matrix->m44())}; | 258 static_cast<float>(m_matrix->m43()), static_cast<float>(m_matrix->m44())}; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 261 << m24() << ", " << m31() << ", " << m32() << ", " << m33() << ", " | 281 << m24() << ", " << m31() << ", " << m32() << ", " << m33() << ", " |
| 262 << m34() << ", " << m41() << ", " << m42() << ", " << m43() << ", " | 282 << m34() << ", " << m41() << ", " << m42() << ", " << m43() << ", " |
| 263 << m44(); | 283 << m44(); |
| 264 } | 284 } |
| 265 stream << ")"; | 285 stream << ")"; |
| 266 | 286 |
| 267 return String(stream.str().c_str()); | 287 return String(stream.str().c_str()); |
| 268 } | 288 } |
| 269 | 289 |
| 270 } // namespace blink | 290 } // namespace blink |
| OLD | NEW |