Loading core/java/android/service/wallpaper/WallpaperService.java +2 −2 Original line number Diff line number Diff line Loading @@ -608,7 +608,7 @@ public abstract class WallpaperService extends Service { final int relayoutResult = mSession.relayout( mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, View.VISIBLE, false, mWinFrame, mContentInsets, View.VISIBLE, 0, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurfaceHolder.mSurface); if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface Loading Loading @@ -654,7 +654,7 @@ public abstract class WallpaperService extends Service { } redrawNeeded |= creating || (relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0; || (relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0; if (forceReport || creating || surfaceCreating || formatChanged || sizeChanged) { Loading core/java/android/view/IWindowSession.aidl +9 −4 Original line number Diff line number Diff line Loading @@ -54,9 +54,8 @@ interface IWindowSession { * @param requestedWidth The width the window wants to be. * @param requestedHeight The height the window wants to be. * @param viewVisibility Window root view's visibility. * @param insetsPending Set to true if the client will be later giving * internal insets; as a result, the window will not impact other window * layouts until the insets are given. * @param flags Request flags: {@link WindowManagerImpl#RELAYOUT_INSETS_PENDING}, * {@link WindowManagerImpl#RELAYOUT_DEFER_SURFACE_DESTROY}. * @param outFrame Rect in which is placed the new position/size on * screen. * @param outContentInsets Rect in which is placed the offsets from Loading @@ -80,10 +79,16 @@ interface IWindowSession { */ int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewVisibility, boolean insetsPending, out Rect outFrame, out Rect outContentInsets, int flags, out Rect outFrame, out Rect outContentInsets, out Rect outVisibleInsets, out Configuration outConfig, out Surface outSurface); /** * If a call to relayout() asked to have the surface destroy deferred, * it must call this once it is okay to destroy that surface. */ void performDeferredDestroy(IWindow window); /** * Called by a client to report that it ran out of graphics memory. */ Loading core/java/android/view/SurfaceView.java +64 −88 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package android.view; import android.util.DisplayMetrics; import com.android.internal.view.BaseIWindow; import android.content.Context; Loading Loading @@ -82,7 +81,6 @@ import java.util.concurrent.locks.ReentrantLock; public class SurfaceView extends View { static private final String TAG = "SurfaceView"; static private final boolean DEBUG = false; static private final boolean localLOGV = DEBUG ? true : false; final ArrayList<SurfaceHolder.Callback> mCallbacks = new ArrayList<SurfaceHolder.Callback>(); Loading @@ -90,7 +88,8 @@ public class SurfaceView extends View { final int[] mLocation = new int[2]; final ReentrantLock mSurfaceLock = new ReentrantLock(); final Surface mSurface = new Surface(); Surface mSurface = new Surface(); // Current surface in use Surface mNewSurface = new Surface(); // New surface we are switching to boolean mDrawingStopped = true; final WindowManager.LayoutParams mLayout Loading Loading @@ -145,8 +144,7 @@ public class SurfaceView extends View { int mRequestedFormat = PixelFormat.RGB_565; boolean mHaveFrame = false; boolean mDestroyReportNeeded = false; boolean mNewSurfaceNeeded = false; boolean mSurfaceCreated = false; long mLastLockTime = 0; boolean mVisible = false; Loading Loading @@ -236,46 +234,6 @@ public class SurfaceView extends View { updateWindow(false, false); } /** * This method is not intended for general use. It was created * temporarily to improve performance of 3D layers in Launcher * and should be removed and fixed properly. * * Do not call this method. Ever. * * @hide */ protected void showSurface() { if (mSession != null) { updateWindow(true, false); } } /** * This method is not intended for general use. It was created * temporarily to improve performance of 3D layers in Launcher * and should be removed and fixed properly. * * Do not call this method. Ever. * * @hide */ protected void hideSurface() { if (mSession != null && mWindow != null) { mSurfaceLock.lock(); try { DisplayMetrics metrics = getResources().getDisplayMetrics(); mLayout.x = metrics.widthPixels * 3; mSession.relayout(mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, VISIBLE, false, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface); } catch (RemoteException e) { // Ignore } finally { mSurfaceLock.unlock(); } } } @Override protected void onDetachedFromWindow() { if (mGlobalListenersAdded) { Loading Loading @@ -444,14 +402,13 @@ public class SurfaceView extends View { final boolean creating = mWindow == null; final boolean formatChanged = mFormat != mRequestedFormat; final boolean sizeChanged = mWidth != myWidth || mHeight != myHeight; final boolean visibleChanged = mVisible != mRequestedVisible || mNewSurfaceNeeded; final boolean visibleChanged = mVisible != mRequestedVisible; if (force || creating || formatChanged || sizeChanged || visibleChanged || mLeft != mLocation[0] || mTop != mLocation[1] || mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded) { if (localLOGV) Log.i(TAG, "Changes: creating=" + creating if (DEBUG) Log.i(TAG, "Changes: creating=" + creating + " format=" + formatChanged + " size=" + sizeChanged + " visible=" + visibleChanged + " left=" + (mLeft != mLocation[0]) Loading Loading @@ -496,15 +453,11 @@ public class SurfaceView extends View { mVisible ? VISIBLE : GONE, mContentInsets); } if (visibleChanged && (!visible || mNewSurfaceNeeded)) { reportSurfaceDestroyed(); } mNewSurfaceNeeded = false; boolean realSizeChanged; boolean reportDrawNeeded; int relayoutResult; mSurfaceLock.lock(); try { mUpdateWindowNeeded = false; Loading @@ -512,15 +465,19 @@ public class SurfaceView extends View { mReportDrawNeeded = false; mDrawingStopped = !visible; final int relayoutResult = mSession.relayout( if (DEBUG) Log.i(TAG, "Cur surface: " + mSurface); relayoutResult = mSession.relayout( mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface); if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { visible ? VISIBLE : GONE, WindowManagerImpl.RELAYOUT_DEFER_SURFACE_DESTROY, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mNewSurface); if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) { mReportDrawNeeded = true; } if (localLOGV) Log.i(TAG, "New surface: " + mSurface if (DEBUG) Log.i(TAG, "New surface: " + mNewSurface + ", vis=" + visible + ", frame=" + mWinFrame); mSurfaceFrame.left = 0; Loading @@ -547,28 +504,54 @@ public class SurfaceView extends View { try { redrawNeeded |= creating | reportDrawNeeded; if (visible) { mDestroyReportNeeded = true; SurfaceHolder.Callback callbacks[] = null; SurfaceHolder.Callback callbacks[]; synchronized (mCallbacks) { callbacks = new SurfaceHolder.Callback[mCallbacks.size()]; mCallbacks.toArray(callbacks); final boolean surfaceChanged = (relayoutResult&WindowManagerImpl.RELAYOUT_RES_SURFACE_CHANGED) != 0; if (mSurfaceCreated && (surfaceChanged || (!visible && visibleChanged))) { mSurfaceCreated = false; if (mSurface.isValid()) { if (DEBUG) Log.i(TAG, "visibleChanged -- surfaceDestroyed"); callbacks = getSurfaceCallbacks(); for (SurfaceHolder.Callback c : callbacks) { c.surfaceDestroyed(mSurfaceHolder); } } } if (visibleChanged) { Surface tmpSurface = mSurface; mSurface = mNewSurface; mNewSurface = tmpSurface; mNewSurface.release(); if (visible) { if (!mSurfaceCreated && (surfaceChanged || visibleChanged)) { mSurfaceCreated = true; mIsCreating = true; if (DEBUG) Log.i(TAG, "visibleChanged -- surfaceCreated"); if (callbacks == null) { callbacks = getSurfaceCallbacks(); } for (SurfaceHolder.Callback c : callbacks) { c.surfaceCreated(mSurfaceHolder); } } if (creating || formatChanged || sizeChanged || visibleChanged || realSizeChanged) { if (DEBUG) Log.i(TAG, "surfaceChanged -- format=" + mFormat + " w=" + myWidth + " h=" + myHeight); if (callbacks == null) { callbacks = getSurfaceCallbacks(); } for (SurfaceHolder.Callback c : callbacks) { c.surfaceChanged(mSurfaceHolder, mFormat, myWidth, myHeight); } } if (redrawNeeded) { if (DEBUG) Log.i(TAG, "surfaceRedrawNeeded"); if (callbacks == null) { callbacks = getSurfaceCallbacks(); } for (SurfaceHolder.Callback c : callbacks) { if (c instanceof SurfaceHolder.Callback2) { ((SurfaceHolder.Callback2)c).surfaceRedrawNeeded( Loading @@ -576,41 +559,34 @@ public class SurfaceView extends View { } } } } else { mSurface.release(); } } finally { mIsCreating = false; if (redrawNeeded) { if (DEBUG) Log.i(TAG, "finishedDrawing"); mSession.finishDrawing(mWindow); } mSession.performDeferredDestroy(mWindow); } } catch (RemoteException ex) { } if (localLOGV) Log.v( if (DEBUG) Log.v( TAG, "Layout: x=" + mLayout.x + " y=" + mLayout.y + " w=" + mLayout.width + " h=" + mLayout.height + ", frame=" + mSurfaceFrame); } } private void reportSurfaceDestroyed() { if (mDestroyReportNeeded) { mDestroyReportNeeded = false; private SurfaceHolder.Callback[] getSurfaceCallbacks() { SurfaceHolder.Callback callbacks[]; synchronized (mCallbacks) { callbacks = new SurfaceHolder.Callback[mCallbacks.size()]; mCallbacks.toArray(callbacks); } for (SurfaceHolder.Callback c : callbacks) { c.surfaceDestroyed(mSurfaceHolder); } } super.onDetachedFromWindow(); return callbacks; } void handleGetNewSurface() { mNewSurfaceNeeded = true; updateWindow(false, false); } Loading @@ -636,7 +612,7 @@ public class SurfaceView extends View { Rect visibleInsets, boolean reportDraw, Configuration newConfig) { SurfaceView surfaceView = mSurfaceView.get(); if (surfaceView != null) { if (localLOGV) Log.v( if (DEBUG) Log.v( "SurfaceView", surfaceView + " got resized: w=" + w + " h=" + h + ", cur w=" + mCurWidth + " h=" + mCurHeight); surfaceView.mSurfaceLock.lock(); Loading Loading @@ -754,7 +730,7 @@ public class SurfaceView extends View { private final Canvas internalLockCanvas(Rect dirty) { mSurfaceLock.lock(); if (localLOGV) Log.i(TAG, "Locking canvas... stopped=" if (DEBUG) Log.i(TAG, "Locking canvas... stopped=" + mDrawingStopped + ", win=" + mWindow); Canvas c = null; Loading @@ -774,7 +750,7 @@ public class SurfaceView extends View { } } if (localLOGV) Log.i(TAG, "Returned canvas: " + c); if (DEBUG) Log.i(TAG, "Returned canvas: " + c); if (c != null) { mLastLockTime = SystemClock.uptimeMillis(); return c; Loading core/java/android/view/ViewRootImpl.java +6 −6 Original line number Diff line number Diff line Loading @@ -1426,7 +1426,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, if (!mStopped) { boolean focusChangedDueToTouchMode = ensureTouchModeLocally( (relayoutResult&WindowManagerImpl.RELAYOUT_IN_TOUCH_MODE) != 0); (relayoutResult&WindowManagerImpl.RELAYOUT_RES_IN_TOUCH_MODE) != 0); if (focusChangedDueToTouchMode || mWidth != host.getMeasuredWidth() || mHeight != host.getMeasuredHeight() || contentInsetsChanged) { childWidthMeasureSpec = getRootMeasureSpec(mWidth, lp.width); Loading Loading @@ -1637,7 +1637,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, mLastDrawDurationNanos = System.nanoTime() - drawStartTime; } if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0 if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0 || mReportNextDraw) { if (LOCAL_LOGV) { Log.v(TAG, "FINISHED DRAWING: " + mWindowAttributes.getTitle()); Loading Loading @@ -1670,7 +1670,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, } // We were supposed to report when we are done drawing. Since we canceled the // draw, remember it here. if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) { mReportNextDraw = true; } if (fullRedrawNeeded) { Loading Loading @@ -3586,8 +3586,8 @@ public final class ViewRootImpl extends Handler implements ViewParent, mWindow, mSeq, params, (int) (mView.getMeasuredWidth() * appScale + 0.5f), (int) (mView.getMeasuredHeight() * appScale + 0.5f), viewVisibility, insetsPending, mWinFrame, mPendingContentInsets, mPendingVisibleInsets, viewVisibility, insetsPending ? WindowManagerImpl.RELAYOUT_INSETS_PENDING : 0, mWinFrame, mPendingContentInsets, mPendingVisibleInsets, mPendingConfiguration, mSurface); //Log.d(TAG, "<<<<<< BACK FROM relayout"); if (restore) { Loading Loading @@ -3717,7 +3717,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, // animation info. try { if ((relayoutWindow(mWindowAttributes, viewVisibility, false) & WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { & WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) { sWindowSession.finishDrawing(mWindow); } } catch (RemoteException e) { Loading core/java/android/view/WindowManagerImpl.java +23 −4 Original line number Diff line number Diff line Loading @@ -63,15 +63,34 @@ public class WindowManagerImpl implements WindowManager { * The user is navigating with keys (not the touch screen), so * navigational focus should be shown. */ public static final int RELAYOUT_IN_TOUCH_MODE = 0x1; public static final int RELAYOUT_RES_IN_TOUCH_MODE = 0x1; /** * This is the first time the window is being drawn, * so the client must call drawingFinished() when done */ public static final int RELAYOUT_FIRST_TIME = 0x2; public static final int RELAYOUT_RES_FIRST_TIME = 0x2; /** * The window manager has changed the surface from the last call. */ public static final int RELAYOUT_RES_SURFACE_CHANGED = 0x4; /** * Flag for relayout: the client will be later giving * internal insets; as a result, the window will not impact other window * layouts until the insets are given. */ public static final int RELAYOUT_INSETS_PENDING = 0x1; /** * Flag for relayout: the client may be currently using the current surface, * so if it is to be destroyed as a part of the relayout the destroy must * be deferred until later. The client will call performDeferredDestroy() * when it is okay. */ public static final int RELAYOUT_DEFER_SURFACE_DESTROY = 0x2; public static final int ADD_FLAG_APP_VISIBLE = 0x2; public static final int ADD_FLAG_IN_TOUCH_MODE = RELAYOUT_IN_TOUCH_MODE; public static final int ADD_FLAG_IN_TOUCH_MODE = RELAYOUT_RES_IN_TOUCH_MODE; public static final int ADD_OKAY = 0; public static final int ADD_BAD_APP_TOKEN = -1; Loading Loading
core/java/android/service/wallpaper/WallpaperService.java +2 −2 Original line number Diff line number Diff line Loading @@ -608,7 +608,7 @@ public abstract class WallpaperService extends Service { final int relayoutResult = mSession.relayout( mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, View.VISIBLE, false, mWinFrame, mContentInsets, View.VISIBLE, 0, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurfaceHolder.mSurface); if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface Loading Loading @@ -654,7 +654,7 @@ public abstract class WallpaperService extends Service { } redrawNeeded |= creating || (relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0; || (relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0; if (forceReport || creating || surfaceCreating || formatChanged || sizeChanged) { Loading
core/java/android/view/IWindowSession.aidl +9 −4 Original line number Diff line number Diff line Loading @@ -54,9 +54,8 @@ interface IWindowSession { * @param requestedWidth The width the window wants to be. * @param requestedHeight The height the window wants to be. * @param viewVisibility Window root view's visibility. * @param insetsPending Set to true if the client will be later giving * internal insets; as a result, the window will not impact other window * layouts until the insets are given. * @param flags Request flags: {@link WindowManagerImpl#RELAYOUT_INSETS_PENDING}, * {@link WindowManagerImpl#RELAYOUT_DEFER_SURFACE_DESTROY}. * @param outFrame Rect in which is placed the new position/size on * screen. * @param outContentInsets Rect in which is placed the offsets from Loading @@ -80,10 +79,16 @@ interface IWindowSession { */ int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewVisibility, boolean insetsPending, out Rect outFrame, out Rect outContentInsets, int flags, out Rect outFrame, out Rect outContentInsets, out Rect outVisibleInsets, out Configuration outConfig, out Surface outSurface); /** * If a call to relayout() asked to have the surface destroy deferred, * it must call this once it is okay to destroy that surface. */ void performDeferredDestroy(IWindow window); /** * Called by a client to report that it ran out of graphics memory. */ Loading
core/java/android/view/SurfaceView.java +64 −88 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package android.view; import android.util.DisplayMetrics; import com.android.internal.view.BaseIWindow; import android.content.Context; Loading Loading @@ -82,7 +81,6 @@ import java.util.concurrent.locks.ReentrantLock; public class SurfaceView extends View { static private final String TAG = "SurfaceView"; static private final boolean DEBUG = false; static private final boolean localLOGV = DEBUG ? true : false; final ArrayList<SurfaceHolder.Callback> mCallbacks = new ArrayList<SurfaceHolder.Callback>(); Loading @@ -90,7 +88,8 @@ public class SurfaceView extends View { final int[] mLocation = new int[2]; final ReentrantLock mSurfaceLock = new ReentrantLock(); final Surface mSurface = new Surface(); Surface mSurface = new Surface(); // Current surface in use Surface mNewSurface = new Surface(); // New surface we are switching to boolean mDrawingStopped = true; final WindowManager.LayoutParams mLayout Loading Loading @@ -145,8 +144,7 @@ public class SurfaceView extends View { int mRequestedFormat = PixelFormat.RGB_565; boolean mHaveFrame = false; boolean mDestroyReportNeeded = false; boolean mNewSurfaceNeeded = false; boolean mSurfaceCreated = false; long mLastLockTime = 0; boolean mVisible = false; Loading Loading @@ -236,46 +234,6 @@ public class SurfaceView extends View { updateWindow(false, false); } /** * This method is not intended for general use. It was created * temporarily to improve performance of 3D layers in Launcher * and should be removed and fixed properly. * * Do not call this method. Ever. * * @hide */ protected void showSurface() { if (mSession != null) { updateWindow(true, false); } } /** * This method is not intended for general use. It was created * temporarily to improve performance of 3D layers in Launcher * and should be removed and fixed properly. * * Do not call this method. Ever. * * @hide */ protected void hideSurface() { if (mSession != null && mWindow != null) { mSurfaceLock.lock(); try { DisplayMetrics metrics = getResources().getDisplayMetrics(); mLayout.x = metrics.widthPixels * 3; mSession.relayout(mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, VISIBLE, false, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface); } catch (RemoteException e) { // Ignore } finally { mSurfaceLock.unlock(); } } } @Override protected void onDetachedFromWindow() { if (mGlobalListenersAdded) { Loading Loading @@ -444,14 +402,13 @@ public class SurfaceView extends View { final boolean creating = mWindow == null; final boolean formatChanged = mFormat != mRequestedFormat; final boolean sizeChanged = mWidth != myWidth || mHeight != myHeight; final boolean visibleChanged = mVisible != mRequestedVisible || mNewSurfaceNeeded; final boolean visibleChanged = mVisible != mRequestedVisible; if (force || creating || formatChanged || sizeChanged || visibleChanged || mLeft != mLocation[0] || mTop != mLocation[1] || mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded) { if (localLOGV) Log.i(TAG, "Changes: creating=" + creating if (DEBUG) Log.i(TAG, "Changes: creating=" + creating + " format=" + formatChanged + " size=" + sizeChanged + " visible=" + visibleChanged + " left=" + (mLeft != mLocation[0]) Loading Loading @@ -496,15 +453,11 @@ public class SurfaceView extends View { mVisible ? VISIBLE : GONE, mContentInsets); } if (visibleChanged && (!visible || mNewSurfaceNeeded)) { reportSurfaceDestroyed(); } mNewSurfaceNeeded = false; boolean realSizeChanged; boolean reportDrawNeeded; int relayoutResult; mSurfaceLock.lock(); try { mUpdateWindowNeeded = false; Loading @@ -512,15 +465,19 @@ public class SurfaceView extends View { mReportDrawNeeded = false; mDrawingStopped = !visible; final int relayoutResult = mSession.relayout( if (DEBUG) Log.i(TAG, "Cur surface: " + mSurface); relayoutResult = mSession.relayout( mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface); if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { visible ? VISIBLE : GONE, WindowManagerImpl.RELAYOUT_DEFER_SURFACE_DESTROY, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mNewSurface); if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) { mReportDrawNeeded = true; } if (localLOGV) Log.i(TAG, "New surface: " + mSurface if (DEBUG) Log.i(TAG, "New surface: " + mNewSurface + ", vis=" + visible + ", frame=" + mWinFrame); mSurfaceFrame.left = 0; Loading @@ -547,28 +504,54 @@ public class SurfaceView extends View { try { redrawNeeded |= creating | reportDrawNeeded; if (visible) { mDestroyReportNeeded = true; SurfaceHolder.Callback callbacks[] = null; SurfaceHolder.Callback callbacks[]; synchronized (mCallbacks) { callbacks = new SurfaceHolder.Callback[mCallbacks.size()]; mCallbacks.toArray(callbacks); final boolean surfaceChanged = (relayoutResult&WindowManagerImpl.RELAYOUT_RES_SURFACE_CHANGED) != 0; if (mSurfaceCreated && (surfaceChanged || (!visible && visibleChanged))) { mSurfaceCreated = false; if (mSurface.isValid()) { if (DEBUG) Log.i(TAG, "visibleChanged -- surfaceDestroyed"); callbacks = getSurfaceCallbacks(); for (SurfaceHolder.Callback c : callbacks) { c.surfaceDestroyed(mSurfaceHolder); } } } if (visibleChanged) { Surface tmpSurface = mSurface; mSurface = mNewSurface; mNewSurface = tmpSurface; mNewSurface.release(); if (visible) { if (!mSurfaceCreated && (surfaceChanged || visibleChanged)) { mSurfaceCreated = true; mIsCreating = true; if (DEBUG) Log.i(TAG, "visibleChanged -- surfaceCreated"); if (callbacks == null) { callbacks = getSurfaceCallbacks(); } for (SurfaceHolder.Callback c : callbacks) { c.surfaceCreated(mSurfaceHolder); } } if (creating || formatChanged || sizeChanged || visibleChanged || realSizeChanged) { if (DEBUG) Log.i(TAG, "surfaceChanged -- format=" + mFormat + " w=" + myWidth + " h=" + myHeight); if (callbacks == null) { callbacks = getSurfaceCallbacks(); } for (SurfaceHolder.Callback c : callbacks) { c.surfaceChanged(mSurfaceHolder, mFormat, myWidth, myHeight); } } if (redrawNeeded) { if (DEBUG) Log.i(TAG, "surfaceRedrawNeeded"); if (callbacks == null) { callbacks = getSurfaceCallbacks(); } for (SurfaceHolder.Callback c : callbacks) { if (c instanceof SurfaceHolder.Callback2) { ((SurfaceHolder.Callback2)c).surfaceRedrawNeeded( Loading @@ -576,41 +559,34 @@ public class SurfaceView extends View { } } } } else { mSurface.release(); } } finally { mIsCreating = false; if (redrawNeeded) { if (DEBUG) Log.i(TAG, "finishedDrawing"); mSession.finishDrawing(mWindow); } mSession.performDeferredDestroy(mWindow); } } catch (RemoteException ex) { } if (localLOGV) Log.v( if (DEBUG) Log.v( TAG, "Layout: x=" + mLayout.x + " y=" + mLayout.y + " w=" + mLayout.width + " h=" + mLayout.height + ", frame=" + mSurfaceFrame); } } private void reportSurfaceDestroyed() { if (mDestroyReportNeeded) { mDestroyReportNeeded = false; private SurfaceHolder.Callback[] getSurfaceCallbacks() { SurfaceHolder.Callback callbacks[]; synchronized (mCallbacks) { callbacks = new SurfaceHolder.Callback[mCallbacks.size()]; mCallbacks.toArray(callbacks); } for (SurfaceHolder.Callback c : callbacks) { c.surfaceDestroyed(mSurfaceHolder); } } super.onDetachedFromWindow(); return callbacks; } void handleGetNewSurface() { mNewSurfaceNeeded = true; updateWindow(false, false); } Loading @@ -636,7 +612,7 @@ public class SurfaceView extends View { Rect visibleInsets, boolean reportDraw, Configuration newConfig) { SurfaceView surfaceView = mSurfaceView.get(); if (surfaceView != null) { if (localLOGV) Log.v( if (DEBUG) Log.v( "SurfaceView", surfaceView + " got resized: w=" + w + " h=" + h + ", cur w=" + mCurWidth + " h=" + mCurHeight); surfaceView.mSurfaceLock.lock(); Loading Loading @@ -754,7 +730,7 @@ public class SurfaceView extends View { private final Canvas internalLockCanvas(Rect dirty) { mSurfaceLock.lock(); if (localLOGV) Log.i(TAG, "Locking canvas... stopped=" if (DEBUG) Log.i(TAG, "Locking canvas... stopped=" + mDrawingStopped + ", win=" + mWindow); Canvas c = null; Loading @@ -774,7 +750,7 @@ public class SurfaceView extends View { } } if (localLOGV) Log.i(TAG, "Returned canvas: " + c); if (DEBUG) Log.i(TAG, "Returned canvas: " + c); if (c != null) { mLastLockTime = SystemClock.uptimeMillis(); return c; Loading
core/java/android/view/ViewRootImpl.java +6 −6 Original line number Diff line number Diff line Loading @@ -1426,7 +1426,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, if (!mStopped) { boolean focusChangedDueToTouchMode = ensureTouchModeLocally( (relayoutResult&WindowManagerImpl.RELAYOUT_IN_TOUCH_MODE) != 0); (relayoutResult&WindowManagerImpl.RELAYOUT_RES_IN_TOUCH_MODE) != 0); if (focusChangedDueToTouchMode || mWidth != host.getMeasuredWidth() || mHeight != host.getMeasuredHeight() || contentInsetsChanged) { childWidthMeasureSpec = getRootMeasureSpec(mWidth, lp.width); Loading Loading @@ -1637,7 +1637,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, mLastDrawDurationNanos = System.nanoTime() - drawStartTime; } if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0 if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0 || mReportNextDraw) { if (LOCAL_LOGV) { Log.v(TAG, "FINISHED DRAWING: " + mWindowAttributes.getTitle()); Loading Loading @@ -1670,7 +1670,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, } // We were supposed to report when we are done drawing. Since we canceled the // draw, remember it here. if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) { mReportNextDraw = true; } if (fullRedrawNeeded) { Loading Loading @@ -3586,8 +3586,8 @@ public final class ViewRootImpl extends Handler implements ViewParent, mWindow, mSeq, params, (int) (mView.getMeasuredWidth() * appScale + 0.5f), (int) (mView.getMeasuredHeight() * appScale + 0.5f), viewVisibility, insetsPending, mWinFrame, mPendingContentInsets, mPendingVisibleInsets, viewVisibility, insetsPending ? WindowManagerImpl.RELAYOUT_INSETS_PENDING : 0, mWinFrame, mPendingContentInsets, mPendingVisibleInsets, mPendingConfiguration, mSurface); //Log.d(TAG, "<<<<<< BACK FROM relayout"); if (restore) { Loading Loading @@ -3717,7 +3717,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, // animation info. try { if ((relayoutWindow(mWindowAttributes, viewVisibility, false) & WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { & WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) { sWindowSession.finishDrawing(mWindow); } } catch (RemoteException e) { Loading
core/java/android/view/WindowManagerImpl.java +23 −4 Original line number Diff line number Diff line Loading @@ -63,15 +63,34 @@ public class WindowManagerImpl implements WindowManager { * The user is navigating with keys (not the touch screen), so * navigational focus should be shown. */ public static final int RELAYOUT_IN_TOUCH_MODE = 0x1; public static final int RELAYOUT_RES_IN_TOUCH_MODE = 0x1; /** * This is the first time the window is being drawn, * so the client must call drawingFinished() when done */ public static final int RELAYOUT_FIRST_TIME = 0x2; public static final int RELAYOUT_RES_FIRST_TIME = 0x2; /** * The window manager has changed the surface from the last call. */ public static final int RELAYOUT_RES_SURFACE_CHANGED = 0x4; /** * Flag for relayout: the client will be later giving * internal insets; as a result, the window will not impact other window * layouts until the insets are given. */ public static final int RELAYOUT_INSETS_PENDING = 0x1; /** * Flag for relayout: the client may be currently using the current surface, * so if it is to be destroyed as a part of the relayout the destroy must * be deferred until later. The client will call performDeferredDestroy() * when it is okay. */ public static final int RELAYOUT_DEFER_SURFACE_DESTROY = 0x2; public static final int ADD_FLAG_APP_VISIBLE = 0x2; public static final int ADD_FLAG_IN_TOUCH_MODE = RELAYOUT_IN_TOUCH_MODE; public static final int ADD_FLAG_IN_TOUCH_MODE = RELAYOUT_RES_IN_TOUCH_MODE; public static final int ADD_OKAY = 0; public static final int ADD_BAD_APP_TOKEN = -1; Loading