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

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

Issue 2015433004: Add main thread scrolling reasons to GraphicsLayer::layerTreeAsJSON. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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 | cc/layers/layer.h » ('j') | 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>
9
10 #include "base/trace_event/trace_event_argument.h"
11
8 namespace cc { 12 namespace cc {
9 13
10 // Ensure this stays in sync with MainThreadScrollingReason in histograms.xml. 14 // Ensure this stays in sync with MainThreadScrollingReason in histograms.xml.
11 // When adding a new MainThreadScrollingReason, make sure the corresponding 15 // When adding a new MainThreadScrollingReason, make sure the corresponding
12 // [MainThread/Compositor]CanSetScrollReasons function is also updated. 16 // [MainThread/Compositor]CanSetScrollReasons function is also updated.
13 struct MainThreadScrollingReason { 17 struct MainThreadScrollingReason {
14 // Non-transient scrolling reasons. 18 // Non-transient scrolling reasons.
15 enum : uint32_t { kNotScrollingOnMain = 0 }; 19 enum : uint32_t { kNotScrollingOnMain = 0 };
16 enum : uint32_t { kHasBackgroundAttachmentFixedObjects = 1 << 0 }; 20 enum : uint32_t { kHasBackgroundAttachmentFixedObjects = 1 << 0 };
17 enum : uint32_t { kHasNonLayerViewportConstrainedObjects = 1 << 1 }; 21 enum : uint32_t { kHasNonLayerViewportConstrainedObjects = 1 << 1 };
(...skipping 30 matching lines...) Expand all
48 52
49 // Returns true if the given MainThreadScrollingReason can be set by the 53 // Returns true if the given MainThreadScrollingReason can be set by the
50 // compositor. 54 // compositor.
51 static bool CompositorCanSetScrollReasons(uint32_t reasons) { 55 static bool CompositorCanSetScrollReasons(uint32_t reasons) {
52 uint32_t reasons_set_by_compositor = 56 uint32_t reasons_set_by_compositor =
53 kNonFastScrollableRegion | kEventHandlers | kFailedHitTest | 57 kNonFastScrollableRegion | kEventHandlers | kFailedHitTest |
54 kNoScrollingLayer | kNotScrollable | kContinuingMainThreadScroll | 58 kNoScrollingLayer | kNotScrollable | kContinuingMainThreadScroll |
55 kNonInvertibleTransform | kPageBasedScrolling; 59 kNonInvertibleTransform | kPageBasedScrolling;
56 return (reasons & reasons_set_by_compositor) == reasons; 60 return (reasons & reasons_set_by_compositor) == reasons;
57 } 61 }
62
63 static std::string mainThreadScrollingReasonsAsText(uint32_t reasons) {
64 base::trace_event::TracedValue tracedValue;
65 mainThreadScrollingReasonsAsTracedValue(reasons, &tracedValue);
66 std::string result_in_array_foramt = tracedValue.ToString();
67 // Remove '{main_thread_scrolling_reasons:[', ']}', and any '"' chars.
68 std::string result =
69 result_in_array_foramt.substr(34, result_in_array_foramt.length() - 36);
70 result.erase(std::remove(result.begin(), result.end(), '\"'), result.end());
71 return result;
72 }
73
74 static void mainThreadScrollingReasonsAsTracedValue(
75 uint32_t reasons,
76 base::trace_event::TracedValue* tracedValue) {
77 tracedValue->BeginArray("main_thread_scrolling_reasons");
78 if (reasons &
79 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)
80 tracedValue->AppendString("Has background-attachment:fixed");
81 if (reasons &
82 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects)
83 tracedValue->AppendString("Has non-layer viewport-constrained objects");
84 if (reasons & MainThreadScrollingReason::kThreadedScrollingDisabled)
85 tracedValue->AppendString("Threaded scrolling is disabled");
86 if (reasons & MainThreadScrollingReason::kScrollbarScrolling)
87 tracedValue->AppendString("Scrollbar scrolling");
88 if (reasons & MainThreadScrollingReason::kPageOverlay)
89 tracedValue->AppendString("Page overlay");
90 if (reasons & MainThreadScrollingReason::kAnimatingScrollOnMainThread)
91 tracedValue->AppendString("Animating scroll on main thread");
92 if (reasons & MainThreadScrollingReason::kHasStickyPositionObjects)
93 tracedValue->AppendString("Has sticky position objects");
94 if (reasons & MainThreadScrollingReason::kCustomScrollbarScrolling)
95 tracedValue->AppendString("Custom scrollbar scrolling");
96
97 // Transient scrolling reasons.
98 if (reasons & MainThreadScrollingReason::kNonFastScrollableRegion)
99 tracedValue->AppendString("Non fast scrollable region");
100 if (reasons & MainThreadScrollingReason::kEventHandlers)
101 tracedValue->AppendString("Event handlers");
102 if (reasons & MainThreadScrollingReason::kFailedHitTest)
103 tracedValue->AppendString("Failed hit test");
104 if (reasons & MainThreadScrollingReason::kNoScrollingLayer)
105 tracedValue->AppendString("No scrolling layer");
106 if (reasons & MainThreadScrollingReason::kNotScrollable)
107 tracedValue->AppendString("Not scrollable");
108 if (reasons & MainThreadScrollingReason::kContinuingMainThreadScroll)
109 tracedValue->AppendString("Continuing main thread scroll");
110 if (reasons & MainThreadScrollingReason::kNonInvertibleTransform)
111 tracedValue->AppendString("Non-invertible transform");
112 if (reasons & MainThreadScrollingReason::kPageBasedScrolling)
113 tracedValue->AppendString("Page-based scrolling");
114 tracedValue->EndArray();
115 }
58 }; 116 };
59 117
60 } // namespace cc 118 } // namespace cc
61 119
62 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ 120 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_
OLDNEW
« no previous file with comments | « no previous file | cc/layers/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698