• danakj@chromium.org's avatar
    cc: Make animations tick regardless of drawing. · 3d9f7431
    danakj@chromium.org authored
    The compositor should tick and finish animations even if it is not
    drawing anything. It can not draw for various reasons:
    1) The tab is backgrounded.
    2) CanDraw() is false for any of its reasons.
    3) PrepareToDraw() fails due to checkerboarding.
    4) There is no damage on the screen to draw.
    
    Currently the problems are:
    - When backgrounded, the animations are ticked but their states are not updated.
    - When CanDraw() is false, we don't draw, and animations just stop ticking.
    - If we stop drawing when we damage the screen, we tick animations, but don't
      update animation state since this happens in DrawLayers().
    
    To solve these problems, I've moved the animation control more explicitly out
    of LayerTreeHostImpl. The proxy already calls Animate(). Now it will also call
    UpdateAnimationState(). It always does this after calling Animate() regardless
    if drawing or not.
    
    Secondly, the missing UpdateAnimationState() call is added to the OnTimerTick
    for background animation ticking.
    
    We enable background ticking only when we change visibility, currently. But
    when CanDraw() is false, we don't draw and thus don't tick animations. So
    instead we add to LayerTreeHostImpl a UpdateBackgroundAnimateTicking() method.
    We call this always after calling Animate() since that can remove animations -
    it's something Animate() used to do. And we also call this:
    a) After a commit - this could add new animations, or change visibility.
    b) After changing CanDraw()'s state.
    
    However, when PrepareToDraw() is false, we do not want to start new animations
    so we let animations finish without starting new ones. This is verified by 
    the LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations test.
    
    This is covered by adding single-thread mode to all the animation unit tests
    (except those that call SetNeedsAnimate() which is not legal in single thread
    mode). Also by new tests:
    LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw.RunSingleThread
    LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw.RunMultiThread
    LayerTreeHostAnimationTestRunAnimationWhenNotVisible.RunSingleThread
    LayerTreeHostAnimationTestRunAnimationWhenNotVisible.RunMultiThread
    LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations.RunMultiThread
    
    Added scheduler tests:
    SchedulerStateMachineTest.ReportIfNotDrawing
    SchedulerStateMachineTest.ReportIfNotDrawingFromAcquiredTextures
    
    R=ajuma@chromium.org
    BUG=222915
    
    Review URL: https://chromiumcodereview.appspot.com/13613003
    
    git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192671 0039d316-1c4b-4281-b951-d872f2087c98
    3d9f7431
layer_animation_controller.h 5.57 KB