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