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

Side by Side Diff: Source/core/dom/DOMMatrix.cpp

Issue 446803002: Implement translate() and translateSelf() in DOMMatrix. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 months 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 "config.h" 5 #include "config.h"
6 #include "core/dom/DOMMatrix.h" 6 #include "core/dom/DOMMatrix.h"
7 7
8 namespace blink { 8 namespace blink {
9 9
10 DOMMatrix* DOMMatrix::create() 10 DOMMatrix* DOMMatrix::create()
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 m_matrix[3][3] = m44; 45 m_matrix[3][3] = m44;
46 m_is2D = is2D; 46 m_is2D = is2D;
47 } 47 }
48 48
49 void DOMMatrix::setIs2D(bool value) 49 void DOMMatrix::setIs2D(bool value)
50 { 50 {
51 if (m_is2D) 51 if (m_is2D)
52 m_is2D = value; 52 m_is2D = value;
53 } 53 }
54 54
55 DOMMatrix* DOMMatrix::translateSelf(double tx, double ty, double tz)
56 {
57 if (!tx && !ty && !tz)
58 return this;
59
60 if (tz)
61 m_is2D = false;
62
63 if (isIdentity()) {
krit 2014/08/08 06:24:15 Why don't you use TransformationMatrix here?
zino 2014/08/16 03:23:32 Done.
64 m_matrix[3][0] = tx;
65 m_matrix[3][1] = ty;
66 m_matrix[3][2] = tz;
67 } else {
68 m_matrix[3][0] += tx * m11() + ty * m21();
69 m_matrix[3][1] += tx * m12() + ty * m22();
70
71 if (!m_is2D) {
72 m_matrix[3][0] += tz * m31();
73 m_matrix[3][1] += tz * m32();
74 m_matrix[3][2] += tx * m13() + ty * m23() + tz * m33();
75 m_matrix[3][3] += tx * m14() + ty * m24() + tz * m34();
76 }
77 }
78
79 return this;
80 }
81
55 } // namespace blink 82 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698