summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/SurfaceView.java39
-rw-r--r--core/java/android/view/ViewRootImpl.java19
-rw-r--r--services/core/java/com/android/server/wm/WindowStateAnimator.java2
3 files changed, 34 insertions, 26 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 9cc6b287431e..1a6689838545 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -96,7 +96,7 @@ import java.util.concurrent.locks.ReentrantLock;
* artifacts may occur on previous versions of the platform when its window is
* positioned asynchronously.</p>
*/
-public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallback {
+public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCallback {
private static final String TAG = "SurfaceView";
private static final boolean DEBUG = false;
private static final boolean DEBUG_POSITION = false;
@@ -227,9 +227,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
mRequestedVisible = mViewVisibility && mWindowVisibility && !mWindowStopped;
}
- /** @hide */
- @Override
- public void windowStopped(boolean stopped) {
+ private void setWindowStopped(boolean stopped) {
mWindowStopped = stopped;
updateRequestedVisibility();
updateSurface();
@@ -239,7 +237,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- getViewRootImpl().addWindowStoppedCallback(this);
+ getViewRootImpl().addSurfaceChangedCallback(this);
mWindowStopped = false;
mViewVisibility = getVisibility() == VISIBLE;
@@ -459,7 +457,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
// the lifecycle. Instead of attaching it to a view, he/she can just pass
// the SurfaceHolder forward, most live wallpapers do it.
if (viewRoot != null) {
- viewRoot.removeWindowStoppedCallback(this);
+ viewRoot.removeSurfaceChangedCallback(this);
}
mAttachedToWindow = false;
@@ -1349,4 +1347,33 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
public SurfaceControl getSurfaceControl() {
return mSurfaceControl;
}
+
+ /**
+ * Set window stopped to false and update surface visibility when ViewRootImpl surface is
+ * created.
+ * @hide
+ */
+ @Override
+ public void surfaceCreated(SurfaceControl.Transaction t) {
+ setWindowStopped(false);
+ }
+
+ /**
+ * Set window stopped to true and update surface visibility when ViewRootImpl surface is
+ * destroyed.
+ * @hide
+ */
+ @Override
+ public void surfaceDestroyed() {
+ setWindowStopped(true);
+ }
+
+ /**
+ * Called when a valid ViewRootImpl surface is replaced by another valid surface.
+ * @hide
+ */
+ @Override
+ public void surfaceReplaced(SurfaceControl.Transaction t) {
+
+ }
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index a4f6aea3f46a..354cc9645635 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1547,19 +1547,6 @@ public final class ViewRootImpl implements ViewParent,
mIsAmbientMode = ambient;
}
- interface WindowStoppedCallback {
- public void windowStopped(boolean stopped);
- }
- private final ArrayList<WindowStoppedCallback> mWindowStoppedCallbacks = new ArrayList<>();
-
- void addWindowStoppedCallback(WindowStoppedCallback c) {
- mWindowStoppedCallbacks.add(c);
- }
-
- void removeWindowStoppedCallback(WindowStoppedCallback c) {
- mWindowStoppedCallbacks.remove(c);
- }
-
void setWindowStopped(boolean stopped) {
checkThread();
if (mStopped != stopped) {
@@ -1576,13 +1563,7 @@ public final class ViewRootImpl implements ViewParent,
if (renderer != null) {
renderer.destroyHardwareResources(mView);
}
- }
-
- for (int i = 0; i < mWindowStoppedCallbacks.size(); i++) {
- mWindowStoppedCallbacks.get(i).windowStopped(stopped);
- }
- if (mStopped) {
if (mSurface.isValid()) {
if (mSurfaceHolder != null) {
notifyHolderSurfaceDestroyed();
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 3ba3280be7bb..d5a736d2800e 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -1299,7 +1299,7 @@ class WindowStateAnimator {
mSurfaceController.mSurfaceControl);
}
- mPostDrawTransaction.apply();
+ SurfaceControl.mergeToGlobalTransaction(mPostDrawTransaction);
return true;
}