Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1015)

Side by Side Diff: third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp

Issue 2423753002: [GeometryInterface] add transformPoint(point) function. (Closed)
Patch Set: update test msg. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/DOMMatrixReadOnly.h" 5 #include "core/dom/DOMMatrixReadOnly.h"
6 6
7 #include "bindings/core/v8/V8ObjectBuilder.h" 7 #include "bindings/core/v8/V8ObjectBuilder.h"
8 #include "core/dom/DOMMatrix.h" 8 #include "core/dom/DOMMatrix.h"
9 #include "core/dom/DOMMatrixInit.h" 9 #include "core/dom/DOMMatrixInit.h"
10 #include "core/dom/DOMPoint.h"
11 #include "core/dom/DOMPointInit.h"
10 12
11 namespace blink { 13 namespace blink {
12 namespace { 14 namespace {
13 15
14 void setDictionaryMembers(DOMMatrixInit& other) { 16 void setDictionaryMembers(DOMMatrixInit& other) {
15 if (!other.hasM11()) 17 if (!other.hasM11())
16 other.setM11(other.hasA() ? other.a() : 1); 18 other.setM11(other.hasA() ? other.a() : 1);
17 19
18 if (!other.hasM12()) 20 if (!other.hasM12())
19 other.setM12(other.hasB() ? other.b() : 0); 21 other.setM12(other.hasB() ? other.b() : 0);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 flipY->setM22(-this->m22()); 224 flipY->setM22(-this->m22());
223 flipY->setM23(-this->m23()); 225 flipY->setM23(-this->m23());
224 flipY->setM24(-this->m24()); 226 flipY->setM24(-this->m24());
225 return flipY; 227 return flipY;
226 } 228 }
227 229
228 DOMMatrix* DOMMatrixReadOnly::inverse() { 230 DOMMatrix* DOMMatrixReadOnly::inverse() {
229 return DOMMatrix::create(this)->invertSelf(); 231 return DOMMatrix::create(this)->invertSelf();
230 } 232 }
231 233
234 DOMPoint* DOMMatrixReadOnly::transformPoint(const DOMPointInit& point) {
235 if (is2D() && point.z() == 0 && point.w() == 1) {
236 double x = point.x() * m11() + point.y() * m12() + m41();
237 double y = point.x() * m12() + point.y() * m22() + m42();
238 return DOMPoint::create(x, y, 0, 1);
239 }
240
241 double x = point.x() * m11() + point.y() * m21() + point.z() * m31() +
242 point.w() * m41();
243 double y = point.x() * m12() + point.y() * m22() + point.z() * m32() +
244 point.w() * m42();
245 double z = point.x() * m13() + point.y() * m23() + point.z() * m33() +
246 point.w() * m43();
247 double w = point.x() * m14() + point.y() * m24() + point.z() * m34() +
248 point.w() * m44();
249 return DOMPoint::create(x, y, z, w);
250 }
251
232 DOMFloat32Array* DOMMatrixReadOnly::toFloat32Array() const { 252 DOMFloat32Array* DOMMatrixReadOnly::toFloat32Array() const {
233 float array[] = { 253 float array[] = {
234 static_cast<float>(m_matrix->m11()), static_cast<float>(m_matrix->m12()), 254 static_cast<float>(m_matrix->m11()), static_cast<float>(m_matrix->m12()),
235 static_cast<float>(m_matrix->m13()), static_cast<float>(m_matrix->m14()), 255 static_cast<float>(m_matrix->m13()), static_cast<float>(m_matrix->m14()),
236 static_cast<float>(m_matrix->m21()), static_cast<float>(m_matrix->m22()), 256 static_cast<float>(m_matrix->m21()), static_cast<float>(m_matrix->m22()),
237 static_cast<float>(m_matrix->m23()), static_cast<float>(m_matrix->m24()), 257 static_cast<float>(m_matrix->m23()), static_cast<float>(m_matrix->m24()),
238 static_cast<float>(m_matrix->m31()), static_cast<float>(m_matrix->m32()), 258 static_cast<float>(m_matrix->m31()), static_cast<float>(m_matrix->m32()),
239 static_cast<float>(m_matrix->m33()), static_cast<float>(m_matrix->m34()), 259 static_cast<float>(m_matrix->m33()), static_cast<float>(m_matrix->m34()),
240 static_cast<float>(m_matrix->m41()), static_cast<float>(m_matrix->m42()), 260 static_cast<float>(m_matrix->m41()), static_cast<float>(m_matrix->m42()),
241 static_cast<float>(m_matrix->m43()), static_cast<float>(m_matrix->m44())}; 261 static_cast<float>(m_matrix->m43()), static_cast<float>(m_matrix->m44())};
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 result.addNumber("m41", m41()); 314 result.addNumber("m41", m41());
295 result.addNumber("m42", m42()); 315 result.addNumber("m42", m42());
296 result.addNumber("m43", m43()); 316 result.addNumber("m43", m43());
297 result.addNumber("m44", m44()); 317 result.addNumber("m44", m44());
298 result.addBoolean("is2D", is2D()); 318 result.addBoolean("is2D", is2D());
299 result.addBoolean("isIdentity", isIdentity()); 319 result.addBoolean("isIdentity", isIdentity());
300 return result.scriptValue(); 320 return result.scriptValue();
301 } 321 }
302 322
303 } // namespace blink 323 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.h ('k') | third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698