Merge "Simplify distance calculating method for gesture input." into jb-mr1-dev

main
Ken Wakasa 2012-09-19 00:52:30 -07:00 committed by Android (Google) Code Review
commit 63dd5b4c8f
2 changed files with 6 additions and 15 deletions

View File

@ -64,17 +64,8 @@ static inline float getAngleDiff(float a1, float a2) {
return diff; return diff;
} }
// static float pointToLineSegSquaredDistanceFloat(
// float x, float y, float x1, float y1, float x2, float y2) {
// float A = x - x1;
// float B = y - y1;
// float C = x2 - x1;
// float D = y2 - y1;
// return fabsf(A * D - C * B) / sqrtf(C * C + D * D);
// }
static inline float pointToLineSegSquaredDistanceFloat( static inline float pointToLineSegSquaredDistanceFloat(
float x, float y, float x1, float y1, float x2, float y2) { float x, float y, float x1, float y1, float x2, float y2, bool extend) {
const float ray1x = x - x1; const float ray1x = x - x1;
const float ray1y = y - y1; const float ray1y = y - y1;
const float ray2x = x2 - x1; const float ray2x = x2 - x1;
@ -86,10 +77,10 @@ static inline float pointToLineSegSquaredDistanceFloat(
float projectionX; float projectionX;
float projectionY; float projectionY;
if (projectionLengthSqr < 0.0f) { if (!extend && projectionLengthSqr < 0.0f) {
projectionX = x1; projectionX = x1;
projectionY = y1; projectionY = y1;
} else if (projectionLengthSqr > 1.0f) { } else if (!extend && projectionLengthSqr > 1.0f) {
projectionX = x2; projectionX = x2;
projectionY = y2; projectionY = y2;
} else { } else {

View File

@ -504,7 +504,7 @@ int32_t ProximityInfoState::getAllPossibleChars(
if (index >= mInputXs.size()) { if (index >= mInputXs.size()) {
return filterSize; return filterSize;
} }
int i = filterSize; int newFilterSize = filterSize;
for (int j = 0; j < mProximityInfo->getKeyCount(); ++j) { for (int j = 0; j < mProximityInfo->getKeyCount(); ++j) {
if (mNearKeysVector[index].test(j)) { if (mNearKeysVector[index].test(j)) {
const int32_t keyCodePoint = mProximityInfo->getCodePointOf(j); const int32_t keyCodePoint = mProximityInfo->getCodePointOf(j);
@ -517,11 +517,11 @@ int32_t ProximityInfoState::getAllPossibleChars(
} }
} }
if (insert) { if (insert) {
filter[i++] = keyCodePoint; filter[newFilterSize++] = keyCodePoint;
} }
} }
} }
return i; return newFilterSize;
} }
float ProximityInfoState::getAveragePointDuration() const { float ProximityInfoState::getAveragePointDuration() const {