From 6c22439bf80da08576e86c1282afc5cfa431e235 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Tue, 22 Jan 2013 13:14:53 +0900 Subject: [PATCH] Remove MAX_PROXIMITY_CHARS_SIZE_INTERNAL Change-Id: I18a997503de4033b5341b564145bca862a872098 --- .../inputmethod/keyboard/ProximityInfo.java | 23 +++++++++++-------- .../inputmethod/latin/BinaryDictionary.java | 4 ++-- .../android/inputmethod/latin/Constants.java | 2 +- ...oid_inputmethod_keyboard_ProximityInfo.cpp | 12 +++++----- native/jni/src/defines.h | 16 +++++-------- native/jni/src/proximity_info.cpp | 20 ++++++++++------ native/jni/src/proximity_info.h | 3 +-- native/jni/src/proximity_info_state.cpp | 12 +++++----- native/jni/src/proximity_info_state.h | 15 ++++-------- native/jni/src/proximity_info_state_utils.cpp | 22 +++++++++--------- native/jni/src/proximity_info_state_utils.h | 16 ++++++------- native/jni/src/proximity_info_utils.h | 6 ++--- 12 files changed, 74 insertions(+), 77 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java index 29c65f19b..32cee734a 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java @@ -30,8 +30,7 @@ public final class ProximityInfo { private static final String TAG = ProximityInfo.class.getSimpleName(); private static final boolean DEBUG = false; - /** MAX_PROXIMITY_CHARS_SIZE must be the same as MAX_PROXIMITY_CHARS_SIZE_INTERNAL - * in defines.h */ + // Must be equal to MAX_PROXIMITY_CHARS_SIZE in native/jni/src/defines.h public static final int MAX_PROXIMITY_CHARS_SIZE = 16; /** Number of key widths from current touch point to search for nearest keys. */ private static final float SEARCH_DISTANCE = 1.2f; @@ -88,9 +87,13 @@ public final class ProximityInfo { final int rowSize, final int gridWidth, final int gridHeight) { final ProximityInfo spellCheckerProximityInfo = createDummyProximityInfo(); spellCheckerProximityInfo.mNativeProximityInfo = - spellCheckerProximityInfo.setProximityInfoNative("", - rowSize, gridWidth, gridHeight, gridWidth, gridHeight, - 1, proximityCharsArray, 0, null, null, null, null, null, null, null, null); + spellCheckerProximityInfo.setProximityInfoNative("" /* locale */, + gridWidth /* displayWidth */, gridHeight /* displayHeight */, + gridWidth, gridHeight, 1 /* mostCommonKeyWidth */, proximityCharsArray, + 0 /* keyCount */, null /*keyXCoordinates */, null /* keyYCoordinates */, + null /* keyWidths */, null /* keyHeights */, null /* keyCharCodes */, + null /* sweetSpotCenterXs */, null /* sweetSpotCenterYs */, + null /* sweetSpotRadii */); return spellCheckerProximityInfo; } @@ -100,11 +103,11 @@ public final class ProximityInfo { } // TODO: Stop passing proximityCharsArray - private static native long setProximityInfoNative(String locale, int maxProximityCharsSize, + private static native long setProximityInfoNative(String locale, int displayWidth, int displayHeight, int gridWidth, int gridHeight, int mostCommonKeyWidth, int[] proximityCharsArray, int keyCount, int[] keyXCoordinates, int[] keyYCoordinates, int[] keyWidths, int[] keyHeights, int[] keyCharCodes, - float[] sweetSpotCenterX, float[] sweetSpotCenterY, float[] sweetSpotRadii); + float[] sweetSpotCenterXs, float[] sweetSpotCenterYs, float[] sweetSpotRadii); private static native void releaseProximityInfoNative(long nativeProximityInfo); @@ -230,9 +233,9 @@ public final class ProximityInfo { } // TODO: Stop passing proximityCharsArray - return setProximityInfoNative(mLocaleStr, MAX_PROXIMITY_CHARS_SIZE, mKeyboardMinWidth, - mKeyboardHeight, mGridWidth, mGridHeight, mMostCommonKeyWidth, proximityCharsArray, - keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes, + return setProximityInfoNative(mLocaleStr, mKeyboardMinWidth, mKeyboardHeight, + mGridWidth, mGridHeight, mMostCommonKeyWidth, proximityCharsArray, keyCount, + keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes, sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii); } diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 59d51b0b9..ad3163347 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -35,9 +35,9 @@ public final class BinaryDictionary extends Dictionary { public static final String DICTIONARY_PACK_AUTHORITY = "com.android.inputmethod.latin.dictionarypack"; - // Must be identical to MAX_WORD_LENGTH in native/jni/src/defines.h + // Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h private static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH; - // Must be identical to MAX_RESULTS in native/jni/src/defines.h + // Must be equal to MAX_RESULTS in native/jni/src/defines.h private static final int MAX_RESULTS = 18; private long mNativeDict; diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java index 748900b3a..85cc55232 100644 --- a/java/src/com/android/inputmethod/latin/Constants.java +++ b/java/src/com/android/inputmethod/latin/Constants.java @@ -127,7 +127,7 @@ public final class Constants { } public static final class Dictionary { - // Must be identical to MAX_WORD_LENGTH in native/jni/src/defines.h + // Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h public static final int MAX_WORD_LENGTH = 48; private Dictionary() { diff --git a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp index d718290ad..30ca3f1b8 100644 --- a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp +++ b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp @@ -25,14 +25,14 @@ namespace latinime { static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jclass clazz, jstring localeJStr, - jint maxProximityCharsSize, jint displayWidth, jint displayHeight, jint gridWidth, - jint gridHeight, jint mostCommonkeyWidth, jintArray proximityChars, jint keyCount, + jint displayWidth, jint displayHeight, jint gridWidth, jint gridHeight, + jint mostCommonkeyWidth, jintArray proximityChars, jint keyCount, jintArray keyXCoordinates, jintArray keyYCoordinates, jintArray keyWidths, jintArray keyHeights, jintArray keyCharCodes, jfloatArray sweetSpotCenterXs, jfloatArray sweetSpotCenterYs, jfloatArray sweetSpotRadii) { - ProximityInfo *proximityInfo = new ProximityInfo(env, localeJStr, maxProximityCharsSize, - displayWidth, displayHeight, gridWidth, gridHeight, mostCommonkeyWidth, proximityChars, - keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes, + ProximityInfo *proximityInfo = new ProximityInfo(env, localeJStr, displayWidth, displayHeight, + gridWidth, gridHeight, mostCommonkeyWidth, proximityChars, keyCount, + keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes, sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii); return reinterpret_cast(proximityInfo); } @@ -43,7 +43,7 @@ static void latinime_Keyboard_release(JNIEnv *env, jclass clazz, jlong proximity } static JNINativeMethod sMethods[] = { - {"setProximityInfoNative", "(Ljava/lang/String;IIIIII[II[I[I[I[I[I[F[F[F)J", + {"setProximityInfoNative", "(Ljava/lang/String;IIIII[II[I[I[I[I[I[F[F[F)J", reinterpret_cast(latinime_Keyboard_setProximityInfo)}, {"releaseProximityInfoNative", "(J)V", reinterpret_cast(latinime_Keyboard_release)} }; diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h index 1f432b431..922a746b8 100644 --- a/native/jni/src/defines.h +++ b/native/jni/src/defines.h @@ -28,10 +28,13 @@ #define AK_FORCE_INLINE inline #endif // defined(FLAG_DO_PROFILE) || defined(FLAG_DBG) -// Must be identical to Constants.Dictionary.MAX_WORD_LENGTH in Java +// Must be equal to Constants.Dictionary.MAX_WORD_LENGTH in Java #define MAX_WORD_LENGTH 48 -// Must be identical to BinaryDictionary.MAX_RESULTS in Java +// Must be equal to BinaryDictionary.MAX_RESULTS in Java #define MAX_RESULTS 18 +// Must be equal to ProximityInfo.MAX_PROXIMITY_CHARS_SIZE in Java +#define MAX_PROXIMITY_CHARS_SIZE 16 +#define ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE 2 #if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG) #include @@ -249,6 +252,7 @@ static inline void prof_out(void) { #define S_INT_MIN (-2147483647 - 1) // -(1 << 31) #endif +#define M_PI_F 3.14159265f #define MAX_PERCENTILE 100 // Number of base-10 digits in the largest integer + 1 to leave room for a zero terminator. @@ -325,12 +329,6 @@ static inline void prof_out(void) { #define MAX_FREQ 255 #define MAX_BIGRAM_FREQ 15 -// This must be the same as ProximityInfo#MAX_PROXIMITY_CHARS_SIZE, currently it's 16. -#define MAX_PROXIMITY_CHARS_SIZE_INTERNAL 16 - -// This must be equal to ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE in KeyDetector.java -#define ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE 2 - // Assuming locale strings such as en_US, sr-Latn etc. #define MAX_LOCALE_STRING_LENGTH 10 @@ -395,8 +393,6 @@ static inline void prof_out(void) { template inline T min(T a, T b) { return a < b ? a : b; } template inline T max(T a, T b) { return a > b ? a : b; } -#define M_PI_F 3.14159265f - #define NELEMS(x) (sizeof(x) / sizeof((x)[0])) // The ratio of neutral area radius to sweet spot radius. diff --git a/native/jni/src/proximity_info.cpp b/native/jni/src/proximity_info.cpp index c563b0796..8157fe2d0 100644 --- a/native/jni/src/proximity_info.cpp +++ b/native/jni/src/proximity_info.cpp @@ -47,15 +47,14 @@ static AK_FORCE_INLINE void safeGetOrFillZeroFloatArrayRegion(JNIEnv *env, jfloa } } -ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr, const int maxProximityCharsSize, +ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr, const int keyboardWidth, const int keyboardHeight, const int gridWidth, const int gridHeight, const int mostCommonKeyWidth, const jintArray proximityChars, const int keyCount, const jintArray keyXCoordinates, const jintArray keyYCoordinates, const jintArray keyWidths, const jintArray keyHeights, const jintArray keyCharCodes, const jfloatArray sweetSpotCenterXs, const jfloatArray sweetSpotCenterYs, const jfloatArray sweetSpotRadii) - : MAX_PROXIMITY_CHARS_SIZE(maxProximityCharsSize), GRID_WIDTH(gridWidth), - GRID_HEIGHT(gridHeight), MOST_COMMON_KEY_WIDTH(mostCommonKeyWidth), + : GRID_WIDTH(gridWidth), GRID_HEIGHT(gridHeight), MOST_COMMON_KEY_WIDTH(mostCommonKeyWidth), MOST_COMMON_KEY_WIDTH_SQUARE(mostCommonKeyWidth * mostCommonKeyWidth), CELL_WIDTH((keyboardWidth + gridWidth - 1) / gridWidth), CELL_HEIGHT((keyboardHeight + gridHeight - 1) / gridHeight), @@ -65,11 +64,17 @@ ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr, const int ma && keyWidths && keyHeights && keyCharCodes && sweetSpotCenterXs && sweetSpotCenterYs && sweetSpotRadii), mProximityCharsArray(new int[GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE - /* proximityGridLength */]), + /* proximityCharsLength */]), mCodeToKeyMap() { - const int proximityGridLength = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE; + /* Let's check the input array length here to make sure */ + const jsize proximityCharsLength = env->GetArrayLength(proximityChars); + if (proximityCharsLength != GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE) { + AKLOGE("Invalid proximityCharsLength: %d", proximityCharsLength); + ASSERT(false); + return; + } if (DEBUG_PROXIMITY_INFO) { - AKLOGI("Create proximity info array %d", proximityGridLength); + AKLOGI("Create proximity info array %d", proximityCharsLength); } const jsize localeCStrUtf8Length = env->GetStringUTFLength(localeJStr); if (localeCStrUtf8Length >= MAX_LOCALE_STRING_LENGTH) { @@ -78,7 +83,8 @@ ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr, const int ma } memset(mLocaleStr, 0, sizeof(mLocaleStr)); env->GetStringUTFRegion(localeJStr, 0, env->GetStringLength(localeJStr), mLocaleStr); - safeGetOrFillZeroIntArrayRegion(env, proximityChars, proximityGridLength, mProximityCharsArray); + safeGetOrFillZeroIntArrayRegion(env, proximityChars, proximityCharsLength, + mProximityCharsArray); safeGetOrFillZeroIntArrayRegion(env, keyXCoordinates, KEY_COUNT, mKeyXCoordinates); safeGetOrFillZeroIntArrayRegion(env, keyYCoordinates, KEY_COUNT, mKeyYCoordinates); safeGetOrFillZeroIntArrayRegion(env, keyWidths, KEY_COUNT, mKeyWidths); diff --git a/native/jni/src/proximity_info.h b/native/jni/src/proximity_info.h index cd0bc32cc..6d571d7bb 100644 --- a/native/jni/src/proximity_info.h +++ b/native/jni/src/proximity_info.h @@ -28,7 +28,7 @@ class Correction; class ProximityInfo { public: - ProximityInfo(JNIEnv *env, const jstring localeJStr, const int maxProximityCharsSize, + ProximityInfo(JNIEnv *env, const jstring localeJStr, const int keyboardWidth, const int keyboardHeight, const int gridWidth, const int gridHeight, const int mostCommonKeyWidth, const jintArray proximityChars, const int keyCount, const jintArray keyXCoordinates, const jintArray keyYCoordinates, @@ -126,7 +126,6 @@ class ProximityInfo { float calculateNormalizedSquaredDistance(const int keyIndex, const int inputIndex) const; bool hasInputCoordinates() const; - const int MAX_PROXIMITY_CHARS_SIZE; const int GRID_WIDTH; const int GRID_HEIGHT; const int MOST_COMMON_KEY_WIDTH; diff --git a/native/jni/src/proximity_info_state.cpp b/native/jni/src/proximity_info_state.cpp index 5f3b26662..058a03187 100644 --- a/native/jni/src/proximity_info_state.cpp +++ b/native/jni/src/proximity_info_state.cpp @@ -208,7 +208,7 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi a += 0; AKLOGI("--- Primary = %c, x = %d, y = %d", primaryKey, x, y); } - for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL && proximityCodePoints[j] > 0; + for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE && proximityCodePoints[j] > 0; ++j) { const int currentCodePoint = proximityCodePoints[j]; const float squaredDistance = @@ -216,10 +216,10 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi mProximityInfo->getKeyIndexOf(currentCodePoint), i) : NOT_A_DISTANCE_FLOAT; if (squaredDistance >= 0.0f) { - mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j] = + mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE + j] = (int) (squaredDistance * NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR); } else { - mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j] = + mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE + j] = (j == 0) ? EQUIVALENT_CHAR_WITHOUT_DISTANCE_INFO : PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO; } @@ -355,7 +355,7 @@ ProximityType ProximityInfoState::getMatchedProximityId(const int index, const i // Not an exact nor an accent-alike match: search the list of close keys int j = 1; - while (j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL + while (j < MAX_PROXIMITY_CHARS_SIZE && currentCodePoints[j] > ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) { const bool matched = (currentCodePoints[j] == baseLowerC || currentCodePoints[j] == c); if (matched) { @@ -366,10 +366,10 @@ ProximityType ProximityInfoState::getMatchedProximityId(const int index, const i } ++j; } - if (j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL + if (j < MAX_PROXIMITY_CHARS_SIZE && currentCodePoints[j] == ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) { ++j; - while (j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL + while (j < MAX_PROXIMITY_CHARS_SIZE && currentCodePoints[j] > ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) { const bool matched = (currentCodePoints[j] == baseLowerC || currentCodePoints[j] == c); if (matched) { diff --git a/native/jni/src/proximity_info_state.h b/native/jni/src/proximity_info_state.h index d31447ead..9d3976f3a 100644 --- a/native/jni/src/proximity_info_state.h +++ b/native/jni/src/proximity_info_state.h @@ -73,7 +73,7 @@ class ProximityInfoState { AK_FORCE_INLINE bool existsCodePointInProximityAt(const int index, const int c) const { const int *codePoints = getProximityCodePointsAt(index); int i = 0; - while (codePoints[i] > 0 && i < MAX_PROXIMITY_CHARS_SIZE_INTERNAL) { + while (codePoints[i] > 0 && i < MAX_PROXIMITY_CHARS_SIZE) { if (codePoints[i++] == c) { return true; } @@ -99,7 +99,7 @@ class ProximityInfoState { inline int getNormalizedSquaredDistance( const int inputIndex, const int proximityIndex) const { return mNormalizedSquaredDistances[ - inputIndex * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + proximityIndex]; + inputIndex * MAX_PROXIMITY_CHARS_SIZE + proximityIndex]; } inline const int *getPrimaryInputWord() const { @@ -119,7 +119,7 @@ class ProximityInfoState { if (*inputProximities != *word) { return false; } - inputProximities += MAX_PROXIMITY_CHARS_SIZE_INTERNAL; + inputProximities += MAX_PROXIMITY_CHARS_SIZE; word++; } return true; @@ -214,11 +214,6 @@ class ProximityInfoState { float calculateSquaredDistanceFromSweetSpotCenter( const int keyIndex, const int inputIndex) const; - bool pushTouchPoint(const int inputIndex, const int nodeCodePoint, int x, int y, const int time, - const bool sample, const bool isLastPoint, const float sumAngle, - NearKeysDistanceMap *const currentNearKeysDistances, - const NearKeysDistanceMap *const prevNearKeysDistances, - const NearKeysDistanceMap *const prevPrevNearKeysDistances); ///////////////////////////////////////// // Defined here // ///////////////////////////////////////// @@ -284,8 +279,8 @@ class ProximityInfoState { // inputs including the current input point. std::vector mSearchKeysVector; bool mTouchPositionCorrectionEnabled; - int mInputProximities[MAX_PROXIMITY_CHARS_SIZE_INTERNAL * MAX_WORD_LENGTH]; - int mNormalizedSquaredDistances[MAX_PROXIMITY_CHARS_SIZE_INTERNAL * MAX_WORD_LENGTH]; + int mInputProximities[MAX_PROXIMITY_CHARS_SIZE * MAX_WORD_LENGTH]; + int mNormalizedSquaredDistances[MAX_PROXIMITY_CHARS_SIZE * MAX_WORD_LENGTH]; int mSampledInputSize; int mPrimaryInputWord[MAX_WORD_LENGTH]; }; diff --git a/native/jni/src/proximity_info_state_utils.cpp b/native/jni/src/proximity_info_state_utils.cpp index 146ce0545..65a258309 100644 --- a/native/jni/src/proximity_info_state_utils.cpp +++ b/native/jni/src/proximity_info_state_utils.cpp @@ -16,6 +16,7 @@ #include +#include "defines.h" #include "geometry_utils.h" #include "proximity_info.h" #include "proximity_info_params.h" @@ -24,13 +25,12 @@ namespace latinime { /* static */ int ProximityInfoStateUtils::updateTouchPoints(const int mostCommonKeyWidth, const ProximityInfo *const proximityInfo, const int maxPointToKeyLength, - const int *const inputProximities, - const int *const inputXCoordinates, const int *const inputYCoordinates, - const int *const times, const int *const pointerIds, const int inputSize, - const bool isGeometric, const int pointerId, const int pushTouchPointStartIndex, - std::vector *sampledInputXs, std::vector *sampledInputYs, - std::vector *sampledInputTimes, std::vector *sampledLengthCache, - std::vector *sampledInputIndice) { + const int *const inputProximities, const int *const inputXCoordinates, + const int *const inputYCoordinates, const int *const times, const int *const pointerIds, + const int inputSize, const bool isGeometric, const int pointerId, + const int pushTouchPointStartIndex, std::vector *sampledInputXs, + std::vector *sampledInputYs, std::vector *sampledInputTimes, + std::vector *sampledLengthCache, std::vector *sampledInputIndice) { if (DEBUG_SAMPLING_POINTS) { if (times) { for (int i = 0; i < inputSize; ++i) { @@ -94,7 +94,7 @@ namespace latinime { } if (pushTouchPoint(mostCommonKeyWidth, proximityInfo, maxPointToKeyLength, - i, c, x, y, time, isGeometric /* do sampling */, + i, c, x, y, time, isGeometric /* doSampling */, i == lastInputIndex, sumAngle, currentNearKeysDistances, prevNearKeysDistances, prevPrevNearKeysDistances, sampledInputXs, sampledInputYs, sampledInputTimes, sampledLengthCache, @@ -117,7 +117,7 @@ namespace latinime { /* static */ const int *ProximityInfoStateUtils::getProximityCodePointsAt( const int *const inputProximities, const int index) { - return inputProximities + (index * MAX_PROXIMITY_CHARS_SIZE_INTERNAL); + return inputProximities + (index * MAX_PROXIMITY_CHARS_SIZE); } /* static */ int ProximityInfoStateUtils::getPrimaryCodePointAt( @@ -325,7 +325,7 @@ namespace latinime { /* static */ bool ProximityInfoStateUtils::pushTouchPoint(const int mostCommonKeyWidth, const ProximityInfo *const proximityInfo, const int maxPointToKeyLength, const int inputIndex, const int nodeCodePoint, int x, int y, - const int time, const bool sample, const bool isLastPoint, const float sumAngle, + const int time, const bool doSampling, const bool isLastPoint, const float sumAngle, NearKeysDistanceMap *const currentNearKeysDistances, const NearKeysDistanceMap *const prevNearKeysDistances, const NearKeysDistanceMap *const prevPrevNearKeysDistances, @@ -336,7 +336,7 @@ namespace latinime { size_t size = sampledInputXs->size(); bool popped = false; - if (nodeCodePoint < 0 && sample) { + if (nodeCodePoint < 0 && doSampling) { const float nearest = updateNearKeysDistances( proximityInfo, maxPointToKeyLength, x, y, currentNearKeysDistances); const float score = getPointScore(mostCommonKeyWidth, x, y, time, isLastPoint, nearest, diff --git a/native/jni/src/proximity_info_state_utils.h b/native/jni/src/proximity_info_state_utils.h index 90a98ef8d..3408aef89 100644 --- a/native/jni/src/proximity_info_state_utils.h +++ b/native/jni/src/proximity_info_state_utils.h @@ -36,8 +36,7 @@ class ProximityInfoStateUtils { std::vector *sampledInputXs, std::vector *sampledInputYs, std::vector *sampledInputTimes, std::vector *sampledLengthCache, std::vector *sampledInputIndice); - static const int *getProximityCodePointsAt( - const int *const inputProximities, const int index); + static const int *getProximityCodePointsAt(const int *const inputProximities, const int index); static int getPrimaryCodePointAt(const int *const inputProximities, const int index); static void popInputData(std::vector *sampledInputXs, std::vector *sampledInputYs, std::vector *sampledInputTimes, std::vector *sampledLengthCache, @@ -57,8 +56,7 @@ class ProximityInfoStateUtils { const std::vector *const sampledInputYs, const std::vector *const inputIndice, std::vector *beelineSpeedPercentiles); static float getDirection(const std::vector *const sampledInputXs, - const std::vector *const sampledInputYs, - const int index0, const int index1); + const std::vector *const sampledInputYs, const int index0, const int index1); private: DISALLOW_IMPLICIT_CONSTRUCTORS(ProximityInfoStateUtils); @@ -71,16 +69,16 @@ class ProximityInfoStateUtils { static bool isPrevLocalMin(const NearKeysDistanceMap *const currentNearKeysDistances, const NearKeysDistanceMap *const prevNearKeysDistances, const NearKeysDistanceMap *const prevPrevNearKeysDistances); - static float getPointScore(const int mostCommonKeyWidth, - const int x, const int y, const int time, const bool lastPoint, const float nearest, - const float sumAngle, const NearKeysDistanceMap *const currentNearKeysDistances, + static float getPointScore(const int mostCommonKeyWidth, const int x, const int y, + const int time, const bool lastPoint, const float nearest, const float sumAngle, + const NearKeysDistanceMap *const currentNearKeysDistances, const NearKeysDistanceMap *const prevNearKeysDistances, const NearKeysDistanceMap *const prevPrevNearKeysDistances, std::vector *sampledInputXs, std::vector *sampledInputYs); static bool pushTouchPoint(const int mostCommonKeyWidth, const ProximityInfo *const proximityInfo, const int maxPointToKeyLength, - const int inputIndex, const int nodeCodePoint, int x, int y, - const int time, const bool sample, const bool isLastPoint, const float sumAngle, + const int inputIndex, const int nodeCodePoint, int x, int y, const int time, + const bool doSampling, const bool isLastPoint, const float sumAngle, NearKeysDistanceMap *const currentNearKeysDistances, const NearKeysDistanceMap *const prevNearKeysDistances, const NearKeysDistanceMap *const prevPrevNearKeysDistances, diff --git a/native/jni/src/proximity_info_utils.h b/native/jni/src/proximity_info_utils.h index 09302075a..24917d879 100644 --- a/native/jni/src/proximity_info_utils.h +++ b/native/jni/src/proximity_info_utils.h @@ -61,7 +61,7 @@ class ProximityInfoUtils { const int primaryKey = inputCodes[i]; const int x = inputXCoordinates[i]; const int y = inputYCoordinates[i]; - int *proximities = &inputProximities[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL]; + int *proximities = &inputProximities[i * MAX_PROXIMITY_CHARS_SIZE]; calculateProximities(keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, proximityCharsArray, maxProximityCharsSize, cellHeight, cellWidth, gridWidth, mostCommonKeyWidth, keyCount, x, y, primaryKey, localeStr, codeToKeyMap, @@ -71,9 +71,9 @@ class ProximityInfoUtils { if (DEBUG_PROXIMITY_CHARS) { for (int i = 0; i < inputSize; ++i) { AKLOGI("---"); - for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL; ++j) { + for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE; ++j) { int proximityChar = - inputProximities[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j]; + inputProximities[i * MAX_PROXIMITY_CHARS_SIZE + j]; proximityChar += 0; AKLOGI("--- (%d)%c", i, proximityChar); }