diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-05-09 17:10:34 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-05-09 17:10:34 -0700 |
commit | d97f6b4ef9676a6ecc3d8a67f364687c885a9eaa (patch) | |
tree | 8512226a79f62883a13c20ce7c20ba4e26fa2e1a | |
parent | ae58e5aec4a80c4ba9102e102803f9916bbfc106 (diff) | |
parent | 79cdb882984959663cc01ac3ccd490843d91617c (diff) | |
download | frameworks_native-d97f6b4ef9676a6ecc3d8a67f364687c885a9eaa.zip frameworks_native-d97f6b4ef9676a6ecc3d8a67f364687c885a9eaa.tar.gz frameworks_native-d97f6b4ef9676a6ecc3d8a67f364687c885a9eaa.tar.bz2 |
am 4907d1d5: am 0c6cbf41: Merge "Better compat mode part one: start scaling windows." into honeycomb-mr2
* commit '4907d1d5e2c7d244b07579b8c52153df69754e85':
Better compat mode part one: start scaling windows.
-rw-r--r-- | include/ui/Input.h | 2 | ||||
-rw-r--r-- | libs/ui/Input.cpp | 47 |
2 files changed, 25 insertions, 24 deletions
diff --git a/include/ui/Input.h b/include/ui/Input.h index d9d77c4..bc5b718 100644 --- a/include/ui/Input.h +++ b/include/ui/Input.h @@ -203,6 +203,8 @@ struct PointerCoords { status_t setAxisValue(int32_t axis, float value); float* editAxisValue(int32_t axis); + void scale(float scale); + #ifdef HAVE_ANDROID_OS status_t readFromParcel(Parcel* parcel); status_t writeToParcel(Parcel* parcel) const; diff --git a/libs/ui/Input.cpp b/libs/ui/Input.cpp index e2e698e..19d590a 100644 --- a/libs/ui/Input.cpp +++ b/libs/ui/Input.cpp @@ -298,6 +298,24 @@ float* PointerCoords::editAxisValue(int32_t axis) { return &values[index]; } +static inline void scaleAxisValue(PointerCoords& c, int axis, float scaleFactor) { + float* value = c.editAxisValue(axis); + if (value) { + *value *= scaleFactor; + } +} + +void PointerCoords::scale(float scaleFactor) { + // No need to scale pressure or size since they are normalized. + // No need to scale orientation since it is meaningless to do so. + scaleAxisValue(*this, AMOTION_EVENT_AXIS_X, scaleFactor); + scaleAxisValue(*this, AMOTION_EVENT_AXIS_Y, scaleFactor); + scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOUCH_MAJOR, scaleFactor); + scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOUCH_MINOR, scaleFactor); + scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOOL_MAJOR, scaleFactor); + scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOOL_MINOR, scaleFactor); +} + #ifdef HAVE_ANDROID_OS status_t PointerCoords::readFromParcel(Parcel* parcel) { bits = parcel->readInt64(); @@ -411,11 +429,9 @@ float MotionEvent::getAxisValue(int32_t axis, size_t pointerIndex) const { float value = getRawPointerCoords(pointerIndex)->getAxisValue(axis); switch (axis) { case AMOTION_EVENT_AXIS_X: - value += mXOffset; - break; + return value + mXOffset; case AMOTION_EVENT_AXIS_Y: - value += mYOffset; - break; + return value + mYOffset; } return value; } @@ -435,11 +451,9 @@ float MotionEvent::getHistoricalAxisValue(int32_t axis, size_t pointerIndex, float value = getHistoricalRawPointerCoords(pointerIndex, historicalIndex)->getAxisValue(axis); switch (axis) { case AMOTION_EVENT_AXIS_X: - value += mXOffset; - break; + return value + mXOffset; case AMOTION_EVENT_AXIS_Y: - value += mYOffset; - break; + return value + mYOffset; } return value; } @@ -449,13 +463,6 @@ void MotionEvent::offsetLocation(float xOffset, float yOffset) { mYOffset += yOffset; } -static inline void scaleAxisValue(PointerCoords& c, int axis, float scaleFactor) { - float* value = c.editAxisValue(axis); - if (value) { - *value *= scaleFactor; - } -} - void MotionEvent::scale(float scaleFactor) { mXOffset *= scaleFactor; mYOffset *= scaleFactor; @@ -464,15 +471,7 @@ void MotionEvent::scale(float scaleFactor) { size_t numSamples = mSamplePointerCoords.size(); for (size_t i = 0; i < numSamples; i++) { - PointerCoords& c = mSamplePointerCoords.editItemAt(i); - // No need to scale pressure or size since they are normalized. - // No need to scale orientation since it is meaningless to do so. - scaleAxisValue(c, AMOTION_EVENT_AXIS_X, scaleFactor); - scaleAxisValue(c, AMOTION_EVENT_AXIS_Y, scaleFactor); - scaleAxisValue(c, AMOTION_EVENT_AXIS_TOUCH_MAJOR, scaleFactor); - scaleAxisValue(c, AMOTION_EVENT_AXIS_TOUCH_MINOR, scaleFactor); - scaleAxisValue(c, AMOTION_EVENT_AXIS_TOOL_MAJOR, scaleFactor); - scaleAxisValue(c, AMOTION_EVENT_AXIS_TOOL_MINOR, scaleFactor); + mSamplePointerCoords.editItemAt(i).scale(scaleFactor); } } |