Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CC_ANIMATION_SCROLL_OFFSET_ANIMATIONS_H_ | 5 #ifndef CC_ANIMATION_SCROLL_OFFSET_ANIMATIONS_H_ |
| 6 #define CC_ANIMATION_SCROLL_OFFSET_ANIMATIONS_H_ | 6 #define CC_ANIMATION_SCROLL_OFFSET_ANIMATIONS_H_ |
| 7 | 7 |
| 8 #include <unordered_map> | |
| 9 | |
| 8 #include "cc/animation/scroll_offset_animations_impl.h" | 10 #include "cc/animation/scroll_offset_animations_impl.h" |
| 9 #include "cc/trees/mutator_host_client.h" | 11 #include "cc/trees/mutator_host_client.h" |
| 10 | 12 |
| 11 namespace cc { | 13 namespace cc { |
| 12 | 14 |
| 13 // A ScrollOffsetAnimationUpdate represents a change on the main thread | 15 // A ScrollOffsetAnimationUpdate represents a change on the main thread |
| 14 // that may impact an impl-only scroll offset animation. | 16 // that may impact an impl-only scroll offset animation. |
| 15 // Note that this class only exists on the main thread. | 17 // Note that this class only exists on the main thread. |
| 16 struct CC_EXPORT ScrollOffsetAnimationUpdate { | 18 struct CC_EXPORT ScrollOffsetAnimationUpdate { |
| 17 enum Type { SCROLL_OFFSET_CHANGED }; | 19 explicit ScrollOffsetAnimationUpdate(ElementId); |
| 18 | 20 |
| 19 ScrollOffsetAnimationUpdate(Type, ElementId); | |
| 20 | |
| 21 Type type_; | |
| 22 // The element to which this update applies. | 21 // The element to which this update applies. |
| 23 ElementId element_id_; | 22 ElementId element_id_; |
| 24 | 23 |
| 25 // The amount by which the scroll offset is changed on the main thread. | 24 // The amount by which the scroll offset is changed on the main thread. |
| 26 gfx::Vector2dF adjustment_; | 25 gfx::Vector2dF adjustment_; |
| 26 | |
| 27 // If set to true, abort the currently running impl only scroll offset | |
| 28 // animation running on cc and finish it on the main thread. | |
| 29 bool takeover_; | |
| 27 }; | 30 }; |
| 28 | 31 |
| 29 // ScrollOffsetAnimations contains a list of ScrollOffsetAnimationUpdates. | 32 // ScrollOffsetAnimations contains a list of ScrollOffsetAnimationUpdates. |
| 30 // PushPropertiesTo is called during commit time and the necessary update is | 33 // PushPropertiesTo is called during commit time and the necessary update is |
| 31 // made to the impl-only animation. | 34 // made to the impl-only animation. |
| 32 class CC_EXPORT ScrollOffsetAnimations { | 35 class CC_EXPORT ScrollOffsetAnimations { |
| 33 public: | 36 public: |
| 34 explicit ScrollOffsetAnimations(AnimationHost* animation_host); | 37 explicit ScrollOffsetAnimations(AnimationHost* animation_host); |
| 35 ~ScrollOffsetAnimations(); | 38 ~ScrollOffsetAnimations(); |
| 36 | 39 |
| 37 void AddUpdate(ScrollOffsetAnimationUpdate); | 40 void AddAdjustmentUpdate(ElementId, gfx::Vector2dF adjustment); |
| 41 void AddTakeoverUpdate(ElementId); | |
| 42 | |
| 38 bool HasUpdatesForTesting() const; | 43 bool HasUpdatesForTesting() const; |
| 39 | 44 |
| 40 // Goes through the updates in the order in which they're added and calls the | 45 // Goes through the updates in the order in which they're added and calls the |
| 41 // appropriate handler for each update. | 46 // appropriate handler for each update. |
| 42 void PushPropertiesTo(ScrollOffsetAnimationsImpl*); | 47 void PushPropertiesTo(ScrollOffsetAnimationsImpl*); |
| 43 | 48 |
| 44 private: | 49 private: |
| 45 using UpdatesQueue = std::vector<ScrollOffsetAnimationUpdate>; | 50 ScrollOffsetAnimationUpdate GetUpdateForElementId(ElementId) const; |
| 46 UpdatesQueue queue_; | 51 |
| 52 using ElementToUpdate = | |
|
skobes
2016/05/24 23:50:50
I'd call this UpdateMap or maybe ElementToUpdateMa
ymalik
2016/05/25 16:09:05
Done.
| |
| 53 std::unordered_map<ElementId, ScrollOffsetAnimationUpdate>; | |
| 54 ElementToUpdate element_to_update_map_; | |
| 47 | 55 |
| 48 AnimationHost* animation_host_; | 56 AnimationHost* animation_host_; |
| 49 }; | 57 }; |
| 50 | 58 |
| 51 } // namespace cc | 59 } // namespace cc |
| 52 | 60 |
| 53 #endif // CC_ANIMATION_SCROLL_OFFSET_ANIMATIONS_H_ | 61 #endif // CC_ANIMATION_SCROLL_OFFSET_ANIMATIONS_H_ |
| OLD | NEW |