Skip to content
Snippets Groups Projects
Commit 30a324a5 authored by Satoshi Kataoka's avatar Satoshi Kataoka Committed by Android (Google) Code Review
Browse files

Merge "Cleanup gesture code overlay"

parents c5e911c0 deb09872
No related branches found
No related tags found
No related merge requests found
Showing
with 100 additions and 323 deletions
...@@ -49,7 +49,7 @@ LATIN_IME_CORE_SRC_FILES := \ ...@@ -49,7 +49,7 @@ LATIN_IME_CORE_SRC_FILES := \
proximity_info.cpp \ proximity_info.cpp \
proximity_info_state.cpp \ proximity_info_state.cpp \
unigram_dictionary.cpp \ unigram_dictionary.cpp \
gesture/incremental_decoder_interface.cpp gesture/gesture_decoder_wrapper.cpp
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
$(LATIN_IME_JNI_SRC_FILES) \ $(LATIN_IME_JNI_SRC_FILES) \
...@@ -78,49 +78,8 @@ include $(BUILD_STATIC_LIBRARY) ...@@ -78,49 +78,8 @@ include $(BUILD_STATIC_LIBRARY)
###################################### ######################################
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_C_INCLUDES += $(LATIN_IME_SRC_FULLPATH_DIR) \
$(addprefix $(LATIN_IME_SRC_FULLPATH_DIR)/, gesture gesture/impl)
LOCAL_CFLAGS += -Werror -Wall
# To suppress compiler warnings for unused variables/functions used for debug features etc.
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
LATIN_IME_GESTURE_IMPL_SRC_FILES := \
gesture/impl/gesture_decoder_impl.cpp \
gesture/impl/incremental_decoder_impl.cpp \
gesture/impl/token_beam_impl.cpp \
gesture/impl/token_impl.cpp
LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_GESTURE_IMPL_SRC_FILES))
ifeq ($(FLAG_DO_PROFILE), true)
$(warning Making profiling version of native library)
LOCAL_CFLAGS += -DFLAG_DO_PROFILE
else # FLAG_DO_PROFILE
ifeq ($(FLAG_DBG), true)
$(warning Making debug version of native library)
LOCAL_CFLAGS += -DFLAG_DBG
endif # FLAG_DBG
endif # FLAG_DO_PROFILE
# TODO: Can remove this static library from AOSP completely?
LOCAL_MODULE := libjni_latinime_gesture_impl_aosp_static
LOCAL_MODULE_TAGS := optional
ifdef HISTORICAL_NDK_VERSIONS_ROOT # In the platform build system
include external/stlport/libstlport.mk
else # In the NDK build system
LOCAL_C_INCLUDES += external/stlport/stlport bionic
endif
include $(BUILD_STATIC_LIBRARY)
######################################
include $(CLEAR_VARS)
# All code in LOCAL_WHOLE_STATIC_LIBRARIES will be built into this shared library. # All code in LOCAL_WHOLE_STATIC_LIBRARIES will be built into this shared library.
LOCAL_WHOLE_STATIC_LIBRARIES := \ LOCAL_WHOLE_STATIC_LIBRARIES := libjni_latinime_common_static
libjni_latinime_common_static libjni_latinime_gesture_impl_aosp_static
ifdef HISTORICAL_NDK_VERSIONS_ROOT # In the platform build system ifdef HISTORICAL_NDK_VERSIONS_ROOT # In the platform build system
LOCAL_SHARED_LIBRARIES := libstlport LOCAL_SHARED_LIBRARIES := libstlport
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "binary_format.h" #include "binary_format.h"
#include "defines.h" #include "defines.h"
#include "dictionary.h" #include "dictionary.h"
#include "incremental_decoder_interface.h" #include "gesture_decoder_wrapper.h"
namespace latinime { namespace latinime {
...@@ -44,8 +44,7 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, ...@@ -44,8 +44,7 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
mUnigramDictionary = new UnigramDictionary(mDict + headerSize, typedLetterMultiplier, mUnigramDictionary = new UnigramDictionary(mDict + headerSize, typedLetterMultiplier,
fullWordMultiplier, maxWordLength, maxWords, options); fullWordMultiplier, maxWordLength, maxWords, options);
mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength); mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength);
mGestureDecoder = IncrementalDecoderInterface::getGestureDecoderInstance(maxWordLength, mGestureDecoder = new GestureDecoderWrapper(maxWordLength, maxWords);
maxWords);
mGestureDecoder->setDict(mUnigramDictionary, mBigramDictionary, mGestureDecoder->setDict(mUnigramDictionary, mBigramDictionary,
mDict + headerSize /* dict root */, 0 /* root pos */); mDict + headerSize /* dict root */, 0 /* root pos */);
} }
......
...@@ -45,6 +45,7 @@ class Dictionary { ...@@ -45,6 +45,7 @@ class Dictionary {
result = mGestureDecoder->getSuggestions(proximityInfo, xcoordinates, ycoordinates, result = mGestureDecoder->getSuggestions(proximityInfo, xcoordinates, ycoordinates,
times, pointerIds, codes, codesSize, commitPoint, times, pointerIds, codes, codesSize, commitPoint,
outWords, frequencies, spaceIndices); outWords, frequencies, spaceIndices);
return result;
} else { } else {
std::map<int, int> bigramMap; std::map<int, int> bigramMap;
uint8_t bigramFilter[BIGRAM_FILTER_BYTE_SIZE]; uint8_t bigramFilter[BIGRAM_FILTER_BYTE_SIZE];
...@@ -53,8 +54,8 @@ class Dictionary { ...@@ -53,8 +54,8 @@ class Dictionary {
result = mUnigramDictionary->getSuggestions(proximityInfo, xcoordinates, result = mUnigramDictionary->getSuggestions(proximityInfo, xcoordinates,
ycoordinates, codes, codesSize, &bigramMap, bigramFilter, ycoordinates, codes, codesSize, &bigramMap, bigramFilter,
useFullEditDistance, outWords, frequencies); useFullEditDistance, outWords, frequencies);
return result;
} }
return result;
} }
int getBigrams(const int32_t *word, int length, int *codes, int codesSize, int getBigrams(const int32_t *word, int length, int *codes, int codesSize,
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
#include "token_impl.h" #include "gesture_decoder_wrapper.h"
namespace latinime { namespace latinime {
IncrementalDecoderInterface *
(*GestureDecoderWrapper::sGestureDecoderFactoryMethod)(int, int) = 0;
} // namespace latinime } // namespace latinime
...@@ -14,9 +14,10 @@ ...@@ -14,9 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef LATINIME_INCREMENTAL_DECODER_IMPL_H #ifndef LATINIME_GESTURE_DECODER_WRAPPER_H
#define LATINIME_INCREMENTAL_DECODER_IMPL_H #define LATINIME_GESTURE_DECODER_WRAPPER_H
#include <stdint.h>
#include "defines.h" #include "defines.h"
#include "incremental_decoder_interface.h" #include "incremental_decoder_interface.h"
...@@ -24,23 +25,67 @@ namespace latinime { ...@@ -24,23 +25,67 @@ namespace latinime {
class UnigramDictionary; class UnigramDictionary;
class BigramDictionary; class BigramDictionary;
class ProximityInfo;
class IncrementalDecoderImpl : public IncrementalDecoderInterface { class GestureDecoderWrapper : public IncrementalDecoderInterface {
public: public:
IncrementalDecoderImpl(int maxWordLength, int maxWords) { }; GestureDecoderWrapper(const int maxWordLength, const int maxWords) {
void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram, mIncrementalDecoderInterface = getGestureDecoderInstance(maxWordLength, maxWords);
const uint8_t *dictRoot, int rootPos) { }; }
void setPrevWord(const int32_t *prevWord, int prevWordLength) { };
void reset() { }; virtual ~GestureDecoderWrapper() {
delete mIncrementalDecoderInterface;
}
int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times, int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times,
int *pointerIds, int *codes, int inputSize, int commitPoint, int *pointerIds, int *codes, int inputSize, int commitPoint,
unsigned short *outWords, int *frequencies, int *outputIndices) { unsigned short *outWords, int *frequencies, int *outputIndices) {
return 0; if (!mIncrementalDecoderInterface) {
return 0;
}
return mIncrementalDecoderInterface->getSuggestions(
pInfo, inputXs, inputYs, times, pointerIds, codes, inputSize, commitPoint,
outWords, frequencies, outputIndices);
}
void reset() {
if (!mIncrementalDecoderInterface) {
return;
}
mIncrementalDecoderInterface->reset();
}
void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram,
const uint8_t *dictRoot, int rootPos) {
if (!mIncrementalDecoderInterface) {
return;
}
mIncrementalDecoderInterface->setDict(dict, bigram, dictRoot, rootPos);
}
void setPrevWord(const int32_t *prevWord, int prevWordLength) {
if (!mIncrementalDecoderInterface) {
return;
}
mIncrementalDecoderInterface->setPrevWord(prevWord, prevWordLength);
}
static void setGestureDecoderFactoryMethod(
IncrementalDecoderInterface *(*factoryMethod)(int, int)) {
sGestureDecoderFactoryMethod = factoryMethod;
} }
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalDecoderImpl); DISALLOW_COPY_AND_ASSIGN(GestureDecoderWrapper);
static IncrementalDecoderInterface *getGestureDecoderInstance(int maxWordLength, int maxWords) {
if (sGestureDecoderFactoryMethod) {
return sGestureDecoderFactoryMethod(maxWordLength, maxWords);
}
return 0;
}
static IncrementalDecoderInterface *(*sGestureDecoderFactoryMethod)(int, int);
IncrementalDecoderInterface *mIncrementalDecoderInterface;
}; };
} // namespace latinime } // namespace latinime
#endif // LATINIME_INCREMENTAL_DECODER_IMPL_H #endif // LATINIME_GESTURE_DECODER_WRAPPER_H
/*
* Copyright (C) 2012 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.
*/
#include "gesture_decoder_impl.h"
#include "incremental_decoder_interface.h"
namespace latinime {
// A factory method for GestureDecoderImpl
static IncrementalDecoderInterface *getDecoderInstance(int maxWordLength, int maxWords) {
return new GestureDecoderImpl(maxWordLength, maxWords);
}
// An ad-hoc internal class to register the factory method defined above
class GestureDecoderFactoryRegisterer {
public:
GestureDecoderFactoryRegisterer() {
IncrementalDecoderInterface::setGestureDecoderFactoryMethod(getDecoderInstance);
}
private:
DISALLOW_COPY_AND_ASSIGN(GestureDecoderFactoryRegisterer);
};
// To invoke the GestureDecoderFactoryRegisterer constructor in the global constructor
// Not sure, but can be static?
GestureDecoderFactoryRegisterer gestureDecoderFactoryRegisterer;
} // namespace latinime
/*
* Copyright (C) 2012 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_GESTURE_DECODER_IMPL_H
#define LATINIME_GESTURE_DECODER_IMPL_H
#include "defines.h"
#include "incremental_decoder_impl.h"
namespace latinime {
class GestureDecoderImpl : public IncrementalDecoderImpl {
public:
GestureDecoderImpl(int maxWordLength, int maxWords) :
IncrementalDecoderImpl(maxWordLength, maxWords) {
}
int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times,
int *pointerIds, int *codes, int inputSize, int commitPoint,
unsigned short *outWords, int *frequencies, int *outputIndices) {
return 0;
}
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(GestureDecoderImpl);
};
} // namespace latinime
#endif // LATINIME_GESTURE_DECODER_IMPL_H
/*
* Copyright (C) 2012 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_NOTHING_H
#define LATINIME_NOTHING_H
namespace latinime {
} // namespace latinime
#endif // LATINIME_NOTHING_H
/*
* Copyright (C) 2012 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.
*/
#include "incremental_decoder_impl.h"
#include "incremental_decoder_interface.h"
namespace latinime {
// A factory method for IncrementalDecoderImpl
static IncrementalDecoderInterface *getDecoderInstance(int maxWordLength, int maxWords) {
return new IncrementalDecoderImpl(maxWordLength, maxWords);
}
// An ad-hoc internal class to register the factory method defined above
class IncrementalDecoderFactoryRegisterer {
public:
IncrementalDecoderFactoryRegisterer() {
IncrementalDecoderInterface::setIncrementalDecoderFactoryMethod(getDecoderInstance);
}
private:
DISALLOW_COPY_AND_ASSIGN(IncrementalDecoderFactoryRegisterer);
};
// To invoke the IncrementalDecoderFactoryRegisterer constructor in the global constructor
// Not sure, but can be static?
IncrementalDecoderFactoryRegisterer incrementalDecoderFactoryRegisterer;
} // namespace latinime
/*
* Copyright (C) 2012 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.
*/
#include "token_beam_impl.h"
namespace latinime {
} // namespace latinime
/*
* Copyright (C) 2012 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_TOKEN_BEAM_IMPL_H
#define LATINIME_TOKEN_BEAM_IMPL_H
#include "defines.h"
namespace latinime {
class TokenBeamImpl {
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(TokenBeamImpl);
};
} // namespace latinime
#endif // LATINIME_TOKEN_BEAM_IMPL_H
/*
* Copyright (C) 2012 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_TOKEN_IMPL_H
#define LATINIME_TOKEN_IMPL_H
#include "defines.h"
namespace latinime {
struct TokenImpl {
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(TokenImpl);
};
} // namespace latinime
#endif // LATINIME_TOKEN_IMPL_H
/*
* Copyright (C) 2012 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.
*/
#include "incremental_decoder_interface.h"
namespace latinime {
IncrementalDecoderInterface *
(*IncrementalDecoderInterface::sGestureDecoderFactoryMethod)(int, int) = 0;
IncrementalDecoderInterface *
(*IncrementalDecoderInterface::sIncrementalDecoderFactoryMethod)(int, int) = 0;
} // namespace latinime
...@@ -36,35 +36,6 @@ class IncrementalDecoderInterface { ...@@ -36,35 +36,6 @@ class IncrementalDecoderInterface {
const uint8_t *dictRoot, int rootPos) = 0; const uint8_t *dictRoot, int rootPos) = 0;
virtual void setPrevWord(const int32_t *prevWord, int prevWordLength) = 0; virtual void setPrevWord(const int32_t *prevWord, int prevWordLength) = 0;
virtual ~IncrementalDecoderInterface() { }; virtual ~IncrementalDecoderInterface() { };
static IncrementalDecoderInterface *getGestureDecoderInstance(int maxWordLength, int maxWords) {
if (sGestureDecoderFactoryMethod) {
return sGestureDecoderFactoryMethod(maxWordLength, maxWords);
}
return 0;
}
static IncrementalDecoderInterface *getIncrementalDecoderInstance(int maxWordLength,
int maxWords) {
if (sIncrementalDecoderFactoryMethod) {
return sIncrementalDecoderFactoryMethod(maxWordLength, maxWords);
}
return 0;
}
static void setGestureDecoderFactoryMethod(
IncrementalDecoderInterface *(*factoryMethod)(int, int)) {
sGestureDecoderFactoryMethod = factoryMethod;
}
static void setIncrementalDecoderFactoryMethod(
IncrementalDecoderInterface *(*factoryMethod)(int, int)) {
sIncrementalDecoderFactoryMethod = factoryMethod;
}
private:
static IncrementalDecoderInterface *(*sGestureDecoderFactoryMethod)(int, int);
static IncrementalDecoderInterface *(*sIncrementalDecoderFactoryMethod)(int, int);
}; };
} // namespace latinime } // namespace latinime
#endif // LATINIME_INCREMENTAL_DECODER_INTERFACE_H #endif // LATINIME_INCREMENTAL_DECODER_INTERFACE_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment