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

Side by Side Diff: cc/input/main_thread_scrolling_reason.h

Issue 2469013004: Put all reasons in MainThreadScrollingReason into one enum (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 #include <string> 8 #include <string>
9 9
10 #include "base/trace_event/trace_event_argument.h" 10 #include "base/trace_event/trace_event_argument.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 // Ensure this stays in sync with MainThreadScrollingReason in histograms.xml. 14 // Ensure this stays in sync with MainThreadScrollingReason in histograms.xml.
15 // When adding a new MainThreadScrollingReason, make sure the corresponding 15 // When adding a new MainThreadScrollingReason, make sure the corresponding
16 // [MainThread/Compositor]CanSetScrollReasons function is also updated. 16 // [MainThread/Compositor]CanSetScrollReasons function is also updated.
17 struct MainThreadScrollingReason { 17 struct MainThreadScrollingReason {
18 // Non-transient scrolling reasons. 18 enum : uint32_t {
19 enum : uint32_t { kNotScrollingOnMain = 0 }; 19 // Non-transient scrolling reasons.
20 enum : uint32_t { kHasBackgroundAttachmentFixedObjects = 1 << 0 }; 20 kNotScrollingOnMain = 0,
21 enum : uint32_t { kHasNonLayerViewportConstrainedObjects = 1 << 1 }; 21 kHasBackgroundAttachmentFixedObjects = 1 << 0,
22 enum : uint32_t { kThreadedScrollingDisabled = 1 << 2 }; 22 kHasNonLayerViewportConstrainedObjects = 1 << 1,
23 enum : uint32_t { kScrollbarScrolling = 1 << 3 }; 23 kThreadedScrollingDisabled = 1 << 2,
24 enum : uint32_t { kPageOverlay = 1 << 4 }; 24 kScrollbarScrolling = 1 << 3,
25 // This bit is set when any of the other main thread scrolling reasons cause 25 kPageOverlay = 1 << 4,
26 // an input event to be handled on the main thread, and the main thread
27 // blink::ScrollAnimator is in the middle of running a scroll offset
28 // animation. Note that a scroll handled by the main thread can result in an
29 // animation running on the main thread or on the compositor thread.
30 enum : uint32_t { kHandlingScrollFromMainThread = 1 << 13 };
31 enum : uint32_t { kCustomScrollbarScrolling = 1 << 15 };
32 26
33 // Transient scrolling reasons. These are computed for each scroll begin. 27 // This bit is set when any of the other main thread scrolling reasons cause
34 enum : uint32_t { kNonFastScrollableRegion = 1 << 5 }; 28 // an input event to be handled on the main thread, and the main thread
35 enum : uint32_t { kFailedHitTest = 1 << 7 }; 29 // blink::ScrollAnimator is in the middle of running a scroll offset
36 enum : uint32_t { kNoScrollingLayer = 1 << 8 }; 30 // animation. Note that a scroll handled by the main thread can result in an
37 enum : uint32_t { kNotScrollable = 1 << 9 }; 31 // animation running on the main thread or on the compositor thread.
38 enum : uint32_t { kContinuingMainThreadScroll = 1 << 10 }; 32 kHandlingScrollFromMainThread = 1 << 13,
39 enum : uint32_t { kNonInvertibleTransform = 1 << 11 }; 33 kCustomScrollbarScrolling = 1 << 15,
40 enum : uint32_t { kPageBasedScrolling = 1 << 12 };
41 34
42 // The number of flags in this struct (excluding itself). 35 // Transient scrolling reasons. These are computed for each scroll begin.
43 enum : uint32_t { kMainThreadScrollingReasonCount = 17 }; 36 kNonFastScrollableRegion = 1 << 5,
37 kFailedHitTest = 1 << 7,
38 kNoScrollingLayer = 1 << 8,
39 kNotScrollable = 1 << 9,
40 kContinuingMainThreadScroll = 1 << 10,
41 kNonInvertibleTransform = 1 << 11,
42 kPageBasedScrolling = 1 << 12,
43
44 // The number of flags in this struct (excluding itself).
45 kMainThreadScrollingReasonCount = 17,
46 };
44 47
45 // Returns true if the given MainThreadScrollingReason can be set by the main 48 // Returns true if the given MainThreadScrollingReason can be set by the main
46 // thread. 49 // thread.
47 static bool MainThreadCanSetScrollReasons(uint32_t reasons) { 50 static bool MainThreadCanSetScrollReasons(uint32_t reasons) {
48 uint32_t reasons_set_by_main_thread = 51 uint32_t reasons_set_by_main_thread =
49 kNotScrollingOnMain | kHasBackgroundAttachmentFixedObjects | 52 kNotScrollingOnMain | kHasBackgroundAttachmentFixedObjects |
50 kHasNonLayerViewportConstrainedObjects | kThreadedScrollingDisabled | 53 kHasNonLayerViewportConstrainedObjects | kThreadedScrollingDisabled |
51 kScrollbarScrolling | kPageOverlay | kHandlingScrollFromMainThread | 54 kScrollbarScrolling | kPageOverlay | kHandlingScrollFromMainThread |
52 kCustomScrollbarScrolling; 55 kCustomScrollbarScrolling;
53 return (reasons & reasons_set_by_main_thread) == reasons; 56 return (reasons & reasons_set_by_main_thread) == reasons;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 tracedValue->AppendString("Non-invertible transform"); 113 tracedValue->AppendString("Non-invertible transform");
111 if (reasons & MainThreadScrollingReason::kPageBasedScrolling) 114 if (reasons & MainThreadScrollingReason::kPageBasedScrolling)
112 tracedValue->AppendString("Page-based scrolling"); 115 tracedValue->AppendString("Page-based scrolling");
113 tracedValue->EndArray(); 116 tracedValue->EndArray();
114 } 117 }
115 }; 118 };
116 119
117 } // namespace cc 120 } // namespace cc
118 121
119 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ 122 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698