| 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 kHasBoxShadowFromNonRootLayer = 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 | |
| 72 kHasBoxShadowFromNonRootLayer; |
| 71 return (reasons & reasons_set_by_main_thread) == reasons; | 73 return (reasons & reasons_set_by_main_thread) == reasons; |
| 72 } | 74 } |
| 73 | 75 |
| 74 // Returns true if the given MainThreadScrollingReason can be set by the | 76 // Returns true if the given MainThreadScrollingReason can be set by the |
| 75 // compositor. | 77 // compositor. |
| 76 static bool CompositorCanSetScrollReasons(uint32_t reasons) { | 78 static bool CompositorCanSetScrollReasons(uint32_t reasons) { |
| 77 uint32_t reasons_set_by_compositor = | 79 uint32_t reasons_set_by_compositor = |
| 78 kNonFastScrollableRegion | kFailedHitTest | kNoScrollingLayer | | 80 kNonFastScrollableRegion | kFailedHitTest | kNoScrollingLayer | |
| 79 kNotScrollable | kContinuingMainThreadScroll | kNonInvertibleTransform | | 81 kNotScrollable | kContinuingMainThreadScroll | kNonInvertibleTransform | |
| 80 kPageBasedScrolling; | 82 kPageBasedScrolling; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 tracedValue->AppendString("Has transform and LCD text"); | 120 tracedValue->AppendString("Has transform and LCD text"); |
| 119 if (reasons & | 121 if (reasons & |
| 120 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText) { | 122 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText) { |
| 121 tracedValue->AppendString( | 123 tracedValue->AppendString( |
| 122 "Background is not opaque in rect and LCD text"); | 124 "Background is not opaque in rect and LCD text"); |
| 123 } | 125 } |
| 124 if (reasons & MainThreadScrollingReason::kHasBorderRadius) | 126 if (reasons & MainThreadScrollingReason::kHasBorderRadius) |
| 125 tracedValue->AppendString("Has border radius"); | 127 tracedValue->AppendString("Has border radius"); |
| 126 if (reasons & MainThreadScrollingReason::kHasClipRelatedProperty) | 128 if (reasons & MainThreadScrollingReason::kHasClipRelatedProperty) |
| 127 tracedValue->AppendString("Has clip related property"); | 129 tracedValue->AppendString("Has clip related property"); |
| 130 if (reasons & MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer) |
| 131 tracedValue->AppendString("Has box shadow from non-root layer"); |
| 128 | 132 |
| 129 // Transient scrolling reasons. | 133 // Transient scrolling reasons. |
| 130 if (reasons & MainThreadScrollingReason::kNonFastScrollableRegion) | 134 if (reasons & MainThreadScrollingReason::kNonFastScrollableRegion) |
| 131 tracedValue->AppendString("Non fast scrollable region"); | 135 tracedValue->AppendString("Non fast scrollable region"); |
| 132 if (reasons & MainThreadScrollingReason::kFailedHitTest) | 136 if (reasons & MainThreadScrollingReason::kFailedHitTest) |
| 133 tracedValue->AppendString("Failed hit test"); | 137 tracedValue->AppendString("Failed hit test"); |
| 134 if (reasons & MainThreadScrollingReason::kNoScrollingLayer) | 138 if (reasons & MainThreadScrollingReason::kNoScrollingLayer) |
| 135 tracedValue->AppendString("No scrolling layer"); | 139 tracedValue->AppendString("No scrolling layer"); |
| 136 if (reasons & MainThreadScrollingReason::kNotScrollable) | 140 if (reasons & MainThreadScrollingReason::kNotScrollable) |
| 137 tracedValue->AppendString("Not scrollable"); | 141 tracedValue->AppendString("Not scrollable"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 155 reason = reason >> 1; | 159 reason = reason >> 1; |
| 156 ++index; | 160 ++index; |
| 157 } | 161 } |
| 158 return index; | 162 return index; |
| 159 } | 163 } |
| 160 }; | 164 }; |
| 161 | 165 |
| 162 } // namespace cc | 166 } // namespace cc |
| 163 | 167 |
| 164 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ | 168 #endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_ |
| OLD | NEW |