Chromium Code Reviews| Index: cc/input/main_thread_scrolling_reason.h |
| diff --git a/cc/input/main_thread_scrolling_reason.h b/cc/input/main_thread_scrolling_reason.h |
| index 9746d9425740d96ff63e52707b498f08b4878d80..947a8b6576c15fff434dcdda20085ba8325844b9 100644 |
| --- a/cc/input/main_thread_scrolling_reason.h |
| +++ b/cc/input/main_thread_scrolling_reason.h |
| @@ -37,6 +37,7 @@ struct MainThreadScrollingReason { |
| // These *AndLCDText reasons are due to subpixel text rendering which can |
| // only be applied by blending glyphs with the background at a specific |
| // screen position; transparency and transforms break this. |
| + kNonCompositedReasonsFirst = 16, |
| kHasOpacityAndLCDText = 1 << 16, |
| kHasTransformAndLCDText = 1 << 17, |
| kBackgroundNotOpaqueInRectAndLCDText = 1 << 18, |
| @@ -44,6 +45,14 @@ struct MainThreadScrollingReason { |
| kHasClipRelatedProperty = 1 << 20, |
| kHasBoxShadowFromNonRootLayer = 1 << 21, |
| + // Scrolling a composited element which is on top of a non-composited |
| + // one will end up with main thread scrolling because we are scrolling a non |
| + // fast scrollable region. If all scrollers from the composited element's |
| + // containing block chain are composited, it must be because of an element |
| + // not in the chain in which case the following reason is added. |
|
bokan
2017/04/06 14:25:24
Nit: the reason isn't added, it's reported.
|
| + kUnknownNonCompositedRegion = 1 << 22, |
| + kNonCompositedReasonsLast = 22, |
| + |
| // Transient scrolling reasons. These are computed for each scroll begin. |
| kNonFastScrollableRegion = 1 << 5, |
| kFailedHitTest = 1 << 7, |
| @@ -57,7 +66,7 @@ struct MainThreadScrollingReason { |
| // New flags should increment this number but it should never be decremented |
| // because the values are used in UMA histograms. It should also be noted |
| // that it excludes the kNotScrollingOnMain value. |
| - kMainThreadScrollingReasonCount = 22, |
| + kMainThreadScrollingReasonCount = 23, |
| }; |
| // Returns true if the given MainThreadScrollingReason can be set by the main |
| @@ -67,10 +76,7 @@ struct MainThreadScrollingReason { |
| kNotScrollingOnMain | kHasBackgroundAttachmentFixedObjects | |
| kHasNonLayerViewportConstrainedObjects | kThreadedScrollingDisabled | |
| kScrollbarScrolling | kPageOverlay | kHandlingScrollFromMainThread | |
| - kCustomScrollbarScrolling | kHasOpacityAndLCDText | |
| - kHasTransformAndLCDText | kBackgroundNotOpaqueInRectAndLCDText | |
| - kHasBorderRadius | kHasClipRelatedProperty | |
| - kHasBoxShadowFromNonRootLayer; |
| + kCustomScrollbarScrolling; |
| return (reasons & reasons_set_by_main_thread) == reasons; |
| } |
| @@ -84,6 +90,20 @@ struct MainThreadScrollingReason { |
| return (reasons & reasons_set_by_compositor) == reasons; |
| } |
| + // Usually a scroller won't be composited with the following reasons |
| + // unless we force the promotion. e.g. Apply will-change:transform. |
| + // Returns true if the MainThreadScrollingReason is one of the follow |
| + // reasons that prevented a scroller from being composited. |
| + static bool NonCompositedScrollReasons(uint32_t reasons) { |
| + uint32_t non_composited_reasons = |
| + kHasOpacityAndLCDText | kHasTransformAndLCDText | |
| + kBackgroundNotOpaqueInRectAndLCDText | kHasBorderRadius | |
| + kHasClipRelatedProperty | kHasBoxShadowFromNonRootLayer | |
| + kUnknownNonCompositedRegion; |
| + return reasons && |
| + (non_composited_reasons == (reasons | non_composited_reasons)); |
| + } |
| + |
| static std::string mainThreadScrollingReasonsAsText(uint32_t reasons) { |
| base::trace_event::TracedValue tracedValue; |
| mainThreadScrollingReasonsAsTracedValue(reasons, &tracedValue); |
| @@ -131,6 +151,12 @@ struct MainThreadScrollingReason { |
| if (reasons & MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer) |
| tracedValue->AppendString("Has box shadow from non-root layer"); |
| + // This reason is only used for reporting to UMA that we don't know why |
| + // but we ended up on the main thread because of some non-composited |
| + // scroller. It should never actually be stored/set on a ScrollableArea |
| + // or GraphicsLayer therefore we don't need to trace it. |
| + DCHECK(!(reasons & MainThreadScrollingReason::kUnknownNonCompositedRegion)); |
| + |
| // Transient scrolling reasons. |
| if (reasons & MainThreadScrollingReason::kNonFastScrollableRegion) |
| tracedValue->AppendString("Non fast scrollable region"); |
| @@ -148,20 +174,6 @@ struct MainThreadScrollingReason { |
| tracedValue->AppendString("Page-based scrolling"); |
| tracedValue->EndArray(); |
| } |
| - |
| - // For a given reason, return its index in enum |
| - static int getReasonIndex(uint32_t reason) { |
| - // Multiple reasons provided |
| - if (reason & (reason - 1)) |
| - return -1; |
| - |
| - int index = -1; |
| - while (reason > 0) { |
| - reason = reason >> 1; |
| - ++index; |
| - } |
| - return index; |
| - } |
| }; |
| } // namespace cc |