Merge "Preload minikin LocaleListCache in Zygote."
This commit is contained in:
committed by
Android (Google) Code Review
commit
c2832239d9
@@ -57,6 +57,7 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
import dalvik.annotation.optimization.CriticalNative;
|
||||
import dalvik.annotation.optimization.FastNative;
|
||||
|
||||
import libcore.util.NativeAllocationRegistry;
|
||||
|
||||
@@ -1406,6 +1407,9 @@ public class Typeface {
|
||||
FontConfig config = SystemFonts.getSystemPreinstalledFontConfig();
|
||||
for (int i = 0; i < config.getFontFamilies().size(); ++i) {
|
||||
FontConfig.FontFamily family = config.getFontFamilies().get(i);
|
||||
if (!family.getLocaleList().isEmpty()) {
|
||||
nativeRegisterLocaleList(family.getLocaleList().toLanguageTags());
|
||||
}
|
||||
boolean loadFamily = false;
|
||||
for (int j = 0; j < family.getLocaleList().size(); ++j) {
|
||||
String fontScript = ULocale.addLikelySubtags(
|
||||
@@ -1568,4 +1572,7 @@ public class Typeface {
|
||||
private static native void nativeAddFontCollections(long nativePtr);
|
||||
|
||||
private static native void nativeWarmUpCache(String fileName);
|
||||
|
||||
@FastNative
|
||||
private static native void nativeRegisterLocaleList(String locales);
|
||||
}
|
||||
|
||||
@@ -20,18 +20,20 @@
|
||||
#include <minikin/FontCollection.h>
|
||||
#include <minikin/FontFamily.h>
|
||||
#include <minikin/FontFileParser.h>
|
||||
#include <minikin/LocaleList.h>
|
||||
#include <minikin/SystemFonts.h>
|
||||
#include <nativehelper/ScopedPrimitiveArray.h>
|
||||
#include <nativehelper/ScopedUtfChars.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "FontUtils.h"
|
||||
#include "GraphicsJNI.h"
|
||||
#include "SkData.h"
|
||||
#include "SkTypeface.h"
|
||||
#include "fonts/Font.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
@@ -380,6 +382,12 @@ static void Typeface_addFontCollection(CRITICAL_JNI_PARAMS_COMMA jlong faceHandl
|
||||
minikin::SystemFonts::addFontMap(std::move(collection));
|
||||
}
|
||||
|
||||
// Fast Native
|
||||
static void Typeface_registerLocaleList(JNIEnv* env, jobject, jstring jLocales) {
|
||||
ScopedUtfChars locales(env, jLocales);
|
||||
minikin::registerLocaleList(locales.c_str());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const JNINativeMethod gTypefaceMethods[] = {
|
||||
@@ -405,6 +413,7 @@ static const JNINativeMethod gTypefaceMethods[] = {
|
||||
{"nativeGetFamily", "(JI)J", (void*)Typeface_getFamily},
|
||||
{"nativeWarmUpCache", "(Ljava/lang/String;)V", (void*)Typeface_warmUpCache},
|
||||
{"nativeAddFontCollections", "(J)V", (void*)Typeface_addFontCollection},
|
||||
{"nativeRegisterLocaleList", "(Ljava/lang/String;)V", (void*)Typeface_registerLocaleList},
|
||||
};
|
||||
|
||||
int register_android_graphics_Typeface(JNIEnv* env)
|
||||
|
||||
Reference in New Issue
Block a user