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/interpolated_transform.h" | 5 #include "ui/gfx/interpolated_transform.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #ifndef M_PI | 9 #ifndef M_PI |
| 10 #define M_PI 3.14159265358979323846 | 10 #define M_PI 3.14159265358979323846 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 : InterpolatedTransform(start_time, end_time), | 267 : InterpolatedTransform(start_time, end_time), |
| 268 start_pos_(start_pos), | 268 start_pos_(start_pos), |
| 269 end_pos_(end_pos) { | 269 end_pos_(end_pos) { |
| 270 } | 270 } |
| 271 | 271 |
| 272 InterpolatedTranslation::~InterpolatedTranslation() {} | 272 InterpolatedTranslation::~InterpolatedTranslation() {} |
| 273 | 273 |
| 274 gfx::Transform | 274 gfx::Transform |
| 275 InterpolatedTranslation::InterpolateButDoNotCompose(float t) const { | 275 InterpolatedTranslation::InterpolateButDoNotCompose(float t) const { |
| 276 gfx::Transform result; | 276 gfx::Transform result; |
| 277 result.Translate3d(ValueBetween(t, start_pos_.x(), end_pos_.x()), | 277 result.Translate3d(ValueBetween(t, static_cast<float>(start_pos_.x()), |
|
danakj
2014/10/18 18:40:06
isn't start_pos_ floats already? https://code.goog
Peter Kasting
2014/10/20 23:38:56
Yes -- I think this got changed since the time I o
| |
| 278 ValueBetween(t, start_pos_.y(), end_pos_.y()), | 278 static_cast<float>(end_pos_.x())), |
| 279 ValueBetween(t, start_pos_.z(), end_pos_.z())); | 279 ValueBetween(t, static_cast<float>(start_pos_.y()), |
| 280 static_cast<float>(end_pos_.y())), | |
| 281 ValueBetween(t, static_cast<float>(start_pos_.z()), | |
| 282 static_cast<float>(end_pos_.z()))); | |
| 280 return result; | 283 return result; |
| 281 } | 284 } |
| 282 | 285 |
| 283 /////////////////////////////////////////////////////////////////////////////// | 286 /////////////////////////////////////////////////////////////////////////////// |
| 284 // InterpolatedConstantTransform | 287 // InterpolatedConstantTransform |
| 285 // | 288 // |
| 286 | 289 |
| 287 InterpolatedConstantTransform::InterpolatedConstantTransform( | 290 InterpolatedConstantTransform::InterpolatedConstantTransform( |
| 288 const gfx::Transform& transform) | 291 const gfx::Transform& transform) |
| 289 : InterpolatedTransform(), | 292 : InterpolatedTransform(), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 if (transform_.get()) { | 327 if (transform_.get()) { |
| 325 return transform_->Interpolate(t); | 328 return transform_->Interpolate(t); |
| 326 } | 329 } |
| 327 return gfx::Transform(); | 330 return gfx::Transform(); |
| 328 } | 331 } |
| 329 | 332 |
| 330 void InterpolatedTransformAboutPivot::Init(const gfx::Point& pivot, | 333 void InterpolatedTransformAboutPivot::Init(const gfx::Point& pivot, |
| 331 InterpolatedTransform* xform) { | 334 InterpolatedTransform* xform) { |
| 332 gfx::Transform to_pivot; | 335 gfx::Transform to_pivot; |
| 333 gfx::Transform from_pivot; | 336 gfx::Transform from_pivot; |
| 334 to_pivot.Translate(-pivot.x(), -pivot.y()); | 337 to_pivot.Translate(SkScalarToMScalar(SkIntToScalar(-pivot.x())), |
|
danakj
2014/10/18 18:40:06
yo dawg, i heard you like static casts :/
we shou
Peter Kasting
2014/10/20 23:38:56
Filed https://code.google.com/p/skia/issues/detail
| |
| 335 from_pivot.Translate(pivot.x(), pivot.y()); | 338 SkScalarToMScalar(SkIntToScalar(-pivot.y()))); |
| 339 from_pivot.Translate(SkScalarToMScalar(SkIntToScalar(pivot.x())), | |
| 340 SkScalarToMScalar(SkIntToScalar(pivot.y()))); | |
| 336 | 341 |
| 337 scoped_ptr<InterpolatedTransform> pre_transform( | 342 scoped_ptr<InterpolatedTransform> pre_transform( |
| 338 new InterpolatedConstantTransform(to_pivot)); | 343 new InterpolatedConstantTransform(to_pivot)); |
| 339 scoped_ptr<InterpolatedTransform> post_transform( | 344 scoped_ptr<InterpolatedTransform> post_transform( |
| 340 new InterpolatedConstantTransform(from_pivot)); | 345 new InterpolatedConstantTransform(from_pivot)); |
| 341 | 346 |
| 342 pre_transform->SetChild(xform); | 347 pre_transform->SetChild(xform); |
| 343 xform->SetChild(post_transform.release()); | 348 xform->SetChild(post_transform.release()); |
| 344 transform_.reset(pre_transform.release()); | 349 transform_.reset(pre_transform.release()); |
| 345 } | 350 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 375 | 380 |
| 376 void InterpolatedMatrixTransform::Init(const gfx::Transform& start_transform, | 381 void InterpolatedMatrixTransform::Init(const gfx::Transform& start_transform, |
| 377 const gfx::Transform& end_transform) { | 382 const gfx::Transform& end_transform) { |
| 378 bool success = gfx::DecomposeTransform(&start_decomp_, start_transform); | 383 bool success = gfx::DecomposeTransform(&start_decomp_, start_transform); |
| 379 DCHECK(success); | 384 DCHECK(success); |
| 380 success = gfx::DecomposeTransform(&end_decomp_, end_transform); | 385 success = gfx::DecomposeTransform(&end_decomp_, end_transform); |
| 381 DCHECK(success); | 386 DCHECK(success); |
| 382 } | 387 } |
| 383 | 388 |
| 384 } // namespace ui | 389 } // namespace ui |
| OLD | NEW |