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