diff options
author | Dianne Hackborn <hackbod@google.com> | 2013-02-23 03:15:35 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-02-23 03:15:35 +0000 |
commit | bd0dc13cb870e4dc0c3dfbbeba83a9e03ab481e9 (patch) | |
tree | 280c6eb956bc3499b9d027cac432953de815566a /core | |
parent | 460fdd427cf7ee97dfa02f20174b6d941a09c6db (diff) | |
parent | c4aad01cbbb69c916ef323693e1fd0560b0eccba (diff) | |
download | frameworks_base-bd0dc13cb870e4dc0c3dfbbeba83a9e03ab481e9.zip frameworks_base-bd0dc13cb870e4dc0c3dfbbeba83a9e03ab481e9.tar.gz frameworks_base-bd0dc13cb870e4dc0c3dfbbeba83a9e03ab481e9.tar.bz2 |
Merge "Formalize overscan metrics."
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 5 | ||||
-rw-r--r-- | core/java/android/view/IWindow.aidl | 2 | ||||
-rw-r--r-- | core/java/android/view/IWindowSession.aidl | 5 | ||||
-rw-r--r-- | core/java/android/view/SurfaceView.java | 5 | ||||
-rw-r--r-- | core/java/android/view/View.java | 54 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 47 | ||||
-rw-r--r-- | core/java/android/view/WindowManagerPolicy.java | 13 | ||||
-rw-r--r-- | core/java/com/android/internal/os/SomeArgs.java | 2 | ||||
-rw-r--r-- | core/java/com/android/internal/view/BaseIWindow.java | 2 | ||||
-rw-r--r-- | core/java/com/android/internal/widget/ActionBarOverlayLayout.java | 16 |
10 files changed, 115 insertions, 36 deletions
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 9dc77b9..71d8fb6 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -153,6 +153,7 @@ public abstract class WallpaperService extends Service { int mCurWindowPrivateFlags = mWindowPrivateFlags; final Rect mVisibleInsets = new Rect(); final Rect mWinFrame = new Rect(); + final Rect mOverscanInsets = new Rect(); final Rect mContentInsets = new Rect(); final Configuration mConfiguration = new Configuration(); @@ -252,7 +253,7 @@ public abstract class WallpaperService extends Service { final BaseIWindow mWindow = new BaseIWindow() { @Override - public void resized(Rect frame, Rect contentInsets, + public void resized(Rect frame, Rect overscanInsets, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { Message msg = mCaller.obtainMessageI(MSG_WINDOW_RESIZED, reportDraw ? 1 : 0); @@ -627,7 +628,7 @@ public abstract class WallpaperService extends Service { final int relayoutResult = mSession.relayout( mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, - View.VISIBLE, 0, mWinFrame, mContentInsets, + View.VISIBLE, 0, mWinFrame, mOverscanInsets, mContentInsets, mVisibleInsets, mConfiguration, mSurfaceHolder.mSurface); if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl index 15bd46c..8ec07ef 100644 --- a/core/java/android/view/IWindow.aidl +++ b/core/java/android/view/IWindow.aidl @@ -45,7 +45,7 @@ oneway interface IWindow { */ void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor); - void resized(in Rect frame, in Rect contentInsets, + void resized(in Rect frame, in Rect overscanInsets, in Rect contentInsets, in Rect visibleInsets, boolean reportDraw, in Configuration newConfig); void moved(int newX, int newY); void dispatchAppVisibility(boolean visible); diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl index ff9dcce..0a8e609 100644 --- a/core/java/android/view/IWindowSession.aidl +++ b/core/java/android/view/IWindowSession.aidl @@ -63,6 +63,9 @@ interface IWindowSession { * {@link WindowManagerGlobal#RELAYOUT_DEFER_SURFACE_DESTROY}. * @param outFrame Rect in which is placed the new position/size on * screen. + * @param outOverscanInsets Rect in which is placed the offsets from + * <var>outFrame</var> in which the content of the window are inside + * of the display's overlay region. * @param outContentInsets Rect in which is placed the offsets from * <var>outFrame</var> in which the content of the window should be * placed. This can be used to modify the window layout to ensure its @@ -84,7 +87,7 @@ interface IWindowSession { */ int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewVisibility, - int flags, out Rect outFrame, + int flags, out Rect outFrame, out Rect outOverscanInsets, out Rect outContentInsets, out Rect outVisibleInsets, out Configuration outConfig, out Surface outSurface); diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 9008521..5d0f523 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -103,6 +103,7 @@ public class SurfaceView extends View { MyWindow mWindow; final Rect mVisibleInsets = new Rect(); final Rect mWinFrame = new Rect(); + final Rect mOverscanInsets = new Rect(); final Rect mContentInsets = new Rect(); final Configuration mConfiguration = new Configuration(); @@ -507,7 +508,7 @@ public class SurfaceView extends View { mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, visible ? VISIBLE : GONE, WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY, - mWinFrame, mContentInsets, + mWinFrame, mOverscanInsets, mContentInsets, mVisibleInsets, mConfiguration, mNewSurface); if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) { mReportDrawNeeded = true; @@ -642,7 +643,7 @@ public class SurfaceView extends View { } @Override - public void resized(Rect frame, Rect contentInsets, + public void resized(Rect frame, Rect overscanInsets, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { SurfaceView surfaceView = mSurfaceView.get(); if (surfaceView != null) { diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index dcf51e4..ab8f934 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -5679,20 +5679,45 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if ((mViewFlags & FITS_SYSTEM_WINDOWS) == FITS_SYSTEM_WINDOWS) { mUserPaddingStart = UNDEFINED_PADDING; mUserPaddingEnd = UNDEFINED_PADDING; - if ((mViewFlags & OPTIONAL_FITS_SYSTEM_WINDOWS) == 0 - || mAttachInfo == null - || (mAttachInfo.mSystemUiVisibility & SYSTEM_UI_LAYOUT_FLAGS) == 0) { - internalSetPadding(insets.left, insets.top, insets.right, insets.bottom); - return true; - } else { - internalSetPadding(0, 0, 0, 0); - return false; + Rect localInsets = sThreadLocal.get(); + if (localInsets == null) { + localInsets = new Rect(); + sThreadLocal.set(localInsets); } + boolean res = computeFitSystemWindows(insets, localInsets); + internalSetPadding(localInsets.left, localInsets.top, + localInsets.right, localInsets.bottom); + return res; } return false; } /** + * @hide Compute the insets that should be consumed by this view and the ones + * that should propagate to those under it. + */ + protected boolean computeFitSystemWindows(Rect inoutInsets, Rect outLocalInsets) { + if ((mViewFlags & OPTIONAL_FITS_SYSTEM_WINDOWS) == 0 + || mAttachInfo == null + || ((mAttachInfo.mSystemUiVisibility & SYSTEM_UI_LAYOUT_FLAGS) == 0 + && !mAttachInfo.mOverscanRequested)) { + outLocalInsets.set(inoutInsets); + inoutInsets.set(0, 0, 0, 0); + return true; + } else { + // The application wants to take care of fitting system window for + // the content... however we still need to take care of any overscan here. + final Rect overscan = mAttachInfo.mOverscanInsets; + outLocalInsets.set(overscan); + inoutInsets.left -= overscan.left; + inoutInsets.top -= overscan.top; + inoutInsets.right -= overscan.right; + inoutInsets.bottom -= overscan.bottom; + return false; + } + } + + /** * Sets whether or not this view should account for system screen decorations * such as the status bar and inset its content; that is, controlling whether * the default implementation of {@link #fitSystemWindows(Rect)} will be @@ -17919,6 +17944,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * For windows that are full-screen but using insets to layout inside + * of the screen areas, these are the current insets to appear inside + * the overscan area of the display. + */ + final Rect mOverscanInsets = new Rect(); + + /** + * For windows that are full-screen but using insets to layout inside * of the screen decorations, these are the current insets for the * content of the window. */ @@ -18020,6 +18052,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, boolean mHasSystemUiListeners; /** + * Set if the window has requested to extend into the overscan region + * via WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN. + */ + boolean mOverscanRequested; + + /** * Set if the visibility of any views has changed. */ boolean mViewVisibilityChanged; diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 9b6dafb..b8fae86 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -229,6 +229,7 @@ public final class ViewRootImpl implements ViewParent, boolean mIsDrawing; int mLastSystemUiVisibility; int mClientWindowLayoutFlags; + boolean mLastOverscanRequested; /** @hide */ public static final int EVENT_NOT_HANDLED = 0; @@ -262,6 +263,7 @@ public final class ViewRootImpl implements ViewParent, // These are accessed by multiple threads. final Rect mWinFrame; // frame given by window manager. + final Rect mPendingOverscanInsets = new Rect(); final Rect mPendingVisibleInsets = new Rect(); final Rect mPendingContentInsets = new Rect(); final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets @@ -566,6 +568,7 @@ public final class ViewRootImpl implements ViewParent, if (mTranslator != null) { mTranslator.translateRectInScreenToAppWindow(mAttachInfo.mContentInsets); } + mPendingOverscanInsets.set(0, 0, 0, 0); mPendingContentInsets.set(mAttachInfo.mContentInsets); mPendingVisibleInsets.set(0, 0, 0, 0); if (DEBUG_LAYOUT) Log.v(TAG, "Added window " + mWindow); @@ -1255,6 +1258,9 @@ public final class ViewRootImpl implements ViewParent, mAttachInfo.mInTouchMode = !mAddedTouchMode; ensureTouchModeLocally(mAddedTouchMode); } else { + if (!mPendingOverscanInsets.equals(mAttachInfo.mOverscanInsets)) { + insetsChanged = true; + } if (!mPendingContentInsets.equals(mAttachInfo.mContentInsets)) { insetsChanged = true; } @@ -1320,15 +1326,20 @@ public final class ViewRootImpl implements ViewParent, } } - if (params != null && (host.mPrivateFlags & View.PFLAG_REQUEST_TRANSPARENT_REGIONS) != 0) { - if (!PixelFormat.formatHasAlpha(params.format)) { - params.format = PixelFormat.TRANSLUCENT; + if (params != null) { + if ((host.mPrivateFlags & View.PFLAG_REQUEST_TRANSPARENT_REGIONS) != 0) { + if (!PixelFormat.formatHasAlpha(params.format)) { + params.format = PixelFormat.TRANSLUCENT; + } } + mAttachInfo.mOverscanRequested = (params.flags + & WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN) != 0; } if (mFitSystemWindowsRequested) { mFitSystemWindowsRequested = false; mFitSystemWindowsInsets.set(mAttachInfo.mContentInsets); + mLastOverscanRequested = mAttachInfo.mOverscanRequested; host.fitSystemWindows(mFitSystemWindowsInsets); if (mLayoutRequested) { // Short-circuit catching a new layout request here, so @@ -1383,7 +1394,6 @@ public final class ViewRootImpl implements ViewParent, boolean hwInitialized = false; boolean contentInsetsChanged = false; - boolean visibleInsetsChanged; boolean hadSurface = mSurface.isValid(); try { @@ -1396,6 +1406,7 @@ public final class ViewRootImpl implements ViewParent, relayoutResult = relayoutWindow(params, viewVisibility, insetsPending); if (DEBUG_LAYOUT) Log.v(TAG, "relayout: frame=" + frame.toShortString() + + " overscan=" + mPendingOverscanInsets.toShortString() + " content=" + mPendingContentInsets.toShortString() + " visible=" + mPendingVisibleInsets.toShortString() + " surface=" + mSurface); @@ -1407,9 +1418,11 @@ public final class ViewRootImpl implements ViewParent, mPendingConfiguration.seq = 0; } + final boolean overscanInsetsChanged = !mPendingOverscanInsets.equals( + mAttachInfo.mOverscanInsets); contentInsetsChanged = !mPendingContentInsets.equals( mAttachInfo.mContentInsets); - visibleInsetsChanged = !mPendingVisibleInsets.equals( + final boolean visibleInsetsChanged = !mPendingVisibleInsets.equals( mAttachInfo.mVisibleInsets); if (contentInsetsChanged) { if (mWidth > 0 && mHeight > 0 && lp != null && @@ -1486,9 +1499,18 @@ public final class ViewRootImpl implements ViewParent, if (DEBUG_LAYOUT) Log.v(TAG, "Content insets changing to: " + mAttachInfo.mContentInsets); } + if (overscanInsetsChanged) { + mAttachInfo.mOverscanInsets.set(mPendingOverscanInsets); + if (DEBUG_LAYOUT) Log.v(TAG, "Overscan insets changing to: " + + mAttachInfo.mOverscanInsets); + // Need to relayout with content insets. + contentInsetsChanged = true; + } if (contentInsetsChanged || mLastSystemUiVisibility != - mAttachInfo.mSystemUiVisibility || mFitSystemWindowsRequested) { + mAttachInfo.mSystemUiVisibility || mFitSystemWindowsRequested + || mLastOverscanRequested != mAttachInfo.mOverscanRequested) { mLastSystemUiVisibility = mAttachInfo.mSystemUiVisibility; + mLastOverscanRequested = mAttachInfo.mOverscanRequested; mFitSystemWindowsRequested = false; mFitSystemWindowsInsets.set(mAttachInfo.mContentInsets); host.fitSystemWindows(mFitSystemWindowsInsets); @@ -2942,6 +2964,7 @@ public final class ViewRootImpl implements ViewParent, // Recycled in the fall through... SomeArgs args = (SomeArgs) msg.obj; if (mWinFrame.equals(args.arg1) + && mPendingOverscanInsets.equals(args.arg5) && mPendingContentInsets.equals(args.arg2) && mPendingVisibleInsets.equals(args.arg3) && args.arg4 == null) { @@ -2958,6 +2981,7 @@ public final class ViewRootImpl implements ViewParent, } mWinFrame.set((Rect) args.arg1); + mPendingOverscanInsets.set((Rect) args.arg5); mPendingContentInsets.set((Rect) args.arg2); mPendingVisibleInsets.set((Rect) args.arg3); @@ -4031,7 +4055,7 @@ public final class ViewRootImpl implements ViewParent, (int) (mView.getMeasuredWidth() * appScale + 0.5f), (int) (mView.getMeasuredHeight() * appScale + 0.5f), viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, - mWinFrame, mPendingContentInsets, mPendingVisibleInsets, + mWinFrame, mPendingOverscanInsets, mPendingContentInsets, mPendingVisibleInsets, mPendingConfiguration, mSurface); //Log.d(TAG, "<<<<<< BACK FROM relayout"); if (restore) { @@ -4040,6 +4064,7 @@ public final class ViewRootImpl implements ViewParent, if (mTranslator != null) { mTranslator.translateRectInScreenToAppWinFrame(mWinFrame); + mTranslator.translateRectInScreenToAppWindow(mPendingOverscanInsets); mTranslator.translateRectInScreenToAppWindow(mPendingContentInsets); mTranslator.translateRectInScreenToAppWindow(mPendingVisibleInsets); } @@ -4245,7 +4270,7 @@ public final class ViewRootImpl implements ViewParent, mHandler.sendMessage(msg); } - public void dispatchResized(Rect frame, Rect contentInsets, + public void dispatchResized(Rect frame, Rect overscanInsets, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { if (DEBUG_LAYOUT) Log.v(TAG, "Resizing " + this + ": frame=" + frame.toShortString() + " contentInsets=" + contentInsets.toShortString() @@ -4254,6 +4279,7 @@ public final class ViewRootImpl implements ViewParent, Message msg = mHandler.obtainMessage(reportDraw ? MSG_RESIZED_REPORT : MSG_RESIZED); if (mTranslator != null) { mTranslator.translateRectInScreenToAppWindow(frame); + mTranslator.translateRectInScreenToAppWindow(overscanInsets); mTranslator.translateRectInScreenToAppWindow(contentInsets); mTranslator.translateRectInScreenToAppWindow(visibleInsets); } @@ -4263,6 +4289,7 @@ public final class ViewRootImpl implements ViewParent, args.arg2 = sameProcessCall ? new Rect(contentInsets) : contentInsets; args.arg3 = sameProcessCall ? new Rect(visibleInsets) : visibleInsets; args.arg4 = sameProcessCall && newConfig != null ? new Configuration(newConfig) : newConfig; + args.arg5 = sameProcessCall ? new Rect(overscanInsets) : overscanInsets; msg.obj = args; mHandler.sendMessage(msg); } @@ -4997,11 +5024,11 @@ public final class ViewRootImpl implements ViewParent, mWindowSession = viewAncestor.mWindowSession; } - public void resized(Rect frame, Rect contentInsets, + public void resized(Rect frame, Rect overscanInsets, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { final ViewRootImpl viewAncestor = mViewAncestor.get(); if (viewAncestor != null) { - viewAncestor.dispatchResized(frame, contentInsets, + viewAncestor.dispatchResized(frame, overscanInsets, contentInsets, visibleInsets, reportDraw, newConfig); } } diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 60779ce..c0044b6 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -154,6 +154,8 @@ public interface WindowManagerPolicy { * @param displayFrame The frame of the overall display in which this * window can appear, used for constraining the overall dimensions * of the window. + * @param overlayFrame The frame within the display that is inside + * of the overlay region. * @param contentFrame The frame within the display in which we would * like active content to appear. This will cause windows behind to * be resized to match the given content frame. @@ -165,7 +167,7 @@ public interface WindowManagerPolicy { * are visible. */ public void computeFrameLw(Rect parentFrame, Rect displayFrame, - Rect contentFrame, Rect visibleFrame); + Rect overlayFrame, Rect contentFrame, Rect visibleFrame); /** * Retrieve the current frame of the window that has been assigned by @@ -193,6 +195,15 @@ public interface WindowManagerPolicy { public Rect getDisplayFrameLw(); /** + * Retrieve the frame of the area inside the overscan region of the + * display that this window was last laid out in. Must be called with the + * window manager lock held. + * + * @return Rect The rectangle holding the display overscan frame. + */ + public Rect getOverscanFrameLw(); + + /** * Retrieve the frame of the content area that this window was last * laid out in. This is the area in which the content of the window * should be placed. It will be smaller than the display frame to diff --git a/core/java/com/android/internal/os/SomeArgs.java b/core/java/com/android/internal/os/SomeArgs.java index 88e58dc..6fb72f1 100644 --- a/core/java/com/android/internal/os/SomeArgs.java +++ b/core/java/com/android/internal/os/SomeArgs.java @@ -39,6 +39,7 @@ public final class SomeArgs { public Object arg2; public Object arg3; public Object arg4; + public Object arg5; public int argi1; public int argi2; public int argi3; @@ -85,6 +86,7 @@ public final class SomeArgs { arg2 = null; arg3 = null; arg4 = null; + arg5 = null; argi1 = 0; argi2 = 0; argi3 = 0; diff --git a/core/java/com/android/internal/view/BaseIWindow.java b/core/java/com/android/internal/view/BaseIWindow.java index b76e89d..02bd4ac 100644 --- a/core/java/com/android/internal/view/BaseIWindow.java +++ b/core/java/com/android/internal/view/BaseIWindow.java @@ -34,7 +34,7 @@ public class BaseIWindow extends IWindow.Stub { } @Override - public void resized(Rect frame, Rect contentInsets, + public void resized(Rect frame, Rect overscanInsets, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { if (reportDraw) { try { diff --git a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java index a129496..18a696e 100644 --- a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java +++ b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java @@ -41,7 +41,7 @@ public class ActionBarOverlayLayout extends FrameLayout { private ActionBarView mActionView; private View mActionBarBottom; private int mLastSystemUiVisibility; - private final Rect mZeroRect = new Rect(0, 0, 0, 0); + private final Rect mLocalInsets = new Rect(); static final int[] mActionBarSizeAttr = new int [] { com.android.internal.R.attr.actionBarSize @@ -165,13 +165,8 @@ public class ActionBarOverlayLayout extends FrameLayout { // make sure its content is not being covered by system UI... though it // will still be covered by the action bar since they have requested it to // overlay. - if ((vis & SYSTEM_UI_LAYOUT_FLAGS) == 0) { - changed |= applyInsets(mContent, insets, true, true, true, true); - // The insets are now consumed. - insets.set(0, 0, 0, 0); - } else { - changed |= applyInsets(mContent, mZeroRect, true, true, true, true); - } + boolean res = computeFitSystemWindows(insets, mLocalInsets); + changed |= applyInsets(mContent, mLocalInsets, true, true, true, true); if (stable || mActionBarTop.getVisibility() == VISIBLE) { @@ -190,7 +185,7 @@ public class ActionBarOverlayLayout extends FrameLayout { if (mActionView.isSplitActionBar()) { if (stable || (mActionBarBottom != null && mActionBarBottom.getVisibility() == VISIBLE)) { - // If action bar is split, adjust buttom insets for it. + // If action bar is split, adjust bottom insets for it. insets.bottom += mActionBarHeight; } } @@ -199,7 +194,8 @@ public class ActionBarOverlayLayout extends FrameLayout { requestLayout(); } - return super.fitSystemWindows(insets); + super.fitSystemWindows(insets); + return true; } void pullChildren() { |