Merge "Calculate isContinuationPossible for typing"

This commit is contained in:
Satoshi Kataoka 2012-12-10 23:24:36 -08:00 committed by Android (Google) Code Review
commit 7ead070db5
3 changed files with 23 additions and 12 deletions

View file

@ -376,6 +376,7 @@ static inline void prof_out(void) {
#define MIN_USER_TYPED_LENGTH_FOR_EXCESSIVE_CHARACTER_SUGGESTION 3 #define MIN_USER_TYPED_LENGTH_FOR_EXCESSIVE_CHARACTER_SUGGESTION 3
// TODO: Remove // TODO: Remove
#define MAX_POINTER_COUNT 1
#define MAX_POINTER_COUNT_FOR_G 2 #define MAX_POINTER_COUNT_FOR_G 2
// Size, in bytes, of the bloom filter index for bigrams // Size, in bytes, of the bloom filter index for bigrams

View file

@ -39,12 +39,8 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
const ProximityInfo *proximityInfo, const int *const inputCodes, const int inputSize, const ProximityInfo *proximityInfo, const int *const inputCodes, const int inputSize,
const int *const xCoordinates, const int *const yCoordinates, const int *const times, const int *const xCoordinates, const int *const yCoordinates, const int *const times,
const int *const pointerIds, const bool isGeometric) { const int *const pointerIds, const bool isGeometric) {
if (isGeometric) {
mIsContinuationPossible = checkAndReturnIsContinuationPossible( mIsContinuationPossible = checkAndReturnIsContinuationPossible(
inputSize, xCoordinates, yCoordinates, times); inputSize, xCoordinates, yCoordinates, times, isGeometric);
} else {
mIsContinuationPossible = false;
}
mProximityInfo = proximityInfo; mProximityInfo = proximityInfo;
mHasTouchPositionCorrectionData = proximityInfo->hasTouchPositionCorrectionData(); mHasTouchPositionCorrectionData = proximityInfo->hasTouchPositionCorrectionData();
@ -466,7 +462,9 @@ float ProximityInfoState::calculateBeelineSpeedRate(
} }
bool ProximityInfoState::checkAndReturnIsContinuationPossible(const int inputSize, bool ProximityInfoState::checkAndReturnIsContinuationPossible(const int inputSize,
const int *const xCoordinates, const int *const yCoordinates, const int *const times) { const int *const xCoordinates, const int *const yCoordinates, const int *const times,
const bool isGeometric) const {
if (isGeometric) {
for (int i = 0; i < mSampledInputSize; ++i) { for (int i = 0; i < mSampledInputSize; ++i) {
const int index = mInputIndice[i]; const int index = mInputIndice[i];
if (index > inputSize || xCoordinates[index] != mSampledInputXs[i] || if (index > inputSize || xCoordinates[index] != mSampledInputXs[i] ||
@ -474,6 +472,18 @@ bool ProximityInfoState::checkAndReturnIsContinuationPossible(const int inputSiz
return false; return false;
} }
} }
} else {
if (inputSize < mSampledInputSize) {
// Assuming the cache is invalid if the previous input size is larger than the new one.
return false;
}
for (int i = 0; i < mSampledInputSize && i < MAX_WORD_LENGTH_INTERNAL; ++i) {
if (xCoordinates[i] != mSampledInputXs[i]
|| yCoordinates[i] != mSampledInputYs[i]) {
return false;
}
}
}
return true; return true;
} }

View file

@ -242,7 +242,7 @@ class ProximityInfoState {
const NearKeysDistanceMap *const prevNearKeysDistances, const NearKeysDistanceMap *const prevNearKeysDistances,
const NearKeysDistanceMap *const prevPrevNearKeysDistances) const; const NearKeysDistanceMap *const prevPrevNearKeysDistances) const;
bool checkAndReturnIsContinuationPossible(const int inputSize, const int *const xCoordinates, bool checkAndReturnIsContinuationPossible(const int inputSize, const int *const xCoordinates,
const int *const yCoordinates, const int *const times); const int *const yCoordinates, const int *const times, const bool isGeometric) const;
void popInputData(); void popInputData();
void updateAlignPointProbabilities(const int start); void updateAlignPointProbabilities(const int start);
bool suppressCharProbabilities(const int index1, const int index2); bool suppressCharProbabilities(const int index1, const int index2);