• Bo Liu's avatar
    weblayer: Avoid flicker in surface transition · 263aa9b0
    Bo Liu authored
    Do a complicated dance to avoid visual artifacts during transition:
    1) Allocate new SurfaceData, and insert it into view hierarchy
       below the existing SurfaceData, so it is not yet showing.
    2) When Surface is allocated by new View, swap chromium compositor
       to the new Surface. |markForDestroy| is called on the previous
       SurfaceData, and the two SurfaceDatas are linked through these to
       variables. Note at this point the existing view should is still
       visible.
    3) Wait until new SurfaceData decides that it has content is visible
       to be shown.
       * For TextureView, wait until TextureView.invalidate is called
       * For SurfaceView, wait for two swaps from the chromium compositor
    4) New SurfaceData calls |destroy| on previous SurfaceData.
       * For TextureView, it is simply detached immediately from the view
         tree
       * For SurfaceView, to avoid flicker, move it to the back first
         before and wait two frames before detaching.
    5) Previous SurfaceData runs callbacks on the new SurfaceData to signal
       the completion of the transition.
    
    Other related changes:
    * Update CompositorImpl::SetNeedsComposite to force a new frame to be
      produced.
    * Allow java to control caching and releasing the back buffer.
    * To complete the steps above, chain the two SurfaceDatas so new one
      calls destroy on old one, and old one calls runCallbacks on the new
      one.
    * Add TextureViewWithInvalidate to listen to when it is invalidated.
    * Implement moveChildToBackWithoutDetach with calls to bringChildToFront
      since android does not have a moveChildToBack method.
    * Send an artificial surfaceDestroyed signal in destroy to control
      back buffer caching.
    
    Change-Id: Ie43485304c1c08df5ae11cd7756767d29e84e112
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1836605
    Commit-Queue: Bo <boliu@chromium.org>
    Reviewed-by: default avatarScott Violet <sky@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#704494}
    263aa9b0
content_view_render_view.cc 4.48 KB