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 "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 Loading... | |
| 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::scaleSelf(double scale, double ox, double oy) | |
| 56 { | |
| 57 return scaleNonUniformSelf(scale, scale, 1, ox, oy); | |
| 58 } | |
| 59 | |
| 60 DOMMatrix* DOMMatrix::scale3dSelf(double scale, double ox, double oy, double oz) | |
| 61 { | |
| 62 return scaleNonUniformSelf(scale, scale, scale, ox, oy, oz); | |
| 63 } | |
| 64 | |
| 65 DOMMatrix* DOMMatrix::scaleNonUniformSelf(double sx, double sy, double sz, | |
| 66 double ox, double oy, double oz) | |
| 67 { | |
| 68 if (sz != 1 || oz) | |
| 69 m_is2D = false; | |
| 70 | |
| 71 if (sx == 1 && sy == 1 && sz == 1) | |
| 72 return this; | |
| 73 | |
| 74 bool hasTranslation = (ox || oy || oz); | |
| 75 | |
| 76 if (hasTranslation) | |
| 77 translateSelf(ox, oy, oz); | |
| 78 | |
| 79 if (isIdentity()) { | |
|
krit
2014/08/08 05:47:34
Why not implement this in TransformationMatrix?
zino
2014/08/17 11:35:25
Done.
| |
| 80 m_matrix[0][0] = sx; | |
| 81 m_matrix[1][1] = sy; | |
| 82 m_matrix[2][2] = sz; | |
| 83 } else { | |
| 84 if (sx != 1) { | |
| 85 m_matrix[0][0] *= sx; | |
| 86 m_matrix[0][1] *= sx; | |
| 87 m_matrix[0][2] *= sx; | |
| 88 m_matrix[0][3] *= sx; | |
| 89 } | |
| 90 if (sy != 1) { | |
| 91 m_matrix[1][0] *= sy; | |
| 92 m_matrix[1][1] *= sy; | |
| 93 m_matrix[1][2] *= sy; | |
| 94 m_matrix[1][3] *= sy; | |
| 95 } | |
| 96 if (sz != 1) { | |
| 97 m_matrix[2][0] *= sz; | |
| 98 m_matrix[2][1] *= sz; | |
| 99 m_matrix[2][2] *= sz; | |
| 100 m_matrix[2][3] *= sz; | |
| 101 } | |
| 102 } | |
| 103 | |
| 104 if (hasTranslation) | |
| 105 translateSelf(-ox, -oy, -oz); | |
| 106 | |
| 107 return this; | |
| 108 } | |
| 109 | |
| 55 } // namespace blink | 110 } // namespace blink |
| OLD | NEW |