Loading core/java/android/view/SurfaceView.java +19 −32 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import static android.view.WindowManagerPolicyConstants.APPLICATION_PANEL_SUBLAY import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.CompatibilityInfo.Translator; import android.content.res.Configuration; import android.graphics.BlendMode; import android.graphics.Canvas; import android.graphics.Color; Loading Loading @@ -102,8 +101,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb private static final boolean DEBUG = false; @UnsupportedAppUsage final ArrayList<SurfaceHolder.Callback> mCallbacks = new ArrayList<SurfaceHolder.Callback>(); final ArrayList<SurfaceHolder.Callback> mCallbacks = new ArrayList<>(); final int[] mLocation = new int[2]; Loading @@ -127,7 +125,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb SurfaceControl mDeferredDestroySurfaceControl; SurfaceControl mBackgroundControl; final Rect mTmpRect = new Rect(); final Configuration mConfiguration = new Configuration(); Paint mRoundedViewportPaint; Loading @@ -137,24 +134,15 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb boolean mIsCreating = false; private volatile boolean mRtHandlingPositionUpdates = false; private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { updateSurface(); } }; private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener = this::updateSurface; @UnsupportedAppUsage private final ViewTreeObserver.OnPreDrawListener mDrawListener = new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { private final ViewTreeObserver.OnPreDrawListener mDrawListener = () -> { // reposition ourselves where the surface is mHaveFrame = getWidth() > 0 && getHeight() > 0; updateSurface(); return true; } }; boolean mRequestedVisible = false; Loading Loading @@ -190,7 +178,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) final Rect mSurfaceFrame = new Rect(); int mLastSurfaceWidth = -1, mLastSurfaceHeight = -1; private Translator mTranslator; private boolean mGlobalListenersAdded; private boolean mAttachedToWindow; Loading Loading @@ -555,9 +542,9 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb return; } mTranslator = viewRoot.mTranslator; if (mTranslator != null) { mSurface.setCompatibilityTranslator(mTranslator); final Translator translator = viewRoot.mTranslator; if (translator != null) { mSurface.setCompatibilityTranslator(translator); } int myWidth = mRequestedWidth; Loading Loading @@ -596,8 +583,8 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb mScreenRect.top = mWindowSpaceTop; mScreenRect.right = mWindowSpaceLeft + getWidth(); mScreenRect.bottom = mWindowSpaceTop + getHeight(); if (mTranslator != null) { mTranslator.translateRectInAppWindowToScreen(mScreenRect); if (translator != null) { translator.translateRectInAppWindowToScreen(mScreenRect); } final Rect surfaceInsets = getParentSurfaceInsets(); Loading Loading @@ -683,11 +670,11 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb mSurfaceFrame.left = 0; mSurfaceFrame.top = 0; if (mTranslator == null) { if (translator == null) { mSurfaceFrame.right = mSurfaceWidth; mSurfaceFrame.bottom = mSurfaceHeight; } else { float appInvertedScale = mTranslator.applicationInvertedScale; float appInvertedScale = translator.applicationInvertedScale; mSurfaceFrame.right = (int) (mSurfaceWidth * appInvertedScale + 0.5f); mSurfaceFrame.bottom = (int) (mSurfaceHeight * appInvertedScale + 0.5f); } Loading Loading @@ -821,8 +808,8 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb mScreenRect.set(mWindowSpaceLeft, mWindowSpaceTop, mWindowSpaceLeft + mLocation[0], mWindowSpaceTop + mLocation[1]); if (mTranslator != null) { mTranslator.translateRectInAppWindowToScreen(mScreenRect); if (translator != null) { translator.translateRectInAppWindowToScreen(mScreenRect); } if (mSurfaceControl == null) { Loading Loading @@ -1037,7 +1024,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb synchronized (mCallbacks) { // This is a linear search, but in practice we'll // have only a couple callbacks, so it doesn't matter. if (mCallbacks.contains(callback) == false) { if (!mCallbacks.contains(callback)) { mCallbacks.add(callback); } } Loading Loading
core/java/android/view/SurfaceView.java +19 −32 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import static android.view.WindowManagerPolicyConstants.APPLICATION_PANEL_SUBLAY import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.CompatibilityInfo.Translator; import android.content.res.Configuration; import android.graphics.BlendMode; import android.graphics.Canvas; import android.graphics.Color; Loading Loading @@ -102,8 +101,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb private static final boolean DEBUG = false; @UnsupportedAppUsage final ArrayList<SurfaceHolder.Callback> mCallbacks = new ArrayList<SurfaceHolder.Callback>(); final ArrayList<SurfaceHolder.Callback> mCallbacks = new ArrayList<>(); final int[] mLocation = new int[2]; Loading @@ -127,7 +125,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb SurfaceControl mDeferredDestroySurfaceControl; SurfaceControl mBackgroundControl; final Rect mTmpRect = new Rect(); final Configuration mConfiguration = new Configuration(); Paint mRoundedViewportPaint; Loading @@ -137,24 +134,15 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb boolean mIsCreating = false; private volatile boolean mRtHandlingPositionUpdates = false; private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { updateSurface(); } }; private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener = this::updateSurface; @UnsupportedAppUsage private final ViewTreeObserver.OnPreDrawListener mDrawListener = new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { private final ViewTreeObserver.OnPreDrawListener mDrawListener = () -> { // reposition ourselves where the surface is mHaveFrame = getWidth() > 0 && getHeight() > 0; updateSurface(); return true; } }; boolean mRequestedVisible = false; Loading Loading @@ -190,7 +178,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) final Rect mSurfaceFrame = new Rect(); int mLastSurfaceWidth = -1, mLastSurfaceHeight = -1; private Translator mTranslator; private boolean mGlobalListenersAdded; private boolean mAttachedToWindow; Loading Loading @@ -555,9 +542,9 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb return; } mTranslator = viewRoot.mTranslator; if (mTranslator != null) { mSurface.setCompatibilityTranslator(mTranslator); final Translator translator = viewRoot.mTranslator; if (translator != null) { mSurface.setCompatibilityTranslator(translator); } int myWidth = mRequestedWidth; Loading Loading @@ -596,8 +583,8 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb mScreenRect.top = mWindowSpaceTop; mScreenRect.right = mWindowSpaceLeft + getWidth(); mScreenRect.bottom = mWindowSpaceTop + getHeight(); if (mTranslator != null) { mTranslator.translateRectInAppWindowToScreen(mScreenRect); if (translator != null) { translator.translateRectInAppWindowToScreen(mScreenRect); } final Rect surfaceInsets = getParentSurfaceInsets(); Loading Loading @@ -683,11 +670,11 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb mSurfaceFrame.left = 0; mSurfaceFrame.top = 0; if (mTranslator == null) { if (translator == null) { mSurfaceFrame.right = mSurfaceWidth; mSurfaceFrame.bottom = mSurfaceHeight; } else { float appInvertedScale = mTranslator.applicationInvertedScale; float appInvertedScale = translator.applicationInvertedScale; mSurfaceFrame.right = (int) (mSurfaceWidth * appInvertedScale + 0.5f); mSurfaceFrame.bottom = (int) (mSurfaceHeight * appInvertedScale + 0.5f); } Loading Loading @@ -821,8 +808,8 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb mScreenRect.set(mWindowSpaceLeft, mWindowSpaceTop, mWindowSpaceLeft + mLocation[0], mWindowSpaceTop + mLocation[1]); if (mTranslator != null) { mTranslator.translateRectInAppWindowToScreen(mScreenRect); if (translator != null) { translator.translateRectInAppWindowToScreen(mScreenRect); } if (mSurfaceControl == null) { Loading Loading @@ -1037,7 +1024,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb synchronized (mCallbacks) { // This is a linear search, but in practice we'll // have only a couple callbacks, so it doesn't matter. if (mCallbacks.contains(callback) == false) { if (!mCallbacks.contains(callback)) { mCallbacks.add(callback); } } Loading