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

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

Issue 10882043: Revert 153291 - 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) {
48 } 47 }
49 48
50 LayerAnimator::~LayerAnimator() { 49 LayerAnimator::~LayerAnimator() {
51 for (size_t i = 0; i < running_animations_.size(); ++i) 50 for (size_t i = 0; i < running_animations_.size(); ++i)
52 running_animations_[i].sequence->OnAnimatorDestroyed(); 51 running_animations_[i].sequence->OnAnimatorDestroyed();
53 ClearAnimations(); 52 ClearAnimations();
54 if (destroyed_)
55 *destroyed_ = true;
56 } 53 }
57 54
58 // static 55 // static
59 LayerAnimator* LayerAnimator::CreateDefaultAnimator() { 56 LayerAnimator* LayerAnimator::CreateDefaultAnimator() {
60 return new LayerAnimator(base::TimeDelta::FromMilliseconds(0)); 57 return new LayerAnimator(base::TimeDelta::FromMilliseconds(0));
61 } 58 }
62 59
63 // static 60 // static
64 LayerAnimator* LayerAnimator::CreateImplicitAnimator() { 61 LayerAnimator* LayerAnimator::CreateImplicitAnimator() {
65 return new LayerAnimator(kDefaultTransitionDuration); 62 return new LayerAnimator(kDefaultTransitionDuration);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return true; 273 return true;
277 } 274 }
278 return false; 275 return false;
279 } 276 }
280 277
281 // LayerAnimator private ------------------------------------------------------- 278 // LayerAnimator private -------------------------------------------------------
282 279
283 void LayerAnimator::Step(base::TimeTicks now) { 280 void LayerAnimator::Step(base::TimeTicks now) {
284 TRACE_EVENT0("ui", "LayerAnimator::Step"); 281 TRACE_EVENT0("ui", "LayerAnimator::Step");
285 282
286 bool destroyed = false;
287 destroyed_ = &destroyed;
288 last_step_time_ = now; 283 last_step_time_ = now;
289 // We need to make a copy of the running animations because progressing them 284 // We need to make a copy of the running animations because progressing them
290 // and finishing them may indirectly affect the collection of running 285 // and finishing them may indirectly affect the collection of running
291 // animations. 286 // animations.
292 RunningAnimations running_animations_copy = running_animations_; 287 RunningAnimations running_animations_copy = running_animations_;
293 bool needs_redraw = false; 288 bool needs_redraw = false;
294 for (size_t i = 0; i < running_animations_copy.size(); ++i) { 289 for (size_t i = 0; i < running_animations_copy.size(); ++i) {
295 if (!HasAnimation(running_animations_copy[i].sequence)) 290 if (!HasAnimation(running_animations_copy[i].sequence))
296 continue; 291 continue;
297 292
298 base::TimeDelta delta = now - running_animations_copy[i].start_time; 293 base::TimeDelta delta = now - running_animations_copy[i].start_time;
299 if (delta >= running_animations_copy[i].sequence->duration() && 294 if (delta >= running_animations_copy[i].sequence->duration() &&
300 !running_animations_copy[i].sequence->is_cyclic()) { 295 !running_animations_copy[i].sequence->is_cyclic()) {
301 FinishAnimation(running_animations_copy[i].sequence); 296 FinishAnimation(running_animations_copy[i].sequence);
302 if (destroyed)
303 return;
304 needs_redraw = true; 297 needs_redraw = true;
305 } else if (ProgressAnimation(running_animations_copy[i].sequence, delta)) { 298 } else if (ProgressAnimation(running_animations_copy[i].sequence, delta))
306 needs_redraw = true; 299 needs_redraw = true;
307 }
308 } 300 }
309 301
310 destroyed_ = NULL;
311 if (needs_redraw && delegate()) 302 if (needs_redraw && delegate())
312 delegate()->ScheduleDrawForAnimation(); 303 delegate()->ScheduleDrawForAnimation();
313 } 304 }
314 305
315 void LayerAnimator::SetStartTime(base::TimeTicks start_time) { 306 void LayerAnimator::SetStartTime(base::TimeTicks start_time) {
316 // Do nothing. 307 // Do nothing.
317 } 308 }
318 309
319 base::TimeDelta LayerAnimator::GetTimerInterval() const { 310 base::TimeDelta LayerAnimator::GetTimerInterval() const {
320 return kTimerInterval; 311 return kTimerInterval;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 } 611 }
621 } 612 }
622 sequence->OnScheduled(); 613 sequence->OnScheduled();
623 } 614 }
624 615
625 base::TimeDelta LayerAnimator::GetTransitionDuration() const { 616 base::TimeDelta LayerAnimator::GetTransitionDuration() const {
626 return transition_duration_; 617 return transition_duration_;
627 } 618 }
628 619
629 } // namespace ui 620 } // 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