1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_
#define CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_
#include <stdint.h>
#include <memory>
#include <string>
#include "cc/cc_export.h"
namespace base {
namespace trace_event {
class TracedValue;
}
} // namespace base
namespace cc {
// Ensure this stays in sync with the "MainThreadScrollingReason" enum in:
// tools/metrics/histograms/enums.xml
// When adding a new MainThreadScrollingReason, make sure the corresponding
// kRepaintReasons and kHitTestReasons are also updated.
struct CC_EXPORT MainThreadScrollingReason {
enum : uint32_t {
kNotScrollingOnMain = 0,
// This is used only to report the histogram of main thread scrolling for
// any reason below. It's a histogram bucket index instead of a bit.
kScrollingOnMainForAnyReason = 1,
// This enum simultaneously defines actual bitmask values and indices into
// the bitmask (which are the numbers after "1 << " below, used as the
// histogram bucket indices), but value 0 and 1 are used as the histogram
// bucket indices for kNotScrollingMain and kScrollingOnMainForAnyReason,
// respectively, so the 0th bit and the 1st bit should never be used.
// See also blink::RecordScrollReasonsMetric().
// Main-thread repaint reasons.
// See InputHandler::ScrollStatus::main_thread_repaint_reasons.
// They are set in ScrollNode::main_thread_scrolling_reasons, or
// kNoScrollingLayer is used for a ScrollNode that doesn't have
// main_thread_scrolling_reasons but is_composited is false.
kHasBackgroundAttachmentFixedObjects = 1 << 2,
// 1 << 4 is used by kPopupNoThreadedInput below.
// Subpixel (LCD) text rendering requires blending glyphs with an opaque
// background.
kNotOpaqueForTextAndLCDText = 1 << 5,
kPreferNonCompositedScrolling = 1 << 15,
kBackgroundNeedsRepaintOnScroll = 1 << 16,
// Main-thread hit-test reasons.
// See InputHandler::ScrollStatus::main_thread_hit_test_reasons.
kScrollbarScrolling = 1 << 7,
kMainThreadScrollHitTestRegion = 1 << 8,
kFailedHitTest = 1 << 9,
// 1 << 10 is used by kNoScrollingLayer above.
// The following reasons are neither repaint reasons nor hit-test reasons.
// They don't go through InputHandler::ScrollBegin() or set in
// InputHandler::ScrollStatus.
// We need main thread Scrolling in a popup because it doesn't have a
// threaded input handler. This flag is for metrics only, see
// blink::WebPagePopupImpl::HandleGestureEvent.
kPopupNoThreadedInput = 1 << 4,
// Scrolling can be handled on the compositor thread but it might be
// blocked on the main thread waiting for non-passive event handlers to
// process the wheel/touch events (i.e. were they preventDefaulted?).
kWheelEventHandlerRegion = 1 << 13,
kTouchEventHandlerRegion = 1 << 14,
// 1 << 15 is used by kPreferNonCompositedScrolling above.
// 1 << 16 is used by kBackgroundNeedsRepaintOnScroll above.
// For blink::RecordScrollReasonsMetric() to know the number of used bits.
kMainThreadScrollingReasonLast = 16,
};
static constexpr uint32_t kRepaintReasons =
kHasBackgroundAttachmentFixedObjects | kNotOpaqueForTextAndLCDText |
kPreferNonCompositedScrolling | kBackgroundNeedsRepaintOnScroll;
static constexpr uint32_t kHitTestReasons =
kScrollbarScrolling | kMainThreadScrollHitTestRegion | kFailedHitTest;
static bool AreRepaintReasons(uint32_t reasons) {
return (reasons & ~kRepaintReasons) == 0;
}
static bool AreHitTestReasons(uint32_t reasons) {
return (reasons & ~kHitTestReasons) == 0;
}
static int BucketIndexForTesting(uint32_t reason);
static std::string AsText(uint32_t reasons);
static void AddToTracedValue(uint32_t reasons,
base::trace_event::TracedValue&);
};
} // namespace cc
#endif // CC_INPUT_MAIN_THREAD_SCROLLING_REASON_H_
|