Skip to content
  • ccameron's avatar
    Mac: Don't repaint scrollbars every frame · a54da38a
    ccameron authored
    The core issue here is that Blink, when it sees that it needs to
    change the scrollbar in any way (even just moving the thumb), uses the
    signal blink::Scrollbar::setNeedsPaintInvalidation(). This will trigger
    a call to cc::PaintedScrollbarLayer::Update(), which will re-paint all
    controls into textures and then emit quads the quads for the controls.
    
    We often only need to re-arrange the quads for the controls of the
    scrollbar, not re-paint them.
    
    The system that knows whether or not the controls need to be
    repainted is blink::ScrollbarTheme (because that's the code that knows
    the theme that will be used to do the painting).
    
    Add blink::ScrollbarTheme::shouldRepaintAllPartsOnInvalidation() to
    indicate if a call to blink::Scrollbar::setNeedsPaintInvalidation()
    should cause re-painting of all of the controls. If this returns false
    for a given theme, then methods blink::Scrollbar::setNeedsPaintTrack()
    and blink::Scrollbar::setNeedsPaintThumb() may be used to specify more
    granular control.
    
    Back in cc::PaintedScrollbarLayer::Update(), use the methods
    cc::Scrollbar::NeedsPaintPart() to check if re-paint is needed (it is
    hooked up to the bit that is set by the blink::Scrollbar methods).
    
    While we're in the neighborhood, it is worth noting that most of the
    repainting of scrollbars on Mac is due to the alpha of the thumb or the
    track changing. Add methods to blink::Scrollbar to query the opacity
    of the controls, so that we can do the blending at compositing time
    instead of requiring a repaint.
    
    And, while we're in that neighborhood, fix cc::CALayerOverlay's
    FromTextureQuad function to correctly take into account per-vertex
    opacity.
    
    BUG=549277
    TEST=
    - Set the system to only show scrollbars while scrolling
    - Open a page with a vertical scrollbar
    - Scroll to make the scroll thumb appear
    - Hover the mouse somewhere below the thumb
    - The thumb should become thicker and the track should appear
    - After some time, the thumb and the track should fade away
    TEST=
    - Open a page with a scrollbar and search (command-F) for some text
    - Ensure that the ticks on the vertical scrollbar appear
    CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
    
    Review URL: https://codereview.chromium.org/1458703010
    
    Cr-Commit-Position: refs/heads/master@{#361938}
    a54da38a