| 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 #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" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // Style-related scrolling on main reasons. | 35 // Style-related scrolling on main reasons. |
| 36 // These *AndLCDText reasons are due to subpixel text rendering which can | 36 // These *AndLCDText reasons are due to subpixel text rendering which can |
| 37 // only be applied by blending glyphs with the background at a specific | 37 // only be applied by blending glyphs with the background at a specific |
| 38 // screen position; transparency and transforms break this. | 38 // screen position; transparency and transforms break this. |
| 39 kHasOpacityAndLCDText = 1 << 16, | 39 kHasOpacityAndLCDText = 1 << 16, |
| 40 kHasTransformAndLCDText = 1 << 17, | 40 kHasTransformAndLCDText = 1 << 17, |
| 41 kBackgroundNotOpaqueInRectAndLCDText = 1 << 18, | 41 kBackgroundNotOpaqueInRectAndLCDText = 1 << 18, |
| 42 kHasBorderRadius = 1 << 19, | 42 kHasBorderRadius = 1 << 19, |
| 43 kHasClipRelatedProperty = 1 << 20, | 43 kHasClipRelatedProperty = 1 << 20, |
| 44 kHasBoxShadowAndLCDText = 1 << 21, |
| 44 | 45 |
| 45 // Transient scrolling reasons. These are computed for each scroll begin. | 46 // Transient scrolling reasons. These are computed for each scroll begin. |
| 46 kNonFastScrollableRegion = 1 << 5, | 47 kNonFastScrollableRegion = 1 << 5, |
| 47 kFailedHitTest = 1 << 7, | 48 kFailedHitTest = 1 << 7, |
| 48 kNoScrollingLayer = 1 << 8, | 49 kNoScrollingLayer = 1 << 8, |
| 49 kNotScrollable = 1 << 9, | 50 kNotScrollable = 1 << 9, |
| 50 kContinuingMainThreadScroll = 1 << 10, | 51 kContinuingMainThreadScroll = 1 << 10, |
| 51 kNonInvertibleTransform = 1 << 11, | 52 kNonInvertibleTransform = 1 << 11, |
| 52 kPageBasedScrolling = 1 << 12, | 53 kPageBasedScrolling = 1 << 12, |
| 53 | 54 |
| 54 // The maximum number of flags in this struct (excluding itself). | 55 // The maximum number of flags in this struct (excluding itself). |
| 55 // New flags should increment this number but it should never be decremented | 56 // New flags should increment this number but it should never be decremented |
| 56 // because the values are used in UMA histograms. It should also be noted | 57 // because the values are used in UMA histograms. It should also be noted |
| 57 // that it excludes the kNotScrollingOnMain value. | 58 // that it excludes the kNotScrollingOnMain value. |
| 58 kMainThreadScrollingReasonCount = 21, | 59 kMainThreadScrollingReasonCount = 22, |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 // Returns true if the given MainThreadScrollingReason can be set by the main | 62 // Returns true if the given MainThreadScrollingReason can be set by the main |
| 62 // thread. | 63 // thread. |
| 63 static bool MainThreadCanSetScrollReasons(uint32_t reasons) { | 64 static bool MainThreadCanSetScrollReasons(uint32_t reasons) { |
| 64 uint32_t reasons_set_by_main_thread = | 65 uint32_t reasons_set_by_main_thread = |
| 65 kNotScrollingOnMain | kHasBackgroundAttachmentFixedObjects | | 66 kNotScrollingOnMain | kHasBackgroundAttachmentFixedObjects | |
| 66 kHasNonLayerViewportConstrainedObjects | kThreadedScrollingDisabled | | 67 kHasNonLayerViewportConstrainedObjects | kThreadedScrollingDisabled | |
| 67 kScrollbarScrolling | kPageOverlay | kHandlingScrollFromMainThread | | 68 kScrollbarScrolling | kPageOverlay | kHandlingScrollFromMainThread | |
| 68 kCustomScrollbarScrolling | kHasOpacityAndLCDText | | 69 kCustomScrollbarScrolling | kHasOpacityAndLCDText | |
| 69 kHasTransformAndLCDText | kBackgroundNotOpaqueInRectAndLCDText | | 70 kHasTransformAndLCDText | kBackgroundNotOpaqueInRectAndLCDText | |
| 70 kHasBorderRadius | kHasClipRelatedProperty; | 71 kHasBorderRadius | kHasClipRelatedProperty | kHasBoxShadowAndLCDText; |
| 71 return (reasons & reasons_set_by_main_thread) == reasons; | 72 return (reasons & reasons_set_by_main_thread) == reasons; |
| 72 } | 73 } |
| 73 | 74 |
| 74 // Returns true if the given MainThreadScrollingReason can be set by the | 75 // Returns true if the given MainThreadScrollingReason can be set by the |
| 75 // compositor. | 76 // compositor. |
| 76 static bool CompositorCanSetScrollReasons(uint32_t reasons) { | 77 static bool CompositorCanSetScrollReasons(uint32_t reasons) { |
| 77 uint32_t reasons_set_by_compositor = | 78 uint32_t reasons_set_by_compositor = |
| 78 kNonFastScrollableRegion | kFailedHitTest | kNoScrollingLayer | | 79 kNonFastScrollableRegion | kFailedHitTest | kNoScrollingLayer | |
| 79 kNotScrollable | kContinuingMainThreadScroll | kNonInvertibleTransform | | 80 kNotScrollable | kContinuingMainThreadScroll | kNonInvertibleTransform | |
| 80 kPageBasedScrolling; | 81 kPageBasedScrolling; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 tracedValue->AppendString("Has transform and LCD text"); | 119 tracedValue->AppendString("Has transform and LCD text"); |
| 119 if (reasons & | 120 if (reasons & |
| 120 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText) { | 121 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText) { |
| 121 tracedValue->AppendString( | 122 tracedValue->AppendString( |
| 122 "Background is not opaque in rect and LCD text"); | 123 "Background is not opaque in rect and LCD text"); |
| 123 } | 124 } |
| 124 if (reasons & MainThreadScrollingReason::kHasBorderRadius) | 125 if (reasons & MainThreadScrollingReason::kHasBorderRadius) |
| 125 tracedValue->AppendString("Has border radius"); | 126 tracedValue->AppendString("Has border radius"); |
| 126 if (reasons & MainThreadScrollingReason::kHasClipRelatedProperty) | 127 if (reasons & MainThreadScrollingReason::kHasClipRelatedProperty) |
| 127 tracedValue->AppendString("Has clip related property"); | 128 tracedValue->AppendString("Has clip related property"); |
| 129 if (reasons & MainThreadScrollingReason::kHasBoxShadowAndLCDText) |
| 130 tracedValue->AppendString("Has box shadow and LCD text"); |
| 128 | 131 |
| 129 // Transient scrolling reasons. | 132 // Transient scrolling reasons. |
| 130 if (reasons & MainThreadScrollingReason::kNonFastScrollableRegion) | 133 if (reasons & MainThreadScrollingReason::kNonFastScrollableRegion) |
| 131 tracedValue->AppendString("Non fast scrollable region"); | 134 tracedValue->AppendString("Non fast scrollable region"); |
| 132 if (reasons & MainThreadScrollingReason::kFailedHitTest) | 135 if (reasons & MainThreadScrollingReason::kFailedHitTest) |
| 133 tracedValue->AppendString("Failed hit test"); | 136 tracedValue->AppendString("Failed hit test"); |
| 134 if (reasons & MainThreadScrollingReason::kNoScrollingLayer) | 137 if (reasons & MainThreadScrollingReason::kNoScrollingLayer) |
| 135 tracedValue->AppendString("No scrolling layer"); | 138 tracedValue->AppendString("No scrolling layer"); |
| 136 if (reasons & MainThreadScrollingReason::kNotScrollable) | 139 if (reasons & MainThreadScrollingReason::kNotScrollable) |
| 137 tracedValue->AppendString("Not scrollable"); | 140 tracedValue->AppendString("Not scrollable"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 155 reason = reason >> 1; | 158 reason = reason >> 1; |
| 156 ++index; | 159 ++index; |
| 157 } | 160 } |
| 158 return index; | 161 return index; |
| 159 } | 162 } |
| 160 }; | 163 }; |
| 161 | 164 |
| 162 } // namespace cc | 165 } // namespace cc |
| 163 | 166 |
| 164 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ | 167 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ |
| OLD | NEW |