Loading graphics/java/android/graphics/FontFamily.java +14 −10 Original line number Diff line number Diff line Loading @@ -45,15 +45,17 @@ public class FontFamily { private static String TAG = "FontFamily"; private @Nullable Runnable mNativeBuilderCleaner; private static class NoImagePreloadHolder { private static final NativeAllocationRegistry sBuilderRegistry = NativeAllocationRegistry.createMalloced( FontFamily.class.getClassLoader(), nGetBuilderReleaseFunc()); private @Nullable Runnable mNativeBuilderCleaner; private static final NativeAllocationRegistry sFamilyRegistry = NativeAllocationRegistry.createMalloced( FontFamily.class.getClassLoader(), nGetFamilyReleaseFunc()); } /** * @hide Loading @@ -74,7 +76,8 @@ public class FontFamily { publicAlternatives = "Use {@link android.graphics.fonts.FontFamily} instead.") public FontFamily() { mBuilderPtr = nInitBuilder(null, 0); mNativeBuilderCleaner = sBuilderRegistry.registerNativeAllocation(this, mBuilderPtr); mNativeBuilderCleaner = NoImagePreloadHolder.sBuilderRegistry.registerNativeAllocation(this, mBuilderPtr); } /** Loading @@ -92,7 +95,8 @@ public class FontFamily { langsString = TextUtils.join(",", langs); } mBuilderPtr = nInitBuilder(langsString, variant); mNativeBuilderCleaner = sBuilderRegistry.registerNativeAllocation(this, mBuilderPtr); mNativeBuilderCleaner = NoImagePreloadHolder.sBuilderRegistry.registerNativeAllocation(this, mBuilderPtr); } /** Loading @@ -113,7 +117,7 @@ public class FontFamily { mNativeBuilderCleaner.run(); mBuilderPtr = 0; if (mNativePtr != 0) { sFamilyRegistry.registerNativeAllocation(this, mNativePtr); NoImagePreloadHolder.sFamilyRegistry.registerNativeAllocation(this, mNativePtr); } return mNativePtr != 0; } Loading graphics/java/android/graphics/fonts/Font.java +11 −9 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ public final class Font { private static final int STYLE_ITALIC = 1; private static final int STYLE_NORMAL = 0; private static class NoImagePreloadHolder { private static final NativeAllocationRegistry BUFFER_REGISTRY = NativeAllocationRegistry.createMalloced( ByteBuffer.class.getClassLoader(), nGetReleaseNativeFont()); Loading @@ -68,6 +69,7 @@ public final class Font { private static final NativeAllocationRegistry FONT_REGISTRY = NativeAllocationRegistry.createMalloced(Font.class.getClassLoader(), nGetReleaseNativeFont()); } /** * A builder class for creating new Font. Loading Loading @@ -530,7 +532,7 @@ public final class Font { public Font(long nativePtr) { mNativePtr = nativePtr; FONT_REGISTRY.registerNativeAllocation(this, mNativePtr); NoImagePreloadHolder.FONT_REGISTRY.registerNativeAllocation(this, mNativePtr); } /** Loading @@ -551,7 +553,7 @@ public final class Font { ByteBuffer fromNative = nNewByteBuffer(mNativePtr); // Bind ByteBuffer's lifecycle with underlying font object. BUFFER_REGISTRY.registerNativeAllocation(fromNative, ref); NoImagePreloadHolder.BUFFER_REGISTRY.registerNativeAllocation(fromNative, ref); // JNI NewDirectBuffer creates writable ByteBuffer even if it is mmaped readonly. mBuffer = fromNative.asReadOnlyBuffer(); Loading graphics/java/android/graphics/fonts/FontFamily.java +6 −4 Original line number Diff line number Diff line Loading @@ -73,9 +73,11 @@ public final class FontFamily { * A builder class for creating new FontFamily. */ public static final class Builder { private static final NativeAllocationRegistry sFamilyRegistory = private static class NoImagePreloadHolder { private static final NativeAllocationRegistry sFamilyRegistry = NativeAllocationRegistry.createMalloced(FontFamily.class.getClassLoader(), nGetReleaseNativeFamily()); } private final ArrayList<Font> mFonts = new ArrayList<>(); // Most FontFamily only has regular, bold, italic, bold-italic. Thus 4 should be good for Loading Loading @@ -183,7 +185,7 @@ public final class FontFamily { final long ptr = nBuild(builderPtr, langTags, variant, isCustomFallback, isDefaultFallback, variableFamilyType); final FontFamily family = new FontFamily(ptr); sFamilyRegistory.registerNativeAllocation(family, ptr); NoImagePreloadHolder.sFamilyRegistry.registerNativeAllocation(family, ptr); return family; } Loading graphics/java/android/graphics/text/LineBreaker.java +6 −4 Original line number Diff line number Diff line Loading @@ -480,9 +480,11 @@ public class LineBreaker { } } private static class NoImagePreloadHolder { private static final NativeAllocationRegistry sRegistry = NativeAllocationRegistry.createMalloced( LineBreaker.class.getClassLoader(), nGetReleaseFunc()); } private final long mNativePtr; Loading @@ -494,7 +496,7 @@ public class LineBreaker { @Nullable int[] indents, boolean useBoundsForWidth) { mNativePtr = nInit(breakStrategy, hyphenationFrequency, justify == JUSTIFICATION_MODE_INTER_WORD, indents, useBoundsForWidth); sRegistry.registerNativeAllocation(this, mNativePtr); NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mNativePtr); } /** Loading graphics/java/android/graphics/text/PositionedGlyphs.java +6 −4 Original line number Diff line number Diff line Loading @@ -46,9 +46,11 @@ import java.util.Objects; * @see TextRunShaper#shapeTextRun(CharSequence, int, int, int, int, float, float, boolean, Paint) */ public final class PositionedGlyphs { private static class NoImagePreloadHolder { private static final NativeAllocationRegistry REGISTRY = NativeAllocationRegistry.createMalloced( Typeface.class.getClassLoader(), nReleaseFunc()); } private final long mLayoutPtr; private final float mXOffset; Loading Loading @@ -259,7 +261,7 @@ public final class PositionedGlyphs { mFonts.add(prevFont); } REGISTRY.registerNativeAllocation(this, layoutPtr); NoImagePreloadHolder.REGISTRY.registerNativeAllocation(this, layoutPtr); } @CriticalNative Loading Loading
graphics/java/android/graphics/FontFamily.java +14 −10 Original line number Diff line number Diff line Loading @@ -45,15 +45,17 @@ public class FontFamily { private static String TAG = "FontFamily"; private @Nullable Runnable mNativeBuilderCleaner; private static class NoImagePreloadHolder { private static final NativeAllocationRegistry sBuilderRegistry = NativeAllocationRegistry.createMalloced( FontFamily.class.getClassLoader(), nGetBuilderReleaseFunc()); private @Nullable Runnable mNativeBuilderCleaner; private static final NativeAllocationRegistry sFamilyRegistry = NativeAllocationRegistry.createMalloced( FontFamily.class.getClassLoader(), nGetFamilyReleaseFunc()); } /** * @hide Loading @@ -74,7 +76,8 @@ public class FontFamily { publicAlternatives = "Use {@link android.graphics.fonts.FontFamily} instead.") public FontFamily() { mBuilderPtr = nInitBuilder(null, 0); mNativeBuilderCleaner = sBuilderRegistry.registerNativeAllocation(this, mBuilderPtr); mNativeBuilderCleaner = NoImagePreloadHolder.sBuilderRegistry.registerNativeAllocation(this, mBuilderPtr); } /** Loading @@ -92,7 +95,8 @@ public class FontFamily { langsString = TextUtils.join(",", langs); } mBuilderPtr = nInitBuilder(langsString, variant); mNativeBuilderCleaner = sBuilderRegistry.registerNativeAllocation(this, mBuilderPtr); mNativeBuilderCleaner = NoImagePreloadHolder.sBuilderRegistry.registerNativeAllocation(this, mBuilderPtr); } /** Loading @@ -113,7 +117,7 @@ public class FontFamily { mNativeBuilderCleaner.run(); mBuilderPtr = 0; if (mNativePtr != 0) { sFamilyRegistry.registerNativeAllocation(this, mNativePtr); NoImagePreloadHolder.sFamilyRegistry.registerNativeAllocation(this, mNativePtr); } return mNativePtr != 0; } Loading
graphics/java/android/graphics/fonts/Font.java +11 −9 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ public final class Font { private static final int STYLE_ITALIC = 1; private static final int STYLE_NORMAL = 0; private static class NoImagePreloadHolder { private static final NativeAllocationRegistry BUFFER_REGISTRY = NativeAllocationRegistry.createMalloced( ByteBuffer.class.getClassLoader(), nGetReleaseNativeFont()); Loading @@ -68,6 +69,7 @@ public final class Font { private static final NativeAllocationRegistry FONT_REGISTRY = NativeAllocationRegistry.createMalloced(Font.class.getClassLoader(), nGetReleaseNativeFont()); } /** * A builder class for creating new Font. Loading Loading @@ -530,7 +532,7 @@ public final class Font { public Font(long nativePtr) { mNativePtr = nativePtr; FONT_REGISTRY.registerNativeAllocation(this, mNativePtr); NoImagePreloadHolder.FONT_REGISTRY.registerNativeAllocation(this, mNativePtr); } /** Loading @@ -551,7 +553,7 @@ public final class Font { ByteBuffer fromNative = nNewByteBuffer(mNativePtr); // Bind ByteBuffer's lifecycle with underlying font object. BUFFER_REGISTRY.registerNativeAllocation(fromNative, ref); NoImagePreloadHolder.BUFFER_REGISTRY.registerNativeAllocation(fromNative, ref); // JNI NewDirectBuffer creates writable ByteBuffer even if it is mmaped readonly. mBuffer = fromNative.asReadOnlyBuffer(); Loading
graphics/java/android/graphics/fonts/FontFamily.java +6 −4 Original line number Diff line number Diff line Loading @@ -73,9 +73,11 @@ public final class FontFamily { * A builder class for creating new FontFamily. */ public static final class Builder { private static final NativeAllocationRegistry sFamilyRegistory = private static class NoImagePreloadHolder { private static final NativeAllocationRegistry sFamilyRegistry = NativeAllocationRegistry.createMalloced(FontFamily.class.getClassLoader(), nGetReleaseNativeFamily()); } private final ArrayList<Font> mFonts = new ArrayList<>(); // Most FontFamily only has regular, bold, italic, bold-italic. Thus 4 should be good for Loading Loading @@ -183,7 +185,7 @@ public final class FontFamily { final long ptr = nBuild(builderPtr, langTags, variant, isCustomFallback, isDefaultFallback, variableFamilyType); final FontFamily family = new FontFamily(ptr); sFamilyRegistory.registerNativeAllocation(family, ptr); NoImagePreloadHolder.sFamilyRegistry.registerNativeAllocation(family, ptr); return family; } Loading
graphics/java/android/graphics/text/LineBreaker.java +6 −4 Original line number Diff line number Diff line Loading @@ -480,9 +480,11 @@ public class LineBreaker { } } private static class NoImagePreloadHolder { private static final NativeAllocationRegistry sRegistry = NativeAllocationRegistry.createMalloced( LineBreaker.class.getClassLoader(), nGetReleaseFunc()); } private final long mNativePtr; Loading @@ -494,7 +496,7 @@ public class LineBreaker { @Nullable int[] indents, boolean useBoundsForWidth) { mNativePtr = nInit(breakStrategy, hyphenationFrequency, justify == JUSTIFICATION_MODE_INTER_WORD, indents, useBoundsForWidth); sRegistry.registerNativeAllocation(this, mNativePtr); NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mNativePtr); } /** Loading
graphics/java/android/graphics/text/PositionedGlyphs.java +6 −4 Original line number Diff line number Diff line Loading @@ -46,9 +46,11 @@ import java.util.Objects; * @see TextRunShaper#shapeTextRun(CharSequence, int, int, int, int, float, float, boolean, Paint) */ public final class PositionedGlyphs { private static class NoImagePreloadHolder { private static final NativeAllocationRegistry REGISTRY = NativeAllocationRegistry.createMalloced( Typeface.class.getClassLoader(), nReleaseFunc()); } private final long mLayoutPtr; private final float mXOffset; Loading Loading @@ -259,7 +261,7 @@ public final class PositionedGlyphs { mFonts.add(prevFont); } REGISTRY.registerNativeAllocation(this, layoutPtr); NoImagePreloadHolder.REGISTRY.registerNativeAllocation(this, layoutPtr); } @CriticalNative Loading