OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
7 | 7 |
8 #include "ui/gfx/transform.h" | 8 #include "ui/gfx/transform.h" |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 } | 177 } |
178 | 178 |
179 void Transform::Translate(SkMScalar x, SkMScalar y) { | 179 void Transform::Translate(SkMScalar x, SkMScalar y) { |
180 matrix_.preTranslate(x, y, 0); | 180 matrix_.preTranslate(x, y, 0); |
181 } | 181 } |
182 | 182 |
183 void Transform::Translate3d(SkMScalar x, SkMScalar y, SkMScalar z) { | 183 void Transform::Translate3d(SkMScalar x, SkMScalar y, SkMScalar z) { |
184 matrix_.preTranslate(x, y, z); | 184 matrix_.preTranslate(x, y, z); |
185 } | 185 } |
186 | 186 |
187 void Transform::SkewX(double angle_x) { | 187 void Transform::Skew(double angle_x, double angle_y) { |
188 if (matrix_.isIdentity()) { | 188 if (matrix_.isIdentity()) { |
189 matrix_.set(0, 1, TanDegrees(angle_x)); | 189 matrix_.set(0, 1, TanDegrees(angle_x)); |
| 190 matrix_.set(1, 0, TanDegrees(angle_y)); |
190 } else { | 191 } else { |
191 SkMatrix44 skew(SkMatrix44::kIdentity_Constructor); | 192 SkMatrix44 skew(SkMatrix44::kIdentity_Constructor); |
192 skew.set(0, 1, TanDegrees(angle_x)); | 193 skew.set(0, 1, TanDegrees(angle_x)); |
193 matrix_.preConcat(skew); | |
194 } | |
195 } | |
196 | |
197 void Transform::SkewY(double angle_y) { | |
198 if (matrix_.isIdentity()) { | |
199 matrix_.set(1, 0, TanDegrees(angle_y)); | |
200 } else { | |
201 SkMatrix44 skew(SkMatrix44::kIdentity_Constructor); | |
202 skew.set(1, 0, TanDegrees(angle_y)); | 194 skew.set(1, 0, TanDegrees(angle_y)); |
203 matrix_.preConcat(skew); | 195 matrix_.preConcat(skew); |
204 } | 196 } |
205 } | 197 } |
206 | 198 |
207 void Transform::ApplyPerspectiveDepth(SkMScalar depth) { | 199 void Transform::ApplyPerspectiveDepth(SkMScalar depth) { |
208 if (depth == 0) | 200 if (depth == 0) |
209 return; | 201 return; |
210 if (matrix_.isIdentity()) { | 202 if (matrix_.isIdentity()) { |
211 matrix_.set(3, 2, -SK_MScalar1 / depth); | 203 matrix_.set(3, 2, -SK_MScalar1 / depth); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 matrix_.get(2, 1), | 552 matrix_.get(2, 1), |
561 matrix_.get(2, 2), | 553 matrix_.get(2, 2), |
562 matrix_.get(2, 3), | 554 matrix_.get(2, 3), |
563 matrix_.get(3, 0), | 555 matrix_.get(3, 0), |
564 matrix_.get(3, 1), | 556 matrix_.get(3, 1), |
565 matrix_.get(3, 2), | 557 matrix_.get(3, 2), |
566 matrix_.get(3, 3)); | 558 matrix_.get(3, 3)); |
567 } | 559 } |
568 | 560 |
569 } // namespace gfx | 561 } // namespace gfx |
OLD | NEW |