summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-05-09 17:08:40 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-05-09 17:08:40 -0700
commit4907d1d5e2c7d244b07579b8c52153df69754e85 (patch)
tree6e670ce463590a36bcbdec8df5a093e6fc3d2f4e /libs
parent45364dc4bfe3e6118ad61f1d38489fe63418699a (diff)
parent0c6cbf410a642f6e9cea7cca0a6e53a4a3cdd324 (diff)
downloadframeworks_base-4907d1d5e2c7d244b07579b8c52153df69754e85.zip
frameworks_base-4907d1d5e2c7d244b07579b8c52153df69754e85.tar.gz
frameworks_base-4907d1d5e2c7d244b07579b8c52153df69754e85.tar.bz2
am 0c6cbf41: Merge "Better compat mode part one: start scaling windows." into honeycomb-mr2
* commit '0c6cbf410a642f6e9cea7cca0a6e53a4a3cdd324': Better compat mode part one: start scaling windows.
Diffstat (limited to 'libs')
-rw-r--r--libs/ui/Input.cpp47
1 files changed, 23 insertions, 24 deletions
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);
}
}