When Using a video player to play videos, the content area of the video is surfaceView. When there is a surfaceView, the transparent area will be calculated. When the video is played in full screen or non-full screen, the size of the transparent area is different. Comment out the code segment that calculates the size of the transparent area, and found that there was no change in visual effects, whether it was full-screen playback or non-full-screen playback. What is the use of the commented out code segment and when will it take effect?
【Reproduce Rate】100%
【Reproduce Step】 (1)Use the video player to play videos, such as com.qiyi.video, com.tencent.qqlive and other three-party apps. The video playback area is SurfaceView. Operate both full screen and non-full screen to see the visual effect. (2)Comment out the code segment that calculates the transparent area, and then use the Tencent Video app to play the video in both full screen and non-full screen to see the visual effect. (3)There is no visual change in the code segment before and after it is commented. What is the use of the commented code segment, and when will it take effect?
【Android version】Android 13、14
【Device】xiaomi device, and other branch devices
//frameworks/base/core/java/android/view/ViewRootImpl.java
public final class ViewRootImpl implements ViewParent,
View.AttachInfo.Callbacks, ThreadedRenderer.DrawCallbacks,
AttachedSurfaceControl {
private void performTraversals() {
if (didLayout) {
performLayout(lp, mWidth, mHeight);
// By this point all views have been sized and positioned
// We can compute the transparent area
if ((host.mPrivateFlags & View.PFLAG_REQUEST_TRANSPARENT_REGIONS) != 0) {
// start out transparent
// TODO: AVOID THAT CALL BY CACHING THE RESULT?
// beginning of the commented code segment
/*
host.getLocationInWindow(mTmpLocation);
mTransparentRegion.set(mTmpLocation[0], mTmpLocation[1],
mTmpLocation[0] + host.mRight - host.mLeft,
mTmpLocation[1] + host.mBottom - host.mTop);
host.gatherTransparentRegion(mTransparentRegion);
if (mTranslator != null) {
mTranslator.translateRegionInWindowToScreen(mTransparentRegion);
}
if (!mTransparentRegion.equals(mPreviousTransparentRegion)) {
mPreviousTransparentRegion.set(mTransparentRegion);
mFullRedrawNeeded = true;
// TODO: Ideally we would do this in prepareSurfaces,
// but prepareSurfaces is currently working under
// the assumption that we paused the render thread
// via the WM relayout code path. We probably eventually
// want to synchronize transparent region hint changes
// with draws.
SurfaceControl sc = getSurfaceControl();
if (sc.isValid()) {
mTransaction.setTransparentRegionHint(sc, mTransparentRegion).apply();
}
}
*/
// end of the commented code segment
}
if (DBG) {
System.out.println("======================================");
System.out.println("performTraversals -- after setFrame");
host.debug();
}
}
}
}