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

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

Issue 2860293002: Change cc::ElementId to be a uint64_t (Closed)
Patch Set: none Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "cc/animation/scroll_offset_animations.h" 5 #include "cc/animation/scroll_offset_animations.h"
6 6
7 #include "cc/animation/animation_host.h" 7 #include "cc/animation/animation_host.h"
8 8
9 namespace cc { 9 namespace cc {
10 10
11 ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate() {} 11 ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate() {}
12 12
13 ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate(ElementId element_id) 13 ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate(ElementId element_id)
14 : element_id_(element_id), takeover_(false) {} 14 : element_id_(element_id), takeover_(false) {}
15 15
16 ScrollOffsetAnimations::ScrollOffsetAnimations(AnimationHost* animation_host) 16 ScrollOffsetAnimations::ScrollOffsetAnimations(AnimationHost* animation_host)
17 : animation_host_(animation_host) {} 17 : animation_host_(animation_host) {}
18 18
19 ScrollOffsetAnimations::~ScrollOffsetAnimations() {} 19 ScrollOffsetAnimations::~ScrollOffsetAnimations() {}
20 20
21 ScrollOffsetAnimationUpdate ScrollOffsetAnimations::GetUpdateForElementId( 21 ScrollOffsetAnimationUpdate ScrollOffsetAnimations::GetUpdateForElementId(
22 ElementId element_id) const { 22 ElementId element_id) const {
23 DCHECK(element_id); 23 DCHECK(element_id.id);
24 auto iter = element_to_update_map_.find(element_id); 24 auto iter = element_to_update_map_.find(element_id.id);
25 return iter == element_to_update_map_.end() 25 return iter == element_to_update_map_.end()
26 ? ScrollOffsetAnimationUpdate(element_id) 26 ? ScrollOffsetAnimationUpdate(element_id)
27 : iter->second; 27 : iter->second;
28 } 28 }
29 29
30 void ScrollOffsetAnimations::AddAdjustmentUpdate(ElementId element_id, 30 void ScrollOffsetAnimations::AddAdjustmentUpdate(ElementId element_id,
31 gfx::Vector2dF adjustment) { 31 gfx::Vector2dF adjustment) {
32 DCHECK(element_id); 32 DCHECK(element_id.id);
33 ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id); 33 ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id);
34 update.adjustment_ += adjustment; 34 update.adjustment_ += adjustment;
35 element_to_update_map_[element_id] = update; 35 element_to_update_map_[element_id.id] = update;
wkorman 2017/05/08 18:23:24 The need to explicitly ref id member data in hash
36 animation_host_->SetNeedsCommit(); 36 animation_host_->SetNeedsCommit();
37 animation_host_->SetNeedsPushProperties(); 37 animation_host_->SetNeedsPushProperties();
38 } 38 }
39 39
40 void ScrollOffsetAnimations::AddTakeoverUpdate(ElementId element_id) { 40 void ScrollOffsetAnimations::AddTakeoverUpdate(ElementId element_id) {
41 DCHECK(element_id); 41 DCHECK(element_id.id);
42 ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id); 42 ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id);
43 update.takeover_ = true; 43 update.takeover_ = true;
44 element_to_update_map_[element_id] = update; 44 element_to_update_map_[element_id.id] = update;
45 animation_host_->SetNeedsCommit(); 45 animation_host_->SetNeedsCommit();
46 animation_host_->SetNeedsPushProperties(); 46 animation_host_->SetNeedsPushProperties();
47 } 47 }
48 48
49 bool ScrollOffsetAnimations::HasUpdatesForTesting() const { 49 bool ScrollOffsetAnimations::HasUpdatesForTesting() const {
50 return !element_to_update_map_.empty(); 50 return !element_to_update_map_.empty();
51 } 51 }
52 52
53 void ScrollOffsetAnimations::PushPropertiesTo( 53 void ScrollOffsetAnimations::PushPropertiesTo(
54 ScrollOffsetAnimationsImpl* animations) { 54 ScrollOffsetAnimationsImpl* animations) {
55 DCHECK(animations); 55 DCHECK(animations);
56 if (element_to_update_map_.empty()) 56 if (element_to_update_map_.empty())
57 return; 57 return;
58 58
59 for (auto& kv : element_to_update_map_) { 59 for (auto& kv : element_to_update_map_) {
60 const auto& update = kv.second; 60 const auto& update = kv.second;
61 if (update.takeover_) 61 if (update.takeover_)
62 animations->ScrollAnimationAbort(true /*needs_completion*/); 62 animations->ScrollAnimationAbort(true /*needs_completion*/);
63 else 63 else
64 animations->ScrollAnimationApplyAdjustment(update.element_id_, 64 animations->ScrollAnimationApplyAdjustment(update.element_id_,
65 update.adjustment_); 65 update.adjustment_);
66 } 66 }
67 element_to_update_map_.clear(); 67 element_to_update_map_.clear();
68 } 68 }
69 69
70 } // namespace cc 70 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698