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

Commit 44fa7cbf authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Register native allocation for Font

In the ag/13482285, accidentally removed font native allocation.
The native bound instance should be unref-ed when the Java font
object is GC-ed.

Bug: 179942558
Test: N/A
Change-Id: I19312844856f19a2e3abf717a7563a0812c9266d
parent 1a8b2fdd
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -63,6 +63,10 @@ public final class Font {
            NativeAllocationRegistry.createMalloced(
            NativeAllocationRegistry.createMalloced(
                    ByteBuffer.class.getClassLoader(), nGetReleaseNativeFont());
                    ByteBuffer.class.getClassLoader(), nGetReleaseNativeFont());


    private static final NativeAllocationRegistry FONT_REGISTRY =
            NativeAllocationRegistry.createMalloced(Font.class.getClassLoader(),
                    nGetReleaseNativeFont());

    private static final Object SOURCE_ID_LOCK = new Object();
    private static final Object SOURCE_ID_LOCK = new Object();
    @GuardedBy("SOURCE_ID_LOCK")
    @GuardedBy("SOURCE_ID_LOCK")
    private static final LongSparseLongArray FONT_SOURCE_ID_MAP =
    private static final LongSparseLongArray FONT_SOURCE_ID_MAP =
@@ -526,11 +530,14 @@ public final class Font {
     * Use Builder instead
     * Use Builder instead
     *
     *
     * Caller must increment underlying minikin::Font ref count.
     * Caller must increment underlying minikin::Font ref count.
     * This class takes the ownership of the passing native objects.
     *
     *
     * @hide
     * @hide
     */
     */
    public Font(long nativePtr) {
    public Font(long nativePtr) {
        mNativePtr = nativePtr;
        mNativePtr = nativePtr;

        FONT_REGISTRY.registerNativeAllocation(this, mNativePtr);
    }
    }


    /**
    /**