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 { kAnimatingScollOnMainThread = 1 << 13 }; | |
jbroman
2016/02/10 20:36:37
nit: Scroll, not Scoll
ymalik
2016/02/10 21:57:58
Wow good catch. nts: don't copy paste long variabl
| |
21 | 22 |
22 // Transient scrolling reasons. These are computed for each scroll begin. | 23 // Transient scrolling reasons. These are computed for each scroll begin. |
23 enum : uint32_t { kNonFastScrollableRegion = 1 << 5 }; | 24 enum : uint32_t { kNonFastScrollableRegion = 1 << 5 }; |
24 enum : uint32_t { kEventHandlers = 1 << 6 }; | 25 enum : uint32_t { kEventHandlers = 1 << 6 }; |
25 enum : uint32_t { kFailedHitTest = 1 << 7 }; | 26 enum : uint32_t { kFailedHitTest = 1 << 7 }; |
26 enum : uint32_t { kNoScrollingLayer = 1 << 8 }; | 27 enum : uint32_t { kNoScrollingLayer = 1 << 8 }; |
27 enum : uint32_t { kNotScrollable = 1 << 9 }; | 28 enum : uint32_t { kNotScrollable = 1 << 9 }; |
28 enum : uint32_t { kContinuingMainThreadScroll = 1 << 10 }; | 29 enum : uint32_t { kContinuingMainThreadScroll = 1 << 10 }; |
29 enum : uint32_t { kNonInvertibleTransform = 1 << 11 }; | 30 enum : uint32_t { kNonInvertibleTransform = 1 << 11 }; |
30 enum : uint32_t { kPageBasedScrolling = 1 << 12 }; | 31 enum : uint32_t { kPageBasedScrolling = 1 << 12 }; |
31 | 32 |
32 // The number of flags in this struct (excluding itself). | 33 // The number of flags in this struct (excluding itself). |
33 enum : uint32_t { kMainThreadScrollingReasonCount = 14 }; | 34 enum : uint32_t { kMainThreadScrollingReasonCount = 15 }; |
34 | 35 |
35 // Returns true if the given MainThreadScrollingReason can be set by the main | 36 // Returns true if the given MainThreadScrollingReason can be set by the main |
36 // thread. | 37 // thread. |
37 static bool MainThreadCanSetScrollReasons(uint32_t reasons) { | 38 static bool MainThreadCanSetScrollReasons(uint32_t reasons) { |
38 uint32_t reasons_set_by_main_thread = | 39 uint32_t reasons_set_by_main_thread = |
39 kNotScrollingOnMain | kHasBackgroundAttachmentFixedObjects | | 40 kNotScrollingOnMain | kHasBackgroundAttachmentFixedObjects | |
40 kHasNonLayerViewportConstrainedObjects | kThreadedScrollingDisabled | | 41 kHasNonLayerViewportConstrainedObjects | kThreadedScrollingDisabled | |
41 kScrollbarScrolling | kPageOverlay; | 42 kScrollbarScrolling | kPageOverlay | kAnimatingScollOnMainThread; |
42 return (reasons & reasons_set_by_main_thread) == reasons; | 43 return (reasons & reasons_set_by_main_thread) == reasons; |
43 } | 44 } |
44 | 45 |
45 // Returns true if the given MainThreadScrollingReason can be set by the | 46 // Returns true if the given MainThreadScrollingReason can be set by the |
46 // compositor. | 47 // compositor. |
47 static bool CompositorCanSetScrollReasons(uint32_t reasons) { | 48 static bool CompositorCanSetScrollReasons(uint32_t reasons) { |
48 uint32_t reasons_set_by_compositor = | 49 uint32_t reasons_set_by_compositor = |
49 kNonFastScrollableRegion | kEventHandlers | kFailedHitTest | | 50 kNonFastScrollableRegion | kEventHandlers | kFailedHitTest | |
50 kNoScrollingLayer | kNotScrollable | kContinuingMainThreadScroll | | 51 kNoScrollingLayer | kNotScrollable | kContinuingMainThreadScroll | |
51 kNonInvertibleTransform | kPageBasedScrolling; | 52 kNonInvertibleTransform | kPageBasedScrolling; |
52 return (reasons & reasons_set_by_compositor) == reasons; | 53 return (reasons & reasons_set_by_compositor) == reasons; |
53 } | 54 } |
54 }; | 55 }; |
55 | 56 |
56 } // namespace cc | 57 } // namespace cc |
57 | 58 |
58 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ | 59 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ |
OLD | NEW |