Loading core/java/android/view/SurfaceView.java +62 −33 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ public class SurfaceView extends View { static final int KEEP_SCREEN_ON_MSG = 1; static final int GET_NEW_SURFACE_MSG = 2; static final int UPDATE_WINDOW_MSG = 3; int mWindowType = WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; Loading @@ -120,6 +121,9 @@ public class SurfaceView extends View { case GET_NEW_SURFACE_MSG: { handleGetNewSurface(); } break; case UPDATE_WINDOW_MSG: { updateWindow(false); } break; } } }; Loading Loading @@ -152,6 +156,9 @@ public class SurfaceView extends View { int mFormat = -1; int mType = -1; final Rect mSurfaceFrame = new Rect(); int mLastSurfaceWidth = -1, mLastSurfaceHeight = -1; boolean mUpdateWindowNeeded; boolean mReportDrawNeeded; private Translator mTranslator; public SurfaceView(Context context) { Loading Loading @@ -369,7 +376,8 @@ public class SurfaceView extends View { || mNewSurfaceNeeded; final boolean typeChanged = mType != mRequestedType; if (force || creating || formatChanged || sizeChanged || visibleChanged || typeChanged || mLeft != mLocation[0] || mTop != mLocation[1]) { || typeChanged || mLeft != mLocation[0] || mTop != mLocation[1] || mUpdateWindowNeeded || mReportDrawNeeded) { if (localLOGV) Log.i(TAG, "Changes: creating=" + creating + " format=" + formatChanged + " size=" + sizeChanged Loading Loading @@ -425,13 +433,23 @@ public class SurfaceView extends View { mNewSurfaceNeeded = false; boolean realSizeChanged; boolean reportDrawNeeded; mSurfaceLock.lock(); try { mUpdateWindowNeeded = false; reportDrawNeeded = mReportDrawNeeded; mReportDrawNeeded = false; mDrawingStopped = !visible; final int relayoutResult = mSession.relayout( mWindow, mLayout, mWidth, mHeight, visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface); if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { mReportDrawNeeded = true; } if (localLOGV) Log.i(TAG, "New surface: " + mSurface + ", vis=" + visible + ", frame=" + mWinFrame); Loading @@ -446,7 +464,16 @@ public class SurfaceView extends View { mSurfaceFrame.right = (int) (mWinFrame.width() * appInvertedScale + 0.5f); mSurfaceFrame.bottom = (int) (mWinFrame.height() * appInvertedScale + 0.5f); } final int surfaceWidth = mSurfaceFrame.right; final int surfaceHeight = mSurfaceFrame.bottom; realSizeChanged = mLastSurfaceWidth != surfaceWidth || mLastSurfaceHeight != surfaceHeight; mLastSurfaceWidth = surfaceWidth; mLastSurfaceHeight = surfaceHeight; } finally { mSurfaceLock.unlock(); } try { if (visible) { Loading @@ -465,9 +492,9 @@ public class SurfaceView extends View { } } if (creating || formatChanged || sizeChanged || visibleChanged) { || visibleChanged || realSizeChanged) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceChanged(mSurfaceHolder, mFormat, mWidth, mHeight); c.surfaceChanged(mSurfaceHolder, mFormat, myWidth, myHeight); } } } else { Loading @@ -475,7 +502,7 @@ public class SurfaceView extends View { } } finally { mIsCreating = false; if (creating || (relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { if (creating || reportDrawNeeded) { mSession.finishDrawing(mWindow); } } Loading Loading @@ -533,17 +560,19 @@ public class SurfaceView extends View { if (localLOGV) Log.v( "SurfaceView", surfaceView + " got resized: w=" + w + " h=" + h + ", cur w=" + mCurWidth + " h=" + mCurHeight); synchronized (this) { if (mCurWidth != w || mCurHeight != h) { mCurWidth = w; mCurHeight = h; } if (reportDraw) { surfaceView.mSurfaceLock.lock(); try { surfaceView.mSession.finishDrawing(surfaceView.mWindow); } catch (RemoteException e) { } if (reportDraw) { surfaceView.mUpdateWindowNeeded = true; surfaceView.mReportDrawNeeded = true; surfaceView.mHandler.sendEmptyMessage(UPDATE_WINDOW_MSG); } else if (surfaceView.mWinFrame.width() != w || surfaceView.mWinFrame.height() != h) { surfaceView.mUpdateWindowNeeded = true; surfaceView.mHandler.sendEmptyMessage(UPDATE_WINDOW_MSG); } } finally { surfaceView.mSurfaceLock.unlock(); } } } Loading Loading
core/java/android/view/SurfaceView.java +62 −33 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ public class SurfaceView extends View { static final int KEEP_SCREEN_ON_MSG = 1; static final int GET_NEW_SURFACE_MSG = 2; static final int UPDATE_WINDOW_MSG = 3; int mWindowType = WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; Loading @@ -120,6 +121,9 @@ public class SurfaceView extends View { case GET_NEW_SURFACE_MSG: { handleGetNewSurface(); } break; case UPDATE_WINDOW_MSG: { updateWindow(false); } break; } } }; Loading Loading @@ -152,6 +156,9 @@ public class SurfaceView extends View { int mFormat = -1; int mType = -1; final Rect mSurfaceFrame = new Rect(); int mLastSurfaceWidth = -1, mLastSurfaceHeight = -1; boolean mUpdateWindowNeeded; boolean mReportDrawNeeded; private Translator mTranslator; public SurfaceView(Context context) { Loading Loading @@ -369,7 +376,8 @@ public class SurfaceView extends View { || mNewSurfaceNeeded; final boolean typeChanged = mType != mRequestedType; if (force || creating || formatChanged || sizeChanged || visibleChanged || typeChanged || mLeft != mLocation[0] || mTop != mLocation[1]) { || typeChanged || mLeft != mLocation[0] || mTop != mLocation[1] || mUpdateWindowNeeded || mReportDrawNeeded) { if (localLOGV) Log.i(TAG, "Changes: creating=" + creating + " format=" + formatChanged + " size=" + sizeChanged Loading Loading @@ -425,13 +433,23 @@ public class SurfaceView extends View { mNewSurfaceNeeded = false; boolean realSizeChanged; boolean reportDrawNeeded; mSurfaceLock.lock(); try { mUpdateWindowNeeded = false; reportDrawNeeded = mReportDrawNeeded; mReportDrawNeeded = false; mDrawingStopped = !visible; final int relayoutResult = mSession.relayout( mWindow, mLayout, mWidth, mHeight, visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface); if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { mReportDrawNeeded = true; } if (localLOGV) Log.i(TAG, "New surface: " + mSurface + ", vis=" + visible + ", frame=" + mWinFrame); Loading @@ -446,7 +464,16 @@ public class SurfaceView extends View { mSurfaceFrame.right = (int) (mWinFrame.width() * appInvertedScale + 0.5f); mSurfaceFrame.bottom = (int) (mWinFrame.height() * appInvertedScale + 0.5f); } final int surfaceWidth = mSurfaceFrame.right; final int surfaceHeight = mSurfaceFrame.bottom; realSizeChanged = mLastSurfaceWidth != surfaceWidth || mLastSurfaceHeight != surfaceHeight; mLastSurfaceWidth = surfaceWidth; mLastSurfaceHeight = surfaceHeight; } finally { mSurfaceLock.unlock(); } try { if (visible) { Loading @@ -465,9 +492,9 @@ public class SurfaceView extends View { } } if (creating || formatChanged || sizeChanged || visibleChanged) { || visibleChanged || realSizeChanged) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceChanged(mSurfaceHolder, mFormat, mWidth, mHeight); c.surfaceChanged(mSurfaceHolder, mFormat, myWidth, myHeight); } } } else { Loading @@ -475,7 +502,7 @@ public class SurfaceView extends View { } } finally { mIsCreating = false; if (creating || (relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { if (creating || reportDrawNeeded) { mSession.finishDrawing(mWindow); } } Loading Loading @@ -533,17 +560,19 @@ public class SurfaceView extends View { if (localLOGV) Log.v( "SurfaceView", surfaceView + " got resized: w=" + w + " h=" + h + ", cur w=" + mCurWidth + " h=" + mCurHeight); synchronized (this) { if (mCurWidth != w || mCurHeight != h) { mCurWidth = w; mCurHeight = h; } if (reportDraw) { surfaceView.mSurfaceLock.lock(); try { surfaceView.mSession.finishDrawing(surfaceView.mWindow); } catch (RemoteException e) { } if (reportDraw) { surfaceView.mUpdateWindowNeeded = true; surfaceView.mReportDrawNeeded = true; surfaceView.mHandler.sendEmptyMessage(UPDATE_WINDOW_MSG); } else if (surfaceView.mWinFrame.width() != w || surfaceView.mWinFrame.height() != h) { surfaceView.mUpdateWindowNeeded = true; surfaceView.mHandler.sendEmptyMessage(UPDATE_WINDOW_MSG); } } finally { surfaceView.mSurfaceLock.unlock(); } } } Loading