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

Side by Side Diff: ui/compositor/layer_animator.cc

Issue 10874064: Fixes crash introduced @ 153047 (you can hit crash by maximizing a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ui/compositor/layer_animator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compositor/layer_animator.h" 5 #include "ui/compositor/layer_animator.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ui/base/animation/animation_container.h" 10 #include "ui/base/animation/animation_container.h"
(...skipping 25 matching lines...) Expand all
36 int LayerAnimator::slow_animation_scale_factor_ = 4; 36 int LayerAnimator::slow_animation_scale_factor_ = 4;
37 37
38 // LayerAnimator public -------------------------------------------------------- 38 // LayerAnimator public --------------------------------------------------------
39 39
40 LayerAnimator::LayerAnimator(base::TimeDelta transition_duration) 40 LayerAnimator::LayerAnimator(base::TimeDelta transition_duration)
41 : delegate_(NULL), 41 : delegate_(NULL),
42 preemption_strategy_(IMMEDIATELY_SET_NEW_TARGET), 42 preemption_strategy_(IMMEDIATELY_SET_NEW_TARGET),
43 transition_duration_(transition_duration), 43 transition_duration_(transition_duration),
44 tween_type_(Tween::LINEAR), 44 tween_type_(Tween::LINEAR),
45 is_started_(false), 45 is_started_(false),
46 disable_timer_for_test_(false) { 46 disable_timer_for_test_(false),
47 destroyed_(NULL) {
47 } 48 }
48 49
49 LayerAnimator::~LayerAnimator() { 50 LayerAnimator::~LayerAnimator() {
50 for (size_t i = 0; i < running_animations_.size(); ++i) 51 for (size_t i = 0; i < running_animations_.size(); ++i)
51 running_animations_[i].sequence->OnAnimatorDestroyed(); 52 running_animations_[i].sequence->OnAnimatorDestroyed();
52 ClearAnimations(); 53 ClearAnimations();
54 if (destroyed_)
55 *destroyed_ = true;
53 } 56 }
54 57
55 // static 58 // static
56 LayerAnimator* LayerAnimator::CreateDefaultAnimator() { 59 LayerAnimator* LayerAnimator::CreateDefaultAnimator() {
57 return new LayerAnimator(base::TimeDelta::FromMilliseconds(0)); 60 return new LayerAnimator(base::TimeDelta::FromMilliseconds(0));
58 } 61 }
59 62
60 // static 63 // static
61 LayerAnimator* LayerAnimator::CreateImplicitAnimator() { 64 LayerAnimator* LayerAnimator::CreateImplicitAnimator() {
62 return new LayerAnimator(kDefaultTransitionDuration); 65 return new LayerAnimator(kDefaultTransitionDuration);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return true; 276 return true;
274 } 277 }
275 return false; 278 return false;
276 } 279 }
277 280
278 // LayerAnimator private ------------------------------------------------------- 281 // LayerAnimator private -------------------------------------------------------
279 282
280 void LayerAnimator::Step(base::TimeTicks now) { 283 void LayerAnimator::Step(base::TimeTicks now) {
281 TRACE_EVENT0("ui", "LayerAnimator::Step"); 284 TRACE_EVENT0("ui", "LayerAnimator::Step");
282 285
286 bool destroyed = false;
287 destroyed_ = &destroyed;
283 last_step_time_ = now; 288 last_step_time_ = now;
284 // We need to make a copy of the running animations because progressing them 289 // We need to make a copy of the running animations because progressing them
285 // and finishing them may indirectly affect the collection of running 290 // and finishing them may indirectly affect the collection of running
286 // animations. 291 // animations.
287 RunningAnimations running_animations_copy = running_animations_; 292 RunningAnimations running_animations_copy = running_animations_;
288 bool needs_redraw = false; 293 bool needs_redraw = false;
289 for (size_t i = 0; i < running_animations_copy.size(); ++i) { 294 for (size_t i = 0; i < running_animations_copy.size(); ++i) {
290 if (!HasAnimation(running_animations_copy[i].sequence)) 295 if (!HasAnimation(running_animations_copy[i].sequence))
291 continue; 296 continue;
292 297
293 base::TimeDelta delta = now - running_animations_copy[i].start_time; 298 base::TimeDelta delta = now - running_animations_copy[i].start_time;
294 if (delta >= running_animations_copy[i].sequence->duration() && 299 if (delta >= running_animations_copy[i].sequence->duration() &&
295 !running_animations_copy[i].sequence->is_cyclic()) { 300 !running_animations_copy[i].sequence->is_cyclic()) {
296 FinishAnimation(running_animations_copy[i].sequence); 301 FinishAnimation(running_animations_copy[i].sequence);
302 if (destroyed)
303 return;
297 needs_redraw = true; 304 needs_redraw = true;
298 } else if (ProgressAnimation(running_animations_copy[i].sequence, delta)) 305 } else if (ProgressAnimation(running_animations_copy[i].sequence, delta)) {
299 needs_redraw = true; 306 needs_redraw = true;
307 }
300 } 308 }
301 309
310 destroyed_ = NULL;
302 if (needs_redraw && delegate()) 311 if (needs_redraw && delegate())
303 delegate()->ScheduleDrawForAnimation(); 312 delegate()->ScheduleDrawForAnimation();
304 } 313 }
305 314
306 void LayerAnimator::SetStartTime(base::TimeTicks start_time) { 315 void LayerAnimator::SetStartTime(base::TimeTicks start_time) {
307 // Do nothing. 316 // Do nothing.
308 } 317 }
309 318
310 base::TimeDelta LayerAnimator::GetTimerInterval() const { 319 base::TimeDelta LayerAnimator::GetTimerInterval() const {
311 return kTimerInterval; 320 return kTimerInterval;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 } 620 }
612 } 621 }
613 sequence->OnScheduled(); 622 sequence->OnScheduled();
614 } 623 }
615 624
616 base::TimeDelta LayerAnimator::GetTransitionDuration() const { 625 base::TimeDelta LayerAnimator::GetTransitionDuration() const {
617 return transition_duration_; 626 return transition_duration_;
618 } 627 }
619 628
620 } // namespace ui 629 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698