private void updateWindow(bool force, bool redrawNeeded) { if (!mHaveFrame) { return; } android.view.ViewRootImpl viewRoot = (android.view.ViewRootImpl)getRootView().getParent (); if (viewRoot != null) { mTranslator = viewRoot.mTranslator; } if (mTranslator != null) { mSurface.setCompatibilityTranslator(mTranslator); } int myWidth = mRequestedWidth; if (myWidth <= 0) { myWidth = getWidth(); } int myHeight = mRequestedHeight; if (myHeight <= 0) { myHeight = getHeight(); } getLocationInWindow(mLocation); bool creating = mWindow == null; bool formatChanged = mFormat != mRequestedFormat; bool sizeChanged = mWidth != myWidth || mHeight != myHeight; bool visibleChanged = mVisible != mRequestedVisible || mNewSurfaceNeeded; if (force || creating || formatChanged || sizeChanged || visibleChanged || mLeft != mLocation[0] || mTop != mLocation[1] || mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded) { try { bool visible = mVisible = mRequestedVisible; mLeft = mLocation[0]; mTop = mLocation[1]; mWidth = myWidth; mHeight = myHeight; mFormat = mRequestedFormat; // Scaling/Translate window's layout here because mLayout is not used elsewhere. // Places the window relative mLayout.x = mLeft; mLayout.y = mTop; mLayout.width = getWidth(); mLayout.height = getHeight(); if (mTranslator != null) { mTranslator.translateLayoutParamsInAppWindowToScreen(mLayout); } mLayout.format = mRequestedFormat; mLayout.flags |= android.view.WindowManagerClass.LayoutParams.FLAG_NOT_TOUCHABLE | android.view.WindowManagerClass.LayoutParams.FLAG_NOT_FOCUSABLE | android.view.WindowManagerClass .LayoutParams.FLAG_LAYOUT_NO_LIMITS | android.view.WindowManagerClass.LayoutParams .FLAG_SCALED | android.view.WindowManagerClass.LayoutParams.FLAG_NOT_FOCUSABLE | android.view.WindowManagerClass.LayoutParams.FLAG_NOT_TOUCHABLE; if (!getContext().getResources().getCompatibilityInfo().supportsScreen()) { mLayout.flags |= android.view.WindowManagerClass.LayoutParams.FLAG_COMPATIBLE_WINDOW; } if (mWindow == null) { mWindow = new android.view.SurfaceView.MyWindow(this); mLayout.type = mWindowType; mLayout.gravity = android.view.Gravity.LEFT | android.view.Gravity.TOP; mSession.addWithoutInputChannel(mWindow, mWindow.mSeq, mLayout, mVisible ? VISIBLE : GONE, mContentInsets); } if (visibleChanged && (!visible || mNewSurfaceNeeded)) { reportSurfaceDestroyed(); } mNewSurfaceNeeded = false; bool realSizeChanged; bool reportDrawNeeded; mSurfaceLock.@lock(); try { mUpdateWindowNeeded = false; reportDrawNeeded = mReportDrawNeeded; mReportDrawNeeded = false; mDrawingStopped = !visible; int relayoutResult = mSession.relayout(mWindow, mWindow.mSeq, mLayout, mWidth, mHeight , visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration , mSurface); if ((relayoutResult & android.view.WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { mReportDrawNeeded = true; } mSurfaceFrame.left = 0; mSurfaceFrame.top = 0; if (mTranslator == null) { mSurfaceFrame.right = mWinFrame.width(); mSurfaceFrame.bottom = mWinFrame.height(); } else { float appInvertedScale = mTranslator.applicationInvertedScale; mSurfaceFrame.right = (int)(mWinFrame.width() * appInvertedScale + 0.5f); mSurfaceFrame.bottom = (int)(mWinFrame.height() * appInvertedScale + 0.5f); } int surfaceWidth = mSurfaceFrame.right; int surfaceHeight = mSurfaceFrame.bottom; realSizeChanged = mLastSurfaceWidth != surfaceWidth || mLastSurfaceHeight != surfaceHeight; mLastSurfaceWidth = surfaceWidth; mLastSurfaceHeight = surfaceHeight; } finally { mSurfaceLock.unlock(); } try { redrawNeeded |= creating | reportDrawNeeded; if (visible) { mDestroyReportNeeded = true; android.view.SurfaceHolderClass.Callback[] callbacks; lock (mCallbacks) { callbacks = new android.view.SurfaceHolderClass.Callback[mCallbacks.size()]; mCallbacks.toArray(callbacks); } if (visibleChanged) { mIsCreating = true; foreach (android.view.SurfaceHolderClass.Callback c in callbacks) { c.surfaceCreated(mSurfaceHolder); } } if (creating || formatChanged || sizeChanged || visibleChanged || realSizeChanged) { foreach (android.view.SurfaceHolderClass.Callback c in callbacks) { c.surfaceChanged(mSurfaceHolder, mFormat, myWidth, myHeight); } } if (redrawNeeded) { foreach (android.view.SurfaceHolderClass.Callback c in callbacks) { if (c is android.view.SurfaceHolderClass.Callback2) { ((android.view.SurfaceHolderClass.Callback2)c).surfaceRedrawNeeded(mSurfaceHolder ); } } } } else { mSurface.release(); } } finally { mIsCreating = false; if (redrawNeeded) { mSession.finishDrawing(mWindow); } } } catch (android.os.RemoteException) { } } }
private void updateWindow(bool force, bool redrawNeeded) { if (!mHaveFrame) { return; } android.view.ViewRootImpl viewRoot = (android.view.ViewRootImpl)getRootView().getParent (); if (viewRoot != null) { mTranslator = viewRoot.mTranslator; } if (mTranslator != null) { mSurface.setCompatibilityTranslator(mTranslator); } int myWidth = mRequestedWidth; if (myWidth <= 0) { myWidth = getWidth(); } int myHeight = mRequestedHeight; if (myHeight <= 0) { myHeight = getHeight(); } getLocationInWindow(mLocation); bool creating = mWindow == null; bool formatChanged = mFormat != mRequestedFormat; bool sizeChanged = mWidth != myWidth || mHeight != myHeight; bool visibleChanged = mVisible != mRequestedVisible || mNewSurfaceNeeded; if (force || creating || formatChanged || sizeChanged || visibleChanged || mLeft != mLocation[0] || mTop != mLocation[1] || mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded) { try { bool visible = mVisible = mRequestedVisible; mLeft = mLocation[0]; mTop = mLocation[1]; mWidth = myWidth; mHeight = myHeight; mFormat = mRequestedFormat; // Scaling/Translate window's layout here because mLayout is not used elsewhere. // Places the window relative mLayout.x = mLeft; mLayout.y = mTop; mLayout.width = getWidth(); mLayout.height = getHeight(); if (mTranslator != null) { mTranslator.translateLayoutParamsInAppWindowToScreen(mLayout); } mLayout.format = mRequestedFormat; mLayout.flags |= android.view.WindowManagerClass.LayoutParams.FLAG_NOT_TOUCHABLE | android.view.WindowManagerClass.LayoutParams.FLAG_NOT_FOCUSABLE | android.view.WindowManagerClass .LayoutParams.FLAG_LAYOUT_NO_LIMITS | android.view.WindowManagerClass.LayoutParams .FLAG_SCALED | android.view.WindowManagerClass.LayoutParams.FLAG_NOT_FOCUSABLE | android.view.WindowManagerClass.LayoutParams.FLAG_NOT_TOUCHABLE; if (!getContext().getResources().getCompatibilityInfo().supportsScreen()) { mLayout.flags |= android.view.WindowManagerClass.LayoutParams.FLAG_COMPATIBLE_WINDOW; } if (mWindow == null) { mWindow = new android.view.SurfaceView.MyWindow(this); mLayout.type = mWindowType; mLayout.gravity = android.view.Gravity.LEFT | android.view.Gravity.TOP; mSession.addWithoutInputChannel(mWindow, mWindow.mSeq, mLayout, mVisible ? VISIBLE : GONE, mContentInsets); } if (visibleChanged && (!visible || mNewSurfaceNeeded)) { reportSurfaceDestroyed(); } mNewSurfaceNeeded = false; bool realSizeChanged; bool reportDrawNeeded; mSurfaceLock.@lock(); try { mUpdateWindowNeeded = false; reportDrawNeeded = mReportDrawNeeded; mReportDrawNeeded = false; mDrawingStopped = !visible; int relayoutResult = mSession.relayout(mWindow, mWindow.mSeq, mLayout, mWidth, mHeight , visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration , mSurface); if ((relayoutResult & android.view.WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { mReportDrawNeeded = true; } mSurfaceFrame.left = 0; mSurfaceFrame.top = 0; if (mTranslator == null) { mSurfaceFrame.right = mWinFrame.width(); mSurfaceFrame.bottom = mWinFrame.height(); } else { float appInvertedScale = mTranslator.applicationInvertedScale; mSurfaceFrame.right = (int)(mWinFrame.width() * appInvertedScale + 0.5f); mSurfaceFrame.bottom = (int)(mWinFrame.height() * appInvertedScale + 0.5f); } int surfaceWidth = mSurfaceFrame.right; int surfaceHeight = mSurfaceFrame.bottom; realSizeChanged = mLastSurfaceWidth != surfaceWidth || mLastSurfaceHeight != surfaceHeight; mLastSurfaceWidth = surfaceWidth; mLastSurfaceHeight = surfaceHeight; } finally { mSurfaceLock.unlock(); } try { redrawNeeded |= creating | reportDrawNeeded; if (visible) { mDestroyReportNeeded = true; android.view.SurfaceHolderClass.Callback[] callbacks; lock (mCallbacks) { callbacks = new android.view.SurfaceHolderClass.Callback[mCallbacks.size()]; mCallbacks.toArray(callbacks); } if (visibleChanged) { mIsCreating = true; foreach (android.view.SurfaceHolderClass.Callback c in callbacks) { c.surfaceCreated(mSurfaceHolder); } } if (creating || formatChanged || sizeChanged || visibleChanged || realSizeChanged) { foreach (android.view.SurfaceHolderClass.Callback c in callbacks) { c.surfaceChanged(mSurfaceHolder, mFormat, myWidth, myHeight); } } if (redrawNeeded) { foreach (android.view.SurfaceHolderClass.Callback c in callbacks) { if (c is android.view.SurfaceHolderClass.Callback2) { ((android.view.SurfaceHolderClass.Callback2)c).surfaceRedrawNeeded(mSurfaceHolder ); } } } } else { mSurface.release(); } } finally { mIsCreating = false; if (redrawNeeded) { mSession.finishDrawing(mWindow); } } } catch (android.os.RemoteException) { } } }
internal virtual void setCompatibilityTranslator(android.content.res.CompatibilityInfo .Translator translator) { throw new System.NotImplementedException(); }