Allow SurfaceView's Surface to be preserved on visibility changes
TextureView preserves the resources for its SurfaceTexture between visibility changes, only releasing them when the TextureView has been detached from the window. SurfaceView, in contrast, destroys its underlying Surface when the view is no longer visible. This imposes some challenges in a use-case around scrolling videos. TextureView is somewhat more efficient in managing codec and Surface resources, since an application could set up the codec ahead of time before committing to immediate playback. An application could also more easily reuse resources when scrolling between two of the same video. To resolve this, add a mode to SurfaceView that allows for retaining the Surface when visibility changes. This means that the Surface would only be cleaned up when the SurfaceView is detached from the window, which mirrors TextureView's default lifecycle. Then, scrolling between two videos is easy, since off-screen SurfaceViews can just be hidden in the layout. Bug: 241567563 Test: SurfaceViewTests Test: Hacked build to test on existing apps Change-Id: Ie873d7733445ddf543bba0745bbfdca1b5b8ae1f
Loading
Please register or sign in to comment