summaryrefslogtreecommitdiffstats
path: root/graphics/java/android/graphics/Typeface.java
diff options
context:
space:
mode:
authorAshok Bhat <ashok.bhat@arm.com>2014-01-20 20:08:01 +0000
committerNarayan Kamath <narayan@google.com>2014-01-27 13:28:16 +0000
commit18b4cbeedef21c1fa666a110a157bab66edff976 (patch)
tree03ee1d020f152fe0206816e272bc11c032508554 /graphics/java/android/graphics/Typeface.java
parent4507ea9e3cabcf68f250da20c10cf0edcb6eb3f2 (diff)
downloadframeworks_base-18b4cbeedef21c1fa666a110a157bab66edff976.zip
frameworks_base-18b4cbeedef21c1fa666a110a157bab66edff976.tar.gz
frameworks_base-18b4cbeedef21c1fa666a110a157bab66edff976.tar.bz2
AArch64: Make graphics classes 64-bit compatible
This a merger of two commits submitted to AOSP by the following authors: ashok.bhat@arm.com, david.butcher@arm.coma craig.barber@arm.com, kevin.petit@arm.com and marcus.oakland@arm.com Due to the very large number of internal conflicts, I have chosen to cherry-pick this change instead of letting it merge through AOSP because the merge conflict resolution would be very hard to review. Commit messages below: ================================================ AArch64: Make graphics classes 64-bit compatible Changes in this patch include [x] Long is used to store native pointers as they can be 64-bit. [x] Some minor changes have been done to conform with standard JNI practice (e.g. use of jint instead of int in JNI function prototypes) [x] AssetAtlasManager is not completely 64-bit compatible yet. Specifically mAtlasMap member has to be converted to hold native pointer using long. Added a TODO to AssetAtlasManager.java to indicate the change required. Signed-off-by: Ashok Bhat <ashok.bhat@arm.com> Signed-off-by: Craig Barber <craig.barber@arm.com> Signed-off-by: Kévin PETIT <kevin.petit@arm.com> Signed-off-by: Marcus Oakland <marcus.oakland@arm.com> ================================================================== AArch64: Use long for pointers in graphics/Camera For storing pointers, long is used in android/graphics/Camera class, as native pointers can be 64-bit. In addition, some minor changes have been done to conform with standard JNI practice (e.g. use of jint instead of int in JNI function prototypes) Signed-off-by: Ashok Bhat <ashok.bhat@arm.com> Signed-off-by: Marcus Oakland <marcus.oakland@arm.com> =================================================================== Change-Id: Ib3eab85ed97ea3e3c227617c20f8d213f17d4ba0
Diffstat (limited to 'graphics/java/android/graphics/Typeface.java')
-rw-r--r--graphics/java/android/graphics/Typeface.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java
index aea3ee5..73e0e8d 100644
--- a/graphics/java/android/graphics/Typeface.java
+++ b/graphics/java/android/graphics/Typeface.java
@@ -18,6 +18,7 @@ package android.graphics;
import android.content.res.AssetManager;
import android.util.SparseArray;
+import android.util.LongSparseArray;
import java.io.File;
@@ -45,13 +46,13 @@ public class Typeface {
public static final Typeface MONOSPACE;
static Typeface[] sDefaults;
- private static final SparseArray<SparseArray<Typeface>> sTypefaceCache =
- new SparseArray<SparseArray<Typeface>>(3);
+ private static final LongSparseArray<SparseArray<Typeface>> sTypefaceCache =
+ new LongSparseArray<SparseArray<Typeface>>(3);
/**
* @hide
*/
- public int native_instance;
+ public long native_instance;
// Style
public static final int NORMAL = 0;
@@ -103,7 +104,7 @@ public class Typeface {
* @return The best matching typeface.
*/
public static Typeface create(Typeface family, int style) {
- int ni = 0;
+ long ni = 0;
if (family != null) {
// Return early if we're asked for the same face/style
if (family.mStyle == style) {
@@ -173,7 +174,7 @@ public class Typeface {
}
// don't allow clients to call this directly
- private Typeface(int ni) {
+ private Typeface(long ni) {
if (ni == 0) {
throw new RuntimeException("native typeface cannot be made");
}
@@ -217,15 +218,20 @@ public class Typeface {
@Override
public int hashCode() {
- int result = native_instance;
+ /*
+ * Modified method for hashCode with long native_instance derived from
+ * http://developer.android.com/reference/java/lang/Object.html
+ */
+ int result = 17;
+ result = 31 * result + (int) (native_instance ^ (native_instance >>> 32));
result = 31 * result + mStyle;
return result;
}
- private static native int nativeCreate(String familyName, int style);
- private static native int nativeCreateFromTypeface(int native_instance, int style);
- private static native void nativeUnref(int native_instance);
- private static native int nativeGetStyle(int native_instance);
- private static native int nativeCreateFromAsset(AssetManager mgr, String path);
- private static native int nativeCreateFromFile(String path);
+ private static native long nativeCreate(String familyName, int style);
+ private static native long nativeCreateFromTypeface(long native_instance, int style);
+ private static native void nativeUnref(long native_instance);
+ private static native int nativeGetStyle(long native_instance);
+ private static native long nativeCreateFromAsset(AssetManager mgr, String path);
+ private static native long nativeCreateFromFile(String path);
}