diff options
author | Alan Viverette <alanv@google.com> | 2014-08-12 22:14:15 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-12 19:31:43 +0000 |
commit | 99421aed1f57195254b36cf10e23c92219d72270 (patch) | |
tree | 581adec6a384b221f37bdb0c9db0d34be8e5e54c | |
parent | 33fe1ed56d7d7b781046d28d7e1aebe42894623e (diff) | |
parent | f6cf1a02537959c5953553000cb7151c0554a333 (diff) | |
download | frameworks_base-99421aed1f57195254b36cf10e23c92219d72270.zip frameworks_base-99421aed1f57195254b36cf10e23c92219d72270.tar.gz frameworks_base-99421aed1f57195254b36cf10e23c92219d72270.tar.bz2 |
Merge "Invalidate root render node when accessibility focus moves" into lmp-dev
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 4d35509..92e0245 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2458,13 +2458,30 @@ public final class ViewRootImpl implements ViewParent, if (mAttachInfo.mHardwareRenderer != null && mAttachInfo.mHardwareRenderer.isEnabled()) { // Draw with hardware renderer. mIsAnimating = false; + boolean invalidateRoot = false; if (mHardwareYOffset != yOffset || mHardwareXOffset != xOffset) { mHardwareYOffset = yOffset; mHardwareXOffset = xOffset; - mAttachInfo.mHardwareRenderer.invalidateRoot(); + invalidateRoot = true; } mResizeAlpha = resizeAlpha; + if (!invalidateRoot) { + // If accessibility focus moved, invalidate the root. + final Drawable drawable = mAttachInfo.mAccessibilityFocusDrawable; + if (drawable != null) { + final Rect bounds = mAttachInfo.mTmpInvalRect; + if (getAccessibilityFocusedRect(bounds) + && !bounds.equals(drawable.getBounds())) { + invalidateRoot = true; + } + } + } + + if (invalidateRoot) { + mAttachInfo.mHardwareRenderer.invalidateRoot(); + } + dirty.setEmpty(); mBlockResizeBuffer = false; @@ -2619,41 +2636,46 @@ public final class ViewRootImpl implements ViewParent, * @param canvas The canvas on which to draw. */ private void drawAccessibilityFocusedDrawableIfNeeded(Canvas canvas) { + final Rect bounds = mAttachInfo.mTmpInvalRect; + if (getAccessibilityFocusedRect(bounds)) { + final Drawable drawable = getAccessibilityFocusedDrawable(); + if (drawable != null) { + drawable.setBounds(bounds); + drawable.draw(canvas); + } + } + } + + private boolean getAccessibilityFocusedRect(Rect bounds) { final AccessibilityManager manager = AccessibilityManager.getInstance(mView.mContext); if (!manager.isEnabled() || !manager.isTouchExplorationEnabled()) { - return; + return false; } final View host = mAccessibilityFocusedHost; if (host == null || host.mAttachInfo == null) { - return; - } - - final Drawable drawable = getAccessibilityFocusedDrawable(); - if (drawable == null) { - return; + return false; } final AccessibilityNodeProvider provider = host.getAccessibilityNodeProvider(); - final Rect bounds = mAttachInfo.mTmpInvalRect; if (provider == null) { host.getBoundsOnScreen(bounds); } else if (mAccessibilityFocusedVirtualView != null) { mAccessibilityFocusedVirtualView.getBoundsInScreen(bounds); } else { - return; + return false; } - bounds.offset(-mAttachInfo.mWindowLeft, -mAttachInfo.mWindowTop); - bounds.intersect(0, 0, mAttachInfo.mViewRootImpl.mWidth, mAttachInfo.mViewRootImpl.mHeight); - drawable.setBounds(bounds); - drawable.draw(canvas); + final AttachInfo attachInfo = mAttachInfo; + bounds.offset(-attachInfo.mWindowLeft, -attachInfo.mWindowTop); + bounds.intersect(0, 0, attachInfo.mViewRootImpl.mWidth, attachInfo.mViewRootImpl.mHeight); + return true; } private Drawable getAccessibilityFocusedDrawable() { // Lazily load the accessibility focus drawable. if (mAttachInfo.mAccessibilityFocusDrawable == null) { - TypedValue value = new TypedValue(); + final TypedValue value = new TypedValue(); final boolean resolved = mView.mContext.getTheme().resolveAttribute( R.attr.accessibilityFocusedDrawable, value, true); if (resolved) { |