/** * A set of information given to a view when it is attached to its parent * window. */ static class AttachInfo { interface Callbacks { void playSoundEffect(int effectId); boolean performHapticFeedback(int effectId, boolean always); } /** * InvalidateInfo is used to post invalidate(int, int, int, int) messages * to a Handler. This class contains the target (View) to invalidate and * the coordinates of the dirty rectangle. * * For performance purposes, this class also implements a pool of up to * POOL_LIMIT objects that get reused. This reduces memory allocations * whenever possible. */ static class InvalidateInfo implements Poolable<InvalidateInfo> { private static final int POOL_LIMIT = 10; private static final Pool<InvalidateInfo> sPool = Pools.synchronizedPool( Pools.finitePool(new PoolableManager<InvalidateInfo>() { public InvalidateInfo newInstance() { return new InvalidateInfo(); } public void onAcquired(InvalidateInfo element) { } public void onReleased(InvalidateInfo element) { element.target = null; } }, POOL_LIMIT) ); private InvalidateInfo mNext; private boolean mIsPooled; View target; int left; int top; int right; int bottom; public void setNextPoolable(InvalidateInfo element) { mNext = element; } public InvalidateInfo getNextPoolable() { return mNext; } static InvalidateInfo acquire() { return sPool.acquire(); } void release() { sPool.release(this); } public boolean isPooled() { return mIsPooled; } public void setPooled(boolean isPooled) { mIsPooled = isPooled; } } final IWindowSession mSession; final IWindow mWindow; final IBinder mWindowToken; final Callbacks mRootCallbacks; HardwareCanvas mHardwareCanvas; /** * The top view of the hierarchy. */ View mRootView; IBinder mPanelParentWindowToken; Surface mSurface; boolean mHardwareAccelerated; boolean mHardwareAccelerationRequested; HardwareRenderer mHardwareRenderer; /** * Scale factor used by the compatibility mode */ float mApplicationScale; /** * Indicates whether the application is in compatibility mode */ boolean mScalingRequired; /** * If set, ViewAncestor doesn't use its lame animation for when the window resizes. */ boolean mTurnOffWindowResizeAnim; /** * Left position of this view's window */ int mWindowLeft; /** * Top position of this view's window */ int mWindowTop; /** * Indicates whether views need to use 32-bit drawing caches */ boolean mUse32BitDrawingCache; /** * 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. */ final Rect mContentInsets = 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 * actual visible parts of the window. */ final Rect mVisibleInsets = new Rect(); /** * The internal insets given by this window. This value is * supplied by the client (through * {@link ViewTreeObserver.OnComputeInternalInsetsListener}) and will * be given to the window manager when changed to be used in laying * out windows behind it. */ final ViewTreeObserver.InternalInsetsInfo mGivenInternalInsets = new ViewTreeObserver.InternalInsetsInfo(); /** * All views in the window's hierarchy that serve as scroll containers, * used to determine if the window can be resized or must be panned * to adjust for a soft input area. */ final ArrayList<View> mScrollContainers = new ArrayList<View>(); final KeyEvent.DispatcherState mKeyDispatchState = new KeyEvent.DispatcherState(); /** * Indicates whether the view's window currently has the focus. */ boolean mHasWindowFocus; /** * The current visibility of the window. */ int mWindowVisibility; /** * Indicates the time at which drawing started to occur. */ long mDrawingTime; /** * Indicates whether or not ignoring the DIRTY_MASK flags. */ boolean mIgnoreDirtyState; /** * This flag tracks when the mIgnoreDirtyState flag is set during draw(), * to avoid clearing that flag prematurely. */ boolean mSetIgnoreDirtyState = false; /** * Indicates whether the view's window is currently in touch mode. */ boolean mInTouchMode; /** * Indicates that ViewAncestor should trigger a global layout change * the next time it performs a traversal */ boolean mRecomputeGlobalAttributes; /** * Always report new attributes at next traversal. */ boolean mForceReportNewAttributes; /** * Set during a traveral if any views want to keep the screen on. */ boolean mKeepScreenOn; /** * Bitwise-or of all of the values that views have passed to setSystemUiVisibility(). */ int mSystemUiVisibility; /** * True if a view in this hierarchy has an OnSystemUiVisibilityChangeListener * attached. */ boolean mHasSystemUiListeners; /** * Set if the visibility of any views has changed. */ boolean mViewVisibilityChanged; /** * Set to true if a view has been scrolled. */ boolean mViewScrollChanged; /** * Global to the view hierarchy used as a temporary for dealing with * x/y points in the transparent region computations. */ final int[] mTransparentLocation = new int[2]; /** * Global to the view hierarchy used as a temporary for dealing with * x/y points in the ViewGroup.invalidateChild implementation. */ final int[] mInvalidateChildLocation = new int[2]; /** * Global to the view hierarchy used as a temporary for dealing with * x/y location when view is transformed. */ final float[] mTmpTransformLocation = new float[2]; /** * The view tree observer used to dispatch global events like * layout, pre-draw, touch mode change, etc. */ final ViewTreeObserver mTreeObserver = new ViewTreeObserver(); /** * A Canvas used by the view hierarchy to perform bitmap caching. */ Canvas mCanvas; /** * A Handler supplied by a view's {@link android.view.ViewRootImpl}. This * handler can be used to pump events in the UI events queue. */ final Handler mHandler; /** * Identifier for messages requesting the view to be invalidated. * Such messages should be sent to {@link #mHandler}. */ static final int INVALIDATE_MSG = 0x1; /** * Identifier for messages requesting the view to invalidate a region. * Such messages should be sent to {@link #mHandler}. */ static final int INVALIDATE_RECT_MSG = 0x2; /** * Temporary for use in computing invalidate rectangles while * calling up the hierarchy. */ final Rect mTmpInvalRect = new Rect(); /** * Temporary for use in computing hit areas with transformed views */ final RectF mTmpTransformRect = new RectF(); /** * Temporary list for use in collecting focusable descendents of a view. */ final ArrayList<View> mFocusablesTempList = new ArrayList<View>(24); /** * The id of the window for accessibility purposes. */ int mAccessibilityWindowId = View.NO_ID; /** * Creates a new set of attachment information with the specified * events handler and thread. * * @param handler the events handler the view must use */ AttachInfo(IWindowSession session, IWindow window, Handler handler, Callbacks effectPlayer) { mSession = session; mWindow = window; mWindowToken = window.asBinder(); mHandler = handler; mRootCallbacks = effectPlayer; } }