Loading core/java/android/view/View.java +32 −24 Original line number Diff line number Diff line Loading @@ -15933,8 +15933,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return false; } transformMotionEventToGlobal(ev); ev.offsetLocation(info.mWindowLeft, info.mWindowTop); final Matrix m = info.mTmpMatrix; m.set(Matrix.IDENTITY_MATRIX); transformMatrixToGlobal(m); ev.transform(m); return true; } Loading @@ -15952,54 +15954,60 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return false; } ev.offsetLocation(-info.mWindowLeft, -info.mWindowTop); transformMotionEventToLocal(ev); final Matrix m = info.mTmpMatrix; m.set(Matrix.IDENTITY_MATRIX); transformMatrixToLocal(m); ev.transform(m); return true; } /** * Recursive helper method that applies transformations in post-order. * Modifies the input matrix such that it maps view-local coordinates to * on-screen coordinates. * * @param ev the on-screen motion event * @param m input matrix to modify */ private void transformMotionEventToLocal(MotionEvent ev) { void transformMatrixToGlobal(Matrix m) { final ViewParent parent = mParent; if (parent instanceof View) { final View vp = (View) parent; vp.transformMotionEventToLocal(ev); ev.offsetLocation(vp.mScrollX, vp.mScrollY); vp.transformMatrixToGlobal(m); m.postTranslate(-vp.mScrollX, -vp.mScrollY); } else if (parent instanceof ViewRootImpl) { final ViewRootImpl vr = (ViewRootImpl) parent; ev.offsetLocation(0, vr.mCurScrollY); vr.transformMatrixToGlobal(m); m.postTranslate(0, -vr.mCurScrollY); } ev.offsetLocation(-mLeft, -mTop); m.postTranslate(mLeft, mTop); if (!hasIdentityMatrix()) { ev.transform(getInverseMatrix()); m.postConcat(getMatrix()); } } /** * Recursive helper method that applies transformations in pre-order. * Modifies the input matrix such that it maps on-screen coordinates to * view-local coordinates. * * @param ev the on-screen motion event * @param m input matrix to modify */ private void transformMotionEventToGlobal(MotionEvent ev) { if (!hasIdentityMatrix()) { ev.transform(getMatrix()); } ev.offsetLocation(mLeft, mTop); void transformMatrixToLocal(Matrix m) { final ViewParent parent = mParent; if (parent instanceof View) { final View vp = (View) parent; ev.offsetLocation(-vp.mScrollX, -vp.mScrollY); vp.transformMotionEventToGlobal(ev); vp.transformMatrixToLocal(m); m.preTranslate(vp.mScrollX, vp.mScrollY); } else if (parent instanceof ViewRootImpl) { final ViewRootImpl vr = (ViewRootImpl) parent; ev.offsetLocation(0, -vr.mCurScrollY); vr.transformMatrixToLocal(m); m.preTranslate(0, vr.mCurScrollY); } m.preTranslate(-mLeft, -mTop); if (!hasIdentityMatrix()) { m.preConcat(getInverseMatrix()); } } core/java/android/view/ViewRootImpl.java +23 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.Point; Loading Loading @@ -1124,6 +1125,28 @@ public final class ViewRootImpl implements ViewParent, return windowSizeMayChange; } /** * Modifies the input matrix such that it maps view-local coordinates to * on-screen coordinates. * * @param m input matrix to modify */ void transformMatrixToGlobal(Matrix m) { final View.AttachInfo attachInfo = mAttachInfo; m.postTranslate(attachInfo.mWindowLeft, attachInfo.mWindowTop); } /** * Modifies the input matrix such that it maps on-screen coordinates to * view-local coordinates. * * @param m input matrix to modify */ void transformMatrixToLocal(Matrix m) { final View.AttachInfo attachInfo = mAttachInfo; m.preTranslate(-attachInfo.mWindowLeft, -attachInfo.mWindowTop); } private void performTraversals() { // cache mView since it is used so much below... final View host = mView; Loading Loading
core/java/android/view/View.java +32 −24 Original line number Diff line number Diff line Loading @@ -15933,8 +15933,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return false; } transformMotionEventToGlobal(ev); ev.offsetLocation(info.mWindowLeft, info.mWindowTop); final Matrix m = info.mTmpMatrix; m.set(Matrix.IDENTITY_MATRIX); transformMatrixToGlobal(m); ev.transform(m); return true; } Loading @@ -15952,54 +15954,60 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return false; } ev.offsetLocation(-info.mWindowLeft, -info.mWindowTop); transformMotionEventToLocal(ev); final Matrix m = info.mTmpMatrix; m.set(Matrix.IDENTITY_MATRIX); transformMatrixToLocal(m); ev.transform(m); return true; } /** * Recursive helper method that applies transformations in post-order. * Modifies the input matrix such that it maps view-local coordinates to * on-screen coordinates. * * @param ev the on-screen motion event * @param m input matrix to modify */ private void transformMotionEventToLocal(MotionEvent ev) { void transformMatrixToGlobal(Matrix m) { final ViewParent parent = mParent; if (parent instanceof View) { final View vp = (View) parent; vp.transformMotionEventToLocal(ev); ev.offsetLocation(vp.mScrollX, vp.mScrollY); vp.transformMatrixToGlobal(m); m.postTranslate(-vp.mScrollX, -vp.mScrollY); } else if (parent instanceof ViewRootImpl) { final ViewRootImpl vr = (ViewRootImpl) parent; ev.offsetLocation(0, vr.mCurScrollY); vr.transformMatrixToGlobal(m); m.postTranslate(0, -vr.mCurScrollY); } ev.offsetLocation(-mLeft, -mTop); m.postTranslate(mLeft, mTop); if (!hasIdentityMatrix()) { ev.transform(getInverseMatrix()); m.postConcat(getMatrix()); } } /** * Recursive helper method that applies transformations in pre-order. * Modifies the input matrix such that it maps on-screen coordinates to * view-local coordinates. * * @param ev the on-screen motion event * @param m input matrix to modify */ private void transformMotionEventToGlobal(MotionEvent ev) { if (!hasIdentityMatrix()) { ev.transform(getMatrix()); } ev.offsetLocation(mLeft, mTop); void transformMatrixToLocal(Matrix m) { final ViewParent parent = mParent; if (parent instanceof View) { final View vp = (View) parent; ev.offsetLocation(-vp.mScrollX, -vp.mScrollY); vp.transformMotionEventToGlobal(ev); vp.transformMatrixToLocal(m); m.preTranslate(vp.mScrollX, vp.mScrollY); } else if (parent instanceof ViewRootImpl) { final ViewRootImpl vr = (ViewRootImpl) parent; ev.offsetLocation(0, -vr.mCurScrollY); vr.transformMatrixToLocal(m); m.preTranslate(0, vr.mCurScrollY); } m.preTranslate(-mLeft, -mTop); if (!hasIdentityMatrix()) { m.preConcat(getInverseMatrix()); } }
core/java/android/view/ViewRootImpl.java +23 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.Point; Loading Loading @@ -1124,6 +1125,28 @@ public final class ViewRootImpl implements ViewParent, return windowSizeMayChange; } /** * Modifies the input matrix such that it maps view-local coordinates to * on-screen coordinates. * * @param m input matrix to modify */ void transformMatrixToGlobal(Matrix m) { final View.AttachInfo attachInfo = mAttachInfo; m.postTranslate(attachInfo.mWindowLeft, attachInfo.mWindowTop); } /** * Modifies the input matrix such that it maps on-screen coordinates to * view-local coordinates. * * @param m input matrix to modify */ void transformMatrixToLocal(Matrix m) { final View.AttachInfo attachInfo = mAttachInfo; m.preTranslate(-attachInfo.mWindowLeft, -attachInfo.mWindowTop); } private void performTraversals() { // cache mView since it is used so much below... final View host = mView; Loading