Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46b9d339 authored by John Reck's avatar John Reck Committed by Android Git Automerger
Browse files

am ee3c1ea5: am 4108f565: am b25c0bb7: am 525ac80d: Merge "Create a...

am ee3c1ea5: am 4108f565: am b25c0bb7: am 525ac80d: Merge "Create a thread_local cache for textLocale" into mnc-dev

* commit 'ee3c1ea5':
  Create a thread_local cache for textLocale
parents eae4345b ee3c1ea5
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -74,6 +74,13 @@ static void defaultSettingsForAndroid(Paint* paint) {
    paint->setTextEncoding(Paint::kGlyphID_TextEncoding);
}

struct LocaleCacheEntry {
    std::string javaLocale;
    std::string languageTag;
};

static thread_local LocaleCacheEntry sSingleEntryLocaleCache;

class PaintGlue {
public:
    enum MoveOpt {
@@ -399,10 +406,14 @@ public:
    static void setTextLocale(JNIEnv* env, jobject clazz, jlong objHandle, jstring locale) {
        Paint* obj = reinterpret_cast<Paint*>(objHandle);
        ScopedUtfChars localeChars(env, locale);
        if (sSingleEntryLocaleCache.javaLocale != localeChars.c_str()) {
            sSingleEntryLocaleCache.javaLocale = localeChars.c_str();
            char langTag[ULOC_FULLNAME_CAPACITY];
            toLanguageTag(langTag, ULOC_FULLNAME_CAPACITY, localeChars.c_str());
            sSingleEntryLocaleCache.languageTag = langTag;
        }

        obj->setTextLocale(langTag);
        obj->setTextLocale(sSingleEntryLocaleCache.languageTag);
    }

    static jboolean isElegantTextHeight(JNIEnv* env, jobject paint) {