| OLD | NEW |
| 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 #ifndef CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ | 5 #ifndef CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ |
| 6 #define CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ | 6 #define CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ |
| 7 | 7 |
| 8 namespace cc { | 8 namespace cc { |
| 9 | 9 |
| 10 // Ensure this stays in sync with MainThreadScrollingReason in histograms.xml. | 10 // Ensure this stays in sync with MainThreadScrollingReason in histograms.xml. |
| 11 // When adding a new MainThreadScrollingReason, make sure the corresponding | 11 // When adding a new MainThreadScrollingReason, make sure the corresponding |
| 12 // [MainThread/Compositor]CanSetScrollReasons function is also updated. | 12 // [MainThread/Compositor]CanSetScrollReasons function is also updated. |
| 13 struct MainThreadScrollingReason { | 13 struct MainThreadScrollingReason { |
| 14 // Non-transient scrolling reasons. | 14 // Non-transient scrolling reasons. |
| 15 enum : uint32_t { kNotScrollingOnMain = 0 }; | 15 enum : uint32_t { kNotScrollingOnMain = 0 }; |
| 16 enum : uint32_t { kHasBackgroundAttachmentFixedObjects = 1 << 0 }; | 16 enum : uint32_t { kHasBackgroundAttachmentFixedObjects = 1 << 0 }; |
| 17 enum : uint32_t { kHasNonLayerViewportConstrainedObjects = 1 << 1 }; | 17 enum : uint32_t { kHasNonLayerViewportConstrainedObjects = 1 << 1 }; |
| 18 enum : uint32_t { kThreadedScrollingDisabled = 1 << 2 }; | 18 enum : uint32_t { kThreadedScrollingDisabled = 1 << 2 }; |
| 19 enum : uint32_t { kScrollbarScrolling = 1 << 3 }; | 19 enum : uint32_t { kScrollbarScrolling = 1 << 3 }; |
| 20 enum : uint32_t { kPageOverlay = 1 << 4 }; | 20 enum : uint32_t { kPageOverlay = 1 << 4 }; |
| 21 enum : uint32_t { kAnimatingScrollOnMainThread = 1 << 13 }; | 21 enum : uint32_t { kAnimatingScrollOnMainThread = 1 << 13 }; |
| 22 enum : uint32_t { kHasStickyPositionObjects = 1 << 14 }; |
| 22 | 23 |
| 23 // Transient scrolling reasons. These are computed for each scroll begin. | 24 // Transient scrolling reasons. These are computed for each scroll begin. |
| 24 enum : uint32_t { kNonFastScrollableRegion = 1 << 5 }; | 25 enum : uint32_t { kNonFastScrollableRegion = 1 << 5 }; |
| 25 enum : uint32_t { kEventHandlers = 1 << 6 }; | 26 enum : uint32_t { kEventHandlers = 1 << 6 }; |
| 26 enum : uint32_t { kFailedHitTest = 1 << 7 }; | 27 enum : uint32_t { kFailedHitTest = 1 << 7 }; |
| 27 enum : uint32_t { kNoScrollingLayer = 1 << 8 }; | 28 enum : uint32_t { kNoScrollingLayer = 1 << 8 }; |
| 28 enum : uint32_t { kNotScrollable = 1 << 9 }; | 29 enum : uint32_t { kNotScrollable = 1 << 9 }; |
| 29 enum : uint32_t { kContinuingMainThreadScroll = 1 << 10 }; | 30 enum : uint32_t { kContinuingMainThreadScroll = 1 << 10 }; |
| 30 enum : uint32_t { kNonInvertibleTransform = 1 << 11 }; | 31 enum : uint32_t { kNonInvertibleTransform = 1 << 11 }; |
| 31 enum : uint32_t { kPageBasedScrolling = 1 << 12 }; | 32 enum : uint32_t { kPageBasedScrolling = 1 << 12 }; |
| 32 | 33 |
| 33 // The number of flags in this struct (excluding itself). | 34 // The number of flags in this struct (excluding itself). |
| 34 enum : uint32_t { kMainThreadScrollingReasonCount = 15 }; | 35 enum : uint32_t { kMainThreadScrollingReasonCount = 16 }; |
| 35 | 36 |
| 36 // Returns true if the given MainThreadScrollingReason can be set by the main | 37 // Returns true if the given MainThreadScrollingReason can be set by the main |
| 37 // thread. | 38 // thread. |
| 38 static bool MainThreadCanSetScrollReasons(uint32_t reasons) { | 39 static bool MainThreadCanSetScrollReasons(uint32_t reasons) { |
| 39 uint32_t reasons_set_by_main_thread = | 40 uint32_t reasons_set_by_main_thread = |
| 40 kNotScrollingOnMain | kHasBackgroundAttachmentFixedObjects | | 41 kNotScrollingOnMain | kHasBackgroundAttachmentFixedObjects | |
| 41 kHasNonLayerViewportConstrainedObjects | kThreadedScrollingDisabled | | 42 kHasNonLayerViewportConstrainedObjects | kThreadedScrollingDisabled | |
| 42 kScrollbarScrolling | kPageOverlay | kAnimatingScrollOnMainThread; | 43 kScrollbarScrolling | kPageOverlay | kAnimatingScrollOnMainThread | |
| 44 kHasStickyPositionObjects; |
| 43 return (reasons & reasons_set_by_main_thread) == reasons; | 45 return (reasons & reasons_set_by_main_thread) == reasons; |
| 44 } | 46 } |
| 45 | 47 |
| 46 // Returns true if the given MainThreadScrollingReason can be set by the | 48 // Returns true if the given MainThreadScrollingReason can be set by the |
| 47 // compositor. | 49 // compositor. |
| 48 static bool CompositorCanSetScrollReasons(uint32_t reasons) { | 50 static bool CompositorCanSetScrollReasons(uint32_t reasons) { |
| 49 uint32_t reasons_set_by_compositor = | 51 uint32_t reasons_set_by_compositor = |
| 50 kNonFastScrollableRegion | kEventHandlers | kFailedHitTest | | 52 kNonFastScrollableRegion | kEventHandlers | kFailedHitTest | |
| 51 kNoScrollingLayer | kNotScrollable | kContinuingMainThreadScroll | | 53 kNoScrollingLayer | kNotScrollable | kContinuingMainThreadScroll | |
| 52 kNonInvertibleTransform | kPageBasedScrolling; | 54 kNonInvertibleTransform | kPageBasedScrolling; |
| 53 return (reasons & reasons_set_by_compositor) == reasons; | 55 return (reasons & reasons_set_by_compositor) == reasons; |
| 54 } | 56 } |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 } // namespace cc | 59 } // namespace cc |
| 58 | 60 |
| 59 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ | 61 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ |
| OLD | NEW |