diff options
Diffstat (limited to 'native/jni/src')
-rw-r--r-- | native/jni/src/debug.h | 71 | ||||
-rw-r--r-- | native/jni/src/defines.h | 4 | ||||
-rw-r--r-- | native/jni/src/proximity_info_state.cpp | 33 |
3 files changed, 35 insertions, 73 deletions
diff --git a/native/jni/src/debug.h b/native/jni/src/debug.h deleted file mode 100644 index 8f6b69d77..000000000 --- a/native/jni/src/debug.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2011, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef LATINIME_DEBUG_H -#define LATINIME_DEBUG_H - -#include "defines.h" - -static inline unsigned char *convertToUnibyteString(unsigned short *input, unsigned char *output, - const unsigned int length) { - unsigned int i = 0; - for (; i < length && input[i] != 0; ++i) - output[i] = input[i] & 0xFF; - output[i] = 0; - return output; -} - -static inline unsigned char *convertToUnibyteStringAndReplaceLastChar(unsigned short *input, - unsigned char *output, const unsigned int length, unsigned char c) { - unsigned int i = 0; - for (; i < length && input[i] != 0; ++i) - output[i] = input[i] & 0xFF; - if (i > 0) output[i-1] = c; - output[i] = 0; - return output; -} - -static inline void LOGI_S16(unsigned short *string, const unsigned int length) { - unsigned char tmp_buffer[length]; - convertToUnibyteString(string, tmp_buffer, length); - AKLOGI(">> %s", tmp_buffer); - // The log facility is throwing out log that comes too fast. The following - // is a dirty way of slowing down processing so that we can see all log. - // TODO : refactor this in a blocking log or something. - // usleep(10); -} - -static inline void LOGI_S16_PLUS(unsigned short *string, const unsigned int length, - unsigned char c) { - unsigned char tmp_buffer[length+1]; - convertToUnibyteStringAndReplaceLastChar(string, tmp_buffer, length, c); - AKLOGI(">> %s", tmp_buffer); - // Likewise - // usleep(10); -} - -static inline void printDebug(const char *tag, int *codes, int codesSize, int MAX_PROXIMITY_CHARS) { - unsigned char *buf = static_cast<unsigned char *>(malloc((1 + codesSize) * sizeof(*buf))); - - buf[codesSize] = 0; - while (--codesSize >= 0) { - buf[codesSize] = static_cast<unsigned char>(codes[codesSize * MAX_PROXIMITY_CHARS]); - } - AKLOGI("%s, WORD = %s", tag, buf); - - free(buf); -} -#endif // LATINIME_DEBUG_H diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h index 95a90275d..ad526fb7f 100644 --- a/native/jni/src/defines.h +++ b/native/jni/src/defines.h @@ -220,7 +220,11 @@ static inline void prof_out(void) { #define DEBUG_CORRECTION_FREQ false #define DEBUG_WORDS_PRIORITY_QUEUE false +#ifdef FLAG_FULL_DBG +#define DEBUG_GEO_FULL true +#else #define DEBUG_GEO_FULL false +#endif #else // FLAG_DBG diff --git a/native/jni/src/proximity_info_state.cpp b/native/jni/src/proximity_info_state.cpp index a4eb7e353..208b69356 100644 --- a/native/jni/src/proximity_info_state.cpp +++ b/native/jni/src/proximity_info_state.cpp @@ -98,6 +98,10 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi mDistanceCache.clear(); mNearKeysVector.clear(); } + if (DEBUG_GEO_FULL) { + AKLOGI("Init ProximityInfoState: reused points = %d, last input size = %d", + pushTouchPointStartIndex, lastSavedInputSize); + } mInputSize = 0; if (xCoordinates && yCoordinates) { @@ -109,6 +113,9 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi lastInputIndex = i; } } + if (DEBUG_GEO_FULL) { + AKLOGI("Init ProximityInfoState: last input index = %d", lastInputIndex); + } // Working space to save near keys distances for current, prev and prevprev input point. NearKeysDistanceMap nearKeysDistances[3]; // These pointers are swapped for each inputs points. @@ -119,13 +126,16 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi for (int i = pushTouchPointStartIndex; i <= lastInputIndex; ++i) { // Assuming pointerId == 0 if pointerIds is null. const int pid = pointerIds ? pointerIds[i] : 0; + if (DEBUG_GEO_FULL) { + AKLOGI("Init ProximityInfoState: (%d)PID = %d", i, pid); + } if (pointerId == pid) { const int c = isGeometric ? NOT_A_COORDINATE : getPrimaryCharAt(i); const int x = proximityOnly ? NOT_A_COORDINATE : xCoordinates[i]; const int y = proximityOnly ? NOT_A_COORDINATE : yCoordinates[i]; const int time = times ? times[i] : -1; - if (pushTouchPoint(i, c, x, y, time, isGeometric, i == lastInputIndex, - currentNearKeysDistances, prevNearKeysDistances, + if (pushTouchPoint(i, c, x, y, time, isGeometric /* do sampling */, + i == lastInputIndex, currentNearKeysDistances, prevNearKeysDistances, prevPrevNearKeysDistances)) { // Previous point information was popped. NearKeysDistanceMap *tmp = prevNearKeysDistances; @@ -218,6 +228,10 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi } } } + + if (DEBUG_GEO_FULL) { + AKLOGI("ProximityState init finished: %d points out of %d", mInputSize, inputSize); + } } bool ProximityInfoState::checkAndReturnIsContinuationPossible(const int inputSize, @@ -363,6 +377,13 @@ bool ProximityInfoState::pushTouchPoint(const int inputIndex, const int nodeChar if (isLastPoint) { if (size > 0 && getDistanceFloat(x, y, mInputXs.back(), mInputYs.back()) < mProximityInfo->getMostCommonKeyWidth() * LAST_POINT_SKIP_DISTANCE_SCALE) { + if (DEBUG_GEO_FULL) { + AKLOGI("p0: size = %zd, x = %d, y = %d, lx = %d, ly = %d, dist = %f, " + "width = %f", size, x, y, mInputXs.back(), mInputYs.back(), + getDistanceFloat(x, y, mInputXs.back(), mInputYs.back()), + mProximityInfo->getMostCommonKeyWidth() + * LAST_POINT_SKIP_DISTANCE_SCALE); + } return popped; } else if (size > 1) { int minChar = 0; @@ -376,6 +397,10 @@ bool ProximityInfoState::pushTouchPoint(const int inputIndex, const int nodeChar } NearKeysDistanceMap::const_iterator itPP = prevNearKeysDistances->find(minChar); + if (DEBUG_GEO_FULL) { + AKLOGI("p1: char = %c, minDist = %f, prevNear key minDist = %f", + minChar, itPP->second, minDist); + } if (itPP != prevNearKeysDistances->end() && minDist > itPP->second) { return popped; } @@ -402,6 +427,10 @@ bool ProximityInfoState::pushTouchPoint(const int inputIndex, const int nodeChar mInputYs.push_back(y); mTimes.push_back(time); mInputIndice.push_back(inputIndex); + if (DEBUG_GEO_FULL) { + AKLOGI("pushTouchPoint: x = %03d, y = %03d, time = %d, index = %d, popped ? %01d", + x, y, time, inputIndex, popped); + } return popped; } |