Loading core/java/android/view/View.java +40 −23 Original line number Diff line number Diff line Loading @@ -1623,7 +1623,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * have changed since the matrix was last calculated. This variable * is only valid after a call to getMatrix(). */ boolean mMatrixIsIdentity = true; private boolean mMatrixIsIdentity = true; /** * The degrees rotation around the pivot point. Loading Loading @@ -4855,6 +4855,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * @return The current transform matrix for the view */ public Matrix getMatrix() { hasIdentityMatrix(); return mMatrix; } /** * Recomputes the transform matrix if necessary. * * @return True if the transform matrix is the identity matrix, false otherwise. */ boolean hasIdentityMatrix() { if (mMatrixDirty) { // transform-related properties have changed since the last time someone // asked for the matrix; recalculate it with the current values Loading @@ -4865,7 +4875,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility mMatrixIsIdentity = mMatrix.isIdentity(); mInverseMatrixDirty = true; } return mMatrix; return mMatrixIsIdentity; } /** Loading Loading @@ -5088,7 +5098,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public final void setTop(int top) { if (top != mTop) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5103,7 +5113,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility // Double-invalidation is necessary to capture view's old and new areas invalidate(); } mTop = top; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading @@ -5128,7 +5140,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public final void setBottom(int bottom) { if (bottom != mBottom) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5143,7 +5155,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility // Double-invalidation is necessary to capture view's old and new areas invalidate(); } mBottom = bottom; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading @@ -5168,7 +5182,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public final void setLeft(int left) { if (left != mLeft) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5183,7 +5197,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility // Double-invalidation is necessary to capture view's old and new areas invalidate(); } mLeft = left; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading @@ -5208,7 +5224,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public final void setRight(int right) { if (right != mRight) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5223,7 +5239,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility // Double-invalidation is necessary to capture view's old and new areas invalidate(); } mRight = right; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading Loading @@ -5279,13 +5297,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * @param outRect The hit rectangle of the view. */ public void getHitRect(Rect outRect) { if (mMatrixIsIdentity || mAttachInfo == null) { if (hasIdentityMatrix() || mAttachInfo == null) { outRect.set(mLeft, mTop, mRight, mBottom); } else { Matrix m = getMatrix(); final RectF tmpRect = mAttachInfo.mTmpTransformRect; tmpRect.set(-mPivotX, -mPivotY, getWidth() - mPivotX, getHeight() - mPivotY); tmpRect.set(-mPivotX, -mPivotY, getWidth() - mPivotX, getHeight() - mPivotY); m.mapRect(tmpRect); outRect.set((int) tmpRect.left + mLeft, (int) tmpRect.top + mTop, (int) tmpRect.right + mLeft, (int) tmpRect.bottom + mTop); Loading @@ -5304,7 +5321,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility boolean dispatchTouchEvent(MotionEvent ev, float parentX, float parentY) { float localX = parentX - mLeft; float localY = parentY - mTop; if (!mMatrixIsIdentity && mAttachInfo != null) { if (!hasIdentityMatrix() && mAttachInfo != null) { // non-identity matrix: transform the point into the view's coordinates final float[] localXY = mAttachInfo.mTmpTransformLocation; localXY[0] = localX; Loading @@ -5313,8 +5330,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility localX = localXY[0]; localY = localXY[1]; } if (localX >= 0 && localY >= 0 && localX < (mRight - mLeft) && localY < (mBottom - mTop)) { if (localX >= 0 && localY >= 0 && localX < (mRight - mLeft) && localY < (mBottom - mTop)) { // It would be safer to clone the event here but we don't for performance. // There are many subtle interactions in touch event dispatch; change at your own risk. mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT; Loading @@ -5331,7 +5347,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * is still within the view. */ private boolean pointInView(float localX, float localY, float slop) { if (!mMatrixIsIdentity && mAttachInfo != null) { if (!hasIdentityMatrix() && mAttachInfo != null) { // non-identity matrix: transform the point into the view's coordinates final float[] localXY = mAttachInfo.mTmpTransformLocation; localXY[0] = localX; Loading @@ -5340,11 +5356,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility localX = localXY[0]; localY = localXY[1]; } if (localX > -slop && localY > -slop && localX < ((mRight - mLeft) + slop) && localY < ((mBottom - mTop) + slop)) { return true; } return false; return localX > -slop && localY > -slop && localX < ((mRight - mLeft) + slop) && localY < ((mBottom - mTop) + slop); } /** Loading Loading @@ -5408,7 +5421,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public void offsetTopAndBottom(int offset) { if (offset != 0) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5423,8 +5436,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } else { invalidate(); } mTop += offset; mBottom += offset; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading @@ -5439,7 +5454,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public void offsetLeftAndRight(int offset) { if (offset != 0) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5454,8 +5469,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } else { invalidate(); } mLeft += offset; mRight += offset; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading core/java/android/view/ViewGroup.java +17 −14 Original line number Diff line number Diff line Loading @@ -106,7 +106,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // Target of Motion events private View mMotionTarget; private final Rect mTempRect = new Rect(); // Layout animation private LayoutAnimationController mLayoutAnimationController; Loading Loading @@ -925,7 +924,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // dispatch the event. float xc; float yc; if (mMatrixIsIdentity || mAttachInfo == null) { if (hasIdentityMatrix() || mAttachInfo == null) { xc = scrolledXFloat - (float) target.mLeft; yc = scrolledYFloat - (float) target.mTop; } else { Loading Loading @@ -1513,7 +1512,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } if (a != null) { final boolean initialized = a.isInitialized(); if (!initialized) { a.initialize(cr - cl, cb - ct, getWidth(), getHeight()); Loading Loading @@ -1609,13 +1607,15 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager float alpha = child.getAlpha(); if (transformToApply != null || alpha < 1.0f || !child.mMatrixIsIdentity) { if (transformToApply != null || alpha < 1.0f || !child.hasIdentityMatrix()) { int transX = 0; int transY = 0; if (hasNoCache) { transX = -sx; transY = -sy; } if (transformToApply != null) { if (concatMatrix) { // Undo the scroll translation, apply the transformation matrix, Loading @@ -1625,22 +1625,24 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager canvas.translate(transX, transY); mGroupFlags |= FLAG_CLEAR_TRANSFORMATION; } float transformAlpha = transformToApply.getAlpha(); if (transformAlpha < 1.0f) { alpha *= transformToApply.getAlpha(); mGroupFlags |= FLAG_CLEAR_TRANSFORMATION; } } if (!child.mMatrixIsIdentity) { if (!child.hasIdentityMatrix()) { canvas.translate(-transX, -transY); canvas.concat(child.getMatrix()); canvas.translate(transX, transY); } if (alpha < 1.0f) { mGroupFlags |= FLAG_CLEAR_TRANSFORMATION; } if (alpha < 1.0f && hasNoCache) { if (hasNoCache) { final int multipliedAlpha = (int) (255 * alpha); if (!child.onSetAlpha(multipliedAlpha)) { canvas.saveLayerAlpha(sx, sy, sx + cr - cl, sy + cb - ct, multipliedAlpha, Loading @@ -1649,6 +1651,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager child.mPrivateFlags |= ALPHA_SET; } } } } else if ((child.mPrivateFlags & ALPHA_SET) == ALPHA_SET) { child.onSetAlpha(255); } Loading Loading
core/java/android/view/View.java +40 −23 Original line number Diff line number Diff line Loading @@ -1623,7 +1623,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * have changed since the matrix was last calculated. This variable * is only valid after a call to getMatrix(). */ boolean mMatrixIsIdentity = true; private boolean mMatrixIsIdentity = true; /** * The degrees rotation around the pivot point. Loading Loading @@ -4855,6 +4855,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * @return The current transform matrix for the view */ public Matrix getMatrix() { hasIdentityMatrix(); return mMatrix; } /** * Recomputes the transform matrix if necessary. * * @return True if the transform matrix is the identity matrix, false otherwise. */ boolean hasIdentityMatrix() { if (mMatrixDirty) { // transform-related properties have changed since the last time someone // asked for the matrix; recalculate it with the current values Loading @@ -4865,7 +4875,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility mMatrixIsIdentity = mMatrix.isIdentity(); mInverseMatrixDirty = true; } return mMatrix; return mMatrixIsIdentity; } /** Loading Loading @@ -5088,7 +5098,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public final void setTop(int top) { if (top != mTop) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5103,7 +5113,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility // Double-invalidation is necessary to capture view's old and new areas invalidate(); } mTop = top; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading @@ -5128,7 +5140,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public final void setBottom(int bottom) { if (bottom != mBottom) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5143,7 +5155,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility // Double-invalidation is necessary to capture view's old and new areas invalidate(); } mBottom = bottom; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading @@ -5168,7 +5182,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public final void setLeft(int left) { if (left != mLeft) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5183,7 +5197,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility // Double-invalidation is necessary to capture view's old and new areas invalidate(); } mLeft = left; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading @@ -5208,7 +5224,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public final void setRight(int right) { if (right != mRight) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5223,7 +5239,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility // Double-invalidation is necessary to capture view's old and new areas invalidate(); } mRight = right; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading Loading @@ -5279,13 +5297,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * @param outRect The hit rectangle of the view. */ public void getHitRect(Rect outRect) { if (mMatrixIsIdentity || mAttachInfo == null) { if (hasIdentityMatrix() || mAttachInfo == null) { outRect.set(mLeft, mTop, mRight, mBottom); } else { Matrix m = getMatrix(); final RectF tmpRect = mAttachInfo.mTmpTransformRect; tmpRect.set(-mPivotX, -mPivotY, getWidth() - mPivotX, getHeight() - mPivotY); tmpRect.set(-mPivotX, -mPivotY, getWidth() - mPivotX, getHeight() - mPivotY); m.mapRect(tmpRect); outRect.set((int) tmpRect.left + mLeft, (int) tmpRect.top + mTop, (int) tmpRect.right + mLeft, (int) tmpRect.bottom + mTop); Loading @@ -5304,7 +5321,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility boolean dispatchTouchEvent(MotionEvent ev, float parentX, float parentY) { float localX = parentX - mLeft; float localY = parentY - mTop; if (!mMatrixIsIdentity && mAttachInfo != null) { if (!hasIdentityMatrix() && mAttachInfo != null) { // non-identity matrix: transform the point into the view's coordinates final float[] localXY = mAttachInfo.mTmpTransformLocation; localXY[0] = localX; Loading @@ -5313,8 +5330,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility localX = localXY[0]; localY = localXY[1]; } if (localX >= 0 && localY >= 0 && localX < (mRight - mLeft) && localY < (mBottom - mTop)) { if (localX >= 0 && localY >= 0 && localX < (mRight - mLeft) && localY < (mBottom - mTop)) { // It would be safer to clone the event here but we don't for performance. // There are many subtle interactions in touch event dispatch; change at your own risk. mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT; Loading @@ -5331,7 +5347,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * is still within the view. */ private boolean pointInView(float localX, float localY, float slop) { if (!mMatrixIsIdentity && mAttachInfo != null) { if (!hasIdentityMatrix() && mAttachInfo != null) { // non-identity matrix: transform the point into the view's coordinates final float[] localXY = mAttachInfo.mTmpTransformLocation; localXY[0] = localX; Loading @@ -5340,11 +5356,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility localX = localXY[0]; localY = localXY[1]; } if (localX > -slop && localY > -slop && localX < ((mRight - mLeft) + slop) && localY < ((mBottom - mTop) + slop)) { return true; } return false; return localX > -slop && localY > -slop && localX < ((mRight - mLeft) + slop) && localY < ((mBottom - mTop) + slop); } /** Loading Loading @@ -5408,7 +5421,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public void offsetTopAndBottom(int offset) { if (offset != 0) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5423,8 +5436,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } else { invalidate(); } mTop += offset; mBottom += offset; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading @@ -5439,7 +5454,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ public void offsetLeftAndRight(int offset) { if (offset != 0) { if (mMatrixIsIdentity) { if (hasIdentityMatrix()) { final ViewParent p = mParent; if (p != null && mAttachInfo != null) { final int[] location = mAttachInfo.mInvalidateChildLocation; Loading @@ -5454,8 +5469,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } else { invalidate(); } mLeft += offset; mRight += offset; if (!mMatrixIsIdentity) { mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); Loading
core/java/android/view/ViewGroup.java +17 −14 Original line number Diff line number Diff line Loading @@ -106,7 +106,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // Target of Motion events private View mMotionTarget; private final Rect mTempRect = new Rect(); // Layout animation private LayoutAnimationController mLayoutAnimationController; Loading Loading @@ -925,7 +924,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // dispatch the event. float xc; float yc; if (mMatrixIsIdentity || mAttachInfo == null) { if (hasIdentityMatrix() || mAttachInfo == null) { xc = scrolledXFloat - (float) target.mLeft; yc = scrolledYFloat - (float) target.mTop; } else { Loading Loading @@ -1513,7 +1512,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } if (a != null) { final boolean initialized = a.isInitialized(); if (!initialized) { a.initialize(cr - cl, cb - ct, getWidth(), getHeight()); Loading Loading @@ -1609,13 +1607,15 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager float alpha = child.getAlpha(); if (transformToApply != null || alpha < 1.0f || !child.mMatrixIsIdentity) { if (transformToApply != null || alpha < 1.0f || !child.hasIdentityMatrix()) { int transX = 0; int transY = 0; if (hasNoCache) { transX = -sx; transY = -sy; } if (transformToApply != null) { if (concatMatrix) { // Undo the scroll translation, apply the transformation matrix, Loading @@ -1625,22 +1625,24 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager canvas.translate(transX, transY); mGroupFlags |= FLAG_CLEAR_TRANSFORMATION; } float transformAlpha = transformToApply.getAlpha(); if (transformAlpha < 1.0f) { alpha *= transformToApply.getAlpha(); mGroupFlags |= FLAG_CLEAR_TRANSFORMATION; } } if (!child.mMatrixIsIdentity) { if (!child.hasIdentityMatrix()) { canvas.translate(-transX, -transY); canvas.concat(child.getMatrix()); canvas.translate(transX, transY); } if (alpha < 1.0f) { mGroupFlags |= FLAG_CLEAR_TRANSFORMATION; } if (alpha < 1.0f && hasNoCache) { if (hasNoCache) { final int multipliedAlpha = (int) (255 * alpha); if (!child.onSetAlpha(multipliedAlpha)) { canvas.saveLayerAlpha(sx, sy, sx + cr - cl, sy + cb - ct, multipliedAlpha, Loading @@ -1649,6 +1651,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager child.mPrivateFlags |= ALPHA_SET; } } } } else if ((child.mPrivateFlags & ALPHA_SET) == ALPHA_SET) { child.onSetAlpha(255); } Loading