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

Side by Side Diff: cc/animation/keyframed_animation_curve.cc

Issue 642983003: cc: Make PictureLayerImpl use a better choice for animated raster scale. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: animationscale: fixes Created 6 years, 2 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "cc/animation/keyframed_animation_curve.h" 7 #include "cc/animation/keyframed_animation_curve.h"
8 #include "ui/gfx/animation/tween.h" 8 #include "ui/gfx/animation/tween.h"
9 #include "ui/gfx/box_f.h" 9 #include "ui/gfx/box_f.h"
10 10
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 bool KeyframedTransformAnimationCurve::IsTranslation() const { 360 bool KeyframedTransformAnimationCurve::IsTranslation() const {
361 for (size_t i = 0; i < keyframes_.size(); ++i) { 361 for (size_t i = 0; i < keyframes_.size(); ++i) {
362 if (!keyframes_[i]->Value().IsTranslation() && 362 if (!keyframes_[i]->Value().IsTranslation() &&
363 !keyframes_[i]->Value().IsIdentity()) 363 !keyframes_[i]->Value().IsIdentity())
364 return false; 364 return false;
365 } 365 }
366 return true; 366 return true;
367 } 367 }
368 368
369 bool KeyframedTransformAnimationCurve::MaximumScale(float* max_scale) const { 369 bool KeyframedTransformAnimationCurve::MaximumTargetScale(
370 float* max_scale) const {
370 DCHECK_GE(keyframes_.size(), 2ul); 371 DCHECK_GE(keyframes_.size(), 2ul);
371 *max_scale = 0.f; 372 *max_scale = 0.f;
372 for (size_t i = 1; i < keyframes_.size(); ++i) { 373 for (size_t i = 1; i < keyframes_.size(); ++i) {
373 float min_progress = 0.f; 374 float min_progress = 0.f;
374 float max_progress = 1.f; 375 float max_progress = 1.f;
375 if (keyframes_[i - 1]->timing_function()) 376 if (keyframes_[i - 1]->timing_function())
376 keyframes_[i - 1]->timing_function()->Range(&min_progress, &max_progress); 377 keyframes_[i - 1]->timing_function()->Range(&min_progress, &max_progress);
377 378
378 float max_scale_for_segment = 0.f; 379 gfx::Vector3dF target_scale_for_segment;
379 if (!keyframes_[i]->Value().MaximumScale(keyframes_[i - 1]->Value(), 380 if (!keyframes_[i]->Value().ScaleComponent(&target_scale_for_segment))
380 min_progress,
381 max_progress,
382 &max_scale_for_segment))
383 return false; 381 return false;
384 382 float max_scale_for_segment =
385 *max_scale = std::max(*max_scale, max_scale_for_segment); 383 fmaxf(std::abs(target_scale_for_segment.x()),
vmpstr 2014/10/10 03:31:23 hehe, why fmaxf then? :P Also, should this be std:
danakj 2014/10/10 05:30:11 Its not in std:: it actually is a co.piler define
vmpstr 2014/10/10 07:26:24 If it's cheaper, then that's good enough. Right ma
384 fmaxf(std::abs(target_scale_for_segment.y()),
385 std::abs(target_scale_for_segment.z())));
386 *max_scale = fmaxf(*max_scale, max_scale_for_segment);
386 } 387 }
387 return true; 388 return true;
388 } 389 }
389 390
390 scoped_ptr<KeyframedFilterAnimationCurve> KeyframedFilterAnimationCurve:: 391 scoped_ptr<KeyframedFilterAnimationCurve> KeyframedFilterAnimationCurve::
391 Create() { 392 Create() {
392 return make_scoped_ptr(new KeyframedFilterAnimationCurve); 393 return make_scoped_ptr(new KeyframedFilterAnimationCurve);
393 } 394 }
394 395
395 KeyframedFilterAnimationCurve::KeyframedFilterAnimationCurve() {} 396 KeyframedFilterAnimationCurve::KeyframedFilterAnimationCurve() {}
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 bool KeyframedFilterAnimationCurve::HasFilterThatMovesPixels() const { 435 bool KeyframedFilterAnimationCurve::HasFilterThatMovesPixels() const {
435 for (size_t i = 0; i < keyframes_.size(); ++i) { 436 for (size_t i = 0; i < keyframes_.size(); ++i) {
436 if (keyframes_[i]->Value().HasFilterThatMovesPixels()) { 437 if (keyframes_[i]->Value().HasFilterThatMovesPixels()) {
437 return true; 438 return true;
438 } 439 }
439 } 440 }
440 return false; 441 return false;
441 } 442 }
442 443
443 } // namespace cc 444 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698