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

Unified Diff: cc/input/main_thread_scrolling_reason.h

Issue 2773593005: Move logic of recording main thread scrolling reasons from cc to blink::ScrollManager (Closed)
Patch Set: bug fix Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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..186c09010f6b4144321e89f83b0943f19ca2e4fc 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.
+ 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,18 @@ 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.
+ 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 +149,8 @@ struct MainThreadScrollingReason {
if (reasons & MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer)
tracedValue->AppendString("Has box shadow from non-root layer");
+ DCHECK(!(reasons & MainThreadScrollingReason::kUnknownNonCompositedRegion));
bokan 2017/04/04 18:14:26 Add a comment here as to why we don't have a strin
+
// Transient scrolling reasons.
if (reasons & MainThreadScrollingReason::kNonFastScrollableRegion)
tracedValue->AppendString("Non fast scrollable region");
@@ -148,20 +168,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

Powered by Google App Engine
This is Rietveld 408576698