Chromium Code Reviews| 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 #include "ui/gfx/transform_util.h" | 5 #include "ui/gfx/transform_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 } // namespace | 275 } // namespace |
| 276 | 276 |
| 277 Transform GetScaleTransform(const Point& anchor, float scale) { | 277 Transform GetScaleTransform(const Point& anchor, float scale) { |
| 278 Transform transform; | 278 Transform transform; |
| 279 transform.Translate(anchor.x() * (1 - scale), | 279 transform.Translate(anchor.x() * (1 - scale), |
| 280 anchor.y() * (1 - scale)); | 280 anchor.y() * (1 - scale)); |
| 281 transform.Scale(scale, scale); | 281 transform.Scale(scale, scale); |
| 282 return transform; | 282 return transform; |
| 283 } | 283 } |
| 284 | 284 |
| 285 Transform GetRectTransform(const gfx::Rect& from, const gfx::Rect& to) { | |
| 286 Transform transform; | |
| 287 transform.Translate(to.x(), to.y()); | |
| 288 transform.Scale(static_cast<double>(to.width()) / from.width(), | |
|
Matt Giuca
2014/11/04 01:05:17
Going to have infinities if from.width() or from.h
calamity
2014/11/04 01:40:29
Done.
| |
| 289 static_cast<double>(to.height()) / from.height()); | |
| 290 transform.Translate(-from.x(), -from.y()); | |
| 291 return transform; | |
| 292 } | |
| 293 | |
| 285 DecomposedTransform::DecomposedTransform() { | 294 DecomposedTransform::DecomposedTransform() { |
| 286 translate[0] = translate[1] = translate[2] = 0.0; | 295 translate[0] = translate[1] = translate[2] = 0.0; |
| 287 scale[0] = scale[1] = scale[2] = 1.0; | 296 scale[0] = scale[1] = scale[2] = 1.0; |
| 288 skew[0] = skew[1] = skew[2] = 0.0; | 297 skew[0] = skew[1] = skew[2] = 0.0; |
| 289 perspective[0] = perspective[1] = perspective[2] = 0.0; | 298 perspective[0] = perspective[1] = perspective[2] = 0.0; |
| 290 quaternion[0] = quaternion[1] = quaternion[2] = 0.0; | 299 quaternion[0] = quaternion[1] = quaternion[2] = 0.0; |
| 291 perspective[3] = quaternion[3] = 1.0; | 300 perspective[3] = quaternion[3] = 1.0; |
| 292 } | 301 } |
| 293 | 302 |
| 294 bool BlendDecomposedTransforms(DecomposedTransform* out, | 303 bool BlendDecomposedTransforms(DecomposedTransform* out, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 perspective[1], | 501 perspective[1], |
| 493 perspective[2], | 502 perspective[2], |
| 494 perspective[3], | 503 perspective[3], |
| 495 quaternion[0], | 504 quaternion[0], |
| 496 quaternion[1], | 505 quaternion[1], |
| 497 quaternion[2], | 506 quaternion[2], |
| 498 quaternion[3]); | 507 quaternion[3]); |
| 499 } | 508 } |
| 500 | 509 |
| 501 } // namespace ui | 510 } // namespace ui |
| OLD | NEW |