Introduce getSourceIdentifier instead of isSameSource.

After some experiment, equality function is not enough for
high performance animation. To use native glyph cache efficiently,
need to cache the Font object during font variation animations.
This identifier will be used for the key of the cache.

Bug: 171911683
Test: atest FontTest
Change-Id: Idbaa1bc83aea2c6af82641bd7d3a553f2cfe4793
diff --git a/libs/hwui/jni/fonts/Font.cpp b/libs/hwui/jni/fonts/Font.cpp
index 4aee6b9..21fcd2f 100644
--- a/libs/hwui/jni/fonts/Font.cpp
+++ b/libs/hwui/jni/fonts/Font.cpp
@@ -239,13 +239,10 @@
 }
 
 // Critical Native
-static jboolean Font_isSameBufferAddress(CRITICAL_JNI_PARAMS_COMMA jlong lFontHandle,
-                                         jlong rFontHandle) {
-    FontWrapper* lFont = reinterpret_cast<FontWrapper*>(lFontHandle);
-    FontWrapper* rFont = reinterpret_cast<FontWrapper*>(rFontHandle);
-    const void* lBufferPtr = lFont->font->typeface()->GetFontData();
-    const void* rBufferPtr = rFont->font->typeface()->GetFontData();
-    return lBufferPtr == rBufferPtr;
+static jlong Font_GetBufferAddress(CRITICAL_JNI_PARAMS_COMMA jlong fontHandle) {
+    FontWrapper* font = reinterpret_cast<FontWrapper*>(fontHandle);
+    const void* bufferPtr = font->font->typeface()->GetFontData();
+    return reinterpret_cast<jlong>(bufferPtr);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -297,7 +294,7 @@
     { "nGetAxisInfo", "(JI)J", (void*) Font_getAxisInfo },
     { "nGetFontPath", "(J)Ljava/lang/String;", (void*) Font_getFontPath },
     { "nGetNativeFontPtr", "(J)J", (void*) Font_getNativeFontPtr },
-    { "nIsSameBufferAddress", "(JJ)Z", (void*) Font_isSameBufferAddress },
+    { "nGetFontBufferAddress", "(J)J", (void*) Font_GetBufferAddress },
 };
 
 static const JNINativeMethod gFontBufferHelperMethods[] = {