diff options
291 files changed, 5390 insertions, 4306 deletions
diff --git a/api/current.txt b/api/current.txt index 8e69592..50337c0 100644 --- a/api/current.txt +++ b/api/current.txt @@ -11027,7 +11027,10 @@ package android.hardware.usb { method public int getDeviceSubclass(); method public android.hardware.usb.UsbInterface getInterface(int); method public int getInterfaceCount(); + method public java.lang.String getManufacturerName(); method public int getProductId(); + method public java.lang.String getProductName(); + method public java.lang.String getSerialNumber(); method public int getVendorId(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; @@ -17648,6 +17651,7 @@ package android.os { method public static void startMethodTracing(java.lang.String); method public static void startMethodTracing(java.lang.String, int); method public static void startMethodTracing(java.lang.String, int, int); + method public static void startMethodTracingSampling(java.lang.String, int, int); method public static void startNativeTracing(); method public static deprecated void stopAllocCounting(); method public static void stopMethodTracing(); diff --git a/core/java/android/animation/PropertyValuesHolder.java b/core/java/android/animation/PropertyValuesHolder.java index 43014ad..21f6eda 100644 --- a/core/java/android/animation/PropertyValuesHolder.java +++ b/core/java/android/animation/PropertyValuesHolder.java @@ -743,9 +743,9 @@ public class PropertyValuesHolder implements Cloneable { static class IntPropertyValuesHolder extends PropertyValuesHolder { // Cache JNI functions to avoid looking them up twice - private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap = - new HashMap<Class, HashMap<String, Integer>>(); - int mJniSetter; + private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap = + new HashMap<Class, HashMap<String, Long>>(); + long mJniSetter; private IntProperty mIntProperty; IntKeyframeSet mIntKeyframeSet; @@ -845,11 +845,11 @@ public class PropertyValuesHolder implements Cloneable { // Check new static hashmap<propName, int> for setter method try { mPropertyMapLock.writeLock().lock(); - HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass); + HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass); if (propertyMap != null) { - Integer mJniSetterInteger = propertyMap.get(mPropertyName); - if (mJniSetterInteger != null) { - mJniSetter = mJniSetterInteger; + Long jniSetter = propertyMap.get(mPropertyName); + if (jniSetter != null) { + mJniSetter = jniSetter; } } if (mJniSetter == 0) { @@ -857,7 +857,7 @@ public class PropertyValuesHolder implements Cloneable { mJniSetter = nGetIntMethod(targetClass, methodName); if (mJniSetter != 0) { if (propertyMap == null) { - propertyMap = new HashMap<String, Integer>(); + propertyMap = new HashMap<String, Long>(); sJNISetterPropertyMap.put(targetClass, propertyMap); } propertyMap.put(mPropertyName, mJniSetter); @@ -880,9 +880,9 @@ public class PropertyValuesHolder implements Cloneable { static class FloatPropertyValuesHolder extends PropertyValuesHolder { // Cache JNI functions to avoid looking them up twice - private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap = - new HashMap<Class, HashMap<String, Integer>>(); - int mJniSetter; + private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap = + new HashMap<Class, HashMap<String, Long>>(); + long mJniSetter; private FloatProperty mFloatProperty; FloatKeyframeSet mFloatKeyframeSet; @@ -982,11 +982,11 @@ public class PropertyValuesHolder implements Cloneable { // Check new static hashmap<propName, int> for setter method try { mPropertyMapLock.writeLock().lock(); - HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass); + HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass); if (propertyMap != null) { - Integer mJniSetterInteger = propertyMap.get(mPropertyName); - if (mJniSetterInteger != null) { - mJniSetter = mJniSetterInteger; + Long jniSetter = propertyMap.get(mPropertyName); + if (jniSetter != null) { + mJniSetter = jniSetter; } } if (mJniSetter == 0) { @@ -994,7 +994,7 @@ public class PropertyValuesHolder implements Cloneable { mJniSetter = nGetFloatMethod(targetClass, methodName); if (mJniSetter != 0) { if (propertyMap == null) { - propertyMap = new HashMap<String, Integer>(); + propertyMap = new HashMap<String, Long>(); sJNISetterPropertyMap.put(targetClass, propertyMap); } propertyMap.put(mPropertyName, mJniSetter); @@ -1015,8 +1015,8 @@ public class PropertyValuesHolder implements Cloneable { } - native static private int nGetIntMethod(Class targetClass, String methodName); - native static private int nGetFloatMethod(Class targetClass, String methodName); - native static private void nCallIntMethod(Object target, int methodID, int arg); - native static private void nCallFloatMethod(Object target, int methodID, float arg); -}
\ No newline at end of file + native static private long nGetIntMethod(Class targetClass, String methodName); + native static private long nGetFloatMethod(Class targetClass, String methodName); + native static private void nCallIntMethod(Object target, long methodID, int arg); + native static private void nCallFloatMethod(Object target, long methodID, float arg); +} diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index d849965..97baf9a 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -96,6 +96,8 @@ import com.android.internal.util.FastPrintWriter; import com.android.org.conscrypt.OpenSSLSocketImpl; import com.google.android.collect.Lists; +import dalvik.system.VMRuntime; + import java.io.File; import java.io.FileDescriptor; import java.io.FileOutputStream; @@ -740,6 +742,9 @@ public final class ActivityThread { setCoreSettings(coreSettings); + // Tell the VMRuntime about the application. + VMRuntime.registerAppInfo(appInfo.dataDir, appInfo.processName); + AppBindData data = new AppBindData(); data.processName = processName; data.appInfo = appInfo; diff --git a/core/java/android/app/NativeActivity.java b/core/java/android/app/NativeActivity.java index 4ca3747..2e05edb 100644 --- a/core/java/android/app/NativeActivity.java +++ b/core/java/android/app/NativeActivity.java @@ -76,7 +76,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2, private NativeContentView mNativeContentView; private InputMethodManager mIMM; - private int mNativeHandle; + private long mNativeHandle; private InputQueue mCurInputQueue; private SurfaceHolder mCurSurfaceHolder; @@ -91,27 +91,26 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2, private boolean mDestroyed; - private native int loadNativeCode(String path, String funcname, MessageQueue queue, + private native long loadNativeCode(String path, String funcname, MessageQueue queue, String internalDataPath, String obbPath, String externalDataPath, int sdkVersion, AssetManager assetMgr, byte[] savedState); - private native void unloadNativeCode(int handle); - - private native void onStartNative(int handle); - private native void onResumeNative(int handle); - private native byte[] onSaveInstanceStateNative(int handle); - private native void onPauseNative(int handle); - private native void onStopNative(int handle); - private native void onConfigurationChangedNative(int handle); - private native void onLowMemoryNative(int handle); - private native void onWindowFocusChangedNative(int handle, boolean focused); - private native void onSurfaceCreatedNative(int handle, Surface surface); - private native void onSurfaceChangedNative(int handle, Surface surface, + private native void unloadNativeCode(long handle); + private native void onStartNative(long handle); + private native void onResumeNative(long handle); + private native byte[] onSaveInstanceStateNative(long handle); + private native void onPauseNative(long handle); + private native void onStopNative(long handle); + private native void onConfigurationChangedNative(long handle); + private native void onLowMemoryNative(long handle); + private native void onWindowFocusChangedNative(long handle, boolean focused); + private native void onSurfaceCreatedNative(long handle, Surface surface); + private native void onSurfaceChangedNative(long handle, Surface surface, int format, int width, int height); - private native void onSurfaceRedrawNeededNative(int handle, Surface surface); - private native void onSurfaceDestroyedNative(int handle); - private native void onInputQueueCreatedNative(int handle, int queuePtr); - private native void onInputQueueDestroyedNative(int handle, int queuePtr); - private native void onContentRectChangedNative(int handle, int x, int y, int w, int h); + private native void onSurfaceRedrawNeededNative(long handle, Surface surface); + private native void onSurfaceDestroyedNative(long handle); + private native void onInputQueueCreatedNative(long handle, long queuePtr); + private native void onInputQueueDestroyedNative(long handle, long queuePtr); + private native void onContentRectChangedNative(long handle, int x, int y, int w, int h); static class NativeContentView extends View { NativeActivity mActivity; diff --git a/core/java/android/app/SharedPreferencesImpl.java b/core/java/android/app/SharedPreferencesImpl.java index 86fd7b9..a292ecb 100644 --- a/core/java/android/app/SharedPreferencesImpl.java +++ b/core/java/android/app/SharedPreferencesImpl.java @@ -421,13 +421,15 @@ final class SharedPreferencesImpl implements SharedPreferences { for (Map.Entry<String, Object> e : mModified.entrySet()) { String k = e.getKey(); Object v = e.getValue(); - if (v == this) { // magic value for a removal mutation + // "this" is the magic value for a removal mutation. In addition, + // setting a value to "null" for a given key is specified to be + // equivalent to calling remove on that key. + if (v == this || v == null) { if (!mMap.containsKey(k)) { continue; } mMap.remove(k); } else { - boolean isSame = false; if (mMap.containsKey(k)) { Object existingValue = mMap.get(k); if (existingValue != null && existingValue.equals(v)) { diff --git a/core/java/android/app/backup/BackupDataInput.java b/core/java/android/app/backup/BackupDataInput.java index 43b920a..03205fb 100644 --- a/core/java/android/app/backup/BackupDataInput.java +++ b/core/java/android/app/backup/BackupDataInput.java @@ -59,7 +59,7 @@ import java.io.IOException; * }</pre> */ public class BackupDataInput { - int mBackupReader; + long mBackupReader; private EntityHeader mHeader = new EntityHeader(); private boolean mHeaderReady; @@ -185,10 +185,10 @@ public class BackupDataInput { } } - private native static int ctor(FileDescriptor fd); - private native static void dtor(int mBackupReader); + private native static long ctor(FileDescriptor fd); + private native static void dtor(long mBackupReader); - private native int readNextHeader_native(int mBackupReader, EntityHeader entity); - private native int readEntityData_native(int mBackupReader, byte[] data, int offset, int size); - private native int skipEntityData_native(int mBackupReader); + private native int readNextHeader_native(long mBackupReader, EntityHeader entity); + private native int readEntityData_native(long mBackupReader, byte[] data, int offset, int size); + private native int skipEntityData_native(long mBackupReader); } diff --git a/core/java/android/app/backup/BackupDataOutput.java b/core/java/android/app/backup/BackupDataOutput.java index 22668b6..3a070b6 100644 --- a/core/java/android/app/backup/BackupDataOutput.java +++ b/core/java/android/app/backup/BackupDataOutput.java @@ -62,7 +62,7 @@ import java.io.IOException; * @see BackupAgent */ public class BackupDataOutput { - int mBackupWriter; + long mBackupWriter; /** @hide */ public BackupDataOutput(FileDescriptor fd) { @@ -121,11 +121,11 @@ public class BackupDataOutput { } } - private native static int ctor(FileDescriptor fd); - private native static void dtor(int mBackupWriter); + private native static long ctor(FileDescriptor fd); + private native static void dtor(long mBackupWriter); - private native static int writeEntityHeader_native(int mBackupWriter, String key, int dataSize); - private native static int writeEntityData_native(int mBackupWriter, byte[] data, int size); - private native static void setKeyPrefix_native(int mBackupWriter, String keyPrefix); + private native static int writeEntityHeader_native(long mBackupWriter, String key, int dataSize); + private native static int writeEntityData_native(long mBackupWriter, byte[] data, int size); + private native static void setKeyPrefix_native(long mBackupWriter, String keyPrefix); } diff --git a/core/java/android/app/backup/FileBackupHelperBase.java b/core/java/android/app/backup/FileBackupHelperBase.java index 887a2e6..4ed5197 100644 --- a/core/java/android/app/backup/FileBackupHelperBase.java +++ b/core/java/android/app/backup/FileBackupHelperBase.java @@ -29,7 +29,7 @@ import java.io.FileDescriptor; class FileBackupHelperBase { private static final String TAG = "FileBackupHelperBase"; - int mPtr; + long mPtr; Context mContext; boolean mExceptionLogged; @@ -115,14 +115,13 @@ class FileBackupHelperBase { return false; } - private static native int ctor(); - private static native void dtor(int ptr); + private static native long ctor(); + private static native void dtor(long ptr); native private static int performBackup_native(FileDescriptor oldState, - int data, FileDescriptor newState, String[] files, String[] keys); - - private static native int writeFile_native(int ptr, String filename, int backupReader); - private static native int writeSnapshot_native(int ptr, FileDescriptor fd); + long data, FileDescriptor newState, String[] files, String[] keys); + private static native int writeFile_native(long ptr, String filename, long backupReader); + private static native int writeSnapshot_native(long ptr, FileDescriptor fd); } diff --git a/core/java/android/content/ContentProviderNative.java b/core/java/android/content/ContentProviderNative.java index bcf0b63..39286d6 100644 --- a/core/java/android/content/ContentProviderNative.java +++ b/core/java/android/content/ContentProviderNative.java @@ -112,17 +112,24 @@ abstract public class ContentProviderNative extends Binder implements IContentPr Cursor cursor = query(callingPkg, url, projection, selection, selectionArgs, sortOrder, cancellationSignal); if (cursor != null) { + CursorToBulkCursorAdaptor adaptor = null; + try { - CursorToBulkCursorAdaptor adaptor = new CursorToBulkCursorAdaptor( - cursor, observer, getProviderName()); - BulkCursorDescriptor d = adaptor.getBulkCursorDescriptor(); + adaptor = new CursorToBulkCursorAdaptor(cursor, observer, + getProviderName()); cursor = null; + BulkCursorDescriptor d = adaptor.getBulkCursorDescriptor(); + adaptor = null; + reply.writeNoException(); reply.writeInt(1); d.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); } finally { // Close cursor if an exception was thrown while constructing the adaptor. + if (adaptor != null) { + adaptor.close(); + } if (cursor != null) { cursor.close(); } diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index fc9e486..93ce633 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -70,7 +70,6 @@ public final class AssetManager { // For communication with native code. private int mObject; - private int mNObject; // used by the NDK private StringBlock mStringBlocks[] = null; @@ -540,6 +539,12 @@ public final class AssetManager { public final int getAssetInt() { return mAsset; } + /** + * @hide + */ + public final long getNativeAsset() { + return mAsset; + } private AssetInputStream(int asset) { mAsset = asset; diff --git a/core/java/android/database/CursorWindow.java b/core/java/android/database/CursorWindow.java index f1f3017..197e3ff 100644 --- a/core/java/android/database/CursorWindow.java +++ b/core/java/android/database/CursorWindow.java @@ -27,6 +27,7 @@ import android.os.Parcelable; import android.os.Process; import android.util.Log; import android.util.SparseIntArray; +import android.util.LongSparseArray; /** * A buffer containing multiple cursor rows. @@ -52,40 +53,40 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { * The native CursorWindow object pointer. (FOR INTERNAL USE ONLY) * @hide */ - public int mWindowPtr; + public long mWindowPtr; private int mStartPos; private final String mName; private final CloseGuard mCloseGuard = CloseGuard.get(); - private static native int nativeCreate(String name, int cursorWindowSize); - private static native int nativeCreateFromParcel(Parcel parcel); - private static native void nativeDispose(int windowPtr); - private static native void nativeWriteToParcel(int windowPtr, Parcel parcel); + private static native long nativeCreate(String name, int cursorWindowSize); + private static native long nativeCreateFromParcel(Parcel parcel); + private static native void nativeDispose(long windowPtr); + private static native void nativeWriteToParcel(long windowPtr, Parcel parcel); - private static native void nativeClear(int windowPtr); + private static native void nativeClear(long windowPtr); - private static native int nativeGetNumRows(int windowPtr); - private static native boolean nativeSetNumColumns(int windowPtr, int columnNum); - private static native boolean nativeAllocRow(int windowPtr); - private static native void nativeFreeLastRow(int windowPtr); + private static native int nativeGetNumRows(long windowPtr); + private static native boolean nativeSetNumColumns(long windowPtr, int columnNum); + private static native boolean nativeAllocRow(long windowPtr); + private static native void nativeFreeLastRow(long windowPtr); - private static native int nativeGetType(int windowPtr, int row, int column); - private static native byte[] nativeGetBlob(int windowPtr, int row, int column); - private static native String nativeGetString(int windowPtr, int row, int column); - private static native long nativeGetLong(int windowPtr, int row, int column); - private static native double nativeGetDouble(int windowPtr, int row, int column); - private static native void nativeCopyStringToBuffer(int windowPtr, int row, int column, + private static native int nativeGetType(long windowPtr, int row, int column); + private static native byte[] nativeGetBlob(long windowPtr, int row, int column); + private static native String nativeGetString(long windowPtr, int row, int column); + private static native long nativeGetLong(long windowPtr, int row, int column); + private static native double nativeGetDouble(long windowPtr, int row, int column); + private static native void nativeCopyStringToBuffer(long windowPtr, int row, int column, CharArrayBuffer buffer); - private static native boolean nativePutBlob(int windowPtr, byte[] value, int row, int column); - private static native boolean nativePutString(int windowPtr, String value, int row, int column); - private static native boolean nativePutLong(int windowPtr, long value, int row, int column); - private static native boolean nativePutDouble(int windowPtr, double value, int row, int column); - private static native boolean nativePutNull(int windowPtr, int row, int column); + private static native boolean nativePutBlob(long windowPtr, byte[] value, int row, int column); + private static native boolean nativePutString(long windowPtr, String value, int row, int column); + private static native boolean nativePutLong(long windowPtr, long value, int row, int column); + private static native boolean nativePutDouble(long windowPtr, double value, int row, int column); + private static native boolean nativePutNull(long windowPtr, int row, int column); - private static native String nativeGetName(int windowPtr); + private static native String nativeGetName(long windowPtr); /** * Creates a new empty cursor window and gives it a name. @@ -713,9 +714,9 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { dispose(); } - private static final SparseIntArray sWindowToPidMap = new SparseIntArray(); + private static final LongSparseArray<Integer> sWindowToPidMap = new LongSparseArray<Integer>(); - private void recordNewWindow(int pid, int window) { + private void recordNewWindow(int pid, long window) { synchronized (sWindowToPidMap) { sWindowToPidMap.put(window, pid); if (Log.isLoggable(STATS_TAG, Log.VERBOSE)) { @@ -724,7 +725,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { } } - private void recordClosingOfWindow(int window) { + private void recordClosingOfWindow(long window) { synchronized (sWindowToPidMap) { if (sWindowToPidMap.size() == 0) { // this means we are not in the ContentProvider. @@ -771,6 +772,6 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { @Override public String toString() { - return getName() + " {" + Integer.toHexString(mWindowPtr) + "}"; + return getName() + " {" + Long.toHexString(mWindowPtr) + "}"; } } diff --git a/core/java/android/database/sqlite/SQLiteConnection.java b/core/java/android/database/sqlite/SQLiteConnection.java index 725a1ff..24a7d33 100644 --- a/core/java/android/database/sqlite/SQLiteConnection.java +++ b/core/java/android/database/sqlite/SQLiteConnection.java @@ -107,7 +107,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen private final OperationLog mRecentOperations = new OperationLog(); // The native SQLiteConnection pointer. (FOR INTERNAL USE ONLY) - private int mConnectionPtr; + private long mConnectionPtr; private boolean mOnlyAllowReadOnlyOperations; @@ -117,45 +117,45 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen // we can ensure that we detach the signal at the right time. private int mCancellationSignalAttachCount; - private static native int nativeOpen(String path, int openFlags, String label, + private static native long nativeOpen(String path, int openFlags, String label, boolean enableTrace, boolean enableProfile); - private static native void nativeClose(int connectionPtr); - private static native void nativeRegisterCustomFunction(int connectionPtr, + private static native void nativeClose(long connectionPtr); + private static native void nativeRegisterCustomFunction(long connectionPtr, SQLiteCustomFunction function); - private static native void nativeRegisterLocalizedCollators(int connectionPtr, String locale); - private static native int nativePrepareStatement(int connectionPtr, String sql); - private static native void nativeFinalizeStatement(int connectionPtr, int statementPtr); - private static native int nativeGetParameterCount(int connectionPtr, int statementPtr); - private static native boolean nativeIsReadOnly(int connectionPtr, int statementPtr); - private static native int nativeGetColumnCount(int connectionPtr, int statementPtr); - private static native String nativeGetColumnName(int connectionPtr, int statementPtr, + private static native void nativeRegisterLocalizedCollators(long connectionPtr, String locale); + private static native long nativePrepareStatement(long connectionPtr, String sql); + private static native void nativeFinalizeStatement(long connectionPtr, long statementPtr); + private static native int nativeGetParameterCount(long connectionPtr, long statementPtr); + private static native boolean nativeIsReadOnly(long connectionPtr, long statementPtr); + private static native int nativeGetColumnCount(long connectionPtr, long statementPtr); + private static native String nativeGetColumnName(long connectionPtr, long statementPtr, int index); - private static native void nativeBindNull(int connectionPtr, int statementPtr, + private static native void nativeBindNull(long connectionPtr, long statementPtr, int index); - private static native void nativeBindLong(int connectionPtr, int statementPtr, + private static native void nativeBindLong(long connectionPtr, long statementPtr, int index, long value); - private static native void nativeBindDouble(int connectionPtr, int statementPtr, + private static native void nativeBindDouble(long connectionPtr, long statementPtr, int index, double value); - private static native void nativeBindString(int connectionPtr, int statementPtr, + private static native void nativeBindString(long connectionPtr, long statementPtr, int index, String value); - private static native void nativeBindBlob(int connectionPtr, int statementPtr, + private static native void nativeBindBlob(long connectionPtr, long statementPtr, int index, byte[] value); private static native void nativeResetStatementAndClearBindings( - int connectionPtr, int statementPtr); - private static native void nativeExecute(int connectionPtr, int statementPtr); - private static native long nativeExecuteForLong(int connectionPtr, int statementPtr); - private static native String nativeExecuteForString(int connectionPtr, int statementPtr); + long connectionPtr, long statementPtr); + private static native void nativeExecute(long connectionPtr, long statementPtr); + private static native long nativeExecuteForLong(long connectionPtr, long statementPtr); + private static native String nativeExecuteForString(long connectionPtr, long statementPtr); private static native int nativeExecuteForBlobFileDescriptor( - int connectionPtr, int statementPtr); - private static native int nativeExecuteForChangedRowCount(int connectionPtr, int statementPtr); + long connectionPtr, long statementPtr); + private static native int nativeExecuteForChangedRowCount(long connectionPtr, long statementPtr); private static native long nativeExecuteForLastInsertedRowId( - int connectionPtr, int statementPtr); + long connectionPtr, long statementPtr); private static native long nativeExecuteForCursorWindow( - int connectionPtr, int statementPtr, int windowPtr, + long connectionPtr, long statementPtr, long windowPtr, int startPos, int requiredPos, boolean countAllRows); - private static native int nativeGetDbLookaside(int connectionPtr); - private static native void nativeCancel(int connectionPtr); - private static native void nativeResetCancel(int connectionPtr, boolean cancelable); + private static native int nativeGetDbLookaside(long connectionPtr); + private static native void nativeCancel(long connectionPtr); + private static native void nativeResetCancel(long connectionPtr, boolean cancelable); private SQLiteConnection(SQLiteConnectionPool pool, SQLiteDatabaseConfiguration configuration, @@ -886,7 +886,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen skipCache = true; } - final int statementPtr = nativePrepareStatement(mConnectionPtr, sql); + final long statementPtr = nativePrepareStatement(mConnectionPtr, sql); try { final int numParameters = nativeGetParameterCount(mConnectionPtr, statementPtr); final int type = DatabaseUtils.getSqlStatementType(sql); @@ -987,7 +987,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen return; } - final int statementPtr = statement.mStatementPtr; + final long statementPtr = statement.mStatementPtr; for (int i = 0; i < count; i++) { final Object arg = bindArgs[i]; switch (DatabaseUtils.getTypeOfObject(arg)) { @@ -1072,7 +1072,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen void dumpUnsafe(Printer printer, boolean verbose) { printer.println("Connection #" + mConnectionId + ":"); if (verbose) { - printer.println(" connectionPtr: 0x" + Integer.toHexString(mConnectionPtr)); + printer.println(" connectionPtr: 0x" + Long.toHexString(mConnectionPtr)); } printer.println(" isPrimaryConnection: " + mIsPrimaryConnection); printer.println(" onlyAllowReadOnlyOperations: " + mOnlyAllowReadOnlyOperations); @@ -1178,7 +1178,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen return "SQLiteConnection: " + mConfiguration.path + " (" + mConnectionId + ")"; } - private PreparedStatement obtainPreparedStatement(String sql, int statementPtr, + private PreparedStatement obtainPreparedStatement(String sql, long statementPtr, int numParameters, int type, boolean readOnly) { PreparedStatement statement = mPreparedStatementPool; if (statement != null) { @@ -1225,7 +1225,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen // The native sqlite3_stmt object pointer. // Lifetime is managed explicitly by the connection. - public int mStatementPtr; + public long mStatementPtr; // The number of parameters that the prepared statement has. public int mNumParameters; @@ -1271,7 +1271,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen if (statement.mInCache) { // might be false due to a race with entryRemoved String sql = entry.getKey(); printer.println(" " + i + ": statementPtr=0x" - + Integer.toHexString(statement.mStatementPtr) + + Long.toHexString(statement.mStatementPtr) + ", numParameters=" + statement.mNumParameters + ", type=" + statement.mType + ", readOnly=" + statement.mReadOnly diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index feb47aa..111062d 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -151,7 +151,7 @@ public class Camera { private static final int CAMERA_MSG_PREVIEW_METADATA = 0x400; private static final int CAMERA_MSG_FOCUS_MOVE = 0x800; - private int mNativeContext; // accessed by native methods + private long mNativeContext; // accessed by native methods private EventHandler mEventHandler; private ShutterCallback mShutterCallback; private PictureCallback mRawImageCallback; diff --git a/core/java/android/hardware/SystemSensorManager.java b/core/java/android/hardware/SystemSensorManager.java index 50fdb41..8684a04 100644 --- a/core/java/android/hardware/SystemSensorManager.java +++ b/core/java/android/hardware/SystemSensorManager.java @@ -222,14 +222,14 @@ public class SystemSensorManager extends SensorManager { * the queues and the listeners. */ private static abstract class BaseEventQueue { - private native int nativeInitBaseEventQueue(BaseEventQueue eventQ, MessageQueue msgQ, + private native long nativeInitBaseEventQueue(BaseEventQueue eventQ, MessageQueue msgQ, float[] scratch); - private static native int nativeEnableSensor(int eventQ, int handle, int rateUs, + private static native int nativeEnableSensor(long eventQ, int handle, int rateUs, int maxBatchReportLatencyUs, int reservedFlags); - private static native int nativeDisableSensor(int eventQ, int handle); - private static native void nativeDestroySensorEventQueue(int eventQ); - private static native int nativeFlushSensor(int eventQ); - private int nSensorEventQueue; + private static native int nativeDisableSensor(long eventQ, int handle); + private static native void nativeDestroySensorEventQueue(long eventQ); + private static native int nativeFlushSensor(long eventQ); + private long nSensorEventQueue; private final SparseBooleanArray mActiveSensors = new SparseBooleanArray(); protected final SparseIntArray mSensorAccuracies = new SparseIntArray(); protected final SparseBooleanArray mFirstEvent = new SparseBooleanArray(); diff --git a/core/java/android/hardware/usb/UsbDevice.java b/core/java/android/hardware/usb/UsbDevice.java index 9bd38f9..d1e63f6 100644 --- a/core/java/android/hardware/usb/UsbDevice.java +++ b/core/java/android/hardware/usb/UsbDevice.java @@ -46,6 +46,9 @@ public class UsbDevice implements Parcelable { private static final String TAG = "UsbDevice"; private final String mName; + private final String mManufacturerName; + private final String mProductName; + private final String mSerialNumber; private final int mVendorId; private final int mProductId; private final int mClass; @@ -58,13 +61,18 @@ public class UsbDevice implements Parcelable { * @hide */ public UsbDevice(String name, int vendorId, int productId, - int Class, int subClass, int protocol, Parcelable[] interfaces) { + int Class, int subClass, int protocol, + String manufacturerName, String productName, String serialNumber, + Parcelable[] interfaces) { mName = name; mVendorId = vendorId; mProductId = productId; mClass = Class; mSubclass = subClass; mProtocol = protocol; + mManufacturerName = manufacturerName; + mProductName = productName; + mSerialNumber = serialNumber; mInterfaces = interfaces; } @@ -80,6 +88,33 @@ public class UsbDevice implements Parcelable { } /** + * Returns the manufacturer name of the device. + * + * @return the manufacturer name + */ + public String getManufacturerName() { + return mManufacturerName; + } + + /** + * Returns the product name of the device. + * + * @return the product name + */ + public String getProductName() { + return mProductName; + } + + /** + * Returns the serial number of the device. + * + * @return the serial number name + */ + public String getSerialNumber() { + return mSerialNumber; + } + + /** * Returns a unique integer ID for the device. * This is a convenience for clients that want to use an integer to represent * the device, rather than the device name. @@ -176,7 +211,8 @@ public class UsbDevice implements Parcelable { return "UsbDevice[mName=" + mName + ",mVendorId=" + mVendorId + ",mProductId=" + mProductId + ",mClass=" + mClass + ",mSubclass=" + mSubclass + ",mProtocol=" + mProtocol + - ",mInterfaces=" + mInterfaces + "]"; + ",mManufacturerName=" + mManufacturerName + ",mProductName=" + mProductName + + ",mSerialNumber=" + mSerialNumber + ",mInterfaces=" + mInterfaces + "]"; } public static final Parcelable.Creator<UsbDevice> CREATOR = @@ -188,8 +224,12 @@ public class UsbDevice implements Parcelable { int clasz = in.readInt(); int subClass = in.readInt(); int protocol = in.readInt(); + String manufacturerName = in.readString(); + String productName = in.readString(); + String serialNumber = in.readString(); Parcelable[] interfaces = in.readParcelableArray(UsbInterface.class.getClassLoader()); - return new UsbDevice(name, vendorId, productId, clasz, subClass, protocol, interfaces); + return new UsbDevice(name, vendorId, productId, clasz, subClass, protocol, + manufacturerName, productName, serialNumber, interfaces); } public UsbDevice[] newArray(int size) { @@ -208,6 +248,9 @@ public class UsbDevice implements Parcelable { parcel.writeInt(mClass); parcel.writeInt(mSubclass); parcel.writeInt(mProtocol); + parcel.writeString(mManufacturerName); + parcel.writeString(mProductName); + parcel.writeString(mSerialNumber); parcel.writeParcelableArray(mInterfaces, 0); } diff --git a/core/java/android/hardware/usb/UsbDeviceConnection.java b/core/java/android/hardware/usb/UsbDeviceConnection.java index b2034b2..389475f 100644 --- a/core/java/android/hardware/usb/UsbDeviceConnection.java +++ b/core/java/android/hardware/usb/UsbDeviceConnection.java @@ -32,7 +32,7 @@ public class UsbDeviceConnection { private final UsbDevice mDevice; // used by the JNI code - private int mNativeContext; + private long mNativeContext; /** * UsbDevice should only be instantiated by UsbService implementation diff --git a/core/java/android/hardware/usb/UsbRequest.java b/core/java/android/hardware/usb/UsbRequest.java index 3646715..ce66084 100644 --- a/core/java/android/hardware/usb/UsbRequest.java +++ b/core/java/android/hardware/usb/UsbRequest.java @@ -37,7 +37,7 @@ public class UsbRequest { private static final String TAG = "UsbRequest"; // used by the JNI code - private int mNativeContext; + private long mNativeContext; private UsbEndpoint mEndpoint; diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index f4a8391..ba71605 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -56,7 +56,7 @@ public class Binder implements IBinder { private static String sDumpDisabled = null; /* mObject is used by native code, do not remove or rename */ - private int mObject; + private long mObject; private IInterface mOwner; private String mDescriptor; @@ -390,7 +390,7 @@ public class Binder implements IBinder { private native final void destroy(); // Entry point from android_util_Binder.cpp's onTransact - private boolean execTransact(int code, int dataObj, int replyObj, + private boolean execTransact(int code, long dataObj, long replyObj, int flags) { Parcel data = Parcel.obtain(dataObj); Parcel reply = Parcel.obtain(replyObj); @@ -499,6 +499,6 @@ final class BinderProxy implements IBinder { } final private WeakReference mSelf; - private int mObject; - private int mOrgue; + private long mObject; + private long mOrgue; } diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java index 974bf8d..2de1204 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -578,7 +578,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo * tracing. */ public static void startMethodTracing() { - VMDebug.startMethodTracing(DEFAULT_TRACE_FILE_PATH, 0, 0); + VMDebug.startMethodTracing(DEFAULT_TRACE_FILE_PATH, 0, 0, false, 0); } /** @@ -589,7 +589,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo * information about reading trace files. * * @param traceName Name for the trace log file to create. - * If no name argument is given, this value defaults to "/sdcard/dmtrace.trace". + * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace". * If the files already exist, they will be truncated. * If the trace file given does not end in ".trace", it will be appended for you. */ @@ -604,7 +604,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a> for * information about reading trace files. * @param traceName Name for the trace log file to create. - * If no name argument is given, this value defaults to "/sdcard/dmtrace.trace". + * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace". * If the files already exist, they will be truncated. * If the trace file given does not end in ".trace", it will be appended for you. * @@ -627,26 +627,54 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo * in relative terms (e.g. was run #1 faster than run #2). The times * for native methods will not change, so don't try to use this to * compare the performance of interpreted and native implementations of the - * same method. As an alternative, consider using "native" tracing - * in the emulator via {@link #startNativeTracing()}. + * same method. As an alternative, consider using sampling-based method + * tracing via {@link #startMethodTracingSampling(String, int, int)} or + * "native" tracing in the emulator via {@link #startNativeTracing()}. * </p> * * @param traceName Name for the trace log file to create. - * If no name argument is given, this value defaults to "/sdcard/dmtrace.trace". + * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace". * If the files already exist, they will be truncated. * If the trace file given does not end in ".trace", it will be appended for you. * @param bufferSize The maximum amount of trace data we gather. If not given, it defaults to 8MB. + * @param flags Flags to control method tracing. The only one that is currently defined is {@link #TRACE_COUNT_ALLOCS}. */ public static void startMethodTracing(String traceName, int bufferSize, int flags) { + VMDebug.startMethodTracing(fixTraceName(traceName), bufferSize, flags, false, 0); + } + + /** + * Start sampling-based method tracing, specifying the trace log file name, + * the buffer size, and the sampling interval. The trace files will be put + * under "/sdcard" unless an absolute path is given. See <a + href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a> + * for information about reading trace files. + * + * @param traceName Name for the trace log file to create. + * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace". + * If the files already exist, they will be truncated. + * If the trace file given does not end in ".trace", it will be appended for you. + * @param bufferSize The maximum amount of trace data we gather. If not given, it defaults to 8MB. + * @param intervalUs The amount of time between each sample in microseconds. + */ + public static void startMethodTracingSampling(String traceName, + int bufferSize, int intervalUs) { + VMDebug.startMethodTracing(fixTraceName(traceName), bufferSize, 0, true, intervalUs); + } - String pathName = traceName; - if (pathName.charAt(0) != '/') - pathName = DEFAULT_TRACE_PATH_PREFIX + pathName; - if (!pathName.endsWith(DEFAULT_TRACE_EXTENSION)) - pathName = pathName + DEFAULT_TRACE_EXTENSION; + /** + * Formats name of trace log file for method tracing. + */ + private static String fixTraceName(String traceName) { + if (traceName == null) + traceName = DEFAULT_TRACE_FILE_PATH; + if (traceName.charAt(0) != '/') + traceName = DEFAULT_TRACE_PATH_PREFIX + traceName; + if (!traceName.endsWith(DEFAULT_TRACE_EXTENSION)) + traceName = traceName + DEFAULT_TRACE_EXTENSION; - VMDebug.startMethodTracing(pathName, bufferSize, flags); + return traceName; } /** @@ -660,7 +688,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo */ public static void startMethodTracing(String traceName, FileDescriptor fd, int bufferSize, int flags) { - VMDebug.startMethodTracing(traceName, fd, bufferSize, flags); + VMDebug.startMethodTracing(traceName, fd, bufferSize, flags, false, 0); } /** diff --git a/core/java/android/os/MemoryFile.java b/core/java/android/os/MemoryFile.java index e8148f7..ee7a4c6 100644 --- a/core/java/android/os/MemoryFile.java +++ b/core/java/android/os/MemoryFile.java @@ -43,19 +43,19 @@ public class MemoryFile private static native FileDescriptor native_open(String name, int length) throws IOException; // returns memory address for ashmem region - private static native int native_mmap(FileDescriptor fd, int length, int mode) + private static native long native_mmap(FileDescriptor fd, int length, int mode) throws IOException; - private static native void native_munmap(int addr, int length) throws IOException; + private static native void native_munmap(long addr, int length) throws IOException; private static native void native_close(FileDescriptor fd); - private static native int native_read(FileDescriptor fd, int address, byte[] buffer, + private static native int native_read(FileDescriptor fd, long address, byte[] buffer, int srcOffset, int destOffset, int count, boolean isUnpinned) throws IOException; - private static native void native_write(FileDescriptor fd, int address, byte[] buffer, + private static native void native_write(FileDescriptor fd, long address, byte[] buffer, int srcOffset, int destOffset, int count, boolean isUnpinned) throws IOException; private static native void native_pin(FileDescriptor fd, boolean pin) throws IOException; private static native int native_get_size(FileDescriptor fd) throws IOException; private FileDescriptor mFD; // ashmem file descriptor - private int mAddress; // address of ashmem memory + private long mAddress; // address of ashmem memory private int mLength; // total length of our ashmem region private boolean mAllowPurging = false; // true if our ashmem region is unpinned diff --git a/core/java/android/os/MessageQueue.java b/core/java/android/os/MessageQueue.java index 799de5c..75f9813 100644 --- a/core/java/android/os/MessageQueue.java +++ b/core/java/android/os/MessageQueue.java @@ -35,7 +35,7 @@ public final class MessageQueue { private final boolean mQuitAllowed; @SuppressWarnings("unused") - private int mPtr; // used by native code + private long mPtr; // used by native code Message mMessages; private final ArrayList<IdleHandler> mIdleHandlers = new ArrayList<IdleHandler>(); @@ -49,11 +49,11 @@ public final class MessageQueue { // Barriers are indicated by messages with a null target whose arg1 field carries the token. private int mNextBarrierToken; - private native static int nativeInit(); - private native static void nativeDestroy(int ptr); - private native static void nativePollOnce(int ptr, int timeoutMillis); - private native static void nativeWake(int ptr); - private native static boolean nativeIsIdling(int ptr); + private native static long nativeInit(); + private native static void nativeDestroy(long ptr); + private native static void nativePollOnce(long ptr, int timeoutMillis); + private native static void nativeWake(long ptr); + private native static boolean nativeIsIdling(long ptr); /** * Callback interface for discovering when a thread is going to block diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java index 94b9617..6716098 100644 --- a/core/java/android/os/Parcel.java +++ b/core/java/android/os/Parcel.java @@ -182,7 +182,7 @@ public final class Parcel { private static final String TAG = "Parcel"; @SuppressWarnings({"UnusedDeclaration"}) - private int mNativePtr; // used by native code + private long mNativePtr; // used by native code /** * Flag indicating if {@link #mNativePtr} was allocated by this object, @@ -232,47 +232,47 @@ public final class Parcel { private static final int EX_NETWORK_MAIN_THREAD = -6; private static final int EX_HAS_REPLY_HEADER = -128; // special; see below - private static native int nativeDataSize(int nativePtr); - private static native int nativeDataAvail(int nativePtr); - private static native int nativeDataPosition(int nativePtr); - private static native int nativeDataCapacity(int nativePtr); - private static native void nativeSetDataSize(int nativePtr, int size); - private static native void nativeSetDataPosition(int nativePtr, int pos); - private static native void nativeSetDataCapacity(int nativePtr, int size); - - private static native boolean nativePushAllowFds(int nativePtr, boolean allowFds); - private static native void nativeRestoreAllowFds(int nativePtr, boolean lastValue); - - private static native void nativeWriteByteArray(int nativePtr, byte[] b, int offset, int len); - private static native void nativeWriteInt(int nativePtr, int val); - private static native void nativeWriteLong(int nativePtr, long val); - private static native void nativeWriteFloat(int nativePtr, float val); - private static native void nativeWriteDouble(int nativePtr, double val); - private static native void nativeWriteString(int nativePtr, String val); - private static native void nativeWriteStrongBinder(int nativePtr, IBinder val); - private static native void nativeWriteFileDescriptor(int nativePtr, FileDescriptor val); - - private static native byte[] nativeCreateByteArray(int nativePtr); - private static native int nativeReadInt(int nativePtr); - private static native long nativeReadLong(int nativePtr); - private static native float nativeReadFloat(int nativePtr); - private static native double nativeReadDouble(int nativePtr); - private static native String nativeReadString(int nativePtr); - private static native IBinder nativeReadStrongBinder(int nativePtr); - private static native FileDescriptor nativeReadFileDescriptor(int nativePtr); - - private static native int nativeCreate(); - private static native void nativeFreeBuffer(int nativePtr); - private static native void nativeDestroy(int nativePtr); - - private static native byte[] nativeMarshall(int nativePtr); + private static native int nativeDataSize(long nativePtr); + private static native int nativeDataAvail(long nativePtr); + private static native int nativeDataPosition(long nativePtr); + private static native int nativeDataCapacity(long nativePtr); + private static native void nativeSetDataSize(long nativePtr, int size); + private static native void nativeSetDataPosition(long nativePtr, int pos); + private static native void nativeSetDataCapacity(long nativePtr, int size); + + private static native boolean nativePushAllowFds(long nativePtr, boolean allowFds); + private static native void nativeRestoreAllowFds(long nativePtr, boolean lastValue); + + private static native void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len); + private static native void nativeWriteInt(long nativePtr, int val); + private static native void nativeWriteLong(long nativePtr, long val); + private static native void nativeWriteFloat(long nativePtr, float val); + private static native void nativeWriteDouble(long nativePtr, double val); + private static native void nativeWriteString(long nativePtr, String val); + private static native void nativeWriteStrongBinder(long nativePtr, IBinder val); + private static native void nativeWriteFileDescriptor(long nativePtr, FileDescriptor val); + + private static native byte[] nativeCreateByteArray(long nativePtr); + private static native int nativeReadInt(long nativePtr); + private static native long nativeReadLong(long nativePtr); + private static native float nativeReadFloat(long nativePtr); + private static native double nativeReadDouble(long nativePtr); + private static native String nativeReadString(long nativePtr); + private static native IBinder nativeReadStrongBinder(long nativePtr); + private static native FileDescriptor nativeReadFileDescriptor(long nativePtr); + + private static native long nativeCreate(); + private static native void nativeFreeBuffer(long nativePtr); + private static native void nativeDestroy(long nativePtr); + + private static native byte[] nativeMarshall(long nativePtr); private static native void nativeUnmarshall( - int nativePtr, byte[] data, int offest, int length); + long nativePtr, byte[] data, int offest, int length); private static native void nativeAppendFrom( - int thisNativePtr, int otherNativePtr, int offset, int length); - private static native boolean nativeHasFileDescriptors(int nativePtr); - private static native void nativeWriteInterfaceToken(int nativePtr, String interfaceName); - private static native void nativeEnforceInterface(int nativePtr, String interfaceName); + long thisNativePtr, long otherNativePtr, int offset, int length); + private static native boolean nativeHasFileDescriptors(long nativePtr); + private static native void nativeWriteInterfaceToken(long nativePtr, String interfaceName); + private static native void nativeEnforceInterface(long nativePtr, String interfaceName); public final static Parcelable.Creator<String> STRING_CREATOR = new Parcelable.Creator<String>() { @@ -2229,6 +2229,11 @@ public final class Parcel { mCreators = new HashMap<ClassLoader,HashMap<String,Parcelable.Creator>>(); static protected final Parcel obtain(int obj) { + throw new UnsupportedOperationException(); + } + + /** @hide */ + static protected final Parcel obtain(long obj) { final Parcel[] pool = sHolderPool; synchronized (pool) { Parcel p; @@ -2247,7 +2252,7 @@ public final class Parcel { return new Parcel(obj); } - private Parcel(int nativePtr) { + private Parcel(long nativePtr) { if (DEBUG_RECYCLE) { mStack = new RuntimeException(); } @@ -2255,7 +2260,7 @@ public final class Parcel { init(nativePtr); } - private void init(int nativePtr) { + private void init(long nativePtr) { if (nativePtr != 0) { mNativePtr = nativePtr; mOwnsNativeParcelObject = false; diff --git a/core/java/android/speech/srec/MicrophoneInputStream.java b/core/java/android/speech/srec/MicrophoneInputStream.java index fab77a9..94db176 100644 --- a/core/java/android/speech/srec/MicrophoneInputStream.java +++ b/core/java/android/speech/srec/MicrophoneInputStream.java @@ -34,7 +34,7 @@ public final class MicrophoneInputStream extends InputStream { } private final static String TAG = "MicrophoneInputStream"; - private int mAudioRecord = 0; + private long mAudioRecord = 0; private byte[] mOneByte = new byte[1]; /** @@ -102,9 +102,9 @@ public final class MicrophoneInputStream extends InputStream { // // AudioRecord JNI interface // - private static native int AudioRecordNew(int sampleRate, int fifoDepth); - private static native int AudioRecordStart(int audioRecord); - private static native int AudioRecordRead(int audioRecord, byte[] b, int offset, int length) throws IOException; - private static native void AudioRecordStop(int audioRecord) throws IOException; - private static native void AudioRecordDelete(int audioRecord) throws IOException; + private static native long AudioRecordNew(int sampleRate, int fifoDepth); + private static native int AudioRecordStart(long audioRecord); + private static native int AudioRecordRead(long audioRecord, byte[] b, int offset, int length) throws IOException; + private static native void AudioRecordStop(long audioRecord) throws IOException; + private static native void AudioRecordDelete(long audioRecord) throws IOException; } diff --git a/core/java/android/speech/srec/Recognizer.java b/core/java/android/speech/srec/Recognizer.java index db5d8fd..1396204 100644 --- a/core/java/android/speech/srec/Recognizer.java +++ b/core/java/android/speech/srec/Recognizer.java @@ -125,10 +125,10 @@ public final class Recognizer { public static final String KEY_MEANING = "meaning"; // handle to SR_Vocabulary object - private int mVocabulary = 0; + private long mVocabulary = 0; // handle to SR_Recognizer object - private int mRecognizer = 0; + private long mRecognizer = 0; // Grammar currently associated with Recognizer via SR_GrammarSetupRecognizer private Grammar mActiveGrammar = null; @@ -174,7 +174,7 @@ public final class Recognizer { * Represents a grammar loaded into the Recognizer. */ public class Grammar { - private int mGrammar = 0; + private long mGrammar = 0; /** * Create a <code>Grammar</code> instance. @@ -603,116 +603,116 @@ public final class Recognizer { // // SR_Recognizer methods // - private static native void SR_RecognizerStart(int recognizer); - private static native void SR_RecognizerStop(int recognizer); - private static native int SR_RecognizerCreate(); - private static native void SR_RecognizerDestroy(int recognizer); - private static native void SR_RecognizerSetup(int recognizer); - private static native void SR_RecognizerUnsetup(int recognizer); - private static native boolean SR_RecognizerIsSetup(int recognizer); - private static native String SR_RecognizerGetParameter(int recognizer, String key); - private static native int SR_RecognizerGetSize_tParameter(int recognizer, String key); - private static native boolean SR_RecognizerGetBoolParameter(int recognizer, String key); - private static native void SR_RecognizerSetParameter(int recognizer, String key, String value); - private static native void SR_RecognizerSetSize_tParameter(int recognizer, + private static native void SR_RecognizerStart(long recognizer); + private static native void SR_RecognizerStop(long recognizer); + private static native long SR_RecognizerCreate(); + private static native void SR_RecognizerDestroy(long recognizer); + private static native void SR_RecognizerSetup(long recognizer); + private static native void SR_RecognizerUnsetup(long recognizer); + private static native boolean SR_RecognizerIsSetup(long recognizer); + private static native String SR_RecognizerGetParameter(long recognizer, String key); + private static native int SR_RecognizerGetSize_tParameter(long recognizer, String key); + private static native boolean SR_RecognizerGetBoolParameter(long recognizer, String key); + private static native void SR_RecognizerSetParameter(long recognizer, String key, String value); + private static native void SR_RecognizerSetSize_tParameter(long recognizer, String key, int value); - private static native void SR_RecognizerSetBoolParameter(int recognizer, String key, + private static native void SR_RecognizerSetBoolParameter(long recognizer, String key, boolean value); - private static native void SR_RecognizerSetupRule(int recognizer, int grammar, + private static native void SR_RecognizerSetupRule(long recognizer, long grammar, String ruleName); - private static native boolean SR_RecognizerHasSetupRules(int recognizer); - private static native void SR_RecognizerActivateRule(int recognizer, int grammar, + private static native boolean SR_RecognizerHasSetupRules(long recognizer); + private static native void SR_RecognizerActivateRule(long recognizer, long grammar, String ruleName, int weight); - private static native void SR_RecognizerDeactivateRule(int recognizer, int grammar, + private static native void SR_RecognizerDeactivateRule(long recognizer, long grammar, String ruleName); - private static native void SR_RecognizerDeactivateAllRules(int recognizer); - private static native boolean SR_RecognizerIsActiveRule(int recognizer, int grammar, + private static native void SR_RecognizerDeactivateAllRules(long recognizer); + private static native boolean SR_RecognizerIsActiveRule(long recognizer, long grammar, String ruleName); - private static native boolean SR_RecognizerCheckGrammarConsistency(int recognizer, - int grammar); - private static native int SR_RecognizerPutAudio(int recognizer, byte[] buffer, int offset, + private static native boolean SR_RecognizerCheckGrammarConsistency(long recognizer, + long grammar); + private static native int SR_RecognizerPutAudio(long recognizer, byte[] buffer, int offset, int length, boolean isLast); - private static native int SR_RecognizerAdvance(int recognizer); - // private static native void SR_RecognizerLoadUtterance(int recognizer, + private static native int SR_RecognizerAdvance(long recognizer); + // private static native void SR_RecognizerLoadUtterance(long recognizer, // const LCHAR* filename); - // private static native void SR_RecognizerLoadWaveFile(int recognizer, + // private static native void SR_RecognizerLoadWaveFile(long recognizer, // const LCHAR* filename); - // private static native void SR_RecognizerSetLockFunction(int recognizer, + // private static native void SR_RecognizerSetLockFunction(long recognizer, // SR_RecognizerLockFunction function, void* data); - private static native boolean SR_RecognizerIsSignalClipping(int recognizer); - private static native boolean SR_RecognizerIsSignalDCOffset(int recognizer); - private static native boolean SR_RecognizerIsSignalNoisy(int recognizer); - private static native boolean SR_RecognizerIsSignalTooQuiet(int recognizer); - private static native boolean SR_RecognizerIsSignalTooFewSamples(int recognizer); - private static native boolean SR_RecognizerIsSignalTooManySamples(int recognizer); + private static native boolean SR_RecognizerIsSignalClipping(long recognizer); + private static native boolean SR_RecognizerIsSignalDCOffset(long recognizer); + private static native boolean SR_RecognizerIsSignalNoisy(long recognizer); + private static native boolean SR_RecognizerIsSignalTooQuiet(long recognizer); + private static native boolean SR_RecognizerIsSignalTooFewSamples(long recognizer); + private static native boolean SR_RecognizerIsSignalTooManySamples(long recognizer); // private static native void SR_Recognizer_Change_Sample_Rate (size_t new_sample_rate); // // SR_AcousticState native methods // - private static native void SR_AcousticStateReset(int recognizer); - private static native void SR_AcousticStateSet(int recognizer, String state); - private static native String SR_AcousticStateGet(int recognizer); + private static native void SR_AcousticStateReset(long recognizer); + private static native void SR_AcousticStateSet(long recognizer, String state); + private static native String SR_AcousticStateGet(long recognizer); // // SR_Grammar native methods // - private static native void SR_GrammarCompile(int grammar); - private static native void SR_GrammarAddWordToSlot(int grammar, String slot, + private static native void SR_GrammarCompile(long grammar); + private static native void SR_GrammarAddWordToSlot(long grammar, String slot, String word, String pronunciation, int weight, String tag); - private static native void SR_GrammarResetAllSlots(int grammar); - // private static native void SR_GrammarAddNametagToSlot(int grammar, String slot, + private static native void SR_GrammarResetAllSlots(long grammar); + // private static native void SR_GrammarAddNametagToSlot(long grammar, String slot, // const struct SR_Nametag_t* nametag, int weight, String tag); - private static native void SR_GrammarSetupVocabulary(int grammar, int vocabulary); - // private static native void SR_GrammarSetupModels(int grammar, SR_AcousticModels* models); - private static native void SR_GrammarSetupRecognizer(int grammar, int recognizer); - private static native void SR_GrammarUnsetupRecognizer(int grammar); - // private static native void SR_GrammarGetModels(int grammar,SR_AcousticModels** models); - private static native int SR_GrammarCreate(); - private static native void SR_GrammarDestroy(int grammar); - private static native int SR_GrammarLoad(String filename); - private static native void SR_GrammarSave(int grammar, String filename); - // private static native void SR_GrammarSetDispatchFunction(int grammar, + private static native void SR_GrammarSetupVocabulary(long grammar, long vocabulary); + // private static native void SR_GrammarSetupModels(long grammar, SR_AcousticModels* models); + private static native void SR_GrammarSetupRecognizer(long grammar, long recognizer); + private static native void SR_GrammarUnsetupRecognizer(long grammar); + // private static native void SR_GrammarGetModels(long grammar,SR_AcousticModels** models); + private static native long SR_GrammarCreate(); + private static native void SR_GrammarDestroy(long grammar); + private static native long SR_GrammarLoad(String filename); + private static native void SR_GrammarSave(long grammar, String filename); + // private static native void SR_GrammarSetDispatchFunction(long grammar, // const LCHAR* name, void* userData, SR_GrammarDispatchFunction function); - // private static native void SR_GrammarSetParameter(int grammar, const + // private static native void SR_GrammarSetParameter(long grammar, const // LCHAR* key, void* value); - // private static native void SR_GrammarSetSize_tParameter(int grammar, + // private static native void SR_GrammarSetSize_tParameter(long grammar, // const LCHAR* key, size_t value); - // private static native void SR_GrammarGetParameter(int grammar, const + // private static native void SR_GrammarGetParameter(long grammar, const // LCHAR* key, void** value); - // private static native void SR_GrammarGetSize_tParameter(int grammar, + // private static native void SR_GrammarGetSize_tParameter(long grammar, // const LCHAR* key, size_t* value); - // private static native void SR_GrammarCheckParse(int grammar, const LCHAR* + // private static native void SR_GrammarCheckParse(long grammar, const LCHAR* // transcription, SR_SemanticResult** result, size_t* resultCount); - private static native void SR_GrammarAllowOnly(int grammar, String transcription); - private static native void SR_GrammarAllowAll(int grammar); + private static native void SR_GrammarAllowOnly(long grammar, String transcription); + private static native void SR_GrammarAllowAll(long grammar); // // SR_Vocabulary native methods // // private static native int SR_VocabularyCreate(); - private static native int SR_VocabularyLoad(); + private static native long SR_VocabularyLoad(); // private static native void SR_VocabularySave(SR_Vocabulary* self, // const LCHAR* filename); // private static native void SR_VocabularyAddWord(SR_Vocabulary* self, // const LCHAR* word); // private static native void SR_VocabularyGetLanguage(SR_Vocabulary* self, // ESR_Locale* locale); - private static native void SR_VocabularyDestroy(int vocabulary); - private static native String SR_VocabularyGetPronunciation(int vocabulary, String word); + private static native void SR_VocabularyDestroy(long vocabulary); + private static native String SR_VocabularyGetPronunciation(long vocabulary, String word); // // SR_RecognizerResult native methods // - private static native byte[] SR_RecognizerResultGetWaveform(int recognizer); - private static native int SR_RecognizerResultGetSize(int recognizer); - private static native int SR_RecognizerResultGetKeyCount(int recognizer, int nbest); - private static native String[] SR_RecognizerResultGetKeyList(int recognizer, int nbest); - private static native String SR_RecognizerResultGetValue(int recognizer, + private static native byte[] SR_RecognizerResultGetWaveform(long recognizer); + private static native int SR_RecognizerResultGetSize(long recognizer); + private static native int SR_RecognizerResultGetKeyCount(long recognizer, int nbest); + private static native String[] SR_RecognizerResultGetKeyList(long recognizer, int nbest); + private static native String SR_RecognizerResultGetValue(long recognizer, int nbest, String key); - // private static native void SR_RecognizerResultGetLocale(int recognizer, ESR_Locale* locale); + // private static native void SR_RecognizerResultGetLocale(long recognizer, ESR_Locale* locale); } diff --git a/core/java/android/view/DisplayEventReceiver.java b/core/java/android/view/DisplayEventReceiver.java index 4dade20..de46a4a 100644 --- a/core/java/android/view/DisplayEventReceiver.java +++ b/core/java/android/view/DisplayEventReceiver.java @@ -36,16 +36,16 @@ public abstract class DisplayEventReceiver { private final CloseGuard mCloseGuard = CloseGuard.get(); - private int mReceiverPtr; + private long mReceiverPtr; // We keep a reference message queue object here so that it is not // GC'd while the native peer of the receiver is using them. private MessageQueue mMessageQueue; - private static native int nativeInit(DisplayEventReceiver receiver, + private static native long nativeInit(DisplayEventReceiver receiver, MessageQueue messageQueue); - private static native void nativeDispose(int receiverPtr); - private static native void nativeScheduleVsync(int receiverPtr); + private static native void nativeDispose(long receiverPtr); + private static native void nativeScheduleVsync(long receiverPtr); /** * Creates a display event receiver. diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java index beefc21..6a15fa6 100644 --- a/core/java/android/view/GLES20Canvas.java +++ b/core/java/android/view/GLES20Canvas.java @@ -49,7 +49,7 @@ class GLES20Canvas extends HardwareCanvas { private static final int MODIFIER_COLOR_FILTER = 4; private final boolean mOpaque; - private int mRenderer; + private long mRenderer; // The native renderer will be destroyed when this object dies. // DO NOT overwrite this reference once it is set. @@ -92,7 +92,7 @@ class GLES20Canvas extends HardwareCanvas { /** * Creates a canvas to render into an FBO. */ - GLES20Canvas(int layer, boolean translucent) { + GLES20Canvas(long layer, boolean translucent) { mOpaque = !translucent; mRenderer = nCreateLayerRenderer(layer); setupFinalizer(); @@ -122,16 +122,16 @@ class GLES20Canvas extends HardwareCanvas { nResetDisplayListRenderer(mRenderer); } - private static native int nCreateRenderer(); - private static native int nCreateLayerRenderer(int layer); - private static native int nCreateDisplayListRenderer(); - private static native void nResetDisplayListRenderer(int renderer); - private static native void nDestroyRenderer(int renderer); + private static native long nCreateRenderer(); + private static native long nCreateLayerRenderer(long layer); + private static native long nCreateDisplayListRenderer(); + private static native void nResetDisplayListRenderer(long renderer); + private static native void nDestroyRenderer(long renderer); private static final class CanvasFinalizer { - private final int mRenderer; + private final long mRenderer; - public CanvasFinalizer(int renderer) { + public CanvasFinalizer(long renderer) { mRenderer = renderer; } @@ -151,7 +151,7 @@ class GLES20Canvas extends HardwareCanvas { nSetName(mRenderer, name); } - private static native void nSetName(int renderer, String name); + private static native void nSetName(long renderer, String name); /////////////////////////////////////////////////////////////////////////// // Hardware layers @@ -177,26 +177,26 @@ class GLES20Canvas extends HardwareCanvas { nClearLayerUpdates(mRenderer); } - static native int nCreateTextureLayer(boolean opaque, int[] layerInfo); - static native int nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo); - static native boolean nResizeLayer(int layerId, int width, int height, int[] layerInfo); - static native void nSetOpaqueLayer(int layerId, boolean isOpaque); - static native void nSetLayerPaint(int layerId, int nativePaint); - static native void nSetLayerColorFilter(int layerId, int nativeColorFilter); - static native void nUpdateTextureLayer(int layerId, int width, int height, boolean opaque, + static native long nCreateTextureLayer(boolean opaque, int[] layerInfo); + static native long nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo); + static native boolean nResizeLayer(long layerId, int width, int height, int[] layerInfo); + static native void nSetOpaqueLayer(long layerId, boolean isOpaque); + static native void nSetLayerPaint(long layerId, long nativePaint); + static native void nSetLayerColorFilter(long layerId, long nativeColorFilter); + static native void nUpdateTextureLayer(long layerId, int width, int height, boolean opaque, SurfaceTexture surface); - static native void nClearLayerTexture(int layerId); - static native void nSetTextureLayerTransform(int layerId, int matrix); - static native void nDestroyLayer(int layerId); - static native void nDestroyLayerDeferred(int layerId); - static native void nUpdateRenderLayer(int layerId, int renderer, int displayList, + static native void nClearLayerTexture(long layerId); + static native void nSetTextureLayerTransform(long layerId, long matrix); + static native void nDestroyLayer(long layerId); + static native void nDestroyLayerDeferred(long layerId); + static native void nUpdateRenderLayer(long layerId, long renderer, long displayList, int left, int top, int right, int bottom); - static native boolean nCopyLayer(int layerId, int bitmap); + static native boolean nCopyLayer(long layerId, long bitmap); - private static native void nClearLayerUpdates(int renderer); - private static native void nFlushLayerUpdates(int renderer); - private static native void nPushLayerUpdate(int renderer, int layer); - private static native void nCancelLayerUpdate(int renderer, int layer); + private static native void nClearLayerUpdates(long renderer); + private static native void nFlushLayerUpdates(long renderer); + private static native void nPushLayerUpdate(long renderer, long layer); + private static native void nCancelLayerUpdate(long renderer, long layer); /////////////////////////////////////////////////////////////////////////// // Canvas management @@ -233,7 +233,7 @@ class GLES20Canvas extends HardwareCanvas { /** * Returns the native OpenGLRenderer object. */ - int getRenderer() { + long getRenderer() { return mRenderer; } @@ -249,7 +249,7 @@ class GLES20Canvas extends HardwareCanvas { nSetViewport(mRenderer, width, height); } - private static native void nSetViewport(int renderer, int width, int height); + private static native void nSetViewport(long renderer, int width, int height); @Override public int onPreDraw(Rect dirty) { @@ -261,8 +261,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native int nPrepare(int renderer, boolean opaque); - private static native int nPrepareDirty(int renderer, int left, int top, int right, int bottom, + private static native int nPrepare(long renderer, boolean opaque); + private static native int nPrepareDirty(long renderer, int left, int top, int right, int bottom, boolean opaque); @Override @@ -270,7 +270,7 @@ class GLES20Canvas extends HardwareCanvas { nFinish(mRenderer); } - private static native void nFinish(int renderer); + private static native void nFinish(long renderer); /** * Returns the size of the stencil buffer required by the underlying @@ -290,45 +290,45 @@ class GLES20Canvas extends HardwareCanvas { nSetCountOverdrawEnabled(mRenderer, enabled); } - static native void nSetCountOverdrawEnabled(int renderer, boolean enabled); + static native void nSetCountOverdrawEnabled(long renderer, boolean enabled); float getOverdraw() { return nGetOverdraw(mRenderer); } - static native float nGetOverdraw(int renderer); + static native float nGetOverdraw(long renderer); /////////////////////////////////////////////////////////////////////////// // Functor /////////////////////////////////////////////////////////////////////////// @Override - public int callDrawGLFunction(int drawGLFunction) { + public int callDrawGLFunction(long drawGLFunction) { return nCallDrawGLFunction(mRenderer, drawGLFunction); } - private static native int nCallDrawGLFunction(int renderer, int drawGLFunction); + private static native int nCallDrawGLFunction(long renderer, long drawGLFunction); @Override public int invokeFunctors(Rect dirty) { return nInvokeFunctors(mRenderer, dirty); } - private static native int nInvokeFunctors(int renderer, Rect dirty); + private static native int nInvokeFunctors(long renderer, Rect dirty); @Override - public void detachFunctor(int functor) { + public void detachFunctor(long functor) { nDetachFunctor(mRenderer, functor); } - private static native void nDetachFunctor(int renderer, int functor); + private static native void nDetachFunctor(long renderer, long functor); @Override - public void attachFunctor(int functor) { + public void attachFunctor(long functor) { nAttachFunctor(mRenderer, functor); } - private static native void nAttachFunctor(int renderer, int functor); + private static native void nAttachFunctor(long renderer, long functor); /////////////////////////////////////////////////////////////////////////// // Memory @@ -402,18 +402,18 @@ class GLES20Canvas extends HardwareCanvas { // Display list /////////////////////////////////////////////////////////////////////////// - int getDisplayList(int displayList) { + long getDisplayList(long displayList) { return nGetDisplayList(mRenderer, displayList); } - private static native int nGetDisplayList(int renderer, int displayList); + private static native long nGetDisplayList(long renderer, long displayList); @Override void outputDisplayList(DisplayList displayList) { nOutputDisplayList(mRenderer, ((GLES20DisplayList) displayList).getNativeDisplayList()); } - private static native void nOutputDisplayList(int renderer, int displayList); + private static native void nOutputDisplayList(long renderer, long displayList); @Override public int drawDisplayList(DisplayList displayList, Rect dirty, int flags) { @@ -421,7 +421,7 @@ class GLES20Canvas extends HardwareCanvas { dirty, flags); } - private static native int nDrawDisplayList(int renderer, int displayList, + private static native int nDrawDisplayList(long renderer, long displayList, Rect dirty, int flags); /////////////////////////////////////////////////////////////////////////// @@ -435,7 +435,7 @@ class GLES20Canvas extends HardwareCanvas { nDrawLayer(mRenderer, glLayer.getLayer(), x, y); } - private static native void nDrawLayer(int renderer, int layer, float x, float y); + private static native void nDrawLayer(long renderer, long layer, float x, float y); void interrupt() { nInterrupt(mRenderer); @@ -445,8 +445,8 @@ class GLES20Canvas extends HardwareCanvas { nResume(mRenderer); } - private static native void nInterrupt(int renderer); - private static native void nResume(int renderer); + private static native void nInterrupt(long renderer); + private static native void nResume(long renderer); /////////////////////////////////////////////////////////////////////////// // Support @@ -487,14 +487,14 @@ class GLES20Canvas extends HardwareCanvas { return nClipPath(mRenderer, path.mNativePath, op.nativeInt); } - private static native boolean nClipPath(int renderer, int path, int op); + private static native boolean nClipPath(long renderer, long path, int op); @Override public boolean clipRect(float left, float top, float right, float bottom) { return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt); } - private static native boolean nClipRect(int renderer, float left, float top, + private static native boolean nClipRect(long renderer, float left, float top, float right, float bottom, int op); @Override @@ -507,7 +507,7 @@ class GLES20Canvas extends HardwareCanvas { return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt); } - private static native boolean nClipRect(int renderer, int left, int top, + private static native boolean nClipRect(long renderer, int left, int top, int right, int bottom, int op); @Override @@ -542,21 +542,21 @@ class GLES20Canvas extends HardwareCanvas { return nClipRegion(mRenderer, region.mNativeRegion, op.nativeInt); } - private static native boolean nClipRegion(int renderer, int region, int op); + private static native boolean nClipRegion(long renderer, long region, int op); @Override public boolean getClipBounds(Rect bounds) { return nGetClipBounds(mRenderer, bounds); } - private static native boolean nGetClipBounds(int renderer, Rect bounds); + private static native boolean nGetClipBounds(long renderer, Rect bounds); @Override public boolean quickReject(float left, float top, float right, float bottom, EdgeType type) { return nQuickReject(mRenderer, left, top, right, bottom); } - private static native boolean nQuickReject(int renderer, float left, float top, + private static native boolean nQuickReject(long renderer, float left, float top, float right, float bottom); @Override @@ -581,35 +581,35 @@ class GLES20Canvas extends HardwareCanvas { if (dx != 0.0f || dy != 0.0f) nTranslate(mRenderer, dx, dy); } - private static native void nTranslate(int renderer, float dx, float dy); + private static native void nTranslate(long renderer, float dx, float dy); @Override public void skew(float sx, float sy) { nSkew(mRenderer, sx, sy); } - private static native void nSkew(int renderer, float sx, float sy); + private static native void nSkew(long renderer, float sx, float sy); @Override public void rotate(float degrees) { nRotate(mRenderer, degrees); } - private static native void nRotate(int renderer, float degrees); + private static native void nRotate(long renderer, float degrees); @Override public void scale(float sx, float sy) { nScale(mRenderer, sx, sy); } - private static native void nScale(int renderer, float sx, float sy); + private static native void nScale(long renderer, float sx, float sy); @Override public void setMatrix(Matrix matrix) { nSetMatrix(mRenderer, matrix == null ? 0 : matrix.native_instance); } - private static native void nSetMatrix(int renderer, int matrix); + private static native void nSetMatrix(long renderer, long matrix); @SuppressWarnings("deprecation") @Override @@ -617,14 +617,14 @@ class GLES20Canvas extends HardwareCanvas { nGetMatrix(mRenderer, matrix.native_instance); } - private static native void nGetMatrix(int renderer, int matrix); + private static native void nGetMatrix(long renderer, long matrix); @Override public void concat(Matrix matrix) { if (matrix != null) nConcatMatrix(mRenderer, matrix.native_instance); } - private static native void nConcatMatrix(int renderer, int matrix); + private static native void nConcatMatrix(long renderer, long matrix); /////////////////////////////////////////////////////////////////////////// // State management @@ -640,7 +640,7 @@ class GLES20Canvas extends HardwareCanvas { return nSave(mRenderer, saveFlags); } - private static native int nSave(int renderer, int flags); + private static native int nSave(long renderer, int flags); @Override public int saveLayer(RectF bounds, Paint paint, int saveFlags) { @@ -651,7 +651,7 @@ class GLES20Canvas extends HardwareCanvas { int count; int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; count = nSaveLayer(mRenderer, nativePaint, saveFlags); } finally { if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier); @@ -659,7 +659,7 @@ class GLES20Canvas extends HardwareCanvas { return count; } - private static native int nSaveLayer(int renderer, int paint, int saveFlags); + private static native int nSaveLayer(long renderer, long paint, int saveFlags); @Override public int saveLayer(float left, float top, float right, float bottom, Paint paint, @@ -668,7 +668,7 @@ class GLES20Canvas extends HardwareCanvas { int count; int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; count = nSaveLayer(mRenderer, left, top, right, bottom, nativePaint, saveFlags); } finally { if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier); @@ -678,8 +678,8 @@ class GLES20Canvas extends HardwareCanvas { return save(saveFlags); } - private static native int nSaveLayer(int renderer, float left, float top, - float right, float bottom, int paint, int saveFlags); + private static native int nSaveLayer(long renderer, float left, float top, + float right, float bottom, long paint, int saveFlags); @Override public int saveLayerAlpha(RectF bounds, int alpha, int saveFlags) { @@ -690,7 +690,7 @@ class GLES20Canvas extends HardwareCanvas { return nSaveLayerAlpha(mRenderer, alpha, saveFlags); } - private static native int nSaveLayerAlpha(int renderer, int alpha, int saveFlags); + private static native int nSaveLayerAlpha(long renderer, int alpha, int saveFlags); @Override public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha, @@ -701,7 +701,7 @@ class GLES20Canvas extends HardwareCanvas { return save(saveFlags); } - private static native int nSaveLayerAlpha(int renderer, float left, float top, float right, + private static native int nSaveLayerAlpha(long renderer, float left, float top, float right, float bottom, int alpha, int saveFlags); @Override @@ -709,21 +709,21 @@ class GLES20Canvas extends HardwareCanvas { nRestore(mRenderer); } - private static native void nRestore(int renderer); + private static native void nRestore(long renderer); @Override public void restoreToCount(int saveCount) { nRestoreToCount(mRenderer, saveCount); } - private static native void nRestoreToCount(int renderer, int saveCount); + private static native void nRestoreToCount(long renderer, int saveCount); @Override public int getSaveCount() { return nGetSaveCount(mRenderer); } - private static native int nGetSaveCount(int renderer); + private static native int nGetSaveCount(long renderer); /////////////////////////////////////////////////////////////////////////// // Filtering @@ -740,8 +740,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nResetPaintFilter(int renderer); - private static native void nSetupPaintFilter(int renderer, int clearBits, int setBits); + private static native void nResetPaintFilter(long renderer); + private static native void nSetupPaintFilter(long renderer, int clearBits, int setBits); @Override public DrawFilter getDrawFilter() { @@ -764,9 +764,9 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawArc(int renderer, float left, float top, + private static native void nDrawArc(long renderer, float left, float top, float right, float bottom, float startAngle, float sweepAngle, - boolean useCenter, int paint); + boolean useCenter, long paint); @Override public void drawARGB(int a, int r, int g, int b) { @@ -780,7 +780,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing patches int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawPatch(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, patch.mNativeChunk, dst.left, dst.top, dst.right, dst.bottom, nativePaint); } finally { @@ -795,7 +795,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing patches int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawPatch(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, patch.mNativeChunk, dst.left, dst.top, dst.right, dst.bottom, nativePaint); } finally { @@ -803,8 +803,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawPatch(int renderer, int bitmap, byte[] buffer, int chunk, - float left, float top, float right, float bottom, int paint); + private static native void nDrawPatch(long renderer, long bitmap, byte[] buffer, long chunk, + float left, float top, float right, float bottom, long paint); @Override public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) { @@ -812,15 +812,15 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing bitmaps int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, left, top, nativePaint); } finally { if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); } } - private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer, - float left, float top, int paint); + private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer, + float left, float top, long paint); @Override public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) { @@ -828,7 +828,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing bitmaps int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, matrix.native_instance, nativePaint); } finally { @@ -836,8 +836,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer, - int matrix, int paint); + private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer, + long matrix, long paint); @Override public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) { @@ -845,7 +845,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing bitmaps int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; int left, top, right, bottom; if (src == null) { @@ -872,7 +872,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing bitmaps int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; float left, top, right, bottom; if (src == null) { @@ -893,9 +893,9 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer, + private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer, float srcLeft, float srcTop, float srcRight, float srcBottom, - float left, float top, float right, float bottom, int paint); + float left, float top, float right, float bottom, long paint); @Override public void drawBitmap(int[] colors, int offset, int stride, float x, float y, @@ -923,7 +923,7 @@ class GLES20Canvas extends HardwareCanvas { // Shaders are ignored when drawing bitmaps int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawBitmap(mRenderer, colors, offset, stride, x, y, width, height, hasAlpha, nativePaint); } finally { @@ -931,8 +931,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawBitmap(int renderer, int[] colors, int offset, int stride, - float x, float y, int width, int height, boolean hasAlpha, int nativePaint); + private static native void nDrawBitmap(long renderer, int[] colors, int offset, int stride, + float x, float y, int width, int height, boolean hasAlpha, long nativePaint); @Override public void drawBitmap(int[] colors, int offset, int stride, int x, int y, @@ -962,7 +962,7 @@ class GLES20Canvas extends HardwareCanvas { int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; try { - final int nativePaint = paint == null ? 0 : paint.mNativePaint; + final long nativePaint = paint == null ? 0 : paint.mNativePaint; nDrawBitmapMesh(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, meshWidth, meshHeight, verts, vertOffset, colors, colorOffset, nativePaint); } finally { @@ -970,9 +970,9 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawBitmapMesh(int renderer, int bitmap, byte[] buffer, + private static native void nDrawBitmapMesh(long renderer, long bitmap, byte[] buffer, int meshWidth, int meshHeight, float[] verts, int vertOffset, - int[] colors, int colorOffset, int paint); + int[] colors, int colorOffset, long paint); @Override public void drawCircle(float cx, float cy, float radius, Paint paint) { @@ -984,8 +984,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawCircle(int renderer, float cx, float cy, - float radius, int paint); + private static native void nDrawCircle(long renderer, float cx, float cy, + float radius, long paint); @Override public void drawColor(int color) { @@ -997,7 +997,7 @@ class GLES20Canvas extends HardwareCanvas { nDrawColor(mRenderer, color, mode.nativeInt); } - private static native void nDrawColor(int renderer, int color, int mode); + private static native void nDrawColor(long renderer, int color, int mode); @Override public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) { @@ -1024,8 +1024,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawLines(int renderer, float[] points, - int offset, int count, int paint); + private static native void nDrawLines(long renderer, float[] points, + int offset, int count, long paint); @Override public void drawLines(float[] pts, Paint paint) { @@ -1042,8 +1042,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawOval(int renderer, float left, float top, - float right, float bottom, int paint); + private static native void nDrawOval(long renderer, float left, float top, + float right, float bottom, long paint); @Override public void drawPaint(Paint paint) { @@ -1068,8 +1068,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawPath(int renderer, int path, int paint); - private static native void nDrawRects(int renderer, int region, int paint); + private static native void nDrawPath(long renderer, long path, long paint); + private static native void nDrawRects(long renderer, long region, long paint); void drawRects(float[] rects, int count, Paint paint) { int modifiers = setupModifiers(paint, MODIFIER_COLOR_FILTER | MODIFIER_SHADER); @@ -1080,7 +1080,7 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawRects(int renderer, float[] rects, int count, int paint); + private static native void nDrawRects(long renderer, float[] rects, int count, long paint); @Override public void drawPicture(Picture picture) { @@ -1147,8 +1147,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawPoints(int renderer, float[] points, - int offset, int count, int paint); + private static native void nDrawPoints(long renderer, float[] points, + int offset, int count, long paint); @SuppressWarnings("deprecation") @Override @@ -1165,8 +1165,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawPosText(int renderer, char[] text, int index, int count, - float[] pos, int paint); + private static native void nDrawPosText(long renderer, char[] text, int index, int count, + float[] pos, long paint); @SuppressWarnings("deprecation") @Override @@ -1183,8 +1183,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawPosText(int renderer, String text, int start, int end, - float[] pos, int paint); + private static native void nDrawPosText(long renderer, String text, int start, int end, + float[] pos, long paint); @Override public void drawRect(float left, float top, float right, float bottom, Paint paint) { @@ -1197,8 +1197,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawRect(int renderer, float left, float top, - float right, float bottom, int paint); + private static native void nDrawRect(long renderer, float left, float top, + float right, float bottom, long paint); @Override public void drawRect(Rect r, Paint paint) { @@ -1226,8 +1226,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawRoundRect(int renderer, float left, float top, - float right, float bottom, float rx, float y, int paint); + private static native void nDrawRoundRect(long renderer, float left, float top, + float right, float bottom, float rx, float y, long paint); @Override public void drawText(char[] text, int index, int count, float x, float y, Paint paint) { @@ -1243,8 +1243,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawText(int renderer, char[] text, int index, int count, - float x, float y, int bidiFlags, int paint); + private static native void nDrawText(long renderer, char[] text, int index, int count, + float x, float y, int bidiFlags, long paint); @Override public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) { @@ -1283,8 +1283,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawText(int renderer, String text, int start, int end, - float x, float y, int bidiFlags, int paint); + private static native void nDrawText(long renderer, String text, int start, int end, + float x, float y, int bidiFlags, long paint); @Override public void drawText(String text, float x, float y, Paint paint) { @@ -1313,8 +1313,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawTextOnPath(int renderer, char[] text, int index, int count, - int path, float hOffset, float vOffset, int bidiFlags, int nativePaint); + private static native void nDrawTextOnPath(long renderer, char[] text, int index, int count, + long path, float hOffset, float vOffset, int bidiFlags, long nativePaint); @Override public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) { @@ -1329,8 +1329,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawTextOnPath(int renderer, String text, int start, int end, - int path, float hOffset, float vOffset, int bidiFlags, int nativePaint); + private static native void nDrawTextOnPath(long renderer, String text, int start, int end, + long path, float hOffset, float vOffset, int bidiFlags, long nativePaint); @Override public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount, @@ -1351,8 +1351,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawTextRun(int renderer, char[] text, int index, int count, - int contextIndex, int contextCount, float x, float y, int dir, int nativePaint); + private static native void nDrawTextRun(long renderer, char[] text, int index, int count, + int contextIndex, int contextCount, float x, float y, int dir, long nativePaint); @Override public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd, @@ -1385,8 +1385,8 @@ class GLES20Canvas extends HardwareCanvas { } } - private static native void nDrawTextRun(int renderer, String text, int start, int end, - int contextStart, int contextEnd, float x, float y, int flags, int nativePaint); + private static native void nDrawTextRun(long renderer, String text, int start, int end, + int contextStart, int contextEnd, float x, float y, int flags, long nativePaint); @Override public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset, @@ -1466,10 +1466,10 @@ class GLES20Canvas extends HardwareCanvas { return MODIFIER_NONE; } - private static native void nSetupShader(int renderer, int shader); - private static native void nSetupColorFilter(int renderer, int colorFilter); - private static native void nSetupShadow(int renderer, float radius, + private static native void nSetupShader(long renderer, long shader); + private static native void nSetupColorFilter(long renderer, long colorFilter); + private static native void nSetupShadow(long renderer, float radius, float dx, float dy, int color); - private static native void nResetModifiers(int renderer, int modifiers); + private static native void nResetModifiers(long renderer, int modifiers); } diff --git a/core/java/android/view/GLES20DisplayList.java b/core/java/android/view/GLES20DisplayList.java index c652bac..7f8b3bd 100644 --- a/core/java/android/view/GLES20DisplayList.java +++ b/core/java/android/view/GLES20DisplayList.java @@ -44,7 +44,7 @@ class GLES20DisplayList extends DisplayList { return mValid && mFinalizer != null; } - int getNativeDisplayList() { + long getNativeDisplayList() { if (!mValid || mFinalizer == null) { throw new IllegalStateException("The display list is not valid."); } @@ -124,9 +124,9 @@ class GLES20DisplayList extends DisplayList { return nGetDisplayListSize(mFinalizer.mNativeDisplayList); } - private static native void nDestroyDisplayList(int displayList); - private static native int nGetDisplayListSize(int displayList); - private static native void nSetDisplayListName(int displayList, String name); + private static native void nDestroyDisplayList(long displayList); + private static native int nGetDisplayListSize(long displayList); + private static native void nSetDisplayListName(long displayList, String name); /////////////////////////////////////////////////////////////////////////// // Native View Properties @@ -440,62 +440,62 @@ class GLES20DisplayList extends DisplayList { } } - private static native void nReset(int displayList); - private static native void nOffsetTopAndBottom(int displayList, float offset); - private static native void nOffsetLeftAndRight(int displayList, float offset); - private static native void nSetLeftTopRightBottom(int displayList, int left, int top, + private static native void nReset(long displayList); + private static native void nOffsetTopAndBottom(long displayList, float offset); + private static native void nOffsetLeftAndRight(long displayList, float offset); + private static native void nSetLeftTopRightBottom(long displayList, int left, int top, int right, int bottom); - private static native void nSetBottom(int displayList, int bottom); - private static native void nSetRight(int displayList, int right); - private static native void nSetTop(int displayList, int top); - private static native void nSetLeft(int displayList, int left); - private static native void nSetCameraDistance(int displayList, float distance); - private static native void nSetPivotY(int displayList, float pivotY); - private static native void nSetPivotX(int displayList, float pivotX); - private static native void nSetCaching(int displayList, boolean caching); - private static native void nSetClipToBounds(int displayList, boolean clipToBounds); - private static native void nSetAlpha(int displayList, float alpha); - private static native void nSetHasOverlappingRendering(int displayList, + private static native void nSetBottom(long displayList, int bottom); + private static native void nSetRight(long displayList, int right); + private static native void nSetTop(long displayList, int top); + private static native void nSetLeft(long displayList, int left); + private static native void nSetCameraDistance(long displayList, float distance); + private static native void nSetPivotY(long displayList, float pivotY); + private static native void nSetPivotX(long displayList, float pivotX); + private static native void nSetCaching(long displayList, boolean caching); + private static native void nSetClipToBounds(long displayList, boolean clipToBounds); + private static native void nSetAlpha(long displayList, float alpha); + private static native void nSetHasOverlappingRendering(long displayList, boolean hasOverlappingRendering); - private static native void nSetTranslationX(int displayList, float translationX); - private static native void nSetTranslationY(int displayList, float translationY); - private static native void nSetRotation(int displayList, float rotation); - private static native void nSetRotationX(int displayList, float rotationX); - private static native void nSetRotationY(int displayList, float rotationY); - private static native void nSetScaleX(int displayList, float scaleX); - private static native void nSetScaleY(int displayList, float scaleY); - private static native void nSetTransformationInfo(int displayList, float alpha, + private static native void nSetTranslationX(long displayList, float translationX); + private static native void nSetTranslationY(long displayList, float translationY); + private static native void nSetRotation(long displayList, float rotation); + private static native void nSetRotationX(long displayList, float rotationX); + private static native void nSetRotationY(long displayList, float rotationY); + private static native void nSetScaleX(long displayList, float scaleX); + private static native void nSetScaleY(long displayList, float scaleY); + private static native void nSetTransformationInfo(long displayList, float alpha, float translationX, float translationY, float rotation, float rotationX, float rotationY, float scaleX, float scaleY); - private static native void nSetStaticMatrix(int displayList, int nativeMatrix); - private static native void nSetAnimationMatrix(int displayList, int animationMatrix); - - private static native boolean nHasOverlappingRendering(int displayList); - private static native void nGetMatrix(int displayList, int matrix); - private static native float nGetAlpha(int displayList); - private static native float nGetLeft(int displayList); - private static native float nGetTop(int displayList); - private static native float nGetRight(int displayList); - private static native float nGetBottom(int displayList); - private static native float nGetCameraDistance(int displayList); - private static native float nGetScaleX(int displayList); - private static native float nGetScaleY(int displayList); - private static native float nGetTranslationX(int displayList); - private static native float nGetTranslationY(int displayList); - private static native float nGetRotation(int displayList); - private static native float nGetRotationX(int displayList); - private static native float nGetRotationY(int displayList); - private static native float nGetPivotX(int displayList); - private static native float nGetPivotY(int displayList); + private static native void nSetStaticMatrix(long displayList, long nativeMatrix); + private static native void nSetAnimationMatrix(long displayList, long animationMatrix); + + private static native boolean nHasOverlappingRendering(long displayList); + private static native void nGetMatrix(long displayList, long matrix); + private static native float nGetAlpha(long displayList); + private static native float nGetLeft(long displayList); + private static native float nGetTop(long displayList); + private static native float nGetRight(long displayList); + private static native float nGetBottom(long displayList); + private static native float nGetCameraDistance(long displayList); + private static native float nGetScaleX(long displayList); + private static native float nGetScaleY(long displayList); + private static native float nGetTranslationX(long displayList); + private static native float nGetTranslationY(long displayList); + private static native float nGetRotation(long displayList); + private static native float nGetRotationX(long displayList); + private static native float nGetRotationY(long displayList); + private static native float nGetPivotX(long displayList); + private static native float nGetPivotY(long displayList); /////////////////////////////////////////////////////////////////////////// // Finalization /////////////////////////////////////////////////////////////////////////// private static class DisplayListFinalizer { - final int mNativeDisplayList; + final long mNativeDisplayList; - public DisplayListFinalizer(int nativeDisplayList) { + public DisplayListFinalizer(long nativeDisplayList) { mNativeDisplayList = nativeDisplayList; } diff --git a/core/java/android/view/GLES20Layer.java b/core/java/android/view/GLES20Layer.java index 0e3311c..37154eb 100644 --- a/core/java/android/view/GLES20Layer.java +++ b/core/java/android/view/GLES20Layer.java @@ -24,7 +24,7 @@ import android.graphics.Paint; * An OpenGL ES 2.0 implementation of {@link HardwareLayer}. */ abstract class GLES20Layer extends HardwareLayer { - int mLayer; + long mLayer; Finalizer mFinalizer; GLES20Layer() { @@ -39,7 +39,7 @@ abstract class GLES20Layer extends HardwareLayer { * * @return A pointer to the native layer object, or 0 if the object is NULL */ - public int getLayer() { + public long getLayer() { return mLayer; } @@ -75,9 +75,9 @@ abstract class GLES20Layer extends HardwareLayer { } static class Finalizer { - private int mLayerId; + private long mLayerId; - public Finalizer(int layerId) { + public Finalizer(long layerId) { mLayerId = layerId; } diff --git a/core/java/android/view/GLES20RecordingCanvas.java b/core/java/android/view/GLES20RecordingCanvas.java index b6fc38d..e3e1c76 100644 --- a/core/java/android/view/GLES20RecordingCanvas.java +++ b/core/java/android/view/GLES20RecordingCanvas.java @@ -58,7 +58,7 @@ class GLES20RecordingCanvas extends GLES20Canvas { mDisplayList.clearReferences(); } - int end(int nativeDisplayList) { + long end(long nativeDisplayList) { return getDisplayList(nativeDisplayList); } diff --git a/core/java/android/view/GraphicBuffer.java b/core/java/android/view/GraphicBuffer.java index 30c077c..5f2a9cd 100644 --- a/core/java/android/view/GraphicBuffer.java +++ b/core/java/android/view/GraphicBuffer.java @@ -56,7 +56,7 @@ public class GraphicBuffer implements Parcelable { private final int mFormat; private final int mUsage; // Note: do not rename, this field is used by native code - private final int mNativeObject; + private final long mNativeObject; // These two fields are only used by lock/unlockCanvas() private Canvas mCanvas; @@ -77,7 +77,7 @@ public class GraphicBuffer implements Parcelable { * @return A <code>GraphicBuffer</code> instance or null */ public static GraphicBuffer create(int width, int height, int format, int usage) { - int nativeObject = nCreateGraphicBuffer(width, height, format, usage); + long nativeObject = nCreateGraphicBuffer(width, height, format, usage); if (nativeObject != 0) { return new GraphicBuffer(width, height, format, usage, nativeObject); } @@ -87,7 +87,7 @@ public class GraphicBuffer implements Parcelable { /** * Private use only. See {@link #create(int, int, int, int)}. */ - private GraphicBuffer(int width, int height, int format, int usage, int nativeObject) { + private GraphicBuffer(int width, int height, int format, int usage, long nativeObject) { mWidth = width; mHeight = height; mFormat = format; @@ -271,7 +271,7 @@ public class GraphicBuffer implements Parcelable { int height = in.readInt(); int format = in.readInt(); int usage = in.readInt(); - int nativeObject = nReadGraphicBufferFromParcel(in); + long nativeObject = nReadGraphicBufferFromParcel(in); if (nativeObject != 0) { return new GraphicBuffer(width, height, format, usage, nativeObject); } @@ -283,10 +283,10 @@ public class GraphicBuffer implements Parcelable { } }; - private static native int nCreateGraphicBuffer(int width, int height, int format, int usage); - private static native void nDestroyGraphicBuffer(int nativeObject); - private static native void nWriteGraphicBufferToParcel(int nativeObject, Parcel dest); - private static native int nReadGraphicBufferFromParcel(Parcel in); - private static native boolean nLockCanvas(int nativeObject, Canvas canvas, Rect dirty); - private static native boolean nUnlockCanvasAndPost(int nativeObject, Canvas canvas); + private static native long nCreateGraphicBuffer(int width, int height, int format, int usage); + private static native void nDestroyGraphicBuffer(long nativeObject); + private static native void nWriteGraphicBufferToParcel(long nativeObject, Parcel dest); + private static native long nReadGraphicBufferFromParcel(Parcel in); + private static native boolean nLockCanvas(long nativeObject, Canvas canvas, Rect dirty); + private static native boolean nUnlockCanvasAndPost(long nativeObject, Canvas canvas); } diff --git a/core/java/android/view/HardwareCanvas.java b/core/java/android/view/HardwareCanvas.java index 259e1cd..10f700c 100644 --- a/core/java/android/view/HardwareCanvas.java +++ b/core/java/android/view/HardwareCanvas.java @@ -145,7 +145,7 @@ public abstract class HardwareCanvas extends Canvas { * * @hide */ - public int callDrawGLFunction(int drawGLFunction) { + public int callDrawGLFunction(long drawGLFunction) { // Noop - this is done in the display list recorder subclass return DisplayList.STATUS_DONE; } @@ -170,12 +170,12 @@ public abstract class HardwareCanvas extends Canvas { * @param functor The native functor to remove from the execution queue. * * @see #invokeFunctors(android.graphics.Rect) - * @see #callDrawGLFunction(int) - * @see #detachFunctor(int) + * @see #callDrawGLFunction(long) + * @see #detachFunctor(long) * * @hide */ - abstract void detachFunctor(int functor); + abstract void detachFunctor(long functor); /** * Attaches the specified functor to the current functor execution queue. @@ -183,12 +183,12 @@ public abstract class HardwareCanvas extends Canvas { * @param functor The native functor to add to the execution queue. * * @see #invokeFunctors(android.graphics.Rect) - * @see #callDrawGLFunction(int) - * @see #detachFunctor(int) + * @see #callDrawGLFunction(long) + * @see #detachFunctor(long) * * @hide */ - abstract void attachFunctor(int functor); + abstract void attachFunctor(long functor); /** * Indicates that the specified layer must be updated as soon as possible. diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index f215189..3781bdb 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -568,7 +568,7 @@ public abstract class HardwareRenderer { * @see HardwareCanvas#callDrawGLFunction(int) * @see #attachFunctor(android.view.View.AttachInfo, int) */ - abstract void detachFunctor(int functor); + abstract void detachFunctor(long functor); /** * Schedules the specified functor in the functors execution queue. @@ -581,7 +581,7 @@ public abstract class HardwareRenderer { * * @return true if the functor was attached successfully */ - abstract boolean attachFunctor(View.AttachInfo attachInfo, int functor); + abstract boolean attachFunctor(View.AttachInfo attachInfo, long functor); /** * Initializes the hardware renderer for the specified surface and setup the @@ -1712,14 +1712,14 @@ public abstract class HardwareRenderer { } @Override - void detachFunctor(int functor) { + void detachFunctor(long functor) { if (mCanvas != null) { mCanvas.detachFunctor(functor); } } @Override - boolean attachFunctor(View.AttachInfo attachInfo, int functor) { + boolean attachFunctor(View.AttachInfo attachInfo, long functor) { if (mCanvas != null) { mCanvas.attachFunctor(functor); mFunctorsRunnable.attachInfo = attachInfo; diff --git a/core/java/android/view/InputChannel.java b/core/java/android/view/InputChannel.java index 40ee1ad..de195ae 100644 --- a/core/java/android/view/InputChannel.java +++ b/core/java/android/view/InputChannel.java @@ -46,7 +46,7 @@ public final class InputChannel implements Parcelable { }; @SuppressWarnings("unused") - private int mPtr; // used by native code + private long mPtr; // used by native code private static native InputChannel[] nativeOpenInputChannelPair(String name); diff --git a/core/java/android/view/InputEventReceiver.java b/core/java/android/view/InputEventReceiver.java index 25972e7..91ef50d 100644 --- a/core/java/android/view/InputEventReceiver.java +++ b/core/java/android/view/InputEventReceiver.java @@ -34,7 +34,7 @@ public abstract class InputEventReceiver { private final CloseGuard mCloseGuard = CloseGuard.get(); - private int mReceiverPtr; + private long mReceiverPtr; // We keep references to the input channel and message queue objects here so that // they are not GC'd while the native peer of the receiver is using them. @@ -44,11 +44,11 @@ public abstract class InputEventReceiver { // Map from InputEvent sequence numbers to dispatcher sequence numbers. private final SparseIntArray mSeqMap = new SparseIntArray(); - private static native int nativeInit(WeakReference<InputEventReceiver> receiver, + private static native long nativeInit(WeakReference<InputEventReceiver> receiver, InputChannel inputChannel, MessageQueue messageQueue); - private static native void nativeDispose(int receiverPtr); - private static native void nativeFinishInputEvent(int receiverPtr, int seq, boolean handled); - private static native boolean nativeConsumeBatchedInputEvents(int receiverPtr, + private static native void nativeDispose(long receiverPtr); + private static native void nativeFinishInputEvent(long receiverPtr, int seq, boolean handled); + private static native boolean nativeConsumeBatchedInputEvents(long receiverPtr, long frameTimeNanos); /** diff --git a/core/java/android/view/InputEventSender.java b/core/java/android/view/InputEventSender.java index be6a623..304ea3f 100644 --- a/core/java/android/view/InputEventSender.java +++ b/core/java/android/view/InputEventSender.java @@ -33,18 +33,18 @@ public abstract class InputEventSender { private final CloseGuard mCloseGuard = CloseGuard.get(); - private int mSenderPtr; + private long mSenderPtr; // We keep references to the input channel and message queue objects here so that // they are not GC'd while the native peer of the receiver is using them. private InputChannel mInputChannel; private MessageQueue mMessageQueue; - private static native int nativeInit(WeakReference<InputEventSender> sender, + private static native long nativeInit(WeakReference<InputEventSender> sender, InputChannel inputChannel, MessageQueue messageQueue); - private static native void nativeDispose(int senderPtr); - private static native boolean nativeSendKeyEvent(int senderPtr, int seq, KeyEvent event); - private static native boolean nativeSendMotionEvent(int senderPtr, int seq, MotionEvent event); + private static native void nativeDispose(long senderPtr); + private static native boolean nativeSendKeyEvent(long senderPtr, int seq, KeyEvent event); + private static native boolean nativeSendMotionEvent(long senderPtr, int seq, MotionEvent event); /** * Creates an input event sender bound to the specified input channel. diff --git a/core/java/android/view/InputQueue.java b/core/java/android/view/InputQueue.java index e3de89d..d5cec49 100644 --- a/core/java/android/view/InputQueue.java +++ b/core/java/android/view/InputQueue.java @@ -23,7 +23,7 @@ import android.os.Looper; import android.os.MessageQueue; import android.util.Pools.Pool; import android.util.Pools.SimplePool; -import android.util.SparseArray; +import android.util.LongSparseArray; import java.lang.ref.WeakReference; @@ -32,20 +32,20 @@ import java.lang.ref.WeakReference; * input events. Currently only usable from native code. */ public final class InputQueue { - private final SparseArray<ActiveInputEvent> mActiveEventArray = - new SparseArray<ActiveInputEvent>(20); + private final LongSparseArray<ActiveInputEvent> mActiveEventArray = + new LongSparseArray<ActiveInputEvent>(20); private final Pool<ActiveInputEvent> mActiveInputEventPool = new SimplePool<ActiveInputEvent>(20); private final CloseGuard mCloseGuard = CloseGuard.get(); - private int mPtr; + private long mPtr; - private static native int nativeInit(WeakReference<InputQueue> weakQueue, + private static native long nativeInit(WeakReference<InputQueue> weakQueue, MessageQueue messageQueue); - private static native int nativeSendKeyEvent(int ptr, KeyEvent e, boolean preDispatch); - private static native int nativeSendMotionEvent(int ptr, MotionEvent e); - private static native void nativeDispose(int ptr); + private static native long nativeSendKeyEvent(long ptr, KeyEvent e, boolean preDispatch); + private static native long nativeSendMotionEvent(long ptr, MotionEvent e); + private static native void nativeDispose(long ptr); /** @hide */ public InputQueue() { @@ -84,7 +84,7 @@ public final class InputQueue { } /** @hide */ - public int getNativePtr() { + public long getNativePtr() { return mPtr; } @@ -92,7 +92,7 @@ public final class InputQueue { public void sendInputEvent(InputEvent e, Object token, boolean predispatch, FinishedInputEventCallback callback) { ActiveInputEvent event = obtainActiveInputEvent(token, callback); - int id; + long id; if (e instanceof KeyEvent) { id = nativeSendKeyEvent(mPtr, (KeyEvent) e, predispatch); } else { @@ -101,7 +101,7 @@ public final class InputQueue { mActiveEventArray.put(id, event); } - private void finishInputEvent(int id, boolean handled) { + private void finishInputEvent(long id, boolean handled) { int index = mActiveEventArray.indexOfKey(id); if (index >= 0) { ActiveInputEvent e = mActiveEventArray.valueAt(index); diff --git a/core/java/android/view/KeyCharacterMap.java b/core/java/android/view/KeyCharacterMap.java index 9e5f25a..55dd6bb 100644 --- a/core/java/android/view/KeyCharacterMap.java +++ b/core/java/android/view/KeyCharacterMap.java @@ -282,20 +282,20 @@ public class KeyCharacterMap implements Parcelable { } }; - private int mPtr; + private long mPtr; - private static native int nativeReadFromParcel(Parcel in); - private static native void nativeWriteToParcel(int ptr, Parcel out); - private static native void nativeDispose(int ptr); + private static native long nativeReadFromParcel(Parcel in); + private static native void nativeWriteToParcel(long ptr, Parcel out); + private static native void nativeDispose(long ptr); - private static native char nativeGetCharacter(int ptr, int keyCode, int metaState); - private static native boolean nativeGetFallbackAction(int ptr, int keyCode, int metaState, + private static native char nativeGetCharacter(long ptr, int keyCode, int metaState); + private static native boolean nativeGetFallbackAction(long ptr, int keyCode, int metaState, FallbackAction outFallbackAction); - private static native char nativeGetNumber(int ptr, int keyCode); - private static native char nativeGetMatch(int ptr, int keyCode, char[] chars, int metaState); - private static native char nativeGetDisplayLabel(int ptr, int keyCode); - private static native int nativeGetKeyboardType(int ptr); - private static native KeyEvent[] nativeGetEvents(int ptr, char[] chars); + private static native char nativeGetNumber(long ptr, int keyCode); + private static native char nativeGetMatch(long ptr, int keyCode, char[] chars, int metaState); + private static native char nativeGetDisplayLabel(long ptr, int keyCode); + private static native int nativeGetKeyboardType(long ptr); + private static native KeyEvent[] nativeGetEvents(long ptr, char[] chars); private KeyCharacterMap(Parcel in) { if (in == null) { @@ -308,7 +308,7 @@ public class KeyCharacterMap implements Parcelable { } // Called from native - private KeyCharacterMap(int ptr) { + private KeyCharacterMap(long ptr) { mPtr = ptr; } diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index db577f3..ddce3ce 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -1311,63 +1311,63 @@ public final class MotionEvent extends InputEvent implements Parcelable { } // Pointer to the native MotionEvent object that contains the actual data. - private int mNativePtr; + private long mNativePtr; private MotionEvent mNext; - private static native int nativeInitialize(int nativePtr, + private static native long nativeInitialize(long nativePtr, int deviceId, int source, int action, int flags, int edgeFlags, int metaState, int buttonState, float xOffset, float yOffset, float xPrecision, float yPrecision, long downTimeNanos, long eventTimeNanos, int pointerCount, PointerProperties[] pointerIds, PointerCoords[] pointerCoords); - private static native int nativeCopy(int destNativePtr, int sourceNativePtr, + private static native long nativeCopy(long destNativePtr, long sourceNativePtr, boolean keepHistory); - private static native void nativeDispose(int nativePtr); - private static native void nativeAddBatch(int nativePtr, long eventTimeNanos, + private static native void nativeDispose(long nativePtr); + private static native void nativeAddBatch(long nativePtr, long eventTimeNanos, PointerCoords[] pointerCoords, int metaState); - private static native int nativeGetDeviceId(int nativePtr); - private static native int nativeGetSource(int nativePtr); - private static native int nativeSetSource(int nativePtr, int source); - private static native int nativeGetAction(int nativePtr); - private static native void nativeSetAction(int nativePtr, int action); - private static native boolean nativeIsTouchEvent(int nativePtr); - private static native int nativeGetFlags(int nativePtr); - private static native void nativeSetFlags(int nativePtr, int flags); - private static native int nativeGetEdgeFlags(int nativePtr); - private static native void nativeSetEdgeFlags(int nativePtr, int action); - private static native int nativeGetMetaState(int nativePtr); - private static native int nativeGetButtonState(int nativePtr); - private static native void nativeOffsetLocation(int nativePtr, float deltaX, float deltaY); - private static native float nativeGetXOffset(int nativePtr); - private static native float nativeGetYOffset(int nativePtr); - private static native float nativeGetXPrecision(int nativePtr); - private static native float nativeGetYPrecision(int nativePtr); - private static native long nativeGetDownTimeNanos(int nativePtr); - private static native void nativeSetDownTimeNanos(int nativePtr, long downTime); - - private static native int nativeGetPointerCount(int nativePtr); - private static native int nativeGetPointerId(int nativePtr, int pointerIndex); - private static native int nativeGetToolType(int nativePtr, int pointerIndex); - private static native int nativeFindPointerIndex(int nativePtr, int pointerId); - - private static native int nativeGetHistorySize(int nativePtr); - private static native long nativeGetEventTimeNanos(int nativePtr, int historyPos); - private static native float nativeGetRawAxisValue(int nativePtr, + private static native int nativeGetDeviceId(long nativePtr); + private static native int nativeGetSource(long nativePtr); + private static native int nativeSetSource(long nativePtr, int source); + private static native int nativeGetAction(long nativePtr); + private static native void nativeSetAction(long nativePtr, int action); + private static native boolean nativeIsTouchEvent(long nativePtr); + private static native int nativeGetFlags(long nativePtr); + private static native void nativeSetFlags(long nativePtr, int flags); + private static native int nativeGetEdgeFlags(long nativePtr); + private static native void nativeSetEdgeFlags(long nativePtr, int action); + private static native int nativeGetMetaState(long nativePtr); + private static native int nativeGetButtonState(long nativePtr); + private static native void nativeOffsetLocation(long nativePtr, float deltaX, float deltaY); + private static native float nativeGetXOffset(long nativePtr); + private static native float nativeGetYOffset(long nativePtr); + private static native float nativeGetXPrecision(long nativePtr); + private static native float nativeGetYPrecision(long nativePtr); + private static native long nativeGetDownTimeNanos(long nativePtr); + private static native void nativeSetDownTimeNanos(long nativePtr, long downTime); + + private static native int nativeGetPointerCount(long nativePtr); + private static native int nativeGetPointerId(long nativePtr, int pointerIndex); + private static native int nativeGetToolType(long nativePtr, int pointerIndex); + private static native int nativeFindPointerIndex(long nativePtr, int pointerId); + + private static native int nativeGetHistorySize(long nativePtr); + private static native long nativeGetEventTimeNanos(long nativePtr, int historyPos); + private static native float nativeGetRawAxisValue(long nativePtr, int axis, int pointerIndex, int historyPos); - private static native float nativeGetAxisValue(int nativePtr, + private static native float nativeGetAxisValue(long nativePtr, int axis, int pointerIndex, int historyPos); - private static native void nativeGetPointerCoords(int nativePtr, + private static native void nativeGetPointerCoords(long nativePtr, int pointerIndex, int historyPos, PointerCoords outPointerCoords); - private static native void nativeGetPointerProperties(int nativePtr, + private static native void nativeGetPointerProperties(long nativePtr, int pointerIndex, PointerProperties outPointerProperties); - private static native void nativeScale(int nativePtr, float scale); - private static native void nativeTransform(int nativePtr, Matrix matrix); + private static native void nativeScale(long nativePtr, float scale); + private static native void nativeTransform(long nativePtr, Matrix matrix); - private static native int nativeReadFromParcel(int nativePtr, Parcel parcel); - private static native void nativeWriteToParcel(int nativePtr, Parcel parcel); + private static native long nativeReadFromParcel(long nativePtr, Parcel parcel); + private static native void nativeWriteToParcel(long nativePtr, Parcel parcel); private MotionEvent() { } diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index 1bfda2d..91645e7 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -32,19 +32,19 @@ import dalvik.system.CloseGuard; public class Surface implements Parcelable { private static final String TAG = "Surface"; - private static native int nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture) + private static native long nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture) throws OutOfResourcesException; - private static native int nativeCreateFromSurfaceControl(int surfaceControlNativeObject); + private static native long nativeCreateFromSurfaceControl(long surfaceControlNativeObject); - private static native int nativeLockCanvas(int nativeObject, Canvas canvas, Rect dirty) + private static native long nativeLockCanvas(long nativeObject, Canvas canvas, Rect dirty) throws OutOfResourcesException; - private static native void nativeUnlockCanvasAndPost(int nativeObject, Canvas canvas); + private static native void nativeUnlockCanvasAndPost(long nativeObject, Canvas canvas); - private static native void nativeRelease(int nativeObject); - private static native boolean nativeIsValid(int nativeObject); - private static native boolean nativeIsConsumerRunningBehind(int nativeObject); - private static native int nativeReadFromParcel(int nativeObject, Parcel source); - private static native void nativeWriteToParcel(int nativeObject, Parcel dest); + private static native void nativeRelease(long nativeObject); + private static native boolean nativeIsValid(long nativeObject); + private static native boolean nativeIsConsumerRunningBehind(long nativeObject); + private static native long nativeReadFromParcel(long nativeObject, Parcel source); + private static native void nativeWriteToParcel(long nativeObject, Parcel dest); public static final Parcelable.Creator<Surface> CREATOR = new Parcelable.Creator<Surface>() { @@ -71,8 +71,8 @@ public class Surface implements Parcelable { // Guarded state. final Object mLock = new Object(); // protects the native state private String mName; - int mNativeObject; // package scope only for SurfaceControl access - private int mLockedObject; + long mNativeObject; // package scope only for SurfaceControl access + private long mLockedObject; private int mGenerationId; // incremented each time mNativeObject changes private final Canvas mCanvas = new CompatibleCanvas(); @@ -130,7 +130,7 @@ public class Surface implements Parcelable { } /* called from android_view_Surface_createFromIGraphicBufferProducer() */ - private Surface(int nativeObject) { + private Surface(long nativeObject) { synchronized (mLock) { setNativeObjectLocked(nativeObject); } @@ -261,8 +261,8 @@ public class Surface implements Parcelable { checkNotReleasedLocked(); if (mNativeObject != mLockedObject) { Log.w(TAG, "WARNING: Surface's mNativeObject (0x" + - Integer.toHexString(mNativeObject) + ") != mLockedObject (0x" + - Integer.toHexString(mLockedObject) +")"); + Long.toHexString(mNativeObject) + ") != mLockedObject (0x" + + Long.toHexString(mLockedObject) +")"); } if (mLockedObject == 0) { throw new IllegalStateException("Surface was not locked"); @@ -307,12 +307,12 @@ public class Surface implements Parcelable { throw new IllegalArgumentException("other must not be null"); } - int surfaceControlPtr = other.mNativeObject; + long surfaceControlPtr = other.mNativeObject; if (surfaceControlPtr == 0) { throw new NullPointerException( "SurfaceControl native object is null. Are you using a released SurfaceControl?"); } - int newNativeObject = nativeCreateFromSurfaceControl(surfaceControlPtr); + long newNativeObject = nativeCreateFromSurfaceControl(surfaceControlPtr); synchronized (mLock) { if (mNativeObject != 0) { @@ -334,7 +334,7 @@ public class Surface implements Parcelable { throw new IllegalArgumentException("other must not be null"); } if (other != this) { - final int newPtr; + final long newPtr; synchronized (other.mLock) { newPtr = other.mNativeObject; other.setNativeObjectLocked(0); @@ -391,7 +391,7 @@ public class Surface implements Parcelable { } } - private void setNativeObjectLocked(int ptr) { + private void setNativeObjectLocked(long ptr) { if (mNativeObject != ptr) { if (mNativeObject == 0 && ptr != 0) { mCloseGuard.open("release"); diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index b22d5cf..62afa60 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -33,11 +33,11 @@ import android.view.Surface.OutOfResourcesException; public class SurfaceControl { private static final String TAG = "SurfaceControl"; - private static native int nativeCreate(SurfaceSession session, String name, + private static native long nativeCreate(SurfaceSession session, String name, int w, int h, int format, int flags) throws OutOfResourcesException; - private static native void nativeRelease(int nativeObject); - private static native void nativeDestroy(int nativeObject); + private static native void nativeRelease(long nativeObject); + private static native void nativeDestroy(long nativeObject); private static native Bitmap nativeScreenshot(IBinder displayToken, int width, int height, int minLayer, int maxLayer, boolean allLayers); @@ -48,21 +48,21 @@ public class SurfaceControl { private static native void nativeCloseTransaction(); private static native void nativeSetAnimationTransaction(); - private static native void nativeSetLayer(int nativeObject, int zorder); - private static native void nativeSetPosition(int nativeObject, float x, float y); - private static native void nativeSetSize(int nativeObject, int w, int h); - private static native void nativeSetTransparentRegionHint(int nativeObject, Region region); - private static native void nativeSetAlpha(int nativeObject, float alpha); - private static native void nativeSetMatrix(int nativeObject, float dsdx, float dtdx, float dsdy, float dtdy); - private static native void nativeSetFlags(int nativeObject, int flags, int mask); - private static native void nativeSetWindowCrop(int nativeObject, int l, int t, int r, int b); - private static native void nativeSetLayerStack(int nativeObject, int layerStack); + private static native void nativeSetLayer(long nativeObject, int zorder); + private static native void nativeSetPosition(long nativeObject, float x, float y); + private static native void nativeSetSize(long nativeObject, int w, int h); + private static native void nativeSetTransparentRegionHint(long nativeObject, Region region); + private static native void nativeSetAlpha(long nativeObject, float alpha); + private static native void nativeSetMatrix(long nativeObject, float dsdx, float dtdx, float dsdy, float dtdy); + private static native void nativeSetFlags(long nativeObject, int flags, int mask); + private static native void nativeSetWindowCrop(long nativeObject, int l, int t, int r, int b); + private static native void nativeSetLayerStack(long nativeObject, int layerStack); private static native IBinder nativeGetBuiltInDisplay(int physicalDisplayId); private static native IBinder nativeCreateDisplay(String name, boolean secure); private static native void nativeDestroyDisplay(IBinder displayToken); private static native void nativeSetDisplaySurface( - IBinder displayToken, int nativeSurfaceObject); + IBinder displayToken, long nativeSurfaceObject); private static native void nativeSetDisplayLayerStack( IBinder displayToken, int layerStack); private static native void nativeSetDisplayProjection( @@ -77,7 +77,7 @@ public class SurfaceControl { private final CloseGuard mCloseGuard = CloseGuard.get(); private final String mName; - int mNativeObject; // package visibility only for Surface.java access + long mNativeObject; // package visibility only for Surface.java access private static final boolean HEADLESS = "1".equals( SystemProperties.get("ro.config.headless", "0")); diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java index 47f7628..b78af2e 100644 --- a/core/java/android/view/TextureView.java +++ b/core/java/android/view/TextureView.java @@ -127,7 +127,7 @@ public class TextureView extends View { private final Object[] mNativeWindowLock = new Object[0]; // Used from native code, do not write! @SuppressWarnings({"UnusedDeclaration"}) - private int mNativeWindow; + private long mNativeWindow; /** * Creates a new TextureView. @@ -816,6 +816,6 @@ public class TextureView extends View { private native void nCreateNativeWindow(SurfaceTexture surface); private native void nDestroyNativeWindow(); - private static native boolean nLockCanvas(int nativeWindow, Canvas canvas, Rect dirty); - private static native void nUnlockCanvasAndPost(int nativeWindow, Canvas canvas); + private static native boolean nLockCanvas(long nativeWindow, Canvas canvas, Rect dirty); + private static native void nUnlockCanvasAndPost(long nativeWindow, Canvas canvas); } diff --git a/core/java/android/view/VelocityTracker.java b/core/java/android/view/VelocityTracker.java index eb81f72..22b5cca 100644 --- a/core/java/android/view/VelocityTracker.java +++ b/core/java/android/view/VelocityTracker.java @@ -34,17 +34,17 @@ public final class VelocityTracker { private static final int ACTIVE_POINTER_ID = -1; - private int mPtr; + private long mPtr; private final String mStrategy; - private static native int nativeInitialize(String strategy); - private static native void nativeDispose(int ptr); - private static native void nativeClear(int ptr); - private static native void nativeAddMovement(int ptr, MotionEvent event); - private static native void nativeComputeCurrentVelocity(int ptr, int units, float maxVelocity); - private static native float nativeGetXVelocity(int ptr, int id); - private static native float nativeGetYVelocity(int ptr, int id); - private static native boolean nativeGetEstimator(int ptr, int id, Estimator outEstimator); + private static native long nativeInitialize(String strategy); + private static native void nativeDispose(long ptr); + private static native void nativeClear(long ptr); + private static native void nativeAddMovement(long ptr, MotionEvent event); + private static native void nativeComputeCurrentVelocity(long ptr, int units, float maxVelocity); + private static native float nativeGetXVelocity(long ptr, int id); + private static native float nativeGetYVelocity(long ptr, int id); + private static native boolean nativeGetEstimator(long ptr, int id, Estimator outEstimator); /** * Retrieve a new VelocityTracker object to watch the velocity of a diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index 082ff3d..abddc90 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -363,8 +363,6 @@ public abstract class CompoundButton extends Button implements Checkable { @Override public Parcelable onSaveInstanceState() { - // Force our ancestor class to save its state - setFreezesText(true); Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); diff --git a/core/java/android/widget/CursorTreeAdapter.java b/core/java/android/widget/CursorTreeAdapter.java index 44d1656..405e45a 100644..100755 --- a/core/java/android/widget/CursorTreeAdapter.java +++ b/core/java/android/widget/CursorTreeAdapter.java @@ -497,7 +497,7 @@ public abstract class CursorTreeAdapter extends BaseExpandableListAdapter implem @Override public void onChange(boolean selfChange) { - if (mAutoRequery && mCursor != null) { + if (mAutoRequery && mCursor != null && !mCursor.isClosed()) { if (false) Log.v("Cursor", "Auto requerying " + mCursor + " due to update"); mDataValid = mCursor.requery(); diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 9dab7b4..748af7b 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -317,7 +317,7 @@ public class Editor { mErrorPopup = null; } - + mShowErrorAfterAttach = false; } else { setErrorIcon(icon); if (mTextView.isFocused()) { diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java index b75d36f..5cbabef 100644 --- a/core/java/android/widget/Spinner.java +++ b/core/java/android/widget/Spinner.java @@ -952,8 +952,10 @@ public class Spinner extends AbsSpinner implements OnClickListener { private CharSequence mPrompt; public void dismiss() { - mPopup.dismiss(); - mPopup = null; + if (mPopup != null) { + mPopup.dismiss(); + mPopup = null; + } } public boolean isShowing() { diff --git a/core/java/com/android/internal/app/ProcessStats.java b/core/java/com/android/internal/app/ProcessStats.java index 0cad33c..a87992a 100644 --- a/core/java/com/android/internal/app/ProcessStats.java +++ b/core/java/com/android/internal/app/ProcessStats.java @@ -1046,7 +1046,7 @@ public final class ProcessStats implements Parcelable { public boolean evaluateSystemProperties(boolean update) { boolean changed = false; - String runtime = SystemProperties.get("persist.sys.dalvik.vm.lib", + String runtime = SystemProperties.get("persist.sys.dalvik.vm.lib.1", VMRuntime.getRuntime().vmLibrary()); if (!Objects.equals(runtime, mRuntime)) { changed = true; diff --git a/core/java/com/android/internal/util/XmlUtils.java b/core/java/com/android/internal/util/XmlUtils.java index 0b74cf3..b35de93 100644 --- a/core/java/com/android/internal/util/XmlUtils.java +++ b/core/java/com/android/internal/util/XmlUtils.java @@ -482,12 +482,13 @@ public class XmlUtils { * @see #readThisMapXml * #see #writeMapXml */ - public static final HashMap readMapXml(InputStream in) + @SuppressWarnings("unchecked") + public static final HashMap<String, ?> readMapXml(InputStream in) throws XmlPullParserException, java.io.IOException { XmlPullParser parser = Xml.newPullParser(); parser.setInput(in, null); - return (HashMap)readValueXml(parser, new String[1]); + return (HashMap<String, ?>) readValueXml(parser, new String[1]); } /** @@ -548,22 +549,16 @@ public class XmlUtils { * * @see #readMapXml */ - public static final HashMap readThisMapXml(XmlPullParser parser, String endTag, String[] name) - throws XmlPullParserException, java.io.IOException + public static final HashMap<String, ?> readThisMapXml(XmlPullParser parser, String endTag, + String[] name) throws XmlPullParserException, java.io.IOException { - HashMap map = new HashMap(); + HashMap<String, Object> map = new HashMap<String, Object>(); int eventType = parser.getEventType(); do { if (eventType == parser.START_TAG) { Object val = readThisValueXml(parser, name); - if (name[0] != null) { - //System.out.println("Adding to map: " + name + " -> " + val); - map.put(name[0], val); - } else { - throw new XmlPullParserException( - "Map value without name attribute: " + parser.getName()); - } + map.put(name[0], val); } else if (eventType == parser.END_TAG) { if (parser.getName().equals(endTag)) { return map; diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index eea9ee1..7143a8a 100644 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -289,8 +289,9 @@ static int getPremulBitmapCreateFlags(bool isMutable) { }
static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors,
- int offset, int stride, int width, int height,
- SkBitmap::Config config, jboolean isMutable) {
+ jint offset, jint stride, jint width, jint height,
+ jint configHandle, jboolean isMutable) {
+ SkBitmap::Config config = static_cast<SkBitmap::Config>(configHandle);
if (NULL != jColors) {
size_t n = env->GetArrayLength(jColors);
if (n < SkAbs32(stride) * (size_t)height) {
@@ -321,8 +322,10 @@ static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors, getPremulBitmapCreateFlags(isMutable), NULL, NULL);
}
-static jobject Bitmap_copy(JNIEnv* env, jobject, const SkBitmap* src,
- SkBitmap::Config dstConfig, jboolean isMutable) {
+static jobject Bitmap_copy(JNIEnv* env, jobject, jlong srcHandle,
+ jint dstConfigHandle, jboolean isMutable) {
+ const SkBitmap* src = reinterpret_cast<SkBitmap*>(srcHandle);
+ SkBitmap::Config dstConfig = static_cast<SkBitmap::Config>(dstConfigHandle);
SkBitmap result;
JavaPixelAllocator allocator(env);
@@ -333,7 +336,8 @@ static jobject Bitmap_copy(JNIEnv* env, jobject, const SkBitmap* src, getPremulBitmapCreateFlags(isMutable), NULL, NULL);
}
-static void Bitmap_destructor(JNIEnv* env, jobject, SkBitmap* bitmap) {
+static void Bitmap_destructor(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
#ifdef USE_OPENGL_RENDERER
if (android::uirenderer::Caches::hasInstance()) {
android::uirenderer::Caches::getInstance().resourceCache.destructor(bitmap);
@@ -343,24 +347,28 @@ static void Bitmap_destructor(JNIEnv* env, jobject, SkBitmap* bitmap) { delete bitmap;
}
-static jboolean Bitmap_recycle(JNIEnv* env, jobject, SkBitmap* bitmap) {
+static jboolean Bitmap_recycle(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
#ifdef USE_OPENGL_RENDERER
if (android::uirenderer::Caches::hasInstance()) {
- return android::uirenderer::Caches::getInstance().resourceCache.recycle(bitmap);
+ bool result;
+ result = android::uirenderer::Caches::getInstance().resourceCache.recycle(bitmap);
+ return result ? JNI_TRUE : JNI_FALSE;
}
#endif // USE_OPENGL_RENDERER
bitmap->setPixels(NULL, NULL);
- return true;
+ return JNI_TRUE;
}
-static void Bitmap_reconfigure(JNIEnv* env, jobject clazz, jint bitmapInt,
- int width, int height, SkBitmap::Config config, int allocSize) {
+static void Bitmap_reconfigure(JNIEnv* env, jobject clazz, jlong bitmapHandle,
+ jint width, jint height, jint configHandle, jint allocSize) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkBitmap::Config config = static_cast<SkBitmap::Config>(configHandle);
if (width * height * SkBitmap::ComputeBytesPerPixel(config) > allocSize) {
// done in native as there's no way to get BytesPerPixel in Java
doThrowIAE(env, "Bitmap not large enough to support new configuration");
return;
}
- SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapInt);
SkPixelRef* ref = bitmap->pixelRef();
SkSafeRef(ref);
bitmap->setConfig(config, width, height);
@@ -380,9 +388,10 @@ enum JavaEncodeFormat { kWEBP_JavaEncodeFormat = 2
};
-static bool Bitmap_compress(JNIEnv* env, jobject clazz, SkBitmap* bitmap,
- int format, int quality,
- jobject jstream, jbyteArray jstorage) {
+static jboolean Bitmap_compress(JNIEnv* env, jobject clazz, jlong bitmapHandle,
+ jint format, jint quality,
+ jobject jstream, jbyteArray jstorage) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkImageEncoder::Type fm;
switch (format) {
@@ -396,7 +405,7 @@ static bool Bitmap_compress(JNIEnv* env, jobject clazz, SkBitmap* bitmap, fm = SkImageEncoder::kWEBP_Type;
break;
default:
- return false;
+ return JNI_FALSE;
}
bool success = false;
@@ -404,12 +413,12 @@ static bool Bitmap_compress(JNIEnv* env, jobject clazz, SkBitmap* bitmap, SkAutoLockPixels alp(*bitmap);
if (NULL == bitmap->getPixels()) {
- return false;
+ return JNI_FALSE;
}
SkWStream* strm = CreateJavaOutputStreamAdaptor(env, jstream, jstorage);
if (NULL == strm) {
- return false;
+ return JNI_FALSE;
}
SkImageEncoder* encoder = SkImageEncoder::Create(fm);
@@ -419,40 +428,48 @@ static bool Bitmap_compress(JNIEnv* env, jobject clazz, SkBitmap* bitmap, }
delete strm;
}
- return success;
+ return success ? JNI_TRUE : JNI_FALSE;
}
-static void Bitmap_erase(JNIEnv* env, jobject, SkBitmap* bitmap, jint color) {
+static void Bitmap_erase(JNIEnv* env, jobject, jlong bitmapHandle, jint color) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
bitmap->eraseColor(color);
}
-static int Bitmap_rowBytes(JNIEnv* env, jobject, SkBitmap* bitmap) {
- return bitmap->rowBytes();
+static jint Bitmap_rowBytes(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ return static_cast<jint>(bitmap->rowBytes());
}
-static int Bitmap_config(JNIEnv* env, jobject, SkBitmap* bitmap) {
- return bitmap->config();
+static jint Bitmap_config(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ return static_cast<jint>(bitmap->config());
}
-static int Bitmap_getGenerationId(JNIEnv* env, jobject, SkBitmap* bitmap) {
- return bitmap->getGenerationID();
+static jint Bitmap_getGenerationId(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ return static_cast<jint>(bitmap->getGenerationID());
}
-static jboolean Bitmap_hasAlpha(JNIEnv* env, jobject, SkBitmap* bitmap) {
- return !bitmap->isOpaque();
+static jboolean Bitmap_hasAlpha(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ return !bitmap->isOpaque() ? JNI_TRUE : JNI_FALSE;
}
-static void Bitmap_setHasAlpha(JNIEnv* env, jobject, SkBitmap* bitmap,
+static void Bitmap_setHasAlpha(JNIEnv* env, jobject, jlong bitmapHandle,
jboolean hasAlpha) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
bitmap->setIsOpaque(!hasAlpha);
}
-static jboolean Bitmap_hasMipMap(JNIEnv* env, jobject, SkBitmap* bitmap) {
- return bitmap->hasHardwareMipMap();
+static jboolean Bitmap_hasMipMap(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ return bitmap->hasHardwareMipMap() ? JNI_TRUE : JNI_FALSE;
}
-static void Bitmap_setHasMipMap(JNIEnv* env, jobject, SkBitmap* bitmap,
+static void Bitmap_setHasMipMap(JNIEnv* env, jobject, jlong bitmapHandle,
jboolean hasMipMap) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
bitmap->setHasHardwareMipMap(hasMipMap);
}
@@ -526,12 +543,13 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { }
static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
- const SkBitmap* bitmap,
+ jlong bitmapHandle,
jboolean isMutable, jint density,
jobject parcel) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
if (parcel == NULL) {
SkDebugf("------- writeToParcel null parcel\n");
- return false;
+ return JNI_FALSE;
}
android::Parcel* p = android::parcelForJavaObject(env, parcel);
@@ -562,7 +580,7 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject, android::status_t status = p->writeBlob(size, &blob);
if (status) {
doThrowRE(env, "Could not write bitmap to parcel blob.");
- return false;
+ return JNI_FALSE;
}
bitmap->lockPixels();
@@ -575,12 +593,14 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject, bitmap->unlockPixels();
blob.release();
- return true;
+ return JNI_TRUE;
}
static jobject Bitmap_extractAlpha(JNIEnv* env, jobject clazz,
- const SkBitmap* src, const SkPaint* paint,
+ jlong srcHandle, jlong paintHandle,
jintArray offsetXY) {
+ const SkBitmap* src = reinterpret_cast<SkBitmap*>(srcHandle);
+ const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);
SkIPoint offset;
SkBitmap* dst = new SkBitmap;
JavaPixelAllocator allocator(env);
@@ -606,8 +626,9 @@ static jobject Bitmap_extractAlpha(JNIEnv* env, jobject clazz, ///////////////////////////////////////////////////////////////////////////////
-static int Bitmap_getPixel(JNIEnv* env, jobject, const SkBitmap* bitmap,
- int x, int y, bool isPremultiplied) {
+static jint Bitmap_getPixel(JNIEnv* env, jobject, jlong bitmapHandle,
+ jint x, jint y, jboolean isPremultiplied) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkAutoLockPixels alp(*bitmap);
ToColorProc proc = ChooseToColorProc(*bitmap, isPremultiplied);
@@ -621,12 +642,13 @@ static int Bitmap_getPixel(JNIEnv* env, jobject, const SkBitmap* bitmap, SkColor dst[1];
proc(dst, src, 1, bitmap->getColorTable());
- return dst[0];
+ return static_cast<jint>(dst[0]);
}
-static void Bitmap_getPixels(JNIEnv* env, jobject, const SkBitmap* bitmap,
- jintArray pixelArray, int offset, int stride,
- int x, int y, int width, int height, bool isPremultiplied) {
+static void Bitmap_getPixels(JNIEnv* env, jobject, jlong bitmapHandle,
+ jintArray pixelArray, jint offset, jint stride,
+ jint x, jint y, jint width, jint height, jboolean isPremultiplied) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkAutoLockPixels alp(*bitmap);
ToColorProc proc = ChooseToColorProc(*bitmap, isPremultiplied);
@@ -651,8 +673,10 @@ static void Bitmap_getPixels(JNIEnv* env, jobject, const SkBitmap* bitmap, ///////////////////////////////////////////////////////////////////////////////
-static void Bitmap_setPixel(JNIEnv* env, jobject, const SkBitmap* bitmap,
- int x, int y, SkColor color, bool isPremultiplied) {
+static void Bitmap_setPixel(JNIEnv* env, jobject, jlong bitmapHandle,
+ jint x, jint y, jint colorHandle, jboolean isPremultiplied) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkColor color = static_cast<SkColor>(colorHandle);
SkAutoLockPixels alp(*bitmap);
if (NULL == bitmap->getPixels()) {
return;
@@ -667,15 +691,17 @@ static void Bitmap_setPixel(JNIEnv* env, jobject, const SkBitmap* bitmap, bitmap->notifyPixelsChanged();
}
-static void Bitmap_setPixels(JNIEnv* env, jobject, const SkBitmap* bitmap,
- jintArray pixelArray, int offset, int stride,
- int x, int y, int width, int height, bool isPremultiplied) {
+static void Bitmap_setPixels(JNIEnv* env, jobject, jlong bitmapHandle,
+ jintArray pixelArray, jint offset, jint stride,
+ jint x, jint y, jint width, jint height, jboolean isPremultiplied) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
GraphicsJNI::SetPixels(env, pixelArray, offset, stride,
x, y, width, height, *bitmap, isPremultiplied);
}
static void Bitmap_copyPixelsToBuffer(JNIEnv* env, jobject,
- const SkBitmap* bitmap, jobject jbuffer) {
+ jlong bitmapHandle, jobject jbuffer) {
+ const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkAutoLockPixels alp(*bitmap);
const void* src = bitmap->getPixels();
@@ -688,7 +714,8 @@ static void Bitmap_copyPixelsToBuffer(JNIEnv* env, jobject, }
static void Bitmap_copyPixelsFromBuffer(JNIEnv* env, jobject,
- const SkBitmap* bitmap, jobject jbuffer) {
+ jlong bitmapHandle, jobject jbuffer) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkAutoLockPixels alp(*bitmap);
void* dst = bitmap->getPixels();
@@ -700,12 +727,14 @@ static void Bitmap_copyPixelsFromBuffer(JNIEnv* env, jobject, }
}
-static bool Bitmap_sameAs(JNIEnv* env, jobject, const SkBitmap* bm0,
- const SkBitmap* bm1) {
+static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle,
+ jlong bm1Handle) {
+ const SkBitmap* bm0 = reinterpret_cast<SkBitmap*>(bm0Handle);
+ const SkBitmap* bm1 = reinterpret_cast<SkBitmap*>(bm1Handle);
if (bm0->width() != bm1->width() ||
bm0->height() != bm1->height() ||
bm0->config() != bm1->config()) {
- return false;
+ return JNI_FALSE;
}
SkAutoLockPixels alp0(*bm0);
@@ -713,24 +742,24 @@ static bool Bitmap_sameAs(JNIEnv* env, jobject, const SkBitmap* bm0, // if we can't load the pixels, return false
if (NULL == bm0->getPixels() || NULL == bm1->getPixels()) {
- return false;
+ return JNI_FALSE;
}
if (bm0->config() == SkBitmap::kIndex8_Config) {
SkColorTable* ct0 = bm0->getColorTable();
SkColorTable* ct1 = bm1->getColorTable();
if (NULL == ct0 || NULL == ct1) {
- return false;
+ return JNI_FALSE;
}
if (ct0->count() != ct1->count()) {
- return false;
+ return JNI_FALSE;
}
SkAutoLockColors alc0(ct0);
SkAutoLockColors alc1(ct1);
const size_t size = ct0->count() * sizeof(SkPMColor);
if (memcmp(alc0.colors(), alc1.colors(), size) != 0) {
- return false;
+ return JNI_FALSE;
}
}
@@ -741,13 +770,14 @@ static bool Bitmap_sameAs(JNIEnv* env, jobject, const SkBitmap* bm0, const size_t size = bm0->width() * bm0->bytesPerPixel();
for (int y = 0; y < h; y++) {
if (memcmp(bm0->getAddr(0, y), bm1->getAddr(0, y), size) != 0) {
- return false;
+ return JNI_FALSE;
}
}
- return true;
+ return JNI_TRUE;
}
-static void Bitmap_prepareToDraw(JNIEnv* env, jobject, SkBitmap* bitmap) {
+static void Bitmap_prepareToDraw(JNIEnv* env, jobject, jlong bitmapHandle) {
+ SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
bitmap->lockPixels();
bitmap->unlockPixels();
}
@@ -759,38 +789,38 @@ static void Bitmap_prepareToDraw(JNIEnv* env, jobject, SkBitmap* bitmap) { static JNINativeMethod gBitmapMethods[] = {
{ "nativeCreate", "([IIIIIIZ)Landroid/graphics/Bitmap;",
(void*)Bitmap_creator },
- { "nativeCopy", "(IIZ)Landroid/graphics/Bitmap;",
+ { "nativeCopy", "(JIZ)Landroid/graphics/Bitmap;",
(void*)Bitmap_copy },
- { "nativeDestructor", "(I)V", (void*)Bitmap_destructor },
- { "nativeRecycle", "(I)Z", (void*)Bitmap_recycle },
- { "nativeReconfigure", "(IIIII)V", (void*)Bitmap_reconfigure },
- { "nativeCompress", "(IIILjava/io/OutputStream;[B)Z",
+ { "nativeDestructor", "(J)V", (void*)Bitmap_destructor },
+ { "nativeRecycle", "(J)Z", (void*)Bitmap_recycle },
+ { "nativeReconfigure", "(JIIII)V", (void*)Bitmap_reconfigure },
+ { "nativeCompress", "(JIILjava/io/OutputStream;[B)Z",
(void*)Bitmap_compress },
- { "nativeErase", "(II)V", (void*)Bitmap_erase },
- { "nativeRowBytes", "(I)I", (void*)Bitmap_rowBytes },
- { "nativeConfig", "(I)I", (void*)Bitmap_config },
- { "nativeHasAlpha", "(I)Z", (void*)Bitmap_hasAlpha },
- { "nativeSetHasAlpha", "(IZ)V", (void*)Bitmap_setHasAlpha },
- { "nativeHasMipMap", "(I)Z", (void*)Bitmap_hasMipMap },
- { "nativeSetHasMipMap", "(IZ)V", (void*)Bitmap_setHasMipMap },
+ { "nativeErase", "(JI)V", (void*)Bitmap_erase },
+ { "nativeRowBytes", "(J)I", (void*)Bitmap_rowBytes },
+ { "nativeConfig", "(J)I", (void*)Bitmap_config },
+ { "nativeHasAlpha", "(J)Z", (void*)Bitmap_hasAlpha },
+ { "nativeSetHasAlpha", "(JZ)V", (void*)Bitmap_setHasAlpha },
+ { "nativeHasMipMap", "(J)Z", (void*)Bitmap_hasMipMap },
+ { "nativeSetHasMipMap", "(JZ)V", (void*)Bitmap_setHasMipMap },
{ "nativeCreateFromParcel",
"(Landroid/os/Parcel;)Landroid/graphics/Bitmap;",
(void*)Bitmap_createFromParcel },
- { "nativeWriteToParcel", "(IZILandroid/os/Parcel;)Z",
+ { "nativeWriteToParcel", "(JZILandroid/os/Parcel;)Z",
(void*)Bitmap_writeToParcel },
- { "nativeExtractAlpha", "(II[I)Landroid/graphics/Bitmap;",
+ { "nativeExtractAlpha", "(JJ[I)Landroid/graphics/Bitmap;",
(void*)Bitmap_extractAlpha },
- { "nativeGenerationId", "(I)I", (void*)Bitmap_getGenerationId },
- { "nativeGetPixel", "(IIIZ)I", (void*)Bitmap_getPixel },
- { "nativeGetPixels", "(I[IIIIIIIZ)V", (void*)Bitmap_getPixels },
- { "nativeSetPixel", "(IIIIZ)V", (void*)Bitmap_setPixel },
- { "nativeSetPixels", "(I[IIIIIIIZ)V", (void*)Bitmap_setPixels },
- { "nativeCopyPixelsToBuffer", "(ILjava/nio/Buffer;)V",
+ { "nativeGenerationId", "(J)I", (void*)Bitmap_getGenerationId },
+ { "nativeGetPixel", "(JIIZ)I", (void*)Bitmap_getPixel },
+ { "nativeGetPixels", "(J[IIIIIIIZ)V", (void*)Bitmap_getPixels },
+ { "nativeSetPixel", "(JIIIZ)V", (void*)Bitmap_setPixel },
+ { "nativeSetPixels", "(J[IIIIIIIZ)V", (void*)Bitmap_setPixels },
+ { "nativeCopyPixelsToBuffer", "(JLjava/nio/Buffer;)V",
(void*)Bitmap_copyPixelsToBuffer },
- { "nativeCopyPixelsFromBuffer", "(ILjava/nio/Buffer;)V",
+ { "nativeCopyPixelsFromBuffer", "(JLjava/nio/Buffer;)V",
(void*)Bitmap_copyPixelsFromBuffer },
- { "nativeSameAs", "(II)Z", (void*)Bitmap_sameAs },
- { "nativePrepareToDraw", "(I)V", (void*)Bitmap_prepareToDraw },
+ { "nativeSameAs", "(JJ)Z", (void*)Bitmap_sameAs },
+ { "nativePrepareToDraw", "(J)V", (void*)Bitmap_prepareToDraw },
};
#define kClassPathName "android/graphics/Bitmap"
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index da6219f..56d903c 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -272,7 +272,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding SkBitmap* outputBitmap = NULL; unsigned int existingBufferSize = 0; if (javaBitmap != NULL) { - outputBitmap = (SkBitmap*) env->GetIntField(javaBitmap, gBitmap_nativeBitmapFieldID); + outputBitmap = (SkBitmap*) env->GetLongField(javaBitmap, gBitmap_nativeBitmapFieldID); if (outputBitmap->isImmutable()) { ALOGW("Unable to reuse an immutable bitmap as an image decoder target."); javaBitmap = NULL; @@ -525,7 +525,7 @@ static jobject nativeDecodeFileDescriptor(JNIEnv* env, jobject clazz, jobject fi return doDecode(env, stream, padding, bitmapFactoryOptions, weOwnTheFD); } -static jobject nativeDecodeAsset(JNIEnv* env, jobject clazz, jint native_asset, +static jobject nativeDecodeAsset(JNIEnv* env, jobject clazz, jlong native_asset, jobject padding, jobject options) { SkStreamRewindable* stream; @@ -548,7 +548,7 @@ static jobject nativeDecodeAsset(JNIEnv* env, jobject clazz, jint native_asset, } static jobject nativeDecodeByteArray(JNIEnv* env, jobject, jbyteArray byteArray, - int offset, int length, jobject options) { + jint offset, jint length, jobject options) { /* If optionsShareable() we could decide to just wrap the java array and share it, but that means adding a globalref to the java array object @@ -585,7 +585,7 @@ static JNINativeMethod gMethods[] = { }, { "nativeDecodeAsset", - "(ILandroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;", + "(JLandroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;", (void*)nativeDecodeAsset }, @@ -638,7 +638,7 @@ int register_android_graphics_BitmapFactory(JNIEnv* env) { jclass bitmap_class = env->FindClass("android/graphics/Bitmap"); SkASSERT(bitmap_class); - gBitmap_nativeBitmapFieldID = getFieldIDCheck(env, bitmap_class, "mNativeBitmap", "I"); + gBitmap_nativeBitmapFieldID = getFieldIDCheck(env, bitmap_class, "mNativeBitmap", "J"); gBitmap_layoutBoundsFieldID = getFieldIDCheck(env, bitmap_class, "mLayoutBounds", "[I"); int ret = AndroidRuntime::registerNativeMethods(env, "android/graphics/BitmapFactory$Options", diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp index ee47ac4..e7d2422 100644 --- a/core/jni/android/graphics/BitmapRegionDecoder.cpp +++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp @@ -102,7 +102,7 @@ static jobject createBitmapRegionDecoder(JNIEnv* env, SkStream* stream) { } static jobject nativeNewInstanceFromByteArray(JNIEnv* env, jobject, jbyteArray byteArray, - int offset, int length, jboolean isShareable) { + jint offset, jint length, jboolean isShareable) { /* If isShareable we could decide to just wrap the java array and share it, but that means adding a globalref to the java array object For now we just always copy the array's data if isShareable. @@ -151,7 +151,7 @@ static jobject nativeNewInstanceFromStream(JNIEnv* env, jobject clazz, } static jobject nativeNewInstanceFromAsset(JNIEnv* env, jobject clazz, - jint native_asset, // Asset + jlong native_asset, // Asset jboolean isShareable) { Asset* asset = reinterpret_cast<Asset*>(native_asset); SkAutoTUnref<SkMemoryStream> stream(CopyAssetToStream(asset)); @@ -170,8 +170,9 @@ static jobject nativeNewInstanceFromAsset(JNIEnv* env, jobject clazz, * purgeable not supported * reportSizeToVM not supported */ -static jobject nativeDecodeRegion(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd, - int start_x, int start_y, int width, int height, jobject options) { +static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle, + jint start_x, jint start_y, jint width, jint height, jobject options) { + SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle); jobject tileBitmap = NULL; SkImageDecoder *decoder = brd->getDecoder(); int sampleSize = 1; @@ -256,15 +257,18 @@ static jobject nativeDecodeRegion(JNIEnv* env, jobject, SkBitmapRegionDecoder *b return GraphicsJNI::createBitmap(env, bitmap, buff, bitmapCreateFlags, NULL, NULL, -1); } -static int nativeGetHeight(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) { - return brd->getHeight(); +static jint nativeGetHeight(JNIEnv* env, jobject, jlong brdHandle) { + SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle); + return static_cast<jint>(brd->getHeight()); } -static int nativeGetWidth(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) { - return brd->getWidth(); +static jint nativeGetWidth(JNIEnv* env, jobject, jlong brdHandle) { + SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle); + return static_cast<jint>(brd->getWidth()); } -static void nativeClean(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) { +static void nativeClean(JNIEnv* env, jobject, jlong brdHandle) { + SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle); delete brd; } @@ -274,14 +278,14 @@ static void nativeClean(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) { static JNINativeMethod gBitmapRegionDecoderMethods[] = { { "nativeDecodeRegion", - "(IIIIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;", + "(JIIIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;", (void*)nativeDecodeRegion}, - { "nativeGetHeight", "(I)I", (void*)nativeGetHeight}, + { "nativeGetHeight", "(J)I", (void*)nativeGetHeight}, - { "nativeGetWidth", "(I)I", (void*)nativeGetWidth}, + { "nativeGetWidth", "(J)I", (void*)nativeGetWidth}, - { "nativeClean", "(I)V", (void*)nativeClean}, + { "nativeClean", "(J)V", (void*)nativeClean}, { "nativeNewInstance", "([BIIZ)Landroid/graphics/BitmapRegionDecoder;", @@ -299,7 +303,7 @@ static JNINativeMethod gBitmapRegionDecoderMethods[] = { }, { "nativeNewInstance", - "(IZ)Landroid/graphics/BitmapRegionDecoder;", + "(JZ)Landroid/graphics/BitmapRegionDecoder;", (void*)nativeNewInstanceFromAsset }, }; diff --git a/core/jni/android/graphics/Camera.cpp b/core/jni/android/graphics/Camera.cpp index 5176d9a..54d448e 100644 --- a/core/jni/android/graphics/Camera.cpp +++ b/core/jni/android/graphics/Camera.cpp @@ -7,84 +7,102 @@ static jfieldID gNativeInstanceFieldID; static void Camera_constructor(JNIEnv* env, jobject obj) { Sk3DView* view = new Sk3DView; - env->SetIntField(obj, gNativeInstanceFieldID, (int)view); + env->SetLongField(obj, gNativeInstanceFieldID, reinterpret_cast<jlong>(view)); } static void Camera_destructor(JNIEnv* env, jobject obj) { - delete (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* view = reinterpret_cast<Sk3DView*>(viewHandle); + delete view; } static void Camera_save(JNIEnv* env, jobject obj) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->save(); } static void Camera_restore(JNIEnv* env, jobject obj) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->restore(); } static void Camera_translate(JNIEnv* env, jobject obj, - float dx, float dy, float dz) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); + jfloat dx, jfloat dy, jfloat dz) { + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->translate(SkFloatToScalar(dx), SkFloatToScalar(dy), SkFloatToScalar(dz)); } -static void Camera_rotateX(JNIEnv* env, jobject obj, float degrees) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); +static void Camera_rotateX(JNIEnv* env, jobject obj, jfloat degrees) { + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->rotateX(SkFloatToScalar(degrees)); } -static void Camera_rotateY(JNIEnv* env, jobject obj, float degrees) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); +static void Camera_rotateY(JNIEnv* env, jobject obj, jfloat degrees) { + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->rotateY(SkFloatToScalar(degrees)); } -static void Camera_rotateZ(JNIEnv* env, jobject obj, float degrees) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); +static void Camera_rotateZ(JNIEnv* env, jobject obj, jfloat degrees) { + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->rotateZ(SkFloatToScalar(degrees)); } static void Camera_rotate(JNIEnv* env, jobject obj, jfloat x, jfloat y, jfloat z) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->rotateX(SkFloatToScalar(x)); v->rotateY(SkFloatToScalar(y)); v->rotateZ(SkFloatToScalar(z)); } static void Camera_setLocation(JNIEnv* env, jobject obj, jfloat x, jfloat y, jfloat z) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->setCameraLocation(SkFloatToScalar(x), SkFloatToScalar(y), SkFloatToScalar(z)); } static jfloat Camera_getLocationX(JNIEnv* env, jobject obj) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); return SkScalarToFloat(v->getCameraLocationX()); } static jfloat Camera_getLocationY(JNIEnv* env, jobject obj) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); return SkScalarToFloat(v->getCameraLocationY()); } static jfloat Camera_getLocationZ(JNIEnv* env, jobject obj) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); return SkScalarToFloat(v->getCameraLocationZ()); } -static void Camera_getMatrix(JNIEnv* env, jobject obj, int native_matrix) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); - v->getMatrix((SkMatrix*)native_matrix); +static void Camera_getMatrix(JNIEnv* env, jobject obj, jlong matrixHandle) { + SkMatrix* native_matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); + v->getMatrix(native_matrix); } -static void Camera_applyToCanvas(JNIEnv* env, jobject obj, int native_canvas) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); +static void Camera_applyToCanvas(JNIEnv* env, jobject obj, jlong canvasHandle) { + SkCanvas* native_canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->applyToCanvas((SkCanvas*)native_canvas); } -static float Camera_dotWithNormal(JNIEnv* env, jobject obj, - float x, float y, float z) { - Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); +static jfloat Camera_dotWithNormal(JNIEnv* env, jobject obj, + jfloat x, jfloat y, jfloat z) { + jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); + Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); SkScalar dot = v->dotWithNormal(SkFloatToScalar(x), SkFloatToScalar(y), SkFloatToScalar(z)); return SkScalarToFloat(dot); @@ -111,8 +129,8 @@ static JNINativeMethod gCameraMethods[] = { { "getLocationX", "()F", (void*)Camera_getLocationX }, { "getLocationY", "()F", (void*)Camera_getLocationY }, { "getLocationZ", "()F", (void*)Camera_getLocationZ }, - { "nativeGetMatrix", "(I)V", (void*)Camera_getMatrix }, - { "nativeApplyToCanvas", "(I)V", (void*)Camera_applyToCanvas }, + { "nativeGetMatrix", "(J)V", (void*)Camera_getMatrix }, + { "nativeApplyToCanvas", "(J)V", (void*)Camera_applyToCanvas }, { "dotWithNormal", "(FFF)F", (void*)Camera_dotWithNormal } }; @@ -121,7 +139,7 @@ int register_android_graphics_Camera(JNIEnv* env) { if (clazz == 0) { return -1; } - gNativeInstanceFieldID = env->GetFieldID(clazz, "native_instance", "I"); + gNativeInstanceFieldID = env->GetFieldID(clazz, "native_instance", "J"); if (gNativeInstanceFieldID == 0) { return -1; } diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp index 813dd5a..89490bc 100644 --- a/core/jni/android/graphics/Canvas.cpp +++ b/core/jni/android/graphics/Canvas.cpp @@ -38,13 +38,13 @@ static uint32_t get_thread_msec() { #if defined(HAVE_POSIX_CLOCKS) struct timespec tm; - + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm); - + return tm.tv_sec * 1000LL + tm.tv_nsec / 1000000; #else struct timeval tv; - + gettimeofday(&tv, NULL); return tv.tv_sec * 1000LL + tv.tv_usec / 1000; #endif @@ -70,23 +70,27 @@ private: class SkCanvasGlue { public: - static void finalizer(JNIEnv* env, jobject clazz, SkCanvas* canvas) { + static void finalizer(JNIEnv* env, jobject clazz, jlong canvasHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); canvas->unref(); } - static SkCanvas* initRaster(JNIEnv* env, jobject, SkBitmap* bitmap) { + static jlong initRaster(JNIEnv* env, jobject, jlong bitmapHandle) { + SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); if (bitmap) { - return new SkCanvas(*bitmap); + return reinterpret_cast<jlong>(new SkCanvas(*bitmap)); } else { // Create an empty bitmap device to prevent callers from crashing // if they attempt to draw into this canvas. SkBitmap emptyBitmap; - return new SkCanvas(emptyBitmap); + return reinterpret_cast<jlong>(new SkCanvas(emptyBitmap)); } } - + static void copyCanvasState(JNIEnv* env, jobject clazz, - SkCanvas* srcCanvas, SkCanvas* dstCanvas) { + jlong srcCanvasHandle, jlong dstCanvasHandle) { + SkCanvas* srcCanvas = reinterpret_cast<SkCanvas*>(srcCanvasHandle); + SkCanvas* dstCanvas = reinterpret_cast<SkCanvas*>(dstCanvasHandle); if (srcCanvas && dstCanvas) { dstCanvas->setMatrix(srcCanvas->getTotalMatrix()); if (NULL != srcCanvas->getDevice() && NULL != dstCanvas->getDevice()) { @@ -110,73 +114,89 @@ public: static jboolean isOpaque(JNIEnv* env, jobject jcanvas) { NPE_CHECK_RETURN_ZERO(env, jcanvas); SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas); - return canvas->getDevice()->accessBitmap(false).isOpaque(); + bool result = canvas->getDevice()->accessBitmap(false).isOpaque(); + return result ? JNI_TRUE : JNI_FALSE; } - - static int getWidth(JNIEnv* env, jobject jcanvas) { + + static jint getWidth(JNIEnv* env, jobject jcanvas) { NPE_CHECK_RETURN_ZERO(env, jcanvas); SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas); - return canvas->getDevice()->accessBitmap(false).width(); + int width = canvas->getDevice()->accessBitmap(false).width(); + return static_cast<jint>(width); } - - static int getHeight(JNIEnv* env, jobject jcanvas) { + + static jint getHeight(JNIEnv* env, jobject jcanvas) { NPE_CHECK_RETURN_ZERO(env, jcanvas); SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas); - return canvas->getDevice()->accessBitmap(false).height(); + int height = canvas->getDevice()->accessBitmap(false).height(); + return static_cast<jint>(height); } - static int saveAll(JNIEnv* env, jobject jcanvas) { + static jint saveAll(JNIEnv* env, jobject jcanvas) { NPE_CHECK_RETURN_ZERO(env, jcanvas); - return GraphicsJNI::getNativeCanvas(env, jcanvas)->save(); + int result = GraphicsJNI::getNativeCanvas(env, jcanvas)->save(); + return static_cast<jint>(result); } - - static int save(JNIEnv* env, jobject jcanvas, SkCanvas::SaveFlags flags) { + + static jint save(JNIEnv* env, jobject jcanvas, jint flagsHandle) { + SkCanvas::SaveFlags flags = static_cast<SkCanvas::SaveFlags>(flagsHandle); NPE_CHECK_RETURN_ZERO(env, jcanvas); - return GraphicsJNI::getNativeCanvas(env, jcanvas)->save(flags); + int result = GraphicsJNI::getNativeCanvas(env, jcanvas)->save(flags); + return static_cast<jint>(result); } - - static int saveLayer(JNIEnv* env, jobject, SkCanvas* canvas, jobject bounds, - SkPaint* paint, int flags) { + + static jint saveLayer(JNIEnv* env, jobject, jlong canvasHandle, jobject bounds, + jlong paintHandle, jint flags) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkRect* bounds_ = NULL; SkRect storage; if (bounds != NULL) { GraphicsJNI::jrectf_to_rect(env, bounds, &storage); bounds_ = &storage; } - return canvas->saveLayer(bounds_, paint, (SkCanvas::SaveFlags)flags); + return canvas->saveLayer(bounds_, paint, static_cast<SkCanvas::SaveFlags>(flags)); } - - static int saveLayer4F(JNIEnv* env, jobject, SkCanvas* canvas, + + static jint saveLayer4F(JNIEnv* env, jobject, jlong canvasHandle, jfloat l, jfloat t, jfloat r, jfloat b, - SkPaint* paint, int flags) { + jlong paintHandle, jint flags) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkRect bounds; bounds.set(SkFloatToScalar(l), SkFloatToScalar(t), SkFloatToScalar(r), SkFloatToScalar(b)); - return canvas->saveLayer(&bounds, paint, (SkCanvas::SaveFlags)flags); + int result = canvas->saveLayer(&bounds, paint, + static_cast<SkCanvas::SaveFlags>(flags)); + return static_cast<jint>(result); } - - static int saveLayerAlpha(JNIEnv* env, jobject, SkCanvas* canvas, - jobject bounds, int alpha, int flags) { + + static jint saveLayerAlpha(JNIEnv* env, jobject, jlong canvasHandle, + jobject bounds, jint alpha, jint flags) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); SkRect* bounds_ = NULL; SkRect storage; if (bounds != NULL) { GraphicsJNI::jrectf_to_rect(env, bounds, &storage); bounds_ = &storage; } - return canvas->saveLayerAlpha(bounds_, alpha, - (SkCanvas::SaveFlags)flags); + int result = canvas->saveLayerAlpha(bounds_, alpha, + static_cast<SkCanvas::SaveFlags>(flags)); + return static_cast<jint>(result); } - - static int saveLayerAlpha4F(JNIEnv* env, jobject, SkCanvas* canvas, + + static jint saveLayerAlpha4F(JNIEnv* env, jobject, jlong canvasHandle, jfloat l, jfloat t, jfloat r, jfloat b, - int alpha, int flags) { + jint alpha, jint flags) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); SkRect bounds; bounds.set(SkFloatToScalar(l), SkFloatToScalar(t), SkFloatToScalar(r), SkFloatToScalar(b)); - return canvas->saveLayerAlpha(&bounds, alpha, - (SkCanvas::SaveFlags)flags); + int result = canvas->saveLayerAlpha(&bounds, alpha, + static_cast<SkCanvas::SaveFlags>(flags)); + return static_cast<jint>(result); } - + static void restore(JNIEnv* env, jobject jcanvas) { NPE_CHECK_RETURN_VOID(env, jcanvas); SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas); @@ -186,13 +206,14 @@ public: } canvas->restore(); } - - static int getSaveCount(JNIEnv* env, jobject jcanvas) { + + static jint getSaveCount(JNIEnv* env, jobject jcanvas) { NPE_CHECK_RETURN_ZERO(env, jcanvas); - return GraphicsJNI::getNativeCanvas(env, jcanvas)->getSaveCount(); + int result = GraphicsJNI::getNativeCanvas(env, jcanvas)->getSaveCount(); + return static_cast<jint>(result); } - - static void restoreToCount(JNIEnv* env, jobject jcanvas, int restoreCount) { + + static void restoreToCount(JNIEnv* env, jobject jcanvas, jint restoreCount) { NPE_CHECK_RETURN_VOID(env, jcanvas); SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas); if (restoreCount < 1) { @@ -201,48 +222,52 @@ public: } canvas->restoreToCount(restoreCount); } - + static void translate(JNIEnv* env, jobject jcanvas, jfloat dx, jfloat dy) { NPE_CHECK_RETURN_VOID(env, jcanvas); SkScalar dx_ = SkFloatToScalar(dx); SkScalar dy_ = SkFloatToScalar(dy); (void)GraphicsJNI::getNativeCanvas(env, jcanvas)->translate(dx_, dy_); } - + static void scale__FF(JNIEnv* env, jobject jcanvas, jfloat sx, jfloat sy) { NPE_CHECK_RETURN_VOID(env, jcanvas); SkScalar sx_ = SkFloatToScalar(sx); SkScalar sy_ = SkFloatToScalar(sy); (void)GraphicsJNI::getNativeCanvas(env, jcanvas)->scale(sx_, sy_); } - + static void rotate__F(JNIEnv* env, jobject jcanvas, jfloat degrees) { NPE_CHECK_RETURN_VOID(env, jcanvas); SkScalar degrees_ = SkFloatToScalar(degrees); (void)GraphicsJNI::getNativeCanvas(env, jcanvas)->rotate(degrees_); } - + static void skew__FF(JNIEnv* env, jobject jcanvas, jfloat sx, jfloat sy) { NPE_CHECK_RETURN_VOID(env, jcanvas); SkScalar sx_ = SkFloatToScalar(sx); SkScalar sy_ = SkFloatToScalar(sy); (void)GraphicsJNI::getNativeCanvas(env, jcanvas)->skew(sx_, sy_); } - - static void concat(JNIEnv* env, jobject, SkCanvas* canvas, - const SkMatrix* matrix) { + + static void concat(JNIEnv* env, jobject, jlong canvasHandle, + jlong matrixHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + const SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); canvas->concat(*matrix); } - - static void setMatrix(JNIEnv* env, jobject, SkCanvas* canvas, - const SkMatrix* matrix) { + + static void setMatrix(JNIEnv* env, jobject, jlong canvasHandle, + jlong matrixHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + const SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); if (NULL == matrix) { canvas->resetMatrix(); } else { canvas->setMatrix(*matrix); } } - + static jboolean clipRect_FFFF(JNIEnv* env, jobject jcanvas, jfloat left, jfloat top, jfloat right, jfloat bottom) { NPE_CHECK_RETURN_ZERO(env, jcanvas); @@ -250,122 +275,149 @@ public: r.set(SkFloatToScalar(left), SkFloatToScalar(top), SkFloatToScalar(right), SkFloatToScalar(bottom)); SkCanvas* c = GraphicsJNI::getNativeCanvas(env, jcanvas); - return c->clipRect(r); + bool result = c->clipRect(r); + return result ? JNI_TRUE : JNI_FALSE; } - + static jboolean clipRect_IIII(JNIEnv* env, jobject jcanvas, jint left, jint top, jint right, jint bottom) { NPE_CHECK_RETURN_ZERO(env, jcanvas); SkRect r; r.set(SkIntToScalar(left), SkIntToScalar(top), SkIntToScalar(right), SkIntToScalar(bottom)); - return GraphicsJNI::getNativeCanvas(env, jcanvas)->clipRect(r); + bool result = GraphicsJNI::getNativeCanvas(env, jcanvas)->clipRect(r); + return result ? JNI_TRUE : JNI_FALSE; } - + static jboolean clipRect_RectF(JNIEnv* env, jobject jcanvas, jobject rectf) { NPE_CHECK_RETURN_ZERO(env, jcanvas); NPE_CHECK_RETURN_ZERO(env, rectf); SkCanvas* c = GraphicsJNI::getNativeCanvas(env, jcanvas); SkRect tmp; - return c->clipRect(*GraphicsJNI::jrectf_to_rect(env, rectf, &tmp)); + bool result = c->clipRect(*GraphicsJNI::jrectf_to_rect(env, rectf, &tmp)); + return result ? JNI_TRUE : JNI_FALSE; } - + static jboolean clipRect_Rect(JNIEnv* env, jobject jcanvas, jobject rect) { NPE_CHECK_RETURN_ZERO(env, jcanvas); NPE_CHECK_RETURN_ZERO(env, rect); SkCanvas* c = GraphicsJNI::getNativeCanvas(env, jcanvas); SkRect tmp; - return c->clipRect(*GraphicsJNI::jrect_to_rect(env, rect, &tmp)); + bool result = c->clipRect(*GraphicsJNI::jrect_to_rect(env, rect, &tmp)); + return result ? JNI_TRUE : JNI_FALSE; + } - - static jboolean clipRect(JNIEnv* env, jobject, SkCanvas* canvas, - float left, float top, float right, float bottom, - int op) { + + static jboolean clipRect(JNIEnv* env, jobject, jlong canvasHandle, + jfloat left, jfloat top, jfloat right, jfloat bottom, + jint op) { SkRect rect; + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); rect.set(SkFloatToScalar(left), SkFloatToScalar(top), SkFloatToScalar(right), SkFloatToScalar(bottom)); - return canvas->clipRect(rect, (SkRegion::Op)op); + bool result = canvas->clipRect(rect, static_cast<SkRegion::Op>(op)); + return result ? JNI_TRUE : JNI_FALSE; + } - - static jboolean clipPath(JNIEnv* env, jobject, SkCanvas* canvas, - SkPath* path, int op) { - return canvas->clipPath(*path, (SkRegion::Op)op); + + static jboolean clipPath(JNIEnv* env, jobject, jlong canvasHandle, + SkPath* path, jint op) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + bool result = canvas->clipPath(*path, static_cast<SkRegion::Op>(op)); + return result ? JNI_TRUE : JNI_FALSE; } - - static jboolean clipRegion(JNIEnv* env, jobject, SkCanvas* canvas, - SkRegion* deviceRgn, int op) { - return canvas->clipRegion(*deviceRgn, (SkRegion::Op)op); + + static jboolean clipRegion(JNIEnv* env, jobject, jlong canvasHandle, + jlong deviceRgnHandle, jint op) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkRegion* deviceRgn = reinterpret_cast<SkRegion*>(deviceRgnHandle); + bool result = canvas->clipRegion(*deviceRgn, static_cast<SkRegion::Op>(op)); + return result ? JNI_TRUE : JNI_FALSE; } - - static void setDrawFilter(JNIEnv* env, jobject, SkCanvas* canvas, + + static void setDrawFilter(JNIEnv* env, jobject, jlong canvasHandle, SkDrawFilter* filter) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); canvas->setDrawFilter(filter); } - - static jboolean quickReject__RectF(JNIEnv* env, jobject, SkCanvas* canvas, + + static jboolean quickReject__RectF(JNIEnv* env, jobject, jlong canvasHandle, jobject rect) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); SkRect rect_; GraphicsJNI::jrectf_to_rect(env, rect, &rect_); return canvas->quickReject(rect_); } - static jboolean quickReject__Path(JNIEnv* env, jobject, SkCanvas* canvas, + static jboolean quickReject__Path(JNIEnv* env, jobject, jlong canvasHandle, SkPath* path) { - return canvas->quickReject(*path); + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + bool result = canvas->quickReject(*path); + return result ? JNI_TRUE : JNI_FALSE; } - static jboolean quickReject__FFFF(JNIEnv* env, jobject, SkCanvas* canvas, + static jboolean quickReject__FFFF(JNIEnv* env, jobject, jlong canvasHandle, jfloat left, jfloat top, jfloat right, jfloat bottom) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); SkRect r; r.set(SkFloatToScalar(left), SkFloatToScalar(top), SkFloatToScalar(right), SkFloatToScalar(bottom)); - return canvas->quickReject(r); + bool result = canvas->quickReject(r); + return result ? JNI_TRUE : JNI_FALSE; } - - static void drawRGB(JNIEnv* env, jobject, SkCanvas* canvas, + + static void drawRGB(JNIEnv* env, jobject, jlong canvasHandle, jint r, jint g, jint b) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); canvas->drawARGB(0xFF, r, g, b); } - - static void drawARGB(JNIEnv* env, jobject, SkCanvas* canvas, + + static void drawARGB(JNIEnv* env, jobject, jlong canvasHandle, jint a, jint r, jint g, jint b) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); canvas->drawARGB(a, r, g, b); } - - static void drawColor__I(JNIEnv* env, jobject, SkCanvas* canvas, + + static void drawColor__I(JNIEnv* env, jobject, jlong canvasHandle, jint color) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); canvas->drawColor(color); } - - static void drawColor__II(JNIEnv* env, jobject, SkCanvas* canvas, - jint color, SkPorterDuff::Mode mode) { + + static void drawColor__II(JNIEnv* env, jobject, jlong canvasHandle, + jint color, jint modeHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPorterDuff::Mode mode = static_cast<SkPorterDuff::Mode>(modeHandle); canvas->drawColor(color, SkPorterDuff::ToXfermodeMode(mode)); } - - static void drawPaint(JNIEnv* env, jobject, SkCanvas* canvas, - SkPaint* paint) { + + static void drawPaint(JNIEnv* env, jobject, jlong canvasHandle, + jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); canvas->drawPaint(*paint); } - + static void doPoints(JNIEnv* env, jobject jcanvas, jfloatArray jptsArray, jint offset, jint count, jobject jpaint, - SkCanvas::PointMode mode) { + jint modeHandle) { NPE_CHECK_RETURN_VOID(env, jcanvas); NPE_CHECK_RETURN_VOID(env, jptsArray); NPE_CHECK_RETURN_VOID(env, jpaint); + SkCanvas::PointMode mode = static_cast<SkCanvas::PointMode>(modeHandle); SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas); const SkPaint& paint = *GraphicsJNI::getNativePaint(env, jpaint); - + AutoJavaFloatArray autoPts(env, jptsArray); float* floats = autoPts.ptr(); const int length = autoPts.length(); - + if ((offset | count) < 0 || offset + count > length) { doThrowAIOOBE(env); return; } - + // now convert the floats into SkPoints count >>= 1; // now it is the number of points SkAutoSTMalloc<32, SkPoint> storage(count); @@ -374,98 +426,118 @@ public: for (int i = 0; i < count; i++) { pts[i].set(SkFloatToScalar(src[0]), SkFloatToScalar(src[1])); src += 2; - } + } canvas->drawPoints(mode, count, pts, paint); } - + static void drawPoints(JNIEnv* env, jobject jcanvas, jfloatArray jptsArray, jint offset, jint count, jobject jpaint) { doPoints(env, jcanvas, jptsArray, offset, count, jpaint, SkCanvas::kPoints_PointMode); } - + static void drawLines(JNIEnv* env, jobject jcanvas, jfloatArray jptsArray, jint offset, jint count, jobject jpaint) { doPoints(env, jcanvas, jptsArray, offset, count, jpaint, SkCanvas::kLines_PointMode); } - - static void drawPoint(JNIEnv* env, jobject jcanvas, float x, float y, + + static void drawPoint(JNIEnv* env, jobject jcanvas, jfloat x, jfloat y, jobject jpaint) { NPE_CHECK_RETURN_VOID(env, jcanvas); NPE_CHECK_RETURN_VOID(env, jpaint); SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas); const SkPaint& paint = *GraphicsJNI::getNativePaint(env, jpaint); - + canvas->drawPoint(SkFloatToScalar(x), SkFloatToScalar(y), paint); } - - static void drawLine__FFFFPaint(JNIEnv* env, jobject, SkCanvas* canvas, + + static void drawLine__FFFFPaint(JNIEnv* env, jobject, jlong canvasHandle, jfloat startX, jfloat startY, jfloat stopX, - jfloat stopY, SkPaint* paint) { + jfloat stopY, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); canvas->drawLine(SkFloatToScalar(startX), SkFloatToScalar(startY), SkFloatToScalar(stopX), SkFloatToScalar(stopY), *paint); } - - static void drawRect__RectFPaint(JNIEnv* env, jobject, SkCanvas* canvas, - jobject rect, SkPaint* paint) { + + static void drawRect__RectFPaint(JNIEnv* env, jobject, jlong canvasHandle, + jobject rect, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkRect rect_; GraphicsJNI::jrectf_to_rect(env, rect, &rect_); canvas->drawRect(rect_, *paint); } - - static void drawRect__FFFFPaint(JNIEnv* env, jobject, SkCanvas* canvas, + + static void drawRect__FFFFPaint(JNIEnv* env, jobject, jlong canvasHandle, jfloat left, jfloat top, jfloat right, - jfloat bottom, SkPaint* paint) { + jfloat bottom, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkScalar left_ = SkFloatToScalar(left); SkScalar top_ = SkFloatToScalar(top); SkScalar right_ = SkFloatToScalar(right); SkScalar bottom_ = SkFloatToScalar(bottom); canvas->drawRectCoords(left_, top_, right_, bottom_, *paint); } - - static void drawOval(JNIEnv* env, jobject, SkCanvas* canvas, jobject joval, - SkPaint* paint) { + + static void drawOval(JNIEnv* env, jobject, jlong canvasHandle, jobject joval, + jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkRect oval; GraphicsJNI::jrectf_to_rect(env, joval, &oval); canvas->drawOval(oval, *paint); } - - static void drawCircle(JNIEnv* env, jobject, SkCanvas* canvas, jfloat cx, - jfloat cy, jfloat radius, SkPaint* paint) { + + static void drawCircle(JNIEnv* env, jobject, jlong canvasHandle, jfloat cx, + jfloat cy, jfloat radius, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); canvas->drawCircle(SkFloatToScalar(cx), SkFloatToScalar(cy), SkFloatToScalar(radius), *paint); } - - static void drawArc(JNIEnv* env, jobject, SkCanvas* canvas, jobject joval, + + static void drawArc(JNIEnv* env, jobject, jlong canvasHandle, jobject joval, jfloat startAngle, jfloat sweepAngle, - jboolean useCenter, SkPaint* paint) { + jboolean useCenter, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkRect oval; GraphicsJNI::jrectf_to_rect(env, joval, &oval); canvas->drawArc(oval, SkFloatToScalar(startAngle), SkFloatToScalar(sweepAngle), useCenter, *paint); } - - static void drawRoundRect(JNIEnv* env, jobject, SkCanvas* canvas, + + static void drawRoundRect(JNIEnv* env, jobject, jlong canvasHandle, jobject jrect, jfloat rx, jfloat ry, - SkPaint* paint) { + jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkRect rect; GraphicsJNI::jrectf_to_rect(env, jrect, &rect); canvas->drawRoundRect(rect, SkFloatToScalar(rx), SkFloatToScalar(ry), *paint); } - - static void drawPath(JNIEnv* env, jobject, SkCanvas* canvas, SkPath* path, - SkPaint* paint) { + + static void drawPath(JNIEnv* env, jobject, jlong canvasHandle, jlong pathHandle, + jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); canvas->drawPath(*path, *paint); } - + static void drawBitmap__BitmapFFPaint(JNIEnv* env, jobject jcanvas, - SkCanvas* canvas, SkBitmap* bitmap, + jlong canvasHandle, jlong bitmapHandle, jfloat left, jfloat top, - SkPaint* paint, jint canvasDensity, + jlong paintHandle, jint canvasDensity, jint screenDensity, jint bitmapDensity) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkScalar left_ = SkFloatToScalar(left); SkScalar top_ = SkFloatToScalar(top); @@ -508,7 +580,7 @@ public: GraphicsJNI::jrect_to_irect(env, srcIRect, &src); srcPtr = &src; } - + if (screenDensity != 0 && screenDensity != bitmapDensity) { SkPaint filteredPaint; if (paint) { @@ -521,31 +593,39 @@ public: } } - static void drawBitmapRF(JNIEnv* env, jobject, SkCanvas* canvas, - SkBitmap* bitmap, jobject srcIRect, - jobject dstRectF, SkPaint* paint, + static void drawBitmapRF(JNIEnv* env, jobject, jlong canvasHandle, + jlong bitmapHandle, jobject srcIRect, + jobject dstRectF, jlong paintHandle, jint screenDensity, jint bitmapDensity) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkRect dst; GraphicsJNI::jrectf_to_rect(env, dstRectF, &dst); doDrawBitmap(env, canvas, bitmap, srcIRect, dst, paint, screenDensity, bitmapDensity); } - - static void drawBitmapRR(JNIEnv* env, jobject, SkCanvas* canvas, - SkBitmap* bitmap, jobject srcIRect, - jobject dstRect, SkPaint* paint, + + static void drawBitmapRR(JNIEnv* env, jobject, jlong canvasHandle, + jlong bitmapHandle, jobject srcIRect, + jobject dstRect, jlong paintHandle, jint screenDensity, jint bitmapDensity) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkRect dst; GraphicsJNI::jrect_to_rect(env, dstRect, &dst); doDrawBitmap(env, canvas, bitmap, srcIRect, dst, paint, screenDensity, bitmapDensity); } - - static void drawBitmapArray(JNIEnv* env, jobject, SkCanvas* canvas, - jintArray jcolors, int offset, int stride, - jfloat x, jfloat y, int width, int height, - jboolean hasAlpha, SkPaint* paint) + + static void drawBitmapArray(JNIEnv* env, jobject, jlong canvasHandle, + jintArray jcolors, jint offset, jint stride, + jfloat x, jfloat y, jint width, jint height, + jboolean hasAlpha, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkBitmap bitmap; bitmap.setConfig(hasAlpha ? SkBitmap::kARGB_8888_Config : SkBitmap::kRGB_565_Config, width, height); @@ -561,24 +641,31 @@ public: canvas->drawBitmap(bitmap, SkFloatToScalar(x), SkFloatToScalar(y), paint); } - - static void drawBitmapMatrix(JNIEnv* env, jobject, SkCanvas* canvas, - const SkBitmap* bitmap, const SkMatrix* matrix, - const SkPaint* paint) { + + static void drawBitmapMatrix(JNIEnv* env, jobject, jlong canvasHandle, + jlong bitmapHandle, jlong matrixHandle, + jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + const SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); canvas->drawBitmapMatrix(*bitmap, *matrix, paint); } - - static void drawBitmapMesh(JNIEnv* env, jobject, SkCanvas* canvas, - const SkBitmap* bitmap, int meshWidth, int meshHeight, - jfloatArray jverts, int vertIndex, jintArray jcolors, - int colorIndex, const SkPaint* paint) { + + static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle, + jlong bitmapHandle, jint meshWidth, jint meshHeight, + jfloatArray jverts, jint vertIndex, jintArray jcolors, + jint colorIndex, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const int ptCount = (meshWidth + 1) * (meshHeight + 1); const int indexCount = meshWidth * meshHeight * 6; AutoJavaFloatArray vertA(env, jverts, vertIndex + (ptCount << 1)); AutoJavaIntArray colorA(env, jcolors, colorIndex + ptCount); - + /* Our temp storage holds 2 or 3 arrays. texture points [ptCount * sizeof(SkPoint)] optionally vertex points [ptCount * sizeof(SkPoint)] if we need a @@ -617,7 +704,7 @@ public: const SkScalar h = SkIntToScalar(bitmap->height()); const SkScalar dx = w / meshWidth; const SkScalar dy = h / meshHeight; - + SkPoint* texsPtr = texs; SkScalar y = 0; for (int i = 0; i <= meshHeight; i++) { @@ -636,7 +723,7 @@ public: } SkASSERT(texsPtr - texs == ptCount); } - + // cons up indices { uint16_t* indexPtr = indices; @@ -684,13 +771,16 @@ public: indexCount, tmpPaint); } - static void drawVertices(JNIEnv* env, jobject, SkCanvas* canvas, - SkCanvas::VertexMode mode, int vertexCount, - jfloatArray jverts, int vertIndex, - jfloatArray jtexs, int texIndex, - jintArray jcolors, int colorIndex, - jshortArray jindices, int indexIndex, - int indexCount, const SkPaint* paint) { + static void drawVertices(JNIEnv* env, jobject, jlong canvasHandle, + jint modeHandle, jint vertexCount, + jfloatArray jverts, jint vertIndex, + jfloatArray jtexs, jint texIndex, + jintArray jcolors, jint colorIndex, + jshortArray jindices, jint indexIndex, + jint indexCount, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkCanvas::VertexMode mode = static_cast<SkCanvas::VertexMode>(modeHandle); + const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); AutoJavaFloatArray vertA(env, jverts, vertIndex + vertexCount); AutoJavaFloatArray texA(env, jtexs, texIndex + vertexCount); @@ -712,7 +802,7 @@ public: count += ptCount; // += for texs } SkAutoMalloc storage(count * sizeof(SkPoint)); - verts = (SkPoint*)storage.get(); + verts = (SkPoint*)storage.get(); const float* src = vertA.ptr() + vertIndex; for (int i = 0; i < ptCount; i++) { verts[i].set(SkFloatToFixed(src[0]), SkFloatToFixed(src[1])); @@ -742,18 +832,22 @@ public: } - static void drawText___CIIFFIPaint(JNIEnv* env, jobject, SkCanvas* canvas, - jcharArray text, int index, int count, - jfloat x, jfloat y, int flags, SkPaint* paint) { + static void drawText___CIIFFIPaint(JNIEnv* env, jobject, jlong canvasHandle, + jcharArray text, jint index, jint count, + jfloat x, jfloat y, jint flags, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jchar* textArray = env->GetCharArrayElements(text, NULL); drawTextWithGlyphs(canvas, textArray + index, 0, count, x, y, flags, paint); env->ReleaseCharArrayElements(text, textArray, JNI_ABORT); } static void drawText__StringIIFFIPaint(JNIEnv* env, jobject, - SkCanvas* canvas, jstring text, - int start, int end, - jfloat x, jfloat y, int flags, SkPaint* paint) { + jlong canvasHandle, jstring text, + jint start, jint end, + jfloat x, jfloat y, jint flags, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* textArray = env->GetStringChars(text, NULL); drawTextWithGlyphs(canvas, textArray, start, end, x, y, flags, paint); env->ReleaseStringChars(text, textArray); @@ -843,9 +937,11 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l } static void drawTextRun___CIIIIFFIPaint( - JNIEnv* env, jobject, SkCanvas* canvas, jcharArray text, int index, - int count, int contextIndex, int contextCount, - jfloat x, jfloat y, int dirFlags, SkPaint* paint) { + JNIEnv* env, jobject, jlong canvasHandle, jcharArray text, jint index, + jint count, jint contextIndex, jint contextCount, + jfloat x, jfloat y, jint dirFlags, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jchar* chars = env->GetCharArrayElements(text, NULL); drawTextWithGlyphs(canvas, chars + contextIndex, index - contextIndex, @@ -854,9 +950,11 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l } static void drawTextRun__StringIIIIFFIPaint( - JNIEnv* env, jobject obj, SkCanvas* canvas, jstring text, jint start, + JNIEnv* env, jobject obj, jlong canvasHandle, jstring text, jint start, jint end, jint contextStart, jint contextEnd, - jfloat x, jfloat y, jint dirFlags, SkPaint* paint) { + jfloat x, jfloat y, jint dirFlags, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jint count = end - start; jint contextCount = contextEnd - contextStart; @@ -866,9 +964,11 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l env->ReleaseStringChars(text, chars); } - static void drawPosText___CII_FPaint(JNIEnv* env, jobject, SkCanvas* canvas, - jcharArray text, int index, int count, - jfloatArray pos, SkPaint* paint) { + static void drawPosText___CII_FPaint(JNIEnv* env, jobject, jlong canvasHandle, + jcharArray text, jint index, jint count, + jfloatArray pos, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jchar* textArray = text ? env->GetCharArrayElements(text, NULL) : NULL; jsize textCount = text ? env->GetArrayLength(text) : NULL; float* posArray = pos ? env->GetFloatArrayElements(pos, NULL) : NULL; @@ -879,12 +979,12 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l posPtr[indx].fX = SkFloatToScalar(posArray[indx << 1]); posPtr[indx].fY = SkFloatToScalar(posArray[(indx << 1) + 1]); } - + SkPaint::TextEncoding encoding = paint->getTextEncoding(); paint->setTextEncoding(SkPaint::kUTF16_TextEncoding); canvas->drawPosText(textArray + index, count << 1, posPtr, *paint); paint->setTextEncoding(encoding); - + if (text) { env->ReleaseCharArrayElements(text, textArray, 0); } @@ -895,9 +995,11 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l } static void drawPosText__String_FPaint(JNIEnv* env, jobject, - SkCanvas* canvas, jstring text, + jlong canvasHandle, jstring text, jfloatArray pos, - SkPaint* paint) { + jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const void* text_ = text ? env->GetStringChars(text, NULL) : NULL; int byteLength = text ? env->GetStringLength(text) : 0; float* posArray = pos ? env->GetFloatArrayElements(pos, NULL) : NULL; @@ -924,8 +1026,11 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l } static void drawTextOnPath___CIIPathFFPaint(JNIEnv* env, jobject, - SkCanvas* canvas, jcharArray text, int index, int count, - SkPath* path, jfloat hOffset, jfloat vOffset, jint bidiFlags, SkPaint* paint) { + jlong canvasHandle, jcharArray text, jint index, jint count, + jlong pathHandle, jfloat hOffset, jfloat vOffset, jint bidiFlags, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jchar* textArray = env->GetCharArrayElements(text, NULL); TextLayout::drawTextOnPath(paint, textArray + index, count, bidiFlags, hOffset, vOffset, @@ -934,8 +1039,11 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l } static void drawTextOnPath__StringPathFFPaint(JNIEnv* env, jobject, - SkCanvas* canvas, jstring text, SkPath* path, - jfloat hOffset, jfloat vOffset, jint bidiFlags, SkPaint* paint) { + jlong canvasHandle, jstring text, jlong pathHandle, + jfloat hOffset, jfloat vOffset, jint bidiFlags, jlong paintHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* text_ = env->GetStringChars(text, NULL); int count = env->GetStringLength(text); TextLayout::drawTextOnPath(paint, text_, count, bidiFlags, hOffset, vOffset, @@ -970,8 +1078,9 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l return true; } - static bool getClipBounds(JNIEnv* env, jobject, SkCanvas* canvas, - jobject bounds) { + static jboolean getClipBounds(JNIEnv* env, jobject, jlong canvasHandle, + jobject bounds) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); SkRect r; SkIRect ir; bool result = getHardClipBounds(canvas, &r); @@ -982,30 +1091,32 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l r.round(&ir); (void)GraphicsJNI::irect_to_jrect(ir, env, bounds); - return result; + return result ? JNI_TRUE : JNI_FALSE; } - static void getCTM(JNIEnv* env, jobject, SkCanvas* canvas, - SkMatrix* matrix) { + static void getCTM(JNIEnv* env, jobject, jlong canvasHandle, + jlong matrixHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); *matrix = canvas->getTotalMatrix(); } }; static JNINativeMethod gCanvasMethods[] = { - {"finalizer", "(I)V", (void*) SkCanvasGlue::finalizer}, - {"initRaster","(I)I", (void*) SkCanvasGlue::initRaster}, - {"copyNativeCanvasState","(II)V", (void*) SkCanvasGlue::copyCanvasState}, + {"finalizer", "(J)V", (void*) SkCanvasGlue::finalizer}, + {"initRaster","(J)J", (void*) SkCanvasGlue::initRaster}, + {"copyNativeCanvasState","(JJ)V", (void*) SkCanvasGlue::copyCanvasState}, {"isOpaque","()Z", (void*) SkCanvasGlue::isOpaque}, {"getWidth","()I", (void*) SkCanvasGlue::getWidth}, {"getHeight","()I", (void*) SkCanvasGlue::getHeight}, {"save","()I", (void*) SkCanvasGlue::saveAll}, {"save","(I)I", (void*) SkCanvasGlue::save}, - {"native_saveLayer","(ILandroid/graphics/RectF;II)I", + {"native_saveLayer","(JLandroid/graphics/RectF;JI)I", (void*) SkCanvasGlue::saveLayer}, - {"native_saveLayer","(IFFFFII)I", (void*) SkCanvasGlue::saveLayer4F}, - {"native_saveLayerAlpha","(ILandroid/graphics/RectF;II)I", + {"native_saveLayer","(JFFFFJI)I", (void*) SkCanvasGlue::saveLayer4F}, + {"native_saveLayerAlpha","(JLandroid/graphics/RectF;II)I", (void*) SkCanvasGlue::saveLayerAlpha}, - {"native_saveLayerAlpha","(IFFFFII)I", + {"native_saveLayerAlpha","(JFFFFII)I", (void*) SkCanvasGlue::saveLayerAlpha4F}, {"restore","()V", (void*) SkCanvasGlue::restore}, {"getSaveCount","()I", (void*) SkCanvasGlue::getSaveCount}, @@ -1014,77 +1125,77 @@ static JNINativeMethod gCanvasMethods[] = { {"scale","(FF)V", (void*) SkCanvasGlue::scale__FF}, {"rotate","(F)V", (void*) SkCanvasGlue::rotate__F}, {"skew","(FF)V", (void*) SkCanvasGlue::skew__FF}, - {"native_concat","(II)V", (void*) SkCanvasGlue::concat}, - {"native_setMatrix","(II)V", (void*) SkCanvasGlue::setMatrix}, + {"native_concat","(JJ)V", (void*) SkCanvasGlue::concat}, + {"native_setMatrix","(JJ)V", (void*) SkCanvasGlue::setMatrix}, {"clipRect","(FFFF)Z", (void*) SkCanvasGlue::clipRect_FFFF}, {"clipRect","(IIII)Z", (void*) SkCanvasGlue::clipRect_IIII}, {"clipRect","(Landroid/graphics/RectF;)Z", (void*) SkCanvasGlue::clipRect_RectF}, {"clipRect","(Landroid/graphics/Rect;)Z", (void*) SkCanvasGlue::clipRect_Rect}, - {"native_clipRect","(IFFFFI)Z", (void*) SkCanvasGlue::clipRect}, - {"native_clipPath","(III)Z", (void*) SkCanvasGlue::clipPath}, - {"native_clipRegion","(III)Z", (void*) SkCanvasGlue::clipRegion}, - {"nativeSetDrawFilter", "(II)V", (void*) SkCanvasGlue::setDrawFilter}, - {"native_getClipBounds","(ILandroid/graphics/Rect;)Z", + {"native_clipRect","(JFFFFI)Z", (void*) SkCanvasGlue::clipRect}, + {"native_clipPath","(JJI)Z", (void*) SkCanvasGlue::clipPath}, + {"native_clipRegion","(JJI)Z", (void*) SkCanvasGlue::clipRegion}, + {"nativeSetDrawFilter", "(JJ)V", (void*) SkCanvasGlue::setDrawFilter}, + {"native_getClipBounds","(JLandroid/graphics/Rect;)Z", (void*) SkCanvasGlue::getClipBounds}, - {"native_getCTM", "(II)V", (void*)SkCanvasGlue::getCTM}, - {"native_quickReject","(ILandroid/graphics/RectF;)Z", + {"native_getCTM", "(JJ)V", (void*)SkCanvasGlue::getCTM}, + {"native_quickReject","(JLandroid/graphics/RectF;)Z", (void*) SkCanvasGlue::quickReject__RectF}, - {"native_quickReject","(II)Z", (void*) SkCanvasGlue::quickReject__Path}, - {"native_quickReject","(IFFFF)Z", (void*)SkCanvasGlue::quickReject__FFFF}, - {"native_drawRGB","(IIII)V", (void*) SkCanvasGlue::drawRGB}, - {"native_drawARGB","(IIIII)V", (void*) SkCanvasGlue::drawARGB}, - {"native_drawColor","(II)V", (void*) SkCanvasGlue::drawColor__I}, - {"native_drawColor","(III)V", (void*) SkCanvasGlue::drawColor__II}, - {"native_drawPaint","(II)V", (void*) SkCanvasGlue::drawPaint}, + {"native_quickReject","(JJ)Z", (void*) SkCanvasGlue::quickReject__Path}, + {"native_quickReject","(JFFFF)Z", (void*)SkCanvasGlue::quickReject__FFFF}, + {"native_drawRGB","(JIII)V", (void*) SkCanvasGlue::drawRGB}, + {"native_drawARGB","(JIIII)V", (void*) SkCanvasGlue::drawARGB}, + {"native_drawColor","(JI)V", (void*) SkCanvasGlue::drawColor__I}, + {"native_drawColor","(JII)V", (void*) SkCanvasGlue::drawColor__II}, + {"native_drawPaint","(JJ)V", (void*) SkCanvasGlue::drawPaint}, {"drawPoint", "(FFLandroid/graphics/Paint;)V", (void*) SkCanvasGlue::drawPoint}, {"drawPoints", "([FIILandroid/graphics/Paint;)V", (void*) SkCanvasGlue::drawPoints}, {"drawLines", "([FIILandroid/graphics/Paint;)V", (void*) SkCanvasGlue::drawLines}, - {"native_drawLine","(IFFFFI)V", (void*) SkCanvasGlue::drawLine__FFFFPaint}, - {"native_drawRect","(ILandroid/graphics/RectF;I)V", + {"native_drawLine","(JFFFFJ)V", (void*) SkCanvasGlue::drawLine__FFFFPaint}, + {"native_drawRect","(JLandroid/graphics/RectF;J)V", (void*) SkCanvasGlue::drawRect__RectFPaint}, - {"native_drawRect","(IFFFFI)V", (void*) SkCanvasGlue::drawRect__FFFFPaint}, - {"native_drawOval","(ILandroid/graphics/RectF;I)V", + {"native_drawRect","(JFFFFJ)V", (void*) SkCanvasGlue::drawRect__FFFFPaint}, + {"native_drawOval","(JLandroid/graphics/RectF;J)V", (void*) SkCanvasGlue::drawOval}, - {"native_drawCircle","(IFFFI)V", (void*) SkCanvasGlue::drawCircle}, - {"native_drawArc","(ILandroid/graphics/RectF;FFZI)V", + {"native_drawCircle","(JFFFJ)V", (void*) SkCanvasGlue::drawCircle}, + {"native_drawArc","(JLandroid/graphics/RectF;FFZJ)V", (void*) SkCanvasGlue::drawArc}, - {"native_drawRoundRect","(ILandroid/graphics/RectF;FFI)V", + {"native_drawRoundRect","(JLandroid/graphics/RectF;FFJ)V", (void*) SkCanvasGlue::drawRoundRect}, - {"native_drawPath","(III)V", (void*) SkCanvasGlue::drawPath}, - {"native_drawBitmap","(IIFFIIII)V", + {"native_drawPath","(JJJ)V", (void*) SkCanvasGlue::drawPath}, + {"native_drawBitmap","(JJFFJIII)V", (void*) SkCanvasGlue::drawBitmap__BitmapFFPaint}, - {"native_drawBitmap","(IILandroid/graphics/Rect;Landroid/graphics/RectF;III)V", + {"native_drawBitmap","(JJLandroid/graphics/Rect;Landroid/graphics/RectF;JII)V", (void*) SkCanvasGlue::drawBitmapRF}, - {"native_drawBitmap","(IILandroid/graphics/Rect;Landroid/graphics/Rect;III)V", + {"native_drawBitmap","(JJLandroid/graphics/Rect;Landroid/graphics/Rect;JII)V", (void*) SkCanvasGlue::drawBitmapRR}, - {"native_drawBitmap", "(I[IIIFFIIZI)V", + {"native_drawBitmap", "(J[IIIFFIIZJ)V", (void*)SkCanvasGlue::drawBitmapArray}, - {"nativeDrawBitmapMatrix", "(IIII)V", + {"nativeDrawBitmapMatrix", "(JJJJ)V", (void*)SkCanvasGlue::drawBitmapMatrix}, - {"nativeDrawBitmapMesh", "(IIII[FI[III)V", + {"nativeDrawBitmapMesh", "(JJII[FI[IIJ)V", (void*)SkCanvasGlue::drawBitmapMesh}, - {"nativeDrawVertices", "(III[FI[FI[II[SIII)V", + {"nativeDrawVertices", "(JII[FI[FI[II[SIIJ)V", (void*)SkCanvasGlue::drawVertices}, - {"native_drawText","(I[CIIFFII)V", + {"native_drawText","(J[CIIFFIJ)V", (void*) SkCanvasGlue::drawText___CIIFFIPaint}, - {"native_drawText","(ILjava/lang/String;IIFFII)V", + {"native_drawText","(JLjava/lang/String;IIFFIJ)V", (void*) SkCanvasGlue::drawText__StringIIFFIPaint}, - {"native_drawTextRun","(I[CIIIIFFII)V", + {"native_drawTextRun","(J[CIIIIFFIJ)V", (void*) SkCanvasGlue::drawTextRun___CIIIIFFIPaint}, - {"native_drawTextRun","(ILjava/lang/String;IIIIFFII)V", + {"native_drawTextRun","(JLjava/lang/String;IIIIFFIJ)V", (void*) SkCanvasGlue::drawTextRun__StringIIIIFFIPaint}, - {"native_drawPosText","(I[CII[FI)V", + {"native_drawPosText","(J[CII[FJ)V", (void*) SkCanvasGlue::drawPosText___CII_FPaint}, - {"native_drawPosText","(ILjava/lang/String;[FI)V", + {"native_drawPosText","(JLjava/lang/String;[FJ)V", (void*) SkCanvasGlue::drawPosText__String_FPaint}, - {"native_drawTextOnPath","(I[CIIIFFII)V", + {"native_drawTextOnPath","(J[CIIJFFIJ)V", (void*) SkCanvasGlue::drawTextOnPath___CIIPathFFPaint}, - {"native_drawTextOnPath","(ILjava/lang/String;IFFII)V", + {"native_drawTextOnPath","(JLjava/lang/String;JFFIJ)V", (void*) SkCanvasGlue::drawTextOnPath__StringPathFFPaint}, {"freeCaches", "()V", (void*) SkCanvasGlue::freeCaches}, @@ -1105,7 +1216,7 @@ int register_android_graphics_Canvas(JNIEnv* env) { int result; REG(env, "android/graphics/Canvas", gCanvasMethods); - + return result; } diff --git a/core/jni/android/graphics/ColorFilter.cpp b/core/jni/android/graphics/ColorFilter.cpp index dd1177b..f9cefd6 100644 --- a/core/jni/android/graphics/ColorFilter.cpp +++ b/core/jni/android/graphics/ColorFilter.cpp @@ -32,7 +32,9 @@ using namespace uirenderer; class SkColorFilterGlue { public: - static void finalizer(JNIEnv* env, jobject clazz, SkColorFilter* obj, SkiaColorFilter* f) { + static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle, jlong fHandle) { + SkColorFilter* obj = reinterpret_cast<SkColorFilter *>(objHandle); + SkiaColorFilter* f = reinterpret_cast<SkiaColorFilter *>(fHandle); SkSafeUnref(obj); // f == NULL when not !USE_OPENGL_RENDERER, so no need to delete outside the ifdef #ifdef USE_OPENGL_RENDERER @@ -44,26 +46,30 @@ public: #endif } - static SkiaColorFilter* glCreatePorterDuffFilter(JNIEnv* env, jobject, SkColorFilter *skFilter, - jint srcColor, SkPorterDuff::Mode mode) { + static jlong glCreatePorterDuffFilter(JNIEnv* env, jobject, jlong skFilterHandle, + jint srcColor, jint modeHandle) { + SkColorFilter *skFilter = reinterpret_cast<SkColorFilter *>(skFilterHandle); + SkPorterDuff::Mode mode = static_cast<SkPorterDuff::Mode>(modeHandle); #ifdef USE_OPENGL_RENDERER - return new SkiaBlendFilter(skFilter, srcColor, SkPorterDuff::ToXfermodeMode(mode)); + return reinterpret_cast<jlong>(new SkiaBlendFilter(skFilter, srcColor, SkPorterDuff::ToXfermodeMode(mode))); #else return NULL; #endif } - static SkiaColorFilter* glCreateLightingFilter(JNIEnv* env, jobject, SkColorFilter *skFilter, + static jlong glCreateLightingFilter(JNIEnv* env, jobject, jlong skFilterHandle, jint mul, jint add) { + SkColorFilter *skFilter = reinterpret_cast<SkColorFilter *>(skFilterHandle); #ifdef USE_OPENGL_RENDERER - return new SkiaLightingFilter(skFilter, mul, add); + return reinterpret_cast<jlong>(new SkiaLightingFilter(skFilter, mul, add)); #else return NULL; #endif } - static SkiaColorFilter* glCreateColorMatrixFilter(JNIEnv* env, jobject, SkColorFilter *skFilter, + static jlong glCreateColorMatrixFilter(JNIEnv* env, jobject, jlong skFilterHandle, jfloatArray jarray) { + SkColorFilter *skFilter = reinterpret_cast<SkColorFilter *>(skFilterHandle); #ifdef USE_OPENGL_RENDERER AutoJavaFloatArray autoArray(env, jarray, 20); const float* src = autoArray.ptr(); @@ -80,22 +86,23 @@ public: colorVector[2] = src[14]; colorVector[3] = src[19]; - return new SkiaColorMatrixFilter(skFilter, colorMatrix, colorVector); + return reinterpret_cast<jlong>(new SkiaColorMatrixFilter(skFilter, colorMatrix, colorVector)); #else return NULL; #endif } - static SkColorFilter* CreatePorterDuffFilter(JNIEnv* env, jobject, jint srcColor, - SkPorterDuff::Mode mode) { - return SkColorFilter::CreateModeFilter(srcColor, SkPorterDuff::ToXfermodeMode(mode)); + static jlong CreatePorterDuffFilter(JNIEnv* env, jobject, jint srcColor, + jint modeHandle) { + SkPorterDuff::Mode mode = (SkPorterDuff::Mode) modeHandle; + return reinterpret_cast<jlong>(SkColorFilter::CreateModeFilter(srcColor, SkPorterDuff::ToXfermodeMode(mode))); } - static SkColorFilter* CreateLightingFilter(JNIEnv* env, jobject, jint mul, jint add) { - return SkColorFilter::CreateLightingFilter(mul, add); + static jlong CreateLightingFilter(JNIEnv* env, jobject, jint mul, jint add) { + return reinterpret_cast<jlong>(SkColorFilter::CreateLightingFilter(mul, add)); } - static SkColorFilter* CreateColorMatrixFilter(JNIEnv* env, jobject, jfloatArray jarray) { + static jlong CreateColorMatrixFilter(JNIEnv* env, jobject, jfloatArray jarray) { AutoJavaFloatArray autoArray(env, jarray, 20); const float* src = autoArray.ptr(); @@ -104,30 +111,30 @@ public: for (int i = 0; i < 20; i++) { array[i] = SkFloatToScalar(src[i]); } - return new SkColorMatrixFilter(array); + return reinterpret_cast<jlong>(new SkColorMatrixFilter(array)); #else - return new SkColorMatrixFilter(src); + return reinterpret_cast<jlong>(new SkColorMatrixFilter(src)); #endif } }; static JNINativeMethod colorfilter_methods[] = { - {"finalizer", "(II)V", (void*) SkColorFilterGlue::finalizer} + {"finalizer", "(JJ)V", (void*) SkColorFilterGlue::finalizer} }; static JNINativeMethod porterduff_methods[] = { - { "native_CreatePorterDuffFilter", "(II)I", (void*) SkColorFilterGlue::CreatePorterDuffFilter }, - { "nCreatePorterDuffFilter", "(III)I", (void*) SkColorFilterGlue::glCreatePorterDuffFilter } + { "native_CreatePorterDuffFilter", "(II)J", (void*) SkColorFilterGlue::CreatePorterDuffFilter }, + { "nCreatePorterDuffFilter", "(JII)J", (void*) SkColorFilterGlue::glCreatePorterDuffFilter } }; static JNINativeMethod lighting_methods[] = { - { "native_CreateLightingFilter", "(II)I", (void*) SkColorFilterGlue::CreateLightingFilter }, - { "nCreateLightingFilter", "(III)I", (void*) SkColorFilterGlue::glCreateLightingFilter }, + { "native_CreateLightingFilter", "(II)J", (void*) SkColorFilterGlue::CreateLightingFilter }, + { "nCreateLightingFilter", "(JII)J", (void*) SkColorFilterGlue::glCreateLightingFilter }, }; static JNINativeMethod colormatrix_methods[] = { - { "nativeColorMatrixFilter", "([F)I", (void*) SkColorFilterGlue::CreateColorMatrixFilter }, - { "nColorMatrixFilter", "(I[F)I", (void*) SkColorFilterGlue::glCreateColorMatrixFilter } + { "nativeColorMatrixFilter", "([F)J", (void*) SkColorFilterGlue::CreateColorMatrixFilter }, + { "nColorMatrixFilter", "(J[F)J", (void*) SkColorFilterGlue::glCreateColorMatrixFilter } }; #define REG(env, name, array) \ diff --git a/core/jni/android/graphics/DrawFilter.cpp b/core/jni/android/graphics/DrawFilter.cpp index 2f9fe7e..fbfa2ec 100644 --- a/core/jni/android/graphics/DrawFilter.cpp +++ b/core/jni/android/graphics/DrawFilter.cpp @@ -33,18 +33,20 @@ namespace android { class SkDrawFilterGlue { public: - static void finalizer(JNIEnv* env, jobject clazz, SkDrawFilter* obj) { + static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) { + SkDrawFilter* obj = reinterpret_cast<SkDrawFilter*>(objHandle); SkSafeUnref(obj); } - static SkDrawFilter* CreatePaintFlagsDF(JNIEnv* env, jobject clazz, - int clearFlags, int setFlags) { + static jlong CreatePaintFlagsDF(JNIEnv* env, jobject clazz, + jint clearFlags, jint setFlags) { // trim off any out-of-range bits clearFlags &= SkPaint::kAllFlags; setFlags &= SkPaint::kAllFlags; if (clearFlags | setFlags) { - return new SkPaintFlagsDrawFilter(clearFlags, setFlags); + SkDrawFilter* filter = new SkPaintFlagsDrawFilter(clearFlags, setFlags); + return reinterpret_cast<jlong>(filter); } else { return NULL; } @@ -52,11 +54,11 @@ public: }; static JNINativeMethod drawfilter_methods[] = { - {"nativeDestructor", "(I)V", (void*) SkDrawFilterGlue::finalizer} + {"nativeDestructor", "(J)V", (void*) SkDrawFilterGlue::finalizer} }; static JNINativeMethod paintflags_methods[] = { - {"nativeConstructor","(II)I", (void*) SkDrawFilterGlue::CreatePaintFlagsDF} + {"nativeConstructor","(II)J", (void*) SkDrawFilterGlue::CreatePaintFlagsDF} }; #define REG(env, name, array) \ diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp index 38a9ba3..2f4fd29 100644 --- a/core/jni/android/graphics/Graphics.cpp +++ b/core/jni/android/graphics/Graphics.cpp @@ -293,7 +293,8 @@ SkBitmap* GraphicsJNI::getNativeBitmap(JNIEnv* env, jobject bitmap) { SkASSERT(env); SkASSERT(bitmap); SkASSERT(env->IsInstanceOf(bitmap, gBitmap_class)); - SkBitmap* b = (SkBitmap*)env->GetIntField(bitmap, gBitmap_nativeInstanceID); + jlong bitmapHandle = env->GetLongField(bitmap, gBitmap_nativeInstanceID); + SkBitmap* b = reinterpret_cast<SkBitmap*>(bitmapHandle); SkASSERT(b); return b; } @@ -316,7 +317,8 @@ SkCanvas* GraphicsJNI::getNativeCanvas(JNIEnv* env, jobject canvas) { SkASSERT(env); SkASSERT(canvas); SkASSERT(env->IsInstanceOf(canvas, gCanvas_class)); - SkCanvas* c = (SkCanvas*)env->GetIntField(canvas, gCanvas_nativeInstanceID); + jlong canvasHandle = env->GetLongField(canvas, gCanvas_nativeInstanceID); + SkCanvas* c = reinterpret_cast<SkCanvas*>(canvasHandle); SkASSERT(c); return c; } @@ -325,7 +327,8 @@ SkPaint* GraphicsJNI::getNativePaint(JNIEnv* env, jobject paint) { SkASSERT(env); SkASSERT(paint); SkASSERT(env->IsInstanceOf(paint, gPaint_class)); - SkPaint* p = (SkPaint*)env->GetIntField(paint, gPaint_nativeInstanceID); + jlong paintHandle = env->GetLongField(paint, gPaint_nativeInstanceID); + SkPaint* p = reinterpret_cast<SkPaint*>(paintHandle); SkASSERT(p); return p; } @@ -335,7 +338,8 @@ SkPicture* GraphicsJNI::getNativePicture(JNIEnv* env, jobject picture) SkASSERT(env); SkASSERT(picture); SkASSERT(env->IsInstanceOf(picture, gPicture_class)); - SkPicture* p = (SkPicture*)env->GetIntField(picture, gPicture_nativeInstanceID); + jlong pictureHandle = env->GetLongField(picture, gPicture_nativeInstanceID); + SkPicture* p = reinterpret_cast<SkPicture*>(pictureHandle); SkASSERT(p); return p; } @@ -345,7 +349,8 @@ SkRegion* GraphicsJNI::getNativeRegion(JNIEnv* env, jobject region) SkASSERT(env); SkASSERT(region); SkASSERT(env->IsInstanceOf(region, gRegion_class)); - SkRegion* r = (SkRegion*)env->GetIntField(region, gRegion_nativeInstanceID); + jlong regionHandle = env->GetLongField(region, gRegion_nativeInstanceID); + SkRegion* r = reinterpret_cast<SkRegion*>(regionHandle); SkASSERT(r); return r; } @@ -361,7 +366,7 @@ jobject GraphicsJNI::createBitmap(JNIEnv* env, SkBitmap* bitmap, jbyteArray buff bool isPremultiplied = bitmapCreateFlags & kBitmapCreateFlag_Premultiplied; jobject obj = env->NewObject(gBitmap_class, gBitmap_constructorMethodID, - static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)), buffer, + reinterpret_cast<jlong>(bitmap), buffer, bitmap->width(), bitmap->height(), density, isMutable, isPremultiplied, ninepatch, layoutbounds); hasException(env); // For the side effect of logging. @@ -392,7 +397,7 @@ jobject GraphicsJNI::createBitmapRegionDecoder(JNIEnv* env, SkBitmapRegionDecode jobject obj = env->NewObject(gBitmapRegionDecoder_class, gBitmapRegionDecoder_constructorMethodID, - static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap))); + reinterpret_cast<jlong>(bitmap)); hasException(env); // For the side effect of logging. return obj; } @@ -401,7 +406,7 @@ jobject GraphicsJNI::createRegion(JNIEnv* env, SkRegion* region) { SkASSERT(region != NULL); jobject obj = env->NewObject(gRegion_class, gRegion_constructorMethodID, - static_cast<jint>(reinterpret_cast<uintptr_t>(region)), 0); + reinterpret_cast<jlong>(region), 0); hasException(env); // For the side effect of logging. return obj; } @@ -646,30 +651,30 @@ int register_android_graphics_Graphics(JNIEnv* env) gPointF_yFieldID = getFieldIDCheck(env, gPointF_class, "y", "F"); gBitmap_class = make_globalref(env, "android/graphics/Bitmap"); - gBitmap_nativeInstanceID = getFieldIDCheck(env, gBitmap_class, "mNativeBitmap", "I"); - gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>", "(I[BIIIZZ[B[I)V"); + gBitmap_nativeInstanceID = getFieldIDCheck(env, gBitmap_class, "mNativeBitmap", "J"); + gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>", "(J[BIIIZZ[B[I)V"); gBitmap_reinitMethodID = env->GetMethodID(gBitmap_class, "reinit", "(IIZ)V"); gBitmap_getAllocationByteCountMethodID = env->GetMethodID(gBitmap_class, "getAllocationByteCount", "()I"); gBitmapRegionDecoder_class = make_globalref(env, "android/graphics/BitmapRegionDecoder"); - gBitmapRegionDecoder_constructorMethodID = env->GetMethodID(gBitmapRegionDecoder_class, "<init>", "(I)V"); + gBitmapRegionDecoder_constructorMethodID = env->GetMethodID(gBitmapRegionDecoder_class, "<init>", "(J)V"); gBitmapConfig_class = make_globalref(env, "android/graphics/Bitmap$Config"); gBitmapConfig_nativeInstanceID = getFieldIDCheck(env, gBitmapConfig_class, "nativeInt", "I"); gCanvas_class = make_globalref(env, "android/graphics/Canvas"); - gCanvas_nativeInstanceID = getFieldIDCheck(env, gCanvas_class, "mNativeCanvas", "I"); + gCanvas_nativeInstanceID = getFieldIDCheck(env, gCanvas_class, "mNativeCanvas", "J"); gPaint_class = make_globalref(env, "android/graphics/Paint"); - gPaint_nativeInstanceID = getFieldIDCheck(env, gPaint_class, "mNativePaint", "I"); + gPaint_nativeInstanceID = getFieldIDCheck(env, gPaint_class, "mNativePaint", "J"); gPicture_class = make_globalref(env, "android/graphics/Picture"); - gPicture_nativeInstanceID = getFieldIDCheck(env, gPicture_class, "mNativePicture", "I"); + gPicture_nativeInstanceID = getFieldIDCheck(env, gPicture_class, "mNativePicture", "J"); gRegion_class = make_globalref(env, "android/graphics/Region"); - gRegion_nativeInstanceID = getFieldIDCheck(env, gRegion_class, "mNativeRegion", "I"); + gRegion_nativeInstanceID = getFieldIDCheck(env, gRegion_class, "mNativeRegion", "J"); gRegion_constructorMethodID = env->GetMethodID(gRegion_class, "<init>", - "(II)V"); + "(JI)V"); c = env->FindClass("java/lang/Byte"); gByte_class = (jclass) env->NewGlobalRef( diff --git a/core/jni/android/graphics/Interpolator.cpp b/core/jni/android/graphics/Interpolator.cpp index aa33c3d..ca04dfe 100644 --- a/core/jni/android/graphics/Interpolator.cpp +++ b/core/jni/android/graphics/Interpolator.cpp @@ -5,23 +5,26 @@ #include "SkInterpolator.h" #include "SkTemplates.h" -static SkInterpolator* Interpolator_constructor(JNIEnv* env, jobject clazz, int valueCount, int frameCount) +static jlong Interpolator_constructor(JNIEnv* env, jobject clazz, jint valueCount, jint frameCount) { - return new SkInterpolator(valueCount, frameCount); + return reinterpret_cast<jlong>(new SkInterpolator(valueCount, frameCount)); } -static void Interpolator_destructor(JNIEnv* env, jobject clazz, SkInterpolator* interp) +static void Interpolator_destructor(JNIEnv* env, jobject clazz, jlong interpHandle) { + SkInterpolator* interp = reinterpret_cast<SkInterpolator*>(interpHandle); delete interp; } -static void Interpolator_reset(JNIEnv* env, jobject clazz, SkInterpolator* interp, int valueCount, int frameCount) +static void Interpolator_reset(JNIEnv* env, jobject clazz, jlong interpHandle, jint valueCount, jint frameCount) { + SkInterpolator* interp = reinterpret_cast<SkInterpolator*>(interpHandle); interp->reset(valueCount, frameCount); } -static void Interpolator_setKeyFrame(JNIEnv* env, jobject clazz, SkInterpolator* interp, int index, int msec, jfloatArray valueArray, jfloatArray blendArray) +static void Interpolator_setKeyFrame(JNIEnv* env, jobject clazz, jlong interpHandle, jint index, jint msec, jfloatArray valueArray, jfloatArray blendArray) { + SkInterpolator* interp = reinterpret_cast<SkInterpolator*>(interpHandle); SkScalar blendStorage[4]; SkScalar* blend = NULL; @@ -46,8 +49,9 @@ static void Interpolator_setKeyFrame(JNIEnv* env, jobject clazz, SkInterpolator* interp->setKeyFrame(index, msec, scalars, blend); } -static void Interpolator_setRepeatMirror(JNIEnv* env, jobject clazz, SkInterpolator* interp, float repeatCount, jboolean mirror) +static void Interpolator_setRepeatMirror(JNIEnv* env, jobject clazz, jlong interpHandle, jfloat repeatCount, jboolean mirror) { + SkInterpolator* interp = reinterpret_cast<SkInterpolator*>(interpHandle); if (repeatCount > 32000) repeatCount = 32000; @@ -55,8 +59,9 @@ static void Interpolator_setRepeatMirror(JNIEnv* env, jobject clazz, SkInterpola interp->setMirror(mirror != 0); } -static int Interpolator_timeToValues(JNIEnv* env, jobject clazz, SkInterpolator* interp, int msec, jfloatArray valueArray) +static jint Interpolator_timeToValues(JNIEnv* env, jobject clazz, jlong interpHandle, jint msec, jfloatArray valueArray) { + SkInterpolator* interp = reinterpret_cast<SkInterpolator*>(interpHandle); SkInterpolatorBase::Result result; float* values = valueArray ? env->GetFloatArrayElements(valueArray, NULL) : NULL; @@ -70,7 +75,7 @@ static int Interpolator_timeToValues(JNIEnv* env, jobject clazz, SkInterpolator* env->ReleaseFloatArrayElements(valueArray, values, 0); } - return result; + return static_cast<jint>(result); } // ---------------------------------------------------------------------------- @@ -79,12 +84,12 @@ static int Interpolator_timeToValues(JNIEnv* env, jobject clazz, SkInterpolator* * JNI registration. */ static JNINativeMethod gInterpolatorMethods[] = { - { "nativeConstructor", "(II)I", (void*)Interpolator_constructor }, - { "nativeDestructor", "(I)V", (void*)Interpolator_destructor }, - { "nativeReset", "(III)V", (void*)Interpolator_reset }, - { "nativeSetKeyFrame", "(III[F[F)V", (void*)Interpolator_setKeyFrame }, - { "nativeSetRepeatMirror", "(IFZ)V", (void*)Interpolator_setRepeatMirror }, - { "nativeTimeToValues", "(II[F)I", (void*)Interpolator_timeToValues } + { "nativeConstructor", "(II)J", (void*)Interpolator_constructor }, + { "nativeDestructor", "(J)V", (void*)Interpolator_destructor }, + { "nativeReset", "(JII)V", (void*)Interpolator_reset }, + { "nativeSetKeyFrame", "(JII[F[F)V", (void*)Interpolator_setKeyFrame }, + { "nativeSetRepeatMirror", "(JFZ)V", (void*)Interpolator_setRepeatMirror }, + { "nativeTimeToValues", "(JI[F)I", (void*)Interpolator_timeToValues } }; int register_android_graphics_Interpolator(JNIEnv* env) diff --git a/core/jni/android/graphics/LayerRasterizer.cpp b/core/jni/android/graphics/LayerRasterizer.cpp index e5bc6f8..29e7db1 100644 --- a/core/jni/android/graphics/LayerRasterizer.cpp +++ b/core/jni/android/graphics/LayerRasterizer.cpp @@ -3,11 +3,13 @@ class SkLayerRasterizerGlue { public: - static SkRasterizer* create(JNIEnv* env, jobject) { - return new SkLayerRasterizer(); + static jlong create(JNIEnv* env, jobject) { + return reinterpret_cast<jlong>(new SkLayerRasterizer()); } - static void addLayer(JNIEnv* env, jobject, SkLayerRasterizer* layer, const SkPaint* paint, float dx, float dy) { + static void addLayer(JNIEnv* env, jobject, jlong layerHandle, jlong paintHandle, jfloat dx, jfloat dy) { + SkLayerRasterizer* layer = reinterpret_cast<SkLayerRasterizer *>(layerHandle); + const SkPaint* paint = reinterpret_cast<SkPaint *>(paintHandle); SkASSERT(layer); SkASSERT(paint); layer->addLayer(*paint, SkFloatToScalar(dx), SkFloatToScalar(dy)); @@ -19,8 +21,8 @@ public: #include <android_runtime/AndroidRuntime.h> static JNINativeMethod gLayerRasterizerMethods[] = { - { "nativeConstructor", "()I", (void*)SkLayerRasterizerGlue::create }, - { "nativeAddLayer", "(IIFF)V", (void*)SkLayerRasterizerGlue::addLayer } + { "nativeConstructor", "()J", (void*)SkLayerRasterizerGlue::create }, + { "nativeAddLayer", "(JJFF)V", (void*)SkLayerRasterizerGlue::addLayer } }; int register_android_graphics_LayerRasterizer(JNIEnv* env) diff --git a/core/jni/android/graphics/MaskFilter.cpp b/core/jni/android/graphics/MaskFilter.cpp index d954ddf..f331af7 100644 --- a/core/jni/android/graphics/MaskFilter.cpp +++ b/core/jni/android/graphics/MaskFilter.cpp @@ -13,18 +13,19 @@ static void ThrowIAE_IfNull(JNIEnv* env, void* ptr) { class SkMaskFilterGlue { public: - static void destructor(JNIEnv* env, jobject, SkMaskFilter* filter) { + static void destructor(JNIEnv* env, jobject, jlong filterHandle) { + SkMaskFilter* filter = reinterpret_cast<SkMaskFilter *>(filterHandle); SkSafeUnref(filter); } - static SkMaskFilter* createBlur(JNIEnv* env, jobject, float radius, int blurStyle) { + static jlong createBlur(JNIEnv* env, jobject, jfloat radius, jint blurStyle) { SkMaskFilter* filter = SkBlurMaskFilter::Create(SkFloatToScalar(radius), (SkBlurMaskFilter::BlurStyle)blurStyle); ThrowIAE_IfNull(env, filter); - return filter; + return reinterpret_cast<jlong>(filter); } - static SkMaskFilter* createEmboss(JNIEnv* env, jobject, jfloatArray dirArray, float ambient, float specular, float radius) { + static jlong createEmboss(JNIEnv* env, jobject, jfloatArray dirArray, jfloat ambient, jfloat specular, jfloat radius) { SkScalar direction[3]; AutoJavaFloatArray autoDir(env, dirArray, 3); @@ -38,39 +39,42 @@ public: SkFloatToScalar(specular), SkFloatToScalar(radius)); ThrowIAE_IfNull(env, filter); - return filter; + return reinterpret_cast<jlong>(filter); } - static SkMaskFilter* createTable(JNIEnv* env, jobject, jbyteArray jtable) { + static jlong createTable(JNIEnv* env, jobject, jbyteArray jtable) { AutoJavaByteArray autoTable(env, jtable, 256); - return new SkTableMaskFilter((const uint8_t*)autoTable.ptr()); + SkMaskFilter* filter = new SkTableMaskFilter((const uint8_t*)autoTable.ptr()); + return reinterpret_cast<jlong>(filter); } - static SkMaskFilter* createClipTable(JNIEnv* env, jobject, int min, int max) { - return SkTableMaskFilter::CreateClip(min, max); + static jlong createClipTable(JNIEnv* env, jobject, jint min, jint max) { + SkMaskFilter* filter = SkTableMaskFilter::CreateClip(min, max); + return reinterpret_cast<jlong>(filter); } - static SkMaskFilter* createGammaTable(JNIEnv* env, jobject, float gamma) { - return SkTableMaskFilter::CreateGamma(gamma); + static jlong createGammaTable(JNIEnv* env, jobject, jfloat gamma) { + SkMaskFilter* filter = SkTableMaskFilter::CreateGamma(gamma); + return reinterpret_cast<jlong>(filter); } }; static JNINativeMethod gMaskFilterMethods[] = { - { "nativeDestructor", "(I)V", (void*)SkMaskFilterGlue::destructor } + { "nativeDestructor", "(J)V", (void*)SkMaskFilterGlue::destructor } }; static JNINativeMethod gBlurMaskFilterMethods[] = { - { "nativeConstructor", "(FI)I", (void*)SkMaskFilterGlue::createBlur } + { "nativeConstructor", "(FI)J", (void*)SkMaskFilterGlue::createBlur } }; static JNINativeMethod gEmbossMaskFilterMethods[] = { - { "nativeConstructor", "([FFFF)I", (void*)SkMaskFilterGlue::createEmboss } + { "nativeConstructor", "([FFFF)J", (void*)SkMaskFilterGlue::createEmboss } }; static JNINativeMethod gTableMaskFilterMethods[] = { - { "nativeNewTable", "([B)I", (void*)SkMaskFilterGlue::createTable }, - { "nativeNewClip", "(II)I", (void*)SkMaskFilterGlue::createClipTable }, - { "nativeNewGamma", "(F)I", (void*)SkMaskFilterGlue::createGammaTable } + { "nativeNewTable", "([B)J", (void*)SkMaskFilterGlue::createTable }, + { "nativeNewClip", "(II)J", (void*)SkMaskFilterGlue::createClipTable }, + { "nativeNewGamma", "(F)J", (void*)SkMaskFilterGlue::createGammaTable } }; #include <android_runtime/AndroidRuntime.h> diff --git a/core/jni/android/graphics/Matrix.cpp b/core/jni/android/graphics/Matrix.cpp index d0871ac5..a667499 100644 --- a/core/jni/android/graphics/Matrix.cpp +++ b/core/jni/android/graphics/Matrix.cpp @@ -31,218 +31,246 @@ namespace android { class SkMatrixGlue { public: - static void finalizer(JNIEnv* env, jobject clazz, SkMatrix* obj) { + static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); delete obj; } - static SkMatrix* create(JNIEnv* env, jobject clazz, const SkMatrix* src) { + static jlong create(JNIEnv* env, jobject clazz, jlong srcHandle) { + const SkMatrix* src = reinterpret_cast<SkMatrix*>(srcHandle); SkMatrix* obj = new SkMatrix(); if (src) *obj = *src; else obj->reset(); - return obj; + return reinterpret_cast<jlong>(obj); } - - static jboolean isIdentity(JNIEnv* env, jobject clazz, SkMatrix* obj) { - return obj->isIdentity(); + + static jboolean isIdentity(JNIEnv* env, jobject clazz, jlong objHandle) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); + return obj->isIdentity() ? JNI_TRUE : JNI_FALSE; } - - static jboolean rectStaysRect(JNIEnv* env, jobject clazz, SkMatrix* obj) { - return obj->rectStaysRect(); + static jboolean rectStaysRect(JNIEnv* env, jobject clazz, jlong objHandle) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); + return obj->rectStaysRect() ? JNI_TRUE : JNI_FALSE; } - - static void reset(JNIEnv* env, jobject clazz, SkMatrix* obj) { + static void reset(JNIEnv* env, jobject clazz, jlong objHandle) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); obj->reset(); } - - static void set(JNIEnv* env, jobject clazz, SkMatrix* obj, SkMatrix* other) { + static void set(JNIEnv* env, jobject clazz, jlong objHandle, jlong otherHandle) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); + SkMatrix* other = reinterpret_cast<SkMatrix*>(otherHandle); *obj = *other; } - - static void setTranslate(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat dx, jfloat dy) { + static void setTranslate(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar dx_ = SkFloatToScalar(dx); SkScalar dy_ = SkFloatToScalar(dy); obj->setTranslate(dx_, dy_); } - - static void setScale__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy, jfloat px, jfloat py) { + static void setScale__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy, jfloat px, jfloat py) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar sx_ = SkFloatToScalar(sx); SkScalar sy_ = SkFloatToScalar(sy); SkScalar px_ = SkFloatToScalar(px); SkScalar py_ = SkFloatToScalar(py); obj->setScale(sx_, sy_, px_, py_); } - - static void setScale__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy) { + static void setScale__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar sx_ = SkFloatToScalar(sx); SkScalar sy_ = SkFloatToScalar(sy); obj->setScale(sx_, sy_); } - - static void setRotate__FFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees, jfloat px, jfloat py) { + static void setRotate__FFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees, jfloat px, jfloat py) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar degrees_ = SkFloatToScalar(degrees); SkScalar px_ = SkFloatToScalar(px); SkScalar py_ = SkFloatToScalar(py); obj->setRotate(degrees_, px_, py_); } - - static void setRotate__F(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees) { + static void setRotate__F(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar degrees_ = SkFloatToScalar(degrees); obj->setRotate(degrees_); } - - static void setSinCos__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sinValue, jfloat cosValue, jfloat px, jfloat py) { + static void setSinCos__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sinValue, jfloat cosValue, jfloat px, jfloat py) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar sinValue_ = SkFloatToScalar(sinValue); SkScalar cosValue_ = SkFloatToScalar(cosValue); SkScalar px_ = SkFloatToScalar(px); SkScalar py_ = SkFloatToScalar(py); obj->setSinCos(sinValue_, cosValue_, px_, py_); } - - static void setSinCos__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sinValue, jfloat cosValue) { + static void setSinCos__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sinValue, jfloat cosValue) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar sinValue_ = SkFloatToScalar(sinValue); SkScalar cosValue_ = SkFloatToScalar(cosValue); obj->setSinCos(sinValue_, cosValue_); } - - static void setSkew__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat kx, jfloat ky, jfloat px, jfloat py) { + static void setSkew__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat kx, jfloat ky, jfloat px, jfloat py) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar kx_ = SkFloatToScalar(kx); SkScalar ky_ = SkFloatToScalar(ky); SkScalar px_ = SkFloatToScalar(px); SkScalar py_ = SkFloatToScalar(py); obj->setSkew(kx_, ky_, px_, py_); } - - static void setSkew__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat kx, jfloat ky) { + static void setSkew__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat kx, jfloat ky) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar kx_ = SkFloatToScalar(kx); SkScalar ky_ = SkFloatToScalar(ky); obj->setSkew(kx_, ky_); } - - static jboolean setConcat(JNIEnv* env, jobject clazz, SkMatrix* obj, SkMatrix* a, SkMatrix* b) { - return obj->setConcat(*a, *b); + static jboolean setConcat(JNIEnv* env, jobject clazz, jlong objHandle, jlong aHandle, jlong bHandle) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); + SkMatrix* a = reinterpret_cast<SkMatrix*>(aHandle); + SkMatrix* b = reinterpret_cast<SkMatrix*>(bHandle); + return obj->setConcat(*a, *b) ? JNI_TRUE : JNI_FALSE; } - - static jboolean preTranslate(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat dx, jfloat dy) { + + static jboolean preTranslate(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar dx_ = SkFloatToScalar(dx); SkScalar dy_ = SkFloatToScalar(dy); - return obj->preTranslate(dx_, dy_); + return obj->preTranslate(dx_, dy_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean preScale__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy, jfloat px, jfloat py) { + + static jboolean preScale__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy, jfloat px, jfloat py) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar sx_ = SkFloatToScalar(sx); SkScalar sy_ = SkFloatToScalar(sy); SkScalar px_ = SkFloatToScalar(px); SkScalar py_ = SkFloatToScalar(py); - return obj->preScale(sx_, sy_, px_, py_); + return obj->preScale(sx_, sy_, px_, py_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean preScale__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy) { + + static jboolean preScale__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar sx_ = SkFloatToScalar(sx); SkScalar sy_ = SkFloatToScalar(sy); - return obj->preScale(sx_, sy_); + return obj->preScale(sx_, sy_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean preRotate__FFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees, jfloat px, jfloat py) { + + static jboolean preRotate__FFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees, jfloat px, jfloat py) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar degrees_ = SkFloatToScalar(degrees); SkScalar px_ = SkFloatToScalar(px); SkScalar py_ = SkFloatToScalar(py); - return obj->preRotate(degrees_, px_, py_); + return obj->preRotate(degrees_, px_, py_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean preRotate__F(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees) { + + static jboolean preRotate__F(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar degrees_ = SkFloatToScalar(degrees); - return obj->preRotate(degrees_); + return obj->preRotate(degrees_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean preSkew__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat kx, jfloat ky, jfloat px, jfloat py) { + + static jboolean preSkew__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat kx, jfloat ky, jfloat px, jfloat py) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar kx_ = SkFloatToScalar(kx); SkScalar ky_ = SkFloatToScalar(ky); SkScalar px_ = SkFloatToScalar(px); SkScalar py_ = SkFloatToScalar(py); - return obj->preSkew(kx_, ky_, px_, py_); + return obj->preSkew(kx_, ky_, px_, py_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean preSkew__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat kx, jfloat ky) { + + static jboolean preSkew__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat kx, jfloat ky) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar kx_ = SkFloatToScalar(kx); SkScalar ky_ = SkFloatToScalar(ky); - return obj->preSkew(kx_, ky_); + return obj->preSkew(kx_, ky_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean preConcat(JNIEnv* env, jobject clazz, SkMatrix* obj, SkMatrix* other) { - return obj->preConcat(*other); + + static jboolean preConcat(JNIEnv* env, jobject clazz, jlong objHandle, jlong otherHandle) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); + SkMatrix* other = reinterpret_cast<SkMatrix*>(otherHandle); + return obj->preConcat(*other) ? JNI_TRUE : JNI_FALSE; } - - static jboolean postTranslate(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat dx, jfloat dy) { + + static jboolean postTranslate(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar dx_ = SkFloatToScalar(dx); SkScalar dy_ = SkFloatToScalar(dy); - return obj->postTranslate(dx_, dy_); + return obj->postTranslate(dx_, dy_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean postScale__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy, jfloat px, jfloat py) { + + static jboolean postScale__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy, jfloat px, jfloat py) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar sx_ = SkFloatToScalar(sx); SkScalar sy_ = SkFloatToScalar(sy); SkScalar px_ = SkFloatToScalar(px); SkScalar py_ = SkFloatToScalar(py); - return obj->postScale(sx_, sy_, px_, py_); + return obj->postScale(sx_, sy_, px_, py_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean postScale__FF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat sx, jfloat sy) { + + static jboolean postScale__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat sx, jfloat sy) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar sx_ = SkFloatToScalar(sx); SkScalar sy_ = SkFloatToScalar(sy); - return obj->postScale(sx_, sy_); + return obj->postScale(sx_, sy_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean postRotate__FFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees, jfloat px, jfloat py) { + + static jboolean postRotate__FFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees, jfloat px, jfloat py) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar degrees_ = SkFloatToScalar(degrees); SkScalar px_ = SkFloatToScalar(px); SkScalar py_ = SkFloatToScalar(py); - return obj->postRotate(degrees_, px_, py_); + return obj->postRotate(degrees_, px_, py_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean postRotate__F(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat degrees) { + + static jboolean postRotate__F(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar degrees_ = SkFloatToScalar(degrees); - return obj->postRotate(degrees_); + return obj->postRotate(degrees_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean postSkew__FFFF(JNIEnv* env, jobject clazz, SkMatrix* obj, jfloat kx, jfloat ky, jfloat px, jfloat py) { + + static jboolean postSkew__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat kx, jfloat ky, jfloat px, jfloat py) { + SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle); SkScalar kx_ = SkFloatToScalar(kx); SkScalar ky_ = SkFloatToScalar(ky); SkScalar px_ = SkFloatToScalar(px); SkScalar py_ = SkFloatToScalar(py); - return obj->postSkew(kx_, ky_, px_, py_); + return obj->postSkew(kx_, ky_, px_, py_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean postSkew__FF(JNIEnv* env, jobject clazz, SkMatrix* matrix, jfloat kx, jfloat ky) { + + static jboolean postSkew__FF(JNIEnv* env, jobject clazz, jlong matrixHandle, jfloat kx, jfloat ky) { + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); SkScalar kx_ = SkFloatToScalar(kx); SkScalar ky_ = SkFloatToScalar(ky); - return matrix->postSkew(kx_, ky_); + return matrix->postSkew(kx_, ky_) ? JNI_TRUE : JNI_FALSE; } - - static jboolean postConcat(JNIEnv* env, jobject clazz, SkMatrix* matrix, SkMatrix* other) { - return matrix->postConcat(*other); + + static jboolean postConcat(JNIEnv* env, jobject clazz, jlong matrixHandle, jlong otherHandle) { + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + SkMatrix* other = reinterpret_cast<SkMatrix*>(otherHandle); + return matrix->postConcat(*other) ? JNI_TRUE : JNI_FALSE; } - - static jboolean setRectToRect(JNIEnv* env, jobject clazz, SkMatrix* matrix, jobject src, jobject dst, SkMatrix::ScaleToFit stf) { + + static jboolean setRectToRect(JNIEnv* env, jobject clazz, jlong matrixHandle, jobject src, jobject dst, jint stfHandle) { + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + SkMatrix::ScaleToFit stf = static_cast<SkMatrix::ScaleToFit>(stfHandle); SkRect src_; GraphicsJNI::jrectf_to_rect(env, src, &src_); SkRect dst_; GraphicsJNI::jrectf_to_rect(env, dst, &dst_); - return matrix->setRectToRect(src_, dst_, stf); + return matrix->setRectToRect(src_, dst_, stf) ? JNI_TRUE : JNI_FALSE; } - - static jboolean setPolyToPoly(JNIEnv* env, jobject clazz, SkMatrix* matrix, - jfloatArray jsrc, int srcIndex, - jfloatArray jdst, int dstIndex, int ptCount) { + + static jboolean setPolyToPoly(JNIEnv* env, jobject clazz, jlong matrixHandle, + jfloatArray jsrc, jint srcIndex, + jfloatArray jdst, jint dstIndex, jint ptCount) { + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); SkASSERT(srcIndex >= 0); SkASSERT(dstIndex >= 0); SkASSERT((unsigned)ptCount <= 4); - AutoJavaFloatArray autoSrc(env, jsrc, srcIndex + (ptCount << 1)); - AutoJavaFloatArray autoDst(env, jdst, dstIndex + (ptCount << 1)); + AutoJavaFloatArray autoSrc(env, jsrc, srcIndex + (ptCount << 1), kRO_JNIAccess); + AutoJavaFloatArray autoDst(env, jdst, dstIndex + (ptCount << 1), kRW_JNIAccess); float* src = autoSrc.ptr() + srcIndex; float* dst = autoDst.ptr() + dstIndex; + bool result; #ifdef SK_SCALAR_IS_FIXED SkPoint srcPt[4], dstPt[4]; @@ -252,24 +280,28 @@ public: srcPt[i].set(SkFloatToScalar(src[x]), SkFloatToScalar(src[y])); dstPt[i].set(SkFloatToScalar(dst[x]), SkFloatToScalar(dst[y])); } - return matrix->setPolyToPoly(srcPt, dstPt, ptCount); + result = matrix->setPolyToPoly(srcPt, dstPt, ptCount); #else - return matrix->setPolyToPoly((const SkPoint*)src, (const SkPoint*)dst, + result = matrix->setPolyToPoly((const SkPoint*)src, (const SkPoint*)dst, ptCount); #endif + return result ? JNI_TRUE : JNI_FALSE; } - - static jboolean invert(JNIEnv* env, jobject clazz, SkMatrix* matrix, SkMatrix* inverse) { + + static jboolean invert(JNIEnv* env, jobject clazz, jlong matrixHandle, jlong inverseHandle) { + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + SkMatrix* inverse = reinterpret_cast<SkMatrix*>(inverseHandle); return matrix->invert(inverse); } - - static void mapPoints(JNIEnv* env, jobject clazz, SkMatrix* matrix, - jfloatArray dst, int dstIndex, - jfloatArray src, int srcIndex, - int ptCount, bool isPts) { + + static void mapPoints(JNIEnv* env, jobject clazz, jlong matrixHandle, + jfloatArray dst, jint dstIndex, + jfloatArray src, jint srcIndex, + jint ptCount, jboolean isPts) { + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); SkASSERT(ptCount >= 0); - AutoJavaFloatArray autoSrc(env, src, srcIndex + (ptCount << 1)); - AutoJavaFloatArray autoDst(env, dst, dstIndex + (ptCount << 1)); + AutoJavaFloatArray autoSrc(env, src, srcIndex + (ptCount << 1), kRO_JNIAccess); + AutoJavaFloatArray autoDst(env, dst, dstIndex + (ptCount << 1), kRW_JNIAccess); float* srcArray = autoSrc.ptr() + srcIndex; float* dstArray = autoDst.ptr() + dstIndex; @@ -304,21 +336,26 @@ public: ptCount); #endif } - - static jboolean mapRect__RectFRectF(JNIEnv* env, jobject clazz, SkMatrix* matrix, jobjectArray dst, jobject src) { + + static jboolean mapRect__RectFRectF(JNIEnv* env, jobject clazz, jlong matrixHandle, jobjectArray dst, jobject src) { + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); SkRect dst_, src_; GraphicsJNI::jrectf_to_rect(env, src, &src_); jboolean rectStaysRect = matrix->mapRect(&dst_, src_); GraphicsJNI::rect_to_jrectf(dst_, env, dst); - return rectStaysRect; + return rectStaysRect ? JNI_TRUE : JNI_FALSE; } - - static jfloat mapRadius(JNIEnv* env, jobject clazz, SkMatrix* matrix, jfloat radius) { - return SkScalarToFloat(matrix->mapRadius(SkFloatToScalar(radius))); + + static jfloat mapRadius(JNIEnv* env, jobject clazz, jlong matrixHandle, jfloat radius) { + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + float result; + result = SkScalarToFloat(matrix->mapRadius(SkFloatToScalar(radius))); + return static_cast<jfloat>(result); } - - static void getValues(JNIEnv* env, jobject clazz, SkMatrix* matrix, jfloatArray values) { - AutoJavaFloatArray autoValues(env, values, 9); + + static void getValues(JNIEnv* env, jobject clazz, jlong matrixHandle, jfloatArray values) { + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + AutoJavaFloatArray autoValues(env, values, 9, kRW_JNIAccess); float* dst = autoValues.ptr(); #ifdef SK_SCALAR_IS_FIXED @@ -334,9 +371,10 @@ public: } #endif } - - static void setValues(JNIEnv* env, jobject clazz, SkMatrix* matrix, jfloatArray values) { - AutoJavaFloatArray autoValues(env, values, 9); + + static void setValues(JNIEnv* env, jobject clazz, jlong matrixHandle, jfloatArray values) { + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + AutoJavaFloatArray autoValues(env, values, 9, kRO_JNIAccess); const float* src = autoValues.ptr(); #ifdef SK_SCALAR_IS_FIXED @@ -353,53 +391,55 @@ public: #endif } - static jboolean equals(JNIEnv* env, jobject clazz, const SkMatrix* a, const SkMatrix* b) { + static jboolean equals(JNIEnv* env, jobject clazz, jlong aHandle, jlong bHandle) { + const SkMatrix* a = reinterpret_cast<SkMatrix*>(aHandle); + const SkMatrix* b = reinterpret_cast<SkMatrix*>(bHandle); return *a == *b; } }; static JNINativeMethod methods[] = { - {"finalizer", "(I)V", (void*) SkMatrixGlue::finalizer}, - {"native_create","(I)I", (void*) SkMatrixGlue::create}, - {"native_isIdentity","(I)Z", (void*) SkMatrixGlue::isIdentity}, - {"native_rectStaysRect","(I)Z", (void*) SkMatrixGlue::rectStaysRect}, - {"native_reset","(I)V", (void*) SkMatrixGlue::reset}, - {"native_set","(II)V", (void*) SkMatrixGlue::set}, - {"native_setTranslate","(IFF)V", (void*) SkMatrixGlue::setTranslate}, - {"native_setScale","(IFFFF)V", (void*) SkMatrixGlue::setScale__FFFF}, - {"native_setScale","(IFF)V", (void*) SkMatrixGlue::setScale__FF}, - {"native_setRotate","(IFFF)V", (void*) SkMatrixGlue::setRotate__FFF}, - {"native_setRotate","(IF)V", (void*) SkMatrixGlue::setRotate__F}, - {"native_setSinCos","(IFFFF)V", (void*) SkMatrixGlue::setSinCos__FFFF}, - {"native_setSinCos","(IFF)V", (void*) SkMatrixGlue::setSinCos__FF}, - {"native_setSkew","(IFFFF)V", (void*) SkMatrixGlue::setSkew__FFFF}, - {"native_setSkew","(IFF)V", (void*) SkMatrixGlue::setSkew__FF}, - {"native_setConcat","(III)Z", (void*) SkMatrixGlue::setConcat}, - {"native_preTranslate","(IFF)Z", (void*) SkMatrixGlue::preTranslate}, - {"native_preScale","(IFFFF)Z", (void*) SkMatrixGlue::preScale__FFFF}, - {"native_preScale","(IFF)Z", (void*) SkMatrixGlue::preScale__FF}, - {"native_preRotate","(IFFF)Z", (void*) SkMatrixGlue::preRotate__FFF}, - {"native_preRotate","(IF)Z", (void*) SkMatrixGlue::preRotate__F}, - {"native_preSkew","(IFFFF)Z", (void*) SkMatrixGlue::preSkew__FFFF}, - {"native_preSkew","(IFF)Z", (void*) SkMatrixGlue::preSkew__FF}, - {"native_preConcat","(II)Z", (void*) SkMatrixGlue::preConcat}, - {"native_postTranslate","(IFF)Z", (void*) SkMatrixGlue::postTranslate}, - {"native_postScale","(IFFFF)Z", (void*) SkMatrixGlue::postScale__FFFF}, - {"native_postScale","(IFF)Z", (void*) SkMatrixGlue::postScale__FF}, - {"native_postRotate","(IFFF)Z", (void*) SkMatrixGlue::postRotate__FFF}, - {"native_postRotate","(IF)Z", (void*) SkMatrixGlue::postRotate__F}, - {"native_postSkew","(IFFFF)Z", (void*) SkMatrixGlue::postSkew__FFFF}, - {"native_postSkew","(IFF)Z", (void*) SkMatrixGlue::postSkew__FF}, - {"native_postConcat","(II)Z", (void*) SkMatrixGlue::postConcat}, - {"native_setRectToRect","(ILandroid/graphics/RectF;Landroid/graphics/RectF;I)Z", (void*) SkMatrixGlue::setRectToRect}, - {"native_setPolyToPoly","(I[FI[FII)Z", (void*) SkMatrixGlue::setPolyToPoly}, - {"native_invert","(II)Z", (void*) SkMatrixGlue::invert}, - {"native_mapPoints","(I[FI[FIIZ)V", (void*) SkMatrixGlue::mapPoints}, - {"native_mapRect","(ILandroid/graphics/RectF;Landroid/graphics/RectF;)Z", (void*) SkMatrixGlue::mapRect__RectFRectF}, - {"native_mapRadius","(IF)F", (void*) SkMatrixGlue::mapRadius}, - {"native_getValues","(I[F)V", (void*) SkMatrixGlue::getValues}, - {"native_setValues","(I[F)V", (void*) SkMatrixGlue::setValues}, - {"native_equals", "(II)Z", (void*) SkMatrixGlue::equals} + {"finalizer", "(J)V", (void*) SkMatrixGlue::finalizer}, + {"native_create","(J)J", (void*) SkMatrixGlue::create}, + {"native_isIdentity","(J)Z", (void*) SkMatrixGlue::isIdentity}, + {"native_rectStaysRect","(J)Z", (void*) SkMatrixGlue::rectStaysRect}, + {"native_reset","(J)V", (void*) SkMatrixGlue::reset}, + {"native_set","(JJ)V", (void*) SkMatrixGlue::set}, + {"native_setTranslate","(JFF)V", (void*) SkMatrixGlue::setTranslate}, + {"native_setScale","(JFFFF)V", (void*) SkMatrixGlue::setScale__FFFF}, + {"native_setScale","(JFF)V", (void*) SkMatrixGlue::setScale__FF}, + {"native_setRotate","(JFFF)V", (void*) SkMatrixGlue::setRotate__FFF}, + {"native_setRotate","(JF)V", (void*) SkMatrixGlue::setRotate__F}, + {"native_setSinCos","(JFFFF)V", (void*) SkMatrixGlue::setSinCos__FFFF}, + {"native_setSinCos","(JFF)V", (void*) SkMatrixGlue::setSinCos__FF}, + {"native_setSkew","(JFFFF)V", (void*) SkMatrixGlue::setSkew__FFFF}, + {"native_setSkew","(JFF)V", (void*) SkMatrixGlue::setSkew__FF}, + {"native_setConcat","(JJJ)Z", (void*) SkMatrixGlue::setConcat}, + {"native_preTranslate","(JFF)Z", (void*) SkMatrixGlue::preTranslate}, + {"native_preScale","(JFFFF)Z", (void*) SkMatrixGlue::preScale__FFFF}, + {"native_preScale","(JFF)Z", (void*) SkMatrixGlue::preScale__FF}, + {"native_preRotate","(JFFF)Z", (void*) SkMatrixGlue::preRotate__FFF}, + {"native_preRotate","(JF)Z", (void*) SkMatrixGlue::preRotate__F}, + {"native_preSkew","(JFFFF)Z", (void*) SkMatrixGlue::preSkew__FFFF}, + {"native_preSkew","(JFF)Z", (void*) SkMatrixGlue::preSkew__FF}, + {"native_preConcat","(JJ)Z", (void*) SkMatrixGlue::preConcat}, + {"native_postTranslate","(JFF)Z", (void*) SkMatrixGlue::postTranslate}, + {"native_postScale","(JFFFF)Z", (void*) SkMatrixGlue::postScale__FFFF}, + {"native_postScale","(JFF)Z", (void*) SkMatrixGlue::postScale__FF}, + {"native_postRotate","(JFFF)Z", (void*) SkMatrixGlue::postRotate__FFF}, + {"native_postRotate","(JF)Z", (void*) SkMatrixGlue::postRotate__F}, + {"native_postSkew","(JFFFF)Z", (void*) SkMatrixGlue::postSkew__FFFF}, + {"native_postSkew","(JFF)Z", (void*) SkMatrixGlue::postSkew__FF}, + {"native_postConcat","(JJ)Z", (void*) SkMatrixGlue::postConcat}, + {"native_setRectToRect","(JLandroid/graphics/RectF;Landroid/graphics/RectF;I)Z", (void*) SkMatrixGlue::setRectToRect}, + {"native_setPolyToPoly","(J[FI[FII)Z", (void*) SkMatrixGlue::setPolyToPoly}, + {"native_invert","(JJ)Z", (void*) SkMatrixGlue::invert}, + {"native_mapPoints","(J[FI[FIIZ)V", (void*) SkMatrixGlue::mapPoints}, + {"native_mapRect","(JLandroid/graphics/RectF;Landroid/graphics/RectF;)Z", (void*) SkMatrixGlue::mapRect__RectFRectF}, + {"native_mapRadius","(JF)F", (void*) SkMatrixGlue::mapRadius}, + {"native_getValues","(J[F)V", (void*) SkMatrixGlue::getValues}, + {"native_setValues","(J[F)V", (void*) SkMatrixGlue::setValues}, + {"native_equals", "(JJ)Z", (void*) SkMatrixGlue::equals} }; static jfieldID sNativeInstanceField; @@ -409,13 +449,13 @@ int register_android_graphics_Matrix(JNIEnv* env) { sizeof(methods) / sizeof(methods[0])); jclass clazz = env->FindClass("android/graphics/Matrix"); - sNativeInstanceField = env->GetFieldID(clazz, "native_instance", "I"); + sNativeInstanceField = env->GetFieldID(clazz, "native_instance", "J"); return result; } SkMatrix* android_graphics_Matrix_getSkMatrix(JNIEnv* env, jobject matrixObj) { - return reinterpret_cast<SkMatrix*>(env->GetIntField(matrixObj, sNativeInstanceField)); + return reinterpret_cast<SkMatrix*>(env->GetLongField(matrixObj, sNativeInstanceField)); } } diff --git a/core/jni/android/graphics/Movie.cpp b/core/jni/android/graphics/Movie.cpp index feb2dec..0040b6f 100644 --- a/core/jni/android/graphics/Movie.cpp +++ b/core/jni/android/graphics/Movie.cpp @@ -27,43 +27,43 @@ jobject create_jmovie(JNIEnv* env, SkMovie* moov) { return NULL; } return env->NewObject(gMovie_class, gMovie_constructorMethodID, - static_cast<jint>(reinterpret_cast<uintptr_t>(moov))); + static_cast<jlong>(reinterpret_cast<uintptr_t>(moov))); } static SkMovie* J2Movie(JNIEnv* env, jobject movie) { SkASSERT(env); SkASSERT(movie); SkASSERT(env->IsInstanceOf(movie, gMovie_class)); - SkMovie* m = (SkMovie*)env->GetIntField(movie, gMovie_nativeInstanceID); + SkMovie* m = (SkMovie*)env->GetLongField(movie, gMovie_nativeInstanceID); SkASSERT(m); return m; } /////////////////////////////////////////////////////////////////////////////// -static int movie_width(JNIEnv* env, jobject movie) { +static jint movie_width(JNIEnv* env, jobject movie) { NPE_CHECK_RETURN_ZERO(env, movie); - return J2Movie(env, movie)->width(); + return static_cast<jint>(J2Movie(env, movie)->width()); } -static int movie_height(JNIEnv* env, jobject movie) { +static jint movie_height(JNIEnv* env, jobject movie) { NPE_CHECK_RETURN_ZERO(env, movie); - return J2Movie(env, movie)->height(); + return static_cast<jint>(J2Movie(env, movie)->height()); } static jboolean movie_isOpaque(JNIEnv* env, jobject movie) { NPE_CHECK_RETURN_ZERO(env, movie); - return J2Movie(env, movie)->isOpaque(); + return J2Movie(env, movie)->isOpaque() ? JNI_TRUE : JNI_FALSE; } -static int movie_duration(JNIEnv* env, jobject movie) { +static jint movie_duration(JNIEnv* env, jobject movie) { NPE_CHECK_RETURN_ZERO(env, movie); - return J2Movie(env, movie)->duration(); + return static_cast<jint>(J2Movie(env, movie)->duration()); } -static jboolean movie_setTime(JNIEnv* env, jobject movie, int ms) { +static jboolean movie_setTime(JNIEnv* env, jobject movie, jint ms) { NPE_CHECK_RETURN_ZERO(env, movie); - return J2Movie(env, movie)->setTime(ms); + return J2Movie(env, movie)->setTime(ms) ? JNI_TRUE : JNI_FALSE; } static void movie_draw(JNIEnv* env, jobject movie, jobject canvas, @@ -82,7 +82,7 @@ static void movie_draw(JNIEnv* env, jobject movie, jobject canvas, c->drawBitmap(b, sx, sy, p); } -static jobject movie_decodeAsset(JNIEnv* env, jobject clazz, jint native_asset) { +static jobject movie_decodeAsset(JNIEnv* env, jobject clazz, jlong native_asset) { android::Asset* asset = reinterpret_cast<android::Asset*>(native_asset); if (asset == NULL) return NULL; SkAutoTUnref<SkStreamRewindable> stream (new android::AssetStreamAdaptor(asset)); @@ -115,7 +115,7 @@ static jobject movie_decodeStream(JNIEnv* env, jobject clazz, jobject istream) { static jobject movie_decodeByteArray(JNIEnv* env, jobject clazz, jbyteArray byteArray, - int offset, int length) { + jint offset, jint length) { NPE_CHECK_RETURN_ZERO(env, byteArray); @@ -130,7 +130,8 @@ static jobject movie_decodeByteArray(JNIEnv* env, jobject clazz, return create_jmovie(env, moov); } -static void movie_destructor(JNIEnv* env, jobject, SkMovie* movie) { +static void movie_destructor(JNIEnv* env, jobject, jlong movieHandle) { + SkMovie* movie = (SkMovie*) movieHandle; delete movie; } @@ -146,11 +147,11 @@ static JNINativeMethod gMethods[] = { { "setTime", "(I)Z", (void*)movie_setTime }, { "draw", "(Landroid/graphics/Canvas;FFLandroid/graphics/Paint;)V", (void*)movie_draw }, - { "nativeDecodeAsset", "(I)Landroid/graphics/Movie;", + { "nativeDecodeAsset", "(J)Landroid/graphics/Movie;", (void*)movie_decodeAsset }, { "nativeDecodeStream", "(Ljava/io/InputStream;)Landroid/graphics/Movie;", (void*)movie_decodeStream }, - { "nativeDestructor","(I)V", (void*)movie_destructor }, + { "nativeDestructor","(J)V", (void*)movie_destructor }, { "decodeByteArray", "([BII)Landroid/graphics/Movie;", (void*)movie_decodeByteArray }, }; @@ -165,10 +166,10 @@ int register_android_graphics_Movie(JNIEnv* env) RETURN_ERR_IF_NULL(gMovie_class); gMovie_class = (jclass)env->NewGlobalRef(gMovie_class); - gMovie_constructorMethodID = env->GetMethodID(gMovie_class, "<init>", "(I)V"); + gMovie_constructorMethodID = env->GetMethodID(gMovie_class, "<init>", "(J)V"); RETURN_ERR_IF_NULL(gMovie_constructorMethodID); - gMovie_nativeInstanceID = env->GetFieldID(gMovie_class, "mNativeMovie", "I"); + gMovie_nativeInstanceID = env->GetFieldID(gMovie_class, "mNativeMovie", "J"); RETURN_ERR_IF_NULL(gMovie_nativeInstanceID); return android::AndroidRuntime::registerNativeMethods(env, kClassPathName, diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp index 7e6aeae..871e24d 100644 --- a/core/jni/android/graphics/NinePatch.cpp +++ b/core/jni/android/graphics/NinePatch.cpp @@ -46,22 +46,22 @@ class SkNinePatchGlue { public: static jboolean isNinePatchChunk(JNIEnv* env, jobject, jbyteArray obj) { if (NULL == obj) { - return false; + return JNI_FALSE; } if (env->GetArrayLength(obj) < (int)sizeof(Res_png_9patch)) { - return false; + return JNI_FALSE; } const jbyte* array = env->GetByteArrayElements(obj, 0); if (array != NULL) { const Res_png_9patch* chunk = reinterpret_cast<const Res_png_9patch*>(array); int8_t wasDeserialized = chunk->wasDeserialized; env->ReleaseByteArrayElements(obj, const_cast<jbyte*>(array), JNI_ABORT); - return wasDeserialized != -1; + return (wasDeserialized != -1) ? JNI_TRUE : JNI_FALSE; } - return false; + return JNI_FALSE; } - static int8_t* validateNinePatchChunk(JNIEnv* env, jobject, jint, jbyteArray obj) { + static jlong validateNinePatchChunk(JNIEnv* env, jobject, jlong, jbyteArray obj) { size_t chunkSize = env->GetArrayLength(obj); if (chunkSize < (int) (sizeof(Res_png_9patch))) { jniThrowRuntimeException(env, "Array too small for chunk."); @@ -72,10 +72,11 @@ public: // This call copies the content of the jbyteArray env->GetByteArrayRegion(obj, 0, chunkSize, reinterpret_cast<jbyte*>(storage)); // Deserialize in place, return the array we just allocated - return (int8_t*) Res_png_9patch::deserialize(storage); + return reinterpret_cast<jlong>(Res_png_9patch::deserialize(storage)); } - static void finalize(JNIEnv* env, jobject, int8_t* patch) { + static void finalize(JNIEnv* env, jobject, jlong patchHandle) { + int8_t* patch = reinterpret_cast<int8_t*>(patchHandle); #ifdef USE_OPENGL_RENDERER if (android::uirenderer::Caches::hasInstance()) { Res_png_9patch* p = (Res_png_9patch*) patch; @@ -115,9 +116,13 @@ public: } } - static void drawF(JNIEnv* env, jobject, SkCanvas* canvas, jobject boundsRectF, - const SkBitmap* bitmap, Res_png_9patch* chunk, const SkPaint* paint, + static void drawF(JNIEnv* env, jobject, jlong canvasHandle, jobject boundsRectF, + jlong bitmapHandle, jlong chunkHandle, jlong paintHandle, jint destDensity, jint srcDensity) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle); + const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkASSERT(canvas); SkASSERT(boundsRectF); SkASSERT(bitmap); @@ -130,9 +135,13 @@ public: draw(env, canvas, bounds, bitmap, chunk, paint, destDensity, srcDensity); } - static void drawI(JNIEnv* env, jobject, SkCanvas* canvas, jobject boundsRect, - const SkBitmap* bitmap, Res_png_9patch* chunk, const SkPaint* paint, + static void drawI(JNIEnv* env, jobject, jlong canvasHandle, jobject boundsRect, + jlong bitmapHandle, jlong chunkHandle, jlong paintHandle, jint destDensity, jint srcDensity) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle); + const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkASSERT(canvas); SkASSERT(boundsRect); SkASSERT(bitmap); @@ -144,8 +153,10 @@ public: draw(env, canvas, bounds, bitmap, chunk, paint, destDensity, srcDensity); } - static jint getTransparentRegion(JNIEnv* env, jobject, const SkBitmap* bitmap, - Res_png_9patch* chunk, jobject boundsRect) { + static jlong getTransparentRegion(JNIEnv* env, jobject, jlong bitmapHandle, + jlong chunkHandle, jobject boundsRect) { + const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle); SkASSERT(bitmap); SkASSERT(chunk); SkASSERT(boundsRect); @@ -156,7 +167,7 @@ public: SkRegion* region = NULL; NinePatch_Draw(NULL, bounds, *bitmap, *chunk, NULL, ®ion); - return (jint) region; + return reinterpret_cast<jlong>(region); } }; @@ -167,11 +178,11 @@ public: static JNINativeMethod gNinePatchMethods[] = { { "isNinePatchChunk", "([B)Z", (void*) SkNinePatchGlue::isNinePatchChunk }, - { "validateNinePatchChunk", "(I[B)I", (void*) SkNinePatchGlue::validateNinePatchChunk }, - { "nativeFinalize", "(I)V", (void*) SkNinePatchGlue::finalize }, - { "nativeDraw", "(ILandroid/graphics/RectF;IIIII)V", (void*) SkNinePatchGlue::drawF }, - { "nativeDraw", "(ILandroid/graphics/Rect;IIIII)V", (void*) SkNinePatchGlue::drawI }, - { "nativeGetTransparentRegion", "(IILandroid/graphics/Rect;)I", + { "validateNinePatchChunk", "(J[B)J", (void*) SkNinePatchGlue::validateNinePatchChunk }, + { "nativeFinalize", "(J)V", (void*) SkNinePatchGlue::finalize }, + { "nativeDraw", "(JLandroid/graphics/RectF;JJJII)V", (void*) SkNinePatchGlue::drawF }, + { "nativeDraw", "(JLandroid/graphics/Rect;JJJII)V", (void*) SkNinePatchGlue::drawI }, + { "nativeGetTransparentRegion", "(JJLandroid/graphics/Rect;)J", (void*) SkNinePatchGlue::getTransparentRegion } }; diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp index 40e0731..2523481 100644 --- a/core/jni/android/graphics/Paint.cpp +++ b/core/jni/android/graphics/Paint.cpp @@ -70,33 +70,40 @@ public: AFTER, AT_OR_AFTER, BEFORE, AT_OR_BEFORE, AT }; - static void finalizer(JNIEnv* env, jobject clazz, SkPaint* obj) { + static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); delete obj; } - static SkPaint* init(JNIEnv* env, jobject clazz) { + static jlong init(JNIEnv* env, jobject clazz) { SkPaint* obj = new SkPaint(); defaultSettingsForAndroid(obj); - return obj; + return reinterpret_cast<jlong>(obj); } - static SkPaint* intiWithPaint(JNIEnv* env, jobject clazz, SkPaint* paint) { + static jlong initWithPaint(JNIEnv* env, jobject clazz, jlong paintHandle) { + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkPaint* obj = new SkPaint(*paint); - return obj; + return reinterpret_cast<jlong>(obj); } - static void reset(JNIEnv* env, jobject clazz, SkPaint* obj) { + static void reset(JNIEnv* env, jobject clazz, jlong objHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); obj->reset(); defaultSettingsForAndroid(obj); } - static void assign(JNIEnv* env, jobject clazz, SkPaint* dst, const SkPaint* src) { + static void assign(JNIEnv* env, jobject clazz, jlong dstPaintHandle, jlong srcPaintHandle) { + SkPaint* dst = reinterpret_cast<SkPaint*>(dstPaintHandle); + const SkPaint* src = reinterpret_cast<SkPaint*>(srcPaintHandle); *dst = *src; } static jint getFlags(JNIEnv* env, jobject paint) { NPE_CHECK_RETURN_ZERO(env, paint); - return GraphicsJNI::getNativePaint(env, paint)->getFlags(); + int result; + result = GraphicsJNI::getNativePaint(env, paint)->getFlags(); + return static_cast<jint>(result); } static void setFlags(JNIEnv* env, jobject paint, jint flags) { @@ -156,22 +163,29 @@ public: GraphicsJNI::getNativePaint(env, paint)->setDither(dither); } - static jint getStyle(JNIEnv* env, jobject clazz, SkPaint* obj) { - return obj->getStyle(); + static jint getStyle(JNIEnv* env, jobject clazz,jlong objHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + return static_cast<jint>(obj->getStyle()); } - static void setStyle(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Style style) { + static void setStyle(JNIEnv* env, jobject clazz, jlong objHandle, jint styleHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + SkPaint::Style style = static_cast<SkPaint::Style>(styleHandle); obj->setStyle(style); } static jint getColor(JNIEnv* env, jobject paint) { NPE_CHECK_RETURN_ZERO(env, paint); - return GraphicsJNI::getNativePaint(env, paint)->getColor(); + int color; + color = GraphicsJNI::getNativePaint(env, paint)->getColor(); + return static_cast<jint>(color); } static jint getAlpha(JNIEnv* env, jobject paint) { NPE_CHECK_RETURN_ZERO(env, paint); - return GraphicsJNI::getNativePaint(env, paint)->getAlpha(); + int alpha; + alpha = GraphicsJNI::getNativePaint(env, paint)->getAlpha(); + return static_cast<jint>(alpha); } static void setColor(JNIEnv* env, jobject paint, jint color) { @@ -204,59 +218,85 @@ public: GraphicsJNI::getNativePaint(env, paint)->setStrokeMiter(SkFloatToScalar(miter)); } - static jint getStrokeCap(JNIEnv* env, jobject clazz, SkPaint* obj) { - return obj->getStrokeCap(); + static jint getStrokeCap(JNIEnv* env, jobject clazz, jlong objHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + return static_cast<jint>(obj->getStrokeCap()); } - static void setStrokeCap(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Cap cap) { + static void setStrokeCap(JNIEnv* env, jobject clazz, jlong objHandle, jint capHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + SkPaint::Cap cap = static_cast<SkPaint::Cap>(capHandle); obj->setStrokeCap(cap); } - static jint getStrokeJoin(JNIEnv* env, jobject clazz, SkPaint* obj) { - return obj->getStrokeJoin(); + static jint getStrokeJoin(JNIEnv* env, jobject clazz, jlong objHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + return static_cast<jint>(obj->getStrokeJoin()); } - static void setStrokeJoin(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Join join) { + static void setStrokeJoin(JNIEnv* env, jobject clazz, jlong objHandle, jint joinHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + SkPaint::Join join = (SkPaint::Join) joinHandle; obj->setStrokeJoin(join); } - static jboolean getFillPath(JNIEnv* env, jobject clazz, SkPaint* obj, SkPath* src, SkPath* dst) { - return obj->getFillPath(*src, dst); + static jboolean getFillPath(JNIEnv* env, jobject clazz, jlong objHandle, jlong srcHandle, jlong dstHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + SkPath* src = reinterpret_cast<SkPath*>(srcHandle); + SkPath* dst = reinterpret_cast<SkPath*>(dstHandle); + return obj->getFillPath(*src, dst) ? JNI_TRUE : JNI_FALSE; } - static SkShader* setShader(JNIEnv* env, jobject clazz, SkPaint* obj, SkShader* shader) { - return obj->setShader(shader); + static jlong setShader(JNIEnv* env, jobject clazz, jlong objHandle, jlong shaderHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle); + return reinterpret_cast<jlong>(obj->setShader(shader)); } - static SkColorFilter* setColorFilter(JNIEnv* env, jobject clazz, SkPaint* obj, SkColorFilter* filter) { - return obj->setColorFilter(filter); + static jlong setColorFilter(JNIEnv* env, jobject clazz, jlong objHandle, jlong filterHandle) { + SkPaint* obj = reinterpret_cast<SkPaint *>(objHandle); + SkColorFilter* filter = reinterpret_cast<SkColorFilter *>(filterHandle); + return reinterpret_cast<jlong>(obj->setColorFilter(filter)); } - static SkXfermode* setXfermode(JNIEnv* env, jobject clazz, SkPaint* obj, SkXfermode* xfermode) { - return obj->setXfermode(xfermode); + static jlong setXfermode(JNIEnv* env, jobject clazz, jlong objHandle, jlong xfermodeHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + SkXfermode* xfermode = reinterpret_cast<SkXfermode*>(xfermodeHandle); + return reinterpret_cast<jlong>(obj->setXfermode(xfermode)); } - static SkPathEffect* setPathEffect(JNIEnv* env, jobject clazz, SkPaint* obj, SkPathEffect* effect) { - return obj->setPathEffect(effect); + static jlong setPathEffect(JNIEnv* env, jobject clazz, jlong objHandle, jlong effectHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + SkPathEffect* effect = reinterpret_cast<SkPathEffect*>(effectHandle); + return reinterpret_cast<jlong>(obj->setPathEffect(effect)); } - static SkMaskFilter* setMaskFilter(JNIEnv* env, jobject clazz, SkPaint* obj, SkMaskFilter* maskfilter) { - return obj->setMaskFilter(maskfilter); + static jlong setMaskFilter(JNIEnv* env, jobject clazz, jlong objHandle, jlong maskfilterHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + SkMaskFilter* maskfilter = reinterpret_cast<SkMaskFilter*>(maskfilterHandle); + return reinterpret_cast<jlong>(obj->setMaskFilter(maskfilter)); } - static SkTypeface* setTypeface(JNIEnv* env, jobject clazz, SkPaint* obj, SkTypeface* typeface) { - return obj->setTypeface(typeface); + static jlong setTypeface(JNIEnv* env, jobject clazz, jlong objHandle, jlong typefaceHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + SkTypeface* typeface = reinterpret_cast<SkTypeface*>(typefaceHandle); + return reinterpret_cast<jlong>(obj->setTypeface(typeface)); } - static SkRasterizer* setRasterizer(JNIEnv* env, jobject clazz, SkPaint* obj, SkRasterizer* rasterizer) { - return obj->setRasterizer(rasterizer); + static jlong setRasterizer(JNIEnv* env, jobject clazz, jlong objHandle, jlong rasterizerHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + SkRasterizer* rasterizer = reinterpret_cast<SkRasterizer*>(rasterizerHandle); + return reinterpret_cast<jlong>(obj->setRasterizer(rasterizer)); } - static jint getTextAlign(JNIEnv* env, jobject clazz, SkPaint* obj) { - return obj->getTextAlign(); + static jint getTextAlign(JNIEnv* env, jobject clazz, jlong objHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + return static_cast<jint>(obj->getTextAlign()); } - static void setTextAlign(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Align align) { + static void setTextAlign(JNIEnv* env, jobject clazz, jlong objHandle, jint alignHandle) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); + SkPaint::Align align = static_cast<SkPaint::Align>(alignHandle); obj->setTextAlign(align); } @@ -300,7 +340,8 @@ public: output[0] = '\0'; } - static void setTextLocale(JNIEnv* env, jobject clazz, SkPaint* obj, jstring locale) { + static void setTextLocale(JNIEnv* env, jobject clazz, jlong objHandle, jstring locale) { + SkPaint* obj = reinterpret_cast<SkPaint*>(objHandle); ScopedUtfChars localeChars(env, locale); char langTag[ULOC_FULLNAME_CAPACITY]; toLanguageTag(langTag, ULOC_FULLNAME_CAPACITY, localeChars.c_str()); @@ -390,7 +431,7 @@ public: return descent - ascent + leading; } - static jfloat measureText_CIII(JNIEnv* env, jobject jpaint, jcharArray text, int index, int count, + static jfloat measureText_CIII(JNIEnv* env, jobject jpaint, jcharArray text, jint index, jint count, jint bidiFlags) { NPE_CHECK_RETURN_ZERO(env, jpaint); NPE_CHECK_RETURN_ZERO(env, text); @@ -415,7 +456,7 @@ public: return result; } - static jfloat measureText_StringIII(JNIEnv* env, jobject jpaint, jstring text, int start, int end, + static jfloat measureText_StringIII(JNIEnv* env, jobject jpaint, jstring text, jint start, jint end, jint bidiFlags) { NPE_CHECK_RETURN_ZERO(env, jpaint); NPE_CHECK_RETURN_ZERO(env, text); @@ -488,8 +529,9 @@ public: return count; } - static int getTextWidths___CIII_F(JNIEnv* env, jobject clazz, SkPaint* paint, jcharArray text, - int index, int count, jint bidiFlags, jfloatArray widths) { + static jint getTextWidths___CIII_F(JNIEnv* env, jobject clazz, jlong paintHandle, jcharArray text, + jint index, jint count, jint bidiFlags, jfloatArray widths) { + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* textArray = env->GetCharArrayElements(text, NULL); count = dotextwidths(env, paint, textArray + index, count, widths, bidiFlags); env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray), @@ -497,8 +539,9 @@ public: return count; } - static int getTextWidths__StringIII_F(JNIEnv* env, jobject clazz, SkPaint* paint, jstring text, - int start, int end, jint bidiFlags, jfloatArray widths) { + static jint getTextWidths__StringIII_F(JNIEnv* env, jobject clazz, jlong paintHandle, jstring text, + jint start, jint end, jint bidiFlags, jfloatArray widths) { + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* textArray = env->GetStringChars(text, NULL); int count = dotextwidths(env, paint, textArray + start, end - start, widths, bidiFlags); env->ReleaseStringChars(text, textArray); @@ -535,9 +578,10 @@ public: return glyphsCount; } - static int getTextGlyphs__StringIIIII_C(JNIEnv* env, jobject clazz, SkPaint* paint, + static jint getTextGlyphs__StringIIIII_C(JNIEnv* env, jobject clazz, jlong paintHandle, jstring text, jint start, jint end, jint contextStart, jint contextEnd, jint flags, jcharArray glyphs) { + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* textArray = env->GetStringChars(text, NULL); int count = doTextGlyphs(env, paint, textArray + contextStart, start - contextStart, end - start, contextEnd - contextStart, flags, glyphs); @@ -577,9 +621,10 @@ public: return totalAdvance; } - static float getTextRunAdvances___CIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint, + static jfloat getTextRunAdvances___CIIIII_FI(JNIEnv* env, jobject clazz, jlong paintHandle, jcharArray text, jint index, jint count, jint contextIndex, jint contextCount, jint flags, jfloatArray advances, jint advancesIndex) { + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jchar* textArray = env->GetCharArrayElements(text, NULL); jfloat result = doTextRunAdvances(env, paint, textArray + contextIndex, index - contextIndex, count, contextCount, flags, advances, advancesIndex); @@ -587,9 +632,10 @@ public: return result; } - static float getTextRunAdvances__StringIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint, + static jfloat getTextRunAdvances__StringIIIII_FI(JNIEnv* env, jobject clazz, jlong paintHandle, jstring text, jint start, jint end, jint contextStart, jint contextEnd, jint flags, jfloatArray advances, jint advancesIndex) { + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* textArray = env->GetStringChars(text, NULL); jfloat result = doTextRunAdvances(env, paint, textArray + contextStart, start - contextStart, end - start, contextEnd - contextStart, flags, @@ -642,8 +688,9 @@ public: return pos; } - static jint getTextRunCursor___C(JNIEnv* env, jobject clazz, SkPaint* paint, jcharArray text, + static jint getTextRunCursor___C(JNIEnv* env, jobject clazz, jlong paintHandle, jcharArray text, jint contextStart, jint contextCount, jint flags, jint offset, jint cursorOpt) { + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jchar* textArray = env->GetCharArrayElements(text, NULL); jint result = doTextRunCursor(env, paint, textArray, contextStart, contextCount, flags, offset, cursorOpt); @@ -651,8 +698,9 @@ public: return result; } - static jint getTextRunCursor__String(JNIEnv* env, jobject clazz, SkPaint* paint, jstring text, + static jint getTextRunCursor__String(JNIEnv* env, jobject clazz, jlong paintHandle, jstring text, jint contextStart, jint contextEnd, jint flags, jint offset, jint cursorOpt) { + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* textArray = env->GetStringChars(text, NULL); jint result = doTextRunCursor(env, paint, textArray, contextStart, contextEnd - contextStart, flags, offset, cursorOpt); @@ -665,22 +713,26 @@ public: TextLayout::getTextPath(paint, text, count, bidiFlags, x, y, path); } - static void getTextPath___C(JNIEnv* env, jobject clazz, SkPaint* paint, jint bidiFlags, - jcharArray text, int index, int count, jfloat x, jfloat y, SkPath* path) { + static void getTextPath___C(JNIEnv* env, jobject clazz, jlong paintHandle, jint bidiFlags, + jcharArray text, jint index, jint count, jfloat x, jfloat y, jlong pathHandle) { + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); + SkPath* path = reinterpret_cast<SkPath*>(pathHandle); const jchar* textArray = env->GetCharArrayElements(text, NULL); getTextPath(env, paint, textArray + index, count, bidiFlags, x, y, path); env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray), JNI_ABORT); } - static void getTextPath__String(JNIEnv* env, jobject clazz, SkPaint* paint, jint bidiFlags, - jstring text, int start, int end, jfloat x, jfloat y, SkPath* path) { + static void getTextPath__String(JNIEnv* env, jobject clazz, jlong paintHandle, jint bidiFlags, + jstring text, jint start, jint end, jfloat x, jfloat y, jlong pathHandle) { + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); + SkPath* path = reinterpret_cast<SkPath*>(pathHandle); const jchar* textArray = env->GetStringChars(text, NULL); getTextPath(env, paint, textArray + start, end - start, bidiFlags, x, y, path); env->ReleaseStringChars(text, textArray); } static void setShadowLayer(JNIEnv* env, jobject jpaint, jfloat radius, - jfloat dx, jfloat dy, int color) { + jfloat dx, jfloat dy, jint color) { NPE_CHECK_RETURN_VOID(env, jpaint); SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint); @@ -716,8 +768,8 @@ public: return bytes >> 1; } - static int breakTextC(JNIEnv* env, jobject jpaint, jcharArray jtext, - int index, int count, float maxWidth, jint bidiFlags, jfloatArray jmeasuredWidth) { + static jint breakTextC(JNIEnv* env, jobject jpaint, jcharArray jtext, + jint index, jint count, jfloat maxWidth, jint bidiFlags, jfloatArray jmeasuredWidth) { NPE_CHECK_RETURN_ZERO(env, jpaint); NPE_CHECK_RETURN_ZERO(env, jtext); @@ -744,8 +796,8 @@ public: return count; } - static int breakTextS(JNIEnv* env, jobject jpaint, jstring jtext, - bool forwards, float maxWidth, jint bidiFlags, jfloatArray jmeasuredWidth) { + static jint breakTextS(JNIEnv* env, jobject jpaint, jstring jtext, + jboolean forwards, jfloat maxWidth, jint bidiFlags, jfloatArray jmeasuredWidth) { NPE_CHECK_RETURN_ZERO(env, jpaint); NPE_CHECK_RETURN_ZERO(env, jtext); @@ -776,15 +828,17 @@ public: GraphicsJNI::irect_to_jrect(ir, env, bounds); } - static void getStringBounds(JNIEnv* env, jobject, const SkPaint* paint, - jstring text, int start, int end, jint bidiFlags, jobject bounds) { + static void getStringBounds(JNIEnv* env, jobject, jlong paintHandle, + jstring text, jint start, jint end, jint bidiFlags, jobject bounds) { + const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle);; const jchar* textArray = env->GetStringChars(text, NULL); doTextBounds(env, textArray + start, end - start, bounds, *paint, bidiFlags); env->ReleaseStringChars(text, textArray); } - static void getCharArrayBounds(JNIEnv* env, jobject, const SkPaint* paint, - jcharArray text, int index, int count, jint bidiFlags, jobject bounds) { + static void getCharArrayBounds(JNIEnv* env, jobject, jlong paintHandle, + jcharArray text, jint index, jint count, jint bidiFlags, jobject bounds) { + const SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* textArray = env->GetCharArrayElements(text, NULL); doTextBounds(env, textArray + index, count, bounds, *paint, bidiFlags); env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray), @@ -794,11 +848,11 @@ public: }; static JNINativeMethod methods[] = { - {"finalizer", "(I)V", (void*) SkPaintGlue::finalizer}, - {"native_init","()I", (void*) SkPaintGlue::init}, - {"native_initWithPaint","(I)I", (void*) SkPaintGlue::intiWithPaint}, - {"native_reset","(I)V", (void*) SkPaintGlue::reset}, - {"native_set","(II)V", (void*) SkPaintGlue::assign}, + {"finalizer", "(J)V", (void*) SkPaintGlue::finalizer}, + {"native_init","()J", (void*) SkPaintGlue::init}, + {"native_initWithPaint","(J)J", (void*) SkPaintGlue::initWithPaint}, + {"native_reset","(J)V", (void*) SkPaintGlue::reset}, + {"native_set","(JJ)V", (void*) SkPaintGlue::assign}, {"getFlags","()I", (void*) SkPaintGlue::getFlags}, {"setFlags","(I)V", (void*) SkPaintGlue::setFlags}, {"getHinting","()I", (void*) SkPaintGlue::getHinting}, @@ -811,8 +865,8 @@ static JNINativeMethod methods[] = { {"setFakeBoldText","(Z)V", (void*) SkPaintGlue::setFakeBoldText}, {"setFilterBitmap","(Z)V", (void*) SkPaintGlue::setFilterBitmap}, {"setDither","(Z)V", (void*) SkPaintGlue::setDither}, - {"native_getStyle","(I)I", (void*) SkPaintGlue::getStyle}, - {"native_setStyle","(II)V", (void*) SkPaintGlue::setStyle}, + {"native_getStyle","(J)I", (void*) SkPaintGlue::getStyle}, + {"native_setStyle","(JI)V", (void*) SkPaintGlue::setStyle}, {"getColor","()I", (void*) SkPaintGlue::getColor}, {"setColor","(I)V", (void*) SkPaintGlue::setColor}, {"getAlpha","()I", (void*) SkPaintGlue::getAlpha}, @@ -821,21 +875,21 @@ static JNINativeMethod methods[] = { {"setStrokeWidth","(F)V", (void*) SkPaintGlue::setStrokeWidth}, {"getStrokeMiter","()F", (void*) SkPaintGlue::getStrokeMiter}, {"setStrokeMiter","(F)V", (void*) SkPaintGlue::setStrokeMiter}, - {"native_getStrokeCap","(I)I", (void*) SkPaintGlue::getStrokeCap}, - {"native_setStrokeCap","(II)V", (void*) SkPaintGlue::setStrokeCap}, - {"native_getStrokeJoin","(I)I", (void*) SkPaintGlue::getStrokeJoin}, - {"native_setStrokeJoin","(II)V", (void*) SkPaintGlue::setStrokeJoin}, - {"native_getFillPath","(III)Z", (void*) SkPaintGlue::getFillPath}, - {"native_setShader","(II)I", (void*) SkPaintGlue::setShader}, - {"native_setColorFilter","(II)I", (void*) SkPaintGlue::setColorFilter}, - {"native_setXfermode","(II)I", (void*) SkPaintGlue::setXfermode}, - {"native_setPathEffect","(II)I", (void*) SkPaintGlue::setPathEffect}, - {"native_setMaskFilter","(II)I", (void*) SkPaintGlue::setMaskFilter}, - {"native_setTypeface","(II)I", (void*) SkPaintGlue::setTypeface}, - {"native_setRasterizer","(II)I", (void*) SkPaintGlue::setRasterizer}, - {"native_getTextAlign","(I)I", (void*) SkPaintGlue::getTextAlign}, - {"native_setTextAlign","(II)V", (void*) SkPaintGlue::setTextAlign}, - {"native_setTextLocale","(ILjava/lang/String;)V", (void*) SkPaintGlue::setTextLocale}, + {"native_getStrokeCap","(J)I", (void*) SkPaintGlue::getStrokeCap}, + {"native_setStrokeCap","(JI)V", (void*) SkPaintGlue::setStrokeCap}, + {"native_getStrokeJoin","(J)I", (void*) SkPaintGlue::getStrokeJoin}, + {"native_setStrokeJoin","(JI)V", (void*) SkPaintGlue::setStrokeJoin}, + {"native_getFillPath","(JJJ)Z", (void*) SkPaintGlue::getFillPath}, + {"native_setShader","(JJ)J", (void*) SkPaintGlue::setShader}, + {"native_setColorFilter","(JJ)J", (void*) SkPaintGlue::setColorFilter}, + {"native_setXfermode","(JJ)J", (void*) SkPaintGlue::setXfermode}, + {"native_setPathEffect","(JJ)J", (void*) SkPaintGlue::setPathEffect}, + {"native_setMaskFilter","(JJ)J", (void*) SkPaintGlue::setMaskFilter}, + {"native_setTypeface","(JJ)J", (void*) SkPaintGlue::setTypeface}, + {"native_setRasterizer","(JJ)J", (void*) SkPaintGlue::setRasterizer}, + {"native_getTextAlign","(J)I", (void*) SkPaintGlue::getTextAlign}, + {"native_setTextAlign","(JI)V", (void*) SkPaintGlue::setTextAlign}, + {"native_setTextLocale","(JLjava/lang/String;)V", (void*) SkPaintGlue::setTextLocale}, {"getTextSize","()F", (void*) SkPaintGlue::getTextSize}, {"setTextSize","(F)V", (void*) SkPaintGlue::setTextSize}, {"getTextScaleX","()F", (void*) SkPaintGlue::getTextScaleX}, @@ -851,24 +905,24 @@ static JNINativeMethod methods[] = { {"native_measureText","(Ljava/lang/String;III)F", (void*) SkPaintGlue::measureText_StringIII}, {"native_breakText","([CIIFI[F)I", (void*) SkPaintGlue::breakTextC}, {"native_breakText","(Ljava/lang/String;ZFI[F)I", (void*) SkPaintGlue::breakTextS}, - {"native_getTextWidths","(I[CIII[F)I", (void*) SkPaintGlue::getTextWidths___CIII_F}, - {"native_getTextWidths","(ILjava/lang/String;III[F)I", (void*) SkPaintGlue::getTextWidths__StringIII_F}, - {"native_getTextRunAdvances","(I[CIIIII[FI)F", + {"native_getTextWidths","(J[CIII[F)I", (void*) SkPaintGlue::getTextWidths___CIII_F}, + {"native_getTextWidths","(JLjava/lang/String;III[F)I", (void*) SkPaintGlue::getTextWidths__StringIII_F}, + {"native_getTextRunAdvances","(J[CIIIII[FI)F", (void*) SkPaintGlue::getTextRunAdvances___CIIIII_FI}, - {"native_getTextRunAdvances","(ILjava/lang/String;IIIII[FI)F", + {"native_getTextRunAdvances","(JLjava/lang/String;IIIII[FI)F", (void*) SkPaintGlue::getTextRunAdvances__StringIIIII_FI}, - {"native_getTextGlyphs","(ILjava/lang/String;IIIII[C)I", + {"native_getTextGlyphs","(JLjava/lang/String;IIIII[C)I", (void*) SkPaintGlue::getTextGlyphs__StringIIIII_C}, - {"native_getTextRunCursor", "(I[CIIIII)I", (void*) SkPaintGlue::getTextRunCursor___C}, - {"native_getTextRunCursor", "(ILjava/lang/String;IIIII)I", + {"native_getTextRunCursor", "(J[CIIIII)I", (void*) SkPaintGlue::getTextRunCursor___C}, + {"native_getTextRunCursor", "(JLjava/lang/String;IIIII)I", (void*) SkPaintGlue::getTextRunCursor__String}, - {"native_getTextPath","(II[CIIFFI)V", (void*) SkPaintGlue::getTextPath___C}, - {"native_getTextPath","(IILjava/lang/String;IIFFI)V", (void*) SkPaintGlue::getTextPath__String}, - {"nativeGetStringBounds", "(ILjava/lang/String;IIILandroid/graphics/Rect;)V", + {"native_getTextPath","(JI[CIIFFJ)V", (void*) SkPaintGlue::getTextPath___C}, + {"native_getTextPath","(JILjava/lang/String;IIFFJ)V", (void*) SkPaintGlue::getTextPath__String}, + {"nativeGetStringBounds", "(JLjava/lang/String;IIILandroid/graphics/Rect;)V", (void*) SkPaintGlue::getStringBounds }, - {"nativeGetCharArrayBounds", "(I[CIIILandroid/graphics/Rect;)V", + {"nativeGetCharArrayBounds", "(J[CIIILandroid/graphics/Rect;)V", (void*) SkPaintGlue::getCharArrayBounds }, {"nSetShadowLayer", "(FFFI)V", (void*)SkPaintGlue::setShadowLayer} }; diff --git a/core/jni/android/graphics/Path.cpp b/core/jni/android/graphics/Path.cpp index ab7f1dc..54b6996 100644 --- a/core/jni/android/graphics/Path.cpp +++ b/core/jni/android/graphics/Path.cpp @@ -34,7 +34,8 @@ namespace android { class SkPathGlue { public: - static void finalizer(JNIEnv* env, jobject clazz, SkPath* obj) { + static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); #ifdef USE_OPENGL_RENDERER if (android::uirenderer::Caches::hasInstance()) { android::uirenderer::Caches::getInstance().resourceCache.destructor(obj); @@ -44,79 +45,96 @@ public: delete obj; } - static SkPath* init1(JNIEnv* env, jobject clazz) { - return new SkPath(); + static jlong init1(JNIEnv* env, jobject clazz) { + return reinterpret_cast<jlong>(new SkPath()); } - - static SkPath* init2(JNIEnv* env, jobject clazz, SkPath* val) { - return new SkPath(*val); + + static jlong init2(JNIEnv* env, jobject clazz, jlong valHandle) { + SkPath* val = reinterpret_cast<SkPath*>(valHandle); + return reinterpret_cast<jlong>(new SkPath(*val)); } - - static void reset(JNIEnv* env, jobject clazz, SkPath* obj) { + + static void reset(JNIEnv* env, jobject clazz, jlong objHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); obj->reset(); } - static void rewind(JNIEnv* env, jobject clazz, SkPath* obj) { + static void rewind(JNIEnv* env, jobject clazz, jlong objHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); obj->rewind(); } - static void assign(JNIEnv* env, jobject clazz, SkPath* dst, const SkPath* src) { + static void assign(JNIEnv* env, jobject clazz, jlong dstHandle, jlong srcHandle) { + SkPath* dst = reinterpret_cast<SkPath*>(dstHandle); + const SkPath* src = reinterpret_cast<SkPath*>(srcHandle); *dst = *src; } - - static jint getFillType(JNIEnv* env, jobject clazz, SkPath* obj) { + + static jint getFillType(JNIEnv* env, jobject clazz, jlong objHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); return obj->getFillType(); } - static void setFillType(JNIEnv* env, jobject clazz, SkPath* path, SkPath::FillType ft) { + static void setFillType(JNIEnv* env, jobject clazz, jlong pathHandle, jint ftHandle) { + SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + SkPath::FillType ft = static_cast<SkPath::FillType>(ftHandle); path->setFillType(ft); } - - static jboolean isEmpty(JNIEnv* env, jobject clazz, SkPath* obj) { + + static jboolean isEmpty(JNIEnv* env, jobject clazz, jlong objHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); return obj->isEmpty(); } - static jboolean isRect(JNIEnv* env, jobject clazz, SkPath* obj, jobject rect) { + static jboolean isRect(JNIEnv* env, jobject clazz, jlong objHandle, jobject rect) { SkRect rect_; + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); jboolean result = obj->isRect(&rect_); GraphicsJNI::rect_to_jrectf(rect_, env, rect); return result; } - static void computeBounds(JNIEnv* env, jobject clazz, SkPath* obj, jobject bounds) { + static void computeBounds(JNIEnv* env, jobject clazz, jlong objHandle, jobject bounds) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); const SkRect& bounds_ = obj->getBounds(); GraphicsJNI::rect_to_jrectf(bounds_, env, bounds); } - static void incReserve(JNIEnv* env, jobject clazz, SkPath* obj, jint extraPtCount) { + static void incReserve(JNIEnv* env, jobject clazz, jlong objHandle, jint extraPtCount) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); obj->incReserve(extraPtCount); } - static void moveTo__FF(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x, jfloat y) { + static void moveTo__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x, jfloat y) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); SkScalar x_ = SkFloatToScalar(x); SkScalar y_ = SkFloatToScalar(y); obj->moveTo(x_, y_); } - static void rMoveTo(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx, jfloat dy) { + static void rMoveTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); SkScalar dx_ = SkFloatToScalar(dx); SkScalar dy_ = SkFloatToScalar(dy); obj->rMoveTo(dx_, dy_); } - static void lineTo__FF(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x, jfloat y) { + static void lineTo__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x, jfloat y) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); SkScalar x_ = SkFloatToScalar(x); SkScalar y_ = SkFloatToScalar(y); obj->lineTo(x_, y_); } - static void rLineTo(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx, jfloat dy) { + static void rLineTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); SkScalar dx_ = SkFloatToScalar(dx); SkScalar dy_ = SkFloatToScalar(dy); obj->rLineTo(dx_, dy_); } - static void quadTo__FFFF(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x1, jfloat y1, jfloat x2, jfloat y2) { + static void quadTo__FFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x1, jfloat y1, jfloat x2, jfloat y2) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); SkScalar x1_ = SkFloatToScalar(x1); SkScalar y1_ = SkFloatToScalar(y1); SkScalar x2_ = SkFloatToScalar(x2); @@ -124,7 +142,8 @@ public: obj->quadTo(x1_, y1_, x2_, y2_); } - static void rQuadTo(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx1, jfloat dy1, jfloat dx2, jfloat dy2) { + static void rQuadTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx1, jfloat dy1, jfloat dx2, jfloat dy2) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); SkScalar dx1_ = SkFloatToScalar(dx1); SkScalar dy1_ = SkFloatToScalar(dy1); SkScalar dx2_ = SkFloatToScalar(dx2); @@ -132,7 +151,8 @@ public: obj->rQuadTo(dx1_, dy1_, dx2_, dy2_); } - static void cubicTo__FFFFFF(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) { + static void cubicTo__FFFFFF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); SkScalar x1_ = SkFloatToScalar(x1); SkScalar y1_ = SkFloatToScalar(y1); SkScalar x2_ = SkFloatToScalar(x2); @@ -142,7 +162,8 @@ public: obj->cubicTo(x1_, y1_, x2_, y2_, x3_, y3_); } - static void rCubicTo(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) { + static void rCubicTo(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); SkScalar x1_ = SkFloatToScalar(x1); SkScalar y1_ = SkFloatToScalar(y1); SkScalar x2_ = SkFloatToScalar(x2); @@ -152,7 +173,8 @@ public: obj->rCubicTo(x1_, y1_, x2_, y2_, x3_, y3_); } - static void arcTo(JNIEnv* env, jobject clazz, SkPath* obj, jobject oval, jfloat startAngle, jfloat sweepAngle, jboolean forceMoveTo) { + static void arcTo(JNIEnv* env, jobject clazz, jlong objHandle, jobject oval, jfloat startAngle, jfloat sweepAngle, jboolean forceMoveTo) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); SkRect oval_; GraphicsJNI::jrectf_to_rect(env, oval, &oval_); SkScalar startAngle_ = SkFloatToScalar(startAngle); @@ -160,17 +182,22 @@ public: obj->arcTo(oval_, startAngle_, sweepAngle_, forceMoveTo); } - static void close(JNIEnv* env, jobject clazz, SkPath* obj) { + static void close(JNIEnv* env, jobject clazz, jlong objHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); obj->close(); } - static void addRect__RectFI(JNIEnv* env, jobject clazz, SkPath* obj, jobject rect, SkPath::Direction dir) { + static void addRect__RectFI(JNIEnv* env, jobject clazz, jlong objHandle, jobject rect, jint dirHandle) { SkRect rect_; + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); GraphicsJNI::jrectf_to_rect(env, rect, &rect_); obj->addRect(rect_, dir); } - static void addRect__FFFFI(JNIEnv* env, jobject clazz, SkPath* obj, jfloat left, jfloat top, jfloat right, jfloat bottom, SkPath::Direction dir) { + static void addRect__FFFFI(JNIEnv* env, jobject clazz, jlong objHandle, jfloat left, jfloat top, jfloat right, jfloat bottom, jint dirHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); SkScalar left_ = SkFloatToScalar(left); SkScalar top_ = SkFloatToScalar(top); SkScalar right_ = SkFloatToScalar(right); @@ -178,39 +205,48 @@ public: obj->addRect(left_, top_, right_, bottom_, dir); } - static void addOval(JNIEnv* env, jobject clazz, SkPath* obj, jobject oval, SkPath::Direction dir) { + static void addOval(JNIEnv* env, jobject clazz, jlong objHandle, jobject oval, jint dirHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); SkRect oval_; GraphicsJNI::jrectf_to_rect(env, oval, &oval_); obj->addOval(oval_, dir); } - static void addCircle(JNIEnv* env, jobject clazz, SkPath* obj, jfloat x, jfloat y, jfloat radius, SkPath::Direction dir) { + static void addCircle(JNIEnv* env, jobject clazz, jlong objHandle, jfloat x, jfloat y, jfloat radius, jint dirHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); SkScalar x_ = SkFloatToScalar(x); SkScalar y_ = SkFloatToScalar(y); SkScalar radius_ = SkFloatToScalar(radius); obj->addCircle(x_, y_, radius_, dir); } - static void addArc(JNIEnv* env, jobject clazz, SkPath* obj, jobject oval, jfloat startAngle, jfloat sweepAngle) { + static void addArc(JNIEnv* env, jobject clazz, jlong objHandle, jobject oval, jfloat startAngle, jfloat sweepAngle) { SkRect oval_; + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); GraphicsJNI::jrectf_to_rect(env, oval, &oval_); SkScalar startAngle_ = SkFloatToScalar(startAngle); SkScalar sweepAngle_ = SkFloatToScalar(sweepAngle); obj->addArc(oval_, startAngle_, sweepAngle_); } - static void addRoundRectXY(JNIEnv* env, jobject clazz, SkPath* obj, jobject rect, - jfloat rx, jfloat ry, SkPath::Direction dir) { + static void addRoundRectXY(JNIEnv* env, jobject clazz, jlong objHandle, jobject rect, + jfloat rx, jfloat ry, jint dirHandle) { SkRect rect_; + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); GraphicsJNI::jrectf_to_rect(env, rect, &rect_); SkScalar rx_ = SkFloatToScalar(rx); SkScalar ry_ = SkFloatToScalar(ry); obj->addRoundRect(rect_, rx_, ry_, dir); } - static void addRoundRect8(JNIEnv* env, jobject, SkPath* obj, jobject rect, - jfloatArray array, SkPath::Direction dir) { + static void addRoundRect8(JNIEnv* env, jobject, jlong objHandle, jobject rect, + jfloatArray array, jint dirHandle) { SkRect rect_; + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkPath::Direction dir = static_cast<SkPath::Direction>(dirHandle); GraphicsJNI::jrectf_to_rect(env, rect, &rect_); AutoJavaFloatArray afa(env, array, 8); const float* src = afa.ptr(); @@ -222,90 +258,110 @@ public: obj->addRoundRect(rect_, dst, dir); } - static void addPath__PathFF(JNIEnv* env, jobject clazz, SkPath* obj, SkPath* src, jfloat dx, jfloat dy) { + static void addPath__PathFF(JNIEnv* env, jobject clazz, jlong objHandle, jlong srcHandle, jfloat dx, jfloat dy) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkPath* src = reinterpret_cast<SkPath*>(srcHandle); SkScalar dx_ = SkFloatToScalar(dx); SkScalar dy_ = SkFloatToScalar(dy); obj->addPath(*src, dx_, dy_); } - static void addPath__Path(JNIEnv* env, jobject clazz, SkPath* obj, SkPath* src) { + static void addPath__Path(JNIEnv* env, jobject clazz, jlong objHandle, jlong srcHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkPath* src = reinterpret_cast<SkPath*>(srcHandle); obj->addPath(*src); } - static void addPath__PathMatrix(JNIEnv* env, jobject clazz, SkPath* obj, SkPath* src, SkMatrix* matrix) { + static void addPath__PathMatrix(JNIEnv* env, jobject clazz, jlong objHandle, jlong srcHandle, jlong matrixHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkPath* src = reinterpret_cast<SkPath*>(srcHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); obj->addPath(*src, *matrix); } - static void offset__FFPath(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx, jfloat dy, SkPath* dst) { + static void offset__FFPath(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy, jlong dstHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkPath* dst = reinterpret_cast<SkPath*>(dstHandle); SkScalar dx_ = SkFloatToScalar(dx); SkScalar dy_ = SkFloatToScalar(dy); obj->offset(dx_, dy_, dst); } - static void offset__FF(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx, jfloat dy) { + static void offset__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); SkScalar dx_ = SkFloatToScalar(dx); SkScalar dy_ = SkFloatToScalar(dy); obj->offset(dx_, dy_); } - static void setLastPoint(JNIEnv* env, jobject clazz, SkPath* obj, jfloat dx, jfloat dy) { + static void setLastPoint(JNIEnv* env, jobject clazz, jlong objHandle, jfloat dx, jfloat dy) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); SkScalar dx_ = SkFloatToScalar(dx); SkScalar dy_ = SkFloatToScalar(dy); obj->setLastPt(dx_, dy_); } - static void transform__MatrixPath(JNIEnv* env, jobject clazz, SkPath* obj, SkMatrix* matrix, SkPath* dst) { + static void transform__MatrixPath(JNIEnv* env, jobject clazz, jlong objHandle, jlong matrixHandle, jlong dstHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + SkPath* dst = reinterpret_cast<SkPath*>(dstHandle); obj->transform(*matrix, dst); } - static void transform__Matrix(JNIEnv* env, jobject clazz, SkPath* obj, SkMatrix* matrix) { + static void transform__Matrix(JNIEnv* env, jobject clazz, jlong objHandle, jlong matrixHandle) { + SkPath* obj = reinterpret_cast<SkPath*>(objHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); obj->transform(*matrix); } - static jboolean op(JNIEnv* env, jobject clazz, SkPath* p1, SkPath* p2, SkPathOp op, SkPath* r) { - return Op(*p1, *p2, op, r); + static jboolean op(JNIEnv* env, jobject clazz, jlong p1Handle, jlong p2Handle, jint opHandle, jlong rHandle) { + SkPath* p1 = reinterpret_cast<SkPath*>(p1Handle); + SkPath* p2 = reinterpret_cast<SkPath*>(p2Handle); + SkPathOp op = static_cast<SkPathOp>(opHandle); + SkPath* r = reinterpret_cast<SkPath*>(rHandle); + return Op(*p1, *p2, op, r); } }; static JNINativeMethod methods[] = { - {"finalizer", "(I)V", (void*) SkPathGlue::finalizer}, - {"init1","()I", (void*) SkPathGlue::init1}, - {"init2","(I)I", (void*) SkPathGlue::init2}, - {"native_reset","(I)V", (void*) SkPathGlue::reset}, - {"native_rewind","(I)V", (void*) SkPathGlue::rewind}, - {"native_set","(II)V", (void*) SkPathGlue::assign}, - {"native_getFillType","(I)I", (void*) SkPathGlue::getFillType}, - {"native_setFillType","(II)V", (void*) SkPathGlue::setFillType}, - {"native_isEmpty","(I)Z", (void*) SkPathGlue::isEmpty}, - {"native_isRect","(ILandroid/graphics/RectF;)Z", (void*) SkPathGlue::isRect}, - {"native_computeBounds","(ILandroid/graphics/RectF;)V", (void*) SkPathGlue::computeBounds}, - {"native_incReserve","(II)V", (void*) SkPathGlue::incReserve}, - {"native_moveTo","(IFF)V", (void*) SkPathGlue::moveTo__FF}, - {"native_rMoveTo","(IFF)V", (void*) SkPathGlue::rMoveTo}, - {"native_lineTo","(IFF)V", (void*) SkPathGlue::lineTo__FF}, - {"native_rLineTo","(IFF)V", (void*) SkPathGlue::rLineTo}, - {"native_quadTo","(IFFFF)V", (void*) SkPathGlue::quadTo__FFFF}, - {"native_rQuadTo","(IFFFF)V", (void*) SkPathGlue::rQuadTo}, - {"native_cubicTo","(IFFFFFF)V", (void*) SkPathGlue::cubicTo__FFFFFF}, - {"native_rCubicTo","(IFFFFFF)V", (void*) SkPathGlue::rCubicTo}, - {"native_arcTo","(ILandroid/graphics/RectF;FFZ)V", (void*) SkPathGlue::arcTo}, - {"native_close","(I)V", (void*) SkPathGlue::close}, - {"native_addRect","(ILandroid/graphics/RectF;I)V", (void*) SkPathGlue::addRect__RectFI}, - {"native_addRect","(IFFFFI)V", (void*) SkPathGlue::addRect__FFFFI}, - {"native_addOval","(ILandroid/graphics/RectF;I)V", (void*) SkPathGlue::addOval}, - {"native_addCircle","(IFFFI)V", (void*) SkPathGlue::addCircle}, - {"native_addArc","(ILandroid/graphics/RectF;FF)V", (void*) SkPathGlue::addArc}, - {"native_addRoundRect","(ILandroid/graphics/RectF;FFI)V", (void*) SkPathGlue::addRoundRectXY}, - {"native_addRoundRect","(ILandroid/graphics/RectF;[FI)V", (void*) SkPathGlue::addRoundRect8}, - {"native_addPath","(IIFF)V", (void*) SkPathGlue::addPath__PathFF}, - {"native_addPath","(II)V", (void*) SkPathGlue::addPath__Path}, - {"native_addPath","(III)V", (void*) SkPathGlue::addPath__PathMatrix}, - {"native_offset","(IFFI)V", (void*) SkPathGlue::offset__FFPath}, - {"native_offset","(IFF)V", (void*) SkPathGlue::offset__FF}, - {"native_setLastPoint","(IFF)V", (void*) SkPathGlue::setLastPoint}, - {"native_transform","(III)V", (void*) SkPathGlue::transform__MatrixPath}, - {"native_transform","(II)V", (void*) SkPathGlue::transform__Matrix}, - {"native_op","(IIII)Z", (void*) SkPathGlue::op} + {"finalizer", "(J)V", (void*) SkPathGlue::finalizer}, + {"init1","()J", (void*) SkPathGlue::init1}, + {"init2","(J)J", (void*) SkPathGlue::init2}, + {"native_reset","(J)V", (void*) SkPathGlue::reset}, + {"native_rewind","(J)V", (void*) SkPathGlue::rewind}, + {"native_set","(JJ)V", (void*) SkPathGlue::assign}, + {"native_getFillType","(J)I", (void*) SkPathGlue::getFillType}, + {"native_setFillType","(JI)V", (void*) SkPathGlue::setFillType}, + {"native_isEmpty","(J)Z", (void*) SkPathGlue::isEmpty}, + {"native_isRect","(JLandroid/graphics/RectF;)Z", (void*) SkPathGlue::isRect}, + {"native_computeBounds","(JLandroid/graphics/RectF;)V", (void*) SkPathGlue::computeBounds}, + {"native_incReserve","(JI)V", (void*) SkPathGlue::incReserve}, + {"native_moveTo","(JFF)V", (void*) SkPathGlue::moveTo__FF}, + {"native_rMoveTo","(JFF)V", (void*) SkPathGlue::rMoveTo}, + {"native_lineTo","(JFF)V", (void*) SkPathGlue::lineTo__FF}, + {"native_rLineTo","(JFF)V", (void*) SkPathGlue::rLineTo}, + {"native_quadTo","(JFFFF)V", (void*) SkPathGlue::quadTo__FFFF}, + {"native_rQuadTo","(JFFFF)V", (void*) SkPathGlue::rQuadTo}, + {"native_cubicTo","(JFFFFFF)V", (void*) SkPathGlue::cubicTo__FFFFFF}, + {"native_rCubicTo","(JFFFFFF)V", (void*) SkPathGlue::rCubicTo}, + {"native_arcTo","(JLandroid/graphics/RectF;FFZ)V", (void*) SkPathGlue::arcTo}, + {"native_close","(J)V", (void*) SkPathGlue::close}, + {"native_addRect","(JLandroid/graphics/RectF;I)V", (void*) SkPathGlue::addRect__RectFI}, + {"native_addRect","(JFFFFI)V", (void*) SkPathGlue::addRect__FFFFI}, + {"native_addOval","(JLandroid/graphics/RectF;I)V", (void*) SkPathGlue::addOval}, + {"native_addCircle","(JFFFI)V", (void*) SkPathGlue::addCircle}, + {"native_addArc","(JLandroid/graphics/RectF;FF)V", (void*) SkPathGlue::addArc}, + {"native_addRoundRect","(JLandroid/graphics/RectF;FFI)V", (void*) SkPathGlue::addRoundRectXY}, + {"native_addRoundRect","(JLandroid/graphics/RectF;[FI)V", (void*) SkPathGlue::addRoundRect8}, + {"native_addPath","(JJFF)V", (void*) SkPathGlue::addPath__PathFF}, + {"native_addPath","(JJ)V", (void*) SkPathGlue::addPath__Path}, + {"native_addPath","(JJJ)V", (void*) SkPathGlue::addPath__PathMatrix}, + {"native_offset","(JFFJ)V", (void*) SkPathGlue::offset__FFPath}, + {"native_offset","(JFF)V", (void*) SkPathGlue::offset__FF}, + {"native_setLastPoint","(JFF)V", (void*) SkPathGlue::setLastPoint}, + {"native_transform","(JJJ)V", (void*) SkPathGlue::transform__MatrixPath}, + {"native_transform","(JJ)V", (void*) SkPathGlue::transform__Matrix}, + {"native_op","(JJIJ)Z", (void*) SkPathGlue::op} }; int register_android_graphics_Path(JNIEnv* env) { diff --git a/core/jni/android/graphics/PathEffect.cpp b/core/jni/android/graphics/PathEffect.cpp index 0503614..2803758 100644 --- a/core/jni/android/graphics/PathEffect.cpp +++ b/core/jni/android/graphics/PathEffect.cpp @@ -11,22 +11,29 @@ class SkPathEffectGlue { public: - static void destructor(JNIEnv* env, jobject, SkPathEffect* effect) { + static void destructor(JNIEnv* env, jobject, jlong effectHandle) { + SkPathEffect* effect = reinterpret_cast<SkPathEffect*>(effectHandle); SkSafeUnref(effect); } - static SkPathEffect* Compose_constructor(JNIEnv* env, jobject, - SkPathEffect* outer, SkPathEffect* inner) { - return new SkComposePathEffect(outer, inner); + static jlong Compose_constructor(JNIEnv* env, jobject, + jlong outerHandle, jlong innerHandle) { + SkPathEffect* outer = reinterpret_cast<SkPathEffect*>(outerHandle); + SkPathEffect* inner = reinterpret_cast<SkPathEffect*>(innerHandle); + SkPathEffect* effect = new SkComposePathEffect(outer, inner); + return reinterpret_cast<jlong>(effect); } - static SkPathEffect* Sum_constructor(JNIEnv* env, jobject, - SkPathEffect* first, SkPathEffect* second) { - return new SkSumPathEffect(first, second); + static jlong Sum_constructor(JNIEnv* env, jobject, + jlong firstHandle, jlong secondHandle) { + SkPathEffect* first = reinterpret_cast<SkPathEffect*>(firstHandle); + SkPathEffect* second = reinterpret_cast<SkPathEffect*>(secondHandle); + SkPathEffect* effect = new SkSumPathEffect(first, second); + return reinterpret_cast<jlong>(effect); } - static SkPathEffect* Dash_constructor(JNIEnv* env, jobject, - jfloatArray intervalArray, float phase) { + static jlong Dash_constructor(JNIEnv* env, jobject, + jfloatArray intervalArray, jfloat phase) { AutoJavaFloatArray autoInterval(env, intervalArray); int count = autoInterval.length() & ~1; // even number float* values = autoInterval.ptr(); @@ -36,24 +43,29 @@ public: for (int i = 0; i < count; i++) { intervals[i] = SkFloatToScalar(values[i]); } - return new SkDashPathEffect(intervals, count, SkFloatToScalar(phase)); + SkPathEffect* effect = new SkDashPathEffect(intervals, count, SkFloatToScalar(phase)); + return reinterpret_cast<jlong>(effect); } - static SkPathEffect* OneD_constructor(JNIEnv* env, jobject, - const SkPath* shape, float advance, float phase, int style) { + static jlong OneD_constructor(JNIEnv* env, jobject, + jlong shapeHandle, jfloat advance, jfloat phase, jint style) { + const SkPath* shape = reinterpret_cast<SkPath*>(shapeHandle); SkASSERT(shape != NULL); - return new SkPath1DPathEffect(*shape, SkFloatToScalar(advance), + SkPathEffect* effect = new SkPath1DPathEffect(*shape, SkFloatToScalar(advance), SkFloatToScalar(phase), (SkPath1DPathEffect::Style)style); + return reinterpret_cast<jlong>(effect); } - static SkPathEffect* Corner_constructor(JNIEnv* env, jobject, float radius){ - return new SkCornerPathEffect(SkFloatToScalar(radius)); + static jlong Corner_constructor(JNIEnv* env, jobject, jfloat radius){ + SkPathEffect* effect = new SkCornerPathEffect(SkFloatToScalar(radius)); + return reinterpret_cast<jlong>(effect); } - static SkPathEffect* Discrete_constructor(JNIEnv* env, jobject, - float length, float deviation) { - return new SkDiscretePathEffect(SkFloatToScalar(length), + static jlong Discrete_constructor(JNIEnv* env, jobject, + jfloat length, jfloat deviation) { + SkPathEffect* effect = new SkDiscretePathEffect(SkFloatToScalar(length), SkFloatToScalar(deviation)); + return reinterpret_cast<jlong>(effect); } }; @@ -61,31 +73,31 @@ public: //////////////////////////////////////////////////////////////////////////////////////////////////////// static JNINativeMethod gPathEffectMethods[] = { - { "nativeDestructor", "(I)V", (void*)SkPathEffectGlue::destructor } + { "nativeDestructor", "(J)V", (void*)SkPathEffectGlue::destructor } }; static JNINativeMethod gComposePathEffectMethods[] = { - { "nativeCreate", "(II)I", (void*)SkPathEffectGlue::Compose_constructor } + { "nativeCreate", "(JJ)J", (void*)SkPathEffectGlue::Compose_constructor } }; static JNINativeMethod gSumPathEffectMethods[] = { - { "nativeCreate", "(II)I", (void*)SkPathEffectGlue::Sum_constructor } + { "nativeCreate", "(JJ)J", (void*)SkPathEffectGlue::Sum_constructor } }; static JNINativeMethod gDashPathEffectMethods[] = { - { "nativeCreate", "([FF)I", (void*)SkPathEffectGlue::Dash_constructor } + { "nativeCreate", "([FF)J", (void*)SkPathEffectGlue::Dash_constructor } }; static JNINativeMethod gPathDashPathEffectMethods[] = { - { "nativeCreate", "(IFFI)I", (void*)SkPathEffectGlue::OneD_constructor } + { "nativeCreate", "(JFFI)J", (void*)SkPathEffectGlue::OneD_constructor } }; static JNINativeMethod gCornerPathEffectMethods[] = { - { "nativeCreate", "(F)I", (void*)SkPathEffectGlue::Corner_constructor } + { "nativeCreate", "(F)J", (void*)SkPathEffectGlue::Corner_constructor } }; static JNINativeMethod gDiscretePathEffectMethods[] = { - { "nativeCreate", "(FF)I", (void*)SkPathEffectGlue::Discrete_constructor } + { "nativeCreate", "(FF)J", (void*)SkPathEffectGlue::Discrete_constructor } }; #include <android_runtime/AndroidRuntime.h> diff --git a/core/jni/android/graphics/PathMeasure.cpp b/core/jni/android/graphics/PathMeasure.cpp index 51a3f3a..8478a02 100644 --- a/core/jni/android/graphics/PathMeasure.cpp +++ b/core/jni/android/graphics/PathMeasure.cpp @@ -52,11 +52,24 @@ namespace android { class SkPathMeasureGlue { public: - static PathMeasurePair* create(JNIEnv* env, jobject clazz, const SkPath* path, jboolean forceClosed) { - return path ? new PathMeasurePair(*path, forceClosed) : new PathMeasurePair; + static jlong create(JNIEnv* env, jobject clazz, jlong pathHandle, + jboolean forceClosedHandle) { + const SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + bool forceClosed = (forceClosedHandle == JNI_TRUE); + PathMeasurePair* pair; + if(path) + pair = new PathMeasurePair(*path, forceClosed); + else + pair = new PathMeasurePair; + return reinterpret_cast<jlong>(pair); } - - static void setPath(JNIEnv* env, jobject clazz, PathMeasurePair* pair, const SkPath* path, jboolean forceClosed) { + + static void setPath(JNIEnv* env, jobject clazz, jlong pairHandle, + jlong pathHandle, jboolean forceClosedHandle) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + const SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + bool forceClosed = (forceClosedHandle == JNI_TRUE); + if (NULL == path) { pair->fPath.reset(); } else { @@ -64,11 +77,12 @@ public: } pair->fMeasure.setPath(&pair->fPath, forceClosed); } - - static jfloat getLength(JNIEnv* env, jobject clazz, PathMeasurePair* pair) { - return SkScalarToFloat(pair->fMeasure.getLength()); + + static jfloat getLength(JNIEnv* env, jobject clazz, jlong pairHandle) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + return static_cast<jfloat>(SkScalarToFloat(pair->fMeasure.getLength())); } - + static void convertTwoElemFloatArray(JNIEnv* env, jfloatArray array, const SkScalar src[2]) { AutoJavaFloatArray autoArray(env, array, 2); jfloat* ptr = autoArray.ptr(); @@ -76,13 +90,14 @@ public: ptr[1] = SkScalarToFloat(src[1]); } - static jboolean getPosTan(JNIEnv* env, jobject clazz, PathMeasurePair* pair, jfloat dist, jfloatArray pos, jfloatArray tan) { + static jboolean getPosTan(JNIEnv* env, jobject clazz, jlong pairHandle, jfloat dist, jfloatArray pos, jfloatArray tan) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); SkScalar tmpPos[2], tmpTan[2]; SkScalar* posPtr = pos ? tmpPos : NULL; SkScalar* tanPtr = tan ? tmpTan : NULL; if (!pair->fMeasure.getPosTan(SkFloatToScalar(dist), (SkPoint*)posPtr, (SkVector*)tanPtr)) { - return false; + return JNI_FALSE; } if (pos) { @@ -91,42 +106,53 @@ public: if (tan) { convertTwoElemFloatArray(env, tan, tmpTan); } - return true; + return JNI_TRUE; } - - static jboolean getMatrix(JNIEnv* env, jobject clazz, PathMeasurePair* pair, jfloat dist, - SkMatrix* matrix, int flags) { - return pair->fMeasure.getMatrix(SkFloatToScalar(dist), matrix, (SkPathMeasure::MatrixFlags)flags); + + static jboolean getMatrix(JNIEnv* env, jobject clazz, jlong pairHandle, jfloat dist, + jlong matrixHandle, jint flags) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + bool result = pair->fMeasure.getMatrix(SkFloatToScalar(dist), matrix, (SkPathMeasure::MatrixFlags)flags); + return result ? JNI_TRUE : JNI_FALSE; } - - static jboolean getSegment(JNIEnv* env, jobject clazz, PathMeasurePair* pair, jfloat startF, - jfloat stopF, SkPath* dst, jboolean startWithMoveTo) { - return pair->fMeasure.getSegment(SkFloatToScalar(startF), SkFloatToScalar(stopF), dst, startWithMoveTo); + + static jboolean getSegment(JNIEnv* env, jobject clazz, jlong pairHandle, jfloat startF, + jfloat stopF, jlong dstHandle, jboolean startWithMoveTo) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + SkPath* dst = reinterpret_cast<SkPath*>(dstHandle); + bool result = pair->fMeasure.getSegment(SkFloatToScalar(startF), SkFloatToScalar(stopF), dst, startWithMoveTo); + return result ? JNI_TRUE : JNI_FALSE; } - - static jboolean isClosed(JNIEnv* env, jobject clazz, PathMeasurePair* pair) { - return pair->fMeasure.isClosed(); + + static jboolean isClosed(JNIEnv* env, jobject clazz, jlong pairHandle) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + bool result = pair->fMeasure.isClosed(); + return result ? JNI_TRUE : JNI_FALSE; } - - static jboolean nextContour(JNIEnv* env, jobject clazz, PathMeasurePair* pair) { - return pair->fMeasure.nextContour(); + + static jboolean nextContour(JNIEnv* env, jobject clazz, jlong pairHandle) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + bool result = pair->fMeasure.nextContour(); + return result ? JNI_TRUE : JNI_FALSE; } - - static void destroy(JNIEnv* env, jobject clazz, PathMeasurePair* pair) { + + static void destroy(JNIEnv* env, jobject clazz, jlong pairHandle) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); delete pair; } }; static JNINativeMethod methods[] = { - {"native_create", "(IZ)I", (void*) SkPathMeasureGlue::create }, - {"native_setPath", "(IIZ)V", (void*) SkPathMeasureGlue::setPath }, - {"native_getLength", "(I)F", (void*) SkPathMeasureGlue::getLength }, - {"native_getPosTan", "(IF[F[F)Z", (void*) SkPathMeasureGlue::getPosTan }, - {"native_getMatrix", "(IFII)Z", (void*) SkPathMeasureGlue::getMatrix }, - {"native_getSegment", "(IFFIZ)Z", (void*) SkPathMeasureGlue::getSegment }, - {"native_isClosed", "(I)Z", (void*) SkPathMeasureGlue::isClosed }, - {"native_nextContour", "(I)Z", (void*) SkPathMeasureGlue::nextContour }, - {"native_destroy", "(I)V", (void*) SkPathMeasureGlue::destroy } + {"native_create", "(JZ)J", (void*) SkPathMeasureGlue::create }, + {"native_setPath", "(JJZ)V", (void*) SkPathMeasureGlue::setPath }, + {"native_getLength", "(J)F", (void*) SkPathMeasureGlue::getLength }, + {"native_getPosTan", "(JF[F[F)Z", (void*) SkPathMeasureGlue::getPosTan }, + {"native_getMatrix", "(JFJI)Z", (void*) SkPathMeasureGlue::getMatrix }, + {"native_getSegment", "(JFFJZ)Z", (void*) SkPathMeasureGlue::getSegment }, + {"native_isClosed", "(J)Z", (void*) SkPathMeasureGlue::isClosed }, + {"native_nextContour", "(J)Z", (void*) SkPathMeasureGlue::nextContour }, + {"native_destroy", "(J)V", (void*) SkPathMeasureGlue::destroy } }; int register_android_graphics_PathMeasure(JNIEnv* env) { diff --git a/core/jni/android/graphics/Picture.cpp b/core/jni/android/graphics/Picture.cpp index fcf22b8..bac8ef7 100644 --- a/core/jni/android/graphics/Picture.cpp +++ b/core/jni/android/graphics/Picture.cpp @@ -28,71 +28,80 @@ namespace android { class SkPictureGlue { public: - static SkPicture* newPicture(JNIEnv* env, jobject, const SkPicture* src) { + static jlong newPicture(JNIEnv* env, jobject, jlong srcHandle) { + const SkPicture* src = reinterpret_cast<SkPicture*>(srcHandle); if (src) { - return new SkPicture(*src); + return reinterpret_cast<jlong>(new SkPicture(*src)); } else { - return new SkPicture; + return reinterpret_cast<jlong>(new SkPicture); } } - - static SkPicture* deserialize(JNIEnv* env, jobject, jobject jstream, - jbyteArray jstorage) { + + static jlong deserialize(JNIEnv* env, jobject, jobject jstream, + jbyteArray jstorage) { SkPicture* picture = NULL; SkStream* strm = CreateJavaInputStreamAdaptor(env, jstream, jstorage); if (strm) { picture = SkPicture::CreateFromStream(strm); delete strm; } - return picture; + return reinterpret_cast<jlong>(picture); } - - static void killPicture(JNIEnv* env, jobject, SkPicture* picture) { + + static void killPicture(JNIEnv* env, jobject, jlong pictureHandle) { + SkPicture* picture = reinterpret_cast<SkPicture*>(pictureHandle); SkASSERT(picture); picture->unref(); } - - static void draw(JNIEnv* env, jobject, SkCanvas* canvas, - SkPicture* picture) { + + static void draw(JNIEnv* env, jobject, jlong canvasHandle, + jlong pictureHandle) { + SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle); + SkPicture* picture = reinterpret_cast<SkPicture*>(pictureHandle); SkASSERT(canvas); SkASSERT(picture); picture->draw(canvas); } - - static bool serialize(JNIEnv* env, jobject, SkPicture* picture, + + static jboolean serialize(JNIEnv* env, jobject, jlong pictureHandle, jobject jstream, jbyteArray jstorage) { + SkPicture* picture = reinterpret_cast<SkPicture*>(pictureHandle); SkWStream* strm = CreateJavaOutputStreamAdaptor(env, jstream, jstorage); if (NULL != strm) { picture->serialize(strm); delete strm; - return true; + return JNI_TRUE; } - return false; + return JNI_FALSE; } - - static int getWidth(JNIEnv* env, jobject jpic) { + + static jint getWidth(JNIEnv* env, jobject jpic) { NPE_CHECK_RETURN_ZERO(env, jpic); - return GraphicsJNI::getNativePicture(env, jpic)->width(); + int width = GraphicsJNI::getNativePicture(env, jpic)->width(); + return static_cast<jint>(width); } - - static int getHeight(JNIEnv* env, jobject jpic) { + + static jint getHeight(JNIEnv* env, jobject jpic) { NPE_CHECK_RETURN_ZERO(env, jpic); - return GraphicsJNI::getNativePicture(env, jpic)->height(); + int height = GraphicsJNI::getNativePicture(env, jpic)->height(); + return static_cast<jint>(height); } - - static SkCanvas* beginRecording(JNIEnv* env, jobject, SkPicture* pict, - int w, int h) { + + static jlong beginRecording(JNIEnv* env, jobject, jlong pictHandle, + jint w, jint h) { + SkPicture* pict = reinterpret_cast<SkPicture*>(pictHandle); // beginRecording does not ref its return value, it just returns it. SkCanvas* canvas = pict->beginRecording(w, h); // the java side will wrap this guy in a Canvas.java, which will call // unref in its finalizer, so we have to ref it here, so that both that // Canvas.java and our picture can both be owners canvas->ref(); - return canvas; + return reinterpret_cast<jlong>(canvas); } - - static void endRecording(JNIEnv* env, jobject, SkPicture* pict) { + + static void endRecording(JNIEnv* env, jobject, jlong pictHandle) { + SkPicture* pict = reinterpret_cast<SkPicture*>(pictHandle); pict->endRecording(); } }; @@ -100,30 +109,30 @@ public: static JNINativeMethod gPictureMethods[] = { {"getWidth", "()I", (void*) SkPictureGlue::getWidth}, {"getHeight", "()I", (void*) SkPictureGlue::getHeight}, - {"nativeConstructor", "(I)I", (void*) SkPictureGlue::newPicture}, - {"nativeCreateFromStream", "(Ljava/io/InputStream;[B)I", (void*)SkPictureGlue::deserialize}, - {"nativeBeginRecording", "(III)I", (void*) SkPictureGlue::beginRecording}, - {"nativeEndRecording", "(I)V", (void*) SkPictureGlue::endRecording}, - {"nativeDraw", "(II)V", (void*) SkPictureGlue::draw}, - {"nativeWriteToStream", "(ILjava/io/OutputStream;[B)Z", (void*)SkPictureGlue::serialize}, - {"nativeDestructor","(I)V", (void*) SkPictureGlue::killPicture} + {"nativeConstructor", "(J)J", (void*) SkPictureGlue::newPicture}, + {"nativeCreateFromStream", "(Ljava/io/InputStream;[B)J", (void*)SkPictureGlue::deserialize}, + {"nativeBeginRecording", "(JII)J", (void*) SkPictureGlue::beginRecording}, + {"nativeEndRecording", "(J)V", (void*) SkPictureGlue::endRecording}, + {"nativeDraw", "(JJ)V", (void*) SkPictureGlue::draw}, + {"nativeWriteToStream", "(JLjava/io/OutputStream;[B)Z", (void*)SkPictureGlue::serialize}, + {"nativeDestructor","(J)V", (void*) SkPictureGlue::killPicture} }; #include <android_runtime/AndroidRuntime.h> - + #define REG(env, name, array) \ result = android::AndroidRuntime::registerNativeMethods(env, name, array, \ SK_ARRAY_COUNT(array)); \ if (result < 0) return result - + int register_android_graphics_Picture(JNIEnv* env) { int result; - + REG(env, "android/graphics/Picture", gPictureMethods); - + return result; } - + } diff --git a/core/jni/android/graphics/PorterDuff.cpp b/core/jni/android/graphics/PorterDuff.cpp index 47de601..8a49eb5 100644 --- a/core/jni/android/graphics/PorterDuff.cpp +++ b/core/jni/android/graphics/PorterDuff.cpp @@ -31,15 +31,15 @@ namespace android { class SkPorterDuffGlue { public: - static SkXfermode* CreateXfermode(JNIEnv* env, jobject, - SkPorterDuff::Mode mode) { - return SkPorterDuff::CreateXfermode(mode); + static jlong CreateXfermode(JNIEnv* env, jobject, jint modeHandle) { + SkPorterDuff::Mode mode = static_cast<SkPorterDuff::Mode>(modeHandle); + return reinterpret_cast<jlong>(SkPorterDuff::CreateXfermode(mode)); } }; static JNINativeMethod methods[] = { - {"nativeCreateXfermode","(I)I", (void*) SkPorterDuffGlue::CreateXfermode}, + {"nativeCreateXfermode","(I)J", (void*) SkPorterDuffGlue::CreateXfermode}, }; int register_android_graphics_PorterDuff(JNIEnv* env) { diff --git a/core/jni/android/graphics/Rasterizer.cpp b/core/jni/android/graphics/Rasterizer.cpp index 4e1b36a..b6450d0 100644 --- a/core/jni/android/graphics/Rasterizer.cpp +++ b/core/jni/android/graphics/Rasterizer.cpp @@ -31,14 +31,15 @@ namespace android { class SkRasterizerGlue { public: - static void finalizer(JNIEnv* env, jobject clazz, SkRasterizer* obj) { + static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) { + SkRasterizer* obj = reinterpret_cast<SkRasterizer *>(objHandle); SkSafeUnref(obj); } }; static JNINativeMethod methods[] = { - {"finalizer", "(I)V", (void*) SkRasterizerGlue::finalizer} + {"finalizer", "(J)V", (void*) SkRasterizerGlue::finalizer} }; int register_android_graphics_Rasterizer(JNIEnv* env) { diff --git a/core/jni/android/graphics/Region.cpp b/core/jni/android/graphics/Region.cpp index ded2186..bcf1273 100644 --- a/core/jni/android/graphics/Region.cpp +++ b/core/jni/android/graphics/Region.cpp @@ -29,95 +29,131 @@ namespace android { static jfieldID gRegion_nativeInstanceFieldID; +static inline jboolean boolTojboolean(bool value) { + return value ? JNI_TRUE : JNI_FALSE; +} + static inline SkRegion* GetSkRegion(JNIEnv* env, jobject regionObject) { - SkRegion* rgn = (SkRegion*)env->GetIntField(regionObject, gRegion_nativeInstanceFieldID); - SkASSERT(rgn != NULL); - return rgn; + jlong regionHandle = env->GetLongField(regionObject, gRegion_nativeInstanceFieldID); + SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle); + SkASSERT(region != NULL); + return region; } -static SkRegion* Region_constructor(JNIEnv* env, jobject) { - return new SkRegion; +static jlong Region_constructor(JNIEnv* env, jobject) { + return reinterpret_cast<jlong>(new SkRegion); } -static void Region_destructor(JNIEnv* env, jobject, SkRegion* region) { +static void Region_destructor(JNIEnv* env, jobject, jlong regionHandle) { + SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle); SkASSERT(region); delete region; } -static void Region_setRegion(JNIEnv* env, jobject, SkRegion* dst, const SkRegion* src) { +static void Region_setRegion(JNIEnv* env, jobject, jlong dstHandle, jlong srcHandle) { + SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle); + const SkRegion* src = reinterpret_cast<SkRegion*>(srcHandle); SkASSERT(dst && src); *dst = *src; } -static jboolean Region_setRect(JNIEnv* env, jobject, SkRegion* dst, int left, int top, int right, int bottom) { - return dst->setRect(left, top, right, bottom); +static jboolean Region_setRect(JNIEnv* env, jobject, jlong dstHandle, jint left, jint top, jint right, jint bottom) { + SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle); + bool result = dst->setRect(left, top, right, bottom); + return boolTojboolean(result); } -static jboolean Region_setPath(JNIEnv* env, jobject, SkRegion* dst, - const SkPath* path, const SkRegion* clip) { +static jboolean Region_setPath(JNIEnv* env, jobject, jlong dstHandle, + jlong pathHandle, jlong clipHandle) { + SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle); + const SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + const SkRegion* clip = reinterpret_cast<SkRegion*>(clipHandle); SkASSERT(dst && path && clip); - return dst->setPath(*path, *clip); + bool result = dst->setPath(*path, *clip); + return boolTojboolean(result); + } -static jboolean Region_getBounds(JNIEnv* env, jobject, SkRegion* region, jobject rectBounds) { +static jboolean Region_getBounds(JNIEnv* env, jobject, jlong regionHandle, jobject rectBounds) { + SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle); GraphicsJNI::irect_to_jrect(region->getBounds(), env, rectBounds); - return !region->isEmpty(); + bool result = !region->isEmpty(); + return boolTojboolean(result); } -static jboolean Region_getBoundaryPath(JNIEnv* env, jobject, const SkRegion* region, SkPath* path) { - return region->getBoundaryPath(path); +static jboolean Region_getBoundaryPath(JNIEnv* env, jobject, jlong regionHandle, jlong pathHandle) { + const SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle); + SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + bool result = region->getBoundaryPath(path); + return boolTojboolean(result); } -static jboolean Region_op0(JNIEnv* env, jobject, SkRegion* dst, int left, int top, int right, int bottom, int op) { +static jboolean Region_op0(JNIEnv* env, jobject, jlong dstHandle, jint left, jint top, jint right, jint bottom, jint op) { + SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle); SkIRect ir; ir.set(left, top, right, bottom); - return dst->op(ir, (SkRegion::Op)op); + bool result = dst->op(ir, (SkRegion::Op)op); + return boolTojboolean(result); } -static jboolean Region_op1(JNIEnv* env, jobject, SkRegion* dst, jobject rectObject, const SkRegion* region, int op) { +static jboolean Region_op1(JNIEnv* env, jobject, jlong dstHandle, jobject rectObject, jlong regionHandle, jint op) { + SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle); + const SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle); SkIRect ir; GraphicsJNI::jrect_to_irect(env, rectObject, &ir); - return dst->op(ir, *region, (SkRegion::Op)op); + bool result = dst->op(ir, *region, (SkRegion::Op)op); + return boolTojboolean(result); } -static jboolean Region_op2(JNIEnv* env, jobject, SkRegion* dst, const SkRegion* region1, const SkRegion* region2, int op) { - return dst->op(*region1, *region2, (SkRegion::Op)op); +static jboolean Region_op2(JNIEnv* env, jobject, jlong dstHandle, jlong region1Handle, jlong region2Handle, jint op) { + SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle); + const SkRegion* region1 = reinterpret_cast<SkRegion*>(region1Handle); + const SkRegion* region2 = reinterpret_cast<SkRegion*>(region2Handle); + bool result = dst->op(*region1, *region2, (SkRegion::Op)op); + return boolTojboolean(result); } //////////////////////////////////// These are methods, not static static jboolean Region_isEmpty(JNIEnv* env, jobject region) { - return GetSkRegion(env, region)->isEmpty(); + bool result = GetSkRegion(env, region)->isEmpty(); + return boolTojboolean(result); } static jboolean Region_isRect(JNIEnv* env, jobject region) { - return GetSkRegion(env, region)->isRect(); + bool result = GetSkRegion(env, region)->isRect(); + return boolTojboolean(result); } static jboolean Region_isComplex(JNIEnv* env, jobject region) { - return GetSkRegion(env, region)->isComplex(); + bool result = GetSkRegion(env, region)->isComplex(); + return boolTojboolean(result); } -static jboolean Region_contains(JNIEnv* env, jobject region, int x, int y) { - return GetSkRegion(env, region)->contains(x, y); +static jboolean Region_contains(JNIEnv* env, jobject region, jint x, jint y) { + bool result = GetSkRegion(env, region)->contains(x, y); + return boolTojboolean(result); } -static jboolean Region_quickContains(JNIEnv* env, jobject region, int left, int top, int right, int bottom) { - return GetSkRegion(env, region)->quickContains(left, top, right, bottom); +static jboolean Region_quickContains(JNIEnv* env, jobject region, jint left, jint top, jint right, jint bottom) { + bool result = GetSkRegion(env, region)->quickContains(left, top, right, bottom); + return boolTojboolean(result); } -static jboolean Region_quickRejectIIII(JNIEnv* env, jobject region, int left, int top, int right, int bottom) { +static jboolean Region_quickRejectIIII(JNIEnv* env, jobject region, jint left, jint top, jint right, jint bottom) { SkIRect ir; ir.set(left, top, right, bottom); - return GetSkRegion(env, region)->quickReject(ir); + bool result = GetSkRegion(env, region)->quickReject(ir); + return boolTojboolean(result); } static jboolean Region_quickRejectRgn(JNIEnv* env, jobject region, jobject other) { - return GetSkRegion(env, region)->quickReject(*GetSkRegion(env, other)); + bool result = GetSkRegion(env, region)->quickReject(*GetSkRegion(env, other)); + return boolTojboolean(result); } -static void Region_translate(JNIEnv* env, jobject region, int x, int y, jobject dst) { +static void Region_translate(JNIEnv* env, jobject region, jint x, jint y, jobject dst) { SkRegion* rgn = GetSkRegion(env, region); if (dst) rgn->translate(x, y, GetSkRegion(env, dst)); @@ -155,7 +191,8 @@ static void Region_scale(JNIEnv* env, jobject region, jfloat scale, jobject dst) scale_rgn(rgn, *rgn, scale); } -static jstring Region_toString(JNIEnv* env, jobject clazz, SkRegion* region) { +static jstring Region_toString(JNIEnv* env, jobject clazz, jlong regionHandle) { + SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle); char* str = region->toString(); if (str == NULL) { return NULL; @@ -167,7 +204,7 @@ static jstring Region_toString(JNIEnv* env, jobject clazz, SkRegion* region) { //////////////////////////////////////////////////////////////////////////////////////////////////////////// -static SkRegion* Region_createFromParcel(JNIEnv* env, jobject clazz, jobject parcel) +static jlong Region_createFromParcel(JNIEnv* env, jobject clazz, jobject parcel) { if (parcel == NULL) { return NULL; @@ -179,13 +216,14 @@ static SkRegion* Region_createFromParcel(JNIEnv* env, jobject clazz, jobject par size_t size = p->readInt32(); region->readFromMemory(p->readInplace(size)); - return region; + return reinterpret_cast<jlong>(region); } -static jboolean Region_writeToParcel(JNIEnv* env, jobject clazz, const SkRegion* region, jobject parcel) +static jboolean Region_writeToParcel(JNIEnv* env, jobject clazz, jlong regionHandle, jobject parcel) { + const SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle); if (parcel == NULL) { - return false; + return JNI_FALSE; } android::Parcel* p = android::parcelForJavaObject(env, parcel); @@ -194,14 +232,16 @@ static jboolean Region_writeToParcel(JNIEnv* env, jobject clazz, const SkRegion* p->writeInt32(size); region->writeToMemory(p->writeInplace(size)); - return true; + return JNI_TRUE; } //////////////////////////////////////////////////////////////////////////////////////////////////////////// -static jboolean Region_equals(JNIEnv* env, jobject clazz, const SkRegion *r1, const SkRegion* r2) +static jboolean Region_equals(JNIEnv* env, jobject clazz, jlong r1Handle, jlong r2Handle) { - return (jboolean) (*r1 == *r2); + const SkRegion *r1 = reinterpret_cast<SkRegion*>(r1Handle); + const SkRegion *r2 = reinterpret_cast<SkRegion*>(r2Handle); + return boolTojboolean(*r1 == *r2); } //////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -217,20 +257,23 @@ struct RgnIterPair { } }; -static RgnIterPair* RegionIter_constructor(JNIEnv* env, jobject, const SkRegion* region) +static jlong RegionIter_constructor(JNIEnv* env, jobject, jlong regionHandle) { + const SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle); SkASSERT(region); - return new RgnIterPair(*region); + return reinterpret_cast<jlong>(new RgnIterPair(*region)); } -static void RegionIter_destructor(JNIEnv* env, jobject, RgnIterPair* pair) +static void RegionIter_destructor(JNIEnv* env, jobject, jlong pairHandle) { + RgnIterPair* pair = reinterpret_cast<RgnIterPair*>(pairHandle); SkASSERT(pair); delete pair; } -static jboolean RegionIter_next(JNIEnv* env, jobject, RgnIterPair* pair, jobject rectObject) +static jboolean RegionIter_next(JNIEnv* env, jobject, jlong pairHandle, jobject rectObject) { + RgnIterPair* pair = reinterpret_cast<RgnIterPair*>(pairHandle); // the caller has checked that rectObject is not nul SkASSERT(pair); SkASSERT(rectObject); @@ -238,31 +281,31 @@ static jboolean RegionIter_next(JNIEnv* env, jobject, RgnIterPair* pair, jobject if (!pair->fIter.done()) { GraphicsJNI::irect_to_jrect(pair->fIter.rect(), env, rectObject); pair->fIter.next(); - return true; + return JNI_TRUE; } - return false; + return JNI_FALSE; } //////////////////////////////////////////////////////////////////////////////////////////////////////////// static JNINativeMethod gRegionIterMethods[] = { - { "nativeConstructor", "(I)I", (void*)RegionIter_constructor }, - { "nativeDestructor", "(I)V", (void*)RegionIter_destructor }, - { "nativeNext", "(ILandroid/graphics/Rect;)Z", (void*)RegionIter_next } + { "nativeConstructor", "(J)J", (void*)RegionIter_constructor }, + { "nativeDestructor", "(J)V", (void*)RegionIter_destructor }, + { "nativeNext", "(JLandroid/graphics/Rect;)Z", (void*)RegionIter_next } }; static JNINativeMethod gRegionMethods[] = { // these are static methods - { "nativeConstructor", "()I", (void*)Region_constructor }, - { "nativeDestructor", "(I)V", (void*)Region_destructor }, - { "nativeSetRegion", "(II)V", (void*)Region_setRegion }, - { "nativeSetRect", "(IIIII)Z", (void*)Region_setRect }, - { "nativeSetPath", "(III)Z", (void*)Region_setPath }, - { "nativeGetBounds", "(ILandroid/graphics/Rect;)Z", (void*)Region_getBounds }, - { "nativeGetBoundaryPath", "(II)Z", (void*)Region_getBoundaryPath }, - { "nativeOp", "(IIIIII)Z", (void*)Region_op0 }, - { "nativeOp", "(ILandroid/graphics/Rect;II)Z", (void*)Region_op1 }, - { "nativeOp", "(IIII)Z", (void*)Region_op2 }, + { "nativeConstructor", "()J", (void*)Region_constructor }, + { "nativeDestructor", "(J)V", (void*)Region_destructor }, + { "nativeSetRegion", "(JJ)V", (void*)Region_setRegion }, + { "nativeSetRect", "(JIIII)Z", (void*)Region_setRect }, + { "nativeSetPath", "(JJJ)Z", (void*)Region_setPath }, + { "nativeGetBounds", "(JLandroid/graphics/Rect;)Z", (void*)Region_getBounds }, + { "nativeGetBoundaryPath", "(JJ)Z", (void*)Region_getBoundaryPath }, + { "nativeOp", "(JIIIII)Z", (void*)Region_op0 }, + { "nativeOp", "(JLandroid/graphics/Rect;JI)Z", (void*)Region_op1 }, + { "nativeOp", "(JJJI)Z", (void*)Region_op2 }, // these are methods that take the java region object { "isEmpty", "()Z", (void*)Region_isEmpty }, { "isRect", "()Z", (void*)Region_isRect }, @@ -273,11 +316,11 @@ static JNINativeMethod gRegionMethods[] = { { "quickReject", "(Landroid/graphics/Region;)Z", (void*)Region_quickRejectRgn }, { "scale", "(FLandroid/graphics/Region;)V", (void*)Region_scale }, { "translate", "(IILandroid/graphics/Region;)V", (void*)Region_translate }, - { "nativeToString", "(I)Ljava/lang/String;", (void*)Region_toString }, + { "nativeToString", "(J)Ljava/lang/String;", (void*)Region_toString }, // parceling methods - { "nativeCreateFromParcel", "(Landroid/os/Parcel;)I", (void*)Region_createFromParcel }, - { "nativeWriteToParcel", "(ILandroid/os/Parcel;)Z", (void*)Region_writeToParcel }, - { "nativeEquals", "(II)Z", (void*)Region_equals }, + { "nativeCreateFromParcel", "(Landroid/os/Parcel;)J", (void*)Region_createFromParcel }, + { "nativeWriteToParcel", "(JLandroid/os/Parcel;)Z", (void*)Region_writeToParcel }, + { "nativeEquals", "(JJ)Z", (void*)Region_equals }, }; int register_android_graphics_Region(JNIEnv* env) @@ -285,7 +328,7 @@ int register_android_graphics_Region(JNIEnv* env) jclass clazz = env->FindClass("android/graphics/Region"); SkASSERT(clazz); - gRegion_nativeInstanceFieldID = env->GetFieldID(clazz, "mNativeRegion", "I"); + gRegion_nativeInstanceFieldID = env->GetFieldID(clazz, "mNativeRegion", "J"); SkASSERT(gRegion_nativeInstanceFieldID); int result = android::AndroidRuntime::registerNativeMethods(env, "android/graphics/Region", diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp index 6323ab3..3047440 100644 --- a/core/jni/android/graphics/Shader.cpp +++ b/core/jni/android/graphics/Shader.cpp @@ -24,7 +24,7 @@ static void ThrowIAE_IfNull(JNIEnv* env, void* ptr) { } } -static void Color_RGBToHSV(JNIEnv* env, jobject, int red, int green, int blue, jfloatArray hsvArray) +static void Color_RGBToHSV(JNIEnv* env, jobject, jint red, jint green, jint blue, jfloatArray hsvArray) { SkScalar hsv[3]; SkRGBToHSV(red, green, blue, hsv); @@ -36,7 +36,7 @@ static void Color_RGBToHSV(JNIEnv* env, jobject, int red, int green, int blue, j } } -static int Color_HSVToColor(JNIEnv* env, jobject, int alpha, jfloatArray hsvArray) +static jint Color_HSVToColor(JNIEnv* env, jobject, jint alpha, jfloatArray hsvArray) { AutoJavaFloatArray autoHSV(env, hsvArray, 3); float* values = autoHSV.ptr();; @@ -46,13 +46,15 @@ static int Color_HSVToColor(JNIEnv* env, jobject, int alpha, jfloatArray hsvArra hsv[i] = SkFloatToScalar(values[i]); } - return SkHSVToColor(alpha, hsv); + return static_cast<jint>(SkHSVToColor(alpha, hsv)); } /////////////////////////////////////////////////////////////////////////////////////////////// -static void Shader_destructor(JNIEnv* env, jobject o, SkShader* shader, SkiaShader* skiaShader) +static void Shader_destructor(JNIEnv* env, jobject o, jlong shaderHandle, jlong skiaShaderHandle) { + SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle); + SkiaShader* skiaShader = reinterpret_cast<SkiaShader*>(skiaShaderHandle); SkSafeUnref(shader); // skiaShader == NULL when not !USE_OPENGL_RENDERER, so no need to delete it outside the ifdef #ifdef USE_OPENGL_RENDERER @@ -64,9 +66,12 @@ static void Shader_destructor(JNIEnv* env, jobject o, SkShader* shader, SkiaShad #endif } -static void Shader_setLocalMatrix(JNIEnv* env, jobject o, SkShader* shader, SkiaShader* skiaShader, - const SkMatrix* matrix) +static void Shader_setLocalMatrix(JNIEnv* env, jobject o, jlong shaderHandle, + jlong skiaShaderHandle, jlong matrixHandle) { + SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle); + SkiaShader* skiaShader = reinterpret_cast<SkiaShader*>(skiaShaderHandle); + const SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); if (shader) { if (NULL == matrix) { shader->resetLocalMatrix(); @@ -82,24 +87,27 @@ static void Shader_setLocalMatrix(JNIEnv* env, jobject o, SkShader* shader, Skia /////////////////////////////////////////////////////////////////////////////////////////////// -static SkShader* BitmapShader_constructor(JNIEnv* env, jobject o, const SkBitmap* bitmap, - int tileModeX, int tileModeY) +static jlong BitmapShader_constructor(JNIEnv* env, jobject o, jlong bitmapHandle, + jint tileModeX, jint tileModeY) { + const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); SkShader* s = SkShader::CreateBitmapShader(*bitmap, (SkShader::TileMode)tileModeX, (SkShader::TileMode)tileModeY); ThrowIAE_IfNull(env, s); - return s; + return reinterpret_cast<jlong>(s); } -static SkiaShader* BitmapShader_postConstructor(JNIEnv* env, jobject o, SkShader* shader, - SkBitmap* bitmap, int tileModeX, int tileModeY) { +static jlong BitmapShader_postConstructor(JNIEnv* env, jobject o, jlong shaderHandle, + jlong bitmapHandle, jint tileModeX, jint tileModeY) { + SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle); + SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); #ifdef USE_OPENGL_RENDERER SkiaShader* skiaShader = new SkiaBitmapShader(bitmap, shader, static_cast<SkShader::TileMode>(tileModeX), static_cast<SkShader::TileMode>(tileModeY), NULL, (shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0); - return skiaShader; + return reinterpret_cast<jlong>(skiaShader); #else return NULL; #endif @@ -107,9 +115,9 @@ static SkiaShader* BitmapShader_postConstructor(JNIEnv* env, jobject o, SkShader /////////////////////////////////////////////////////////////////////////////////////////////// -static SkShader* LinearGradient_create1(JNIEnv* env, jobject o, - float x0, float y0, float x1, float y1, - jintArray colorArray, jfloatArray posArray, int tileMode) +static jlong LinearGradient_create1(JNIEnv* env, jobject o, + jfloat x0, jfloat y0, jfloat x1, jfloat y1, + jintArray colorArray, jfloatArray posArray, jint tileMode) { SkPoint pts[2]; pts[0].set(SkFloatToScalar(x0), SkFloatToScalar(y0)); @@ -137,13 +145,14 @@ static SkShader* LinearGradient_create1(JNIEnv* env, jobject o, env->ReleaseIntArrayElements(colorArray, const_cast<jint*>(colorValues), JNI_ABORT); ThrowIAE_IfNull(env, shader); - return shader; + return reinterpret_cast<jlong>(shader); } -static SkiaShader* LinearGradient_postCreate1(JNIEnv* env, jobject o, SkShader* shader, - float x0, float y0, float x1, float y1, jintArray colorArray, - jfloatArray posArray, int tileMode) { +static jlong LinearGradient_postCreate1(JNIEnv* env, jobject o, jlong shaderHandle, + jfloat x0, jfloat y0, jfloat x1, jfloat y1, jintArray colorArray, + jfloatArray posArray, jint tileMode) { #ifdef USE_OPENGL_RENDERER + SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle); size_t count = env->GetArrayLength(colorArray); const jint* colorValues = env->GetIntArrayElements(colorArray, NULL); @@ -206,15 +215,16 @@ static SkiaShader* LinearGradient_postCreate1(JNIEnv* env, jobject o, SkShader* (shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0); env->ReleaseIntArrayElements(colorArray, const_cast<jint*>(colorValues), JNI_ABORT); - return skiaShader; + return reinterpret_cast<jlong>(skiaShader); #else return NULL; #endif } -static SkiaShader* LinearGradient_postCreate2(JNIEnv* env, jobject o, SkShader* shader, - float x0, float y0, float x1, float y1, int color0, int color1, int tileMode) { +static jlong LinearGradient_postCreate2(JNIEnv* env, jobject o, jlong shaderHandle, + jfloat x0, jfloat y0, jfloat x1, jfloat y1, jint color0, jint color1, jint tileMode) { #ifdef USE_OPENGL_RENDERER + SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle); float* storedBounds = new float[4]; storedBounds[0] = x0; storedBounds[1] = y0; storedBounds[2] = x1; storedBounds[3] = y1; @@ -231,15 +241,15 @@ static SkiaShader* LinearGradient_postCreate2(JNIEnv* env, jobject o, SkShader* storedPositions, 2, shader, static_cast<SkShader::TileMode>(tileMode), NULL, (shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0); - return skiaShader; + return reinterpret_cast<jlong>(skiaShader); #else return NULL; #endif } -static SkShader* LinearGradient_create2(JNIEnv* env, jobject o, - float x0, float y0, float x1, float y1, - int color0, int color1, int tileMode) +static jlong LinearGradient_create2(JNIEnv* env, jobject o, + jfloat x0, jfloat y0, jfloat x1, jfloat y1, + jint color0, jint color1, jint tileMode) { SkPoint pts[2]; pts[0].set(SkFloatToScalar(x0), SkFloatToScalar(y0)); @@ -252,13 +262,13 @@ static SkShader* LinearGradient_create2(JNIEnv* env, jobject o, SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, (SkShader::TileMode)tileMode); ThrowIAE_IfNull(env, s); - return s; + return reinterpret_cast<jlong>(s); } /////////////////////////////////////////////////////////////////////////////////////////////// -static SkShader* RadialGradient_create1(JNIEnv* env, jobject, float x, float y, float radius, - jintArray colorArray, jfloatArray posArray, int tileMode) { +static jlong RadialGradient_create1(JNIEnv* env, jobject, jfloat x, jfloat y, jfloat radius, + jintArray colorArray, jfloatArray posArray, jint tileMode) { SkPoint center; center.set(SkFloatToScalar(x), SkFloatToScalar(y)); @@ -285,11 +295,11 @@ static SkShader* RadialGradient_create1(JNIEnv* env, jobject, float x, float y, JNI_ABORT); ThrowIAE_IfNull(env, shader); - return shader; + return reinterpret_cast<jlong>(shader); } -static SkShader* RadialGradient_create2(JNIEnv* env, jobject, float x, float y, float radius, - int color0, int color1, int tileMode) { +static jlong RadialGradient_create2(JNIEnv* env, jobject, jfloat x, jfloat y, jfloat radius, + jint color0, jint color1, jint tileMode) { SkPoint center; center.set(SkFloatToScalar(x), SkFloatToScalar(y)); @@ -300,12 +310,13 @@ static SkShader* RadialGradient_create2(JNIEnv* env, jobject, float x, float y, SkShader* s = SkGradientShader::CreateRadial(center, SkFloatToScalar(radius), colors, NULL, 2, (SkShader::TileMode)tileMode); ThrowIAE_IfNull(env, s); - return s; + return reinterpret_cast<jlong>(s); } -static SkiaShader* RadialGradient_postCreate1(JNIEnv* env, jobject o, SkShader* shader, - float x, float y, float radius, jintArray colorArray, jfloatArray posArray, int tileMode) { +static jlong RadialGradient_postCreate1(JNIEnv* env, jobject o, jlong shaderHandle, + jfloat x, jfloat y, jfloat radius, jintArray colorArray, jfloatArray posArray, jint tileMode) { #ifdef USE_OPENGL_RENDERER + SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle); size_t count = env->GetArrayLength(colorArray); const jint* colorValues = env->GetIntArrayElements(colorArray, NULL); @@ -335,15 +346,16 @@ static SkiaShader* RadialGradient_postCreate1(JNIEnv* env, jobject o, SkShader* (shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0); env->ReleaseIntArrayElements(colorArray, const_cast<jint*>(colorValues), JNI_ABORT); - return skiaShader; + return reinterpret_cast<jlong>(skiaShader); #else return NULL; #endif } -static SkiaShader* RadialGradient_postCreate2(JNIEnv* env, jobject o, SkShader* shader, - float x, float y, float radius, int color0, int color1, int tileMode) { +static jlong RadialGradient_postCreate2(JNIEnv* env, jobject o, jlong shaderHandle, + jfloat x, jfloat y, jfloat radius, jint color0, jint color1, jint tileMode) { #ifdef USE_OPENGL_RENDERER + SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle); float* storedPositions = new float[2]; storedPositions[0] = 0.0f; storedPositions[1] = 1.0f; @@ -356,7 +368,7 @@ static SkiaShader* RadialGradient_postCreate2(JNIEnv* env, jobject o, SkShader* storedPositions, 2, shader, (SkShader::TileMode) tileMode, NULL, (shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0); - return skiaShader; + return reinterpret_cast<jlong>(skiaShader); #else return NULL; #endif @@ -364,7 +376,7 @@ static SkiaShader* RadialGradient_postCreate2(JNIEnv* env, jobject o, SkShader* /////////////////////////////////////////////////////////////////////////////// -static SkShader* SweepGradient_create1(JNIEnv* env, jobject, float x, float y, +static jlong SweepGradient_create1(JNIEnv* env, jobject, jfloat x, jfloat y, jintArray jcolors, jfloatArray jpositions) { size_t count = env->GetArrayLength(jcolors); const jint* colors = env->GetIntArrayElements(jcolors, NULL); @@ -388,10 +400,10 @@ static SkShader* SweepGradient_create1(JNIEnv* env, jobject, float x, float y, env->ReleaseIntArrayElements(jcolors, const_cast<jint*>(colors), JNI_ABORT); ThrowIAE_IfNull(env, shader); - return shader; + return reinterpret_cast<jlong>(shader); } -static SkShader* SweepGradient_create2(JNIEnv* env, jobject, float x, float y, +static jlong SweepGradient_create2(JNIEnv* env, jobject, jfloat x, jfloat y, int color0, int color1) { SkColor colors[2]; colors[0] = color0; @@ -399,12 +411,13 @@ static SkShader* SweepGradient_create2(JNIEnv* env, jobject, float x, float y, SkShader* s = SkGradientShader::CreateSweep(SkFloatToScalar(x), SkFloatToScalar(y), colors, NULL, 2); ThrowIAE_IfNull(env, s); - return s; + return reinterpret_cast<jlong>(s); } -static SkiaShader* SweepGradient_postCreate1(JNIEnv* env, jobject o, SkShader* shader, - float x, float y, jintArray colorArray, jfloatArray posArray) { +static jlong SweepGradient_postCreate1(JNIEnv* env, jobject o, jlong shaderHandle, + jfloat x, jfloat y, jintArray colorArray, jfloatArray posArray) { #ifdef USE_OPENGL_RENDERER + SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle); size_t count = env->GetArrayLength(colorArray); const jint* colorValues = env->GetIntArrayElements(colorArray, NULL); @@ -433,15 +446,16 @@ static SkiaShader* SweepGradient_postCreate1(JNIEnv* env, jobject o, SkShader* s shader, NULL, (shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0); env->ReleaseIntArrayElements(colorArray, const_cast<jint*>(colorValues), JNI_ABORT); - return skiaShader; + return reinterpret_cast<jlong>(skiaShader); #else return NULL; #endif } -static SkiaShader* SweepGradient_postCreate2(JNIEnv* env, jobject o, SkShader* shader, - float x, float y, int color0, int color1) { +static jlong SweepGradient_postCreate2(JNIEnv* env, jobject o, jlong shaderHandle, + jfloat x, jfloat y, jint color0, jint color1) { #ifdef USE_OPENGL_RENDERER + SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle); float* storedPositions = new float[2]; storedPositions[0] = 0.0f; storedPositions[1] = 1.0f; @@ -453,7 +467,7 @@ static SkiaShader* SweepGradient_postCreate2(JNIEnv* env, jobject o, SkShader* s SkiaShader* skiaShader = new SkiaSweepGradientShader(x, y, storedColors, storedPositions, 2, shader, NULL, (shader->getFlags() & SkShader::kOpaqueAlpha_Flag) == 0); - return skiaShader; + return reinterpret_cast<jlong>(skiaShader); #else return NULL; #endif @@ -461,39 +475,57 @@ static SkiaShader* SweepGradient_postCreate2(JNIEnv* env, jobject o, SkShader* s /////////////////////////////////////////////////////////////////////////////////////////////// -static SkShader* ComposeShader_create1(JNIEnv* env, jobject o, - SkShader* shaderA, SkShader* shaderB, SkXfermode* mode) +static jlong ComposeShader_create1(JNIEnv* env, jobject o, + jlong shaderAHandle, jlong shaderBHandle, jlong modeHandle) { - return new SkComposeShader(shaderA, shaderB, mode); + SkShader* shaderA = reinterpret_cast<SkShader *>(shaderAHandle); + SkShader* shaderB = reinterpret_cast<SkShader *>(shaderBHandle); + SkXfermode* mode = reinterpret_cast<SkXfermode *>(modeHandle); + SkShader* shader = new SkComposeShader(shaderA, shaderB, mode); + return reinterpret_cast<jlong>(shader); } -static SkShader* ComposeShader_create2(JNIEnv* env, jobject o, - SkShader* shaderA, SkShader* shaderB, SkPorterDuff::Mode porterDuffMode) +static jlong ComposeShader_create2(JNIEnv* env, jobject o, + jlong shaderAHandle, jlong shaderBHandle, jint porterDuffModeHandle) { + SkShader* shaderA = reinterpret_cast<SkShader *>(shaderAHandle); + SkShader* shaderB = reinterpret_cast<SkShader *>(shaderBHandle); + SkPorterDuff::Mode porterDuffMode = static_cast<SkPorterDuff::Mode>(porterDuffModeHandle); SkAutoUnref au(SkPorterDuff::CreateXfermode(porterDuffMode)); SkXfermode* mode = (SkXfermode*) au.get(); - return new SkComposeShader(shaderA, shaderB, mode); + SkShader* shader = new SkComposeShader(shaderA, shaderB, mode); + return reinterpret_cast<jlong>(shader); } -static SkiaShader* ComposeShader_postCreate2(JNIEnv* env, jobject o, SkShader* shader, - SkiaShader* shaderA, SkiaShader* shaderB, SkPorterDuff::Mode porterDuffMode) { +static jlong ComposeShader_postCreate2(JNIEnv* env, jobject o, jlong shaderHandle, + jlong shaderAHandle, jlong shaderBHandle, jint porterDuffModeHandle) { #ifdef USE_OPENGL_RENDERER + SkShader* shader = reinterpret_cast<SkShader *>(shaderHandle); + SkiaShader* shaderA = reinterpret_cast<SkiaShader *>(shaderAHandle); + SkiaShader* shaderB = reinterpret_cast<SkiaShader *>(shaderBHandle); + SkPorterDuff::Mode porterDuffMode = static_cast<SkPorterDuff::Mode>(porterDuffModeHandle); SkXfermode::Mode mode = SkPorterDuff::ToXfermodeMode(porterDuffMode); - return new SkiaComposeShader(shaderA, shaderB, mode, shader); + SkiaShader* skiaShader = new SkiaComposeShader(shaderA, shaderB, mode, shader); + return reinterpret_cast<jlong>(skiaShader); #else return NULL; #endif } -static SkiaShader* ComposeShader_postCreate1(JNIEnv* env, jobject o, SkShader* shader, - SkiaShader* shaderA, SkiaShader* shaderB, SkXfermode* mode) { +static jlong ComposeShader_postCreate1(JNIEnv* env, jobject o, jlong shaderHandle, + jlong shaderAHandle, jlong shaderBHandle, jlong modeHandle) { #ifdef USE_OPENGL_RENDERER + SkShader* shader = reinterpret_cast<SkShader *>(shaderHandle); + SkiaShader* shaderA = reinterpret_cast<SkiaShader *>(shaderAHandle); + SkiaShader* shaderB = reinterpret_cast<SkiaShader *>(shaderBHandle); + SkXfermode* mode = reinterpret_cast<SkXfermode *>(modeHandle); SkXfermode::Mode skiaMode; if (!SkXfermode::IsMode(mode, &skiaMode)) { // TODO: Support other modes skiaMode = SkXfermode::kSrcOver_Mode; } - return new SkiaComposeShader(shaderA, shaderB, skiaMode, shader); + SkiaShader* skiaShader = new SkiaComposeShader(shaderA, shaderB, skiaMode, shader); + return reinterpret_cast<jlong>(skiaShader); #else return NULL; #endif @@ -507,41 +539,41 @@ static JNINativeMethod gColorMethods[] = { }; static JNINativeMethod gShaderMethods[] = { - { "nativeDestructor", "(II)V", (void*)Shader_destructor }, - { "nativeSetLocalMatrix", "(III)V", (void*)Shader_setLocalMatrix } + { "nativeDestructor", "(JJ)V", (void*)Shader_destructor }, + { "nativeSetLocalMatrix", "(JJJ)V", (void*)Shader_setLocalMatrix } }; static JNINativeMethod gBitmapShaderMethods[] = { - { "nativeCreate", "(III)I", (void*)BitmapShader_constructor }, - { "nativePostCreate", "(IIII)I", (void*)BitmapShader_postConstructor } + { "nativeCreate", "(JII)J", (void*)BitmapShader_constructor }, + { "nativePostCreate", "(JJII)J", (void*)BitmapShader_postConstructor } }; static JNINativeMethod gLinearGradientMethods[] = { - { "nativeCreate1", "(FFFF[I[FI)I", (void*)LinearGradient_create1 }, - { "nativeCreate2", "(FFFFIII)I", (void*)LinearGradient_create2 }, - { "nativePostCreate1", "(IFFFF[I[FI)I", (void*)LinearGradient_postCreate1 }, - { "nativePostCreate2", "(IFFFFIII)I", (void*)LinearGradient_postCreate2 } + { "nativeCreate1", "(FFFF[I[FI)J", (void*)LinearGradient_create1 }, + { "nativeCreate2", "(FFFFIII)J", (void*)LinearGradient_create2 }, + { "nativePostCreate1", "(JFFFF[I[FI)J", (void*)LinearGradient_postCreate1 }, + { "nativePostCreate2", "(JFFFFIII)J", (void*)LinearGradient_postCreate2 } }; static JNINativeMethod gRadialGradientMethods[] = { - { "nativeCreate1", "(FFF[I[FI)I", (void*)RadialGradient_create1 }, - { "nativeCreate2", "(FFFIII)I", (void*)RadialGradient_create2 }, - { "nativePostCreate1", "(IFFF[I[FI)I", (void*)RadialGradient_postCreate1 }, - { "nativePostCreate2", "(IFFFIII)I", (void*)RadialGradient_postCreate2 } + { "nativeCreate1", "(FFF[I[FI)J", (void*)RadialGradient_create1 }, + { "nativeCreate2", "(FFFIII)J", (void*)RadialGradient_create2 }, + { "nativePostCreate1", "(JFFF[I[FI)J", (void*)RadialGradient_postCreate1 }, + { "nativePostCreate2", "(JFFFIII)J", (void*)RadialGradient_postCreate2 } }; static JNINativeMethod gSweepGradientMethods[] = { - { "nativeCreate1", "(FF[I[F)I", (void*)SweepGradient_create1 }, - { "nativeCreate2", "(FFII)I", (void*)SweepGradient_create2 }, - { "nativePostCreate1", "(IFF[I[F)I", (void*)SweepGradient_postCreate1 }, - { "nativePostCreate2", "(IFFII)I", (void*)SweepGradient_postCreate2 } + { "nativeCreate1", "(FF[I[F)J", (void*)SweepGradient_create1 }, + { "nativeCreate2", "(FFII)J", (void*)SweepGradient_create2 }, + { "nativePostCreate1", "(JFF[I[F)J", (void*)SweepGradient_postCreate1 }, + { "nativePostCreate2", "(JFFII)J", (void*)SweepGradient_postCreate2 } }; static JNINativeMethod gComposeShaderMethods[] = { - { "nativeCreate1", "(III)I", (void*)ComposeShader_create1 }, - { "nativeCreate2", "(III)I", (void*)ComposeShader_create2 }, - { "nativePostCreate1", "(IIII)I", (void*)ComposeShader_postCreate1 }, - { "nativePostCreate2", "(IIII)I", (void*)ComposeShader_postCreate2 } + { "nativeCreate1", "(JJJ)J", (void*)ComposeShader_create1 }, + { "nativeCreate2", "(JJI)J", (void*)ComposeShader_create2 }, + { "nativePostCreate1", "(JJJJ)J", (void*)ComposeShader_postCreate1 }, + { "nativePostCreate2", "(JJJI)J", (void*)ComposeShader_postCreate2 } }; #include <android_runtime/AndroidRuntime.h> diff --git a/core/jni/android/graphics/SurfaceTexture.cpp b/core/jni/android/graphics/SurfaceTexture.cpp index 0c9b3bc..3116955 100644 --- a/core/jni/android/graphics/SurfaceTexture.cpp +++ b/core/jni/android/graphics/SurfaceTexture.cpp @@ -55,28 +55,28 @@ static void SurfaceTexture_setSurfaceTexture(JNIEnv* env, jobject thiz, const sp<GLConsumer>& surfaceTexture) { GLConsumer* const p = - (GLConsumer*)env->GetIntField(thiz, fields.surfaceTexture); + (GLConsumer*)env->GetLongField(thiz, fields.surfaceTexture); if (surfaceTexture.get()) { surfaceTexture->incStrong((void*)SurfaceTexture_setSurfaceTexture); } if (p) { p->decStrong((void*)SurfaceTexture_setSurfaceTexture); } - env->SetIntField(thiz, fields.surfaceTexture, (int)surfaceTexture.get()); + env->SetLongField(thiz, fields.surfaceTexture, (jlong)surfaceTexture.get()); } static void SurfaceTexture_setBufferQueue(JNIEnv* env, jobject thiz, const sp<BufferQueue>& bq) { BufferQueue* const p = - (BufferQueue*)env->GetIntField(thiz, fields.bufferQueue); + (BufferQueue*)env->GetLongField(thiz, fields.bufferQueue); if (bq.get()) { bq->incStrong((void*)SurfaceTexture_setBufferQueue); } if (p) { p->decStrong((void*)SurfaceTexture_setBufferQueue); } - env->SetIntField(thiz, fields.bufferQueue, (int)bq.get()); + env->SetLongField(thiz, fields.bufferQueue, (jlong)bq.get()); } static void SurfaceTexture_setFrameAvailableListener(JNIEnv* env, @@ -84,22 +84,22 @@ static void SurfaceTexture_setFrameAvailableListener(JNIEnv* env, { GLConsumer::FrameAvailableListener* const p = (GLConsumer::FrameAvailableListener*) - env->GetIntField(thiz, fields.frameAvailableListener); + env->GetLongField(thiz, fields.frameAvailableListener); if (listener.get()) { listener->incStrong((void*)SurfaceTexture_setSurfaceTexture); } if (p) { p->decStrong((void*)SurfaceTexture_setSurfaceTexture); } - env->SetIntField(thiz, fields.frameAvailableListener, (int)listener.get()); + env->SetLongField(thiz, fields.frameAvailableListener, (jlong)listener.get()); } sp<GLConsumer> SurfaceTexture_getSurfaceTexture(JNIEnv* env, jobject thiz) { - return (GLConsumer*)env->GetIntField(thiz, fields.surfaceTexture); + return (GLConsumer*)env->GetLongField(thiz, fields.surfaceTexture); } sp<IGraphicBufferProducer> SurfaceTexture_getProducer(JNIEnv* env, jobject thiz) { - return (BufferQueue*)env->GetIntField(thiz, fields.bufferQueue); + return (BufferQueue*)env->GetLongField(thiz, fields.bufferQueue); } sp<ANativeWindow> android_SurfaceTexture_getNativeWindow(JNIEnv* env, jobject thiz) { @@ -201,19 +201,19 @@ void JNISurfaceTextureContext::onFrameAvailable() static void SurfaceTexture_classInit(JNIEnv* env, jclass clazz) { fields.surfaceTexture = env->GetFieldID(clazz, - ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID, "I"); + ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID, "J"); if (fields.surfaceTexture == NULL) { ALOGE("can't find android/graphics/SurfaceTexture.%s", ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID); } fields.bufferQueue = env->GetFieldID(clazz, - ANDROID_GRAPHICS_BUFFERQUEUE_JNI_ID, "I"); + ANDROID_GRAPHICS_BUFFERQUEUE_JNI_ID, "J"); if (fields.bufferQueue == NULL) { ALOGE("can't find android/graphics/SurfaceTexture.%s", ANDROID_GRAPHICS_BUFFERQUEUE_JNI_ID); } fields.frameAvailableListener = env->GetFieldID(clazz, - ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID, "I"); + ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID, "J"); if (fields.frameAvailableListener == NULL) { ALOGE("can't find android/graphics/SurfaceTexture.%s", ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID); diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp index ccd75d5..d096c2a 100644 --- a/core/jni/android/graphics/Typeface.cpp +++ b/core/jni/android/graphics/Typeface.cpp @@ -27,8 +27,9 @@ private: const char* fCStr; }; -static SkTypeface* Typeface_create(JNIEnv* env, jobject, jstring name, - SkTypeface::Style style) { +static jlong Typeface_create(JNIEnv* env, jobject, jstring name, + jint styleHandle) { + SkTypeface::Style style = static_cast<SkTypeface::Style>(styleHandle); SkTypeface* face = NULL; if (NULL != name) { @@ -47,10 +48,11 @@ static SkTypeface* Typeface_create(JNIEnv* env, jobject, jstring name, if (NULL == face) { face = SkTypeface::CreateFromName(NULL, style); } - return face; + return reinterpret_cast<jlong>(face); } -static SkTypeface* Typeface_createFromTypeface(JNIEnv* env, jobject, SkTypeface* family, int style) { +static jlong Typeface_createFromTypeface(JNIEnv* env, jobject, jlong familyHandle, jint style) { + SkTypeface* family = reinterpret_cast<SkTypeface*>(familyHandle); SkTypeface* face = SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)style); // Try to find the closest matching font, using the standard heuristic if (NULL == face) { @@ -62,15 +64,17 @@ static SkTypeface* Typeface_createFromTypeface(JNIEnv* env, jobject, SkTypeface* if (NULL == face) { face = SkTypeface::CreateFromName(NULL, (SkTypeface::Style)style); } - return face; + return reinterpret_cast<jlong>(face); } -static void Typeface_unref(JNIEnv* env, jobject obj, SkTypeface* face) { +static void Typeface_unref(JNIEnv* env, jobject obj, jlong faceHandle) { + SkTypeface* face = reinterpret_cast<SkTypeface*>(faceHandle); SkSafeUnref(face); } -static int Typeface_getStyle(JNIEnv* env, jobject obj, SkTypeface* face) { - return face->style(); +static jint Typeface_getStyle(JNIEnv* env, jobject obj, jlong faceHandle) { + SkTypeface* face = reinterpret_cast<SkTypeface*>(faceHandle); + return static_cast<jint>(face->style()); } class AssetStream : public SkStream { @@ -132,9 +136,9 @@ private: const void* fMemoryBase; }; -static SkTypeface* Typeface_createFromAsset(JNIEnv* env, jobject, - jobject jassetMgr, - jstring jpath) { +static jlong Typeface_createFromAsset(JNIEnv* env, jobject, + jobject jassetMgr, + jstring jpath) { NPE_CHECK_RETURN_ZERO(env, jassetMgr); NPE_CHECK_RETURN_ZERO(env, jpath); @@ -156,27 +160,27 @@ static SkTypeface* Typeface_createFromAsset(JNIEnv* env, jobject, // need to unref it here or it won't be freed later on stream->unref(); - return face; + return reinterpret_cast<jlong>(face); } -static SkTypeface* Typeface_createFromFile(JNIEnv* env, jobject, jstring jpath) { +static jlong Typeface_createFromFile(JNIEnv* env, jobject, jstring jpath) { NPE_CHECK_RETURN_ZERO(env, jpath); AutoJavaStringToUTF8 str(env, jpath); - return SkTypeface::CreateFromFile(str.c_str()); + return reinterpret_cast<jlong>(SkTypeface::CreateFromFile(str.c_str())); } /////////////////////////////////////////////////////////////////////////////// static JNINativeMethod gTypefaceMethods[] = { - { "nativeCreate", "(Ljava/lang/String;I)I", (void*)Typeface_create }, - { "nativeCreateFromTypeface", "(II)I", (void*)Typeface_createFromTypeface }, - { "nativeUnref", "(I)V", (void*)Typeface_unref }, - { "nativeGetStyle", "(I)I", (void*)Typeface_getStyle }, - { "nativeCreateFromAsset", "(Landroid/content/res/AssetManager;Ljava/lang/String;)I", + { "nativeCreate", "(Ljava/lang/String;I)J", (void*)Typeface_create }, + { "nativeCreateFromTypeface", "(JI)J", (void*)Typeface_createFromTypeface }, + { "nativeUnref", "(J)V", (void*)Typeface_unref }, + { "nativeGetStyle", "(J)I", (void*)Typeface_getStyle }, + { "nativeCreateFromAsset", "(Landroid/content/res/AssetManager;Ljava/lang/String;)J", (void*)Typeface_createFromAsset }, - { "nativeCreateFromFile", "(Ljava/lang/String;)I", + { "nativeCreateFromFile", "(Ljava/lang/String;)J", (void*)Typeface_createFromFile }, }; diff --git a/core/jni/android/graphics/Xfermode.cpp b/core/jni/android/graphics/Xfermode.cpp index 976a91f..eedceb7 100644 --- a/core/jni/android/graphics/Xfermode.cpp +++ b/core/jni/android/graphics/Xfermode.cpp @@ -26,35 +26,37 @@ namespace android { class SkXfermodeGlue { public: - static void finalizer(JNIEnv* env, jobject, SkXfermode* obj) + static void finalizer(JNIEnv* env, jobject, jlong objHandle) { + SkXfermode* obj = reinterpret_cast<SkXfermode *>(objHandle); SkSafeUnref(obj); } - static SkXfermode* avoid_create(JNIEnv* env, jobject, SkColor opColor, - U8CPU tolerance, SkAvoidXfermode::Mode mode) + static jlong avoid_create(JNIEnv* env, jobject, jint opColor, + jint tolerance, jint modeHandle) { - return new SkAvoidXfermode(opColor, tolerance, mode); + SkAvoidXfermode::Mode mode = static_cast<SkAvoidXfermode::Mode>(modeHandle); + return reinterpret_cast<jlong>(new SkAvoidXfermode(opColor, tolerance, mode)); } - - static SkXfermode* pixelxor_create(JNIEnv* env, jobject, SkColor opColor) + + static jlong pixelxor_create(JNIEnv* env, jobject, jint opColor) { - return new SkPixelXorXfermode(opColor); + return reinterpret_cast<jlong>(new SkPixelXorXfermode(opColor)); } }; /////////////////////////////////////////////////////////////////////////////// static JNINativeMethod gXfermodeMethods[] = { - {"finalizer", "(I)V", (void*) SkXfermodeGlue::finalizer} + {"finalizer", "(J)V", (void*) SkXfermodeGlue::finalizer} }; static JNINativeMethod gAvoidMethods[] = { - {"nativeCreate", "(III)I", (void*) SkXfermodeGlue::avoid_create} + {"nativeCreate", "(III)J", (void*) SkXfermodeGlue::avoid_create} }; static JNINativeMethod gPixelXorMethods[] = { - {"nativeCreate", "(I)I", (void*) SkXfermodeGlue::pixelxor_create} + {"nativeCreate", "(I)J", (void*) SkXfermodeGlue::pixelxor_create} }; #include <android_runtime/AndroidRuntime.h> diff --git a/core/jni/android/graphics/YuvToJpegEncoder.cpp b/core/jni/android/graphics/YuvToJpegEncoder.cpp index f386905..799782d 100644 --- a/core/jni/android/graphics/YuvToJpegEncoder.cpp +++ b/core/jni/android/graphics/YuvToJpegEncoder.cpp @@ -217,8 +217,8 @@ void Yuv422IToJpegEncoder::configSamplingFactors(jpeg_compress_struct* cinfo) { /////////////////////////////////////////////////////////////////////////////// static jboolean YuvImage_compressToJpeg(JNIEnv* env, jobject, jbyteArray inYuv, - int format, int width, int height, jintArray offsets, - jintArray strides, int jpegQuality, jobject jstream, + jint format, jint width, jint height, jintArray offsets, + jintArray strides, jint jpegQuality, jobject jstream, jbyteArray jstorage) { jbyte* yuv = env->GetByteArrayElements(inYuv, NULL); SkWStream* strm = CreateJavaOutputStreamAdaptor(env, jstream, jstorage); @@ -227,7 +227,7 @@ static jboolean YuvImage_compressToJpeg(JNIEnv* env, jobject, jbyteArray inYuv, jint* imgStrides = env->GetIntArrayElements(strides, NULL); YuvToJpegEncoder* encoder = YuvToJpegEncoder::create(format, imgStrides); if (encoder == NULL) { - return false; + return JNI_FALSE; } encoder->encode(strm, yuv, width, height, imgOffsets, jpegQuality); @@ -235,7 +235,7 @@ static jboolean YuvImage_compressToJpeg(JNIEnv* env, jobject, jbyteArray inYuv, env->ReleaseByteArrayElements(inYuv, yuv, 0); env->ReleaseIntArrayElements(offsets, imgOffsets, 0); env->ReleaseIntArrayElements(strides, imgStrides, 0); - return true; + return JNI_TRUE; } /////////////////////////////////////////////////////////////////////////////// diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp index 44af199..48367ff 100644 --- a/core/jni/android/opengl/util.cpp +++ b/core/jni/android/opengl/util.cpp @@ -389,7 +389,7 @@ static void computeFrustum(const float* m, float* f) { } static -int util_frustumCullSpheres(JNIEnv *env, jclass clazz, +jint util_frustumCullSpheres(JNIEnv *env, jclass clazz, jfloatArray mvp_ref, jint mvpOffset, jfloatArray spheres_ref, jint spheresOffset, jint spheresCount, jintArray results_ref, jint resultsOffset, jint resultsCapacity) { @@ -436,7 +436,7 @@ int util_frustumCullSpheres(JNIEnv *env, jclass clazz, */ static -int util_visibilityTest(JNIEnv *env, jclass clazz, +jint util_visibilityTest(JNIEnv *env, jclass clazz, jfloatArray ws_ref, jint wsOffset, jfloatArray positions_ref, jint positionsOffset, jcharArray indices_ref, jint indicesOffset, jint indexCount) { @@ -553,7 +553,7 @@ static jfieldID nativeBitmapID = 0; void nativeUtilsClassInit(JNIEnv *env, jclass clazz) { jclass bitmapClass = env->FindClass("android/graphics/Bitmap"); - nativeBitmapID = env->GetFieldID(bitmapClass, "mNativeBitmap", "I"); + nativeBitmapID = env->GetFieldID(bitmapClass, "mNativeBitmap", "J"); } extern void setGLDebugLevel(int level); @@ -630,7 +630,7 @@ static jint util_getInternalFormat(JNIEnv *env, jclass clazz, jobject jbitmap) { SkBitmap const * nativeBitmap = - (SkBitmap const *)env->GetIntField(jbitmap, nativeBitmapID); + (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); SkBitmap::Config config = bitmap.getConfig(); return getInternalFormat(config); @@ -640,7 +640,7 @@ static jint util_getType(JNIEnv *env, jclass clazz, jobject jbitmap) { SkBitmap const * nativeBitmap = - (SkBitmap const *)env->GetIntField(jbitmap, nativeBitmapID); + (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); SkBitmap::Config config = bitmap.getConfig(); return getType(config); @@ -651,7 +651,7 @@ static jint util_texImage2D(JNIEnv *env, jclass clazz, jobject jbitmap, jint type, jint border) { SkBitmap const * nativeBitmap = - (SkBitmap const *)env->GetIntField(jbitmap, nativeBitmapID); + (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); SkBitmap::Config config = bitmap.getConfig(); if (internalformat < 0) { @@ -700,7 +700,7 @@ static jint util_texSubImage2D(JNIEnv *env, jclass clazz, jobject jbitmap, jint format, jint type) { SkBitmap const * nativeBitmap = - (SkBitmap const *)env->GetIntField(jbitmap, nativeBitmapID); + (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); SkBitmap::Config config = bitmap.getConfig(); if (format < 0) { @@ -773,7 +773,7 @@ getPointer(JNIEnv *_env, jobject buffer, jint *remaining) pointer = _env->CallStaticLongMethod(nioAccessClass, getBasePointerID, buffer); if (pointer != 0L) { - return (void *) (jint) pointer; + return reinterpret_cast<void *>(pointer); } return NULL; } @@ -974,7 +974,7 @@ static jboolean etc1_isValid(JNIEnv *env, jclass clazz, result = etc1_pkm_is_valid((etc1_byte*) headerB.getData()); } } - return result; + return result ? JNI_TRUE : JNI_FALSE; } /** @@ -997,7 +997,7 @@ static jint etc1_getWidth(JNIEnv *env, jclass clazz, /** * Read the image height from a PKM header */ -static int etc1_getHeight(JNIEnv *env, jclass clazz, +static jint etc1_getHeight(JNIEnv *env, jclass clazz, jobject header) { jint result = 0; BufferHelper headerB(env, header); diff --git a/core/jni/android_animation_PropertyValuesHolder.cpp b/core/jni/android_animation_PropertyValuesHolder.cpp index 5991805..1e3ec18 100644 --- a/core/jni/android_animation_PropertyValuesHolder.cpp +++ b/core/jni/android_animation_PropertyValuesHolder.cpp @@ -29,44 +29,44 @@ namespace android { const char* const kClassPathName = "android/animation/PropertyValuesHolder"; -static jmethodID android_animation_PropertyValuesHolder_getIntMethod( +static jlong android_animation_PropertyValuesHolder_getIntMethod( JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName) { const char *nativeString = env->GetStringUTFChars(methodName, 0); jmethodID mid = env->GetMethodID(targetClass, nativeString, "(I)V"); env->ReleaseStringUTFChars(methodName, nativeString); - return mid; + return reinterpret_cast<jlong>(mid); } -static jmethodID android_animation_PropertyValuesHolder_getFloatMethod( +static jlong android_animation_PropertyValuesHolder_getFloatMethod( JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName) { const char *nativeString = env->GetStringUTFChars(methodName, 0); jmethodID mid = env->GetMethodID(targetClass, nativeString, "(F)V"); env->ReleaseStringUTFChars(methodName, nativeString); - return mid; + return reinterpret_cast<jlong>(mid); } static void android_animation_PropertyValuesHolder_callIntMethod( - JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, int arg) + JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jint arg) { - env->CallVoidMethod(target, methodID, arg); + env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg); } static void android_animation_PropertyValuesHolder_callFloatMethod( - JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, float arg) + JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jfloat arg) { - env->CallVoidMethod(target, methodID, arg); + env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg); } static JNINativeMethod gMethods[] = { - { "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)I", + { "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)J", (void*)android_animation_PropertyValuesHolder_getIntMethod }, - { "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)I", + { "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)J", (void*)android_animation_PropertyValuesHolder_getFloatMethod }, - { "nCallIntMethod", "(Ljava/lang/Object;II)V", + { "nCallIntMethod", "(Ljava/lang/Object;JI)V", (void*)android_animation_PropertyValuesHolder_callIntMethod }, - { "nCallFloatMethod", "(Ljava/lang/Object;IF)V", + { "nCallFloatMethod", "(Ljava/lang/Object;JF)V", (void*)android_animation_PropertyValuesHolder_callFloatMethod } }; diff --git a/core/jni/android_app_NativeActivity.cpp b/core/jni/android_app_NativeActivity.cpp index 5418006..9c44093 100644 --- a/core/jni/android_app_NativeActivity.cpp +++ b/core/jni/android_app_NativeActivity.cpp @@ -241,10 +241,10 @@ static int mainWorkCallback(int fd, int events, void* data) { // ------------------------------------------------------------------------ -static jint +static jlong loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName, jobject messageQueue, jstring internalDataDir, jstring obbDir, - jstring externalDataDir, int sdkVersion, + jstring externalDataDir, jint sdkVersion, jobject jAssetMgr, jbyteArray savedState) { LOG_TRACE("loadNativeCode_native"); @@ -338,11 +338,11 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName } } - return (jint)code; + return (jlong)code; } static void -unloadNativeCode_native(JNIEnv* env, jobject clazz, jint handle) +unloadNativeCode_native(JNIEnv* env, jobject clazz, jlong handle) { LOG_TRACE("unloadNativeCode_native"); if (handle != 0) { @@ -352,7 +352,7 @@ unloadNativeCode_native(JNIEnv* env, jobject clazz, jint handle) } static void -onStart_native(JNIEnv* env, jobject clazz, jint handle) +onStart_native(JNIEnv* env, jobject clazz, jlong handle) { LOG_TRACE("onStart_native"); if (handle != 0) { @@ -364,7 +364,7 @@ onStart_native(JNIEnv* env, jobject clazz, jint handle) } static void -onResume_native(JNIEnv* env, jobject clazz, jint handle) +onResume_native(JNIEnv* env, jobject clazz, jlong handle) { LOG_TRACE("onResume_native"); if (handle != 0) { @@ -376,7 +376,7 @@ onResume_native(JNIEnv* env, jobject clazz, jint handle) } static jbyteArray -onSaveInstanceState_native(JNIEnv* env, jobject clazz, jint handle) +onSaveInstanceState_native(JNIEnv* env, jobject clazz, jlong handle) { LOG_TRACE("onSaveInstanceState_native"); @@ -403,7 +403,7 @@ onSaveInstanceState_native(JNIEnv* env, jobject clazz, jint handle) } static void -onPause_native(JNIEnv* env, jobject clazz, jint handle) +onPause_native(JNIEnv* env, jobject clazz, jlong handle) { LOG_TRACE("onPause_native"); if (handle != 0) { @@ -415,7 +415,7 @@ onPause_native(JNIEnv* env, jobject clazz, jint handle) } static void -onStop_native(JNIEnv* env, jobject clazz, jint handle) +onStop_native(JNIEnv* env, jobject clazz, jlong handle) { LOG_TRACE("onStop_native"); if (handle != 0) { @@ -427,7 +427,7 @@ onStop_native(JNIEnv* env, jobject clazz, jint handle) } static void -onConfigurationChanged_native(JNIEnv* env, jobject clazz, jint handle) +onConfigurationChanged_native(JNIEnv* env, jobject clazz, jlong handle) { LOG_TRACE("onConfigurationChanged_native"); if (handle != 0) { @@ -439,7 +439,7 @@ onConfigurationChanged_native(JNIEnv* env, jobject clazz, jint handle) } static void -onLowMemory_native(JNIEnv* env, jobject clazz, jint handle) +onLowMemory_native(JNIEnv* env, jobject clazz, jlong handle) { LOG_TRACE("onLowMemory_native"); if (handle != 0) { @@ -451,7 +451,7 @@ onLowMemory_native(JNIEnv* env, jobject clazz, jint handle) } static void -onWindowFocusChanged_native(JNIEnv* env, jobject clazz, jint handle, jboolean focused) +onWindowFocusChanged_native(JNIEnv* env, jobject clazz, jlong handle, jboolean focused) { LOG_TRACE("onWindowFocusChanged_native"); if (handle != 0) { @@ -463,7 +463,7 @@ onWindowFocusChanged_native(JNIEnv* env, jobject clazz, jint handle, jboolean fo } static void -onSurfaceCreated_native(JNIEnv* env, jobject clazz, jint handle, jobject surface) +onSurfaceCreated_native(JNIEnv* env, jobject clazz, jlong handle, jobject surface) { LOG_TRACE("onSurfaceCreated_native"); if (handle != 0) { @@ -483,7 +483,7 @@ static int32_t getWindowProp(ANativeWindow* window, int what) { } static void -onSurfaceChanged_native(JNIEnv* env, jobject clazz, jint handle, jobject surface, +onSurfaceChanged_native(JNIEnv* env, jobject clazz, jlong handle, jobject surface, jint format, jint width, jint height) { LOG_TRACE("onSurfaceChanged_native"); @@ -524,7 +524,7 @@ onSurfaceChanged_native(JNIEnv* env, jobject clazz, jint handle, jobject surface } static void -onSurfaceRedrawNeeded_native(JNIEnv* env, jobject clazz, jint handle) +onSurfaceRedrawNeeded_native(JNIEnv* env, jobject clazz, jlong handle) { LOG_TRACE("onSurfaceRedrawNeeded_native"); if (handle != 0) { @@ -536,7 +536,7 @@ onSurfaceRedrawNeeded_native(JNIEnv* env, jobject clazz, jint handle) } static void -onSurfaceDestroyed_native(JNIEnv* env, jobject clazz, jint handle, jobject surface) +onSurfaceDestroyed_native(JNIEnv* env, jobject clazz, jlong handle, jobject surface) { LOG_TRACE("onSurfaceDestroyed_native"); if (handle != 0) { @@ -550,7 +550,7 @@ onSurfaceDestroyed_native(JNIEnv* env, jobject clazz, jint handle, jobject surfa } static void -onInputQueueCreated_native(JNIEnv* env, jobject clazz, jint handle, jint queuePtr) +onInputQueueCreated_native(JNIEnv* env, jobject clazz, jlong handle, jlong queuePtr) { LOG_TRACE("onInputChannelCreated_native"); if (handle != 0) { @@ -563,7 +563,7 @@ onInputQueueCreated_native(JNIEnv* env, jobject clazz, jint handle, jint queuePt } static void -onInputQueueDestroyed_native(JNIEnv* env, jobject clazz, jint handle, jint queuePtr) +onInputQueueDestroyed_native(JNIEnv* env, jobject clazz, jlong handle, jlong queuePtr) { LOG_TRACE("onInputChannelDestroyed_native"); if (handle != 0) { @@ -576,7 +576,7 @@ onInputQueueDestroyed_native(JNIEnv* env, jobject clazz, jint handle, jint queue } static void -onContentRectChanged_native(JNIEnv* env, jobject clazz, jint handle, +onContentRectChanged_native(JNIEnv* env, jobject clazz, jlong handle, jint x, jint y, jint w, jint h) { LOG_TRACE("onContentRectChanged_native"); @@ -594,26 +594,26 @@ onContentRectChanged_native(JNIEnv* env, jobject clazz, jint handle, } static const JNINativeMethod g_methods[] = { - { "loadNativeCode", "(Ljava/lang/String;Ljava/lang/String;Landroid/os/MessageQueue;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILandroid/content/res/AssetManager;[B)I", + { "loadNativeCode", "(Ljava/lang/String;Ljava/lang/String;Landroid/os/MessageQueue;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILandroid/content/res/AssetManager;[B)J", (void*)loadNativeCode_native }, - { "unloadNativeCode", "(I)V", (void*)unloadNativeCode_native }, - { "onStartNative", "(I)V", (void*)onStart_native }, - { "onResumeNative", "(I)V", (void*)onResume_native }, - { "onSaveInstanceStateNative", "(I)[B", (void*)onSaveInstanceState_native }, - { "onPauseNative", "(I)V", (void*)onPause_native }, - { "onStopNative", "(I)V", (void*)onStop_native }, - { "onConfigurationChangedNative", "(I)V", (void*)onConfigurationChanged_native }, - { "onLowMemoryNative", "(I)V", (void*)onLowMemory_native }, - { "onWindowFocusChangedNative", "(IZ)V", (void*)onWindowFocusChanged_native }, - { "onSurfaceCreatedNative", "(ILandroid/view/Surface;)V", (void*)onSurfaceCreated_native }, - { "onSurfaceChangedNative", "(ILandroid/view/Surface;III)V", (void*)onSurfaceChanged_native }, - { "onSurfaceRedrawNeededNative", "(ILandroid/view/Surface;)V", (void*)onSurfaceRedrawNeeded_native }, - { "onSurfaceDestroyedNative", "(I)V", (void*)onSurfaceDestroyed_native }, - { "onInputQueueCreatedNative", "(II)V", + { "unloadNativeCode", "(J)V", (void*)unloadNativeCode_native }, + { "onStartNative", "(J)V", (void*)onStart_native }, + { "onResumeNative", "(J)V", (void*)onResume_native }, + { "onSaveInstanceStateNative", "(J)[B", (void*)onSaveInstanceState_native }, + { "onPauseNative", "(J)V", (void*)onPause_native }, + { "onStopNative", "(J)V", (void*)onStop_native }, + { "onConfigurationChangedNative", "(J)V", (void*)onConfigurationChanged_native }, + { "onLowMemoryNative", "(J)V", (void*)onLowMemory_native }, + { "onWindowFocusChangedNative", "(JZ)V", (void*)onWindowFocusChanged_native }, + { "onSurfaceCreatedNative", "(JLandroid/view/Surface;)V", (void*)onSurfaceCreated_native }, + { "onSurfaceChangedNative", "(JLandroid/view/Surface;III)V", (void*)onSurfaceChanged_native }, + { "onSurfaceRedrawNeededNative", "(JLandroid/view/Surface;)V", (void*)onSurfaceRedrawNeeded_native }, + { "onSurfaceDestroyedNative", "(J)V", (void*)onSurfaceDestroyed_native }, + { "onInputQueueCreatedNative", "(JJ)V", (void*)onInputQueueCreated_native }, - { "onInputQueueDestroyedNative", "(II)V", + { "onInputQueueDestroyedNative", "(JJ)V", (void*)onInputQueueDestroyed_native }, - { "onContentRectChangedNative", "(IIIII)V", (void*)onContentRectChanged_native }, + { "onContentRectChangedNative", "(JIIII)V", (void*)onContentRectChanged_native }, }; static const char* const kNativeActivityPathName = "android/app/NativeActivity"; diff --git a/core/jni/android_app_backup_FullBackup.cpp b/core/jni/android_app_backup_FullBackup.cpp index 2ca645a..3cfaa82 100644 --- a/core/jni/android_app_backup_FullBackup.cpp +++ b/core/jni/android_app_backup_FullBackup.cpp @@ -70,7 +70,7 @@ static struct { * path: absolute path to the file to be saved * dataOutput: the BackupDataOutput object that we're saving into */ -static int backupToTar(JNIEnv* env, jobject clazz, jstring packageNameObj, +static jint backupToTar(JNIEnv* env, jobject clazz, jstring packageNameObj, jstring domainObj, jstring linkdomain, jstring rootpathObj, jstring pathObj, jobject dataOutputObj) { int ret; @@ -92,22 +92,22 @@ static int backupToTar(JNIEnv* env, jobject clazz, jstring packageNameObj, if (packagenamechars) env->ReleaseStringUTFChars(packageNameObj, packagenamechars); // Extract the data output fd - BackupDataWriter* writer = (BackupDataWriter*) env->GetIntField(dataOutputObj, + BackupDataWriter* writer = (BackupDataWriter*) env->GetLongField(dataOutputObj, sBackupDataOutput.mBackupWriter); // Validate if (!writer) { ALOGE("No output stream provided [%s]", path.string()); - return -1; + return (jint) -1; } if (path.length() < rootpath.length()) { ALOGE("file path [%s] shorter than root path [%s]", path.string(), rootpath.string()); - return -1; + return (jint) -1; } - return write_tarfile(packageName, domain, rootpath, path, writer); + return (jint) write_tarfile(packageName, domain, rootpath, path, writer); } static const JNINativeMethod g_methods[] = { @@ -121,7 +121,7 @@ int register_android_app_backup_FullBackup(JNIEnv* env) jclass clazz = env->FindClass("android/app/backup/BackupDataOutput"); LOG_FATAL_IF(clazz == NULL, "Unable to find class android.app.backup.BackupDataOutput"); - sBackupDataOutput.mBackupWriter = env->GetFieldID(clazz, "mBackupWriter", "I"); + sBackupDataOutput.mBackupWriter = env->GetFieldID(clazz, "mBackupWriter", "J"); LOG_FATAL_IF(sBackupDataOutput.mBackupwriter == NULL, "Unable to find mBackupWriter field in android.app.backup.BackupDataOutput"); diff --git a/core/jni/android_backup_BackupDataInput.cpp b/core/jni/android_backup_BackupDataInput.cpp index 25b0007..90763b0 100644 --- a/core/jni/android_backup_BackupDataInput.cpp +++ b/core/jni/android_backup_BackupDataInput.cpp @@ -29,25 +29,25 @@ namespace android static jfieldID s_keyField = 0; static jfieldID s_dataSizeField = 0; -static int +static jlong ctor_native(JNIEnv* env, jobject clazz, jobject fileDescriptor) { int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); if (fd == -1) { - return NULL; + return (jlong)NULL; } - return (int)new BackupDataReader(fd); + return (jlong)new BackupDataReader(fd); } static void -dtor_native(JNIEnv* env, jobject clazz, int r) +dtor_native(JNIEnv* env, jobject clazz, jlong r) { delete (BackupDataReader*)r; } static jint -readNextHeader_native(JNIEnv* env, jobject clazz, int r, jobject entity) +readNextHeader_native(JNIEnv* env, jobject clazz, jlong r, jobject entity) { int err; bool done; @@ -89,7 +89,7 @@ readNextHeader_native(JNIEnv* env, jobject clazz, int r, jobject entity) } static jint -readEntityData_native(JNIEnv* env, jobject clazz, int r, jbyteArray data, int offset, int size) +readEntityData_native(JNIEnv* env, jobject clazz, jlong r, jbyteArray data, jint offset, jint size) { int err; BackupDataReader* reader = (BackupDataReader*)r; @@ -112,7 +112,7 @@ readEntityData_native(JNIEnv* env, jobject clazz, int r, jbyteArray data, int of } static jint -skipEntityData_native(JNIEnv* env, jobject clazz, int r) +skipEntityData_native(JNIEnv* env, jobject clazz, jlong r) { int err; BackupDataReader* reader = (BackupDataReader*)r; @@ -123,12 +123,12 @@ skipEntityData_native(JNIEnv* env, jobject clazz, int r) } static const JNINativeMethod g_methods[] = { - { "ctor", "(Ljava/io/FileDescriptor;)I", (void*)ctor_native }, - { "dtor", "(I)V", (void*)dtor_native }, - { "readNextHeader_native", "(ILandroid/app/backup/BackupDataInput$EntityHeader;)I", + { "ctor", "(Ljava/io/FileDescriptor;)J", (void*)ctor_native }, + { "dtor", "(J)V", (void*)dtor_native }, + { "readNextHeader_native", "(JLandroid/app/backup/BackupDataInput$EntityHeader;)I", (void*)readNextHeader_native }, - { "readEntityData_native", "(I[BII)I", (void*)readEntityData_native }, - { "skipEntityData_native", "(I)I", (void*)skipEntityData_native }, + { "readEntityData_native", "(J[BII)I", (void*)readEntityData_native }, + { "skipEntityData_native", "(J)I", (void*)skipEntityData_native }, }; int register_android_backup_BackupDataInput(JNIEnv* env) diff --git a/core/jni/android_backup_BackupDataOutput.cpp b/core/jni/android_backup_BackupDataOutput.cpp index e8f0fb8..8244e1b 100644 --- a/core/jni/android_backup_BackupDataOutput.cpp +++ b/core/jni/android_backup_BackupDataOutput.cpp @@ -25,25 +25,25 @@ namespace android { -static int +static jlong ctor_native(JNIEnv* env, jobject clazz, jobject fileDescriptor) { int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); if (fd == -1) { - return NULL; + return (jlong)NULL; } - return (int)new BackupDataWriter(fd); + return (jlong)new BackupDataWriter(fd); } static void -dtor_native(JNIEnv* env, jobject clazz, int w) +dtor_native(JNIEnv* env, jobject clazz, jlong w) { delete (BackupDataWriter*)w; } static jint -writeEntityHeader_native(JNIEnv* env, jobject clazz, int w, jstring key, int dataSize) +writeEntityHeader_native(JNIEnv* env, jobject clazz, jlong w, jstring key, jint dataSize) { int err; BackupDataWriter* writer = (BackupDataWriter*)w; @@ -56,11 +56,11 @@ writeEntityHeader_native(JNIEnv* env, jobject clazz, int w, jstring key, int dat env->ReleaseStringUTFChars(key, keyUTF); - return err; + return (jint)err; } static jint -writeEntityData_native(JNIEnv* env, jobject clazz, int w, jbyteArray data, int size) +writeEntityData_native(JNIEnv* env, jobject clazz, jlong w, jbyteArray data, jint size) { int err; BackupDataWriter* writer = (BackupDataWriter*)w; @@ -79,11 +79,11 @@ writeEntityData_native(JNIEnv* env, jobject clazz, int w, jbyteArray data, int s env->ReleaseByteArrayElements(data, dataBytes, JNI_ABORT); - return err; + return (jint)err; } static void -setKeyPrefix_native(JNIEnv* env, jobject clazz, int w, jstring keyPrefixObj) +setKeyPrefix_native(JNIEnv* env, jobject clazz, jlong w, jstring keyPrefixObj) { int err; BackupDataWriter* writer = (BackupDataWriter*)w; @@ -97,11 +97,11 @@ setKeyPrefix_native(JNIEnv* env, jobject clazz, int w, jstring keyPrefixObj) } static const JNINativeMethod g_methods[] = { - { "ctor", "(Ljava/io/FileDescriptor;)I", (void*)ctor_native }, - { "dtor", "(I)V", (void*)dtor_native }, - { "writeEntityHeader_native", "(ILjava/lang/String;I)I", (void*)writeEntityHeader_native }, - { "writeEntityData_native", "(I[BI)I", (void*)writeEntityData_native }, - { "setKeyPrefix_native", "(ILjava/lang/String;)V", (void*)setKeyPrefix_native }, + { "ctor", "(Ljava/io/FileDescriptor;)J", (void*)ctor_native }, + { "dtor", "(J)V", (void*)dtor_native }, + { "writeEntityHeader_native", "(JLjava/lang/String;I)I", (void*)writeEntityHeader_native }, + { "writeEntityData_native", "(J[BI)I", (void*)writeEntityData_native }, + { "setKeyPrefix_native", "(JLjava/lang/String;)V", (void*)setKeyPrefix_native }, }; int register_android_backup_BackupDataOutput(JNIEnv* env) diff --git a/core/jni/android_backup_BackupHelperDispatcher.cpp b/core/jni/android_backup_BackupHelperDispatcher.cpp index 3e36677..a8b7d44 100644 --- a/core/jni/android_backup_BackupHelperDispatcher.cpp +++ b/core/jni/android_backup_BackupHelperDispatcher.cpp @@ -40,7 +40,7 @@ struct chunk_header_v1 { static jfieldID s_chunkSizeField = 0; static jfieldID s_keyPrefixField = 0; -static int +static jint readHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj) { chunk_header_v1 flattenedHeader; @@ -52,7 +52,7 @@ readHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj) amt = read(fd, &flattenedHeader.headerSize, sizeof(flattenedHeader.headerSize)); if (amt != sizeof(flattenedHeader.headerSize)) { - return -1; + return (jint) -1; } int remainingHeader = flattenedHeader.headerSize - sizeof(flattenedHeader.headerSize); @@ -62,7 +62,7 @@ readHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj) if (remainingHeader > 0) { lseek(fd, remainingHeader, SEEK_CUR); // >0 means skip this chunk - return 1; + return (jint) 1; } } @@ -70,7 +70,7 @@ readHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj) sizeof(chunk_header_v1)-sizeof(flattenedHeader.headerSize)); if (amt <= 0) { ALOGW("Failed reading chunk header"); - return -1; + return (jint) -1; } remainingHeader -= sizeof(chunk_header_v1)-sizeof(flattenedHeader.headerSize); @@ -80,7 +80,7 @@ readHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj) if (remainingHeader > 0) { lseek(fd, remainingHeader, SEEK_CUR); // >0 means skip this chunk - return 1; + return (jint) 1; } } @@ -96,13 +96,13 @@ readHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj) remainingHeader < flattenedHeader.nameLength) { ALOGW("Malformed V1 header remainingHeader=%d dataSize=%d nameLength=%d", remainingHeader, flattenedHeader.dataSize, flattenedHeader.nameLength); - return -1; + return (jint) -1; } buf = keyPrefix.lockBuffer(flattenedHeader.nameLength); if (buf == NULL) { ALOGW("unable to allocate %d bytes", flattenedHeader.nameLength); - return -1; + return (jint) -1; } amt = read(fd, buf, flattenedHeader.nameLength); @@ -119,17 +119,17 @@ readHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj) env->SetIntField(headerObj, s_chunkSizeField, flattenedHeader.dataSize); env->SetObjectField(headerObj, s_keyPrefixField, env->NewStringUTF(keyPrefix.string())); - return 0; + return (jint) 0; } -static int +static jint skipChunk_native(JNIEnv* env, jobject clazz, jobject fdObj, jint bytesToSkip) { int fd = jniGetFDFromFileDescriptor(env, fdObj); lseek(fd, bytesToSkip, SEEK_CUR); - return 0; + return (jint) 0; } static int @@ -139,7 +139,7 @@ padding_len(int len) return len == 0 ? len : 4 - len; } -static int +static jint allocateHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj) { int pos; @@ -161,10 +161,10 @@ allocateHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdO lseek(fd, headerSize, SEEK_CUR); - return pos; + return (jint) pos; } -static int +static jint writeHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj, jint pos) { int err; @@ -188,26 +188,26 @@ writeHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj, lseek(fd, pos, SEEK_SET); err = write(fd, &header, sizeof(chunk_header_v1)); if (err != sizeof(chunk_header_v1)) { - return errno; + return (jint) errno; } buf = env->GetStringUTFChars(nameObj, NULL); err = write(fd, buf, header.nameLength); env->ReleaseStringUTFChars(nameObj, buf); if (err != header.nameLength) { - return errno; + return (jint) errno; } if (namePadding != 0) { int zero = 0; err = write(fd, &zero, namePadding); if (err != namePadding) { - return errno; + return (jint) errno; } } lseek(fd, prevPos, SEEK_SET); - return 0; + return (jint) 0; } static const JNINativeMethod g_methods[] = { diff --git a/core/jni/android_backup_FileBackupHelperBase.cpp b/core/jni/android_backup_FileBackupHelperBase.cpp index bb3a751..66e3e9d 100644 --- a/core/jni/android_backup_FileBackupHelperBase.cpp +++ b/core/jni/android_backup_FileBackupHelperBase.cpp @@ -25,20 +25,20 @@ namespace android { -static int +static jlong ctor(JNIEnv* env, jobject clazz) { - return (int)new RestoreHelperBase(); + return (jlong)new RestoreHelperBase(); } static void -dtor(JNIEnv* env, jobject clazz, jint ptr) +dtor(JNIEnv* env, jobject clazz, jlong ptr) { delete (RestoreHelperBase*)ptr; } -static int -performBackup_native(JNIEnv* env, jobject clazz, jobject oldState, int data, +static jint +performBackup_native(JNIEnv* env, jobject clazz, jobject oldState, jlong data, jobject newState, jobjectArray files, jobjectArray keys) { int err; @@ -72,12 +72,12 @@ performBackup_native(JNIEnv* env, jobject clazz, jobject oldState, int data, } free(keysUTF); - return err; + return (jint) err; } -static int -writeFile_native(JNIEnv* env, jobject clazz, jint ptr, jstring filenameObj, int backupReaderPtr) +static jint +writeFile_native(JNIEnv* env, jobject clazz, jlong ptr, jstring filenameObj, jlong backupReaderPtr) { int err; RestoreHelperBase* restore = (RestoreHelperBase*)ptr; @@ -90,11 +90,11 @@ writeFile_native(JNIEnv* env, jobject clazz, jint ptr, jstring filenameObj, int env->ReleaseStringUTFChars(filenameObj, filename); - return err; + return (jint) err; } -static int -writeSnapshot_native(JNIEnv* env, jobject clazz, jint ptr, jobject fileDescriptor) +static jint +writeSnapshot_native(JNIEnv* env, jobject clazz, jlong ptr, jobject fileDescriptor) { int err; @@ -103,17 +103,17 @@ writeSnapshot_native(JNIEnv* env, jobject clazz, jint ptr, jobject fileDescripto err = restore->WriteSnapshot(fd); - return err; + return (jint) err; } static const JNINativeMethod g_methods[] = { - { "ctor", "()I", (void*)ctor }, - { "dtor", "(I)V", (void*)dtor }, + { "ctor", "()J", (void*)ctor }, + { "dtor", "(J)V", (void*)dtor }, { "performBackup_native", - "(Ljava/io/FileDescriptor;ILjava/io/FileDescriptor;[Ljava/lang/String;[Ljava/lang/String;)I", + "(Ljava/io/FileDescriptor;JLjava/io/FileDescriptor;[Ljava/lang/String;[Ljava/lang/String;)I", (void*)performBackup_native }, - { "writeFile_native", "(ILjava/lang/String;I)I", (void*)writeFile_native }, - { "writeSnapshot_native", "(ILjava/io/FileDescriptor;)I", (void*)writeSnapshot_native }, + { "writeFile_native", "(JLjava/lang/String;J)I", (void*)writeFile_native }, + { "writeSnapshot_native", "(JLjava/io/FileDescriptor;)I", (void*)writeSnapshot_native }, }; int register_android_backup_FileBackupHelperBase(JNIEnv* env) diff --git a/core/jni/android_database_CursorWindow.cpp b/core/jni/android_database_CursorWindow.cpp index ea02f53..67f3879 100644 --- a/core/jni/android_database_CursorWindow.cpp +++ b/core/jni/android_database_CursorWindow.cpp @@ -58,7 +58,7 @@ static void throwUnknownTypeException(JNIEnv * env, jint type) { jniThrowException(env, "java/lang/IllegalStateException", msg.string()); } -static jint nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursorWindowSize) { +static jlong nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursorWindowSize) { String8 name; const char* nameStr = env->GetStringUTFChars(nameObj, NULL); name.setTo(nameStr); @@ -73,10 +73,10 @@ static jint nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursor } LOG_WINDOW("nativeInitializeEmpty: window = %p", window); - return reinterpret_cast<jint>(window); + return reinterpret_cast<jlong>(window); } -static jint nativeCreateFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) { +static jlong nativeCreateFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) { Parcel* parcel = parcelForJavaObject(env, parcelObj); CursorWindow* window; @@ -88,10 +88,10 @@ static jint nativeCreateFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) LOG_WINDOW("nativeInitializeFromBinder: numRows = %d, numColumns = %d, window = %p", window->getNumRows(), window->getNumColumns(), window); - return reinterpret_cast<jint>(window); + return reinterpret_cast<jlong>(window); } -static void nativeDispose(JNIEnv* env, jclass clazz, jint windowPtr) { +static void nativeDispose(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); if (window) { LOG_WINDOW("Closing window %p", window); @@ -99,12 +99,12 @@ static void nativeDispose(JNIEnv* env, jclass clazz, jint windowPtr) { } } -static jstring nativeGetName(JNIEnv* env, jclass clazz, jint windowPtr) { +static jstring nativeGetName(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); return env->NewStringUTF(window->name().string()); } -static void nativeWriteToParcel(JNIEnv * env, jclass clazz, jint windowPtr, +static void nativeWriteToParcel(JNIEnv * env, jclass clazz, jlong windowPtr, jobject parcelObj) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); Parcel* parcel = parcelForJavaObject(env, parcelObj); @@ -117,7 +117,7 @@ static void nativeWriteToParcel(JNIEnv * env, jclass clazz, jint windowPtr, } } -static void nativeClear(JNIEnv * env, jclass clazz, jint windowPtr) { +static void nativeClear(JNIEnv * env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Clearing window %p", window); status_t status = window->clear(); @@ -126,30 +126,30 @@ static void nativeClear(JNIEnv * env, jclass clazz, jint windowPtr) { } } -static jint nativeGetNumRows(JNIEnv* env, jclass clazz, jint windowPtr) { +static jint nativeGetNumRows(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); return window->getNumRows(); } -static jboolean nativeSetNumColumns(JNIEnv* env, jclass clazz, jint windowPtr, +static jboolean nativeSetNumColumns(JNIEnv* env, jclass clazz, jlong windowPtr, jint columnNum) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->setNumColumns(columnNum); return status == OK; } -static jboolean nativeAllocRow(JNIEnv* env, jclass clazz, jint windowPtr) { +static jboolean nativeAllocRow(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->allocRow(); return status == OK; } -static void nativeFreeLastRow(JNIEnv* env, jclass clazz, jint windowPtr) { +static void nativeFreeLastRow(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); window->freeLastRow(); } -static jint nativeGetType(JNIEnv* env, jclass clazz, jint windowPtr, +static jint nativeGetType(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("returning column type affinity for %d,%d from %p", row, column, window); @@ -164,7 +164,7 @@ static jint nativeGetType(JNIEnv* env, jclass clazz, jint windowPtr, return window->getFieldSlotType(fieldSlot); } -static jbyteArray nativeGetBlob(JNIEnv* env, jclass clazz, jint windowPtr, +static jbyteArray nativeGetBlob(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting blob for %d,%d from %p", row, column, window); @@ -199,7 +199,7 @@ static jbyteArray nativeGetBlob(JNIEnv* env, jclass clazz, jint windowPtr, return NULL; } -static jstring nativeGetString(JNIEnv* env, jclass clazz, jint windowPtr, +static jstring nativeGetString(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting string for %d,%d from %p", row, column, window); @@ -291,7 +291,7 @@ static void clearCharArrayBuffer(JNIEnv* env, jobject bufferObj) { } } -static void nativeCopyStringToBuffer(JNIEnv* env, jclass clazz, jint windowPtr, +static void nativeCopyStringToBuffer(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column, jobject bufferObj) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Copying string for %d,%d from %p", row, column, window); @@ -330,7 +330,7 @@ static void nativeCopyStringToBuffer(JNIEnv* env, jclass clazz, jint windowPtr, } } -static jlong nativeGetLong(JNIEnv* env, jclass clazz, jint windowPtr, +static jlong nativeGetLong(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting long for %d,%d from %p", row, column, window); @@ -361,7 +361,7 @@ static jlong nativeGetLong(JNIEnv* env, jclass clazz, jint windowPtr, } } -static jdouble nativeGetDouble(JNIEnv* env, jclass clazz, jint windowPtr, +static jdouble nativeGetDouble(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting double for %d,%d from %p", row, column, window); @@ -392,7 +392,7 @@ static jdouble nativeGetDouble(JNIEnv* env, jclass clazz, jint windowPtr, } } -static jboolean nativePutBlob(JNIEnv* env, jclass clazz, jint windowPtr, +static jboolean nativePutBlob(JNIEnv* env, jclass clazz, jlong windowPtr, jbyteArray valueObj, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); jsize len = env->GetArrayLength(valueObj); @@ -410,7 +410,7 @@ static jboolean nativePutBlob(JNIEnv* env, jclass clazz, jint windowPtr, return true; } -static jboolean nativePutString(JNIEnv* env, jclass clazz, jint windowPtr, +static jboolean nativePutString(JNIEnv* env, jclass clazz, jlong windowPtr, jstring valueObj, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); @@ -432,7 +432,7 @@ static jboolean nativePutString(JNIEnv* env, jclass clazz, jint windowPtr, return true; } -static jboolean nativePutLong(JNIEnv* env, jclass clazz, jint windowPtr, +static jboolean nativePutLong(JNIEnv* env, jclass clazz, jlong windowPtr, jlong value, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->putLong(row, column, value); @@ -446,7 +446,7 @@ static jboolean nativePutLong(JNIEnv* env, jclass clazz, jint windowPtr, return true; } -static jboolean nativePutDouble(JNIEnv* env, jclass clazz, jint windowPtr, +static jboolean nativePutDouble(JNIEnv* env, jclass clazz, jlong windowPtr, jdouble value, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->putDouble(row, column, value); @@ -460,7 +460,7 @@ static jboolean nativePutDouble(JNIEnv* env, jclass clazz, jint windowPtr, return true; } -static jboolean nativePutNull(JNIEnv* env, jclass clazz, jint windowPtr, +static jboolean nativePutNull(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->putNull(row, column); @@ -477,47 +477,47 @@ static jboolean nativePutNull(JNIEnv* env, jclass clazz, jint windowPtr, static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ - { "nativeCreate", "(Ljava/lang/String;I)I", + { "nativeCreate", "(Ljava/lang/String;I)J", (void*)nativeCreate }, - { "nativeCreateFromParcel", "(Landroid/os/Parcel;)I", + { "nativeCreateFromParcel", "(Landroid/os/Parcel;)J", (void*)nativeCreateFromParcel }, - { "nativeDispose", "(I)V", + { "nativeDispose", "(J)V", (void*)nativeDispose }, - { "nativeWriteToParcel", "(ILandroid/os/Parcel;)V", + { "nativeWriteToParcel", "(JLandroid/os/Parcel;)V", (void*)nativeWriteToParcel }, - { "nativeGetName", "(I)Ljava/lang/String;", + { "nativeGetName", "(J)Ljava/lang/String;", (void*)nativeGetName }, - { "nativeClear", "(I)V", + { "nativeClear", "(J)V", (void*)nativeClear }, - { "nativeGetNumRows", "(I)I", + { "nativeGetNumRows", "(J)I", (void*)nativeGetNumRows }, - { "nativeSetNumColumns", "(II)Z", + { "nativeSetNumColumns", "(JI)Z", (void*)nativeSetNumColumns }, - { "nativeAllocRow", "(I)Z", + { "nativeAllocRow", "(J)Z", (void*)nativeAllocRow }, - { "nativeFreeLastRow", "(I)V", + { "nativeFreeLastRow", "(J)V", (void*)nativeFreeLastRow }, - { "nativeGetType", "(III)I", + { "nativeGetType", "(JII)I", (void*)nativeGetType }, - { "nativeGetBlob", "(III)[B", + { "nativeGetBlob", "(JII)[B", (void*)nativeGetBlob }, - { "nativeGetString", "(III)Ljava/lang/String;", + { "nativeGetString", "(JII)Ljava/lang/String;", (void*)nativeGetString }, - { "nativeGetLong", "(III)J", + { "nativeGetLong", "(JII)J", (void*)nativeGetLong }, - { "nativeGetDouble", "(III)D", + { "nativeGetDouble", "(JII)D", (void*)nativeGetDouble }, - { "nativeCopyStringToBuffer", "(IIILandroid/database/CharArrayBuffer;)V", + { "nativeCopyStringToBuffer", "(JIILandroid/database/CharArrayBuffer;)V", (void*)nativeCopyStringToBuffer }, - { "nativePutBlob", "(I[BII)Z", + { "nativePutBlob", "(J[BII)Z", (void*)nativePutBlob }, - { "nativePutString", "(ILjava/lang/String;II)Z", + { "nativePutString", "(JLjava/lang/String;II)Z", (void*)nativePutString }, - { "nativePutLong", "(IJII)Z", + { "nativePutLong", "(JJII)Z", (void*)nativePutLong }, - { "nativePutDouble", "(IDII)Z", + { "nativePutDouble", "(JDII)Z", (void*)nativePutDouble }, - { "nativePutNull", "(III)Z", + { "nativePutNull", "(JII)Z", (void*)nativePutNull }, }; diff --git a/core/jni/android_database_SQLiteConnection.cpp b/core/jni/android_database_SQLiteConnection.cpp index 6e496fd..ae56432 100644 --- a/core/jni/android_database_SQLiteConnection.cpp +++ b/core/jni/android_database_SQLiteConnection.cpp @@ -109,7 +109,7 @@ static int sqliteProgressHandlerCallback(void* data) { } -static jint nativeOpen(JNIEnv* env, jclass clazz, jstring pathStr, jint openFlags, +static jlong nativeOpen(JNIEnv* env, jclass clazz, jstring pathStr, jint openFlags, jstring labelStr, jboolean enableTrace, jboolean enableProfile) { int sqliteFlags; if (openFlags & SQLiteConnection::CREATE_IF_NECESSARY) { @@ -170,10 +170,10 @@ static jint nativeOpen(JNIEnv* env, jclass clazz, jstring pathStr, jint openFlag } ALOGV("Opened connection %p with label '%s'", db, label.string()); - return reinterpret_cast<jint>(connection); + return reinterpret_cast<jlong>(connection); } -static void nativeClose(JNIEnv* env, jclass clazz, jint connectionPtr) { +static void nativeClose(JNIEnv* env, jclass clazz, jlong connectionPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); if (connection) { @@ -243,7 +243,7 @@ static void sqliteCustomFunctionDestructor(void* data) { env->DeleteGlobalRef(functionObjGlobal); } -static void nativeRegisterCustomFunction(JNIEnv* env, jclass clazz, jint connectionPtr, +static void nativeRegisterCustomFunction(JNIEnv* env, jclass clazz, jlong connectionPtr, jobject functionObj) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); @@ -267,7 +267,7 @@ static void nativeRegisterCustomFunction(JNIEnv* env, jclass clazz, jint connect } } -static void nativeRegisterLocalizedCollators(JNIEnv* env, jclass clazz, jint connectionPtr, +static void nativeRegisterLocalizedCollators(JNIEnv* env, jclass clazz, jlong connectionPtr, jstring localeStr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); @@ -280,7 +280,7 @@ static void nativeRegisterLocalizedCollators(JNIEnv* env, jclass clazz, jint con } } -static jint nativePrepareStatement(JNIEnv* env, jclass clazz, jint connectionPtr, +static jlong nativePrepareStatement(JNIEnv* env, jclass clazz, jlong connectionPtr, jstring sqlString) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); @@ -308,11 +308,11 @@ static jint nativePrepareStatement(JNIEnv* env, jclass clazz, jint connectionPtr } ALOGV("Prepared statement %p on connection %p", statement, connection->db); - return reinterpret_cast<jint>(statement); + return reinterpret_cast<jlong>(statement); } -static void nativeFinalizeStatement(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr) { +static void nativeFinalizeStatement(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -323,32 +323,32 @@ static void nativeFinalizeStatement(JNIEnv* env, jclass clazz, jint connectionPt sqlite3_finalize(statement); } -static jint nativeGetParameterCount(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr) { +static jint nativeGetParameterCount(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); return sqlite3_bind_parameter_count(statement); } -static jboolean nativeIsReadOnly(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr) { +static jboolean nativeIsReadOnly(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); return sqlite3_stmt_readonly(statement) != 0; } -static jint nativeGetColumnCount(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr) { +static jint nativeGetColumnCount(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); return sqlite3_column_count(statement); } -static jstring nativeGetColumnName(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr, jint index) { +static jstring nativeGetColumnName(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr, jint index) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -363,8 +363,8 @@ static jstring nativeGetColumnName(JNIEnv* env, jclass clazz, jint connectionPtr return NULL; } -static void nativeBindNull(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr, jint index) { +static void nativeBindNull(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr, jint index) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -374,8 +374,8 @@ static void nativeBindNull(JNIEnv* env, jclass clazz, jint connectionPtr, } } -static void nativeBindLong(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr, jint index, jlong value) { +static void nativeBindLong(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr, jint index, jlong value) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -385,8 +385,8 @@ static void nativeBindLong(JNIEnv* env, jclass clazz, jint connectionPtr, } } -static void nativeBindDouble(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr, jint index, jdouble value) { +static void nativeBindDouble(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr, jint index, jdouble value) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -396,8 +396,8 @@ static void nativeBindDouble(JNIEnv* env, jclass clazz, jint connectionPtr, } } -static void nativeBindString(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr, jint index, jstring valueString) { +static void nativeBindString(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr, jint index, jstring valueString) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -411,8 +411,8 @@ static void nativeBindString(JNIEnv* env, jclass clazz, jint connectionPtr, } } -static void nativeBindBlob(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr, jint index, jbyteArray valueArray) { +static void nativeBindBlob(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr, jint index, jbyteArray valueArray) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -425,8 +425,8 @@ static void nativeBindBlob(JNIEnv* env, jclass clazz, jint connectionPtr, } } -static void nativeResetStatementAndClearBindings(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr) { +static void nativeResetStatementAndClearBindings(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -450,8 +450,8 @@ static int executeNonQuery(JNIEnv* env, SQLiteConnection* connection, sqlite3_st return err; } -static void nativeExecute(JNIEnv* env, jclass clazz, jint connectionPtr, - jint statementPtr) { +static void nativeExecute(JNIEnv* env, jclass clazz, jlong connectionPtr, + jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -459,7 +459,7 @@ static void nativeExecute(JNIEnv* env, jclass clazz, jint connectionPtr, } static jint nativeExecuteForChangedRowCount(JNIEnv* env, jclass clazz, - jint connectionPtr, jint statementPtr) { + jlong connectionPtr, jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -468,7 +468,7 @@ static jint nativeExecuteForChangedRowCount(JNIEnv* env, jclass clazz, } static jlong nativeExecuteForLastInsertedRowId(JNIEnv* env, jclass clazz, - jint connectionPtr, jint statementPtr) { + jlong connectionPtr, jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -486,7 +486,7 @@ static int executeOneRowQuery(JNIEnv* env, SQLiteConnection* connection, sqlite3 } static jlong nativeExecuteForLong(JNIEnv* env, jclass clazz, - jint connectionPtr, jint statementPtr) { + jlong connectionPtr, jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -498,7 +498,7 @@ static jlong nativeExecuteForLong(JNIEnv* env, jclass clazz, } static jstring nativeExecuteForString(JNIEnv* env, jclass clazz, - jint connectionPtr, jint statementPtr) { + jlong connectionPtr, jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -548,7 +548,7 @@ static int createAshmemRegionWithData(JNIEnv* env, const void* data, size_t leng } static jint nativeExecuteForBlobFileDescriptor(JNIEnv* env, jclass clazz, - jint connectionPtr, jint statementPtr) { + jlong connectionPtr, jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -665,7 +665,7 @@ static CopyRowResult copyRow(JNIEnv* env, CursorWindow* window, } static jlong nativeExecuteForCursorWindow(JNIEnv* env, jclass clazz, - jint connectionPtr, jint statementPtr, jint windowPtr, + jlong connectionPtr, jlong statementPtr, jlong windowPtr, jint startPos, jint requiredPos, jboolean countAllRows) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); @@ -760,7 +760,7 @@ static jlong nativeExecuteForCursorWindow(JNIEnv* env, jclass clazz, return result; } -static jint nativeGetDbLookaside(JNIEnv* env, jobject clazz, jint connectionPtr) { +static jint nativeGetDbLookaside(JNIEnv* env, jobject clazz, jlong connectionPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); int cur = -1; @@ -769,12 +769,12 @@ static jint nativeGetDbLookaside(JNIEnv* env, jobject clazz, jint connectionPtr) return cur; } -static void nativeCancel(JNIEnv* env, jobject clazz, jint connectionPtr) { +static void nativeCancel(JNIEnv* env, jobject clazz, jlong connectionPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); connection->canceled = true; } -static void nativeResetCancel(JNIEnv* env, jobject clazz, jint connectionPtr, +static void nativeResetCancel(JNIEnv* env, jobject clazz, jlong connectionPtr, jboolean cancelable) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); connection->canceled = false; @@ -791,57 +791,57 @@ static void nativeResetCancel(JNIEnv* env, jobject clazz, jint connectionPtr, static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ - { "nativeOpen", "(Ljava/lang/String;ILjava/lang/String;ZZ)I", + { "nativeOpen", "(Ljava/lang/String;ILjava/lang/String;ZZ)J", (void*)nativeOpen }, - { "nativeClose", "(I)V", + { "nativeClose", "(J)V", (void*)nativeClose }, - { "nativeRegisterCustomFunction", "(ILandroid/database/sqlite/SQLiteCustomFunction;)V", + { "nativeRegisterCustomFunction", "(JLandroid/database/sqlite/SQLiteCustomFunction;)V", (void*)nativeRegisterCustomFunction }, - { "nativeRegisterLocalizedCollators", "(ILjava/lang/String;)V", + { "nativeRegisterLocalizedCollators", "(JLjava/lang/String;)V", (void*)nativeRegisterLocalizedCollators }, - { "nativePrepareStatement", "(ILjava/lang/String;)I", + { "nativePrepareStatement", "(JLjava/lang/String;)J", (void*)nativePrepareStatement }, - { "nativeFinalizeStatement", "(II)V", + { "nativeFinalizeStatement", "(JJ)V", (void*)nativeFinalizeStatement }, - { "nativeGetParameterCount", "(II)I", + { "nativeGetParameterCount", "(JJ)I", (void*)nativeGetParameterCount }, - { "nativeIsReadOnly", "(II)Z", + { "nativeIsReadOnly", "(JJ)Z", (void*)nativeIsReadOnly }, - { "nativeGetColumnCount", "(II)I", + { "nativeGetColumnCount", "(JJ)I", (void*)nativeGetColumnCount }, - { "nativeGetColumnName", "(III)Ljava/lang/String;", + { "nativeGetColumnName", "(JJI)Ljava/lang/String;", (void*)nativeGetColumnName }, - { "nativeBindNull", "(III)V", + { "nativeBindNull", "(JJI)V", (void*)nativeBindNull }, - { "nativeBindLong", "(IIIJ)V", + { "nativeBindLong", "(JJIJ)V", (void*)nativeBindLong }, - { "nativeBindDouble", "(IIID)V", + { "nativeBindDouble", "(JJID)V", (void*)nativeBindDouble }, - { "nativeBindString", "(IIILjava/lang/String;)V", + { "nativeBindString", "(JJILjava/lang/String;)V", (void*)nativeBindString }, - { "nativeBindBlob", "(III[B)V", + { "nativeBindBlob", "(JJI[B)V", (void*)nativeBindBlob }, - { "nativeResetStatementAndClearBindings", "(II)V", + { "nativeResetStatementAndClearBindings", "(JJ)V", (void*)nativeResetStatementAndClearBindings }, - { "nativeExecute", "(II)V", + { "nativeExecute", "(JJ)V", (void*)nativeExecute }, - { "nativeExecuteForLong", "(II)J", + { "nativeExecuteForLong", "(JJ)J", (void*)nativeExecuteForLong }, - { "nativeExecuteForString", "(II)Ljava/lang/String;", + { "nativeExecuteForString", "(JJ)Ljava/lang/String;", (void*)nativeExecuteForString }, - { "nativeExecuteForBlobFileDescriptor", "(II)I", + { "nativeExecuteForBlobFileDescriptor", "(JJ)I", (void*)nativeExecuteForBlobFileDescriptor }, - { "nativeExecuteForChangedRowCount", "(II)I", + { "nativeExecuteForChangedRowCount", "(JJ)I", (void*)nativeExecuteForChangedRowCount }, - { "nativeExecuteForLastInsertedRowId", "(II)J", + { "nativeExecuteForLastInsertedRowId", "(JJ)J", (void*)nativeExecuteForLastInsertedRowId }, - { "nativeExecuteForCursorWindow", "(IIIIIZ)J", + { "nativeExecuteForCursorWindow", "(JJJIIZ)J", (void*)nativeExecuteForCursorWindow }, - { "nativeGetDbLookaside", "(I)I", + { "nativeGetDbLookaside", "(J)I", (void*)nativeGetDbLookaside }, - { "nativeCancel", "(I)V", + { "nativeCancel", "(J)V", (void*)nativeCancel }, - { "nativeResetCancel", "(IZ)V", + { "nativeResetCancel", "(JZ)V", (void*)nativeResetCancel }, }; diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index 09d8d0f..58b61ba 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -113,7 +113,7 @@ sp<Camera> get_native_camera(JNIEnv *env, jobject thiz, JNICameraContext** pCont { sp<Camera> camera; Mutex::Autolock _l(sLock); - JNICameraContext* context = reinterpret_cast<JNICameraContext*>(env->GetIntField(thiz, fields.context)); + JNICameraContext* context = reinterpret_cast<JNICameraContext*>(env->GetLongField(thiz, fields.context)); if (context != NULL) { camera = context->getCamera(); } @@ -500,7 +500,7 @@ static void android_hardware_Camera_native_setup(JNIEnv *env, jobject thiz, camera->setListener(context); // save context in opaque field - env->SetIntField(thiz, fields.context, (int)context.get()); + env->SetLongField(thiz, fields.context, (jlong)context.get()); } // disconnect from camera service @@ -515,10 +515,10 @@ static void android_hardware_Camera_release(JNIEnv *env, jobject thiz) sp<Camera> camera; { Mutex::Autolock _l(sLock); - context = reinterpret_cast<JNICameraContext*>(env->GetIntField(thiz, fields.context)); + context = reinterpret_cast<JNICameraContext*>(env->GetLongField(thiz, fields.context)); // Make sure we do not attempt to callback on a deleted Java object. - env->SetIntField(thiz, fields.context, 0); + env->SetLongField(thiz, fields.context, 0); } // clean up if release has not been called before @@ -627,13 +627,13 @@ static void android_hardware_Camera_stopPreview(JNIEnv *env, jobject thiz) c->stopPreview(); } -static bool android_hardware_Camera_previewEnabled(JNIEnv *env, jobject thiz) +static jboolean android_hardware_Camera_previewEnabled(JNIEnv *env, jobject thiz) { ALOGV("previewEnabled"); sp<Camera> c = get_native_camera(env, thiz, NULL); - if (c == 0) return false; + if (c == 0) return JNI_FALSE; - return c->previewEnabled(); + return c->previewEnabled() ? JNI_TRUE : JNI_FALSE; } static void android_hardware_Camera_setHasPreviewCallback(JNIEnv *env, jobject thiz, jboolean installed, jboolean manualBuffer) @@ -651,10 +651,10 @@ static void android_hardware_Camera_setHasPreviewCallback(JNIEnv *env, jobject t context->setCallbackMode(env, installed, manualBuffer); } -static void android_hardware_Camera_addCallbackBuffer(JNIEnv *env, jobject thiz, jbyteArray bytes, int msgType) { +static void android_hardware_Camera_addCallbackBuffer(JNIEnv *env, jobject thiz, jbyteArray bytes, jint msgType) { ALOGV("addCallbackBuffer: 0x%x", msgType); - JNICameraContext* context = reinterpret_cast<JNICameraContext*>(env->GetIntField(thiz, fields.context)); + JNICameraContext* context = reinterpret_cast<JNICameraContext*>(env->GetLongField(thiz, fields.context)); if (context != NULL) { context->addCallbackBuffer(env, bytes, msgType); @@ -685,7 +685,7 @@ static void android_hardware_Camera_cancelAutoFocus(JNIEnv *env, jobject thiz) } } -static void android_hardware_Camera_takePicture(JNIEnv *env, jobject thiz, int msgType) +static void android_hardware_Camera_takePicture(JNIEnv *env, jobject thiz, jint msgType) { ALOGV("takePicture"); JNICameraContext* context; @@ -999,7 +999,7 @@ static int find_fields(JNIEnv *env, field *fields, int count) int register_android_hardware_Camera(JNIEnv *env) { field fields_to_find[] = { - { "android/hardware/Camera", "mNativeContext", "I", &fields.context }, + { "android/hardware/Camera", "mNativeContext", "J", &fields.context }, { "android/hardware/Camera$CameraInfo", "facing", "I", &fields.facing }, { "android/hardware/Camera$CameraInfo", "orientation", "I", &fields.orientation }, { "android/hardware/Camera$CameraInfo", "canDisableShutterSound", "Z", diff --git a/core/jni/android_hardware_SensorManager.cpp b/core/jni/android_hardware_SensorManager.cpp index 793d1bf..24e0b0a 100644 --- a/core/jni/android_hardware_SensorManager.cpp +++ b/core/jni/android_hardware_SensorManager.cpp @@ -187,7 +187,7 @@ private: } }; -static jint nativeInitSensorEventQueue(JNIEnv *env, jclass clazz, jobject eventQ, jobject msgQ, jfloatArray scratch) { +static jlong nativeInitSensorEventQueue(JNIEnv *env, jclass clazz, jobject eventQ, jobject msgQ, jfloatArray scratch) { SensorManager& mgr(SensorManager::getInstance()); sp<SensorEventQueue> queue(mgr.createEventQueue()); @@ -199,28 +199,28 @@ static jint nativeInitSensorEventQueue(JNIEnv *env, jclass clazz, jobject eventQ sp<Receiver> receiver = new Receiver(queue, messageQueue, eventQ, scratch); receiver->incStrong((void*)nativeInitSensorEventQueue); - return jint(receiver.get()); + return jlong(receiver.get()); } -static jint nativeEnableSensor(JNIEnv *env, jclass clazz, jint eventQ, jint handle, jint rate_us, +static jint nativeEnableSensor(JNIEnv *env, jclass clazz, jlong eventQ, jint handle, jint rate_us, jint maxBatchReportLatency, jint reservedFlags) { sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ)); return receiver->getSensorEventQueue()->enableSensor(handle, rate_us, maxBatchReportLatency, reservedFlags); } -static jint nativeDisableSensor(JNIEnv *env, jclass clazz, jint eventQ, jint handle) { +static jint nativeDisableSensor(JNIEnv *env, jclass clazz, jlong eventQ, jint handle) { sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ)); return receiver->getSensorEventQueue()->disableSensor(handle); } -static void nativeDestroySensorEventQueue(JNIEnv *env, jclass clazz, jint eventQ, jint handle) { +static void nativeDestroySensorEventQueue(JNIEnv *env, jclass clazz, jlong eventQ, jint handle) { sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ)); receiver->destroy(); receiver->decStrong((void*)nativeInitSensorEventQueue); } -static jint nativeFlushSensor(JNIEnv *env, jclass clazz, jint eventQ) { +static jint nativeFlushSensor(JNIEnv *env, jclass clazz, jlong eventQ) { sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ)); return receiver->getSensorEventQueue()->flush(); } @@ -239,23 +239,23 @@ static JNINativeMethod gSystemSensorManagerMethods[] = { static JNINativeMethod gBaseEventQueueMethods[] = { {"nativeInitBaseEventQueue", - "(Landroid/hardware/SystemSensorManager$BaseEventQueue;Landroid/os/MessageQueue;[F)I", + "(Landroid/hardware/SystemSensorManager$BaseEventQueue;Landroid/os/MessageQueue;[F)J", (void*)nativeInitSensorEventQueue }, {"nativeEnableSensor", - "(IIIII)I", + "(JIIII)I", (void*)nativeEnableSensor }, {"nativeDisableSensor", - "(II)I", + "(JI)I", (void*)nativeDisableSensor }, {"nativeDestroySensorEventQueue", - "(I)V", + "(J)V", (void*)nativeDestroySensorEventQueue }, {"nativeFlushSensor", - "(I)I", + "(J)I", (void*)nativeFlushSensor }, }; diff --git a/core/jni/android_hardware_UsbDeviceConnection.cpp b/core/jni/android_hardware_UsbDeviceConnection.cpp index cea5bbf..c10b963 100644 --- a/core/jni/android_hardware_UsbDeviceConnection.cpp +++ b/core/jni/android_hardware_UsbDeviceConnection.cpp @@ -35,7 +35,7 @@ static jfieldID field_context; struct usb_device* get_device_from_object(JNIEnv* env, jobject connection) { - return (struct usb_device*)env->GetIntField(connection, field_context); + return (struct usb_device*)env->GetLongField(connection, field_context); } static jboolean @@ -46,19 +46,19 @@ android_hardware_UsbDeviceConnection_open(JNIEnv *env, jobject thiz, jstring dev // duplicate the file descriptor, since ParcelFileDescriptor will eventually close its copy fd = dup(fd); if (fd < 0) - return false; + return JNI_FALSE; const char *deviceNameStr = env->GetStringUTFChars(deviceName, NULL); struct usb_device* device = usb_device_new(deviceNameStr, fd); if (device) { - env->SetIntField(thiz, field_context, (int)device); + env->SetLongField(thiz, field_context, (jlong)device); } else { ALOGE("usb_device_open failed for %s", deviceNameStr); close(fd); } env->ReleaseStringUTFChars(deviceName, deviceNameStr); - return (device != NULL); + return (device != NULL) ? JNI_TRUE : JNI_FALSE; } static void @@ -68,7 +68,7 @@ android_hardware_UsbDeviceConnection_close(JNIEnv *env, jobject thiz) struct usb_device* device = get_device_from_object(env, thiz); if (device) { usb_device_close(device); - env->SetIntField(thiz, field_context, 0); + env->SetLongField(thiz, field_context, 0); } } @@ -106,12 +106,12 @@ android_hardware_UsbDeviceConnection_get_desc(JNIEnv *env, jobject thiz) static jboolean android_hardware_UsbDeviceConnection_claim_interface(JNIEnv *env, jobject thiz, - int interfaceID, jboolean force) + jint interfaceID, jboolean force) { struct usb_device* device = get_device_from_object(env, thiz); if (!device) { ALOGE("device is closed in native_claim_interface"); - return -1; + return JNI_FALSE; } int ret = usb_device_claim_interface(device, interfaceID); @@ -120,11 +120,11 @@ android_hardware_UsbDeviceConnection_claim_interface(JNIEnv *env, jobject thiz, usb_device_connect_kernel_driver(device, interfaceID, false); ret = usb_device_claim_interface(device, interfaceID); } - return ret == 0; + return (ret == 0) ? JNI_TRUE : JNI_FALSE; } static jint -android_hardware_UsbDeviceConnection_release_interface(JNIEnv *env, jobject thiz, int interfaceID) +android_hardware_UsbDeviceConnection_release_interface(JNIEnv *env, jobject thiz, jint interfaceID) { struct usb_device* device = get_device_from_object(env, thiz); if (!device) { @@ -246,7 +246,7 @@ int register_android_hardware_UsbDeviceConnection(JNIEnv *env) ALOGE("Can't find android/hardware/usb/UsbDeviceConnection"); return -1; } - field_context = env->GetFieldID(clazz, "mNativeContext", "I"); + field_context = env->GetFieldID(clazz, "mNativeContext", "J"); if (field_context == NULL) { ALOGE("Can't find UsbDeviceConnection.mNativeContext"); return -1; diff --git a/core/jni/android_hardware_UsbRequest.cpp b/core/jni/android_hardware_UsbRequest.cpp index 32d5135..01eaec4 100644 --- a/core/jni/android_hardware_UsbRequest.cpp +++ b/core/jni/android_hardware_UsbRequest.cpp @@ -32,7 +32,7 @@ static jfieldID field_context; struct usb_request* get_request_from_object(JNIEnv* env, jobject java_request) { - return (struct usb_request*)env->GetIntField(java_request, field_context); + return (struct usb_request*)env->GetLongField(java_request, field_context); } // in android_hardware_UsbDeviceConnection.cpp @@ -61,7 +61,7 @@ android_hardware_UsbRequest_init(JNIEnv *env, jobject thiz, jobject java_device, struct usb_request* request = usb_request_new(device, &desc); if (request) - env->SetIntField(thiz, field_context, (int)request); + env->SetLongField(thiz, field_context, (jlong)request); return (request != NULL); } @@ -72,7 +72,7 @@ android_hardware_UsbRequest_close(JNIEnv *env, jobject thiz) struct usb_request* request = get_request_from_object(env, thiz); if (request) { usb_request_free(request); - env->SetIntField(thiz, field_context, 0); + env->SetLongField(thiz, field_context, 0); } } @@ -114,14 +114,14 @@ android_hardware_UsbRequest_queue_array(JNIEnv *env, jobject thiz, } } -static int +static jint android_hardware_UsbRequest_dequeue_array(JNIEnv *env, jobject thiz, jbyteArray buffer, jint length, jboolean out) { struct usb_request* request = get_request_from_object(env, thiz); if (!request) { ALOGE("request is closed in native_dequeue"); - return -1; + return (jint) -1; } if (buffer && length && request->buffer && !out) { @@ -130,7 +130,7 @@ android_hardware_UsbRequest_dequeue_array(JNIEnv *env, jobject thiz, } free(request->buffer); env->DeleteGlobalRef((jobject)request->client_data); - return request->actual_length; + return (jint) request->actual_length; } static jboolean @@ -164,17 +164,17 @@ android_hardware_UsbRequest_queue_direct(JNIEnv *env, jobject thiz, } } -static int +static jint android_hardware_UsbRequest_dequeue_direct(JNIEnv *env, jobject thiz) { struct usb_request* request = get_request_from_object(env, thiz); if (!request) { ALOGE("request is closed in native_dequeue"); - return -1; + return (jint) -1; } // all we need to do is delete our global ref env->DeleteGlobalRef((jobject)request->client_data); - return request->actual_length; + return (jint) request->actual_length; } static jboolean @@ -207,7 +207,7 @@ int register_android_hardware_UsbRequest(JNIEnv *env) ALOGE("Can't find android/hardware/usb/UsbRequest"); return -1; } - field_context = env->GetFieldID(clazz, "mNativeContext", "I"); + field_context = env->GetFieldID(clazz, "mNativeContext", "J"); if (field_context == NULL) { ALOGE("Can't find UsbRequest.mNativeContext"); return -1; diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp index 1c43cc5..b22668b 100644 --- a/core/jni/android_media_AudioRecord.cpp +++ b/core/jni/android_media_AudioRecord.cpp @@ -136,7 +136,7 @@ static sp<AudioRecord> getAudioRecord(JNIEnv* env, jobject thiz) { Mutex::Autolock l(sLock); AudioRecord* const ar = - (AudioRecord*)env->GetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj); + (AudioRecord*)env->GetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj); return sp<AudioRecord>(ar); } @@ -144,19 +144,19 @@ static sp<AudioRecord> setAudioRecord(JNIEnv* env, jobject thiz, const sp<AudioR { Mutex::Autolock l(sLock); sp<AudioRecord> old = - (AudioRecord*)env->GetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj); + (AudioRecord*)env->GetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj); if (ar.get()) { ar->incStrong((void*)setAudioRecord); } if (old != 0) { old->decStrong((void*)setAudioRecord); } - env->SetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj, (int)ar.get()); + env->SetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj, (jlong)ar.get()); return old; } // ---------------------------------------------------------------------------- -static int +static jint android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this, jint source, jint sampleRateInHertz, jint channelMask, // Java channel masks map directly to the native definition @@ -168,7 +168,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this, if (!audio_is_input_channel(channelMask)) { ALOGE("Error creating AudioRecord: channel mask %#x is not valid.", channelMask); - return AUDIORECORD_ERROR_SETUP_INVALIDCHANNELMASK; + return (jint) AUDIORECORD_ERROR_SETUP_INVALIDCHANNELMASK; } uint32_t nbChannels = popcount(channelMask); @@ -176,7 +176,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this, if ((audioFormat != ENCODING_PCM_16BIT) && (audioFormat != ENCODING_PCM_8BIT)) { ALOGE("Error creating AudioRecord: unsupported audio format."); - return AUDIORECORD_ERROR_SETUP_INVALIDFORMAT; + return (jint) AUDIORECORD_ERROR_SETUP_INVALIDFORMAT; } int bytesPerSample = audioFormat == ENCODING_PCM_16BIT ? 2 : 1; @@ -185,31 +185,31 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this, if (buffSizeInBytes == 0) { ALOGE("Error creating AudioRecord: frameCount is 0."); - return AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT; + return (jint) AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT; } int frameSize = nbChannels * bytesPerSample; size_t frameCount = buffSizeInBytes / frameSize; if ((uint32_t(source) >= AUDIO_SOURCE_CNT) && (uint32_t(source) != AUDIO_SOURCE_HOTWORD)) { ALOGE("Error creating AudioRecord: unknown source."); - return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE; + return (jint) AUDIORECORD_ERROR_SETUP_INVALIDSOURCE; } jclass clazz = env->GetObjectClass(thiz); if (clazz == NULL) { ALOGE("Can't find %s when setting up callback.", kClassPathName); - return AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED; + return (jint) AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED; } if (jSession == NULL) { ALOGE("Error creating AudioRecord: invalid session ID pointer"); - return AUDIORECORD_ERROR; + return (jint) AUDIORECORD_ERROR; } jint* nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL); if (nSession == NULL) { ALOGE("Error creating AudioRecord: Error retrieving session id pointer"); - return AUDIORECORD_ERROR; + return (jint) AUDIORECORD_ERROR; } int sessionId = nSession[0]; env->ReleasePrimitiveArrayCritical(jSession, nSession, 0); @@ -262,33 +262,33 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this, // save our newly created callback information in the "nativeCallbackCookie" field // of the Java object (in mNativeCallbackCookie) so we can free the memory in finalize() - env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, (int)lpCallbackData); + env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, (jlong)lpCallbackData); - return AUDIORECORD_SUCCESS; + return (jint) AUDIORECORD_SUCCESS; // failure: native_init_failure: env->DeleteGlobalRef(lpCallbackData->audioRecord_class); env->DeleteGlobalRef(lpCallbackData->audioRecord_ref); delete lpCallbackData; - env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0); + env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0); - return AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED; + return (jint) AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED; } // ---------------------------------------------------------------------------- -static int +static jint android_media_AudioRecord_start(JNIEnv *env, jobject thiz, jint event, jint triggerSession) { sp<AudioRecord> lpRecorder = getAudioRecord(env, thiz); if (lpRecorder == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return AUDIORECORD_ERROR; + return (jint) AUDIORECORD_ERROR; } - return android_media_translateRecorderErrorCode( + return (jint) android_media_translateRecorderErrorCode( lpRecorder->start((AudioSystem::sync_event_t)event, triggerSession)); } @@ -319,12 +319,12 @@ static void android_media_AudioRecord_release(JNIEnv *env, jobject thiz) { ALOGV("About to delete lpRecorder: %x\n", (int)lpRecorder.get()); lpRecorder->stop(); - audiorecord_callback_cookie *lpCookie = (audiorecord_callback_cookie *)env->GetIntField( + audiorecord_callback_cookie *lpCookie = (audiorecord_callback_cookie *)env->GetLongField( thiz, javaAudioRecordFields.nativeCallbackCookie); // reset the native resources in the Java object so any attempt to access // them after a call to release fails. - env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0); + env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0); // delete the callback information if (lpCookie) { @@ -585,7 +585,7 @@ int register_android_media_AudioRecord(JNIEnv *env) // mNativeRecorderInJavaObj javaAudioRecordFields.nativeRecorderInJavaObj = env->GetFieldID(audioRecordClass, - JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME, "I"); + JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME, "J"); if (javaAudioRecordFields.nativeRecorderInJavaObj == NULL) { ALOGE("Can't find AudioRecord.%s", JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME); return -1; @@ -593,7 +593,7 @@ int register_android_media_AudioRecord(JNIEnv *env) // mNativeCallbackCookie javaAudioRecordFields.nativeCallbackCookie = env->GetFieldID( audioRecordClass, - JAVA_NATIVECALLBACKINFO_FIELD_NAME, "I"); + JAVA_NATIVECALLBACKINFO_FIELD_NAME, "J"); if (javaAudioRecordFields.nativeCallbackCookie == NULL) { ALOGE("Can't find AudioRecord.%s", JAVA_NATIVECALLBACKINFO_FIELD_NAME); return -1; diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp index 7d99464..a19d111 100644 --- a/core/jni/android_media_AudioSystem.cpp +++ b/core/jni/android_media_AudioSystem.cpp @@ -52,10 +52,10 @@ static int check_AudioSystem_Command(status_t status) return kAudioStatusError; } -static int +static jint android_media_AudioSystem_muteMicrophone(JNIEnv *env, jobject thiz, jboolean on) { - return check_AudioSystem_Command(AudioSystem::muteMicrophone(on)); + return (jint) check_AudioSystem_Command(AudioSystem::muteMicrophone(on)); } static jboolean @@ -91,7 +91,7 @@ android_media_AudioSystem_isSourceActive(JNIEnv *env, jobject thiz, jint source) return state; } -static int +static jint android_media_AudioSystem_setParameters(JNIEnv *env, jobject thiz, jstring keyValuePairs) { const jchar* c_keyValuePairs = env->GetStringCritical(keyValuePairs, 0); @@ -101,7 +101,7 @@ android_media_AudioSystem_setParameters(JNIEnv *env, jobject thiz, jstring keyVa env->ReleaseStringCritical(keyValuePairs, c_keyValuePairs); } int status = check_AudioSystem_Command(AudioSystem::setParameters(0, c_keyValuePairs8)); - return status; + return (jint) status; } static jstring @@ -131,7 +131,7 @@ android_media_AudioSystem_error_callback(status_t err) check_AudioSystem_Command(err)); } -static int +static jint android_media_AudioSystem_setDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jint state, jstring device_address) { const char *c_address = env->GetStringUTFChars(device_address, NULL); @@ -139,60 +139,60 @@ android_media_AudioSystem_setDeviceConnectionState(JNIEnv *env, jobject thiz, ji static_cast <audio_policy_dev_state_t>(state), c_address)); env->ReleaseStringUTFChars(device_address, c_address); - return status; + return (jint) status; } -static int +static jint android_media_AudioSystem_getDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jstring device_address) { const char *c_address = env->GetStringUTFChars(device_address, NULL); int state = static_cast <int>(AudioSystem::getDeviceConnectionState(static_cast <audio_devices_t>(device), c_address)); env->ReleaseStringUTFChars(device_address, c_address); - return state; + return (jint) state; } -static int +static jint android_media_AudioSystem_setPhoneState(JNIEnv *env, jobject thiz, jint state) { - return check_AudioSystem_Command(AudioSystem::setPhoneState((audio_mode_t) state)); + return (jint) check_AudioSystem_Command(AudioSystem::setPhoneState((audio_mode_t) state)); } -static int +static jint android_media_AudioSystem_setForceUse(JNIEnv *env, jobject thiz, jint usage, jint config) { - return check_AudioSystem_Command(AudioSystem::setForceUse(static_cast <audio_policy_force_use_t>(usage), + return (jint) check_AudioSystem_Command(AudioSystem::setForceUse(static_cast <audio_policy_force_use_t>(usage), static_cast <audio_policy_forced_cfg_t>(config))); } -static int +static jint android_media_AudioSystem_getForceUse(JNIEnv *env, jobject thiz, jint usage) { - return static_cast <int>(AudioSystem::getForceUse(static_cast <audio_policy_force_use_t>(usage))); + return static_cast <jint>(AudioSystem::getForceUse(static_cast <audio_policy_force_use_t>(usage))); } -static int +static jint android_media_AudioSystem_initStreamVolume(JNIEnv *env, jobject thiz, jint stream, jint indexMin, jint indexMax) { - return check_AudioSystem_Command(AudioSystem::initStreamVolume(static_cast <audio_stream_type_t>(stream), + return (jint) check_AudioSystem_Command(AudioSystem::initStreamVolume(static_cast <audio_stream_type_t>(stream), indexMin, indexMax)); } -static int +static jint android_media_AudioSystem_setStreamVolumeIndex(JNIEnv *env, jobject thiz, jint stream, jint index, jint device) { - return check_AudioSystem_Command( + return (jint) check_AudioSystem_Command( AudioSystem::setStreamVolumeIndex(static_cast <audio_stream_type_t>(stream), index, (audio_devices_t)device)); } -static int +static jint android_media_AudioSystem_getStreamVolumeIndex(JNIEnv *env, jobject thiz, jint stream, @@ -205,13 +205,13 @@ android_media_AudioSystem_getStreamVolumeIndex(JNIEnv *env, != NO_ERROR) { index = -1; } - return index; + return (jint) index; } -static int +static jint android_media_AudioSystem_setMasterVolume(JNIEnv *env, jobject thiz, jfloat value) { - return check_AudioSystem_Command(AudioSystem::setMasterVolume(value)); + return (jint) check_AudioSystem_Command(AudioSystem::setMasterVolume(value)); } static jfloat @@ -224,10 +224,10 @@ android_media_AudioSystem_getMasterVolume(JNIEnv *env, jobject thiz) return value; } -static int +static jint android_media_AudioSystem_setMasterMute(JNIEnv *env, jobject thiz, jboolean mute) { - return check_AudioSystem_Command(AudioSystem::setMasterMute(mute)); + return (jint) check_AudioSystem_Command(AudioSystem::setMasterMute(mute)); } static jfloat @@ -275,10 +275,10 @@ android_media_AudioSystem_setLowRamDevice(JNIEnv *env, jobject clazz, jboolean i return (jint) AudioSystem::setLowRamDevice((bool) isLowRamDevice); } -static int +static jint android_media_AudioSystem_checkAudioFlinger(JNIEnv *env, jobject clazz) { - return check_AudioSystem_Command(AudioSystem::checkAudioFlinger()); + return (jint) check_AudioSystem_Command(AudioSystem::checkAudioFlinger()); } // ---------------------------------------------------------------------------- diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp index 225bf06..dc8d9d8 100644 --- a/core/jni/android_media_AudioTrack.cpp +++ b/core/jni/android_media_AudioTrack.cpp @@ -174,7 +174,7 @@ static sp<AudioTrack> getAudioTrack(JNIEnv* env, jobject thiz) { Mutex::Autolock l(sLock); AudioTrack* const at = - (AudioTrack*)env->GetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj); + (AudioTrack*)env->GetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj); return sp<AudioTrack>(at); } @@ -182,19 +182,19 @@ static sp<AudioTrack> setAudioTrack(JNIEnv* env, jobject thiz, const sp<AudioTra { Mutex::Autolock l(sLock); sp<AudioTrack> old = - (AudioTrack*)env->GetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj); + (AudioTrack*)env->GetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj); if (at.get()) { at->incStrong((void*)setAudioTrack); } if (old != 0) { old->decStrong((void*)setAudioTrack); } - env->SetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj, (int)at.get()); + env->SetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj, (jlong)at.get()); return old; } // ---------------------------------------------------------------------------- -static int +static jint android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_this, jint streamType, jint sampleRateInHertz, jint javaChannelMask, jint audioFormat, jint buffSizeInBytes, jint memoryMode, jintArray jSession) @@ -206,11 +206,11 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th if (AudioSystem::getOutputFrameCount(&afFrameCount, (audio_stream_type_t) streamType) != NO_ERROR) { ALOGE("Error creating AudioTrack: Could not get AudioSystem frame count."); - return AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM; + return (jint) AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM; } if (AudioSystem::getOutputSamplingRate(&afSampleRate, (audio_stream_type_t) streamType) != NO_ERROR) { ALOGE("Error creating AudioTrack: Could not get AudioSystem sampling rate."); - return AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM; + return (jint) AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM; } // Java channel masks don't map directly to the native definition, but it's a simple shift @@ -219,7 +219,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th if (!audio_is_output_channel(nativeChannelMask)) { ALOGE("Error creating AudioTrack: invalid channel mask %#x.", javaChannelMask); - return AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK; + return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK; } int nbChannels = popcount(nativeChannelMask); @@ -239,7 +239,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th break; default: ALOGE("Error creating AudioTrack: unknown stream type."); - return AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE; + return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE; } // check the format. @@ -247,7 +247,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th if ((audioFormat != ENCODING_PCM_16BIT) && (audioFormat != ENCODING_PCM_8BIT)) { ALOGE("Error creating AudioTrack: unsupported audio format."); - return AUDIOTRACK_ERROR_SETUP_INVALIDFORMAT; + return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDFORMAT; } // for the moment 8bitPCM in MODE_STATIC is not supported natively in the AudioTrack C++ class @@ -272,18 +272,18 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th jclass clazz = env->GetObjectClass(thiz); if (clazz == NULL) { ALOGE("Can't find %s when setting up callback.", kClassPathName); - return AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED; + return (jint) AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED; } if (jSession == NULL) { ALOGE("Error creating AudioTrack: invalid session ID pointer"); - return AUDIOTRACK_ERROR; + return (jint) AUDIOTRACK_ERROR; } jint* nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL); if (nSession == NULL) { ALOGE("Error creating AudioTrack: Error retrieving session id pointer"); - return AUDIOTRACK_ERROR; + return (jint) AUDIOTRACK_ERROR; } int sessionId = nSession[0]; env->ReleasePrimitiveArrayCritical(jSession, nSession, 0); @@ -370,10 +370,10 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th setAudioTrack(env, thiz, lpTrack); // save the JNI resources so we can free them later - //ALOGV("storing lpJniStorage: %x\n", (int)lpJniStorage); - env->SetIntField(thiz, javaAudioTrackFields.jniData, (int)lpJniStorage); + //ALOGV("storing lpJniStorage: %x\n", (long)lpJniStorage); + env->SetLongField(thiz, javaAudioTrackFields.jniData, (jlong)lpJniStorage); - return AUDIOTRACK_SUCCESS; + return (jint) AUDIOTRACK_SUCCESS; // failures: native_init_failure: @@ -383,9 +383,9 @@ native_init_failure: env->DeleteGlobalRef(lpJniStorage->mCallbackData.audioTrack_class); env->DeleteGlobalRef(lpJniStorage->mCallbackData.audioTrack_ref); delete lpJniStorage; - env->SetIntField(thiz, javaAudioTrackFields.jniData, 0); + env->SetLongField(thiz, javaAudioTrackFields.jniData, 0); - return AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED; + return (jint) AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED; } @@ -474,11 +474,11 @@ static void android_media_AudioTrack_native_release(JNIEnv *env, jobject thiz) lpTrack->stop(); // delete the JNI data - AudioTrackJniStorage* pJniStorage = (AudioTrackJniStorage *)env->GetIntField( + AudioTrackJniStorage* pJniStorage = (AudioTrackJniStorage *)env->GetLongField( thiz, javaAudioTrackFields.jniData); // reset the native resources in the Java object so any attempt to access // them after a call to release fails. - env->SetIntField(thiz, javaAudioTrackFields.jniData, 0); + env->SetLongField(thiz, javaAudioTrackFields.jniData, 0); if (pJniStorage) { Mutex::Autolock l(sLock); @@ -955,7 +955,7 @@ int register_android_media_AudioTrack(JNIEnv *env) // nativeTrackInJavaObj javaAudioTrackFields.nativeTrackInJavaObj = env->GetFieldID( audioTrackClass, - JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME, "I"); + JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME, "J"); if (javaAudioTrackFields.nativeTrackInJavaObj == NULL) { ALOGE("Can't find AudioTrack.%s", JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME); return -1; @@ -963,7 +963,7 @@ int register_android_media_AudioTrack(JNIEnv *env) // jniData; javaAudioTrackFields.jniData = env->GetFieldID( audioTrackClass, - JAVA_JNIDATA_FIELD_NAME, "I"); + JAVA_JNIDATA_FIELD_NAME, "J"); if (javaAudioTrackFields.jniData == NULL) { ALOGE("Can't find AudioTrack.%s", JAVA_JNIDATA_FIELD_NAME); return -1; diff --git a/core/jni/android_media_JetPlayer.cpp b/core/jni/android_media_JetPlayer.cpp index 5795aba..69f5711 100644 --- a/core/jni/android_media_JetPlayer.cpp +++ b/core/jni/android_media_JetPlayer.cpp @@ -87,12 +87,12 @@ android_media_JetPlayer_setup(JNIEnv *env, jobject thiz, jobject weak_this, if (result==EAS_SUCCESS) { // save our newly created C++ JetPlayer in the "nativePlayerInJavaObj" field // of the Java object (in mNativePlayerInJavaObj) - env->SetIntField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, (int)lpJet); + env->SetLongField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, (jlong)lpJet); return JNI_TRUE; } else { ALOGE("android_media_JetPlayer_setup(): initialization failed with EAS error code %d", (int)result); delete lpJet; - env->SetIntField(weak_this, javaJetPlayerFields.nativePlayerInJavaObj, 0); + env->SetLongField(weak_this, javaJetPlayerFields.nativePlayerInJavaObj, 0); return JNI_FALSE; } } @@ -103,7 +103,7 @@ static void android_media_JetPlayer_finalize(JNIEnv *env, jobject thiz) { ALOGV("android_media_JetPlayer_finalize(): entering."); - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet != NULL) { lpJet->release(); @@ -119,7 +119,7 @@ static void android_media_JetPlayer_release(JNIEnv *env, jobject thiz) { android_media_JetPlayer_finalize(env, thiz); - env->SetIntField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, 0); + env->SetLongField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, 0); ALOGV("android_media_JetPlayer_release() done"); } @@ -128,7 +128,7 @@ android_media_JetPlayer_release(JNIEnv *env, jobject thiz) static jboolean android_media_JetPlayer_loadFromFile(JNIEnv *env, jobject thiz, jstring path) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -165,7 +165,7 @@ static jboolean android_media_JetPlayer_loadFromFileD(JNIEnv *env, jobject thiz, jobject fileDescriptor, jlong offset, jlong length) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -195,7 +195,7 @@ android_media_JetPlayer_loadFromFileD(JNIEnv *env, jobject thiz, static jboolean android_media_JetPlayer_closeFile(JNIEnv *env, jobject thiz) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -217,7 +217,7 @@ android_media_JetPlayer_closeFile(JNIEnv *env, jobject thiz) static jboolean android_media_JetPlayer_play(JNIEnv *env, jobject thiz) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -241,7 +241,7 @@ android_media_JetPlayer_play(JNIEnv *env, jobject thiz) static jboolean android_media_JetPlayer_pause(JNIEnv *env, jobject thiz) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -271,7 +271,7 @@ android_media_JetPlayer_queueSegment(JNIEnv *env, jobject thiz, jint segmentNum, jint libNum, jint repeatCount, jint transpose, jint muteFlags, jbyte userID) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -298,7 +298,7 @@ android_media_JetPlayer_queueSegmentMuteArray(JNIEnv *env, jobject thiz, jint segmentNum, jint libNum, jint repeatCount, jint transpose, jbooleanArray muteArray, jbyte userID) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -344,7 +344,7 @@ static jboolean android_media_JetPlayer_setMuteFlags(JNIEnv *env, jobject thiz, jint muteFlags /*unsigned?*/, jboolean bSync) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -369,7 +369,7 @@ static jboolean android_media_JetPlayer_setMuteArray(JNIEnv *env, jobject thiz, jbooleanArray muteArray, jboolean bSync) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -415,7 +415,7 @@ static jboolean android_media_JetPlayer_setMuteFlag(JNIEnv *env, jobject thiz, jint trackId, jboolean muteFlag, jboolean bSync) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -441,7 +441,7 @@ android_media_JetPlayer_setMuteFlag(JNIEnv *env, jobject thiz, static jboolean android_media_JetPlayer_triggerClip(JNIEnv *env, jobject thiz, jint clipId) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -466,7 +466,7 @@ android_media_JetPlayer_triggerClip(JNIEnv *env, jobject thiz, jint clipId) static jboolean android_media_JetPlayer_clearQueue(JNIEnv *env, jobject thiz) { - JetPlayer *lpJet = (JetPlayer *)env->GetIntField( + JetPlayer *lpJet = (JetPlayer *)env->GetLongField( thiz, javaJetPlayerFields.nativePlayerInJavaObj); if (lpJet == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -533,7 +533,7 @@ int register_android_media_JetPlayer(JNIEnv *env) // Get the mNativePlayerInJavaObj variable field javaJetPlayerFields.nativePlayerInJavaObj = env->GetFieldID( jetPlayerClass, - JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME, "I"); + JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME, "J"); if (javaJetPlayerFields.nativePlayerInJavaObj == NULL) { ALOGE("Can't find JetPlayer.%s", JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME); return -1; diff --git a/core/jni/android_media_RemoteDisplay.cpp b/core/jni/android_media_RemoteDisplay.cpp index 463be5e..1cd3fbb 100644 --- a/core/jni/android_media_RemoteDisplay.cpp +++ b/core/jni/android_media_RemoteDisplay.cpp @@ -134,7 +134,7 @@ private: // ---------------------------------------------------------------------------- -static jint nativeListen(JNIEnv* env, jobject remoteDisplayObj, jstring ifaceStr) { +static jlong nativeListen(JNIEnv* env, jobject remoteDisplayObj, jstring ifaceStr) { ScopedUtfChars iface(env, ifaceStr); sp<IServiceManager> sm = defaultServiceManager(); @@ -155,20 +155,20 @@ static jint nativeListen(JNIEnv* env, jobject remoteDisplayObj, jstring ifaceStr } NativeRemoteDisplay* wrapper = new NativeRemoteDisplay(display, client); - return reinterpret_cast<jint>(wrapper); + return reinterpret_cast<jlong>(wrapper); } -static void nativePause(JNIEnv* env, jobject remoteDisplayObj, jint ptr) { +static void nativePause(JNIEnv* env, jobject remoteDisplayObj, jlong ptr) { NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr); wrapper->pause(); } -static void nativeResume(JNIEnv* env, jobject remoteDisplayObj, jint ptr) { +static void nativeResume(JNIEnv* env, jobject remoteDisplayObj, jlong ptr) { NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr); wrapper->resume(); } -static void nativeDispose(JNIEnv* env, jobject remoteDisplayObj, jint ptr) { +static void nativeDispose(JNIEnv* env, jobject remoteDisplayObj, jlong ptr) { NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr); delete wrapper; } @@ -176,13 +176,13 @@ static void nativeDispose(JNIEnv* env, jobject remoteDisplayObj, jint ptr) { // ---------------------------------------------------------------------------- static JNINativeMethod gMethods[] = { - {"nativeListen", "(Ljava/lang/String;)I", + {"nativeListen", "(Ljava/lang/String;)J", (void*)nativeListen }, - {"nativeDispose", "(I)V", + {"nativeDispose", "(J)V", (void*)nativeDispose }, - {"nativePause", "(I)V", + {"nativePause", "(J)V", (void*)nativePause }, - {"nativeResume", "(I)V", + {"nativeResume", "(J)V", (void*)nativeResume }, }; diff --git a/core/jni/android_media_ToneGenerator.cpp b/core/jni/android_media_ToneGenerator.cpp index 76e42bc..ca00709 100644 --- a/core/jni/android_media_ToneGenerator.cpp +++ b/core/jni/android_media_ToneGenerator.cpp @@ -39,9 +39,9 @@ struct fields_t { static fields_t fields; static jboolean android_media_ToneGenerator_startTone(JNIEnv *env, jobject thiz, jint toneType, jint durationMs) { - ALOGV("android_media_ToneGenerator_startTone: %x", (int)thiz); + ALOGV("android_media_ToneGenerator_startTone: %p", thiz); - ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz, + ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz, fields.context); if (lpToneGen == NULL) { jniThrowRuntimeException(env, "Method called after release()"); @@ -52,12 +52,12 @@ static jboolean android_media_ToneGenerator_startTone(JNIEnv *env, jobject thiz, } static void android_media_ToneGenerator_stopTone(JNIEnv *env, jobject thiz) { - ALOGV("android_media_ToneGenerator_stopTone: %x", (int)thiz); + ALOGV("android_media_ToneGenerator_stopTone: %p", thiz); - ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz, + ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz, fields.context); - ALOGV("ToneGenerator lpToneGen: %x", (unsigned int)lpToneGen); + ALOGV("ToneGenerator lpToneGen: %p", lpToneGen); if (lpToneGen == NULL) { jniThrowRuntimeException(env, "Method called after release()"); return; @@ -66,7 +66,7 @@ static void android_media_ToneGenerator_stopTone(JNIEnv *env, jobject thiz) { } static jint android_media_ToneGenerator_getAudioSessionId(JNIEnv *env, jobject thiz) { - ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz, + ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz, fields.context); if (lpToneGen == NULL) { jniThrowRuntimeException(env, "Method called after release()"); @@ -76,11 +76,11 @@ static jint android_media_ToneGenerator_getAudioSessionId(JNIEnv *env, jobject t } static void android_media_ToneGenerator_release(JNIEnv *env, jobject thiz) { - ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz, + ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz, fields.context); - ALOGV("android_media_ToneGenerator_release lpToneGen: %x", (int)lpToneGen); + ALOGV("android_media_ToneGenerator_release lpToneGen: %p", lpToneGen); - env->SetIntField(thiz, fields.context, 0); + env->SetLongField(thiz, fields.context, 0); delete lpToneGen; } @@ -89,11 +89,11 @@ static void android_media_ToneGenerator_native_setup(JNIEnv *env, jobject thiz, jint streamType, jint volume) { ToneGenerator *lpToneGen = new ToneGenerator((audio_stream_type_t) streamType, AudioSystem::linearToLog(volume), true); - env->SetIntField(thiz, fields.context, 0); + env->SetLongField(thiz, fields.context, 0); - ALOGV("android_media_ToneGenerator_native_setup jobject: %x", (int)thiz); + ALOGV("android_media_ToneGenerator_native_setup jobject: %p", thiz); - ALOGV("ToneGenerator lpToneGen: %x", (unsigned int)lpToneGen); + ALOGV("ToneGenerator lpToneGen: %p", lpToneGen); if (!lpToneGen->isInited()) { ALOGE("ToneGenerator init failed"); @@ -103,16 +103,16 @@ static void android_media_ToneGenerator_native_setup(JNIEnv *env, jobject thiz, } // Stow our new C++ ToneGenerator in an opaque field in the Java object. - env->SetIntField(thiz, fields.context, (int)lpToneGen); + env->SetLongField(thiz, fields.context, (jlong)lpToneGen); - ALOGV("ToneGenerator fields.context: %x", env->GetIntField(thiz, fields.context)); + ALOGV("ToneGenerator fields.context: %p", (void*) env->GetLongField(thiz, fields.context)); } static void android_media_ToneGenerator_native_finalize(JNIEnv *env, jobject thiz) { - ALOGV("android_media_ToneGenerator_native_finalize jobject: %x", (int)thiz); + ALOGV("android_media_ToneGenerator_native_finalize jobject: %p", thiz); - ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz, + ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz, fields.context); if (lpToneGen != NULL) { @@ -142,12 +142,12 @@ int register_android_media_ToneGenerator(JNIEnv *env) { return -1; } - fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.context = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.context == NULL) { ALOGE("Can't find ToneGenerator.mNativeContext"); return -1; } - ALOGV("register_android_media_ToneGenerator ToneGenerator fields.context: %x", (unsigned int)fields.context); + ALOGV("register_android_media_ToneGenerator ToneGenerator fields.context: %p", fields.context); return AndroidRuntime::registerNativeMethods(env, "android/media/ToneGenerator", gMethods, NELEM(gMethods)); diff --git a/core/jni/android_os_MemoryFile.cpp b/core/jni/android_os_MemoryFile.cpp index 7134191..27b29bc 100644 --- a/core/jni/android_os_MemoryFile.cpp +++ b/core/jni/android_os_MemoryFile.cpp @@ -43,19 +43,20 @@ static jobject android_os_MemoryFile_open(JNIEnv* env, jobject clazz, jstring na return jniCreateFileDescriptor(env, result); } -static jint android_os_MemoryFile_mmap(JNIEnv* env, jobject clazz, jobject fileDescriptor, +static jlong android_os_MemoryFile_mmap(JNIEnv* env, jobject clazz, jobject fileDescriptor, jint length, jint prot) { int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - jint result = (jint)mmap(NULL, length, prot, MAP_SHARED, fd, 0); - if (!result) + void* result = mmap(NULL, length, prot, MAP_SHARED, fd, 0); + if (result == MAP_FAILED) { jniThrowException(env, "java/io/IOException", "mmap failed"); - return result; + } + return reinterpret_cast<jlong>(result); } -static void android_os_MemoryFile_munmap(JNIEnv* env, jobject clazz, jint addr, jint length) +static void android_os_MemoryFile_munmap(JNIEnv* env, jobject clazz, jlong addr, jint length) { - int result = munmap((void *)addr, length); + int result = munmap(reinterpret_cast<void *>(addr), length); if (result < 0) jniThrowException(env, "java/io/IOException", "munmap failed"); } @@ -70,7 +71,7 @@ static void android_os_MemoryFile_close(JNIEnv* env, jobject clazz, jobject file } static jint android_os_MemoryFile_read(JNIEnv* env, jobject clazz, - jobject fileDescriptor, jint address, jbyteArray buffer, jint srcOffset, jint destOffset, + jobject fileDescriptor, jlong address, jbyteArray buffer, jint srcOffset, jint destOffset, jint count, jboolean unpinned) { int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); @@ -89,7 +90,7 @@ static jint android_os_MemoryFile_read(JNIEnv* env, jobject clazz, } static jint android_os_MemoryFile_write(JNIEnv* env, jobject clazz, - jobject fileDescriptor, jint address, jbyteArray buffer, jint srcOffset, jint destOffset, + jobject fileDescriptor, jlong address, jbyteArray buffer, jint srcOffset, jint destOffset, jint count, jboolean unpinned) { int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); @@ -138,11 +139,11 @@ static jint android_os_MemoryFile_get_size(JNIEnv* env, jobject clazz, static const JNINativeMethod methods[] = { {"native_open", "(Ljava/lang/String;I)Ljava/io/FileDescriptor;", (void*)android_os_MemoryFile_open}, - {"native_mmap", "(Ljava/io/FileDescriptor;II)I", (void*)android_os_MemoryFile_mmap}, - {"native_munmap", "(II)V", (void*)android_os_MemoryFile_munmap}, + {"native_mmap", "(Ljava/io/FileDescriptor;II)J", (void*)android_os_MemoryFile_mmap}, + {"native_munmap", "(JI)V", (void*)android_os_MemoryFile_munmap}, {"native_close", "(Ljava/io/FileDescriptor;)V", (void*)android_os_MemoryFile_close}, - {"native_read", "(Ljava/io/FileDescriptor;I[BIIIZ)I", (void*)android_os_MemoryFile_read}, - {"native_write", "(Ljava/io/FileDescriptor;I[BIIIZ)V", (void*)android_os_MemoryFile_write}, + {"native_read", "(Ljava/io/FileDescriptor;J[BIIIZ)I", (void*)android_os_MemoryFile_read}, + {"native_write", "(Ljava/io/FileDescriptor;J[BIIIZ)V", (void*)android_os_MemoryFile_write}, {"native_pin", "(Ljava/io/FileDescriptor;Z)V", (void*)android_os_MemoryFile_pin}, {"native_get_size", "(Ljava/io/FileDescriptor;)I", (void*)android_os_MemoryFile_get_size} diff --git a/core/jni/android_os_MessageQueue.cpp b/core/jni/android_os_MessageQueue.cpp index c9c3720..a8ed895 100644 --- a/core/jni/android_os_MessageQueue.cpp +++ b/core/jni/android_os_MessageQueue.cpp @@ -110,11 +110,11 @@ void NativeMessageQueue::wake() { // ---------------------------------------------------------------------------- sp<MessageQueue> android_os_MessageQueue_getMessageQueue(JNIEnv* env, jobject messageQueueObj) { - jint intPtr = env->GetIntField(messageQueueObj, gMessageQueueClassInfo.mPtr); - return reinterpret_cast<NativeMessageQueue*>(intPtr); + jlong ptr = env->GetLongField(messageQueueObj, gMessageQueueClassInfo.mPtr); + return reinterpret_cast<NativeMessageQueue*>(ptr); } -static jint android_os_MessageQueue_nativeInit(JNIEnv* env, jclass clazz) { +static jlong android_os_MessageQueue_nativeInit(JNIEnv* env, jclass clazz) { NativeMessageQueue* nativeMessageQueue = new NativeMessageQueue(); if (!nativeMessageQueue) { jniThrowRuntimeException(env, "Unable to allocate native queue"); @@ -122,26 +122,26 @@ static jint android_os_MessageQueue_nativeInit(JNIEnv* env, jclass clazz) { } nativeMessageQueue->incStrong(env); - return reinterpret_cast<jint>(nativeMessageQueue); + return reinterpret_cast<jlong>(nativeMessageQueue); } -static void android_os_MessageQueue_nativeDestroy(JNIEnv* env, jclass clazz, jint ptr) { +static void android_os_MessageQueue_nativeDestroy(JNIEnv* env, jclass clazz, jlong ptr) { NativeMessageQueue* nativeMessageQueue = reinterpret_cast<NativeMessageQueue*>(ptr); nativeMessageQueue->decStrong(env); } static void android_os_MessageQueue_nativePollOnce(JNIEnv* env, jclass clazz, - jint ptr, jint timeoutMillis) { + jlong ptr, jint timeoutMillis) { NativeMessageQueue* nativeMessageQueue = reinterpret_cast<NativeMessageQueue*>(ptr); nativeMessageQueue->pollOnce(env, timeoutMillis); } -static void android_os_MessageQueue_nativeWake(JNIEnv* env, jclass clazz, jint ptr) { +static void android_os_MessageQueue_nativeWake(JNIEnv* env, jclass clazz, jlong ptr) { NativeMessageQueue* nativeMessageQueue = reinterpret_cast<NativeMessageQueue*>(ptr); return nativeMessageQueue->wake(); } -static jboolean android_os_MessageQueue_nativeIsIdling(JNIEnv* env, jclass clazz, jint ptr) { +static jboolean android_os_MessageQueue_nativeIsIdling(JNIEnv* env, jclass clazz, jlong ptr) { NativeMessageQueue* nativeMessageQueue = reinterpret_cast<NativeMessageQueue*>(ptr); return nativeMessageQueue->getLooper()->isIdling(); } @@ -150,11 +150,11 @@ static jboolean android_os_MessageQueue_nativeIsIdling(JNIEnv* env, jclass clazz static JNINativeMethod gMessageQueueMethods[] = { /* name, signature, funcPtr */ - { "nativeInit", "()I", (void*)android_os_MessageQueue_nativeInit }, - { "nativeDestroy", "(I)V", (void*)android_os_MessageQueue_nativeDestroy }, - { "nativePollOnce", "(II)V", (void*)android_os_MessageQueue_nativePollOnce }, - { "nativeWake", "(I)V", (void*)android_os_MessageQueue_nativeWake }, - { "nativeIsIdling", "(I)Z", (void*)android_os_MessageQueue_nativeIsIdling } + { "nativeInit", "()J", (void*)android_os_MessageQueue_nativeInit }, + { "nativeDestroy", "(J)V", (void*)android_os_MessageQueue_nativeDestroy }, + { "nativePollOnce", "(JI)V", (void*)android_os_MessageQueue_nativePollOnce }, + { "nativeWake", "(J)V", (void*)android_os_MessageQueue_nativeWake }, + { "nativeIsIdling", "(J)Z", (void*)android_os_MessageQueue_nativeIsIdling } }; #define FIND_CLASS(var, className) \ @@ -174,7 +174,7 @@ int register_android_os_MessageQueue(JNIEnv* env) { FIND_CLASS(clazz, "android/os/MessageQueue"); GET_FIELD_ID(gMessageQueueClassInfo.mPtr, clazz, - "mPtr", "I"); + "mPtr", "J"); return 0; } diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp index aa451e3..50f6c73 100644 --- a/core/jni/android_os_Parcel.cpp +++ b/core/jni/android_os_Parcel.cpp @@ -69,7 +69,7 @@ static struct parcel_offsets_t Parcel* parcelForJavaObject(JNIEnv* env, jobject obj) { if (obj) { - Parcel* p = (Parcel*)env->GetIntField(obj, gParcelOffsets.mNativePtr); + Parcel* p = (Parcel*)env->GetLongField(obj, gParcelOffsets.mNativePtr); if (p != NULL) { return p; } @@ -88,31 +88,31 @@ void recycleJavaParcelObject(JNIEnv* env, jobject parcelObj) env->CallVoidMethod(parcelObj, gParcelOffsets.recycle); } -static jint android_os_Parcel_dataSize(JNIEnv* env, jclass clazz, jint nativePtr) +static jint android_os_Parcel_dataSize(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); return parcel ? parcel->dataSize() : 0; } -static jint android_os_Parcel_dataAvail(JNIEnv* env, jclass clazz, jint nativePtr) +static jint android_os_Parcel_dataAvail(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); return parcel ? parcel->dataAvail() : 0; } -static jint android_os_Parcel_dataPosition(JNIEnv* env, jclass clazz, jint nativePtr) +static jint android_os_Parcel_dataPosition(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); return parcel ? parcel->dataPosition() : 0; } -static jint android_os_Parcel_dataCapacity(JNIEnv* env, jclass clazz, jint nativePtr) +static jint android_os_Parcel_dataCapacity(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); return parcel ? parcel->dataCapacity() : 0; } -static void android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jint nativePtr, jint size) +static void android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jlong nativePtr, jint size) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -123,7 +123,7 @@ static void android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jint native } } -static void android_os_Parcel_setDataPosition(JNIEnv* env, jclass clazz, jint nativePtr, jint pos) +static void android_os_Parcel_setDataPosition(JNIEnv* env, jclass clazz, jlong nativePtr, jint pos) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -131,7 +131,7 @@ static void android_os_Parcel_setDataPosition(JNIEnv* env, jclass clazz, jint na } } -static void android_os_Parcel_setDataCapacity(JNIEnv* env, jclass clazz, jint nativePtr, jint size) +static void android_os_Parcel_setDataCapacity(JNIEnv* env, jclass clazz, jlong nativePtr, jint size) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -142,7 +142,7 @@ static void android_os_Parcel_setDataCapacity(JNIEnv* env, jclass clazz, jint na } } -static jboolean android_os_Parcel_pushAllowFds(JNIEnv* env, jclass clazz, jint nativePtr, jboolean allowFds) +static jboolean android_os_Parcel_pushAllowFds(JNIEnv* env, jclass clazz, jlong nativePtr, jboolean allowFds) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); jboolean ret = JNI_TRUE; @@ -152,7 +152,7 @@ static jboolean android_os_Parcel_pushAllowFds(JNIEnv* env, jclass clazz, jint n return ret; } -static void android_os_Parcel_restoreAllowFds(JNIEnv* env, jclass clazz, jint nativePtr, jboolean lastValue) +static void android_os_Parcel_restoreAllowFds(JNIEnv* env, jclass clazz, jlong nativePtr, jboolean lastValue) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -160,7 +160,7 @@ static void android_os_Parcel_restoreAllowFds(JNIEnv* env, jclass clazz, jint na } } -static void android_os_Parcel_writeNative(JNIEnv* env, jclass clazz, jint nativePtr, jobject data, +static void android_os_Parcel_writeNative(JNIEnv* env, jclass clazz, jlong nativePtr, jobject data, jint offset, jint length) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); @@ -187,7 +187,7 @@ static void android_os_Parcel_writeNative(JNIEnv* env, jclass clazz, jint native } } -static void android_os_Parcel_writeInt(JNIEnv* env, jclass clazz, jint nativePtr, jint val) { +static void android_os_Parcel_writeInt(JNIEnv* env, jclass clazz, jlong nativePtr, jint val) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); const status_t err = parcel->writeInt32(val); if (err != NO_ERROR) { @@ -195,7 +195,7 @@ static void android_os_Parcel_writeInt(JNIEnv* env, jclass clazz, jint nativePtr } } -static void android_os_Parcel_writeLong(JNIEnv* env, jclass clazz, jint nativePtr, jlong val) +static void android_os_Parcel_writeLong(JNIEnv* env, jclass clazz, jlong nativePtr, jlong val) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -206,7 +206,7 @@ static void android_os_Parcel_writeLong(JNIEnv* env, jclass clazz, jint nativePt } } -static void android_os_Parcel_writeFloat(JNIEnv* env, jclass clazz, jint nativePtr, jfloat val) +static void android_os_Parcel_writeFloat(JNIEnv* env, jclass clazz, jlong nativePtr, jfloat val) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -217,7 +217,7 @@ static void android_os_Parcel_writeFloat(JNIEnv* env, jclass clazz, jint nativeP } } -static void android_os_Parcel_writeDouble(JNIEnv* env, jclass clazz, jint nativePtr, jdouble val) +static void android_os_Parcel_writeDouble(JNIEnv* env, jclass clazz, jlong nativePtr, jdouble val) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -228,7 +228,7 @@ static void android_os_Parcel_writeDouble(JNIEnv* env, jclass clazz, jint native } } -static void android_os_Parcel_writeString(JNIEnv* env, jclass clazz, jint nativePtr, jstring val) +static void android_os_Parcel_writeString(JNIEnv* env, jclass clazz, jlong nativePtr, jstring val) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -248,7 +248,7 @@ static void android_os_Parcel_writeString(JNIEnv* env, jclass clazz, jint native } } -static void android_os_Parcel_writeStrongBinder(JNIEnv* env, jclass clazz, jint nativePtr, jobject object) +static void android_os_Parcel_writeStrongBinder(JNIEnv* env, jclass clazz, jlong nativePtr, jobject object) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -259,7 +259,7 @@ static void android_os_Parcel_writeStrongBinder(JNIEnv* env, jclass clazz, jint } } -static void android_os_Parcel_writeFileDescriptor(JNIEnv* env, jclass clazz, jint nativePtr, jobject object) +static void android_os_Parcel_writeFileDescriptor(JNIEnv* env, jclass clazz, jlong nativePtr, jobject object) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -271,7 +271,7 @@ static void android_os_Parcel_writeFileDescriptor(JNIEnv* env, jclass clazz, jin } } -static jbyteArray android_os_Parcel_createByteArray(JNIEnv* env, jclass clazz, jint nativePtr) +static jbyteArray android_os_Parcel_createByteArray(JNIEnv* env, jclass clazz, jlong nativePtr) { jbyteArray ret = NULL; @@ -297,7 +297,7 @@ static jbyteArray android_os_Parcel_createByteArray(JNIEnv* env, jclass clazz, j return ret; } -static jint android_os_Parcel_readInt(JNIEnv* env, jclass clazz, jint nativePtr) +static jint android_os_Parcel_readInt(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -306,7 +306,7 @@ static jint android_os_Parcel_readInt(JNIEnv* env, jclass clazz, jint nativePtr) return 0; } -static jlong android_os_Parcel_readLong(JNIEnv* env, jclass clazz, jint nativePtr) +static jlong android_os_Parcel_readLong(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -315,7 +315,7 @@ static jlong android_os_Parcel_readLong(JNIEnv* env, jclass clazz, jint nativePt return 0; } -static jfloat android_os_Parcel_readFloat(JNIEnv* env, jclass clazz, jint nativePtr) +static jfloat android_os_Parcel_readFloat(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -324,7 +324,7 @@ static jfloat android_os_Parcel_readFloat(JNIEnv* env, jclass clazz, jint native return 0; } -static jdouble android_os_Parcel_readDouble(JNIEnv* env, jclass clazz, jint nativePtr) +static jdouble android_os_Parcel_readDouble(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -333,7 +333,7 @@ static jdouble android_os_Parcel_readDouble(JNIEnv* env, jclass clazz, jint nati return 0; } -static jstring android_os_Parcel_readString(JNIEnv* env, jclass clazz, jint nativePtr) +static jstring android_os_Parcel_readString(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -347,7 +347,7 @@ static jstring android_os_Parcel_readString(JNIEnv* env, jclass clazz, jint nati return NULL; } -static jobject android_os_Parcel_readStrongBinder(JNIEnv* env, jclass clazz, jint nativePtr) +static jobject android_os_Parcel_readStrongBinder(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -356,7 +356,7 @@ static jobject android_os_Parcel_readStrongBinder(JNIEnv* env, jclass clazz, jin return NULL; } -static jobject android_os_Parcel_readFileDescriptor(JNIEnv* env, jclass clazz, jint nativePtr) +static jobject android_os_Parcel_readFileDescriptor(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -468,13 +468,13 @@ static void android_os_Parcel_clearFileDescriptor(JNIEnv* env, jclass clazz, job } } -static jint android_os_Parcel_create(JNIEnv* env, jclass clazz) +static jlong android_os_Parcel_create(JNIEnv* env, jclass clazz) { Parcel* parcel = new Parcel(); - return reinterpret_cast<jint>(parcel); + return reinterpret_cast<jlong>(parcel); } -static void android_os_Parcel_freeBuffer(JNIEnv* env, jclass clazz, jint nativePtr) +static void android_os_Parcel_freeBuffer(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -482,13 +482,13 @@ static void android_os_Parcel_freeBuffer(JNIEnv* env, jclass clazz, jint nativeP } } -static void android_os_Parcel_destroy(JNIEnv* env, jclass clazz, jint nativePtr) +static void android_os_Parcel_destroy(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); delete parcel; } -static jbyteArray android_os_Parcel_marshall(JNIEnv* env, jclass clazz, jint nativePtr) +static jbyteArray android_os_Parcel_marshall(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel == NULL) { @@ -517,7 +517,7 @@ static jbyteArray android_os_Parcel_marshall(JNIEnv* env, jclass clazz, jint nat return ret; } -static void android_os_Parcel_unmarshall(JNIEnv* env, jclass clazz, jint nativePtr, +static void android_os_Parcel_unmarshall(JNIEnv* env, jclass clazz, jlong nativePtr, jbyteArray data, jint offset, jint length) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); @@ -538,8 +538,8 @@ static void android_os_Parcel_unmarshall(JNIEnv* env, jclass clazz, jint nativeP } } -static void android_os_Parcel_appendFrom(JNIEnv* env, jclass clazz, jint thisNativePtr, - jint otherNativePtr, jint offset, jint length) +static void android_os_Parcel_appendFrom(JNIEnv* env, jclass clazz, jlong thisNativePtr, + jlong otherNativePtr, jint offset, jint length) { Parcel* thisParcel = reinterpret_cast<Parcel*>(thisNativePtr); if (thisParcel == NULL) { @@ -556,7 +556,7 @@ static void android_os_Parcel_appendFrom(JNIEnv* env, jclass clazz, jint thisNat } } -static jboolean android_os_Parcel_hasFileDescriptors(JNIEnv* env, jclass clazz, jint nativePtr) +static jboolean android_os_Parcel_hasFileDescriptors(JNIEnv* env, jclass clazz, jlong nativePtr) { jboolean ret = JNI_FALSE; Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); @@ -568,7 +568,7 @@ static jboolean android_os_Parcel_hasFileDescriptors(JNIEnv* env, jclass clazz, return ret; } -static void android_os_Parcel_writeInterfaceToken(JNIEnv* env, jclass clazz, jint nativePtr, +static void android_os_Parcel_writeInterfaceToken(JNIEnv* env, jclass clazz, jlong nativePtr, jstring name) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); @@ -583,7 +583,7 @@ static void android_os_Parcel_writeInterfaceToken(JNIEnv* env, jclass clazz, jin } } -static void android_os_Parcel_enforceInterface(JNIEnv* env, jclass clazz, jint nativePtr, jstring name) +static void android_os_Parcel_enforceInterface(JNIEnv* env, jclass clazz, jlong nativePtr, jstring name) { jboolean ret = JNI_FALSE; @@ -622,50 +622,50 @@ static void android_os_Parcel_enforceInterface(JNIEnv* env, jclass clazz, jint n // ---------------------------------------------------------------------------- static const JNINativeMethod gParcelMethods[] = { - {"nativeDataSize", "(I)I", (void*)android_os_Parcel_dataSize}, - {"nativeDataAvail", "(I)I", (void*)android_os_Parcel_dataAvail}, - {"nativeDataPosition", "(I)I", (void*)android_os_Parcel_dataPosition}, - {"nativeDataCapacity", "(I)I", (void*)android_os_Parcel_dataCapacity}, - {"nativeSetDataSize", "(II)V", (void*)android_os_Parcel_setDataSize}, - {"nativeSetDataPosition", "(II)V", (void*)android_os_Parcel_setDataPosition}, - {"nativeSetDataCapacity", "(II)V", (void*)android_os_Parcel_setDataCapacity}, - - {"nativePushAllowFds", "(IZ)Z", (void*)android_os_Parcel_pushAllowFds}, - {"nativeRestoreAllowFds", "(IZ)V", (void*)android_os_Parcel_restoreAllowFds}, - - {"nativeWriteByteArray", "(I[BII)V", (void*)android_os_Parcel_writeNative}, - {"nativeWriteInt", "(II)V", (void*)android_os_Parcel_writeInt}, - {"nativeWriteLong", "(IJ)V", (void*)android_os_Parcel_writeLong}, - {"nativeWriteFloat", "(IF)V", (void*)android_os_Parcel_writeFloat}, - {"nativeWriteDouble", "(ID)V", (void*)android_os_Parcel_writeDouble}, - {"nativeWriteString", "(ILjava/lang/String;)V", (void*)android_os_Parcel_writeString}, - {"nativeWriteStrongBinder", "(ILandroid/os/IBinder;)V", (void*)android_os_Parcel_writeStrongBinder}, - {"nativeWriteFileDescriptor", "(ILjava/io/FileDescriptor;)V", (void*)android_os_Parcel_writeFileDescriptor}, - - {"nativeCreateByteArray", "(I)[B", (void*)android_os_Parcel_createByteArray}, - {"nativeReadInt", "(I)I", (void*)android_os_Parcel_readInt}, - {"nativeReadLong", "(I)J", (void*)android_os_Parcel_readLong}, - {"nativeReadFloat", "(I)F", (void*)android_os_Parcel_readFloat}, - {"nativeReadDouble", "(I)D", (void*)android_os_Parcel_readDouble}, - {"nativeReadString", "(I)Ljava/lang/String;", (void*)android_os_Parcel_readString}, - {"nativeReadStrongBinder", "(I)Landroid/os/IBinder;", (void*)android_os_Parcel_readStrongBinder}, - {"nativeReadFileDescriptor", "(I)Ljava/io/FileDescriptor;", (void*)android_os_Parcel_readFileDescriptor}, + {"nativeDataSize", "(J)I", (void*)android_os_Parcel_dataSize}, + {"nativeDataAvail", "(J)I", (void*)android_os_Parcel_dataAvail}, + {"nativeDataPosition", "(J)I", (void*)android_os_Parcel_dataPosition}, + {"nativeDataCapacity", "(J)I", (void*)android_os_Parcel_dataCapacity}, + {"nativeSetDataSize", "(JI)V", (void*)android_os_Parcel_setDataSize}, + {"nativeSetDataPosition", "(JI)V", (void*)android_os_Parcel_setDataPosition}, + {"nativeSetDataCapacity", "(JI)V", (void*)android_os_Parcel_setDataCapacity}, + + {"nativePushAllowFds", "(JZ)Z", (void*)android_os_Parcel_pushAllowFds}, + {"nativeRestoreAllowFds", "(JZ)V", (void*)android_os_Parcel_restoreAllowFds}, + + {"nativeWriteByteArray", "(J[BII)V", (void*)android_os_Parcel_writeNative}, + {"nativeWriteInt", "(JI)V", (void*)android_os_Parcel_writeInt}, + {"nativeWriteLong", "(JJ)V", (void*)android_os_Parcel_writeLong}, + {"nativeWriteFloat", "(JF)V", (void*)android_os_Parcel_writeFloat}, + {"nativeWriteDouble", "(JD)V", (void*)android_os_Parcel_writeDouble}, + {"nativeWriteString", "(JLjava/lang/String;)V", (void*)android_os_Parcel_writeString}, + {"nativeWriteStrongBinder", "(JLandroid/os/IBinder;)V", (void*)android_os_Parcel_writeStrongBinder}, + {"nativeWriteFileDescriptor", "(JLjava/io/FileDescriptor;)V", (void*)android_os_Parcel_writeFileDescriptor}, + + {"nativeCreateByteArray", "(J)[B", (void*)android_os_Parcel_createByteArray}, + {"nativeReadInt", "(J)I", (void*)android_os_Parcel_readInt}, + {"nativeReadLong", "(J)J", (void*)android_os_Parcel_readLong}, + {"nativeReadFloat", "(J)F", (void*)android_os_Parcel_readFloat}, + {"nativeReadDouble", "(J)D", (void*)android_os_Parcel_readDouble}, + {"nativeReadString", "(J)Ljava/lang/String;", (void*)android_os_Parcel_readString}, + {"nativeReadStrongBinder", "(J)Landroid/os/IBinder;", (void*)android_os_Parcel_readStrongBinder}, + {"nativeReadFileDescriptor", "(J)Ljava/io/FileDescriptor;", (void*)android_os_Parcel_readFileDescriptor}, {"openFileDescriptor", "(Ljava/lang/String;I)Ljava/io/FileDescriptor;", (void*)android_os_Parcel_openFileDescriptor}, {"dupFileDescriptor", "(Ljava/io/FileDescriptor;)Ljava/io/FileDescriptor;", (void*)android_os_Parcel_dupFileDescriptor}, {"closeFileDescriptor", "(Ljava/io/FileDescriptor;)V", (void*)android_os_Parcel_closeFileDescriptor}, {"clearFileDescriptor", "(Ljava/io/FileDescriptor;)V", (void*)android_os_Parcel_clearFileDescriptor}, - {"nativeCreate", "()I", (void*)android_os_Parcel_create}, - {"nativeFreeBuffer", "(I)V", (void*)android_os_Parcel_freeBuffer}, - {"nativeDestroy", "(I)V", (void*)android_os_Parcel_destroy}, + {"nativeCreate", "()J", (void*)android_os_Parcel_create}, + {"nativeFreeBuffer", "(J)V", (void*)android_os_Parcel_freeBuffer}, + {"nativeDestroy", "(J)V", (void*)android_os_Parcel_destroy}, - {"nativeMarshall", "(I)[B", (void*)android_os_Parcel_marshall}, - {"nativeUnmarshall", "(I[BII)V", (void*)android_os_Parcel_unmarshall}, - {"nativeAppendFrom", "(IIII)V", (void*)android_os_Parcel_appendFrom}, - {"nativeHasFileDescriptors", "(I)Z", (void*)android_os_Parcel_hasFileDescriptors}, - {"nativeWriteInterfaceToken", "(ILjava/lang/String;)V", (void*)android_os_Parcel_writeInterfaceToken}, - {"nativeEnforceInterface", "(ILjava/lang/String;)V", (void*)android_os_Parcel_enforceInterface}, + {"nativeMarshall", "(J)[B", (void*)android_os_Parcel_marshall}, + {"nativeUnmarshall", "(J[BII)V", (void*)android_os_Parcel_unmarshall}, + {"nativeAppendFrom", "(JJII)V", (void*)android_os_Parcel_appendFrom}, + {"nativeHasFileDescriptors", "(J)Z", (void*)android_os_Parcel_hasFileDescriptors}, + {"nativeWriteInterfaceToken", "(JLjava/lang/String;)V", (void*)android_os_Parcel_writeInterfaceToken}, + {"nativeEnforceInterface", "(JLjava/lang/String;)V", (void*)android_os_Parcel_enforceInterface}, }; const char* const kParcelPathName = "android/os/Parcel"; @@ -678,7 +678,7 @@ int register_android_os_Parcel(JNIEnv* env) LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.Parcel"); gParcelOffsets.clazz = (jclass) env->NewGlobalRef(clazz); - gParcelOffsets.mNativePtr = env->GetFieldID(clazz, "mNativePtr", "I"); + gParcelOffsets.mNativePtr = env->GetFieldID(clazz, "mNativePtr", "J"); gParcelOffsets.obtain = env->GetStaticMethodID(clazz, "obtain", "()Landroid/os/Parcel;"); gParcelOffsets.recycle = env->GetMethodID(clazz, "recycle", "()V"); diff --git a/core/jni/android_os_SELinux.cpp b/core/jni/android_os_SELinux.cpp index ca278cf..2b85fef 100644 --- a/core/jni/android_os_SELinux.cpp +++ b/core/jni/android_os_SELinux.cpp @@ -443,8 +443,21 @@ static JNINativeMethod method_table[] = { static int log_callback(int type, const char *fmt, ...) { va_list ap; + int priority; + + switch (type) { + case SELINUX_WARNING: + priority = ANDROID_LOG_WARN; + break; + case SELINUX_INFO: + priority = ANDROID_LOG_INFO; + break; + default: + priority = ANDROID_LOG_ERROR; + break; + } va_start(ap, fmt); - LOG_PRI_VA(ANDROID_LOG_ERROR, "SELinux", fmt, ap); + LOG_PRI_VA(priority, "SELinux", fmt, ap); va_end(ap); return 0; } diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index 2c23f9d..8836918 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -229,7 +229,8 @@ static jint android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject } Asset* a = cookie - ? am->openNonAsset((void*)cookie, fileName8.c_str(), (Asset::AccessMode)mode) + ? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(), + (Asset::AccessMode)mode) : am->openNonAsset(fileName8.c_str(), (Asset::AccessMode)mode); if (a == NULL) { @@ -260,7 +261,7 @@ static jobject android_content_AssetManager_openNonAssetFdNative(JNIEnv* env, jo } Asset* a = cookie - ? am->openNonAsset((void*)cookie, fileName8.c_str(), Asset::ACCESS_RANDOM) + ? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(), Asset::ACCESS_RANDOM) : am->openNonAsset(fileName8.c_str(), Asset::ACCESS_RANDOM); if (a == NULL) { @@ -435,10 +436,10 @@ static jint android_content_AssetManager_addAssetPath(JNIEnv* env, jobject clazz return 0; } - void* cookie; + int32_t cookie; bool res = am->addAssetPath(String8(path8.c_str()), &cookie); - return (res) ? (jint)cookie : 0; + return (res) ? static_cast<jint>(cookie) : 0; } static jboolean android_content_AssetManager_isUpToDate(JNIEnv* env, jobject clazz) @@ -800,7 +801,7 @@ static jstring android_content_AssetManager_getCookieName(JNIEnv* env, jobject c if (am == NULL) { return NULL; } - String8 name(am->getAssetPath((void*)cookie)); + String8 name(am->getAssetPath(static_cast<int32_t>(cookie))); if (name.length() == 0) { jniThrowException(env, "java/lang/IndexOutOfBoundsException", "Empty cookie name"); return NULL; @@ -1386,7 +1387,7 @@ static jint android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject } Asset* a = cookie - ? am->openNonAsset((void*)cookie, fileName8.c_str(), Asset::ACCESS_BUFFER) + ? am->openNonAsset(static_cast<int32_t>(cookie), fileName8.c_str(), Asset::ACCESS_BUFFER) : am->openNonAsset(fileName8.c_str(), Asset::ACCESS_BUFFER); if (a == NULL) { diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index 259d030..475e926 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -267,7 +267,7 @@ protected: //data.print(); //printf("\n"); jboolean res = env->CallBooleanMethod(mObject, gBinderOffsets.mExecTransact, - code, (int32_t)&data, (int32_t)reply, flags); + code, reinterpret_cast<jlong>(&data), reinterpret_cast<jlong>(reply), flags); jthrowable excep = env->ExceptionOccurred(); if (excep) { @@ -577,7 +577,7 @@ jobject javaObjectForIBinder(JNIEnv* env, const sp<IBinder>& val) if (object != NULL) { LOGDEATH("objectForBinder %p: created new proxy %p !\n", val.get(), object); // The proxy holds a reference to the native object. - env->SetIntField(object, gBinderProxyOffsets.mObject, (int)val.get()); + env->SetLongField(object, gBinderProxyOffsets.mObject, (jlong)val.get()); val->incStrong((void*)javaObjectForIBinder); // The native object needs to hold a weak reference back to the @@ -590,7 +590,7 @@ jobject javaObjectForIBinder(JNIEnv* env, const sp<IBinder>& val) // Also remember the death recipients registered on this proxy sp<DeathRecipientList> drl = new DeathRecipientList; drl->incStrong((void*)javaObjectForIBinder); - env->SetIntField(object, gBinderProxyOffsets.mOrgue, reinterpret_cast<jint>(drl.get())); + env->SetLongField(object, gBinderProxyOffsets.mOrgue, reinterpret_cast<jlong>(drl.get())); // Note that a new object reference has been created. android_atomic_inc(&gNumProxyRefs); @@ -606,13 +606,13 @@ sp<IBinder> ibinderForJavaObject(JNIEnv* env, jobject obj) if (env->IsInstanceOf(obj, gBinderOffsets.mClass)) { JavaBBinderHolder* jbh = (JavaBBinderHolder*) - env->GetIntField(obj, gBinderOffsets.mObject); + env->GetLongField(obj, gBinderOffsets.mObject); return jbh != NULL ? jbh->get(env, obj) : NULL; } if (env->IsInstanceOf(obj, gBinderProxyOffsets.mClass)) { return (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + env->GetLongField(obj, gBinderProxyOffsets.mObject); } ALOGW("ibinderForJavaObject: %p is not a Binder object", obj); @@ -764,15 +764,15 @@ static void android_os_Binder_init(JNIEnv* env, jobject obj) } ALOGV("Java Binder %p: acquiring first ref on holder %p", obj, jbh); jbh->incStrong((void*)android_os_Binder_init); - env->SetIntField(obj, gBinderOffsets.mObject, (int)jbh); + env->SetLongField(obj, gBinderOffsets.mObject, (jlong)jbh); } static void android_os_Binder_destroy(JNIEnv* env, jobject obj) { JavaBBinderHolder* jbh = (JavaBBinderHolder*) - env->GetIntField(obj, gBinderOffsets.mObject); + env->GetLongField(obj, gBinderOffsets.mObject); if (jbh != NULL) { - env->SetIntField(obj, gBinderOffsets.mObject, 0); + env->SetLongField(obj, gBinderOffsets.mObject, 0); ALOGV("Java Binder %p: removing ref on holder %p", obj, jbh); jbh->decStrong((void*)android_os_Binder_init); } else { @@ -812,11 +812,11 @@ static int int_register_android_os_Binder(JNIEnv* env) gBinderOffsets.mClass = (jclass) env->NewGlobalRef(clazz); gBinderOffsets.mExecTransact - = env->GetMethodID(clazz, "execTransact", "(IIII)Z"); + = env->GetMethodID(clazz, "execTransact", "(IJJI)Z"); assert(gBinderOffsets.mExecTransact); gBinderOffsets.mObject - = env->GetFieldID(clazz, "mObject", "I"); + = env->GetFieldID(clazz, "mObject", "J"); assert(gBinderOffsets.mObject); return AndroidRuntime::registerNativeMethods( @@ -911,7 +911,7 @@ static int int_register_android_os_BinderInternal(JNIEnv* env) static jboolean android_os_BinderProxy_pingBinder(JNIEnv* env, jobject obj) { IBinder* target = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + env->GetLongField(obj, gBinderProxyOffsets.mObject); if (target == NULL) { return JNI_FALSE; } @@ -921,7 +921,7 @@ static jboolean android_os_BinderProxy_pingBinder(JNIEnv* env, jobject obj) static jstring android_os_BinderProxy_getInterfaceDescriptor(JNIEnv* env, jobject obj) { - IBinder* target = (IBinder*) env->GetIntField(obj, gBinderProxyOffsets.mObject); + IBinder* target = (IBinder*) env->GetLongField(obj, gBinderProxyOffsets.mObject); if (target != NULL) { const String16& desc = target->getInterfaceDescriptor(); return env->NewString(desc.string(), desc.size()); @@ -934,7 +934,7 @@ static jstring android_os_BinderProxy_getInterfaceDescriptor(JNIEnv* env, jobjec static jboolean android_os_BinderProxy_isBinderAlive(JNIEnv* env, jobject obj) { IBinder* target = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + env->GetLongField(obj, gBinderProxyOffsets.mObject); if (target == NULL) { return JNI_FALSE; } @@ -1062,7 +1062,7 @@ static jboolean android_os_BinderProxy_transact(JNIEnv* env, jobject obj, } IBinder* target = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + env->GetLongField(obj, gBinderProxyOffsets.mObject); if (target == NULL) { jniThrowException(env, "java/lang/IllegalStateException", "Binder has been finalized!"); return JNI_FALSE; @@ -1109,7 +1109,7 @@ static void android_os_BinderProxy_linkToDeath(JNIEnv* env, jobject obj, } IBinder* target = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + env->GetLongField(obj, gBinderProxyOffsets.mObject); if (target == NULL) { ALOGW("Binder has been finalized when calling linkToDeath() with recip=%p)\n", recipient); assert(false); @@ -1119,7 +1119,7 @@ static void android_os_BinderProxy_linkToDeath(JNIEnv* env, jobject obj, if (!target->localBinder()) { DeathRecipientList* list = (DeathRecipientList*) - env->GetIntField(obj, gBinderProxyOffsets.mOrgue); + env->GetLongField(obj, gBinderProxyOffsets.mOrgue); sp<JavaDeathRecipient> jdr = new JavaDeathRecipient(env, recipient, list); status_t err = target->linkToDeath(jdr, NULL, flags); if (err != NO_ERROR) { @@ -1141,7 +1141,7 @@ static jboolean android_os_BinderProxy_unlinkToDeath(JNIEnv* env, jobject obj, } IBinder* target = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + env->GetLongField(obj, gBinderProxyOffsets.mObject); if (target == NULL) { ALOGW("Binder has been finalized when calling linkToDeath() with recip=%p)\n", recipient); return JNI_FALSE; @@ -1154,7 +1154,7 @@ static jboolean android_os_BinderProxy_unlinkToDeath(JNIEnv* env, jobject obj, // If we find the matching recipient, proceed to unlink using that DeathRecipientList* list = (DeathRecipientList*) - env->GetIntField(obj, gBinderProxyOffsets.mOrgue); + env->GetLongField(obj, gBinderProxyOffsets.mOrgue); sp<JavaDeathRecipient> origJDR = list->find(recipient); LOGDEATH(" unlink found list %p and JDR %p", list, origJDR.get()); if (origJDR != NULL) { @@ -1183,13 +1183,13 @@ static jboolean android_os_BinderProxy_unlinkToDeath(JNIEnv* env, jobject obj, static void android_os_BinderProxy_destroy(JNIEnv* env, jobject obj) { IBinder* b = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + env->GetLongField(obj, gBinderProxyOffsets.mObject); DeathRecipientList* drl = (DeathRecipientList*) - env->GetIntField(obj, gBinderProxyOffsets.mOrgue); + env->GetLongField(obj, gBinderProxyOffsets.mOrgue); LOGDEATH("Destroying BinderProxy %p: binder=%p drl=%p\n", obj, b, drl); - env->SetIntField(obj, gBinderProxyOffsets.mObject, 0); - env->SetIntField(obj, gBinderProxyOffsets.mOrgue, 0); + env->SetLongField(obj, gBinderProxyOffsets.mObject, 0); + env->SetLongField(obj, gBinderProxyOffsets.mOrgue, 0); drl->decStrong((void*)javaObjectForIBinder); b->decStrong((void*)javaObjectForIBinder); @@ -1231,13 +1231,13 @@ static int int_register_android_os_BinderProxy(JNIEnv* env) assert(gBinderProxyOffsets.mSendDeathNotice); gBinderProxyOffsets.mObject - = env->GetFieldID(clazz, "mObject", "I"); + = env->GetFieldID(clazz, "mObject", "J"); assert(gBinderProxyOffsets.mObject); gBinderProxyOffsets.mSelf = env->GetFieldID(clazz, "mSelf", "Ljava/lang/ref/WeakReference;"); assert(gBinderProxyOffsets.mSelf); gBinderProxyOffsets.mOrgue - = env->GetFieldID(clazz, "mOrgue", "I"); + = env->GetFieldID(clazz, "mOrgue", "J"); assert(gBinderProxyOffsets.mOrgue); clazz = env->FindClass("java/lang/Class"); diff --git a/core/jni/android_util_EventLog.cpp b/core/jni/android_util_EventLog.cpp index 83d8aa2..2593420 100644 --- a/core/jni/android_util_EventLog.cpp +++ b/core/jni/android_util_EventLog.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 The Android Open Source Project + * Copyright (C) 2007-2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,8 @@ #include "jni.h" #include "log/logger.h" +#define UNUSED __attribute__((__unused__)) + // The size of the tag number comes out of the payload size. #define MAX_EVENT_PAYLOAD (LOGGER_ENTRY_MAX_PAYLOAD - sizeof(int32_t)) @@ -44,7 +46,8 @@ static jclass gStringClass; * In class android.util.EventLog: * static native int writeEvent(int tag, int value) */ -static jint android_util_EventLog_writeEvent_Integer(JNIEnv* env, jobject clazz, +static jint android_util_EventLog_writeEvent_Integer(JNIEnv* env UNUSED, + jobject clazz UNUSED, jint tag, jint value) { return android_btWriteLog(tag, EVENT_TYPE_INT, &value, sizeof(value)); @@ -54,7 +57,8 @@ static jint android_util_EventLog_writeEvent_Integer(JNIEnv* env, jobject clazz, * In class android.util.EventLog: * static native int writeEvent(long tag, long value) */ -static jint android_util_EventLog_writeEvent_Long(JNIEnv* env, jobject clazz, +static jint android_util_EventLog_writeEvent_Long(JNIEnv* env UNUSED, + jobject clazz UNUSED, jint tag, jlong value) { return android_btWriteLog(tag, EVENT_TYPE_LONG, &value, sizeof(value)); @@ -64,7 +68,8 @@ static jint android_util_EventLog_writeEvent_Long(JNIEnv* env, jobject clazz, * In class android.util.EventLog: * static native int writeEvent(int tag, String value) */ -static jint android_util_EventLog_writeEvent_String(JNIEnv* env, jobject clazz, +static jint android_util_EventLog_writeEvent_String(JNIEnv* env, + jobject clazz UNUSED, jint tag, jstring value) { uint8_t buf[MAX_EVENT_PAYLOAD]; @@ -142,18 +147,21 @@ static jint android_util_EventLog_writeEvent_Array(JNIEnv* env, jobject clazz, * In class android.util.EventLog: * static native void readEvents(int[] tags, Collection<Event> output) * - * Reads events from the event log, typically /dev/log/events + * Reads events from the event log */ -static void android_util_EventLog_readEvents(JNIEnv* env, jobject clazz, +static void android_util_EventLog_readEvents(JNIEnv* env, jobject clazz UNUSED, jintArray tags, jobject out) { + if (tags == NULL || out == NULL) { jniThrowNullPointerException(env, NULL); return; } - int fd = open("/dev/" LOGGER_LOG_EVENTS, O_RDONLY | O_NONBLOCK); - if (fd < 0) { + struct logger_list *logger_list = android_logger_list_open( + LOG_ID_EVENTS, O_RDONLY | O_NONBLOCK, 0, 0); + + if (!logger_list) { jniThrowIOException(env, errno); return; } @@ -161,41 +169,26 @@ static void android_util_EventLog_readEvents(JNIEnv* env, jobject clazz, jsize tagLength = env->GetArrayLength(tags); jint *tagValues = env->GetIntArrayElements(tags, NULL); - uint8_t buf[LOGGER_ENTRY_MAX_LEN]; - struct timeval timeout = {0, 0}; - fd_set readset; - FD_ZERO(&readset); - - for (;;) { - // Use a short select() to try to avoid problems hanging on read(). - // This means we block for 5ms at the end of the log -- oh well. - timeout.tv_usec = 5000; - FD_SET(fd, &readset); - int r = select(fd + 1, &readset, NULL, NULL, &timeout); - if (r == 0) { - break; // no more events - } else if (r < 0 && errno == EINTR) { - continue; // interrupted by signal, try again - } else if (r < 0) { - jniThrowIOException(env, errno); // Will throw on return - break; - } + while (1) { + log_msg log_msg; + int ret = android_logger_list_read(logger_list, &log_msg); - int len = read(fd, buf, sizeof(buf)); - if (len == 0 || (len < 0 && errno == EAGAIN)) { - break; // no more events - } else if (len < 0 && errno == EINTR) { - continue; // interrupted by signal, try again - } else if (len < 0) { - jniThrowIOException(env, errno); // Will throw on return + if (ret == 0) { break; - } else if ((size_t) len < sizeof(logger_entry) + sizeof(int32_t)) { - jniThrowException(env, "java/io/IOException", "Event too short"); + } + if (ret < 0) { + if (errno == EINTR) { + continue; + } + if (errno == EINVAL) { + jniThrowException(env, "java/io/IOException", "Event too short"); + } else if (errno != EAGAIN) { + jniThrowIOException(env, errno); // Will throw on return + } break; } - logger_entry* entry = (logger_entry*) buf; - int32_t tag = * (int32_t*) (buf + sizeof(*entry)); + int32_t tag = * (int32_t *) log_msg.msg(); int found = 0; for (int i = 0; !found && i < tagLength; ++i) { @@ -203,16 +196,20 @@ static void android_util_EventLog_readEvents(JNIEnv* env, jobject clazz, } if (found) { - jsize len = sizeof(*entry) + entry->len; + jsize len = ret; jbyteArray array = env->NewByteArray(len); - if (array == NULL) break; + if (array == NULL) { + break; + } jbyte *bytes = env->GetByteArrayElements(array, NULL); - memcpy(bytes, buf, len); + memcpy(bytes, log_msg.buf, len); env->ReleaseByteArrayElements(array, bytes, 0); jobject event = env->NewObject(gEventClass, gEventInitID, array); - if (event == NULL) break; + if (event == NULL) { + break; + } env->CallBooleanMethod(out, gCollectionAddID, event); env->DeleteLocalRef(event); @@ -220,7 +217,8 @@ static void android_util_EventLog_readEvents(JNIEnv* env, jobject clazz, } } - close(fd); + android_logger_list_close(logger_list); + env->ReleaseIntArrayElements(tags, tagValues, 0); } diff --git a/core/jni/android_view_DisplayEventReceiver.cpp b/core/jni/android_view_DisplayEventReceiver.cpp index 64fb27b..d4cc159 100644 --- a/core/jni/android_view_DisplayEventReceiver.cpp +++ b/core/jni/android_view_DisplayEventReceiver.cpp @@ -87,7 +87,7 @@ status_t NativeDisplayEventReceiver::initialize() { return result; } - int rc = mMessageQueue->getLooper()->addFd(mReceiver.getFd(), 0, ALOOPER_EVENT_INPUT, + int rc = mMessageQueue->getLooper()->addFd(mReceiver.getFd(), 0, Looper::EVENT_INPUT, this, NULL); if (rc < 0) { return UNKNOWN_ERROR; @@ -125,13 +125,13 @@ status_t NativeDisplayEventReceiver::scheduleVsync() { } int NativeDisplayEventReceiver::handleEvent(int receiveFd, int events, void* data) { - if (events & (ALOOPER_EVENT_ERROR | ALOOPER_EVENT_HANGUP)) { + if (events & (Looper::EVENT_ERROR | Looper::EVENT_HANGUP)) { ALOGE("Display event receiver pipe was closed or an error occurred. " "events=0x%x", events); return 0; // remove the callback } - if (!(events & ALOOPER_EVENT_INPUT)) { + if (!(events & Looper::EVENT_INPUT)) { ALOGW("Received spurious callback for unhandled poll event. " "events=0x%x", events); return 1; // keep the callback @@ -207,7 +207,7 @@ void NativeDisplayEventReceiver::dispatchHotplug(nsecs_t timestamp, int32_t id, } -static jint nativeInit(JNIEnv* env, jclass clazz, jobject receiverObj, +static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverObj, jobject messageQueueObj) { sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, messageQueueObj); if (messageQueue == NULL) { @@ -226,17 +226,17 @@ static jint nativeInit(JNIEnv* env, jclass clazz, jobject receiverObj, } receiver->incStrong(gDisplayEventReceiverClassInfo.clazz); // retain a reference for the object - return reinterpret_cast<jint>(receiver.get()); + return reinterpret_cast<jlong>(receiver.get()); } -static void nativeDispose(JNIEnv* env, jclass clazz, jint receiverPtr) { +static void nativeDispose(JNIEnv* env, jclass clazz, jlong receiverPtr) { sp<NativeDisplayEventReceiver> receiver = reinterpret_cast<NativeDisplayEventReceiver*>(receiverPtr); receiver->dispose(); receiver->decStrong(gDisplayEventReceiverClassInfo.clazz); // drop reference held by the object } -static void nativeScheduleVsync(JNIEnv* env, jclass clazz, jint receiverPtr) { +static void nativeScheduleVsync(JNIEnv* env, jclass clazz, jlong receiverPtr) { sp<NativeDisplayEventReceiver> receiver = reinterpret_cast<NativeDisplayEventReceiver*>(receiverPtr); status_t status = receiver->scheduleVsync(); @@ -251,12 +251,12 @@ static void nativeScheduleVsync(JNIEnv* env, jclass clazz, jint receiverPtr) { static JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ { "nativeInit", - "(Landroid/view/DisplayEventReceiver;Landroid/os/MessageQueue;)I", + "(Landroid/view/DisplayEventReceiver;Landroid/os/MessageQueue;)J", (void*)nativeInit }, { "nativeDispose", - "(I)V", + "(J)V", (void*)nativeDispose }, - { "nativeScheduleVsync", "(I)V", + { "nativeScheduleVsync", "(J)V", (void*)nativeScheduleVsync } }; diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp index b720e73..118af1b 100644 --- a/core/jni/android_view_GLES20Canvas.cpp +++ b/core/jni/android_view_GLES20Canvas.cpp @@ -94,17 +94,17 @@ static struct { // ---------------------------------------------------------------------------- static void android_view_GLES20Canvas_flushCaches(JNIEnv* env, jobject clazz, - Caches::FlushMode mode) { + jint mode) { if (Caches::hasInstance()) { - Caches::getInstance().flush(mode); + Caches::getInstance().flush(static_cast<Caches::FlushMode>(mode)); } } -static bool android_view_GLES20Canvas_initCaches(JNIEnv* env, jobject clazz) { +static jboolean android_view_GLES20Canvas_initCaches(JNIEnv* env, jobject clazz) { if (Caches::hasInstance()) { - return Caches::getInstance().init(); + return Caches::getInstance().init() ? JNI_TRUE : JNI_FALSE; } - return false; + return JNI_FALSE; } static void android_view_GLES20Canvas_terminateCaches(JNIEnv* env, jobject clazz) { @@ -132,15 +132,16 @@ static void android_view_GLES20Canvas_initAtlas(JNIEnv* env, jobject clazz, // Constructors // ---------------------------------------------------------------------------- -static OpenGLRenderer* android_view_GLES20Canvas_createRenderer(JNIEnv* env, jobject clazz) { +static jlong android_view_GLES20Canvas_createRenderer(JNIEnv* env, jobject clazz) { RENDERER_LOGD("Create OpenGLRenderer"); OpenGLRenderer* renderer = new OpenGLRenderer(); renderer->initProperties(); - return renderer; + return reinterpret_cast<jlong>(renderer); } static void android_view_GLES20Canvas_destroyRenderer(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer) { + jlong rendererHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); RENDERER_LOGD("Destroy OpenGLRenderer"); delete renderer; } @@ -150,23 +151,27 @@ static void android_view_GLES20Canvas_destroyRenderer(JNIEnv* env, jobject clazz // ---------------------------------------------------------------------------- static void android_view_GLES20Canvas_setViewport(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jint width, jint height) { + jlong rendererHandle, jint width, jint height) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->setViewport(width, height); } -static int android_view_GLES20Canvas_prepare(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jboolean opaque) { +static jint android_view_GLES20Canvas_prepare(JNIEnv* env, jobject clazz, + jlong rendererHandle, jboolean opaque) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); return renderer->prepare(opaque); } -static int android_view_GLES20Canvas_prepareDirty(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jint left, jint top, jint right, jint bottom, +static jint android_view_GLES20Canvas_prepareDirty(JNIEnv* env, jobject clazz, + jlong rendererHandle, jint left, jint top, jint right, jint bottom, jboolean opaque) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); return renderer->prepareDirty(left, top, right, bottom, opaque); } static void android_view_GLES20Canvas_finish(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer) { + jlong rendererHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->finish(); } @@ -175,7 +180,8 @@ static jint android_view_GLES20Canvas_getStencilSize(JNIEnv* env, jobject clazz) } static void android_view_GLES20Canvas_setName(JNIEnv* env, - jobject clazz, OpenGLRenderer* renderer, jstring name) { + jobject clazz, jlong rendererHandle, jstring name) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); if (name != NULL) { const char* textArray = env->GetStringUTFChars(name, NULL); renderer->setName(textArray); @@ -186,12 +192,14 @@ static void android_view_GLES20Canvas_setName(JNIEnv* env, } static void android_view_GLES20Canvas_setCountOverdrawEnabled(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jboolean enabled) { + jlong rendererHandle, jboolean enabled) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->setCountOverdrawEnabled(enabled); } static jfloat android_view_GLES20Canvas_getOverdraw(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer) { + jlong rendererHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); return renderer->getOverdraw(); } @@ -200,23 +208,30 @@ static jfloat android_view_GLES20Canvas_getOverdraw(JNIEnv* env, jobject clazz, // ---------------------------------------------------------------------------- static jint android_view_GLES20Canvas_callDrawGLFunction(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, Functor* functor) { + jlong rendererHandle, jlong functorHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + Functor* functor = reinterpret_cast<Functor*>(functorHandle); android::uirenderer::Rect dirty; return renderer->callDrawGLFunction(functor, dirty); } static void android_view_GLES20Canvas_detachFunctor(JNIEnv* env, - jobject clazz, OpenGLRenderer* renderer, Functor* functor) { + jobject clazz, jlong rendererHandle, jlong functorHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + Functor* functor = reinterpret_cast<Functor*>(functorHandle); renderer->detachFunctor(functor); } static void android_view_GLES20Canvas_attachFunctor(JNIEnv* env, - jobject clazz, OpenGLRenderer* renderer, Functor* functor) { + jobject clazz, jlong rendererHandle, jlong functorHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + Functor* functor = reinterpret_cast<Functor*>(functorHandle); renderer->attachFunctor(functor); } static jint android_view_GLES20Canvas_invokeFunctors(JNIEnv* env, - jobject clazz, OpenGLRenderer* renderer, jobject dirty) { + jobject clazz, jlong rendererHandle, jobject dirty) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); android::uirenderer::Rect bounds; status_t status = renderer->invokeFunctors(bounds); if (status != DrawGlInfo::kStatusDone && dirty != NULL) { @@ -242,23 +257,27 @@ static jint android_view_GLES20Canvas_getMaxTextureHeight(JNIEnv* env, jobject c // State // ---------------------------------------------------------------------------- -static jint android_view_GLES20Canvas_save(JNIEnv* env, jobject clazz, OpenGLRenderer* renderer, +static jint android_view_GLES20Canvas_save(JNIEnv* env, jobject clazz, jlong rendererHandle, jint flags) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); return renderer->save(flags); } static jint android_view_GLES20Canvas_getSaveCount(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer) { + jlong rendererHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); return renderer->getSaveCount(); } static void android_view_GLES20Canvas_restore(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer) { + jlong rendererHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->restore(); } static void android_view_GLES20Canvas_restoreToCount(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jint saveCount) { + jlong rendererHandle, jint saveCount) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->restoreToCount(saveCount); } @@ -267,26 +286,32 @@ static void android_view_GLES20Canvas_restoreToCount(JNIEnv* env, jobject clazz, // ---------------------------------------------------------------------------- static jint android_view_GLES20Canvas_saveLayer(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom, - SkPaint* paint, jint saveFlags) { + jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom, + jlong paintHandle, jint saveFlags) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); return renderer->saveLayer(left, top, right, bottom, paint, saveFlags); } static jint android_view_GLES20Canvas_saveLayerClip(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkPaint* paint, jint saveFlags) { + jlong rendererHandle, jlong paintHandle, jint saveFlags) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const android::uirenderer::Rect& bounds(renderer->getClipBounds()); return renderer->saveLayer(bounds.left, bounds.top, bounds.right, bounds.bottom, paint, saveFlags); } static jint android_view_GLES20Canvas_saveLayerAlpha(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom, + jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom, jint alpha, jint saveFlags) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); return renderer->saveLayerAlpha(left, top, right, bottom, alpha, saveFlags); } static jint android_view_GLES20Canvas_saveLayerAlphaClip(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jint alpha, jint saveFlags) { + jlong rendererHandle, jint alpha, jint saveFlags) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); const android::uirenderer::Rect& bounds(renderer->getClipBounds()); return renderer->saveLayerAlpha(bounds.left, bounds.top, bounds.right, bounds.bottom, alpha, saveFlags); @@ -296,41 +321,57 @@ static jint android_view_GLES20Canvas_saveLayerAlphaClip(JNIEnv* env, jobject cl // Clipping // ---------------------------------------------------------------------------- -static bool android_view_GLES20Canvas_quickReject(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom) { - return renderer->quickRejectNoScissor(left, top, right, bottom); +static jboolean android_view_GLES20Canvas_quickReject(JNIEnv* env, jobject clazz, + jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + bool result = renderer->quickRejectNoScissor(left, top, right, bottom); + return result ? JNI_TRUE : JNI_FALSE; } -static bool android_view_GLES20Canvas_clipRectF(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom, - SkRegion::Op op) { - return renderer->clipRect(left, top, right, bottom, op); +static jboolean android_view_GLES20Canvas_clipRectF(JNIEnv* env, jobject clazz, + jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom, + jint opHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkRegion::Op op = static_cast<SkRegion::Op>(opHandle); + bool result; + result = renderer->clipRect(left, top, right, bottom, op); + return result ? JNI_TRUE : JNI_FALSE; } -static bool android_view_GLES20Canvas_clipRect(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jint left, jint top, jint right, jint bottom, - SkRegion::Op op) { - return renderer->clipRect(float(left), float(top), float(right), float(bottom), op); +static jboolean android_view_GLES20Canvas_clipRect(JNIEnv* env, jobject clazz, + jlong rendererHandle, jint left, jint top, jint right, jint bottom, + jint opHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkRegion::Op op = static_cast<SkRegion::Op>(opHandle); + bool result = renderer->clipRect(float(left), float(top), float(right), float(bottom), op); + return result ? JNI_TRUE : JNI_FALSE; } -static bool android_view_GLES20Canvas_clipPath(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkPath* path, SkRegion::Op op) { - return renderer->clipPath(path, op); +static jboolean android_view_GLES20Canvas_clipPath(JNIEnv* env, jobject clazz, + jlong rendererHandle, jlong pathHandle, jint opHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + SkRegion::Op op = static_cast<SkRegion::Op>(opHandle); + return renderer->clipPath(path, op) ? JNI_TRUE : JNI_FALSE; } -static bool android_view_GLES20Canvas_clipRegion(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkRegion* region, SkRegion::Op op) { - return renderer->clipRegion(region, op); +static jboolean android_view_GLES20Canvas_clipRegion(JNIEnv* env, jobject clazz, + jlong rendererHandle, jlong regionHandle, jint opHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle); + SkRegion::Op op = static_cast<SkRegion::Op>(opHandle); + return renderer->clipRegion(region, op) ? JNI_TRUE : JNI_FALSE; } -static bool android_view_GLES20Canvas_getClipBounds(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jobject rect) { +static jboolean android_view_GLES20Canvas_getClipBounds(JNIEnv* env, jobject clazz, + jlong rendererHandle, jobject rect) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); const android::uirenderer::Rect& bounds(renderer->getClipBounds()); env->CallVoidMethod(rect, gRectClassInfo.set, int(bounds.left), int(bounds.top), int(bounds.right), int(bounds.bottom)); - return !bounds.isEmpty(); + return !bounds.isEmpty() ? JNI_TRUE : JNI_FALSE; } // ---------------------------------------------------------------------------- @@ -338,37 +379,47 @@ static bool android_view_GLES20Canvas_getClipBounds(JNIEnv* env, jobject clazz, // ---------------------------------------------------------------------------- static void android_view_GLES20Canvas_translate(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat dx, jfloat dy) { + jlong rendererHandle, jfloat dx, jfloat dy) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->translate(dx, dy); } static void android_view_GLES20Canvas_rotate(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat degrees) { + jlong rendererHandle, jfloat degrees) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->rotate(degrees); } static void android_view_GLES20Canvas_scale(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat sx, jfloat sy) { + jlong rendererHandle, jfloat sx, jfloat sy) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->scale(sx, sy); } static void android_view_GLES20Canvas_skew(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat sx, jfloat sy) { + jlong rendererHandle, jfloat sx, jfloat sy) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->skew(sx, sy); } static void android_view_GLES20Canvas_setMatrix(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkMatrix* matrix) { + jlong rendererHandle, jlong matrixHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); renderer->setMatrix(matrix); } static void android_view_GLES20Canvas_getMatrix(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkMatrix* matrix) { + jlong rendererHandle, jlong matrixHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); renderer->getMatrix(matrix); } static void android_view_GLES20Canvas_concatMatrix(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkMatrix* matrix) { + jlong rendererHandle, jlong matrixHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); renderer->concatMatrix(matrix); } @@ -377,8 +428,11 @@ static void android_view_GLES20Canvas_concatMatrix(JNIEnv* env, jobject clazz, // ---------------------------------------------------------------------------- static void android_view_GLES20Canvas_drawBitmap(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer, - jfloat left, jfloat top, SkPaint* paint) { + jlong rendererHandle, jlong bitmapHandle, jbyteArray buffer, + jfloat left, jfloat top, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); // This object allows the renderer to allocate a global JNI ref to the buffer object. JavaHeapBitmapRef bitmapRef(env, bitmap, buffer); @@ -386,9 +440,12 @@ static void android_view_GLES20Canvas_drawBitmap(JNIEnv* env, jobject clazz, } static void android_view_GLES20Canvas_drawBitmapRect(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer, - float srcLeft, float srcTop, float srcRight, float srcBottom, - float dstLeft, float dstTop, float dstRight, float dstBottom, SkPaint* paint) { + jlong rendererHandle, jlong bitmapHandle, jbyteArray buffer, + jfloat srcLeft, jfloat srcTop, jfloat srcRight, jfloat srcBottom, + jfloat dstLeft, jfloat dstTop, jfloat dstRight, jfloat dstBottom, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); // This object allows the renderer to allocate a global JNI ref to the buffer object. JavaHeapBitmapRef bitmapRef(env, bitmap, buffer); @@ -397,8 +454,12 @@ static void android_view_GLES20Canvas_drawBitmapRect(JNIEnv* env, jobject clazz, } static void android_view_GLES20Canvas_drawBitmapMatrix(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer, - SkMatrix* matrix, SkPaint* paint) { + jlong rendererHandle, jlong bitmapHandle, jbyteArray buffer, + jlong matrixHandle, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); // This object allows the renderer to allocate a global JNI ref to the buffer object. JavaHeapBitmapRef bitmapRef(env, bitmap, buffer); @@ -406,8 +467,10 @@ static void android_view_GLES20Canvas_drawBitmapMatrix(JNIEnv* env, jobject claz } static void android_view_GLES20Canvas_drawBitmapData(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jintArray colors, jint offset, jint stride, - jfloat left, jfloat top, jint width, jint height, jboolean hasAlpha, SkPaint* paint) { + jlong rendererHandle, jintArray colors, jint offset, jint stride, + jfloat left, jfloat top, jint width, jint height, jboolean hasAlpha, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); SkBitmap* bitmap = new SkBitmap; bitmap->setConfig(hasAlpha ? SkBitmap::kARGB_8888_Config : SkBitmap::kRGB_565_Config, width, height); @@ -431,9 +494,12 @@ static void android_view_GLES20Canvas_drawBitmapData(JNIEnv* env, jobject clazz, } static void android_view_GLES20Canvas_drawBitmapMesh(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer, + jlong rendererHandle, jlong bitmapHandle, jbyteArray buffer, jint meshWidth, jint meshHeight, jfloatArray vertices, jint offset, jintArray colors, - jint colorOffset, SkPaint* paint) { + jint colorOffset, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); // This object allows the renderer to allocate a global JNI ref to the buffer object. JavaHeapBitmapRef bitmapRef(env, bitmap, buffer); @@ -447,8 +513,13 @@ static void android_view_GLES20Canvas_drawBitmapMesh(JNIEnv* env, jobject clazz, } static void android_view_GLES20Canvas_drawPatch(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer, Res_png_9patch* patch, - float left, float top, float right, float bottom, SkPaint* paint) { + jlong rendererHandle, jlong bitmapHandle, jbyteArray buffer, jlong patchHandle, + jfloat left, jfloat top, jfloat right, jfloat bottom, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); + Res_png_9patch* patch = reinterpret_cast<Res_png_9patch*>(patchHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); + // This object allows the renderer to allocate a global JNI ref to the buffer object. JavaHeapBitmapRef bitmapRef(env, bitmap, buffer); @@ -456,41 +527,56 @@ static void android_view_GLES20Canvas_drawPatch(JNIEnv* env, jobject clazz, } static void android_view_GLES20Canvas_drawColor(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jint color, SkXfermode::Mode mode) { + jlong rendererHandle, jint color, SkXfermode::Mode mode) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->drawColor(color, mode); } static void android_view_GLES20Canvas_drawRect(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom, - SkPaint* paint) { + jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom, + jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); renderer->drawRect(left, top, right, bottom, paint); } static void android_view_GLES20Canvas_drawRoundRect(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom, - jfloat rx, jfloat ry, SkPaint* paint) { + jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom, + jfloat rx, jfloat ry, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); renderer->drawRoundRect(left, top, right, bottom, rx, ry, paint); } static void android_view_GLES20Canvas_drawCircle(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat x, jfloat y, jfloat radius, SkPaint* paint) { + jlong rendererHandle, jfloat x, jfloat y, jfloat radius, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); renderer->drawCircle(x, y, radius, paint); } static void android_view_GLES20Canvas_drawOval(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom, - SkPaint* paint) { + jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom, + jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); renderer->drawOval(left, top, right, bottom, paint); } static void android_view_GLES20Canvas_drawArc(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom, - jfloat startAngle, jfloat sweepAngle, jboolean useCenter, SkPaint* paint) { + jlong rendererHandle, jfloat left, jfloat top, jfloat right, jfloat bottom, + jfloat startAngle, jfloat sweepAngle, jboolean useCenter, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); renderer->drawArc(left, top, right, bottom, startAngle, sweepAngle, useCenter, paint); } static void android_view_GLES20Canvas_drawRegionAsRects(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkRegion* region, SkPaint* paint) { + jlong rendererHandle, jlong regionHandle, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); + if (paint->getStyle() != SkPaint::kFill_Style || (paint->isAntiAlias() && !renderer->isCurrentTransformSimple())) { SkRegion::Iterator it(*region); @@ -517,26 +603,35 @@ static void android_view_GLES20Canvas_drawRegionAsRects(JNIEnv* env, jobject cla } static void android_view_GLES20Canvas_drawRects(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloatArray rects, jint count, SkPaint* paint) { + jlong rendererHandle, jfloatArray rects, jint count, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jfloat* storage = env->GetFloatArrayElements(rects, NULL); renderer->drawRects(storage, count, paint); env->ReleaseFloatArrayElements(rects, storage, 0); } static void android_view_GLES20Canvas_drawPoints(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloatArray points, jint offset, jint count, SkPaint* paint) { + jlong rendererHandle, jfloatArray points, jint offset, jint count, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jfloat* storage = env->GetFloatArrayElements(points, NULL); renderer->drawPoints(storage + offset, count, paint); env->ReleaseFloatArrayElements(points, storage, 0); } static void android_view_GLES20Canvas_drawPath(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkPath* path, SkPaint* paint) { + jlong rendererHandle, jlong pathHandle, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); renderer->drawPath(path, paint); } static void android_view_GLES20Canvas_drawLines(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloatArray points, jint offset, jint count, SkPaint* paint) { + jlong rendererHandle, jfloatArray points, jint offset, jint count, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jfloat* storage = env->GetFloatArrayElements(points, NULL); renderer->drawLines(storage + offset, count, paint); env->ReleaseFloatArrayElements(points, storage, 0); @@ -547,24 +642,30 @@ static void android_view_GLES20Canvas_drawLines(JNIEnv* env, jobject clazz, // ---------------------------------------------------------------------------- static void android_view_GLES20Canvas_resetModifiers(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jint modifiers) { + jlong rendererHandle, jint modifiers) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); if (modifiers & MODIFIER_SHADOW) renderer->resetShadow(); if (modifiers & MODIFIER_SHADER) renderer->resetShader(); if (modifiers & MODIFIER_COLOR_FILTER) renderer->resetColorFilter(); } static void android_view_GLES20Canvas_setupShader(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkiaShader* shader) { + jlong rendererHandle, jlong shaderHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkiaShader* shader = reinterpret_cast<SkiaShader*>(shaderHandle); renderer->setupShader(shader); } static void android_view_GLES20Canvas_setupColorFilter(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, SkiaColorFilter* filter) { + jlong rendererHandle, jlong filterHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkiaColorFilter* filter = reinterpret_cast<SkiaColorFilter*>(filterHandle); renderer->setupColorFilter(filter); } static void android_view_GLES20Canvas_setupShadow(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jfloat radius, jfloat dx, jfloat dy, jint color) { + jlong rendererHandle, jfloat radius, jfloat dx, jfloat dy, jint color) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->setupShadow(radius, dx, dy, color); } @@ -573,12 +674,14 @@ static void android_view_GLES20Canvas_setupShadow(JNIEnv* env, jobject clazz, // ---------------------------------------------------------------------------- static void android_view_GLES20Canvas_setupPaintFilter(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jint clearBits, jint setBits) { + jlong rendererHandle, jint clearBits, jint setBits) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->setupPaintFilter(clearBits, setBits); } static void android_view_GLES20Canvas_resetPaintFilter(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer) { + jlong rendererHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->resetPaintFilter(); } @@ -658,24 +761,31 @@ static void renderTextRun(OpenGLRenderer* renderer, const jchar* text, } static void android_view_GLES20Canvas_drawTextArray(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jcharArray text, jint index, jint count, - jfloat x, jfloat y, jint flags, SkPaint* paint) { + jlong rendererHandle, jcharArray text, jint index, jint count, + jfloat x, jfloat y, jint flags, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jchar* textArray = env->GetCharArrayElements(text, NULL); renderText(renderer, textArray + index, count, x, y, flags, paint); env->ReleaseCharArrayElements(text, textArray, JNI_ABORT); } static void android_view_GLES20Canvas_drawText(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jstring text, jint start, jint end, - jfloat x, jfloat y, jint flags, SkPaint* paint) { + jlong rendererHandle, jstring text, jint start, jint end, + jfloat x, jfloat y, jint flags, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* textArray = env->GetStringChars(text, NULL); renderText(renderer, textArray + start, end - start, x, y, flags, paint); env->ReleaseStringChars(text, textArray); } static void android_view_GLES20Canvas_drawTextArrayOnPath(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jcharArray text, jint index, jint count, - SkPath* path, jfloat hOffset, jfloat vOffset, jint flags, SkPaint* paint) { + jlong rendererHandle, jcharArray text, jint index, jint count, + jlong pathHandle, jfloat hOffset, jfloat vOffset, jint flags, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jchar* textArray = env->GetCharArrayElements(text, NULL); renderTextOnPath(renderer, textArray + index, count, path, hOffset, vOffset, flags, paint); @@ -683,8 +793,11 @@ static void android_view_GLES20Canvas_drawTextArrayOnPath(JNIEnv* env, jobject c } static void android_view_GLES20Canvas_drawTextOnPath(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jstring text, jint start, jint end, - SkPath* path, jfloat hOffset, jfloat vOffset, jint flags, SkPaint* paint) { + jlong rendererHandle, jstring text, jint start, jint end, + jlong pathHandle, jfloat hOffset, jfloat vOffset, jint flags, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* textArray = env->GetStringChars(text, NULL); renderTextOnPath(renderer, textArray + start, end - start, path, hOffset, vOffset, flags, paint); @@ -692,9 +805,11 @@ static void android_view_GLES20Canvas_drawTextOnPath(JNIEnv* env, jobject clazz, } static void android_view_GLES20Canvas_drawTextRunArray(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jcharArray text, jint index, jint count, + jlong rendererHandle, jcharArray text, jint index, jint count, jint contextIndex, jint contextCount, jfloat x, jfloat y, jint dirFlags, - SkPaint* paint) { + jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jchar* textArray = env->GetCharArrayElements(text, NULL); renderTextRun(renderer, textArray + contextIndex, index - contextIndex, count, contextCount, x, y, dirFlags, paint); @@ -702,9 +817,11 @@ static void android_view_GLES20Canvas_drawTextRunArray(JNIEnv* env, jobject claz } static void android_view_GLES20Canvas_drawTextRun(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jstring text, jint start, jint end, - jint contextStart, int contextEnd, jfloat x, jfloat y, jint dirFlags, - SkPaint* paint) { + jlong rendererHandle, jstring text, jint start, jint end, + jint contextStart, jint contextEnd, jfloat x, jfloat y, jint dirFlags, + jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* textArray = env->GetStringChars(text, NULL); jint count = end - start; jint contextCount = contextEnd - contextStart; @@ -729,8 +846,10 @@ static void renderPosText(OpenGLRenderer* renderer, const jchar* text, int count } static void android_view_GLES20Canvas_drawPosTextArray(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jcharArray text, jint index, jint count, - jfloatArray pos, SkPaint* paint) { + jlong rendererHandle, jcharArray text, jint index, jint count, + jfloatArray pos, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); jchar* textArray = env->GetCharArrayElements(text, NULL); jfloat* positions = env->GetFloatArrayElements(pos, NULL); @@ -741,8 +860,10 @@ static void android_view_GLES20Canvas_drawPosTextArray(JNIEnv* env, jobject claz } static void android_view_GLES20Canvas_drawPosText(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, jstring text, jint start, jint end, - jfloatArray pos, SkPaint* paint) { + jlong rendererHandle, jstring text, jint start, jint end, + jfloatArray pos, jlong paintHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); const jchar* textArray = env->GetStringChars(text, NULL); jfloat* positions = env->GetFloatArrayElements(pos, NULL); @@ -756,24 +877,31 @@ static void android_view_GLES20Canvas_drawPosText(JNIEnv* env, jobject clazz, // Display lists // ---------------------------------------------------------------------------- -static DisplayList* android_view_GLES20Canvas_getDisplayList(JNIEnv* env, - jobject clazz, DisplayListRenderer* renderer, DisplayList* displayList) { - return renderer->getDisplayList(displayList); +static jlong android_view_GLES20Canvas_getDisplayList(JNIEnv* env, + jobject clazz, jlong rendererHandle, jlong displayListHandle) { + DisplayListRenderer* renderer = reinterpret_cast<DisplayListRenderer*>(rendererHandle); + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); + DisplayList* list = renderer->getDisplayList(displayList); + return reinterpret_cast<jlong>(list); } -static OpenGLRenderer* android_view_GLES20Canvas_createDisplayListRenderer(JNIEnv* env, +static jlong android_view_GLES20Canvas_createDisplayListRenderer(JNIEnv* env, jobject clazz) { - return new DisplayListRenderer; + OpenGLRenderer* renderer = new DisplayListRenderer; + return reinterpret_cast<jlong>(renderer); } static void android_view_GLES20Canvas_resetDisplayListRenderer(JNIEnv* env, - jobject clazz, DisplayListRenderer* renderer) { + jobject clazz, jlong rendererHandle) { + DisplayListRenderer* renderer = reinterpret_cast<DisplayListRenderer*>(rendererHandle); renderer->reset(); } static jint android_view_GLES20Canvas_drawDisplayList(JNIEnv* env, - jobject clazz, OpenGLRenderer* renderer, DisplayList* displayList, + jobject clazz, jlong rendererHandle, jlong displayListHandle, jobject dirty, jint flags) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); android::uirenderer::Rect bounds; status_t status = renderer->drawDisplayList(displayList, bounds, flags); if (status != DrawGlInfo::kStatusDone && dirty != NULL) { @@ -784,7 +912,9 @@ static jint android_view_GLES20Canvas_drawDisplayList(JNIEnv* env, } static void android_view_GLES20Canvas_outputDisplayList(JNIEnv* env, - jobject clazz, OpenGLRenderer* renderer, DisplayList* displayList) { + jobject clazz, jlong rendererHandle, jlong displayListHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); renderer->outputDisplayList(displayList); } @@ -793,26 +923,29 @@ static void android_view_GLES20Canvas_outputDisplayList(JNIEnv* env, // ---------------------------------------------------------------------------- static void android_view_GLES20Canvas_interrupt(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer) { + jlong rendererHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->interrupt(); } static void android_view_GLES20Canvas_resume(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer) { + jlong rendererHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->resume(); } -static OpenGLRenderer* android_view_GLES20Canvas_createLayerRenderer(JNIEnv* env, - jobject clazz, Layer* layer) { +static jlong android_view_GLES20Canvas_createLayerRenderer(JNIEnv* env, + jobject clazz, jlong layerHandle) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); if (layer) { OpenGLRenderer* renderer = new LayerRenderer(layer); renderer->initProperties(); - return renderer; + return reinterpret_cast<jlong>(renderer); } return NULL; } -static Layer* android_view_GLES20Canvas_createTextureLayer(JNIEnv* env, jobject clazz, +static jlong android_view_GLES20Canvas_createTextureLayer(JNIEnv* env, jobject clazz, jboolean isOpaque, jintArray layerInfo) { Layer* layer = LayerRenderer::createTextureLayer(isOpaque); @@ -822,10 +955,10 @@ static Layer* android_view_GLES20Canvas_createTextureLayer(JNIEnv* env, jobject env->ReleaseIntArrayElements(layerInfo, storage, 0); } - return layer; + return reinterpret_cast<jlong>(layer); } -static Layer* android_view_GLES20Canvas_createLayer(JNIEnv* env, jobject clazz, +static jlong android_view_GLES20Canvas_createLayer(JNIEnv* env, jobject clazz, jint width, jint height, jboolean isOpaque, jintArray layerInfo) { Layer* layer = LayerRenderer::createLayer(width, height, isOpaque); @@ -836,44 +969,51 @@ static Layer* android_view_GLES20Canvas_createLayer(JNIEnv* env, jobject clazz, env->ReleaseIntArrayElements(layerInfo, storage, 0); } - return layer; + return reinterpret_cast<jlong>(layer); } -static bool android_view_GLES20Canvas_resizeLayer(JNIEnv* env, jobject clazz, - Layer* layer, jint width, jint height, jintArray layerInfo) { +static jboolean android_view_GLES20Canvas_resizeLayer(JNIEnv* env, jobject clazz, + jlong layerHandle, jint width, jint height, jintArray layerInfo) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); if (LayerRenderer::resizeLayer(layer, width, height)) { jint* storage = env->GetIntArrayElements(layerInfo, NULL); storage[0] = layer->getWidth(); storage[1] = layer->getHeight(); env->ReleaseIntArrayElements(layerInfo, storage, 0); - return true; + return JNI_TRUE; } - return false; + return JNI_FALSE; } static void android_view_GLES20Canvas_setLayerPaint(JNIEnv* env, jobject clazz, - Layer* layer, SkPaint* paint) { + jlong layerHandle, jlong paintHandle) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); + SkPaint* paint = reinterpret_cast<SkPaint*>(paintHandle); if (layer) { layer->setPaint(paint); } } static void android_view_GLES20Canvas_setLayerColorFilter(JNIEnv* env, jobject clazz, - Layer* layer, SkiaColorFilter* colorFilter) { + jlong layerHandle, jlong colorFilterHandle) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); + SkiaColorFilter* colorFilter = reinterpret_cast<SkiaColorFilter*>(colorFilterHandle); if (layer) { layer->setColorFilter(colorFilter); } } static void android_view_GLES20Canvas_setOpaqueLayer(JNIEnv* env, jobject clazz, - Layer* layer, jboolean isOpaque) { + jlong layerHandle, jboolean isOpaque) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); if (layer) { layer->setBlend(!isOpaque); } } static void android_view_GLES20Canvas_updateTextureLayer(JNIEnv* env, jobject clazz, - Layer* layer, jint width, jint height, jboolean isOpaque, jobject surface) { + jlong layerHandle, jint width, jint height, jboolean isOpaque, jobject surface) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); float transform[16]; sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, surface)); @@ -903,57 +1043,75 @@ static void android_view_GLES20Canvas_updateTextureLayer(JNIEnv* env, jobject cl } static void android_view_GLES20Canvas_updateRenderLayer(JNIEnv* env, jobject clazz, - Layer* layer, OpenGLRenderer* renderer, DisplayList* displayList, + jlong layerHandle, jlong rendererHandle, jlong displayListHandle, jint left, jint top, jint right, jint bottom) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); layer->updateDeferred(renderer, displayList, left, top, right, bottom); } static void android_view_GLES20Canvas_clearLayerTexture(JNIEnv* env, jobject clazz, - Layer* layer) { + jlong layerHandle) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); layer->clearTexture(); } static void android_view_GLES20Canvas_setTextureLayerTransform(JNIEnv* env, jobject clazz, - Layer* layer, SkMatrix* matrix) { + jlong layerHandle, jlong matrixHandle) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); layer->getTransform().load(*matrix); } -static void android_view_GLES20Canvas_destroyLayer(JNIEnv* env, jobject clazz, Layer* layer) { +static void android_view_GLES20Canvas_destroyLayer(JNIEnv* env, jobject clazz, jlong layerHandle) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); LayerRenderer::destroyLayer(layer); } static void android_view_GLES20Canvas_destroyLayerDeferred(JNIEnv* env, - jobject clazz, Layer* layer) { + jobject clazz, jlong layerHandle) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); LayerRenderer::destroyLayerDeferred(layer); } static void android_view_GLES20Canvas_drawLayer(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, Layer* layer, jfloat x, jfloat y) { + jlong rendererHandle, jlong layerHandle, jfloat x, jfloat y) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + Layer* layer = reinterpret_cast<Layer*>(layerHandle); renderer->drawLayer(layer, x, y); } static jboolean android_view_GLES20Canvas_copyLayer(JNIEnv* env, jobject clazz, - Layer* layer, SkBitmap* bitmap) { + jlong layerHandle, jlong bitmapHandle) { + Layer* layer = reinterpret_cast<Layer*>(layerHandle); + SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); return LayerRenderer::copyLayer(layer, bitmap); } static void android_view_GLES20Canvas_pushLayerUpdate(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, Layer* layer) { + jlong rendererHandle, jlong layerHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + Layer* layer = reinterpret_cast<Layer*>(layerHandle); renderer->pushLayerUpdate(layer); } static void android_view_GLES20Canvas_cancelLayerUpdate(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer, Layer* layer) { + jlong rendererHandle, jlong layerHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); + Layer* layer = reinterpret_cast<Layer*>(layerHandle); renderer->cancelLayerUpdate(layer); } static void android_view_GLES20Canvas_clearLayerUpdates(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer) { + jlong rendererHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->clearLayerUpdates(); } static void android_view_GLES20Canvas_flushLayerUpdates(JNIEnv* env, jobject clazz, - OpenGLRenderer* renderer) { + jlong rendererHandle) { + OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererHandle); renderer->flushLayerUpdates(); } @@ -1008,132 +1166,132 @@ static JNINativeMethod gMethods[] = { { "nInitAtlas", "(Landroid/view/GraphicBuffer;[II)V", (void*) android_view_GLES20Canvas_initAtlas }, - { "nCreateRenderer", "()I", (void*) android_view_GLES20Canvas_createRenderer }, - { "nDestroyRenderer", "(I)V", (void*) android_view_GLES20Canvas_destroyRenderer }, - { "nSetViewport", "(III)V", (void*) android_view_GLES20Canvas_setViewport }, - { "nPrepare", "(IZ)I", (void*) android_view_GLES20Canvas_prepare }, - { "nPrepareDirty", "(IIIIIZ)I", (void*) android_view_GLES20Canvas_prepareDirty }, - { "nFinish", "(I)V", (void*) android_view_GLES20Canvas_finish }, - { "nSetName", "(ILjava/lang/String;)V", + { "nCreateRenderer", "()J", (void*) android_view_GLES20Canvas_createRenderer }, + { "nDestroyRenderer", "(J)V", (void*) android_view_GLES20Canvas_destroyRenderer }, + { "nSetViewport", "(JII)V", (void*) android_view_GLES20Canvas_setViewport }, + { "nPrepare", "(JZ)I", (void*) android_view_GLES20Canvas_prepare }, + { "nPrepareDirty", "(JIIIIZ)I", (void*) android_view_GLES20Canvas_prepareDirty }, + { "nFinish", "(J)V", (void*) android_view_GLES20Canvas_finish }, + { "nSetName", "(JLjava/lang/String;)V", (void*) android_view_GLES20Canvas_setName }, - { "nSetCountOverdrawEnabled", "(IZ)V", (void*) android_view_GLES20Canvas_setCountOverdrawEnabled }, - { "nGetOverdraw", "(I)F", (void*) android_view_GLES20Canvas_getOverdraw }, + { "nSetCountOverdrawEnabled", "(JZ)V", (void*) android_view_GLES20Canvas_setCountOverdrawEnabled }, + { "nGetOverdraw", "(J)F", (void*) android_view_GLES20Canvas_getOverdraw }, { "nGetStencilSize", "()I", (void*) android_view_GLES20Canvas_getStencilSize }, - { "nCallDrawGLFunction", "(II)I", (void*) android_view_GLES20Canvas_callDrawGLFunction }, - { "nDetachFunctor", "(II)V", (void*) android_view_GLES20Canvas_detachFunctor }, - { "nAttachFunctor", "(II)V", (void*) android_view_GLES20Canvas_attachFunctor }, - { "nInvokeFunctors", "(ILandroid/graphics/Rect;)I", + { "nCallDrawGLFunction", "(JJ)I", (void*) android_view_GLES20Canvas_callDrawGLFunction }, + { "nDetachFunctor", "(JJ)V", (void*) android_view_GLES20Canvas_detachFunctor }, + { "nAttachFunctor", "(JJ)V", (void*) android_view_GLES20Canvas_attachFunctor }, + { "nInvokeFunctors", "(JLandroid/graphics/Rect;)I", (void*) android_view_GLES20Canvas_invokeFunctors }, - { "nSave", "(II)I", (void*) android_view_GLES20Canvas_save }, - { "nRestore", "(I)V", (void*) android_view_GLES20Canvas_restore }, - { "nRestoreToCount", "(II)V", (void*) android_view_GLES20Canvas_restoreToCount }, - { "nGetSaveCount", "(I)I", (void*) android_view_GLES20Canvas_getSaveCount }, - - { "nSaveLayer", "(IFFFFII)I", (void*) android_view_GLES20Canvas_saveLayer }, - { "nSaveLayer", "(III)I", (void*) android_view_GLES20Canvas_saveLayerClip }, - { "nSaveLayerAlpha", "(IFFFFII)I", (void*) android_view_GLES20Canvas_saveLayerAlpha }, - { "nSaveLayerAlpha", "(III)I", (void*) android_view_GLES20Canvas_saveLayerAlphaClip }, - - { "nQuickReject", "(IFFFF)Z", (void*) android_view_GLES20Canvas_quickReject }, - { "nClipRect", "(IFFFFI)Z", (void*) android_view_GLES20Canvas_clipRectF }, - { "nClipRect", "(IIIIII)Z", (void*) android_view_GLES20Canvas_clipRect }, - { "nClipPath", "(III)Z", (void*) android_view_GLES20Canvas_clipPath }, - { "nClipRegion", "(III)Z", (void*) android_view_GLES20Canvas_clipRegion }, - - { "nTranslate", "(IFF)V", (void*) android_view_GLES20Canvas_translate }, - { "nRotate", "(IF)V", (void*) android_view_GLES20Canvas_rotate }, - { "nScale", "(IFF)V", (void*) android_view_GLES20Canvas_scale }, - { "nSkew", "(IFF)V", (void*) android_view_GLES20Canvas_skew }, - - { "nSetMatrix", "(II)V", (void*) android_view_GLES20Canvas_setMatrix }, - { "nGetMatrix", "(II)V", (void*) android_view_GLES20Canvas_getMatrix }, - { "nConcatMatrix", "(II)V", (void*) android_view_GLES20Canvas_concatMatrix }, - - { "nDrawBitmap", "(II[BFFI)V", (void*) android_view_GLES20Canvas_drawBitmap }, - { "nDrawBitmap", "(II[BFFFFFFFFI)V",(void*) android_view_GLES20Canvas_drawBitmapRect }, - { "nDrawBitmap", "(II[BII)V", (void*) android_view_GLES20Canvas_drawBitmapMatrix }, - { "nDrawBitmap", "(I[IIIFFIIZI)V", (void*) android_view_GLES20Canvas_drawBitmapData }, - - { "nDrawBitmapMesh", "(II[BII[FI[III)V",(void*) android_view_GLES20Canvas_drawBitmapMesh }, - - { "nDrawPatch", "(II[BIFFFFI)V", (void*) android_view_GLES20Canvas_drawPatch }, - - { "nDrawColor", "(III)V", (void*) android_view_GLES20Canvas_drawColor }, - { "nDrawRect", "(IFFFFI)V", (void*) android_view_GLES20Canvas_drawRect }, - { "nDrawRects", "(III)V", (void*) android_view_GLES20Canvas_drawRegionAsRects }, - { "nDrawRects", "(I[FII)V", (void*) android_view_GLES20Canvas_drawRects }, - { "nDrawRoundRect", "(IFFFFFFI)V", (void*) android_view_GLES20Canvas_drawRoundRect }, - { "nDrawCircle", "(IFFFI)V", (void*) android_view_GLES20Canvas_drawCircle }, - { "nDrawOval", "(IFFFFI)V", (void*) android_view_GLES20Canvas_drawOval }, - { "nDrawArc", "(IFFFFFFZI)V", (void*) android_view_GLES20Canvas_drawArc }, - { "nDrawPoints", "(I[FIII)V", (void*) android_view_GLES20Canvas_drawPoints }, - - { "nDrawPath", "(III)V", (void*) android_view_GLES20Canvas_drawPath }, - { "nDrawLines", "(I[FIII)V", (void*) android_view_GLES20Canvas_drawLines }, - - { "nResetModifiers", "(II)V", (void*) android_view_GLES20Canvas_resetModifiers }, - { "nSetupShader", "(II)V", (void*) android_view_GLES20Canvas_setupShader }, - { "nSetupColorFilter", "(II)V", (void*) android_view_GLES20Canvas_setupColorFilter }, - { "nSetupShadow", "(IFFFI)V", (void*) android_view_GLES20Canvas_setupShadow }, - - { "nSetupPaintFilter", "(III)V", (void*) android_view_GLES20Canvas_setupPaintFilter }, - { "nResetPaintFilter", "(I)V", (void*) android_view_GLES20Canvas_resetPaintFilter }, - - { "nDrawText", "(I[CIIFFII)V", (void*) android_view_GLES20Canvas_drawTextArray }, - { "nDrawText", "(ILjava/lang/String;IIFFII)V", + { "nSave", "(JI)I", (void*) android_view_GLES20Canvas_save }, + { "nRestore", "(J)V", (void*) android_view_GLES20Canvas_restore }, + { "nRestoreToCount", "(JI)V", (void*) android_view_GLES20Canvas_restoreToCount }, + { "nGetSaveCount", "(J)I", (void*) android_view_GLES20Canvas_getSaveCount }, + + { "nSaveLayer", "(JFFFFJI)I", (void*) android_view_GLES20Canvas_saveLayer }, + { "nSaveLayer", "(JJI)I", (void*) android_view_GLES20Canvas_saveLayerClip }, + { "nSaveLayerAlpha", "(JFFFFII)I", (void*) android_view_GLES20Canvas_saveLayerAlpha }, + { "nSaveLayerAlpha", "(JII)I", (void*) android_view_GLES20Canvas_saveLayerAlphaClip }, + + { "nQuickReject", "(JFFFF)Z", (void*) android_view_GLES20Canvas_quickReject }, + { "nClipRect", "(JFFFFI)Z", (void*) android_view_GLES20Canvas_clipRectF }, + { "nClipRect", "(JIIIII)Z", (void*) android_view_GLES20Canvas_clipRect }, + { "nClipPath", "(JJI)Z", (void*) android_view_GLES20Canvas_clipPath }, + { "nClipRegion", "(JJI)Z", (void*) android_view_GLES20Canvas_clipRegion }, + + { "nTranslate", "(JFF)V", (void*) android_view_GLES20Canvas_translate }, + { "nRotate", "(JF)V", (void*) android_view_GLES20Canvas_rotate }, + { "nScale", "(JFF)V", (void*) android_view_GLES20Canvas_scale }, + { "nSkew", "(JFF)V", (void*) android_view_GLES20Canvas_skew }, + + { "nSetMatrix", "(JJ)V", (void*) android_view_GLES20Canvas_setMatrix }, + { "nGetMatrix", "(JJ)V", (void*) android_view_GLES20Canvas_getMatrix }, + { "nConcatMatrix", "(JJ)V", (void*) android_view_GLES20Canvas_concatMatrix }, + + { "nDrawBitmap", "(JJ[BFFJ)V", (void*) android_view_GLES20Canvas_drawBitmap }, + { "nDrawBitmap", "(JJ[BFFFFFFFFJ)V",(void*) android_view_GLES20Canvas_drawBitmapRect }, + { "nDrawBitmap", "(JJ[BJJ)V", (void*) android_view_GLES20Canvas_drawBitmapMatrix }, + { "nDrawBitmap", "(J[IIIFFIIZJ)V", (void*) android_view_GLES20Canvas_drawBitmapData }, + + { "nDrawBitmapMesh", "(JJ[BII[FI[IIJ)V",(void*) android_view_GLES20Canvas_drawBitmapMesh }, + + { "nDrawPatch", "(JJ[BJFFFFJ)V", (void*) android_view_GLES20Canvas_drawPatch }, + + { "nDrawColor", "(JII)V", (void*) android_view_GLES20Canvas_drawColor }, + { "nDrawRect", "(JFFFFJ)V", (void*) android_view_GLES20Canvas_drawRect }, + { "nDrawRects", "(JJJ)V", (void*) android_view_GLES20Canvas_drawRegionAsRects }, + { "nDrawRects", "(J[FIJ)V", (void*) android_view_GLES20Canvas_drawRects }, + { "nDrawRoundRect", "(JFFFFFFJ)V", (void*) android_view_GLES20Canvas_drawRoundRect }, + { "nDrawCircle", "(JFFFJ)V", (void*) android_view_GLES20Canvas_drawCircle }, + { "nDrawOval", "(JFFFFJ)V", (void*) android_view_GLES20Canvas_drawOval }, + { "nDrawArc", "(JFFFFFFZJ)V", (void*) android_view_GLES20Canvas_drawArc }, + { "nDrawPoints", "(J[FIIJ)V", (void*) android_view_GLES20Canvas_drawPoints }, + + { "nDrawPath", "(JJJ)V", (void*) android_view_GLES20Canvas_drawPath }, + { "nDrawLines", "(J[FIIJ)V", (void*) android_view_GLES20Canvas_drawLines }, + + { "nResetModifiers", "(JI)V", (void*) android_view_GLES20Canvas_resetModifiers }, + { "nSetupShader", "(JJ)V", (void*) android_view_GLES20Canvas_setupShader }, + { "nSetupColorFilter", "(JJ)V", (void*) android_view_GLES20Canvas_setupColorFilter }, + { "nSetupShadow", "(JFFFI)V", (void*) android_view_GLES20Canvas_setupShadow }, + + { "nSetupPaintFilter", "(JII)V", (void*) android_view_GLES20Canvas_setupPaintFilter }, + { "nResetPaintFilter", "(J)V", (void*) android_view_GLES20Canvas_resetPaintFilter }, + + { "nDrawText", "(J[CIIFFIJ)V", (void*) android_view_GLES20Canvas_drawTextArray }, + { "nDrawText", "(JLjava/lang/String;IIFFIJ)V", (void*) android_view_GLES20Canvas_drawText }, - { "nDrawTextOnPath", "(I[CIIIFFII)V", (void*) android_view_GLES20Canvas_drawTextArrayOnPath }, - { "nDrawTextOnPath", "(ILjava/lang/String;IIIFFII)V", + { "nDrawTextOnPath", "(J[CIIJFFIJ)V", (void*) android_view_GLES20Canvas_drawTextArrayOnPath }, + { "nDrawTextOnPath", "(JLjava/lang/String;IIJFFIJ)V", (void*) android_view_GLES20Canvas_drawTextOnPath }, - { "nDrawTextRun", "(I[CIIIIFFII)V", (void*) android_view_GLES20Canvas_drawTextRunArray }, - { "nDrawTextRun", "(ILjava/lang/String;IIIIFFII)V", + { "nDrawTextRun", "(J[CIIIIFFIJ)V", (void*) android_view_GLES20Canvas_drawTextRunArray }, + { "nDrawTextRun", "(JLjava/lang/String;IIIIFFIJ)V", (void*) android_view_GLES20Canvas_drawTextRun }, - { "nDrawPosText", "(I[CII[FI)V", (void*) android_view_GLES20Canvas_drawPosTextArray }, - { "nDrawPosText", "(ILjava/lang/String;II[FI)V", + { "nDrawPosText", "(J[CII[FJ)V", (void*) android_view_GLES20Canvas_drawPosTextArray }, + { "nDrawPosText", "(JLjava/lang/String;II[FJ)V", (void*) android_view_GLES20Canvas_drawPosText }, - { "nGetClipBounds", "(ILandroid/graphics/Rect;)Z", + { "nGetClipBounds", "(JLandroid/graphics/Rect;)Z", (void*) android_view_GLES20Canvas_getClipBounds }, - { "nGetDisplayList", "(II)I", (void*) android_view_GLES20Canvas_getDisplayList }, - { "nOutputDisplayList", "(II)V", (void*) android_view_GLES20Canvas_outputDisplayList }, - { "nDrawDisplayList", "(IILandroid/graphics/Rect;I)I", + { "nGetDisplayList", "(JJ)J", (void*) android_view_GLES20Canvas_getDisplayList }, + { "nOutputDisplayList", "(JJ)V", (void*) android_view_GLES20Canvas_outputDisplayList }, + { "nDrawDisplayList", "(JJLandroid/graphics/Rect;I)I", (void*) android_view_GLES20Canvas_drawDisplayList }, - { "nCreateDisplayListRenderer", "()I", (void*) android_view_GLES20Canvas_createDisplayListRenderer }, - { "nResetDisplayListRenderer", "(I)V", (void*) android_view_GLES20Canvas_resetDisplayListRenderer }, + { "nCreateDisplayListRenderer", "()J", (void*) android_view_GLES20Canvas_createDisplayListRenderer }, + { "nResetDisplayListRenderer", "(J)V", (void*) android_view_GLES20Canvas_resetDisplayListRenderer }, - { "nInterrupt", "(I)V", (void*) android_view_GLES20Canvas_interrupt }, - { "nResume", "(I)V", (void*) android_view_GLES20Canvas_resume }, + { "nInterrupt", "(J)V", (void*) android_view_GLES20Canvas_interrupt }, + { "nResume", "(J)V", (void*) android_view_GLES20Canvas_resume }, - { "nCreateLayerRenderer", "(I)I", (void*) android_view_GLES20Canvas_createLayerRenderer }, - { "nCreateLayer", "(IIZ[I)I", (void*) android_view_GLES20Canvas_createLayer }, - { "nResizeLayer", "(III[I)Z" , (void*) android_view_GLES20Canvas_resizeLayer }, - { "nSetLayerPaint", "(II)V", (void*) android_view_GLES20Canvas_setLayerPaint }, - { "nSetLayerColorFilter", "(II)V", (void*) android_view_GLES20Canvas_setLayerColorFilter }, - { "nSetOpaqueLayer", "(IZ)V", (void*) android_view_GLES20Canvas_setOpaqueLayer }, - { "nCreateTextureLayer", "(Z[I)I", (void*) android_view_GLES20Canvas_createTextureLayer }, - { "nUpdateTextureLayer", "(IIIZLandroid/graphics/SurfaceTexture;)V", + { "nCreateLayerRenderer", "(J)J", (void*) android_view_GLES20Canvas_createLayerRenderer }, + { "nCreateLayer", "(IIZ[I)J", (void*) android_view_GLES20Canvas_createLayer }, + { "nResizeLayer", "(JII[I)Z" , (void*) android_view_GLES20Canvas_resizeLayer }, + { "nSetLayerPaint", "(JJ)V", (void*) android_view_GLES20Canvas_setLayerPaint }, + { "nSetLayerColorFilter", "(JJ)V", (void*) android_view_GLES20Canvas_setLayerColorFilter }, + { "nSetOpaqueLayer", "(JZ)V", (void*) android_view_GLES20Canvas_setOpaqueLayer }, + { "nCreateTextureLayer", "(Z[I)J", (void*) android_view_GLES20Canvas_createTextureLayer }, + { "nUpdateTextureLayer", "(JIIZLandroid/graphics/SurfaceTexture;)V", (void*) android_view_GLES20Canvas_updateTextureLayer }, - { "nUpdateRenderLayer", "(IIIIIII)V", (void*) android_view_GLES20Canvas_updateRenderLayer }, - { "nClearLayerTexture", "(I)V", (void*) android_view_GLES20Canvas_clearLayerTexture }, - { "nDestroyLayer", "(I)V", (void*) android_view_GLES20Canvas_destroyLayer }, - { "nDestroyLayerDeferred", "(I)V", (void*) android_view_GLES20Canvas_destroyLayerDeferred }, - { "nDrawLayer", "(IIFF)V", (void*) android_view_GLES20Canvas_drawLayer }, - { "nCopyLayer", "(II)Z", (void*) android_view_GLES20Canvas_copyLayer }, - { "nClearLayerUpdates", "(I)V", (void*) android_view_GLES20Canvas_clearLayerUpdates }, - { "nFlushLayerUpdates", "(I)V", (void*) android_view_GLES20Canvas_flushLayerUpdates }, - { "nPushLayerUpdate", "(II)V", (void*) android_view_GLES20Canvas_pushLayerUpdate }, - { "nCancelLayerUpdate", "(II)V", (void*) android_view_GLES20Canvas_cancelLayerUpdate }, - - { "nSetTextureLayerTransform", "(II)V", (void*) android_view_GLES20Canvas_setTextureLayerTransform }, + { "nUpdateRenderLayer", "(JJJIIII)V", (void*) android_view_GLES20Canvas_updateRenderLayer }, + { "nClearLayerTexture", "(J)V", (void*) android_view_GLES20Canvas_clearLayerTexture }, + { "nDestroyLayer", "(J)V", (void*) android_view_GLES20Canvas_destroyLayer }, + { "nDestroyLayerDeferred", "(J)V", (void*) android_view_GLES20Canvas_destroyLayerDeferred }, + { "nDrawLayer", "(JJFF)V", (void*) android_view_GLES20Canvas_drawLayer }, + { "nCopyLayer", "(JJ)Z", (void*) android_view_GLES20Canvas_copyLayer }, + { "nClearLayerUpdates", "(J)V", (void*) android_view_GLES20Canvas_clearLayerUpdates }, + { "nFlushLayerUpdates", "(J)V", (void*) android_view_GLES20Canvas_flushLayerUpdates }, + { "nPushLayerUpdate", "(JJ)V", (void*) android_view_GLES20Canvas_pushLayerUpdate }, + { "nCancelLayerUpdate", "(JJ)V", (void*) android_view_GLES20Canvas_cancelLayerUpdate }, + + { "nSetTextureLayerTransform", "(JJ)V", (void*) android_view_GLES20Canvas_setTextureLayerTransform }, { "nGetMaximumTextureWidth", "()I", (void*) android_view_GLES20Canvas_getMaxTextureWidth }, { "nGetMaximumTextureHeight", "()I", (void*) android_view_GLES20Canvas_getMaxTextureHeight }, diff --git a/core/jni/android_view_GLES20DisplayList.cpp b/core/jni/android_view_GLES20DisplayList.cpp index 4ce2e24..8e19efd 100644 --- a/core/jni/android_view_GLES20DisplayList.cpp +++ b/core/jni/android_view_GLES20DisplayList.cpp @@ -42,17 +42,20 @@ using namespace uirenderer; // ---------------------------------------------------------------------------- static void android_view_GLES20DisplayList_reset(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->reset(); } static jint android_view_GLES20DisplayList_getDisplayListSize(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getSize(); } static void android_view_GLES20DisplayList_setDisplayListName(JNIEnv* env, - jobject clazz, DisplayList* displayList, jstring name) { + jobject clazz, jlong displayListHandle, jstring name) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); if (name != NULL) { const char* textArray = env->GetStringUTFChars(name, NULL); displayList->setName(textArray); @@ -61,7 +64,8 @@ static void android_view_GLES20DisplayList_setDisplayListName(JNIEnv* env, } static void android_view_GLES20DisplayList_destroyDisplayList(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); DisplayList::destroyDisplayListDeferred(displayList); } @@ -70,74 +74,91 @@ static void android_view_GLES20DisplayList_destroyDisplayList(JNIEnv* env, // ---------------------------------------------------------------------------- static void android_view_GLES20DisplayList_setCaching(JNIEnv* env, - jobject clazz, DisplayList* displayList, jboolean caching) { + jobject clazz, jlong displayListHandle, jboolean caching) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setCaching(caching); } +//serban static void android_view_GLES20DisplayList_setStaticMatrix(JNIEnv* env, - jobject clazz, DisplayList* displayList, SkMatrix* matrix) { + jobject clazz, jlong displayListHandle, jlong matrixHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); displayList->setStaticMatrix(matrix); } static void android_view_GLES20DisplayList_setAnimationMatrix(JNIEnv* env, - jobject clazz, DisplayList* displayList, SkMatrix* matrix) { + jobject clazz, jlong displayListHandle, jlong matrixHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); displayList->setAnimationMatrix(matrix); } static void android_view_GLES20DisplayList_setClipToBounds(JNIEnv* env, - jobject clazz, DisplayList* displayList, jboolean clipToBounds) { + jobject clazz, jlong displayListHandle, jboolean clipToBounds) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setClipToBounds(clipToBounds); } static void android_view_GLES20DisplayList_setAlpha(JNIEnv* env, - jobject clazz, DisplayList* displayList, float alpha) { + jobject clazz, jlong displayListHandle, jfloat alpha) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setAlpha(alpha); } static void android_view_GLES20DisplayList_setHasOverlappingRendering(JNIEnv* env, - jobject clazz, DisplayList* displayList, bool hasOverlappingRendering) { + jobject clazz, jlong displayListHandle, jboolean hasOverlappingRendering) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setHasOverlappingRendering(hasOverlappingRendering); } static void android_view_GLES20DisplayList_setTranslationX(JNIEnv* env, - jobject clazz, DisplayList* displayList, float tx) { + jobject clazz, jlong displayListHandle, jfloat tx) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setTranslationX(tx); } static void android_view_GLES20DisplayList_setTranslationY(JNIEnv* env, - jobject clazz, DisplayList* displayList, float ty) { + jobject clazz, jlong displayListHandle, jfloat ty) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setTranslationY(ty); } static void android_view_GLES20DisplayList_setRotation(JNIEnv* env, - jobject clazz, DisplayList* displayList, float rotation) { + jobject clazz, jlong displayListHandle, jfloat rotation) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setRotation(rotation); } static void android_view_GLES20DisplayList_setRotationX(JNIEnv* env, - jobject clazz, DisplayList* displayList, float rx) { + jobject clazz, jlong displayListHandle, jfloat rx) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setRotationX(rx); } static void android_view_GLES20DisplayList_setRotationY(JNIEnv* env, - jobject clazz, DisplayList* displayList, float ry) { + jobject clazz, jlong displayListHandle, jfloat ry) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setRotationY(ry); } static void android_view_GLES20DisplayList_setScaleX(JNIEnv* env, - jobject clazz, DisplayList* displayList, float sx) { + jobject clazz, jlong displayListHandle, jfloat sx) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setScaleX(sx); } static void android_view_GLES20DisplayList_setScaleY(JNIEnv* env, - jobject clazz, DisplayList* displayList, float sy) { + jobject clazz, jlong displayListHandle, jfloat sy) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setScaleY(sy); } static void android_view_GLES20DisplayList_setTransformationInfo(JNIEnv* env, - jobject clazz, DisplayList* displayList, float alpha, - float translationX, float translationY, float rotation, float rotationX, float rotationY, - float scaleX, float scaleY) { + jobject clazz, jlong displayListHandle, jfloat alpha, + jfloat translationX, jfloat translationY, jfloat rotation, jfloat rotationX, jfloat rotationY, + jfloat scaleX, jfloat scaleY) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setAlpha(alpha); displayList->setTranslationX(translationX); displayList->setTranslationY(translationY); @@ -149,58 +170,70 @@ static void android_view_GLES20DisplayList_setTransformationInfo(JNIEnv* env, } static void android_view_GLES20DisplayList_setPivotX(JNIEnv* env, - jobject clazz, DisplayList* displayList, float px) { + jobject clazz, jlong displayListHandle, jfloat px) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setPivotX(px); } static void android_view_GLES20DisplayList_setPivotY(JNIEnv* env, - jobject clazz, DisplayList* displayList, float py) { + jobject clazz, jlong displayListHandle, jfloat py) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setPivotY(py); } static void android_view_GLES20DisplayList_setCameraDistance(JNIEnv* env, - jobject clazz, DisplayList* displayList, float distance) { + jobject clazz, jlong displayListHandle, jfloat distance) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setCameraDistance(distance); } static void android_view_GLES20DisplayList_setLeft(JNIEnv* env, - jobject clazz, DisplayList* displayList, int left) { + jobject clazz, jlong displayListHandle, jint left) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setLeft(left); } static void android_view_GLES20DisplayList_setTop(JNIEnv* env, - jobject clazz, DisplayList* displayList, int top) { + jobject clazz, jlong displayListHandle, jint top) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setTop(top); } static void android_view_GLES20DisplayList_setRight(JNIEnv* env, - jobject clazz, DisplayList* displayList, int right) { + jobject clazz, jlong displayListHandle, jint right) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setRight(right); } static void android_view_GLES20DisplayList_setBottom(JNIEnv* env, - jobject clazz, DisplayList* displayList, int bottom) { + jobject clazz, jlong displayListHandle, jint bottom) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setBottom(bottom); } static void android_view_GLES20DisplayList_setLeftTopRightBottom(JNIEnv* env, - jobject clazz, DisplayList* displayList, int left, int top, + jobject clazz, jlong displayListHandle, jint left, jint top, int right, int bottom) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->setLeftTopRightBottom(left, top, right, bottom); } static void android_view_GLES20DisplayList_offsetLeftAndRight(JNIEnv* env, - jobject clazz, DisplayList* displayList, float offset) { + jobject clazz, jlong displayListHandle, jfloat offset) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->offsetLeftRight(offset); } static void android_view_GLES20DisplayList_offsetTopAndBottom(JNIEnv* env, - jobject clazz, DisplayList* displayList, float offset) { + jobject clazz, jlong displayListHandle, jfloat offset) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); displayList->offsetTopBottom(offset); } static void android_view_GLES20DisplayList_getMatrix(JNIEnv* env, - jobject clazz, DisplayList* displayList, SkMatrix* matrix) { + jobject clazz, jlong displayListHandle, jlong matrixHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); SkMatrix* source = displayList->getStaticMatrix(); if (source) { matrix->setConcat(SkMatrix::I(), *source); @@ -210,82 +243,98 @@ static void android_view_GLES20DisplayList_getMatrix(JNIEnv* env, } static jboolean android_view_GLES20DisplayList_hasOverlappingRendering(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->hasOverlappingRendering(); } static jfloat android_view_GLES20DisplayList_getAlpha(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getAlpha(); } static jfloat android_view_GLES20DisplayList_getLeft(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getLeft(); } static jfloat android_view_GLES20DisplayList_getTop(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getTop(); } static jfloat android_view_GLES20DisplayList_getRight(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getRight(); } static jfloat android_view_GLES20DisplayList_getBottom(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getBottom(); } static jfloat android_view_GLES20DisplayList_getCameraDistance(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getCameraDistance(); } static jfloat android_view_GLES20DisplayList_getScaleX(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getScaleX(); } static jfloat android_view_GLES20DisplayList_getScaleY(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getScaleY(); } static jfloat android_view_GLES20DisplayList_getTranslationX(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getTranslationX(); } static jfloat android_view_GLES20DisplayList_getTranslationY(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getTranslationY(); } static jfloat android_view_GLES20DisplayList_getRotation(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getRotation(); } static jfloat android_view_GLES20DisplayList_getRotationX(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getRotationX(); } static jfloat android_view_GLES20DisplayList_getRotationY(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getRotationY(); } static jfloat android_view_GLES20DisplayList_getPivotX(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getPivotX(); } static jfloat android_view_GLES20DisplayList_getPivotY(JNIEnv* env, - jobject clazz, DisplayList* displayList) { + jobject clazz, jlong displayListHandle) { + DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); return displayList->getPivotY(); } @@ -299,58 +348,58 @@ const char* const kClassPathName = "android/view/GLES20DisplayList"; static JNINativeMethod gMethods[] = { #ifdef USE_OPENGL_RENDERER - { "nDestroyDisplayList", "(I)V", (void*) android_view_GLES20DisplayList_destroyDisplayList }, - { "nGetDisplayListSize", "(I)I", (void*) android_view_GLES20DisplayList_getDisplayListSize }, - { "nSetDisplayListName", "(ILjava/lang/String;)V", + { "nDestroyDisplayList", "(J)V", (void*) android_view_GLES20DisplayList_destroyDisplayList }, + { "nGetDisplayListSize", "(J)I", (void*) android_view_GLES20DisplayList_getDisplayListSize }, + { "nSetDisplayListName", "(JLjava/lang/String;)V", (void*) android_view_GLES20DisplayList_setDisplayListName }, - { "nReset", "(I)V", (void*) android_view_GLES20DisplayList_reset }, - { "nSetCaching", "(IZ)V", (void*) android_view_GLES20DisplayList_setCaching }, - { "nSetStaticMatrix", "(II)V", (void*) android_view_GLES20DisplayList_setStaticMatrix }, - { "nSetAnimationMatrix", "(II)V", (void*) android_view_GLES20DisplayList_setAnimationMatrix }, - { "nSetClipToBounds", "(IZ)V", (void*) android_view_GLES20DisplayList_setClipToBounds }, - { "nSetAlpha", "(IF)V", (void*) android_view_GLES20DisplayList_setAlpha }, - { "nSetHasOverlappingRendering", "(IZ)V", + { "nReset", "(J)V", (void*) android_view_GLES20DisplayList_reset }, + { "nSetCaching", "(JZ)V", (void*) android_view_GLES20DisplayList_setCaching }, + { "nSetStaticMatrix", "(JJ)V", (void*) android_view_GLES20DisplayList_setStaticMatrix }, + { "nSetAnimationMatrix", "(JJ)V", (void*) android_view_GLES20DisplayList_setAnimationMatrix }, + { "nSetClipToBounds", "(JZ)V", (void*) android_view_GLES20DisplayList_setClipToBounds }, + { "nSetAlpha", "(JF)V", (void*) android_view_GLES20DisplayList_setAlpha }, + { "nSetHasOverlappingRendering", "(JZ)V", (void*) android_view_GLES20DisplayList_setHasOverlappingRendering }, - { "nSetTranslationX", "(IF)V", (void*) android_view_GLES20DisplayList_setTranslationX }, - { "nSetTranslationY", "(IF)V", (void*) android_view_GLES20DisplayList_setTranslationY }, - { "nSetRotation", "(IF)V", (void*) android_view_GLES20DisplayList_setRotation }, - { "nSetRotationX", "(IF)V", (void*) android_view_GLES20DisplayList_setRotationX }, - { "nSetRotationY", "(IF)V", (void*) android_view_GLES20DisplayList_setRotationY }, - { "nSetScaleX", "(IF)V", (void*) android_view_GLES20DisplayList_setScaleX }, - { "nSetScaleY", "(IF)V", (void*) android_view_GLES20DisplayList_setScaleY }, - { "nSetTransformationInfo","(IFFFFFFFF)V", + { "nSetTranslationX", "(JF)V", (void*) android_view_GLES20DisplayList_setTranslationX }, + { "nSetTranslationY", "(JF)V", (void*) android_view_GLES20DisplayList_setTranslationY }, + { "nSetRotation", "(JF)V", (void*) android_view_GLES20DisplayList_setRotation }, + { "nSetRotationX", "(JF)V", (void*) android_view_GLES20DisplayList_setRotationX }, + { "nSetRotationY", "(JF)V", (void*) android_view_GLES20DisplayList_setRotationY }, + { "nSetScaleX", "(JF)V", (void*) android_view_GLES20DisplayList_setScaleX }, + { "nSetScaleY", "(JF)V", (void*) android_view_GLES20DisplayList_setScaleY }, + { "nSetTransformationInfo","(JFFFFFFFF)V", (void*) android_view_GLES20DisplayList_setTransformationInfo }, - { "nSetPivotX", "(IF)V", (void*) android_view_GLES20DisplayList_setPivotX }, - { "nSetPivotY", "(IF)V", (void*) android_view_GLES20DisplayList_setPivotY }, - { "nSetCameraDistance", "(IF)V", (void*) android_view_GLES20DisplayList_setCameraDistance }, - { "nSetLeft", "(II)V", (void*) android_view_GLES20DisplayList_setLeft }, - { "nSetTop", "(II)V", (void*) android_view_GLES20DisplayList_setTop }, - { "nSetRight", "(II)V", (void*) android_view_GLES20DisplayList_setRight }, - { "nSetBottom", "(II)V", (void*) android_view_GLES20DisplayList_setBottom }, - { "nSetLeftTopRightBottom","(IIIII)V", + { "nSetPivotX", "(JF)V", (void*) android_view_GLES20DisplayList_setPivotX }, + { "nSetPivotY", "(JF)V", (void*) android_view_GLES20DisplayList_setPivotY }, + { "nSetCameraDistance", "(JF)V", (void*) android_view_GLES20DisplayList_setCameraDistance }, + { "nSetLeft", "(JI)V", (void*) android_view_GLES20DisplayList_setLeft }, + { "nSetTop", "(JI)V", (void*) android_view_GLES20DisplayList_setTop }, + { "nSetRight", "(JI)V", (void*) android_view_GLES20DisplayList_setRight }, + { "nSetBottom", "(JI)V", (void*) android_view_GLES20DisplayList_setBottom }, + { "nSetLeftTopRightBottom","(JIIII)V", (void*) android_view_GLES20DisplayList_setLeftTopRightBottom }, - { "nOffsetLeftAndRight", "(IF)V", (void*) android_view_GLES20DisplayList_offsetLeftAndRight }, - { "nOffsetTopAndBottom", "(IF)V", (void*) android_view_GLES20DisplayList_offsetTopAndBottom }, - - - { "nGetMatrix", "(II)V", (void*) android_view_GLES20DisplayList_getMatrix }, - { "nHasOverlappingRendering", "(I)Z", (void*) android_view_GLES20DisplayList_hasOverlappingRendering }, - { "nGetAlpha", "(I)F", (void*) android_view_GLES20DisplayList_getAlpha }, - { "nGetLeft", "(I)F", (void*) android_view_GLES20DisplayList_getLeft }, - { "nGetTop", "(I)F", (void*) android_view_GLES20DisplayList_getTop }, - { "nGetRight", "(I)F", (void*) android_view_GLES20DisplayList_getRight }, - { "nGetBottom", "(I)F", (void*) android_view_GLES20DisplayList_getBottom }, - { "nGetCameraDistance", "(I)F", (void*) android_view_GLES20DisplayList_getCameraDistance }, - { "nGetScaleX", "(I)F", (void*) android_view_GLES20DisplayList_getScaleX }, - { "nGetScaleY", "(I)F", (void*) android_view_GLES20DisplayList_getScaleY }, - { "nGetTranslationX", "(I)F", (void*) android_view_GLES20DisplayList_getTranslationX }, - { "nGetTranslationY", "(I)F", (void*) android_view_GLES20DisplayList_getTranslationY }, - { "nGetRotation", "(I)F", (void*) android_view_GLES20DisplayList_getRotation }, - { "nGetRotationX", "(I)F", (void*) android_view_GLES20DisplayList_getRotationX }, - { "nGetRotationY", "(I)F", (void*) android_view_GLES20DisplayList_getRotationY }, - { "nGetPivotX", "(I)F", (void*) android_view_GLES20DisplayList_getPivotX }, - { "nGetPivotY", "(I)F", (void*) android_view_GLES20DisplayList_getPivotY }, + { "nOffsetLeftAndRight", "(JF)V", (void*) android_view_GLES20DisplayList_offsetLeftAndRight }, + { "nOffsetTopAndBottom", "(JF)V", (void*) android_view_GLES20DisplayList_offsetTopAndBottom }, + + + { "nGetMatrix", "(JJ)V", (void*) android_view_GLES20DisplayList_getMatrix }, + { "nHasOverlappingRendering", "(J)Z", (void*) android_view_GLES20DisplayList_hasOverlappingRendering }, + { "nGetAlpha", "(J)F", (void*) android_view_GLES20DisplayList_getAlpha }, + { "nGetLeft", "(J)F", (void*) android_view_GLES20DisplayList_getLeft }, + { "nGetTop", "(J)F", (void*) android_view_GLES20DisplayList_getTop }, + { "nGetRight", "(J)F", (void*) android_view_GLES20DisplayList_getRight }, + { "nGetBottom", "(J)F", (void*) android_view_GLES20DisplayList_getBottom }, + { "nGetCameraDistance", "(J)F", (void*) android_view_GLES20DisplayList_getCameraDistance }, + { "nGetScaleX", "(J)F", (void*) android_view_GLES20DisplayList_getScaleX }, + { "nGetScaleY", "(J)F", (void*) android_view_GLES20DisplayList_getScaleY }, + { "nGetTranslationX", "(J)F", (void*) android_view_GLES20DisplayList_getTranslationX }, + { "nGetTranslationY", "(J)F", (void*) android_view_GLES20DisplayList_getTranslationY }, + { "nGetRotation", "(J)F", (void*) android_view_GLES20DisplayList_getRotation }, + { "nGetRotationX", "(J)F", (void*) android_view_GLES20DisplayList_getRotationX }, + { "nGetRotationY", "(J)F", (void*) android_view_GLES20DisplayList_getRotationY }, + { "nGetPivotX", "(J)F", (void*) android_view_GLES20DisplayList_getPivotX }, + { "nGetPivotY", "(J)F", (void*) android_view_GLES20DisplayList_getPivotY }, #endif }; diff --git a/core/jni/android_view_GraphicBuffer.cpp b/core/jni/android_view_GraphicBuffer.cpp index d68c0b2..2e8dccf 100644 --- a/core/jni/android_view_GraphicBuffer.cpp +++ b/core/jni/android_view_GraphicBuffer.cpp @@ -89,6 +89,12 @@ static struct { #define SET_INT(object, field, value) \ env->SetIntField(object, field, value) +#define GET_LONG(object, field) \ + env->GetLongField(object, field) + +#define SET_LONG(object, field, value) \ + env->SetLongField(object, field, value) + #define INVOKEV(object, method, ...) \ env->CallVoidMethod(object, method, __VA_ARGS__) @@ -108,7 +114,7 @@ public: // GraphicBuffer lifecycle // ---------------------------------------------------------------------------- -static GraphicBufferWrapper* android_view_GraphiceBuffer_create(JNIEnv* env, jobject clazz, +static jlong android_view_GraphiceBuffer_create(JNIEnv* env, jobject clazz, jint width, jint height, jint format, jint usage) { sp<ISurfaceComposer> composer(ComposerService::getComposerService()); @@ -125,11 +131,14 @@ static GraphicBufferWrapper* android_view_GraphiceBuffer_create(JNIEnv* env, job return NULL; } - return new GraphicBufferWrapper(buffer); + GraphicBufferWrapper* wrapper = new GraphicBufferWrapper(buffer); + return reinterpret_cast<jlong>(wrapper); } static void android_view_GraphiceBuffer_destroy(JNIEnv* env, jobject clazz, - GraphicBufferWrapper* wrapper) { + jlong wrapperHandle) { + GraphicBufferWrapper* wrapper = + reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle); delete wrapper; } @@ -140,9 +149,9 @@ static void android_view_GraphiceBuffer_destroy(JNIEnv* env, jobject clazz, static inline void swapCanvasPtr(JNIEnv* env, jobject canvasObj, SkCanvas* newCanvas) { jobject canvasFinalizerObj = env->GetObjectField(canvasObj, gCanvasClassInfo.mFinalizer); SkCanvas* previousCanvas = reinterpret_cast<SkCanvas*>( - GET_INT(canvasObj, gCanvasClassInfo.mNativeCanvas)); - SET_INT(canvasObj, gCanvasClassInfo.mNativeCanvas, (int) newCanvas); - SET_INT(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (int) newCanvas); + GET_LONG(canvasObj, gCanvasClassInfo.mNativeCanvas)); + SET_LONG(canvasObj, gCanvasClassInfo.mNativeCanvas, (long) newCanvas); + SET_LONG(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (long) newCanvas); SkSafeUnref(previousCanvas); } @@ -160,10 +169,12 @@ static inline SkBitmap::Config convertPixelFormat(int32_t format) { } static jboolean android_view_GraphicBuffer_lockCanvas(JNIEnv* env, jobject, - GraphicBufferWrapper* wrapper, jobject canvas, jobject dirtyRect) { + jlong wrapperHandle, jobject canvas, jobject dirtyRect) { + GraphicBufferWrapper* wrapper = + reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle); if (!wrapper) { - return false; + return JNI_FALSE; } sp<GraphicBuffer> buffer(wrapper->buffer); @@ -181,10 +192,10 @@ static jboolean android_view_GraphicBuffer_lockCanvas(JNIEnv* env, jobject, void* bits = NULL; status_t status = buffer->lock(LOCK_CANVAS_USAGE, rect, &bits); - if (status) return false; + if (status) return JNI_FALSE; if (!bits) { buffer->unlock(); - return false; + return JNI_FALSE; } ssize_t bytesCount = buffer->getStride() * bytesPerPixel(buffer->getPixelFormat()); @@ -213,21 +224,23 @@ static jboolean android_view_GraphicBuffer_lockCanvas(JNIEnv* env, jobject, int(rect.left), int(rect.top), int(rect.right), int(rect.bottom)); } - return true; + return JNI_TRUE; } static jboolean android_view_GraphicBuffer_unlockCanvasAndPost(JNIEnv* env, jobject, - GraphicBufferWrapper* wrapper, jobject canvas) { + jlong wrapperHandle, jobject canvas) { + GraphicBufferWrapper* wrapper = + reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle); SkCanvas* nativeCanvas = SkNEW(SkCanvas); swapCanvasPtr(env, canvas, nativeCanvas); if (wrapper) { status_t status = wrapper->buffer->unlock(); - return status == 0; + return status == 0 ? JNI_TRUE : JNI_FALSE; } - return false; + return JNI_FALSE; } // ---------------------------------------------------------------------------- @@ -235,21 +248,23 @@ static jboolean android_view_GraphicBuffer_unlockCanvasAndPost(JNIEnv* env, jobj // ---------------------------------------------------------------------------- static void android_view_GraphiceBuffer_write(JNIEnv* env, jobject clazz, - GraphicBufferWrapper* wrapper, jobject dest) { + jlong wrapperHandle, jobject dest) { + GraphicBufferWrapper* wrapper = + reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle); Parcel* parcel = parcelForJavaObject(env, dest); if (parcel) { parcel->write(*wrapper->buffer); } } -static GraphicBufferWrapper* android_view_GraphiceBuffer_read(JNIEnv* env, jobject clazz, +static jlong android_view_GraphiceBuffer_read(JNIEnv* env, jobject clazz, jobject in) { Parcel* parcel = parcelForJavaObject(env, in); if (parcel) { sp<GraphicBuffer> buffer = new GraphicBuffer(); parcel->read(*buffer); - return new GraphicBufferWrapper(buffer); + return reinterpret_cast<jlong>(new GraphicBufferWrapper(buffer)); } return NULL; @@ -261,7 +276,7 @@ static GraphicBufferWrapper* android_view_GraphiceBuffer_read(JNIEnv* env, jobje sp<GraphicBuffer> graphicBufferForJavaObject(JNIEnv* env, jobject obj) { if (obj) { - jint nativeObject = env->GetIntField(obj, gGraphicBufferClassInfo.mNativeObject); + jlong nativeObject = env->GetLongField(obj, gGraphicBufferClassInfo.mNativeObject); GraphicBufferWrapper* wrapper = (GraphicBufferWrapper*) nativeObject; if (wrapper != NULL) { sp<GraphicBuffer> buffer(wrapper->buffer); @@ -290,24 +305,24 @@ sp<GraphicBuffer> graphicBufferForJavaObject(JNIEnv* env, jobject obj) { const char* const kClassPathName = "android/view/GraphicBuffer"; static JNINativeMethod gMethods[] = { - { "nCreateGraphicBuffer", "(IIII)I", (void*) android_view_GraphiceBuffer_create }, - { "nDestroyGraphicBuffer", "(I)V", (void*) android_view_GraphiceBuffer_destroy }, + { "nCreateGraphicBuffer", "(IIII)J", (void*) android_view_GraphiceBuffer_create }, + { "nDestroyGraphicBuffer", "(J)V", (void*) android_view_GraphiceBuffer_destroy }, - { "nWriteGraphicBufferToParcel", "(ILandroid/os/Parcel;)V", + { "nWriteGraphicBufferToParcel", "(JLandroid/os/Parcel;)V", (void*) android_view_GraphiceBuffer_write }, - { "nReadGraphicBufferFromParcel", "(Landroid/os/Parcel;)I", + { "nReadGraphicBufferFromParcel", "(Landroid/os/Parcel;)J", (void*) android_view_GraphiceBuffer_read }, - { "nLockCanvas", "(ILandroid/graphics/Canvas;Landroid/graphics/Rect;)Z", + { "nLockCanvas", "(JLandroid/graphics/Canvas;Landroid/graphics/Rect;)Z", (void*) android_view_GraphicBuffer_lockCanvas }, - { "nUnlockCanvasAndPost", "(ILandroid/graphics/Canvas;)Z", + { "nUnlockCanvasAndPost", "(JLandroid/graphics/Canvas;)Z", (void*) android_view_GraphicBuffer_unlockCanvasAndPost }, }; int register_android_view_GraphicBuffer(JNIEnv* env) { jclass clazz; FIND_CLASS(clazz, "android/view/GraphicBuffer"); - GET_FIELD_ID(gGraphicBufferClassInfo.mNativeObject, clazz, "mNativeObject", "I"); + GET_FIELD_ID(gGraphicBufferClassInfo.mNativeObject, clazz, "mNativeObject", "J"); FIND_CLASS(clazz, "android/graphics/Rect"); GET_METHOD_ID(gRectClassInfo.set, clazz, "set", "(IIII)V"); @@ -319,11 +334,11 @@ int register_android_view_GraphicBuffer(JNIEnv* env) { FIND_CLASS(clazz, "android/graphics/Canvas"); GET_FIELD_ID(gCanvasClassInfo.mFinalizer, clazz, "mFinalizer", "Landroid/graphics/Canvas$CanvasFinalizer;"); - GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I"); + GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J"); GET_FIELD_ID(gCanvasClassInfo.mSurfaceFormat, clazz, "mSurfaceFormat", "I"); FIND_CLASS(clazz, "android/graphics/Canvas$CanvasFinalizer"); - GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I"); + GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J"); return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); } diff --git a/core/jni/android_view_InputChannel.cpp b/core/jni/android_view_InputChannel.cpp index ce475e0..d667920 100644 --- a/core/jni/android_view_InputChannel.cpp +++ b/core/jni/android_view_InputChannel.cpp @@ -81,14 +81,14 @@ void NativeInputChannel::invokeAndRemoveDisposeCallback(JNIEnv* env, jobject obj static NativeInputChannel* android_view_InputChannel_getNativeInputChannel(JNIEnv* env, jobject inputChannelObj) { - jint intPtr = env->GetIntField(inputChannelObj, gInputChannelClassInfo.mPtr); - return reinterpret_cast<NativeInputChannel*>(intPtr); + jlong longPtr = env->GetLongField(inputChannelObj, gInputChannelClassInfo.mPtr); + return reinterpret_cast<NativeInputChannel*>(longPtr); } static void android_view_InputChannel_setNativeInputChannel(JNIEnv* env, jobject inputChannelObj, NativeInputChannel* nativeInputChannel) { - env->SetIntField(inputChannelObj, gInputChannelClassInfo.mPtr, - reinterpret_cast<jint>(nativeInputChannel)); + env->SetLongField(inputChannelObj, gInputChannelClassInfo.mPtr, + reinterpret_cast<jlong>(nativeInputChannel)); } sp<InputChannel> android_view_InputChannel_getInputChannel(JNIEnv* env, jobject inputChannelObj) { @@ -296,7 +296,7 @@ int register_android_view_InputChannel(JNIEnv* env) { FIND_CLASS(gInputChannelClassInfo.clazz, "android/view/InputChannel"); GET_FIELD_ID(gInputChannelClassInfo.mPtr, gInputChannelClassInfo.clazz, - "mPtr", "I"); + "mPtr", "J"); GET_METHOD_ID(gInputChannelClassInfo.ctor, gInputChannelClassInfo.clazz, "<init>", "()V"); diff --git a/core/jni/android_view_InputEventReceiver.cpp b/core/jni/android_view_InputEventReceiver.cpp index 92a3e62..f36bf31 100644 --- a/core/jni/android_view_InputEventReceiver.cpp +++ b/core/jni/android_view_InputEventReceiver.cpp @@ -330,7 +330,7 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, } -static jint nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak, +static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak, jobject inputChannelObj, jobject messageQueueObj) { sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env, inputChannelObj); @@ -356,17 +356,17 @@ static jint nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak, } receiver->incStrong(gInputEventReceiverClassInfo.clazz); // retain a reference for the object - return reinterpret_cast<jint>(receiver.get()); + return reinterpret_cast<jlong>(receiver.get()); } -static void nativeDispose(JNIEnv* env, jclass clazz, jint receiverPtr) { +static void nativeDispose(JNIEnv* env, jclass clazz, jlong receiverPtr) { sp<NativeInputEventReceiver> receiver = reinterpret_cast<NativeInputEventReceiver*>(receiverPtr); receiver->dispose(); receiver->decStrong(gInputEventReceiverClassInfo.clazz); // drop reference held by the object } -static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jint receiverPtr, +static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jlong receiverPtr, jint seq, jboolean handled) { sp<NativeInputEventReceiver> receiver = reinterpret_cast<NativeInputEventReceiver*>(receiverPtr); @@ -378,7 +378,7 @@ static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jint receiverPtr, } } -static bool nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jint receiverPtr, +static jboolean nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jlong receiverPtr, jlong frameTimeNanos) { sp<NativeInputEventReceiver> receiver = reinterpret_cast<NativeInputEventReceiver*>(receiverPtr); @@ -389,22 +389,22 @@ static bool nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jint rece String8 message; message.appendFormat("Failed to consume batched input event. status=%d", status); jniThrowRuntimeException(env, message.string()); - return false; + return JNI_FALSE; } - return consumedBatch; + return consumedBatch ? JNI_TRUE : JNI_FALSE; } static JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ { "nativeInit", - "(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)I", + "(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)J", (void*)nativeInit }, - { "nativeDispose", "(I)V", + { "nativeDispose", "(J)V", (void*)nativeDispose }, - { "nativeFinishInputEvent", "(IIZ)V", + { "nativeFinishInputEvent", "(JIZ)V", (void*)nativeFinishInputEvent }, - { "nativeConsumeBatchedInputEvents", "(IJ)Z", + { "nativeConsumeBatchedInputEvents", "(JJ)Z", (void*)nativeConsumeBatchedInputEvents }, }; diff --git a/core/jni/android_view_InputEventSender.cpp b/core/jni/android_view_InputEventSender.cpp index e4b65a1..f156b9a 100644 --- a/core/jni/android_view_InputEventSender.cpp +++ b/core/jni/android_view_InputEventSender.cpp @@ -230,7 +230,7 @@ status_t NativeInputEventSender::receiveFinishedSignals(JNIEnv* env) { } -static jint nativeInit(JNIEnv* env, jclass clazz, jobject senderWeak, +static jlong nativeInit(JNIEnv* env, jclass clazz, jobject senderWeak, jobject inputChannelObj, jobject messageQueueObj) { sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env, inputChannelObj); @@ -256,17 +256,17 @@ static jint nativeInit(JNIEnv* env, jclass clazz, jobject senderWeak, } sender->incStrong(gInputEventSenderClassInfo.clazz); // retain a reference for the object - return reinterpret_cast<jint>(sender.get()); + return reinterpret_cast<jlong>(sender.get()); } -static void nativeDispose(JNIEnv* env, jclass clazz, jint senderPtr) { +static void nativeDispose(JNIEnv* env, jclass clazz, jlong senderPtr) { sp<NativeInputEventSender> sender = reinterpret_cast<NativeInputEventSender*>(senderPtr); sender->dispose(); sender->decStrong(gInputEventSenderClassInfo.clazz); // drop reference held by the object } -static jboolean nativeSendKeyEvent(JNIEnv* env, jclass clazz, jint senderPtr, +static jboolean nativeSendKeyEvent(JNIEnv* env, jclass clazz, jlong senderPtr, jint seq, jobject eventObj) { sp<NativeInputEventSender> sender = reinterpret_cast<NativeInputEventSender*>(senderPtr); @@ -276,7 +276,7 @@ static jboolean nativeSendKeyEvent(JNIEnv* env, jclass clazz, jint senderPtr, return !status; } -static jboolean nativeSendMotionEvent(JNIEnv* env, jclass clazz, jint senderPtr, +static jboolean nativeSendMotionEvent(JNIEnv* env, jclass clazz, jlong senderPtr, jint seq, jobject eventObj) { sp<NativeInputEventSender> sender = reinterpret_cast<NativeInputEventSender*>(senderPtr); @@ -289,13 +289,13 @@ static jboolean nativeSendMotionEvent(JNIEnv* env, jclass clazz, jint senderPtr, static JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ { "nativeInit", - "(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)I", + "(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)J", (void*)nativeInit }, - { "nativeDispose", "(I)V", + { "nativeDispose", "(J)V", (void*)nativeDispose }, - { "nativeSendKeyEvent", "(IILandroid/view/KeyEvent;)Z", + { "nativeSendKeyEvent", "(JILandroid/view/KeyEvent;)Z", (void*)nativeSendKeyEvent }, - { "nativeSendMotionEvent", "(IILandroid/view/MotionEvent;)Z", + { "nativeSendMotionEvent", "(JILandroid/view/MotionEvent;)Z", (void*)nativeSendMotionEvent }, }; diff --git a/core/jni/android_view_InputQueue.cpp b/core/jni/android_view_InputQueue.cpp index 7532c9d..21b73b1 100644 --- a/core/jni/android_view_InputQueue.cpp +++ b/core/jni/android_view_InputQueue.cpp @@ -151,7 +151,7 @@ void InputQueue::handleMessage(const Message& message) { mFinishedEvents.removeAt(0); } env->CallVoidMethod(inputQueueObj.get(), gInputQueueClassInfo.finishInputEvent, - reinterpret_cast<jint>(event), handled); + reinterpret_cast<jlong>(event), handled); recycleInputEvent(event); } break; @@ -193,7 +193,7 @@ InputQueue* InputQueue::createQueue(jobject inputQueueObj, const sp<Looper>& loo return new InputQueue(inputQueueObj, looper, pipeFds[0], pipeFds[1]); } -static jint nativeInit(JNIEnv* env, jobject clazz, jobject queueWeak, jobject jMsgQueue) { +static jlong nativeInit(JNIEnv* env, jobject clazz, jobject queueWeak, jobject jMsgQueue) { sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, jMsgQueue); if (messageQueue == NULL) { jniThrowRuntimeException(env, "MessageQueue is not initialized."); @@ -205,16 +205,16 @@ static jint nativeInit(JNIEnv* env, jobject clazz, jobject queueWeak, jobject jM return 0; } queue->incStrong(&gInputQueueClassInfo); - return reinterpret_cast<jint>(queue.get()); + return reinterpret_cast<jlong>(queue.get()); } -static void nativeDispose(JNIEnv* env, jobject clazz, jint ptr) { +static void nativeDispose(JNIEnv* env, jobject clazz, jlong ptr) { sp<InputQueue> queue = reinterpret_cast<InputQueue*>(ptr); queue->detachLooper(); queue->decStrong(&gInputQueueClassInfo); } -static jint nativeSendKeyEvent(JNIEnv* env, jobject clazz, jint ptr, jobject eventObj, +static jlong nativeSendKeyEvent(JNIEnv* env, jobject clazz, jlong ptr, jobject eventObj, jboolean predispatch) { InputQueue* queue = reinterpret_cast<InputQueue*>(ptr); KeyEvent* event = queue->createKeyEvent(); @@ -230,10 +230,10 @@ static jint nativeSendKeyEvent(JNIEnv* env, jobject clazz, jint ptr, jobject eve } queue->enqueueEvent(event); - return reinterpret_cast<jint>(event); + return reinterpret_cast<jlong>(event); } -static jint nativeSendMotionEvent(JNIEnv* env, jobject clazz, jint ptr, jobject eventObj) { +static jlong nativeSendMotionEvent(JNIEnv* env, jobject clazz, jlong ptr, jobject eventObj) { sp<InputQueue> queue = reinterpret_cast<InputQueue*>(ptr); MotionEvent* originalEvent = android_view_MotionEvent_getNativePtr(env, eventObj); if (!originalEvent) { @@ -243,15 +243,15 @@ static jint nativeSendMotionEvent(JNIEnv* env, jobject clazz, jint ptr, jobject MotionEvent* event = queue->createMotionEvent(); event->copyFrom(originalEvent, true /* keepHistory */); queue->enqueueEvent(event); - return reinterpret_cast<jint>(event); + return reinterpret_cast<jlong>(event); } static const JNINativeMethod g_methods[] = { - { "nativeInit", "(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;)I", + { "nativeInit", "(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;)J", (void*) nativeInit }, - { "nativeDispose", "(I)V", (void*) nativeDispose }, - { "nativeSendKeyEvent", "(ILandroid/view/KeyEvent;Z)I", (void*) nativeSendKeyEvent }, - { "nativeSendMotionEvent", "(ILandroid/view/MotionEvent;)I", (void*) nativeSendMotionEvent }, + { "nativeDispose", "(J)V", (void*) nativeDispose }, + { "nativeSendKeyEvent", "(JLandroid/view/KeyEvent;Z)J", (void*) nativeSendKeyEvent }, + { "nativeSendMotionEvent", "(JLandroid/view/MotionEvent;)J", (void*) nativeSendMotionEvent }, }; static const char* const kInputQueuePathName = "android/view/InputQueue"; @@ -272,7 +272,7 @@ int register_android_view_InputQueue(JNIEnv* env) { jclass clazz; FIND_CLASS(clazz, kInputQueuePathName); - GET_METHOD_ID(gInputQueueClassInfo.finishInputEvent, clazz, "finishInputEvent", "(IZ)V"); + GET_METHOD_ID(gInputQueueClassInfo.finishInputEvent, clazz, "finishInputEvent", "(JZ)V"); return AndroidRuntime::registerNativeMethods( env, kInputQueuePathName, diff --git a/core/jni/android_view_KeyCharacterMap.cpp b/core/jni/android_view_KeyCharacterMap.cpp index ffe2dea..62d5129 100644 --- a/core/jni/android_view_KeyCharacterMap.cpp +++ b/core/jni/android_view_KeyCharacterMap.cpp @@ -75,10 +75,10 @@ jobject android_view_KeyCharacterMap_create(JNIEnv* env, int32_t deviceId, } return env->NewObject(gKeyCharacterMapClassInfo.clazz, gKeyCharacterMapClassInfo.ctor, - reinterpret_cast<jint>(map)); + reinterpret_cast<jlong>(map)); } -static jint nativeReadFromParcel(JNIEnv *env, jobject clazz, jobject parcelObj) { +static jlong nativeReadFromParcel(JNIEnv *env, jobject clazz, jobject parcelObj) { Parcel* parcel = parcelForJavaObject(env, parcelObj); if (!parcel) { return 0; @@ -95,10 +95,10 @@ static jint nativeReadFromParcel(JNIEnv *env, jobject clazz, jobject parcelObj) } NativeKeyCharacterMap* map = new NativeKeyCharacterMap(deviceId, kcm); - return reinterpret_cast<jint>(map); + return reinterpret_cast<jlong>(map); } -static void nativeWriteToParcel(JNIEnv* env, jobject clazz, jint ptr, jobject parcelObj) { +static void nativeWriteToParcel(JNIEnv* env, jobject clazz, jlong ptr, jobject parcelObj) { NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr); Parcel* parcel = parcelForJavaObject(env, parcelObj); if (parcel) { @@ -107,18 +107,18 @@ static void nativeWriteToParcel(JNIEnv* env, jobject clazz, jint ptr, jobject pa } } -static void nativeDispose(JNIEnv *env, jobject clazz, jint ptr) { +static void nativeDispose(JNIEnv *env, jobject clazz, jlong ptr) { NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr); delete map; } -static jchar nativeGetCharacter(JNIEnv *env, jobject clazz, jint ptr, +static jchar nativeGetCharacter(JNIEnv *env, jobject clazz, jlong ptr, jint keyCode, jint metaState) { NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr); return map->getMap()->getCharacter(keyCode, metaState); } -static jboolean nativeGetFallbackAction(JNIEnv *env, jobject clazz, jint ptr, jint keyCode, +static jboolean nativeGetFallbackAction(JNIEnv *env, jobject clazz, jlong ptr, jint keyCode, jint metaState, jobject fallbackActionObj) { NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr); KeyCharacterMap::FallbackAction fallbackAction; @@ -133,12 +133,12 @@ static jboolean nativeGetFallbackAction(JNIEnv *env, jobject clazz, jint ptr, ji return result; } -static jchar nativeGetNumber(JNIEnv *env, jobject clazz, jint ptr, jint keyCode) { +static jchar nativeGetNumber(JNIEnv *env, jobject clazz, jlong ptr, jint keyCode) { NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr); return map->getMap()->getNumber(keyCode); } -static jchar nativeGetMatch(JNIEnv *env, jobject clazz, jint ptr, jint keyCode, +static jchar nativeGetMatch(JNIEnv *env, jobject clazz, jlong ptr, jint keyCode, jcharArray charsArray, jint metaState) { NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr); @@ -154,17 +154,17 @@ static jchar nativeGetMatch(JNIEnv *env, jobject clazz, jint ptr, jint keyCode, return result; } -static jchar nativeGetDisplayLabel(JNIEnv *env, jobject clazz, jint ptr, jint keyCode) { +static jchar nativeGetDisplayLabel(JNIEnv *env, jobject clazz, jlong ptr, jint keyCode) { NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr); return map->getMap()->getDisplayLabel(keyCode); } -static jint nativeGetKeyboardType(JNIEnv *env, jobject clazz, jint ptr) { +static jint nativeGetKeyboardType(JNIEnv *env, jobject clazz, jlong ptr) { NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr); return map->getMap()->getKeyboardType(); } -static jobjectArray nativeGetEvents(JNIEnv *env, jobject clazz, jint ptr, +static jobjectArray nativeGetEvents(JNIEnv *env, jobject clazz, jlong ptr, jcharArray charsArray) { NativeKeyCharacterMap* map = reinterpret_cast<NativeKeyCharacterMap*>(ptr); @@ -199,25 +199,25 @@ static jobjectArray nativeGetEvents(JNIEnv *env, jobject clazz, jint ptr, static JNINativeMethod g_methods[] = { /* name, signature, funcPtr */ - { "nativeReadFromParcel", "(Landroid/os/Parcel;)I", + { "nativeReadFromParcel", "(Landroid/os/Parcel;)J", (void*)nativeReadFromParcel }, - { "nativeWriteToParcel", "(ILandroid/os/Parcel;)V", + { "nativeWriteToParcel", "(JLandroid/os/Parcel;)V", (void*)nativeWriteToParcel }, - { "nativeDispose", "(I)V", + { "nativeDispose", "(J)V", (void*)nativeDispose }, - { "nativeGetCharacter", "(III)C", + { "nativeGetCharacter", "(JII)C", (void*)nativeGetCharacter }, - { "nativeGetFallbackAction", "(IIILandroid/view/KeyCharacterMap$FallbackAction;)Z", + { "nativeGetFallbackAction", "(JIILandroid/view/KeyCharacterMap$FallbackAction;)Z", (void*)nativeGetFallbackAction }, - { "nativeGetNumber", "(II)C", + { "nativeGetNumber", "(JI)C", (void*)nativeGetNumber }, - { "nativeGetMatch", "(II[CI)C", + { "nativeGetMatch", "(JI[CI)C", (void*)nativeGetMatch }, - { "nativeGetDisplayLabel", "(II)C", + { "nativeGetDisplayLabel", "(JI)C", (void*)nativeGetDisplayLabel }, - { "nativeGetKeyboardType", "(I)I", + { "nativeGetKeyboardType", "(J)I", (void*)nativeGetKeyboardType }, - { "nativeGetEvents", "(I[C)[Landroid/view/KeyEvent;", + { "nativeGetEvents", "(J[C)[Landroid/view/KeyEvent;", (void*)nativeGetEvents }, }; @@ -239,7 +239,7 @@ int register_android_view_KeyCharacterMap(JNIEnv* env) gKeyCharacterMapClassInfo.clazz = jclass(env->NewGlobalRef(gKeyCharacterMapClassInfo.clazz)); GET_METHOD_ID(gKeyCharacterMapClassInfo.ctor, gKeyCharacterMapClassInfo.clazz, - "<init>", "(I)V"); + "<init>", "(J)V"); FIND_CLASS(gKeyEventClassInfo.clazz, "android/view/KeyEvent"); gKeyEventClassInfo.clazz = jclass(env->NewGlobalRef(gKeyEventClassInfo.clazz)); diff --git a/core/jni/android_view_MotionEvent.cpp b/core/jni/android_view_MotionEvent.cpp index f1b90e1..76e145b 100644 --- a/core/jni/android_view_MotionEvent.cpp +++ b/core/jni/android_view_MotionEvent.cpp @@ -67,13 +67,13 @@ MotionEvent* android_view_MotionEvent_getNativePtr(JNIEnv* env, jobject eventObj return NULL; } return reinterpret_cast<MotionEvent*>( - env->GetIntField(eventObj, gMotionEventClassInfo.mNativePtr)); + env->GetLongField(eventObj, gMotionEventClassInfo.mNativePtr)); } static void android_view_MotionEvent_setNativePtr(JNIEnv* env, jobject eventObj, MotionEvent* event) { - env->SetIntField(eventObj, gMotionEventClassInfo.mNativePtr, - reinterpret_cast<int>(event)); + env->SetLongField(eventObj, gMotionEventClassInfo.mNativePtr, + reinterpret_cast<jlong>(event)); } jobject android_view_MotionEvent_obtainAsCopy(JNIEnv* env, const MotionEvent* event) { @@ -334,8 +334,8 @@ static void pointerPropertiesFromNative(JNIEnv* env, const PointerProperties* po // ---------------------------------------------------------------------------- -static jint android_view_MotionEvent_nativeInitialize(JNIEnv* env, jclass clazz, - jint nativePtr, +static jlong android_view_MotionEvent_nativeInitialize(JNIEnv* env, jclass clazz, + jlong nativePtr, jint deviceId, jint source, jint action, jint flags, jint edgeFlags, jint metaState, jint buttonState, jfloat xOffset, jfloat yOffset, jfloat xPrecision, jfloat yPrecision, @@ -377,7 +377,7 @@ static jint android_view_MotionEvent_nativeInitialize(JNIEnv* env, jclass clazz, xOffset, yOffset, xPrecision, yPrecision, downTimeNanos, eventTimeNanos, pointerCount, pointerProperties, rawPointerCoords); - return reinterpret_cast<jint>(event); + return reinterpret_cast<jlong>(event); Error: if (!nativePtr) { @@ -386,25 +386,25 @@ Error: return 0; } -static jint android_view_MotionEvent_nativeCopy(JNIEnv* env, jclass clazz, - jint destNativePtr, jint sourceNativePtr, jboolean keepHistory) { +static jlong android_view_MotionEvent_nativeCopy(JNIEnv* env, jclass clazz, + jlong destNativePtr, jlong sourceNativePtr, jboolean keepHistory) { MotionEvent* destEvent = reinterpret_cast<MotionEvent*>(destNativePtr); if (!destEvent) { destEvent = new MotionEvent(); } MotionEvent* sourceEvent = reinterpret_cast<MotionEvent*>(sourceNativePtr); destEvent->copyFrom(sourceEvent, keepHistory); - return reinterpret_cast<jint>(destEvent); + return reinterpret_cast<jlong>(destEvent); } static void android_view_MotionEvent_nativeDispose(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); delete event; } static void android_view_MotionEvent_nativeAddBatch(JNIEnv* env, jclass clazz, - jint nativePtr, jlong eventTimeNanos, jobjectArray pointerCoordsObjArray, + jlong nativePtr, jlong eventTimeNanos, jobjectArray pointerCoordsObjArray, jint metaState) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); size_t pointerCount = event->getPointerCount(); @@ -430,127 +430,127 @@ static void android_view_MotionEvent_nativeAddBatch(JNIEnv* env, jclass clazz, } static jint android_view_MotionEvent_nativeGetDeviceId(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getDeviceId(); } static jint android_view_MotionEvent_nativeGetSource(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getSource(); } static void android_view_MotionEvent_nativeSetSource(JNIEnv* env, jclass clazz, - jint nativePtr, jint source) { + jlong nativePtr, jint source) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); event->setSource(source); } static jint android_view_MotionEvent_nativeGetAction(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getAction(); } static void android_view_MotionEvent_nativeSetAction(JNIEnv* env, jclass clazz, - jint nativePtr, jint action) { + jlong nativePtr, jint action) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); event->setAction(action); } static jboolean android_view_MotionEvent_nativeIsTouchEvent(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->isTouchEvent(); } static jint android_view_MotionEvent_nativeGetFlags(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getFlags(); } static void android_view_MotionEvent_nativeSetFlags(JNIEnv* env, jclass clazz, - jint nativePtr, jint flags) { + jlong nativePtr, jint flags) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); event->setFlags(flags); } static jint android_view_MotionEvent_nativeGetEdgeFlags(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getEdgeFlags(); } static void android_view_MotionEvent_nativeSetEdgeFlags(JNIEnv* env, jclass clazz, - jint nativePtr, jint edgeFlags) { + jlong nativePtr, jint edgeFlags) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); event->setEdgeFlags(edgeFlags); } static jint android_view_MotionEvent_nativeGetMetaState(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getMetaState(); } static jint android_view_MotionEvent_nativeGetButtonState(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getButtonState(); } static void android_view_MotionEvent_nativeOffsetLocation(JNIEnv* env, jclass clazz, - jint nativePtr, jfloat deltaX, jfloat deltaY) { + jlong nativePtr, jfloat deltaX, jfloat deltaY) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->offsetLocation(deltaX, deltaY); } static jfloat android_view_MotionEvent_nativeGetXOffset(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getXOffset(); } static jfloat android_view_MotionEvent_nativeGetYOffset(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getYOffset(); } static jfloat android_view_MotionEvent_nativeGetXPrecision(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getXPrecision(); } static jfloat android_view_MotionEvent_nativeGetYPrecision(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getYPrecision(); } static jlong android_view_MotionEvent_nativeGetDownTimeNanos(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return event->getDownTime(); } static void android_view_MotionEvent_nativeSetDownTimeNanos(JNIEnv* env, jclass clazz, - jint nativePtr, jlong downTimeNanos) { + jlong nativePtr, jlong downTimeNanos) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); event->setDownTime(downTimeNanos); } static jint android_view_MotionEvent_nativeGetPointerCount(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return jint(event->getPointerCount()); } static jint android_view_MotionEvent_nativeGetPointerId(JNIEnv* env, jclass clazz, - jint nativePtr, jint pointerIndex) { + jlong nativePtr, jint pointerIndex) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); size_t pointerCount = event->getPointerCount(); if (!validatePointerIndex(env, pointerIndex, pointerCount)) { @@ -560,7 +560,7 @@ static jint android_view_MotionEvent_nativeGetPointerId(JNIEnv* env, jclass claz } static jint android_view_MotionEvent_nativeGetToolType(JNIEnv* env, jclass clazz, - jint nativePtr, jint pointerIndex) { + jlong nativePtr, jint pointerIndex) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); size_t pointerCount = event->getPointerCount(); if (!validatePointerIndex(env, pointerIndex, pointerCount)) { @@ -570,19 +570,19 @@ static jint android_view_MotionEvent_nativeGetToolType(JNIEnv* env, jclass clazz } static jint android_view_MotionEvent_nativeFindPointerIndex(JNIEnv* env, jclass clazz, - jint nativePtr, jint pointerId) { + jlong nativePtr, jint pointerId) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return jint(event->findPointerIndex(pointerId)); } static jint android_view_MotionEvent_nativeGetHistorySize(JNIEnv* env, jclass clazz, - jint nativePtr) { + jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); return jint(event->getHistorySize()); } static jlong android_view_MotionEvent_nativeGetEventTimeNanos(JNIEnv* env, jclass clazz, - jint nativePtr, jint historyPos) { + jlong nativePtr, jint historyPos) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); if (historyPos == HISTORY_CURRENT) { return event->getEventTime(); @@ -596,7 +596,7 @@ static jlong android_view_MotionEvent_nativeGetEventTimeNanos(JNIEnv* env, jclas } static jfloat android_view_MotionEvent_nativeGetRawAxisValue(JNIEnv* env, jclass clazz, - jint nativePtr, jint axis, jint pointerIndex, jint historyPos) { + jlong nativePtr, jint axis, jint pointerIndex, jint historyPos) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); size_t pointerCount = event->getPointerCount(); if (!validatePointerIndex(env, pointerIndex, pointerCount)) { @@ -615,7 +615,7 @@ static jfloat android_view_MotionEvent_nativeGetRawAxisValue(JNIEnv* env, jclass } static jfloat android_view_MotionEvent_nativeGetAxisValue(JNIEnv* env, jclass clazz, - jint nativePtr, jint axis, jint pointerIndex, jint historyPos) { + jlong nativePtr, jint axis, jint pointerIndex, jint historyPos) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); size_t pointerCount = event->getPointerCount(); if (!validatePointerIndex(env, pointerIndex, pointerCount)) { @@ -634,7 +634,7 @@ static jfloat android_view_MotionEvent_nativeGetAxisValue(JNIEnv* env, jclass cl } static void android_view_MotionEvent_nativeGetPointerCoords(JNIEnv* env, jclass clazz, - jint nativePtr, jint pointerIndex, jint historyPos, jobject outPointerCoordsObj) { + jlong nativePtr, jint pointerIndex, jint historyPos, jobject outPointerCoordsObj) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); size_t pointerCount = event->getPointerCount(); if (!validatePointerIndex(env, pointerIndex, pointerCount) @@ -657,7 +657,7 @@ static void android_view_MotionEvent_nativeGetPointerCoords(JNIEnv* env, jclass } static void android_view_MotionEvent_nativeGetPointerProperties(JNIEnv* env, jclass clazz, - jint nativePtr, jint pointerIndex, jobject outPointerPropertiesObj) { + jlong nativePtr, jint pointerIndex, jobject outPointerPropertiesObj) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); size_t pointerCount = event->getPointerCount(); if (!validatePointerIndex(env, pointerIndex, pointerCount) @@ -670,13 +670,13 @@ static void android_view_MotionEvent_nativeGetPointerProperties(JNIEnv* env, jcl } static void android_view_MotionEvent_nativeScale(JNIEnv* env, jclass clazz, - jint nativePtr, jfloat scale) { + jlong nativePtr, jfloat scale) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); event->scale(scale); } static void android_view_MotionEvent_nativeTransform(JNIEnv* env, jclass clazz, - jint nativePtr, jobject matrixObj) { + jlong nativePtr, jobject matrixObj) { SkMatrix* matrix = android_graphics_Matrix_getSkMatrix(env, matrixObj); MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); @@ -693,8 +693,8 @@ static void android_view_MotionEvent_nativeTransform(JNIEnv* env, jclass clazz, event->transform(m); } -static jint android_view_MotionEvent_nativeReadFromParcel(JNIEnv* env, jclass clazz, - jint nativePtr, jobject parcelObj) { +static jlong android_view_MotionEvent_nativeReadFromParcel(JNIEnv* env, jclass clazz, + jlong nativePtr, jobject parcelObj) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); if (!event) { event = new MotionEvent(); @@ -710,11 +710,11 @@ static jint android_view_MotionEvent_nativeReadFromParcel(JNIEnv* env, jclass cl jniThrowRuntimeException(env, "Failed to read MotionEvent parcel."); return 0; } - return reinterpret_cast<jint>(event); + return reinterpret_cast<jlong>(event); } static void android_view_MotionEvent_nativeWriteToParcel(JNIEnv* env, jclass clazz, - jint nativePtr, jobject parcelObj) { + jlong nativePtr, jobject parcelObj) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); Parcel* parcel = parcelForJavaObject(env, parcelObj); @@ -729,116 +729,116 @@ static void android_view_MotionEvent_nativeWriteToParcel(JNIEnv* env, jclass cla static JNINativeMethod gMotionEventMethods[] = { /* name, signature, funcPtr */ { "nativeInitialize", - "(IIIIIIIIFFFFJJI[Landroid/view/MotionEvent$PointerProperties;" - "[Landroid/view/MotionEvent$PointerCoords;)I", + "(JIIIIIIIFFFFJJI[Landroid/view/MotionEvent$PointerProperties;" + "[Landroid/view/MotionEvent$PointerCoords;)J", (void*)android_view_MotionEvent_nativeInitialize }, { "nativeCopy", - "(IIZ)I", + "(JJZ)J", (void*)android_view_MotionEvent_nativeCopy }, { "nativeDispose", - "(I)V", + "(J)V", (void*)android_view_MotionEvent_nativeDispose }, { "nativeAddBatch", - "(IJ[Landroid/view/MotionEvent$PointerCoords;I)V", + "(JJ[Landroid/view/MotionEvent$PointerCoords;I)V", (void*)android_view_MotionEvent_nativeAddBatch }, { "nativeGetDeviceId", - "(I)I", + "(J)I", (void*)android_view_MotionEvent_nativeGetDeviceId }, { "nativeGetSource", - "(I)I", + "(J)I", (void*)android_view_MotionEvent_nativeGetSource }, { "nativeSetSource", - "(II)I", + "(JI)I", (void*)android_view_MotionEvent_nativeSetSource }, { "nativeGetAction", - "(I)I", + "(J)I", (void*)android_view_MotionEvent_nativeGetAction }, { "nativeSetAction", - "(II)V", + "(JI)V", (void*)android_view_MotionEvent_nativeSetAction }, { "nativeIsTouchEvent", - "(I)Z", + "(J)Z", (void*)android_view_MotionEvent_nativeIsTouchEvent }, { "nativeGetFlags", - "(I)I", + "(J)I", (void*)android_view_MotionEvent_nativeGetFlags }, { "nativeSetFlags", - "(II)V", + "(JI)V", (void*)android_view_MotionEvent_nativeSetFlags }, { "nativeGetEdgeFlags", - "(I)I", + "(J)I", (void*)android_view_MotionEvent_nativeGetEdgeFlags }, { "nativeSetEdgeFlags", - "(II)V", + "(JI)V", (void*)android_view_MotionEvent_nativeSetEdgeFlags }, { "nativeGetMetaState", - "(I)I", + "(J)I", (void*)android_view_MotionEvent_nativeGetMetaState }, { "nativeGetButtonState", - "(I)I", + "(J)I", (void*)android_view_MotionEvent_nativeGetButtonState }, { "nativeOffsetLocation", - "(IFF)V", + "(JFF)V", (void*)android_view_MotionEvent_nativeOffsetLocation }, { "nativeGetXOffset", - "(I)F", + "(J)F", (void*)android_view_MotionEvent_nativeGetXOffset }, { "nativeGetYOffset", - "(I)F", + "(J)F", (void*)android_view_MotionEvent_nativeGetYOffset }, { "nativeGetXPrecision", - "(I)F", + "(J)F", (void*)android_view_MotionEvent_nativeGetXPrecision }, { "nativeGetYPrecision", - "(I)F", + "(J)F", (void*)android_view_MotionEvent_nativeGetYPrecision }, { "nativeGetDownTimeNanos", - "(I)J", + "(J)J", (void*)android_view_MotionEvent_nativeGetDownTimeNanos }, { "nativeSetDownTimeNanos", - "(IJ)V", + "(JJ)V", (void*)android_view_MotionEvent_nativeSetDownTimeNanos }, { "nativeGetPointerCount", - "(I)I", + "(J)I", (void*)android_view_MotionEvent_nativeGetPointerCount }, { "nativeGetPointerId", - "(II)I", + "(JI)I", (void*)android_view_MotionEvent_nativeGetPointerId }, { "nativeGetToolType", - "(II)I", + "(JI)I", (void*)android_view_MotionEvent_nativeGetToolType }, { "nativeFindPointerIndex", - "(II)I", + "(JI)I", (void*)android_view_MotionEvent_nativeFindPointerIndex }, { "nativeGetHistorySize", - "(I)I", + "(J)I", (void*)android_view_MotionEvent_nativeGetHistorySize }, { "nativeGetEventTimeNanos", - "(II)J", + "(JI)J", (void*)android_view_MotionEvent_nativeGetEventTimeNanos }, { "nativeGetRawAxisValue", - "(IIII)F", + "(JIII)F", (void*)android_view_MotionEvent_nativeGetRawAxisValue }, { "nativeGetAxisValue", - "(IIII)F", + "(JIII)F", (void*)android_view_MotionEvent_nativeGetAxisValue }, { "nativeGetPointerCoords", - "(IIILandroid/view/MotionEvent$PointerCoords;)V", + "(JIILandroid/view/MotionEvent$PointerCoords;)V", (void*)android_view_MotionEvent_nativeGetPointerCoords }, { "nativeGetPointerProperties", - "(IILandroid/view/MotionEvent$PointerProperties;)V", + "(JILandroid/view/MotionEvent$PointerProperties;)V", (void*)android_view_MotionEvent_nativeGetPointerProperties }, { "nativeScale", - "(IF)V", + "(JF)V", (void*)android_view_MotionEvent_nativeScale }, { "nativeTransform", - "(ILandroid/graphics/Matrix;)V", + "(JLandroid/graphics/Matrix;)V", (void*)android_view_MotionEvent_nativeTransform }, { "nativeReadFromParcel", - "(ILandroid/os/Parcel;)I", + "(JLandroid/os/Parcel;)J", (void*)android_view_MotionEvent_nativeReadFromParcel }, { "nativeWriteToParcel", - "(ILandroid/os/Parcel;)V", + "(JLandroid/os/Parcel;)V", (void*)android_view_MotionEvent_nativeWriteToParcel }, }; @@ -871,7 +871,7 @@ int register_android_view_MotionEvent(JNIEnv* env) { GET_METHOD_ID(gMotionEventClassInfo.recycle, gMotionEventClassInfo.clazz, "recycle", "()V"); GET_FIELD_ID(gMotionEventClassInfo.mNativePtr, gMotionEventClassInfo.clazz, - "mNativePtr", "I"); + "mNativePtr", "J"); jclass clazz; FIND_CLASS(clazz, "android/view/MotionEvent$PointerCoords"); diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp index 1868469..c2d4ec0 100644 --- a/core/jni/android_view_Surface.cpp +++ b/core/jni/android_view_Surface.cpp @@ -96,7 +96,7 @@ sp<Surface> android_view_Surface_getSurface(JNIEnv* env, jobject surfaceObj) { gSurfaceClassInfo.mLock); if (env->MonitorEnter(lock) == JNI_OK) { sur = reinterpret_cast<Surface *>( - env->GetIntField(surfaceObj, gSurfaceClassInfo.mNativeObject)); + env->GetLongField(surfaceObj, gSurfaceClassInfo.mNativeObject)); env->MonitorExit(lock); } return sur; @@ -113,7 +113,8 @@ jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env, return NULL; } - jobject surfaceObj = env->NewObject(gSurfaceClassInfo.clazz, gSurfaceClassInfo.ctor, surface.get()); + jobject surfaceObj = env->NewObject(gSurfaceClassInfo.clazz, + gSurfaceClassInfo.ctor, (jlong)surface.get()); if (surfaceObj == NULL) { if (env->ExceptionCheck()) { ALOGE("Could not create instance of Surface from IGraphicBufferProducer."); @@ -134,7 +135,7 @@ static inline bool isSurfaceValid(const sp<Surface>& sur) { // ---------------------------------------------------------------------------- -static jint nativeCreateFromSurfaceTexture(JNIEnv* env, jclass clazz, +static jlong nativeCreateFromSurfaceTexture(JNIEnv* env, jclass clazz, jobject surfaceTextureObj) { sp<IGraphicBufferProducer> producer(SurfaceTexture_getProducer(env, surfaceTextureObj)); if (producer == NULL) { @@ -150,20 +151,20 @@ static jint nativeCreateFromSurfaceTexture(JNIEnv* env, jclass clazz, } surface->incStrong(&sRefBaseOwner); - return int(surface.get()); + return jlong(surface.get()); } -static void nativeRelease(JNIEnv* env, jclass clazz, jint nativeObject) { +static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) { sp<Surface> sur(reinterpret_cast<Surface *>(nativeObject)); sur->decStrong(&sRefBaseOwner); } -static jboolean nativeIsValid(JNIEnv* env, jclass clazz, jint nativeObject) { +static jboolean nativeIsValid(JNIEnv* env, jclass clazz, jlong nativeObject) { sp<Surface> sur(reinterpret_cast<Surface *>(nativeObject)); return isSurfaceValid(sur) ? JNI_TRUE : JNI_FALSE; } -static jboolean nativeIsConsumerRunningBehind(JNIEnv* env, jclass clazz, jint nativeObject) { +static jboolean nativeIsConsumerRunningBehind(JNIEnv* env, jclass clazz, jlong nativeObject) { sp<Surface> sur(reinterpret_cast<Surface *>(nativeObject)); if (!isSurfaceValid(sur)) { doThrowIAE(env); @@ -191,14 +192,14 @@ static inline SkBitmap::Config convertPixelFormat(PixelFormat format) { static inline void swapCanvasPtr(JNIEnv* env, jobject canvasObj, SkCanvas* newCanvas) { jobject canvasFinalizerObj = env->GetObjectField(canvasObj, gCanvasClassInfo.mFinalizer); SkCanvas* previousCanvas = reinterpret_cast<SkCanvas*>( - env->GetIntField(canvasObj, gCanvasClassInfo.mNativeCanvas)); - env->SetIntField(canvasObj, gCanvasClassInfo.mNativeCanvas, (int)newCanvas); - env->SetIntField(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (int)newCanvas); + env->GetLongField(canvasObj, gCanvasClassInfo.mNativeCanvas)); + env->SetLongField(canvasObj, gCanvasClassInfo.mNativeCanvas, (jlong)newCanvas); + env->SetLongField(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (jlong)newCanvas); SkSafeUnref(previousCanvas); } -static jint nativeLockCanvas(JNIEnv* env, jclass clazz, - jint nativeObject, jobject canvasObj, jobject dirtyRectObj) { +static jlong nativeLockCanvas(JNIEnv* env, jclass clazz, + jlong nativeObject, jobject canvasObj, jobject dirtyRectObj) { sp<Surface> surface(reinterpret_cast<Surface *>(nativeObject)); if (!isSurfaceValid(surface)) { @@ -262,11 +263,11 @@ static jint nativeLockCanvas(JNIEnv* env, jclass clazz, // because the latter could be replaced while the surface is locked. sp<Surface> lockedSurface(surface); lockedSurface->incStrong(&sRefBaseOwner); - return (int) lockedSurface.get(); + return (jlong) lockedSurface.get(); } static void nativeUnlockCanvasAndPost(JNIEnv* env, jclass clazz, - jint nativeObject, jobject canvasObj) { + jlong nativeObject, jobject canvasObj) { sp<Surface> surface(reinterpret_cast<Surface *>(nativeObject)); if (!isSurfaceValid(surface)) { return; @@ -285,8 +286,8 @@ static void nativeUnlockCanvasAndPost(JNIEnv* env, jclass clazz, // ---------------------------------------------------------------------------- -static jint nativeCreateFromSurfaceControl(JNIEnv* env, jclass clazz, - jint surfaceControlNativeObj) { +static jlong nativeCreateFromSurfaceControl(JNIEnv* env, jclass clazz, + jlong surfaceControlNativeObj) { /* * This is used by the WindowManagerService just after constructing * a Surface and is necessary for returning the Surface reference to @@ -298,11 +299,11 @@ static jint nativeCreateFromSurfaceControl(JNIEnv* env, jclass clazz, if (surface != NULL) { surface->incStrong(&sRefBaseOwner); } - return reinterpret_cast<jint>(surface.get()); + return reinterpret_cast<jlong>(surface.get()); } -static jint nativeReadFromParcel(JNIEnv* env, jclass clazz, - jint nativeObject, jobject parcelObj) { +static jlong nativeReadFromParcel(JNIEnv* env, jclass clazz, + jlong nativeObject, jobject parcelObj) { Parcel* parcel = parcelForJavaObject(env, parcelObj); if (parcel == NULL) { doThrowNPE(env); @@ -317,7 +318,7 @@ static jint nativeReadFromParcel(JNIEnv* env, jclass clazz, if (self != NULL && (self->getIGraphicBufferProducer()->asBinder() == binder)) { // same IGraphicBufferProducer, return ourselves - return int(self.get()); + return jlong(self.get()); } sp<Surface> sur; @@ -334,11 +335,11 @@ static jint nativeReadFromParcel(JNIEnv* env, jclass clazz, self->decStrong(&sRefBaseOwner); } - return int(sur.get()); + return jlong(sur.get()); } static void nativeWriteToParcel(JNIEnv* env, jclass clazz, - jint nativeObject, jobject parcelObj) { + jlong nativeObject, jobject parcelObj) { Parcel* parcel = parcelForJavaObject(env, parcelObj); if (parcel == NULL) { doThrowNPE(env); @@ -351,23 +352,23 @@ static void nativeWriteToParcel(JNIEnv* env, jclass clazz, // ---------------------------------------------------------------------------- static JNINativeMethod gSurfaceMethods[] = { - {"nativeCreateFromSurfaceTexture", "(Landroid/graphics/SurfaceTexture;)I", + {"nativeCreateFromSurfaceTexture", "(Landroid/graphics/SurfaceTexture;)J", (void*)nativeCreateFromSurfaceTexture }, - {"nativeRelease", "(I)V", + {"nativeRelease", "(J)V", (void*)nativeRelease }, - {"nativeIsValid", "(I)Z", + {"nativeIsValid", "(J)Z", (void*)nativeIsValid }, - {"nativeIsConsumerRunningBehind", "(I)Z", + {"nativeIsConsumerRunningBehind", "(J)Z", (void*)nativeIsConsumerRunningBehind }, - {"nativeLockCanvas", "(ILandroid/graphics/Canvas;Landroid/graphics/Rect;)I", + {"nativeLockCanvas", "(JLandroid/graphics/Canvas;Landroid/graphics/Rect;)J", (void*)nativeLockCanvas }, - {"nativeUnlockCanvasAndPost", "(ILandroid/graphics/Canvas;)V", + {"nativeUnlockCanvasAndPost", "(JLandroid/graphics/Canvas;)V", (void*)nativeUnlockCanvasAndPost }, - {"nativeCreateFromSurfaceControl", "(I)I", + {"nativeCreateFromSurfaceControl", "(J)J", (void*)nativeCreateFromSurfaceControl }, - {"nativeReadFromParcel", "(ILandroid/os/Parcel;)I", + {"nativeReadFromParcel", "(JLandroid/os/Parcel;)J", (void*)nativeReadFromParcel }, - {"nativeWriteToParcel", "(ILandroid/os/Parcel;)V", + {"nativeWriteToParcel", "(JLandroid/os/Parcel;)V", (void*)nativeWriteToParcel }, }; @@ -379,18 +380,18 @@ int register_android_view_Surface(JNIEnv* env) jclass clazz = env->FindClass("android/view/Surface"); gSurfaceClassInfo.clazz = jclass(env->NewGlobalRef(clazz)); gSurfaceClassInfo.mNativeObject = - env->GetFieldID(gSurfaceClassInfo.clazz, "mNativeObject", "I"); + env->GetFieldID(gSurfaceClassInfo.clazz, "mNativeObject", "J"); gSurfaceClassInfo.mLock = env->GetFieldID(gSurfaceClassInfo.clazz, "mLock", "Ljava/lang/Object;"); - gSurfaceClassInfo.ctor = env->GetMethodID(gSurfaceClassInfo.clazz, "<init>", "(I)V"); + gSurfaceClassInfo.ctor = env->GetMethodID(gSurfaceClassInfo.clazz, "<init>", "(J)V"); clazz = env->FindClass("android/graphics/Canvas"); gCanvasClassInfo.mFinalizer = env->GetFieldID(clazz, "mFinalizer", "Landroid/graphics/Canvas$CanvasFinalizer;"); - gCanvasClassInfo.mNativeCanvas = env->GetFieldID(clazz, "mNativeCanvas", "I"); + gCanvasClassInfo.mNativeCanvas = env->GetFieldID(clazz, "mNativeCanvas", "J"); gCanvasClassInfo.mSurfaceFormat = env->GetFieldID(clazz, "mSurfaceFormat", "I"); clazz = env->FindClass("android/graphics/Canvas$CanvasFinalizer"); - gCanvasFinalizerClassInfo.mNativeCanvas = env->GetFieldID(clazz, "mNativeCanvas", "I"); + gCanvasFinalizerClassInfo.mNativeCanvas = env->GetFieldID(clazz, "mNativeCanvas", "J"); clazz = env->FindClass("android/graphics/Rect"); gRectClassInfo.left = env->GetFieldID(clazz, "left", "I"); diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index 67eade8..bd53095 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -122,7 +122,7 @@ private: // ---------------------------------------------------------------------------- -static jint nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj, +static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj, jstring nameStr, jint w, jint h, jint format, jint flags) { ScopedUtfChars name(env, nameStr); sp<SurfaceComposerClient> client(android_view_SurfaceSession_getClient(env, sessionObj)); @@ -133,15 +133,15 @@ static jint nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj, return 0; } surface->incStrong((void *)nativeCreate); - return int(surface.get()); + return reinterpret_cast<jlong>(surface.get()); } -static void nativeRelease(JNIEnv* env, jclass clazz, jint nativeObject) { +static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) { sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject)); ctrl->decStrong((void *)nativeCreate); } -static void nativeDestroy(JNIEnv* env, jclass clazz, jint nativeObject) { +static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) { sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject)); ctrl->clear(); ctrl->decStrong((void *)nativeCreate); @@ -229,7 +229,7 @@ static void nativeSetAnimationTransaction(JNIEnv* env, jclass clazz) { SurfaceComposerClient::setAnimationTransaction(); } -static void nativeSetLayer(JNIEnv* env, jclass clazz, jint nativeObject, jint zorder) { +static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong nativeObject, jint zorder) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setLayer(zorder); if (err < 0 && err != NO_INIT) { @@ -237,7 +237,7 @@ static void nativeSetLayer(JNIEnv* env, jclass clazz, jint nativeObject, jint zo } } -static void nativeSetPosition(JNIEnv* env, jclass clazz, jint nativeObject, jfloat x, jfloat y) { +static void nativeSetPosition(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat x, jfloat y) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setPosition(x, y); if (err < 0 && err != NO_INIT) { @@ -245,7 +245,7 @@ static void nativeSetPosition(JNIEnv* env, jclass clazz, jint nativeObject, jflo } } -static void nativeSetSize(JNIEnv* env, jclass clazz, jint nativeObject, jint w, jint h) { +static void nativeSetSize(JNIEnv* env, jclass clazz, jlong nativeObject, jint w, jint h) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setSize(w, h); if (err < 0 && err != NO_INIT) { @@ -253,7 +253,7 @@ static void nativeSetSize(JNIEnv* env, jclass clazz, jint nativeObject, jint w, } } -static void nativeSetFlags(JNIEnv* env, jclass clazz, jint nativeObject, jint flags, jint mask) { +static void nativeSetFlags(JNIEnv* env, jclass clazz, jlong nativeObject, jint flags, jint mask) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setFlags(flags, mask); if (err < 0 && err != NO_INIT) { @@ -261,7 +261,7 @@ static void nativeSetFlags(JNIEnv* env, jclass clazz, jint nativeObject, jint fl } } -static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jint nativeObject, jobject regionObj) { +static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jlong nativeObject, jobject regionObj) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj); if (!region) { @@ -286,7 +286,7 @@ static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jint nativ } } -static void nativeSetAlpha(JNIEnv* env, jclass clazz, jint nativeObject, jfloat alpha) { +static void nativeSetAlpha(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat alpha) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setAlpha(alpha); if (err < 0 && err != NO_INIT) { @@ -294,7 +294,7 @@ static void nativeSetAlpha(JNIEnv* env, jclass clazz, jint nativeObject, jfloat } } -static void nativeSetMatrix(JNIEnv* env, jclass clazz, jint nativeObject, +static void nativeSetMatrix(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat dsdx, jfloat dtdx, jfloat dsdy, jfloat dtdy) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setMatrix(dsdx, dtdx, dsdy, dtdy); @@ -303,7 +303,7 @@ static void nativeSetMatrix(JNIEnv* env, jclass clazz, jint nativeObject, } } -static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jint nativeObject, +static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jlong nativeObject, jint l, jint t, jint r, jint b) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); Rect crop(l, t, r, b); @@ -313,7 +313,7 @@ static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jint nativeObject, } } -static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jint nativeObject, jint layerStack) { +static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jlong nativeObject, jint layerStack) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setLayerStack(layerStack); if (err < 0 && err != NO_INIT) { @@ -341,7 +341,7 @@ static void nativeDestroyDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) { } static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz, - jobject tokenObj, jint nativeSurfaceObject) { + jobject tokenObj, jlong nativeSurfaceObject) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; sp<IGraphicBufferProducer> bufferProducer; @@ -410,11 +410,11 @@ static void nativeUnblankDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) { // ---------------------------------------------------------------------------- static JNINativeMethod sSurfaceControlMethods[] = { - {"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIII)I", + {"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIII)J", (void*)nativeCreate }, - {"nativeRelease", "(I)V", + {"nativeRelease", "(J)V", (void*)nativeRelease }, - {"nativeDestroy", "(I)V", + {"nativeDestroy", "(J)V", (void*)nativeDestroy }, {"nativeScreenshot", "(Landroid/os/IBinder;IIIIZ)Landroid/graphics/Bitmap;", (void*)nativeScreenshotBitmap }, @@ -426,23 +426,23 @@ static JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeCloseTransaction }, {"nativeSetAnimationTransaction", "()V", (void*)nativeSetAnimationTransaction }, - {"nativeSetLayer", "(II)V", + {"nativeSetLayer", "(JI)V", (void*)nativeSetLayer }, - {"nativeSetPosition", "(IFF)V", + {"nativeSetPosition", "(JFF)V", (void*)nativeSetPosition }, - {"nativeSetSize", "(III)V", + {"nativeSetSize", "(JII)V", (void*)nativeSetSize }, - {"nativeSetTransparentRegionHint", "(ILandroid/graphics/Region;)V", + {"nativeSetTransparentRegionHint", "(JLandroid/graphics/Region;)V", (void*)nativeSetTransparentRegionHint }, - {"nativeSetAlpha", "(IF)V", + {"nativeSetAlpha", "(JF)V", (void*)nativeSetAlpha }, - {"nativeSetMatrix", "(IFFFF)V", + {"nativeSetMatrix", "(JFFFF)V", (void*)nativeSetMatrix }, - {"nativeSetFlags", "(III)V", + {"nativeSetFlags", "(JII)V", (void*)nativeSetFlags }, - {"nativeSetWindowCrop", "(IIIII)V", + {"nativeSetWindowCrop", "(JIIII)V", (void*)nativeSetWindowCrop }, - {"nativeSetLayerStack", "(II)V", + {"nativeSetLayerStack", "(JI)V", (void*)nativeSetLayerStack }, {"nativeGetBuiltInDisplay", "(I)Landroid/os/IBinder;", (void*)nativeGetBuiltInDisplay }, @@ -450,7 +450,7 @@ static JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeCreateDisplay }, {"nativeDestroyDisplay", "(Landroid/os/IBinder;)V", (void*)nativeDestroyDisplay }, - {"nativeSetDisplaySurface", "(Landroid/os/IBinder;I)V", + {"nativeSetDisplaySurface", "(Landroid/os/IBinder;J)V", (void*)nativeSetDisplaySurface }, {"nativeSetDisplayLayerStack", "(Landroid/os/IBinder;I)V", (void*)nativeSetDisplayLayerStack }, diff --git a/core/jni/android_view_TextureView.cpp b/core/jni/android_view_TextureView.cpp index 0f429005..54f9278 100644 --- a/core/jni/android_view_TextureView.cpp +++ b/core/jni/android_view_TextureView.cpp @@ -59,9 +59,15 @@ static struct { #define GET_INT(object, field) \ env->GetIntField(object, field) +#define GET_LONG(object, field) \ + env->GetLongField(object, field) + #define SET_INT(object, field, value) \ env->SetIntField(object, field, value) +#define SET_LONG(object, field, value) \ + env->SetLongField(object, field, value) + #define INVOKEV(object, method, ...) \ env->CallVoidMethod(object, method, __VA_ARGS__) @@ -103,35 +109,35 @@ static void android_view_TextureView_createNativeWindow(JNIEnv* env, jobject tex sp<ANativeWindow> window = new Surface(producer, true); window->incStrong((void*)android_view_TextureView_createNativeWindow); - SET_INT(textureView, gTextureViewClassInfo.nativeWindow, jint(window.get())); + SET_LONG(textureView, gTextureViewClassInfo.nativeWindow, jlong(window.get())); } static void android_view_TextureView_destroyNativeWindow(JNIEnv* env, jobject textureView) { ANativeWindow* nativeWindow = (ANativeWindow*) - GET_INT(textureView, gTextureViewClassInfo.nativeWindow); + GET_LONG(textureView, gTextureViewClassInfo.nativeWindow); if (nativeWindow) { sp<ANativeWindow> window(nativeWindow); window->decStrong((void*)android_view_TextureView_createNativeWindow); - SET_INT(textureView, gTextureViewClassInfo.nativeWindow, 0); + SET_LONG(textureView, gTextureViewClassInfo.nativeWindow, 0); } } static inline void swapCanvasPtr(JNIEnv* env, jobject canvasObj, SkCanvas* newCanvas) { jobject canvasFinalizerObj = env->GetObjectField(canvasObj, gCanvasClassInfo.mFinalizer); SkCanvas* previousCanvas = reinterpret_cast<SkCanvas*>( - env->GetIntField(canvasObj, gCanvasClassInfo.mNativeCanvas)); - env->SetIntField(canvasObj, gCanvasClassInfo.mNativeCanvas, (int)newCanvas); - env->SetIntField(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (int)newCanvas); + env->GetLongField(canvasObj, gCanvasClassInfo.mNativeCanvas)); + env->SetLongField(canvasObj, gCanvasClassInfo.mNativeCanvas, (jlong)newCanvas); + env->SetLongField(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (jlong)newCanvas); SkSafeUnref(previousCanvas); } static jboolean android_view_TextureView_lockCanvas(JNIEnv* env, jobject, - jint nativeWindow, jobject canvas, jobject dirtyRect) { + jlong nativeWindow, jobject canvas, jobject dirtyRect) { if (!nativeWindow) { - return false; + return JNI_FALSE; } ANativeWindow_Buffer buffer; @@ -148,7 +154,7 @@ static jboolean android_view_TextureView_lockCanvas(JNIEnv* env, jobject, sp<ANativeWindow> window((ANativeWindow*) nativeWindow); int32_t status = native_window_lock(window.get(), &buffer, &rect); - if (status) return false; + if (status) return JNI_FALSE; ssize_t bytesCount = buffer.stride * bytesPerPixel(buffer.format); @@ -179,11 +185,11 @@ static jboolean android_view_TextureView_lockCanvas(JNIEnv* env, jobject, int(rect.left), int(rect.top), int(rect.right), int(rect.bottom)); } - return true; + return JNI_TRUE; } static void android_view_TextureView_unlockCanvasAndPost(JNIEnv* env, jobject, - jint nativeWindow, jobject canvas) { + jlong nativeWindow, jobject canvas) { SkCanvas* nativeCanvas = SkNEW(SkCanvas); swapCanvasPtr(env, canvas, nativeCanvas); @@ -206,9 +212,9 @@ static JNINativeMethod gMethods[] = { { "nDestroyNativeWindow", "()V", (void*) android_view_TextureView_destroyNativeWindow }, - { "nLockCanvas", "(ILandroid/graphics/Canvas;Landroid/graphics/Rect;)Z", + { "nLockCanvas", "(JLandroid/graphics/Canvas;Landroid/graphics/Rect;)Z", (void*) android_view_TextureView_lockCanvas }, - { "nUnlockCanvasAndPost", "(ILandroid/graphics/Canvas;)V", + { "nUnlockCanvasAndPost", "(JLandroid/graphics/Canvas;)V", (void*) android_view_TextureView_unlockCanvasAndPost }, }; @@ -236,14 +242,14 @@ int register_android_view_TextureView(JNIEnv* env) { FIND_CLASS(clazz, "android/graphics/Canvas"); GET_FIELD_ID(gCanvasClassInfo.mFinalizer, clazz, "mFinalizer", "Landroid/graphics/Canvas$CanvasFinalizer;"); - GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I"); + GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J"); GET_FIELD_ID(gCanvasClassInfo.mSurfaceFormat, clazz, "mSurfaceFormat", "I"); FIND_CLASS(clazz, "android/graphics/Canvas$CanvasFinalizer"); - GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I"); + GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J"); FIND_CLASS(clazz, "android/view/TextureView"); - GET_FIELD_ID(gTextureViewClassInfo.nativeWindow, clazz, "mNativeWindow", "I"); + GET_FIELD_ID(gTextureViewClassInfo.nativeWindow, clazz, "mNativeWindow", "J"); return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); } diff --git a/core/jni/android_view_VelocityTracker.cpp b/core/jni/android_view_VelocityTracker.cpp index 90ba2ba..1e36932 100644 --- a/core/jni/android_view_VelocityTracker.cpp +++ b/core/jni/android_view_VelocityTracker.cpp @@ -138,26 +138,26 @@ bool VelocityTrackerState::getEstimator(int32_t id, VelocityTracker::Estimator* // --- JNI Methods --- -static jint android_view_VelocityTracker_nativeInitialize(JNIEnv* env, jclass clazz, +static jlong android_view_VelocityTracker_nativeInitialize(JNIEnv* env, jclass clazz, jstring strategyStr) { if (strategyStr) { ScopedUtfChars strategy(env, strategyStr); - return reinterpret_cast<jint>(new VelocityTrackerState(strategy.c_str())); + return reinterpret_cast<jlong>(new VelocityTrackerState(strategy.c_str())); } - return reinterpret_cast<jint>(new VelocityTrackerState(NULL)); + return reinterpret_cast<jlong>(new VelocityTrackerState(NULL)); } -static void android_view_VelocityTracker_nativeDispose(JNIEnv* env, jclass clazz, jint ptr) { +static void android_view_VelocityTracker_nativeDispose(JNIEnv* env, jclass clazz, jlong ptr) { VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr); delete state; } -static void android_view_VelocityTracker_nativeClear(JNIEnv* env, jclass clazz, jint ptr) { +static void android_view_VelocityTracker_nativeClear(JNIEnv* env, jclass clazz, jlong ptr) { VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr); state->clear(); } -static void android_view_VelocityTracker_nativeAddMovement(JNIEnv* env, jclass clazz, jint ptr, +static void android_view_VelocityTracker_nativeAddMovement(JNIEnv* env, jclass clazz, jlong ptr, jobject eventObj) { const MotionEvent* event = android_view_MotionEvent_getNativePtr(env, eventObj); if (!event) { @@ -170,13 +170,13 @@ static void android_view_VelocityTracker_nativeAddMovement(JNIEnv* env, jclass c } static void android_view_VelocityTracker_nativeComputeCurrentVelocity(JNIEnv* env, jclass clazz, - jint ptr, jint units, jfloat maxVelocity) { + jlong ptr, jint units, jfloat maxVelocity) { VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr); state->computeCurrentVelocity(units, maxVelocity); } static jfloat android_view_VelocityTracker_nativeGetXVelocity(JNIEnv* env, jclass clazz, - jint ptr, jint id) { + jlong ptr, jint id) { VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr); float vx; state->getVelocity(id, &vx, NULL); @@ -184,7 +184,7 @@ static jfloat android_view_VelocityTracker_nativeGetXVelocity(JNIEnv* env, jclas } static jfloat android_view_VelocityTracker_nativeGetYVelocity(JNIEnv* env, jclass clazz, - jint ptr, jint id) { + jlong ptr, jint id) { VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr); float vy; state->getVelocity(id, NULL, &vy); @@ -192,7 +192,7 @@ static jfloat android_view_VelocityTracker_nativeGetYVelocity(JNIEnv* env, jclas } static jboolean android_view_VelocityTracker_nativeGetEstimator(JNIEnv* env, jclass clazz, - jint ptr, jint id, jobject outEstimatorObj) { + jlong ptr, jint id, jobject outEstimatorObj) { VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr); VelocityTracker::Estimator estimator; bool result = state->getEstimator(id, &estimator); @@ -217,28 +217,28 @@ static jboolean android_view_VelocityTracker_nativeGetEstimator(JNIEnv* env, jcl static JNINativeMethod gVelocityTrackerMethods[] = { /* name, signature, funcPtr */ { "nativeInitialize", - "(Ljava/lang/String;)I", + "(Ljava/lang/String;)J", (void*)android_view_VelocityTracker_nativeInitialize }, { "nativeDispose", - "(I)V", + "(J)V", (void*)android_view_VelocityTracker_nativeDispose }, { "nativeClear", - "(I)V", + "(J)V", (void*)android_view_VelocityTracker_nativeClear }, { "nativeAddMovement", - "(ILandroid/view/MotionEvent;)V", + "(JLandroid/view/MotionEvent;)V", (void*)android_view_VelocityTracker_nativeAddMovement }, { "nativeComputeCurrentVelocity", - "(IIF)V", + "(JIF)V", (void*)android_view_VelocityTracker_nativeComputeCurrentVelocity }, { "nativeGetXVelocity", - "(II)F", + "(JI)F", (void*)android_view_VelocityTracker_nativeGetXVelocity }, { "nativeGetYVelocity", - "(II)F", + "(JI)F", (void*)android_view_VelocityTracker_nativeGetYVelocity }, { "nativeGetEstimator", - "(IILandroid/view/VelocityTracker$Estimator;)Z", + "(JILandroid/view/VelocityTracker$Estimator;)Z", (void*)android_view_VelocityTracker_nativeGetEstimator }, }; diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp index 00da0f7..a860918 100644 --- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp +++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp @@ -202,7 +202,7 @@ copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntr } // Only copy out the native file if it's different. - struct stat st; + struct stat64 st; if (!isFileDifferent(localFileName, uncompLen, modTime, crc, &st)) { return INSTALL_SUCCEEDED; } diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp index 50b3302..a0982bd 100644 --- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp +++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp @@ -82,7 +82,7 @@ static void nativeClassInit(JNIEnv *_env, jclass eglImplClass) gSurface_NativePixelRefFieldID = _env->GetFieldID(surface_class, "mNativePixelRef", "I"); jclass bitmap_class = _env->FindClass("android/graphics/Bitmap"); - gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "I"); + gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "J"); } static const jint gNull_attrib_base[] = {EGL_NONE}; @@ -276,7 +276,7 @@ static void jni_eglCreatePixmapSurface(JNIEnv *_env, jobject _this, jobject out_ jint* base = 0; SkBitmap const * nativeBitmap = - (SkBitmap const *)_env->GetIntField(native_pixmap, + (SkBitmap const *)_env->GetLongField(native_pixmap, gBitmap_NativeBitmapFieldID); SkPixelRef* ref = nativeBitmap ? nativeBitmap->pixelRef() : 0; if (ref == NULL) { diff --git a/core/res/res/values-mcc302-mnc510/config.xml b/core/res/res/values-mcc302-mnc510/config.xml deleted file mode 100644 index 706570c..0000000 --- a/core/res/res/values-mcc302-mnc510/config.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** Copyright 2013, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ ---> - -<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <!-- Don't use roaming icon for considered operators --> - <string-array translatable="false" name="config_operatorConsideredNonRoaming"> - <item>302</item> - </string-array> -</resources> diff --git a/core/res/res/values-mcc404-mnc85/config.xml b/core/res/res/values-mcc404/config.xml index fd780ab..a106b0a 100644 --- a/core/res/res/values-mcc404-mnc85/config.xml +++ b/core/res/res/values-mcc404/config.xml @@ -20,6 +20,7 @@ <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <!-- Show roaming icon though same named operators. --> <string-array translatable="false" name="config_sameNamedOperatorConsideredRoaming"> - <item>40483</item> + <item>404</item> + <item>405</item> </string-array> </resources> diff --git a/core/res/res/values-mcc302-mnc500/config.xml b/core/res/res/values-mcc405/config.xml index 706570c..a106b0a 100644 --- a/core/res/res/values-mcc302-mnc500/config.xml +++ b/core/res/res/values-mcc405/config.xml @@ -18,8 +18,9 @@ --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <!-- Don't use roaming icon for considered operators --> - <string-array translatable="false" name="config_operatorConsideredNonRoaming"> - <item>302</item> + <!-- Show roaming icon though same named operators. --> + <string-array translatable="false" name="config_sameNamedOperatorConsideredRoaming"> + <item>404</item> + <item>405</item> </string-array> </resources> diff --git a/core/res/res/values-mcc404-mnc17/config.xml b/core/res/res/values-mcc520/config.xml index 685d012..b2f3efa 100644 --- a/core/res/res/values-mcc404-mnc17/config.xml +++ b/core/res/res/values-mcc520/config.xml @@ -20,6 +20,6 @@ <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <!-- Show roaming icon though same named operators. --> <string-array translatable="false" name="config_sameNamedOperatorConsideredRoaming"> - <item>40491</item> + <item>520</item> </string-array> </resources> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 9025400..986a005 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4191,7 +4191,7 @@ <!-- Message shown when the user enters an invalid SIM pin password in PUK screen --> <string name="kg_invalid_sim_pin_hint">Type a PIN that is 4 to 8 numbers.</string> <!-- Message shown when the user enters an invalid PUK code in the PUK screen --> - <string name="kg_invalid_sim_puk_hint">PUK code should be 8 numbers or more.</string> + <string name="kg_invalid_sim_puk_hint">PUK code should be 8 numbers.</string> <!-- Message shown when the user enters an invalid PUK code --> <string name="kg_invalid_puk">Re-enter the correct PUK code. Repeated attempts will permanently disable the SIM.</string> <!-- String shown in PUK screen when PIN codes don't match --> diff --git a/core/tests/coretests/src/com/android/internal/util/XmlUtilsTest.java b/core/tests/coretests/src/com/android/internal/util/XmlUtilsTest.java new file mode 100644 index 0000000..2596ece --- /dev/null +++ b/core/tests/coretests/src/com/android/internal/util/XmlUtilsTest.java @@ -0,0 +1,41 @@ +/** + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.util; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import junit.framework.TestCase; + +public class XmlUtilsTest extends TestCase { + + // https://code.google.com/p/android/issues/detail?id=63717 + public void testMapWithNullKeys() throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); + Map<String, Object> map = new HashMap<String, Object>(); + map.put(null, "nullValue"); + map.put("foo", "fooValue"); + XmlUtils.writeMapXml(map, baos); + + InputStream mapInput = new ByteArrayInputStream(baos.toByteArray()); + HashMap<String, ?> deserialized = XmlUtils.readMapXml(mapInput); + assertEquals("nullValue", deserialized.get(null)); + assertEquals("fooValue", deserialized.get("foo")); + } +} diff --git a/drm/java/android/drm/DrmManagerClient.java b/drm/java/android/drm/DrmManagerClient.java index 10cdab0..c05ea2e 100644 --- a/drm/java/android/drm/DrmManagerClient.java +++ b/drm/java/android/drm/DrmManagerClient.java @@ -116,7 +116,7 @@ public class DrmManagerClient { private static final int ACTION_PROCESS_DRM_INFO = 1002; private int mUniqueId; - private int mNativeContext; + private long mNativeContext; private volatile boolean mReleased; private Context mContext; private InfoHandler mInfoHandler; diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp index baddf62..de8531b 100644 --- a/drm/jni/android_drm_DrmManagerClient.cpp +++ b/drm/jni/android_drm_DrmManagerClient.cpp @@ -182,25 +182,27 @@ static sp<DrmManagerClientImpl> setDrmManagerClientImpl( JNIEnv* env, jobject thiz, const sp<DrmManagerClientImpl>& client) { Mutex::Autolock l(sLock); jclass clazz = env->FindClass("android/drm/DrmManagerClient"); - jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "I"); + jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "J"); - sp<DrmManagerClientImpl> old = (DrmManagerClientImpl*)env->GetIntField(thiz, fieldId); + jlong oldHandle = env->GetLongField(thiz, fieldId); + sp<DrmManagerClientImpl> old = reinterpret_cast<DrmManagerClientImpl*>(oldHandle); if (client.get()) { client->incStrong(thiz); } if (old != 0) { old->decStrong(thiz); } - env->SetIntField(thiz, fieldId, (int)client.get()); + env->SetLongField(thiz, fieldId, reinterpret_cast<jlong>(client.get())); return old; } static sp<DrmManagerClientImpl> getDrmManagerClientImpl(JNIEnv* env, jobject thiz) { Mutex::Autolock l(sLock); jclass clazz = env->FindClass("android/drm/DrmManagerClient"); - jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "I"); + jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "J"); - DrmManagerClientImpl* const client = (DrmManagerClientImpl*)env->GetIntField(thiz, fieldId); + jlong clientHandle = env->GetLongField(thiz, fieldId); + DrmManagerClientImpl* const client = reinterpret_cast<DrmManagerClientImpl*>(clientHandle); return sp<DrmManagerClientImpl>(client); } @@ -214,7 +216,7 @@ static jint android_drm_DrmManagerClient_initialize( setDrmManagerClientImpl(env, thiz, drmManager); ALOGV("initialize - Exit"); - return uniqueId; + return static_cast<jint>(uniqueId); } static void android_drm_DrmManagerClient_setListeners( @@ -406,7 +408,7 @@ static jint android_drm_DrmManagerClient_saveRights( delete[] mData; mData = NULL; ALOGV("saveRights - Exit"); - return result; + return static_cast<jint>(result); } static jboolean android_drm_DrmManagerClient_canHandle( @@ -583,7 +585,7 @@ static jint android_drm_DrmManagerClient_getDrmObjectType( ->getDrmObjectType(uniqueId, Utility::getStringValue(env, path), Utility::getStringValue(env, mimeType)); ALOGV("getDrmObjectType Exit"); - return drmObjectType; + return static_cast<jint>(drmObjectType); } static jstring android_drm_DrmManagerClient_getOriginalMimeType( @@ -609,20 +611,21 @@ static jint android_drm_DrmManagerClient_checkRightsStatus( = getDrmManagerClientImpl(env, thiz) ->checkRightsStatus(uniqueId, Utility::getStringValue(env, path), action); ALOGV("checkRightsStatus Exit"); - return rightsStatus; + return static_cast<jint>(rightsStatus); } static jint android_drm_DrmManagerClient_removeRights( JNIEnv* env, jobject thiz, jint uniqueId, jstring path) { ALOGV("removeRights"); - return getDrmManagerClientImpl(env, thiz) - ->removeRights(uniqueId, Utility::getStringValue(env, path)); + return static_cast<jint>(getDrmManagerClientImpl(env, thiz) + ->removeRights(uniqueId, Utility::getStringValue(env, path))); } static jint android_drm_DrmManagerClient_removeAllRights( JNIEnv* env, jobject thiz, jint uniqueId) { ALOGV("removeAllRights"); - return getDrmManagerClientImpl(env, thiz)->removeAllRights(uniqueId); + return static_cast<jint>(getDrmManagerClientImpl(env, thiz) + ->removeAllRights(uniqueId)); } static jint android_drm_DrmManagerClient_openConvertSession( @@ -632,7 +635,7 @@ static jint android_drm_DrmManagerClient_openConvertSession( = getDrmManagerClientImpl(env, thiz) ->openConvertSession(uniqueId, Utility::getStringValue(env, mimeType)); ALOGV("openConvertSession Exit"); - return convertId; + return static_cast<jint>(convertId); } static jobject GetConvertedStatus(JNIEnv* env, DrmConvertedStatus* pDrmConvertedStatus) { @@ -686,7 +689,7 @@ static jobject android_drm_DrmManagerClient_convertData( } static jobject android_drm_DrmManagerClient_closeConvertSession( - JNIEnv* env, jobject thiz, int uniqueId, jint convertId) { + JNIEnv* env, jobject thiz, jint uniqueId, jint convertId) { ALOGV("closeConvertSession Enter"); diff --git a/graphics/java/android/graphics/AvoidXfermode.java b/graphics/java/android/graphics/AvoidXfermode.java index 5a59e36..206c959 100644 --- a/graphics/java/android/graphics/AvoidXfermode.java +++ b/graphics/java/android/graphics/AvoidXfermode.java @@ -56,6 +56,6 @@ public class AvoidXfermode extends Xfermode { native_instance = nativeCreate(opColor, tolerance, mode.nativeInt); } - private static native int nativeCreate(int opColor, int tolerance, - int nativeMode); + private static native long nativeCreate(int opColor, int tolerance, + int nativeMode); } diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java index 3c24683..efce606 100644 --- a/graphics/java/android/graphics/Bitmap.java +++ b/graphics/java/android/graphics/Bitmap.java @@ -41,7 +41,7 @@ public final class Bitmap implements Parcelable { * * @hide */ - public final int mNativeBitmap; + public final long mNativeBitmap; /** * Backing buffer for the Bitmap. @@ -103,7 +103,7 @@ public final class Bitmap implements Parcelable { * int (pointer). */ @SuppressWarnings({"UnusedDeclaration"}) // called from JNI - Bitmap(int nativeBitmap, byte[] buffer, int width, int height, int density, + Bitmap(long nativeBitmap, byte[] buffer, int width, int height, int density, boolean isMutable, boolean isPremultiplied, byte[] ninePatchChunk, int[] layoutBounds) { if (nativeBitmap == 0) { @@ -1511,7 +1511,7 @@ public final class Bitmap implements Parcelable { */ public Bitmap extractAlpha(Paint paint, int[] offsetXY) { checkRecycled("Can't extractAlpha on a recycled bitmap"); - int nativePaint = paint != null ? paint.mNativePaint : 0; + long nativePaint = paint != null ? paint.mNativePaint : 0; Bitmap bm = nativeExtractAlpha(mNativeBitmap, nativePaint, offsetXY); if (bm == null) { throw new RuntimeException("Failed to extractAlpha on Bitmap"); @@ -1545,9 +1545,9 @@ public final class Bitmap implements Parcelable { } private static class BitmapFinalizer { - private final int mNativeBitmap; + private final long mNativeBitmap; - BitmapFinalizer(int nativeBitmap) { + BitmapFinalizer(long nativeBitmap) { mNativeBitmap = nativeBitmap; } @@ -1568,55 +1568,55 @@ public final class Bitmap implements Parcelable { private static native Bitmap nativeCreate(int[] colors, int offset, int stride, int width, int height, int nativeConfig, boolean mutable); - private static native Bitmap nativeCopy(int srcBitmap, int nativeConfig, + private static native Bitmap nativeCopy(long nativeSrcBitmap, int nativeConfig, boolean isMutable); - private static native void nativeDestructor(int nativeBitmap); - private static native boolean nativeRecycle(int nativeBitmap); - private static native void nativeReconfigure(int nativeBitmap, int width, int height, + private static native void nativeDestructor(long nativeBitmap); + private static native boolean nativeRecycle(long nativeBitmap); + private static native void nativeReconfigure(long nativeBitmap, int width, int height, int config, int allocSize); - private static native boolean nativeCompress(int nativeBitmap, int format, + private static native boolean nativeCompress(long nativeBitmap, int format, int quality, OutputStream stream, byte[] tempStorage); - private static native void nativeErase(int nativeBitmap, int color); - private static native int nativeRowBytes(int nativeBitmap); - private static native int nativeConfig(int nativeBitmap); + private static native void nativeErase(long nativeBitmap, int color); + private static native int nativeRowBytes(long nativeBitmap); + private static native int nativeConfig(long nativeBitmap); - private static native int nativeGetPixel(int nativeBitmap, int x, int y, + private static native int nativeGetPixel(long nativeBitmap, int x, int y, boolean isPremultiplied); - private static native void nativeGetPixels(int nativeBitmap, int[] pixels, + private static native void nativeGetPixels(long nativeBitmap, int[] pixels, int offset, int stride, int x, int y, int width, int height, boolean isPremultiplied); - private static native void nativeSetPixel(int nativeBitmap, int x, int y, + private static native void nativeSetPixel(long nativeBitmap, int x, int y, int color, boolean isPremultiplied); - private static native void nativeSetPixels(int nativeBitmap, int[] colors, + private static native void nativeSetPixels(long nativeBitmap, int[] colors, int offset, int stride, int x, int y, int width, int height, boolean isPremultiplied); - private static native void nativeCopyPixelsToBuffer(int nativeBitmap, + private static native void nativeCopyPixelsToBuffer(long nativeBitmap, Buffer dst); - private static native void nativeCopyPixelsFromBuffer(int nb, Buffer src); - private static native int nativeGenerationId(int nativeBitmap); + private static native void nativeCopyPixelsFromBuffer(long nativeBitmap, Buffer src); + private static native int nativeGenerationId(long nativeBitmap); private static native Bitmap nativeCreateFromParcel(Parcel p); // returns true on success - private static native boolean nativeWriteToParcel(int nativeBitmap, + private static native boolean nativeWriteToParcel(long nativeBitmap, boolean isMutable, int density, Parcel p); // returns a new bitmap built from the native bitmap's alpha, and the paint - private static native Bitmap nativeExtractAlpha(int nativeBitmap, - int nativePaint, + private static native Bitmap nativeExtractAlpha(long nativeBitmap, + long nativePaint, int[] offsetXY); - private static native void nativePrepareToDraw(int nativeBitmap); - private static native boolean nativeHasAlpha(int nativeBitmap); - private static native void nativeSetHasAlpha(int nBitmap, boolean hasAlpha); - private static native boolean nativeHasMipMap(int nativeBitmap); - private static native void nativeSetHasMipMap(int nBitmap, boolean hasMipMap); - private static native boolean nativeSameAs(int nb0, int nb1); - - /* package */ final int ni() { + private static native void nativePrepareToDraw(long nativeBitmap); + private static native boolean nativeHasAlpha(long nativeBitmap); + private static native void nativeSetHasAlpha(long nativeBitmap, boolean hasAlpha); + private static native boolean nativeHasMipMap(long nativeBitmap); + private static native void nativeSetHasMipMap(long nativeBitmap, boolean hasMipMap); + private static native boolean nativeSameAs(long nativeBitmap0, long nativeBitmap1); + + /* package */ final long ni() { return mNativeBitmap; } } diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java index 429be49..1f35e50 100644 --- a/graphics/java/android/graphics/BitmapFactory.java +++ b/graphics/java/android/graphics/BitmapFactory.java @@ -583,7 +583,7 @@ public class BitmapFactory { Trace.traceBegin(Trace.TRACE_TAG_GRAPHICS, "decodeBitmap"); try { if (is instanceof AssetManager.AssetInputStream) { - final int asset = ((AssetManager.AssetInputStream) is).getAssetInt(); + final long asset = ((AssetManager.AssetInputStream) is).getNativeAsset(); bm = nativeDecodeAsset(asset, outPadding, opts); } else { bm = decodeStreamInternal(is, outPadding, opts); @@ -686,7 +686,7 @@ public class BitmapFactory { Rect padding, Options opts); private static native Bitmap nativeDecodeFileDescriptor(FileDescriptor fd, Rect padding, Options opts); - private static native Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts); + private static native Bitmap nativeDecodeAsset(long nativeAsset, Rect padding, Options opts); private static native Bitmap nativeDecodeByteArray(byte[] data, int offset, int length, Options opts); private static native boolean nativeIsSeekable(FileDescriptor fd); diff --git a/graphics/java/android/graphics/BitmapRegionDecoder.java b/graphics/java/android/graphics/BitmapRegionDecoder.java index 3a99977..e689b08 100644 --- a/graphics/java/android/graphics/BitmapRegionDecoder.java +++ b/graphics/java/android/graphics/BitmapRegionDecoder.java @@ -33,7 +33,7 @@ import java.io.InputStream; * */ public final class BitmapRegionDecoder { - private int mNativeBitmapRegionDecoder; + private long mNativeBitmapRegionDecoder; private boolean mRecycled; // ensures that the native decoder object exists and that only one decode can // occur at a time. @@ -114,7 +114,7 @@ public final class BitmapRegionDecoder { boolean isShareable) throws IOException { if (is instanceof AssetManager.AssetInputStream) { return nativeNewInstance( - ((AssetManager.AssetInputStream) is).getAssetInt(), + ((AssetManager.AssetInputStream) is).getNativeAsset(), isShareable); } else { // pass some temp storage down to the native code. 1024 is made up, @@ -165,7 +165,7 @@ public final class BitmapRegionDecoder { This can be called from JNI code. */ - private BitmapRegionDecoder(int decoder) { + private BitmapRegionDecoder(long decoder) { mNativeBitmapRegionDecoder = decoder; mRecycled = false; } @@ -254,12 +254,12 @@ public final class BitmapRegionDecoder { } } - private static native Bitmap nativeDecodeRegion(int lbm, + private static native Bitmap nativeDecodeRegion(long lbm, int start_x, int start_y, int width, int height, BitmapFactory.Options options); - private static native int nativeGetWidth(int lbm); - private static native int nativeGetHeight(int lbm); - private static native void nativeClean(int lbm); + private static native int nativeGetWidth(long lbm); + private static native int nativeGetHeight(long lbm); + private static native void nativeClean(long lbm); private static native BitmapRegionDecoder nativeNewInstance( byte[] data, int offset, int length, boolean isShareable); @@ -268,5 +268,5 @@ public final class BitmapRegionDecoder { private static native BitmapRegionDecoder nativeNewInstance( InputStream is, byte[] storage, boolean isShareable); private static native BitmapRegionDecoder nativeNewInstance( - int asset, boolean isShareable); + long asset, boolean isShareable); } diff --git a/graphics/java/android/graphics/BitmapShader.java b/graphics/java/android/graphics/BitmapShader.java index a4f75b9..b7673d8 100644 --- a/graphics/java/android/graphics/BitmapShader.java +++ b/graphics/java/android/graphics/BitmapShader.java @@ -42,7 +42,7 @@ public class BitmapShader extends Shader { mBitmap = bitmap; mTileX = tileX; mTileY = tileY; - final int b = bitmap.ni(); + final long b = bitmap.ni(); native_instance = nativeCreate(b, tileX.nativeInt, tileY.nativeInt); native_shader = nativePostCreate(native_instance, b, tileX.nativeInt, tileY.nativeInt); } @@ -57,8 +57,8 @@ public class BitmapShader extends Shader { return copy; } - private static native int nativeCreate(int native_bitmap, int shaderTileModeX, + private static native long nativeCreate(long native_bitmap, int shaderTileModeX, int shaderTileModeY); - private static native int nativePostCreate(int native_shader, int native_bitmap, + private static native long nativePostCreate(long native_shader, long native_bitmap, int shaderTileModeX, int shaderTileModeY); } diff --git a/graphics/java/android/graphics/BlurMaskFilter.java b/graphics/java/android/graphics/BlurMaskFilter.java index 5eafe76..939af52 100644 --- a/graphics/java/android/graphics/BlurMaskFilter.java +++ b/graphics/java/android/graphics/BlurMaskFilter.java @@ -47,5 +47,5 @@ public class BlurMaskFilter extends MaskFilter { native_instance = nativeConstructor(radius, style.native_int); } - private static native int nativeConstructor(float radius, int style); + private static native long nativeConstructor(float radius, int style); } diff --git a/graphics/java/android/graphics/Camera.java b/graphics/java/android/graphics/Camera.java index 9e07bd4..c263a84 100644 --- a/graphics/java/android/graphics/Camera.java +++ b/graphics/java/android/graphics/Camera.java @@ -159,7 +159,7 @@ public class Camera { } public native float dotWithNormal(float dx, float dy, float dz); - + protected void finalize() throws Throwable { try { nativeDestructor(); @@ -170,8 +170,8 @@ public class Camera { private native void nativeConstructor(); private native void nativeDestructor(); - private native void nativeGetMatrix(int native_matrix); - private native void nativeApplyToCanvas(int native_canvas); - - int native_instance; + private native void nativeGetMatrix(long native_matrix); + private native void nativeApplyToCanvas(long native_canvas); + + long native_instance; } diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index d46238f..f86840e 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -40,7 +40,7 @@ public class Canvas { // assigned in constructors or setBitmap, freed in finalizer /** @hide */ - public int mNativeCanvas; + public long mNativeCanvas; // may be null private Bitmap mBitmap; @@ -84,9 +84,9 @@ public class Canvas { private final CanvasFinalizer mFinalizer; private static final class CanvasFinalizer { - private int mNativeCanvas; + private long mNativeCanvas; - public CanvasFinalizer(int nativeCanvas) { + public CanvasFinalizer(long nativeCanvas) { mNativeCanvas = nativeCanvas; } @@ -144,7 +144,7 @@ public class Canvas { } /** @hide */ - public Canvas(int nativeCanvas) { + public Canvas(long nativeCanvas) { if (nativeCanvas == 0) { throw new IllegalStateException(); } @@ -157,8 +157,8 @@ public class Canvas { * Replace existing canvas while ensuring that the swap has occurred before * the previous native canvas is unreferenced. */ - private void safeCanvasSwap(int nativeCanvas, boolean copyState) { - final int oldCanvas = mNativeCanvas; + private void safeCanvasSwap(long nativeCanvas, boolean copyState) { + final long oldCanvas = mNativeCanvas; mNativeCanvas = nativeCanvas; mFinalizer.mNativeCanvas = nativeCanvas; if (copyState) { @@ -174,7 +174,7 @@ public class Canvas { * * @hide */ - public int getNativeCanvas() { + public long getNativeCanvas() { return mNativeCanvas; } @@ -712,7 +712,7 @@ public class Canvas { } public void setDrawFilter(DrawFilter filter) { - int nativeFilter = 0; + long nativeFilter = 0; if (filter != null) { nativeFilter = filter.mNativeInt; } @@ -1387,7 +1387,7 @@ public class Canvas { vertOffset, texs, texOffset, colors, colorOffset, indices, indexOffset, indexCount, paint.mNativePaint); } - + /** * Draw the text, with origin at (x,y), using the specified paint. The * origin is interpreted based on the Align setting in the paint. @@ -1713,137 +1713,155 @@ public class Canvas { */ public static native void freeTextLayoutCaches(); - private static native int initRaster(int nativeBitmapOrZero); - private static native void copyNativeCanvasState(int srcCanvas, int dstCanvas); - private static native int native_saveLayer(int nativeCanvas, RectF bounds, - int paint, int layerFlags); - private static native int native_saveLayer(int nativeCanvas, float l, + private static native long initRaster(long nativeBitmapOrZero); + private static native void copyNativeCanvasState(long nativeSrcCanvas, + long nativeDstCanvas); + private static native int native_saveLayer(long nativeCanvas, + RectF bounds, + long nativePaint, + int layerFlags); + private static native int native_saveLayer(long nativeCanvas, float l, float t, float r, float b, - int paint, int layerFlags); - private static native int native_saveLayerAlpha(int nativeCanvas, + long nativePaint, + int layerFlags); + private static native int native_saveLayerAlpha(long nativeCanvas, RectF bounds, int alpha, int layerFlags); - private static native int native_saveLayerAlpha(int nativeCanvas, float l, + private static native int native_saveLayerAlpha(long nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags); - private static native void native_concat(int nCanvas, int nMatrix); - private static native void native_setMatrix(int nCanvas, int nMatrix); - private static native boolean native_clipRect(int nCanvas, + private static native void native_concat(long nativeCanvas, + long nativeMatrix); + private static native void native_setMatrix(long nativeCanvas, + long nativeMatrix); + private static native boolean native_clipRect(long nativeCanvas, float left, float top, float right, float bottom, int regionOp); - private static native boolean native_clipPath(int nativeCanvas, - int nativePath, + private static native boolean native_clipPath(long nativeCanvas, + long nativePath, int regionOp); - private static native boolean native_clipRegion(int nativeCanvas, - int nativeRegion, + private static native boolean native_clipRegion(long nativeCanvas, + long nativeRegion, int regionOp); - private static native void nativeSetDrawFilter(int nativeCanvas, - int nativeFilter); - private static native boolean native_getClipBounds(int nativeCanvas, + private static native void nativeSetDrawFilter(long nativeCanvas, + long nativeFilter); + private static native boolean native_getClipBounds(long nativeCanvas, Rect bounds); - private static native void native_getCTM(int canvas, int matrix); - private static native boolean native_quickReject(int nativeCanvas, + private static native void native_getCTM(long nativeCanvas, + long nativeMatrix); + private static native boolean native_quickReject(long nativeCanvas, RectF rect); - private static native boolean native_quickReject(int nativeCanvas, - int path); - private static native boolean native_quickReject(int nativeCanvas, + private static native boolean native_quickReject(long nativeCanvas, + long nativePath); + private static native boolean native_quickReject(long nativeCanvas, float left, float top, float right, float bottom); - private static native void native_drawRGB(int nativeCanvas, int r, int g, + private static native void native_drawRGB(long nativeCanvas, int r, int g, int b); - private static native void native_drawARGB(int nativeCanvas, int a, int r, + private static native void native_drawARGB(long nativeCanvas, int a, int r, int g, int b); - private static native void native_drawColor(int nativeCanvas, int color); - private static native void native_drawColor(int nativeCanvas, int color, + private static native void native_drawColor(long nativeCanvas, int color); + private static native void native_drawColor(long nativeCanvas, int color, int mode); - private static native void native_drawPaint(int nativeCanvas, int paint); - private static native void native_drawLine(int nativeCanvas, float startX, + private static native void native_drawPaint(long nativeCanvas, + long nativePaint); + private static native void native_drawLine(long nativeCanvas, float startX, float startY, float stopX, - float stopY, int paint); - private static native void native_drawRect(int nativeCanvas, RectF rect, - int paint); - private static native void native_drawRect(int nativeCanvas, float left, + float stopY, long nativePaint); + private static native void native_drawRect(long nativeCanvas, RectF rect, + long nativePaint); + private static native void native_drawRect(long nativeCanvas, float left, float top, float right, - float bottom, int paint); - private static native void native_drawOval(int nativeCanvas, RectF oval, - int paint); - private static native void native_drawCircle(int nativeCanvas, float cx, + float bottom, + long nativePaint); + private static native void native_drawOval(long nativeCanvas, RectF oval, + long nativePaint); + private static native void native_drawCircle(long nativeCanvas, float cx, float cy, float radius, - int paint); - private static native void native_drawArc(int nativeCanvas, RectF oval, + long nativePaint); + private static native void native_drawArc(long nativeCanvas, RectF oval, float startAngle, float sweep, - boolean useCenter, int paint); - private static native void native_drawRoundRect(int nativeCanvas, + boolean useCenter, + long nativePaint); + private static native void native_drawRoundRect(long nativeCanvas, RectF rect, float rx, - float ry, int paint); - private static native void native_drawPath(int nativeCanvas, int path, - int paint); - private native void native_drawBitmap(int nativeCanvas, int bitmap, + float ry, long nativePaint); + private static native void native_drawPath(long nativeCanvas, + long nativePath, + long nativePaint); + private native void native_drawBitmap(long nativeCanvas, long nativeBitmap, float left, float top, - int nativePaintOrZero, + long nativePaintOrZero, int canvasDensity, int screenDensity, int bitmapDensity); - private native void native_drawBitmap(int nativeCanvas, int bitmap, + private native void native_drawBitmap(long nativeCanvas, long nativeBitmap, Rect src, RectF dst, - int nativePaintOrZero, + long nativePaintOrZero, int screenDensity, int bitmapDensity); - private static native void native_drawBitmap(int nativeCanvas, int bitmap, + private static native void native_drawBitmap(long nativeCanvas, + long nativeBitmap, Rect src, Rect dst, - int nativePaintOrZero, + long nativePaintOrZero, int screenDensity, int bitmapDensity); - private static native void native_drawBitmap(int nativeCanvas, int[] colors, + private static native void native_drawBitmap(long nativeCanvas, int[] colors, int offset, int stride, float x, float y, int width, int height, boolean hasAlpha, - int nativePaintOrZero); - private static native void nativeDrawBitmapMatrix(int nCanvas, int nBitmap, - int nMatrix, int nPaint); - private static native void nativeDrawBitmapMesh(int nCanvas, int nBitmap, + long nativePaintOrZero); + private static native void nativeDrawBitmapMatrix(long nativeCanvas, + long nativeBitmap, + long nativeMatrix, + long nativePaint); + private static native void nativeDrawBitmapMesh(long nativeCanvas, + long nativeBitmap, int meshWidth, int meshHeight, float[] verts, int vertOffset, - int[] colors, int colorOffset, int nPaint); - private static native void nativeDrawVertices(int nCanvas, int mode, int n, + int[] colors, int colorOffset, + long nativePaint); + private static native void nativeDrawVertices(long nativeCanvas, int mode, int n, float[] verts, int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices, - int indexOffset, int indexCount, int nPaint); - - private static native void native_drawText(int nativeCanvas, char[] text, + int indexOffset, int indexCount, long nativePaint); + + private static native void native_drawText(long nativeCanvas, char[] text, int index, int count, float x, - float y, int flags, int paint); - private static native void native_drawText(int nativeCanvas, String text, + float y, int flags, + long nativePaint); + private static native void native_drawText(long nativeCanvas, String text, int start, int end, float x, - float y, int flags, int paint); + float y, int flags, + long nativePaint); - private static native void native_drawTextRun(int nativeCanvas, String text, + private static native void native_drawTextRun(long nativeCanvas, String text, int start, int end, int contextStart, int contextEnd, - float x, float y, int flags, int paint); + float x, float y, int flags, long nativePaint); - private static native void native_drawTextRun(int nativeCanvas, char[] text, + private static native void native_drawTextRun(long nativeCanvas, char[] text, int start, int count, int contextStart, int contextCount, - float x, float y, int flags, int paint); + float x, float y, int flags, long nativePaint); - private static native void native_drawPosText(int nativeCanvas, + private static native void native_drawPosText(long nativeCanvas, char[] text, int index, int count, float[] pos, - int paint); - private static native void native_drawPosText(int nativeCanvas, + long nativePaint); + private static native void native_drawPosText(long nativeCanvas, String text, float[] pos, - int paint); - private static native void native_drawTextOnPath(int nativeCanvas, + long nativePaint); + private static native void native_drawTextOnPath(long nativeCanvas, char[] text, int index, - int count, int path, + int count, long nativePath, float hOffset, float vOffset, int bidiFlags, - int paint); - private static native void native_drawTextOnPath(int nativeCanvas, - String text, int path, - float hOffset, - float vOffset, - int flags, int paint); - private static native void finalizer(int nativeCanvas); + long nativePaint); + private static native void native_drawTextOnPath(long nativeCanvas, + String text, long nativePath, + float hOffset, + float vOffset, + int flags, long nativePaint); + private static native void finalizer(long nativeCanvas); } diff --git a/graphics/java/android/graphics/ColorFilter.java b/graphics/java/android/graphics/ColorFilter.java index e5cf830..8e432da 100644 --- a/graphics/java/android/graphics/ColorFilter.java +++ b/graphics/java/android/graphics/ColorFilter.java @@ -23,12 +23,12 @@ package android.graphics; public class ColorFilter { - int native_instance; + long native_instance; /** * @hide */ - public int nativeColorFilter; + public long nativeColorFilter; protected void finalize() throws Throwable { try { @@ -38,5 +38,5 @@ public class ColorFilter { } } - private static native void finalizer(int native_instance, int nativeColorFilter); + private static native void finalizer(long native_instance, long nativeColorFilter); } diff --git a/graphics/java/android/graphics/ColorMatrixColorFilter.java b/graphics/java/android/graphics/ColorMatrixColorFilter.java index 4f32342..21b7721 100644 --- a/graphics/java/android/graphics/ColorMatrixColorFilter.java +++ b/graphics/java/android/graphics/ColorMatrixColorFilter.java @@ -45,6 +45,6 @@ public class ColorMatrixColorFilter extends ColorFilter { nativeColorFilter = nColorMatrixFilter(native_instance, array); } - private static native int nativeColorMatrixFilter(float[] array); - private static native int nColorMatrixFilter(int nativeFilter, float[] array); + private static native long nativeColorMatrixFilter(float[] array); + private static native long nColorMatrixFilter(long nativeFilter, float[] array); } diff --git a/graphics/java/android/graphics/ComposePathEffect.java b/graphics/java/android/graphics/ComposePathEffect.java index beac78e..3fc9eb5 100644 --- a/graphics/java/android/graphics/ComposePathEffect.java +++ b/graphics/java/android/graphics/ComposePathEffect.java @@ -27,6 +27,7 @@ public class ComposePathEffect extends PathEffect { innerpe.native_instance); } - private static native int nativeCreate(int outerpe, int innerpe); + private static native long nativeCreate(long nativeOuterpe, + long nativeInnerpe); } diff --git a/graphics/java/android/graphics/ComposeShader.java b/graphics/java/android/graphics/ComposeShader.java index de0d3d6..5109ffd 100644 --- a/graphics/java/android/graphics/ComposeShader.java +++ b/graphics/java/android/graphics/ComposeShader.java @@ -104,12 +104,12 @@ public class ComposeShader extends Shader { return copy; } - private static native int nativeCreate1(int native_shaderA, int native_shaderB, - int native_mode); - private static native int nativeCreate2(int native_shaderA, int native_shaderB, + private static native long nativeCreate1(long native_shaderA, long native_shaderB, + long native_mode); + private static native long nativeCreate2(long native_shaderA, long native_shaderB, int porterDuffMode); - private static native int nativePostCreate1(int native_shader, int native_skiaShaderA, - int native_skiaShaderB, int native_mode); - private static native int nativePostCreate2(int native_shader, int native_skiaShaderA, - int native_skiaShaderB, int porterDuffMode); + private static native long nativePostCreate1(long native_shader, long native_skiaShaderA, + long native_skiaShaderB, long native_mode); + private static native long nativePostCreate2(long native_shader, long native_skiaShaderA, + long native_skiaShaderB, int porterDuffMode); } diff --git a/graphics/java/android/graphics/CornerPathEffect.java b/graphics/java/android/graphics/CornerPathEffect.java index 400c886..8f4d7d9 100644 --- a/graphics/java/android/graphics/CornerPathEffect.java +++ b/graphics/java/android/graphics/CornerPathEffect.java @@ -28,6 +28,6 @@ public class CornerPathEffect extends PathEffect { native_instance = nativeCreate(radius); } - private static native int nativeCreate(float radius); + private static native long nativeCreate(float radius); } diff --git a/graphics/java/android/graphics/DashPathEffect.java b/graphics/java/android/graphics/DashPathEffect.java index 2bdecce..ef3ebe8 100644 --- a/graphics/java/android/graphics/DashPathEffect.java +++ b/graphics/java/android/graphics/DashPathEffect.java @@ -38,6 +38,6 @@ public class DashPathEffect extends PathEffect { native_instance = nativeCreate(intervals, phase); } - private static native int nativeCreate(float intervals[], float phase); + private static native long nativeCreate(float intervals[], float phase); } diff --git a/graphics/java/android/graphics/DiscretePathEffect.java b/graphics/java/android/graphics/DiscretePathEffect.java index de8b2f0..3b3c9c9 100644 --- a/graphics/java/android/graphics/DiscretePathEffect.java +++ b/graphics/java/android/graphics/DiscretePathEffect.java @@ -26,6 +26,6 @@ public class DiscretePathEffect extends PathEffect { native_instance = nativeCreate(segmentLength, deviation); } - private static native int nativeCreate(float length, float deviation); + private static native long nativeCreate(float length, float deviation); } diff --git a/graphics/java/android/graphics/DrawFilter.java b/graphics/java/android/graphics/DrawFilter.java index 1f64539..ed38f37 100644 --- a/graphics/java/android/graphics/DrawFilter.java +++ b/graphics/java/android/graphics/DrawFilter.java @@ -25,7 +25,7 @@ package android.graphics; public class DrawFilter { // this is set by subclasses, but don't make it public - /* package */ int mNativeInt; // pointer to native object + /* package */ long mNativeInt; // pointer to native object protected void finalize() throws Throwable { try { @@ -35,6 +35,6 @@ public class DrawFilter { } } - private static native void nativeDestructor(int nativeDrawFilter); + private static native void nativeDestructor(long nativeDrawFilter); } diff --git a/graphics/java/android/graphics/EmbossMaskFilter.java b/graphics/java/android/graphics/EmbossMaskFilter.java index 5dd8611..a9e180f 100644 --- a/graphics/java/android/graphics/EmbossMaskFilter.java +++ b/graphics/java/android/graphics/EmbossMaskFilter.java @@ -33,6 +33,6 @@ public class EmbossMaskFilter extends MaskFilter { native_instance = nativeConstructor(direction, ambient, specular, blurRadius); } - private static native int nativeConstructor(float[] direction, float ambient, float specular, float blurRadius); + private static native long nativeConstructor(float[] direction, float ambient, float specular, float blurRadius); } diff --git a/graphics/java/android/graphics/Interpolator.java b/graphics/java/android/graphics/Interpolator.java index 75851a6..f695a9e 100644 --- a/graphics/java/android/graphics/Interpolator.java +++ b/graphics/java/android/graphics/Interpolator.java @@ -151,13 +151,13 @@ public class Interpolator { private int mValueCount; private int mFrameCount; - private final int native_instance; + private final long native_instance; - private static native int nativeConstructor(int valueCount, int frameCount); - private static native void nativeDestructor(int native_instance); - private static native void nativeReset(int native_instance, int valueCount, int frameCount); - private static native void nativeSetKeyFrame(int native_instance, int index, int msec, float[] values, float[] blend); - private static native void nativeSetRepeatMirror(int native_instance, float repeatCount, boolean mirror); - private static native int nativeTimeToValues(int native_instance, int msec, float[] values); + private static native long nativeConstructor(int valueCount, int frameCount); + private static native void nativeDestructor(long native_instance); + private static native void nativeReset(long native_instance, int valueCount, int frameCount); + private static native void nativeSetKeyFrame(long native_instance, int index, int msec, float[] values, float[] blend); + private static native void nativeSetRepeatMirror(long native_instance, float repeatCount, boolean mirror); + private static native int nativeTimeToValues(long native_instance, int msec, float[] values); } diff --git a/graphics/java/android/graphics/LargeBitmap.java b/graphics/java/android/graphics/LargeBitmap.java index 6656b17..238b32a 100644 --- a/graphics/java/android/graphics/LargeBitmap.java +++ b/graphics/java/android/graphics/LargeBitmap.java @@ -37,7 +37,7 @@ import java.nio.ShortBuffer; * @hide */ public final class LargeBitmap { - private int mNativeLargeBitmap; + private long mNativeLargeBitmap; private boolean mRecycled; /* Private constructor that must received an already allocated native @@ -45,8 +45,8 @@ public final class LargeBitmap { This can be called from JNI code. */ - private LargeBitmap(int lbm) { - mNativeLargeBitmap = lbm; + private LargeBitmap(long nativeLbm) { + mNativeLargeBitmap = nativeLbm; mRecycled = false; } @@ -119,10 +119,10 @@ public final class LargeBitmap { recycle(); } - private static native Bitmap nativeDecodeRegion(int lbm, + private static native Bitmap nativeDecodeRegion(long nativeLbm, int start_x, int start_y, int width, int height, BitmapFactory.Options options); - private static native int nativeGetWidth(int lbm); - private static native int nativeGetHeight(int lbm); - private static native void nativeClean(int lbm); + private static native int nativeGetWidth(long nativeLbm); + private static native int nativeGetHeight(long nativeLbm); + private static native void nativeClean(long nativeLbm); } diff --git a/graphics/java/android/graphics/LayerRasterizer.java b/graphics/java/android/graphics/LayerRasterizer.java index 9bd55a5..dc307c6 100644 --- a/graphics/java/android/graphics/LayerRasterizer.java +++ b/graphics/java/android/graphics/LayerRasterizer.java @@ -34,7 +34,7 @@ public class LayerRasterizer extends Rasterizer { nativeAddLayer(native_instance, paint.mNativePaint, 0, 0); } - private static native int nativeConstructor(); - private static native void nativeAddLayer(int native_layer, int native_paint, float dx, float dy); + private static native long nativeConstructor(); + private static native void nativeAddLayer(long native_layer, long native_paint, float dx, float dy); } diff --git a/graphics/java/android/graphics/LightingColorFilter.java b/graphics/java/android/graphics/LightingColorFilter.java index c621de6..fbd2694 100644 --- a/graphics/java/android/graphics/LightingColorFilter.java +++ b/graphics/java/android/graphics/LightingColorFilter.java @@ -33,6 +33,6 @@ public class LightingColorFilter extends ColorFilter { nativeColorFilter = nCreateLightingFilter(native_instance, mul, add); } - private static native int native_CreateLightingFilter(int mul, int add); - private static native int nCreateLightingFilter(int nativeFilter, int mul, int add); + private static native long native_CreateLightingFilter(int mul, int add); + private static native long nCreateLightingFilter(long nativeFilter, int mul, int add); } diff --git a/graphics/java/android/graphics/LinearGradient.java b/graphics/java/android/graphics/LinearGradient.java index 4c88de3..9ad3e49 100644 --- a/graphics/java/android/graphics/LinearGradient.java +++ b/graphics/java/android/graphics/LinearGradient.java @@ -116,12 +116,12 @@ public class LinearGradient extends Shader { return copy; } - private native int nativeCreate1(float x0, float y0, float x1, float y1, + private native long nativeCreate1(float x0, float y0, float x1, float y1, int colors[], float positions[], int tileMode); - private native int nativeCreate2(float x0, float y0, float x1, float y1, + private native long nativeCreate2(float x0, float y0, float x1, float y1, int color0, int color1, int tileMode); - private native int nativePostCreate1(int native_shader, float x0, float y0, float x1, float y1, + private native long nativePostCreate1(long native_shader, float x0, float y0, float x1, float y1, int colors[], float positions[], int tileMode); - private native int nativePostCreate2(int native_shader, float x0, float y0, float x1, float y1, + private native long nativePostCreate2(long native_shader, float x0, float y0, float x1, float y1, int color0, int color1, int tileMode); } diff --git a/graphics/java/android/graphics/MaskFilter.java b/graphics/java/android/graphics/MaskFilter.java index 4ebb619..27a7dda 100644 --- a/graphics/java/android/graphics/MaskFilter.java +++ b/graphics/java/android/graphics/MaskFilter.java @@ -27,6 +27,6 @@ public class MaskFilter { nativeDestructor(native_instance); } - private static native void nativeDestructor(int native_filter); - int native_instance; + private static native void nativeDestructor(long native_filter); + long native_instance; } diff --git a/graphics/java/android/graphics/Matrix.java b/graphics/java/android/graphics/Matrix.java index 32e0c01..c8bcf26 100644 --- a/graphics/java/android/graphics/Matrix.java +++ b/graphics/java/android/graphics/Matrix.java @@ -219,7 +219,7 @@ public class Matrix { /** * @hide */ - public int native_instance; + public long native_instance; /** * Create an identity matrix @@ -800,83 +800,86 @@ public class Matrix { } } - /*package*/ final int ni() { + /*package*/ final long ni() { return native_instance; } - private static native int native_create(int native_src_or_zero); - private static native boolean native_isIdentity(int native_object); - private static native boolean native_rectStaysRect(int native_object); - private static native void native_reset(int native_object); - private static native void native_set(int native_object, int other); - private static native void native_setTranslate(int native_object, + private static native long native_create(long native_src_or_zero); + private static native boolean native_isIdentity(long native_object); + private static native boolean native_rectStaysRect(long native_object); + private static native void native_reset(long native_object); + private static native void native_set(long native_object, + long native_other); + private static native void native_setTranslate(long native_object, float dx, float dy); - private static native void native_setScale(int native_object, + private static native void native_setScale(long native_object, float sx, float sy, float px, float py); - private static native void native_setScale(int native_object, + private static native void native_setScale(long native_object, float sx, float sy); - private static native void native_setRotate(int native_object, + private static native void native_setRotate(long native_object, float degrees, float px, float py); - private static native void native_setRotate(int native_object, + private static native void native_setRotate(long native_object, float degrees); - private static native void native_setSinCos(int native_object, + private static native void native_setSinCos(long native_object, float sinValue, float cosValue, float px, float py); - private static native void native_setSinCos(int native_object, + private static native void native_setSinCos(long native_object, float sinValue, float cosValue); - private static native void native_setSkew(int native_object, + private static native void native_setSkew(long native_object, float kx, float ky, float px, float py); - private static native void native_setSkew(int native_object, + private static native void native_setSkew(long native_object, float kx, float ky); - private static native boolean native_setConcat(int native_object, - int a, int b); - private static native boolean native_preTranslate(int native_object, + private static native boolean native_setConcat(long native_object, + long native_a, + long native_b); + private static native boolean native_preTranslate(long native_object, float dx, float dy); - private static native boolean native_preScale(int native_object, + private static native boolean native_preScale(long native_object, float sx, float sy, float px, float py); - private static native boolean native_preScale(int native_object, + private static native boolean native_preScale(long native_object, float sx, float sy); - private static native boolean native_preRotate(int native_object, + private static native boolean native_preRotate(long native_object, float degrees, float px, float py); - private static native boolean native_preRotate(int native_object, + private static native boolean native_preRotate(long native_object, float degrees); - private static native boolean native_preSkew(int native_object, + private static native boolean native_preSkew(long native_object, float kx, float ky, float px, float py); - private static native boolean native_preSkew(int native_object, + private static native boolean native_preSkew(long native_object, float kx, float ky); - private static native boolean native_preConcat(int native_object, - int other_matrix); - private static native boolean native_postTranslate(int native_object, + private static native boolean native_preConcat(long native_object, + long native_other_matrix); + private static native boolean native_postTranslate(long native_object, float dx, float dy); - private static native boolean native_postScale(int native_object, + private static native boolean native_postScale(long native_object, float sx, float sy, float px, float py); - private static native boolean native_postScale(int native_object, + private static native boolean native_postScale(long native_object, float sx, float sy); - private static native boolean native_postRotate(int native_object, + private static native boolean native_postRotate(long native_object, float degrees, float px, float py); - private static native boolean native_postRotate(int native_object, + private static native boolean native_postRotate(long native_object, float degrees); - private static native boolean native_postSkew(int native_object, + private static native boolean native_postSkew(long native_object, float kx, float ky, float px, float py); - private static native boolean native_postSkew(int native_object, + private static native boolean native_postSkew(long native_object, float kx, float ky); - private static native boolean native_postConcat(int native_object, - int other_matrix); - private static native boolean native_setRectToRect(int native_object, + private static native boolean native_postConcat(long native_object, + long native_other_matrix); + private static native boolean native_setRectToRect(long native_object, RectF src, RectF dst, int stf); - private static native boolean native_setPolyToPoly(int native_object, + private static native boolean native_setPolyToPoly(long native_object, float[] src, int srcIndex, float[] dst, int dstIndex, int pointCount); - private static native boolean native_invert(int native_object, int inverse); - private static native void native_mapPoints(int native_object, + private static native boolean native_invert(long native_object, + long native_inverse); + private static native void native_mapPoints(long native_object, float[] dst, int dstIndex, float[] src, int srcIndex, int ptCount, boolean isPts); - private static native boolean native_mapRect(int native_object, + private static native boolean native_mapRect(long native_object, RectF dst, RectF src); - private static native float native_mapRadius(int native_object, + private static native float native_mapRadius(long native_object, float radius); - private static native void native_getValues(int native_object, + private static native void native_getValues(long native_object, float[] values); - private static native void native_setValues(int native_object, + private static native void native_setValues(long native_object, float[] values); - private static native boolean native_equals(int native_a, int native_b); - private static native void finalizer(int native_instance); + private static native boolean native_equals(long native_a, long native_b); + private static native void finalizer(long native_instance); } diff --git a/graphics/java/android/graphics/Movie.java b/graphics/java/android/graphics/Movie.java index 9419faf..b0a4553 100644 --- a/graphics/java/android/graphics/Movie.java +++ b/graphics/java/android/graphics/Movie.java @@ -21,9 +21,9 @@ import java.io.InputStream; import java.io.FileInputStream; public class Movie { - private final int mNativeMovie; + private final long mNativeMovie; - private Movie(int nativeMovie) { + private Movie(long nativeMovie) { if (nativeMovie == 0) { throw new RuntimeException("native movie creation failed"); } @@ -48,19 +48,19 @@ public class Movie { return null; } if (is instanceof AssetManager.AssetInputStream) { - final int asset = ((AssetManager.AssetInputStream) is).getAssetInt(); + final long asset = ((AssetManager.AssetInputStream) is).getNativeAsset(); return nativeDecodeAsset(asset); } return nativeDecodeStream(is); } - private static native Movie nativeDecodeAsset(int asset); + private static native Movie nativeDecodeAsset(long asset); private static native Movie nativeDecodeStream(InputStream is); public static native Movie decodeByteArray(byte[] data, int offset, int length); - private static native void nativeDestructor(int nativeMovie); + private static native void nativeDestructor(long nativeMovie); public static Movie decodeFile(String pathName) { InputStream is; diff --git a/graphics/java/android/graphics/NinePatch.java b/graphics/java/android/graphics/NinePatch.java index 528d9de..69089b1 100644 --- a/graphics/java/android/graphics/NinePatch.java +++ b/graphics/java/android/graphics/NinePatch.java @@ -39,7 +39,7 @@ public class NinePatch { * * @hide */ - public final int mNativeChunk; + public final long mNativeChunk; private Paint mPaint; private String mSrcName; @@ -217,7 +217,7 @@ public class NinePatch { * that are transparent. */ public final Region getTransparentRegion(Rect bounds) { - int r = nativeGetTransparentRegion(mBitmap.ni(), mNativeChunk, bounds); + long r = nativeGetTransparentRegion(mBitmap.ni(), mNativeChunk, bounds); return r != 0 ? new Region(r) : null; } @@ -236,11 +236,11 @@ public class NinePatch { * If validation is successful, this method returns a native Res_png_9patch* * object used by the renderers. */ - private static native int validateNinePatchChunk(int bitmap, byte[] chunk); - private static native void nativeFinalize(int chunk); - private static native void nativeDraw(int canvas_instance, RectF loc, int bitmap_instance, - int c, int paint_instance_or_null, int destDensity, int srcDensity); - private static native void nativeDraw(int canvas_instance, Rect loc, int bitmap_instance, - int c, int paint_instance_or_null, int destDensity, int srcDensity); - private static native int nativeGetTransparentRegion(int bitmap, int chunk, Rect location); + private static native long validateNinePatchChunk(long bitmap, byte[] chunk); + private static native void nativeFinalize(long chunk); + private static native void nativeDraw(long canvas_instance, RectF loc, long bitmap_instance, + long c, long paint_instance_or_null, int destDensity, int srcDensity); + private static native void nativeDraw(long canvas_instance, Rect loc, long bitmap_instance, + long c, long paint_instance_or_null, int destDensity, int srcDensity); + private static native long nativeGetTransparentRegion(long bitmap, long chunk, Rect location); } diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index 5fc2588..33832a7 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -32,7 +32,7 @@ public class Paint { /** * @hide */ - public int mNativePaint; + public long mNativePaint; private ColorFilter mColorFilter; private MaskFilter mMaskFilter; @@ -943,7 +943,7 @@ public class Paint { * @return shader */ public Shader setShader(Shader shader) { - int shaderNative = 0; + long shaderNative = 0; if (shader != null) shaderNative = shader.native_instance; native_setShader(mNativePaint, shaderNative); @@ -967,7 +967,7 @@ public class Paint { * @return filter */ public ColorFilter setColorFilter(ColorFilter filter) { - int filterNative = 0; + long filterNative = 0; if (filter != null) filterNative = filter.native_instance; native_setColorFilter(mNativePaint, filterNative); @@ -994,7 +994,7 @@ public class Paint { * @return xfermode */ public Xfermode setXfermode(Xfermode xfermode) { - int xfermodeNative = 0; + long xfermodeNative = 0; if (xfermode != null) xfermodeNative = xfermode.native_instance; native_setXfermode(mNativePaint, xfermodeNative); @@ -1021,7 +1021,7 @@ public class Paint { * @return effect */ public PathEffect setPathEffect(PathEffect effect) { - int effectNative = 0; + long effectNative = 0; if (effect != null) { effectNative = effect.native_instance; } @@ -1050,7 +1050,7 @@ public class Paint { * @return maskfilter */ public MaskFilter setMaskFilter(MaskFilter maskfilter) { - int maskfilterNative = 0; + long maskfilterNative = 0; if (maskfilter != null) { maskfilterNative = maskfilter.native_instance; } @@ -1081,7 +1081,7 @@ public class Paint { * @return typeface */ public Typeface setTypeface(Typeface typeface) { - int typefaceNative = 0; + long typefaceNative = 0; if (typeface != null) { typefaceNative = typeface.native_instance; } @@ -1112,7 +1112,7 @@ public class Paint { * @return rasterizer */ public Rasterizer setRasterizer(Rasterizer rasterizer) { - int rasterizerNative = 0; + long rasterizerNative = 0; if (rasterizer != null) { rasterizerNative = rasterizer.native_instance; } @@ -2207,68 +2207,68 @@ public class Paint { } } - private static native int native_init(); - private static native int native_initWithPaint(int paint); - private static native void native_reset(int native_object); - private static native void native_set(int native_dst, int native_src); - private static native int native_getStyle(int native_object); - private static native void native_setStyle(int native_object, int style); - private static native int native_getStrokeCap(int native_object); - private static native void native_setStrokeCap(int native_object, int cap); - private static native int native_getStrokeJoin(int native_object); - private static native void native_setStrokeJoin(int native_object, + private static native long native_init(); + private static native long native_initWithPaint(long paint); + private static native void native_reset(long native_object); + private static native void native_set(long native_dst, long native_src); + private static native int native_getStyle(long native_object); + private static native void native_setStyle(long native_object, int style); + private static native int native_getStrokeCap(long native_object); + private static native void native_setStrokeCap(long native_object, int cap); + private static native int native_getStrokeJoin(long native_object); + private static native void native_setStrokeJoin(long native_object, int join); - private static native boolean native_getFillPath(int native_object, - int src, int dst); - private static native int native_setShader(int native_object, int shader); - private static native int native_setColorFilter(int native_object, - int filter); - private static native int native_setXfermode(int native_object, - int xfermode); - private static native int native_setPathEffect(int native_object, - int effect); - private static native int native_setMaskFilter(int native_object, - int maskfilter); - private static native int native_setTypeface(int native_object, - int typeface); - private static native int native_setRasterizer(int native_object, - int rasterizer); - - private static native int native_getTextAlign(int native_object); - private static native void native_setTextAlign(int native_object, + private static native boolean native_getFillPath(long native_object, + long src, long dst); + private static native long native_setShader(long native_object, long shader); + private static native long native_setColorFilter(long native_object, + long filter); + private static native long native_setXfermode(long native_object, + long xfermode); + private static native long native_setPathEffect(long native_object, + long effect); + private static native long native_setMaskFilter(long native_object, + long maskfilter); + private static native long native_setTypeface(long native_object, + long typeface); + private static native long native_setRasterizer(long native_object, + long rasterizer); + + private static native int native_getTextAlign(long native_object); + private static native void native_setTextAlign(long native_object, int align); - private static native void native_setTextLocale(int native_object, + private static native void native_setTextLocale(long native_object, String locale); - private static native int native_getTextWidths(int native_object, + private static native int native_getTextWidths(long native_object, char[] text, int index, int count, int bidiFlags, float[] widths); - private static native int native_getTextWidths(int native_object, + private static native int native_getTextWidths(long native_object, String text, int start, int end, int bidiFlags, float[] widths); - private static native int native_getTextGlyphs(int native_object, + private static native int native_getTextGlyphs(long native_object, String text, int start, int end, int contextStart, int contextEnd, int flags, char[] glyphs); - private static native float native_getTextRunAdvances(int native_object, + private static native float native_getTextRunAdvances(long native_object, char[] text, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex); - private static native float native_getTextRunAdvances(int native_object, + private static native float native_getTextRunAdvances(long native_object, String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex); - private native int native_getTextRunCursor(int native_object, char[] text, + private native int native_getTextRunCursor(long native_object, char[] text, int contextStart, int contextLength, int flags, int offset, int cursorOpt); - private native int native_getTextRunCursor(int native_object, String text, + private native int native_getTextRunCursor(long native_object, String text, int contextStart, int contextEnd, int flags, int offset, int cursorOpt); - private static native void native_getTextPath(int native_object, int bidiFlags, - char[] text, int index, int count, float x, float y, int path); - private static native void native_getTextPath(int native_object, int bidiFlags, - String text, int start, int end, float x, float y, int path); - private static native void nativeGetStringBounds(int nativePaint, + private static native void native_getTextPath(long native_object, int bidiFlags, + char[] text, int index, int count, float x, float y, long path); + private static native void native_getTextPath(long native_object, int bidiFlags, + String text, int start, int end, float x, float y, long path); + private static native void nativeGetStringBounds(long nativePaint, String text, int start, int end, int bidiFlags, Rect bounds); - private static native void nativeGetCharArrayBounds(int nativePaint, + private static native void nativeGetCharArrayBounds(long nativePaint, char[] text, int index, int count, int bidiFlags, Rect bounds); - private static native void finalizer(int nativePaint); + private static native void finalizer(long nativePaint); } diff --git a/graphics/java/android/graphics/PaintFlagsDrawFilter.java b/graphics/java/android/graphics/PaintFlagsDrawFilter.java index c833a12..65a6218 100644 --- a/graphics/java/android/graphics/PaintFlagsDrawFilter.java +++ b/graphics/java/android/graphics/PaintFlagsDrawFilter.java @@ -38,6 +38,6 @@ public class PaintFlagsDrawFilter extends DrawFilter { mNativeInt = nativeConstructor(clearBits, setBits); } - private static native int nativeConstructor(int clearBits, int setBits); + private static native long nativeConstructor(int clearBits, int setBits); } diff --git a/graphics/java/android/graphics/Path.java b/graphics/java/android/graphics/Path.java index 5b04a91..b5a1f64 100644 --- a/graphics/java/android/graphics/Path.java +++ b/graphics/java/android/graphics/Path.java @@ -29,7 +29,7 @@ public class Path { /** * @hide */ - public final int mNativePath; + public final long mNativePath; /** * @hide @@ -56,7 +56,7 @@ public class Path { * @param src The path to copy from when initializing the new path */ public Path(Path src) { - int valNative = 0; + long valNative = 0; if (src != null) { valNative = src.mNativePath; isSimplePath = src.isSimplePath; @@ -634,7 +634,7 @@ public class Path { * the original path is modified. */ public void offset(float dx, float dy, Path dst) { - int dstNative = 0; + long dstNative = 0; if (dst != null) { dstNative = dst.mNativePath; dst.isSimplePath = false; @@ -673,7 +673,7 @@ public class Path { * then the the original path is modified */ public void transform(Matrix matrix, Path dst) { - int dstNative = 0; + long dstNative = 0; if (dst != null) { dst.isSimplePath = false; dstNative = dst.mNativePath; @@ -699,54 +699,54 @@ public class Path { } } - final int ni() { + final long ni() { return mNativePath; } - private static native int init1(); - private static native int init2(int nPath); - private static native void native_reset(int nPath); - private static native void native_rewind(int nPath); - private static native void native_set(int native_dst, int native_src); - private static native int native_getFillType(int nPath); - private static native void native_setFillType(int nPath, int ft); - private static native boolean native_isEmpty(int nPath); - private static native boolean native_isRect(int nPath, RectF rect); - private static native void native_computeBounds(int nPath, RectF bounds); - private static native void native_incReserve(int nPath, int extraPtCount); - private static native void native_moveTo(int nPath, float x, float y); - private static native void native_rMoveTo(int nPath, float dx, float dy); - private static native void native_lineTo(int nPath, float x, float y); - private static native void native_rLineTo(int nPath, float dx, float dy); - private static native void native_quadTo(int nPath, float x1, float y1, + private static native long init1(); + private static native long init2(long nPath); + private static native void native_reset(long nPath); + private static native void native_rewind(long nPath); + private static native void native_set(long native_dst, long native_src); + private static native int native_getFillType(long nPath); + private static native void native_setFillType(long nPath, int ft); + private static native boolean native_isEmpty(long nPath); + private static native boolean native_isRect(long nPath, RectF rect); + private static native void native_computeBounds(long nPath, RectF bounds); + private static native void native_incReserve(long nPath, int extraPtCount); + private static native void native_moveTo(long nPath, float x, float y); + private static native void native_rMoveTo(long nPath, float dx, float dy); + private static native void native_lineTo(long nPath, float x, float y); + private static native void native_rLineTo(long nPath, float dx, float dy); + private static native void native_quadTo(long nPath, float x1, float y1, float x2, float y2); - private static native void native_rQuadTo(int nPath, float dx1, float dy1, + private static native void native_rQuadTo(long nPath, float dx1, float dy1, float dx2, float dy2); - private static native void native_cubicTo(int nPath, float x1, float y1, + private static native void native_cubicTo(long nPath, float x1, float y1, float x2, float y2, float x3, float y3); - private static native void native_rCubicTo(int nPath, float x1, float y1, + private static native void native_rCubicTo(long nPath, float x1, float y1, float x2, float y2, float x3, float y3); - private static native void native_arcTo(int nPath, RectF oval, + private static native void native_arcTo(long nPath, RectF oval, float startAngle, float sweepAngle, boolean forceMoveTo); - private static native void native_close(int nPath); - private static native void native_addRect(int nPath, RectF rect, int dir); - private static native void native_addRect(int nPath, float left, float top, + private static native void native_close(long nPath); + private static native void native_addRect(long nPath, RectF rect, int dir); + private static native void native_addRect(long nPath, float left, float top, float right, float bottom, int dir); - private static native void native_addOval(int nPath, RectF oval, int dir); - private static native void native_addCircle(int nPath, float x, float y, float radius, int dir); - private static native void native_addArc(int nPath, RectF oval, + private static native void native_addOval(long nPath, RectF oval, int dir); + private static native void native_addCircle(long nPath, float x, float y, float radius, int dir); + private static native void native_addArc(long nPath, RectF oval, float startAngle, float sweepAngle); - private static native void native_addRoundRect(int nPath, RectF rect, + private static native void native_addRoundRect(long nPath, RectF rect, float rx, float ry, int dir); - private static native void native_addRoundRect(int nPath, RectF r, float[] radii, int dir); - private static native void native_addPath(int nPath, int src, float dx, float dy); - private static native void native_addPath(int nPath, int src); - private static native void native_addPath(int nPath, int src, int matrix); - private static native void native_offset(int nPath, float dx, float dy, int dst_path); - private static native void native_offset(int nPath, float dx, float dy); - private static native void native_setLastPoint(int nPath, float dx, float dy); - private static native void native_transform(int nPath, int matrix, int dst_path); - private static native void native_transform(int nPath, int matrix); - private static native boolean native_op(int path1, int path2, int op, int result); - private static native void finalizer(int nPath); + private static native void native_addRoundRect(long nPath, RectF r, float[] radii, int dir); + private static native void native_addPath(long nPath, long src, float dx, float dy); + private static native void native_addPath(long nPath, long src); + private static native void native_addPath(long nPath, long src, long matrix); + private static native void native_offset(long nPath, float dx, float dy, long dst_path); + private static native void native_offset(long nPath, float dx, float dy); + private static native void native_setLastPoint(long nPath, float dx, float dy); + private static native void native_transform(long nPath, long matrix, long dst_path); + private static native void native_transform(long nPath, long matrix); + private static native boolean native_op(long path1, long path2, int op, long result); + private static native void finalizer(long nPath); } diff --git a/graphics/java/android/graphics/PathDashPathEffect.java b/graphics/java/android/graphics/PathDashPathEffect.java index e8ad5fd..4f43f68 100644 --- a/graphics/java/android/graphics/PathDashPathEffect.java +++ b/graphics/java/android/graphics/PathDashPathEffect.java @@ -45,7 +45,7 @@ public class PathDashPathEffect extends PathEffect { style.native_style); } - private static native int nativeCreate(int native_path, float advance, + private static native long nativeCreate(long native_path, float advance, float phase, int native_style); } diff --git a/graphics/java/android/graphics/PathEffect.java b/graphics/java/android/graphics/PathEffect.java index 9b2cd66..617dfca 100644 --- a/graphics/java/android/graphics/PathEffect.java +++ b/graphics/java/android/graphics/PathEffect.java @@ -27,6 +27,6 @@ public class PathEffect { nativeDestructor(native_instance); } - private static native void nativeDestructor(int native_patheffect); - int native_instance; + private static native void nativeDestructor(long native_patheffect); + long native_instance; } diff --git a/graphics/java/android/graphics/PathMeasure.java b/graphics/java/android/graphics/PathMeasure.java index 7062824..e56716f 100644 --- a/graphics/java/android/graphics/PathMeasure.java +++ b/graphics/java/android/graphics/PathMeasure.java @@ -138,16 +138,16 @@ public class PathMeasure { native_destroy(native_instance); } - private static native int native_create(int native_path, boolean forceClosed); - private static native void native_setPath(int native_instance, int native_path, boolean forceClosed); - private static native float native_getLength(int native_instance); - private static native boolean native_getPosTan(int native_instance, float distance, float pos[], float tan[]); - private static native boolean native_getMatrix(int native_instance, float distance, int native_matrix, int flags); - private static native boolean native_getSegment(int native_instance, float startD, float stopD, int native_path, boolean startWithMoveTo); - private static native boolean native_isClosed(int native_instance); - private static native boolean native_nextContour(int native_instance); - private static native void native_destroy(int native_instance); + private static native long native_create(long native_path, boolean forceClosed); + private static native void native_setPath(long native_instance, long native_path, boolean forceClosed); + private static native float native_getLength(long native_instance); + private static native boolean native_getPosTan(long native_instance, float distance, float pos[], float tan[]); + private static native boolean native_getMatrix(long native_instance, float distance, long native_matrix, int flags); + private static native boolean native_getSegment(long native_instance, float startD, float stopD, long native_path, boolean startWithMoveTo); + private static native boolean native_isClosed(long native_instance); + private static native boolean native_nextContour(long native_instance); + private static native void native_destroy(long native_instance); - /* package */private final int native_instance; + /* package */private final long native_instance; } diff --git a/graphics/java/android/graphics/Picture.java b/graphics/java/android/graphics/Picture.java index 71e02f6..25188e0 100644 --- a/graphics/java/android/graphics/Picture.java +++ b/graphics/java/android/graphics/Picture.java @@ -29,7 +29,7 @@ import java.io.OutputStream; */ public class Picture { private Canvas mRecordingCanvas; - private final int mNativePicture; + private final long mNativePicture; /** * @hide @@ -63,7 +63,7 @@ public class Picture { * into it. */ public Canvas beginRecording(int width, int height) { - int ni = nativeBeginRecording(mNativePicture, width, height); + long ni = nativeBeginRecording(mNativePicture, width, height); mRecordingCanvas = new RecordingCanvas(this, ni); return mRecordingCanvas; } @@ -164,11 +164,11 @@ public class Picture { } } - final int ni() { + final long ni() { return mNativePicture; } - private Picture(int nativePicture, boolean fromStream) { + private Picture(long nativePicture, boolean fromStream) { if (nativePicture == 0) { throw new RuntimeException(); } @@ -177,21 +177,21 @@ public class Picture { } // return empty picture if src is 0, or a copy of the native src - private static native int nativeConstructor(int nativeSrcOr0); - private static native int nativeCreateFromStream(InputStream stream, + private static native long nativeConstructor(long nativeSrcOr0); + private static native long nativeCreateFromStream(InputStream stream, byte[] storage); - private static native int nativeBeginRecording(int nativeCanvas, + private static native long nativeBeginRecording(long nativeCanvas, int w, int h); - private static native void nativeEndRecording(int nativeCanvas); - private static native void nativeDraw(int nativeCanvas, int nativePicture); - private static native boolean nativeWriteToStream(int nativePicture, + private static native void nativeEndRecording(long nativeCanvas); + private static native void nativeDraw(long nativeCanvas, long nativePicture); + private static native boolean nativeWriteToStream(long nativePicture, OutputStream stream, byte[] storage); - private static native void nativeDestructor(int nativePicture); + private static native void nativeDestructor(long nativePicture); private static class RecordingCanvas extends Canvas { private final Picture mPicture; - public RecordingCanvas(Picture pict, int nativeCanvas) { + public RecordingCanvas(Picture pict, long nativeCanvas) { super(nativeCanvas); mPicture = pict; } diff --git a/graphics/java/android/graphics/PixelXorXfermode.java b/graphics/java/android/graphics/PixelXorXfermode.java index 6075ec3..0080e65 100644 --- a/graphics/java/android/graphics/PixelXorXfermode.java +++ b/graphics/java/android/graphics/PixelXorXfermode.java @@ -29,5 +29,5 @@ public class PixelXorXfermode extends Xfermode { native_instance = nativeCreate(opColor); } - private static native int nativeCreate(int opColor); + private static native long nativeCreate(int opColor); } diff --git a/graphics/java/android/graphics/PorterDuffColorFilter.java b/graphics/java/android/graphics/PorterDuffColorFilter.java index ecc7c24..894284f 100644 --- a/graphics/java/android/graphics/PorterDuffColorFilter.java +++ b/graphics/java/android/graphics/PorterDuffColorFilter.java @@ -29,7 +29,7 @@ public class PorterDuffColorFilter extends ColorFilter { nativeColorFilter = nCreatePorterDuffFilter(native_instance, srcColor, mode.nativeInt); } - private static native int native_CreatePorterDuffFilter(int srcColor, int porterDuffMode); - private static native int nCreatePorterDuffFilter(int nativeFilter, int srcColor, + private static native long native_CreatePorterDuffFilter(int srcColor, int porterDuffMode); + private static native long nCreatePorterDuffFilter(long nativeFilter, int srcColor, int porterDuffMode); } diff --git a/graphics/java/android/graphics/PorterDuffXfermode.java b/graphics/java/android/graphics/PorterDuffXfermode.java index 6ba064c..d9d7689 100644 --- a/graphics/java/android/graphics/PorterDuffXfermode.java +++ b/graphics/java/android/graphics/PorterDuffXfermode.java @@ -32,5 +32,5 @@ public class PorterDuffXfermode extends Xfermode { native_instance = nativeCreateXfermode(mode.nativeInt); } - private static native int nativeCreateXfermode(int mode); + private static native long nativeCreateXfermode(int mode); } diff --git a/graphics/java/android/graphics/RadialGradient.java b/graphics/java/android/graphics/RadialGradient.java index f011e5c..f10e5d6 100644 --- a/graphics/java/android/graphics/RadialGradient.java +++ b/graphics/java/android/graphics/RadialGradient.java @@ -117,14 +117,14 @@ public class RadialGradient extends Shader { return copy; } - private static native int nativeCreate1(float x, float y, float radius, + private static native long nativeCreate1(float x, float y, float radius, int colors[], float positions[], int tileMode); - private static native int nativeCreate2(float x, float y, float radius, + private static native long nativeCreate2(float x, float y, float radius, int color0, int color1, int tileMode); - private static native int nativePostCreate1(int native_shader, float x, float y, float radius, + private static native long nativePostCreate1(long native_shader, float x, float y, float radius, int colors[], float positions[], int tileMode); - private static native int nativePostCreate2(int native_shader, float x, float y, float radius, + private static native long nativePostCreate2(long native_shader, float x, float y, float radius, int color0, int color1, int tileMode); } diff --git a/graphics/java/android/graphics/Rasterizer.java b/graphics/java/android/graphics/Rasterizer.java index feb5f0c..817814c 100644 --- a/graphics/java/android/graphics/Rasterizer.java +++ b/graphics/java/android/graphics/Rasterizer.java @@ -27,7 +27,7 @@ public class Rasterizer { finalizer(native_instance); } - private static native void finalizer(int native_instance); + private static native void finalizer(long native_instance); - int native_instance; + long native_instance; } diff --git a/graphics/java/android/graphics/Region.java b/graphics/java/android/graphics/Region.java index 72d0c43..727723d 100644 --- a/graphics/java/android/graphics/Region.java +++ b/graphics/java/android/graphics/Region.java @@ -30,7 +30,7 @@ public class Region implements Parcelable { /** * @hide */ - public final int mNativeRegion; + public final long mNativeRegion; // the native values for these must match up with the enum in SkRegion.h public enum Op { @@ -342,7 +342,7 @@ public class Region implements Parcelable { * @return a new region created from the data in the parcel */ public Region createFromParcel(Parcel p) { - int ni = nativeCreateFromParcel(p); + long ni = nativeCreateFromParcel(p); if (ni == 0) { throw new RuntimeException(); } @@ -385,7 +385,7 @@ public class Region implements Parcelable { } } - Region(int ni) { + Region(long ni) { if (ni == 0) { throw new RuntimeException(); } @@ -394,38 +394,38 @@ public class Region implements Parcelable { /* add dummy parameter so constructor can be called from jni without triggering 'not cloneable' exception */ - private Region(int ni, int dummy) { + private Region(long ni, int dummy) { this(ni); } - final int ni() { + final long ni() { return mNativeRegion; } - private static native boolean nativeEquals(int native_r1, int native_r2); + private static native boolean nativeEquals(long native_r1, long native_r2); - private static native int nativeConstructor(); - private static native void nativeDestructor(int native_region); + private static native long nativeConstructor(); + private static native void nativeDestructor(long native_region); - private static native void nativeSetRegion(int native_dst, int native_src); - private static native boolean nativeSetRect(int native_dst, int left, + private static native void nativeSetRegion(long native_dst, long native_src); + private static native boolean nativeSetRect(long native_dst, int left, int top, int right, int bottom); - private static native boolean nativeSetPath(int native_dst, int native_path, - int native_clip); - private static native boolean nativeGetBounds(int native_region, Rect rect); - private static native boolean nativeGetBoundaryPath(int native_region, - int native_path); + private static native boolean nativeSetPath(long native_dst, long native_path, + long native_clip); + private static native boolean nativeGetBounds(long native_region, Rect rect); + private static native boolean nativeGetBoundaryPath(long native_region, + long native_path); - private static native boolean nativeOp(int native_dst, int left, int top, + private static native boolean nativeOp(long native_dst, int left, int top, int right, int bottom, int op); - private static native boolean nativeOp(int native_dst, Rect rect, - int native_region, int op); - private static native boolean nativeOp(int native_dst, int native_region1, - int native_region2, int op); + private static native boolean nativeOp(long native_dst, Rect rect, + long native_region, int op); + private static native boolean nativeOp(long native_dst, long native_region1, + long native_region2, int op); - private static native int nativeCreateFromParcel(Parcel p); - private static native boolean nativeWriteToParcel(int native_region, + private static native long nativeCreateFromParcel(Parcel p); + private static native boolean nativeWriteToParcel(long native_region, Parcel p); - private static native String nativeToString(int native_region); + private static native String nativeToString(long native_region); } diff --git a/graphics/java/android/graphics/RegionIterator.java b/graphics/java/android/graphics/RegionIterator.java index 817f853..8401adb 100644 --- a/graphics/java/android/graphics/RegionIterator.java +++ b/graphics/java/android/graphics/RegionIterator.java @@ -45,10 +45,10 @@ public class RegionIterator { nativeDestructor(mNativeIter); } - private static native int nativeConstructor(int native_region); - private static native void nativeDestructor(int native_iter); - private static native boolean nativeNext(int native_iter, Rect r); - - private final int mNativeIter; + private static native long nativeConstructor(long native_region); + private static native void nativeDestructor(long native_iter); + private static native boolean nativeNext(long native_iter, Rect r); + + private final long mNativeIter; } diff --git a/graphics/java/android/graphics/Shader.java b/graphics/java/android/graphics/Shader.java index afc68d8..94b4c4a 100644 --- a/graphics/java/android/graphics/Shader.java +++ b/graphics/java/android/graphics/Shader.java @@ -28,11 +28,11 @@ public class Shader { * * @hide */ - public int native_instance; + public long native_instance; /** * @hide */ - public int native_shader; + public long native_shader; private Matrix mLocalMatrix; @@ -112,7 +112,7 @@ public class Shader { } } - private static native void nativeDestructor(int native_shader, int native_skiaShader); - private static native void nativeSetLocalMatrix(int native_shader, - int native_skiaShader, int matrix_instance); + private static native void nativeDestructor(long native_shader, long native_skiaShader); + private static native void nativeSetLocalMatrix(long native_shader, + long native_skiaShader, long matrix_instance); } diff --git a/graphics/java/android/graphics/SumPathEffect.java b/graphics/java/android/graphics/SumPathEffect.java index cc7c778..8fedc31 100644 --- a/graphics/java/android/graphics/SumPathEffect.java +++ b/graphics/java/android/graphics/SumPathEffect.java @@ -27,6 +27,6 @@ public class SumPathEffect extends PathEffect { second.native_instance); } - private static native int nativeCreate(int first, int second); + private static native long nativeCreate(long first, long second); } diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java index b910a24..1f8e223 100644 --- a/graphics/java/android/graphics/SurfaceTexture.java +++ b/graphics/java/android/graphics/SurfaceTexture.java @@ -69,9 +69,9 @@ public class SurfaceTexture { /** * These fields are used by native code, do not access or modify. */ - private int mSurfaceTexture; - private int mBufferQueue; - private int mFrameAvailableListener; + private long mSurfaceTexture; + private long mBufferQueue; + private long mFrameAvailableListener; /** * Callback interface for being notified that a new stream frame is available. diff --git a/graphics/java/android/graphics/SweepGradient.java b/graphics/java/android/graphics/SweepGradient.java index e9cda39..21239f7 100644 --- a/graphics/java/android/graphics/SweepGradient.java +++ b/graphics/java/android/graphics/SweepGradient.java @@ -106,12 +106,12 @@ public class SweepGradient extends Shader { return copy; } - private static native int nativeCreate1(float x, float y, int colors[], float positions[]); - private static native int nativeCreate2(float x, float y, int color0, int color1); + private static native long nativeCreate1(float x, float y, int colors[], float positions[]); + private static native long nativeCreate2(float x, float y, int color0, int color1); - private static native int nativePostCreate1(int native_shader, float cx, float cy, + private static native long nativePostCreate1(long native_shader, float cx, float cy, int[] colors, float[] positions); - private static native int nativePostCreate2(int native_shader, float cx, float cy, + private static native long nativePostCreate2(long native_shader, float cx, float cy, int color0, int color1); } diff --git a/graphics/java/android/graphics/TableMaskFilter.java b/graphics/java/android/graphics/TableMaskFilter.java index a8a7ff0..d0c1438 100644 --- a/graphics/java/android/graphics/TableMaskFilter.java +++ b/graphics/java/android/graphics/TableMaskFilter.java @@ -28,7 +28,7 @@ public class TableMaskFilter extends MaskFilter { native_instance = nativeNewTable(table); } - private TableMaskFilter(int ni) { + private TableMaskFilter(long ni) { native_instance = ni; } @@ -40,7 +40,7 @@ public class TableMaskFilter extends MaskFilter { return new TableMaskFilter(nativeNewGamma(gamma)); } - private static native int nativeNewTable(byte[] table); - private static native int nativeNewClip(int min, int max); - private static native int nativeNewGamma(float gamma); + private static native long nativeNewTable(byte[] table); + private static native long nativeNewClip(int min, int max); + private static native long nativeNewGamma(float gamma); } diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java index c68c9f7..936ea4f 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,10 +46,10 @@ 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); - int native_instance; + long native_instance; // Style public static final int NORMAL = 0; @@ -100,7 +101,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) { @@ -170,7 +171,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"); } @@ -214,15 +215,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); } diff --git a/graphics/java/android/graphics/Xfermode.java b/graphics/java/android/graphics/Xfermode.java index 2467bdc..883350d 100644 --- a/graphics/java/android/graphics/Xfermode.java +++ b/graphics/java/android/graphics/Xfermode.java @@ -38,7 +38,7 @@ public class Xfermode { } } - private static native void finalizer(int native_instance); + private static native void finalizer(long native_instance); - int native_instance; + long native_instance; } diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index cbc4e5a..aa16951 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -116,7 +116,7 @@ static void _nInit(JNIEnv *_env, jclass _this) gContextId = _env->GetFieldID(_this, "mContext", "I"); jclass bitmapClass = _env->FindClass("android/graphics/Bitmap"); - gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "I"); + gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "J"); } // --------------------------------------------------------------------------- @@ -335,7 +335,7 @@ nContextSendMessage(JNIEnv *_env, jobject _this, RsContext con, jint id, jintArr jint len = 0; if (data) { len = _env->GetArrayLength(data); - jint *ptr = _env->GetIntArrayElements(data, NULL); + ptr = _env->GetIntArrayElements(data, NULL); } LOG_API("nContextSendMessage, con(%p), id(%i), len(%i)", con, id, len); rsContextSendMessage(con, id, (const uint8_t *)ptr, len * sizeof(int)); @@ -522,7 +522,7 @@ static int nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) { SkBitmap const * nativeBitmap = - (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); + (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); bitmap.lockPixels(); @@ -538,7 +538,7 @@ static int nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) { SkBitmap const * nativeBitmap = - (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); + (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); bitmap.lockPixels(); @@ -554,7 +554,7 @@ static int nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) { SkBitmap const * nativeBitmap = - (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); + (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); bitmap.lockPixels(); @@ -570,7 +570,7 @@ static void nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) { SkBitmap const * nativeBitmap = - (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); + (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); int w = bitmap.width(); int h = bitmap.height(); @@ -587,7 +587,7 @@ static void nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) { SkBitmap const * nativeBitmap = - (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); + (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); bitmap.lockPixels(); diff --git a/include/androidfw/AssetManager.h b/include/androidfw/AssetManager.h index d95b45e..a010957 100644 --- a/include/androidfw/AssetManager.h +++ b/include/androidfw/AssetManager.h @@ -92,7 +92,7 @@ public: * then on success, *cookie is set to the value corresponding to the * newly-added asset source. */ - bool addAssetPath(const String8& path, void** cookie); + bool addAssetPath(const String8& path, int32_t* cookie); /* * Convenience for adding the standard system assets. Uses the @@ -103,17 +103,17 @@ public: /* * Iterate over the asset paths in this manager. (Previously * added via addAssetPath() and addDefaultAssets().) On first call, - * 'cookie' must be NULL, resulting in the first cookie being returned. - * Each next cookie will be returned there-after, until NULL indicating + * 'cookie' must be 0, resulting in the first cookie being returned. + * Each next cookie will be returned there-after, until -1 indicating * the end has been reached. */ - void* nextAssetPath(void* cookie) const; + int32_t nextAssetPath(const int32_t cookie) const; /* * Return an asset path in the manager. 'which' must be between 0 and * countAssetPaths(). */ - String8 getAssetPath(void* cookie) const; + String8 getAssetPath(const int32_t cookie) const; /* * Set the current locale and vendor. The locale can change during @@ -159,7 +159,7 @@ public: * Explicit non-asset file. The file explicitly named by the cookie (the * resource set to look in) and fileName will be opened and returned. */ - Asset* openNonAsset(void* cookie, const char* fileName, AccessMode mode); + Asset* openNonAsset(const int32_t cookie, const char* fileName, AccessMode mode); /* * Open a directory within the asset hierarchy. @@ -183,7 +183,7 @@ public: * * To open the top-level directory, pass in "". */ - AssetDir* openNonAssetDir(void* cookie, const char* dirName); + AssetDir* openNonAssetDir(const int32_t cookie, const char* dirName); /* * Get the type of a file in the asset hierarchy. They will either diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp index 503c030..52ab361 100644 --- a/libs/androidfw/AssetManager.cpp +++ b/libs/androidfw/AssetManager.cpp @@ -165,7 +165,7 @@ AssetManager::~AssetManager(void) delete[] mVendor; } -bool AssetManager::addAssetPath(const String8& path, void** cookie) +bool AssetManager::addAssetPath(const String8& path, int32_t* cookie) { AutoMutex _l(mLock); @@ -192,7 +192,7 @@ bool AssetManager::addAssetPath(const String8& path, void** cookie) for (size_t i=0; i<mAssetPaths.size(); i++) { if (mAssetPaths[i].path == ap.path) { if (cookie) { - *cookie = (void*)(i+1); + *cookie = static_cast<int32_t>(i+1); } return true; } @@ -205,7 +205,7 @@ bool AssetManager::addAssetPath(const String8& path, void** cookie) // new paths are always added at the end if (cookie) { - *cookie = (void*)mAssetPaths.size(); + *cookie = static_cast<int32_t>(mAssetPaths.size()); } // add overlay packages for /system/framework; apps are handled by the @@ -395,17 +395,17 @@ bool AssetManager::addDefaultAssets() return addAssetPath(path, NULL); } -void* AssetManager::nextAssetPath(void* cookie) const +int32_t AssetManager::nextAssetPath(const int32_t cookie) const { AutoMutex _l(mLock); - size_t next = ((size_t)cookie)+1; - return next > mAssetPaths.size() ? NULL : (void*)next; + const size_t next = static_cast<size_t>(cookie) + 1; + return next > mAssetPaths.size() ? -1 : next; } -String8 AssetManager::getAssetPath(void* cookie) const +String8 AssetManager::getAssetPath(const int32_t cookie) const { AutoMutex _l(mLock); - const size_t which = ((size_t)cookie)-1; + const size_t which = static_cast<size_t>(cookie) - 1; if (which < mAssetPaths.size()) { return mAssetPaths[which].path; } @@ -575,15 +575,14 @@ Asset* AssetManager::openNonAsset(const char* fileName, AccessMode mode) return NULL; } -Asset* AssetManager::openNonAsset(void* cookie, const char* fileName, AccessMode mode) +Asset* AssetManager::openNonAsset(const int32_t cookie, const char* fileName, AccessMode mode) { - const size_t which = ((size_t)cookie)-1; + const size_t which = static_cast<size_t>(cookie) - 1; AutoMutex _l(mLock); LOG_FATAL_IF(mAssetPaths.size() == 0, "No assets added to AssetManager"); - if (mCacheMode != CACHE_OFF && !mCacheValid) loadFileNameCacheLocked(); @@ -1206,7 +1205,7 @@ AssetDir* AssetManager::openDir(const char* dirName) * * Pass in "" for the root dir. */ -AssetDir* AssetManager::openNonAssetDir(void* cookie, const char* dirName) +AssetDir* AssetManager::openNonAssetDir(const int32_t cookie, const char* dirName) { AutoMutex _l(mLock); @@ -1225,7 +1224,7 @@ AssetDir* AssetManager::openNonAssetDir(void* cookie, const char* dirName) pMergedInfo = new SortedVector<AssetDir::FileInfo>; - const size_t which = ((size_t)cookie)-1; + const size_t which = static_cast<size_t>(cookie) - 1; if (which < mAssetPaths.size()) { const asset_path& ap = mAssetPaths.itemAt(which); diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 00e7870..0be17ff 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -732,7 +732,9 @@ void FontRenderer::blurImage(uint8_t** image, int32_t width, int32_t height, int if (mRs == 0) { mRs = new RSC::RS(); - if (!mRs->init(RSC::RS_INIT_LOW_LATENCY | RSC::RS_INIT_SYNCHRONOUS)) { + // a null path is OK because there are no custom kernels used + // hence nothing gets cached by RS + if (!mRs->init("", RSC::RS_INIT_LOW_LATENCY | RSC::RS_INIT_SYNCHRONOUS)) { ALOGE("blur RS failed to init"); } diff --git a/libs/hwui/SkiaShader.h b/libs/hwui/SkiaShader.h index a63431c..cc56c50 100644 --- a/libs/hwui/SkiaShader.h +++ b/libs/hwui/SkiaShader.h @@ -145,7 +145,7 @@ struct SkiaBitmapShader: public SkiaShader { GLuint* textureUnit); private: - SkiaBitmapShader() { + SkiaBitmapShader() : mBitmap(NULL), mTexture(NULL) { } SkBitmap* mBitmap; diff --git a/media/java/android/media/AmrInputStream.java b/media/java/android/media/AmrInputStream.java index 8b7eee2..e2115e4 100644 --- a/media/java/android/media/AmrInputStream.java +++ b/media/java/android/media/AmrInputStream.java @@ -41,7 +41,7 @@ public final class AmrInputStream extends InputStream private InputStream mInputStream; // native handle - private int mGae; + private long mGae; // result amr stream private final byte[] mBuf = new byte[SAMPLES_PER_FRAME * 2]; @@ -130,11 +130,11 @@ public final class AmrInputStream extends InputStream // // AudioRecord JNI interface // - private static native int GsmAmrEncoderNew(); - private static native void GsmAmrEncoderInitialize(int gae); - private static native int GsmAmrEncoderEncode(int gae, + private static native long GsmAmrEncoderNew(); + private static native void GsmAmrEncoderInitialize(long gae); + private static native int GsmAmrEncoderEncode(long gae, byte[] pcm, int pcmOffset, byte[] amr, int amrOffset) throws IOException; - private static native void GsmAmrEncoderCleanup(int gae); - private static native void GsmAmrEncoderDelete(int gae); + private static native void GsmAmrEncoderCleanup(long gae); + private static native void GsmAmrEncoderDelete(long gae); } diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java index f49ef2e..461b52f 100644 --- a/media/java/android/media/AudioRecord.java +++ b/media/java/android/media/AudioRecord.java @@ -107,13 +107,13 @@ public class AudioRecord * Accessed by native methods: provides access to C++ AudioRecord object */ @SuppressWarnings("unused") - private int mNativeRecorderInJavaObj; + private long mNativeRecorderInJavaObj; /** * Accessed by native methods: provides access to the callback data. */ @SuppressWarnings("unused") - private int mNativeCallbackCookie; + private long mNativeCallbackCookie; //--------------------------------------------------------- diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index 78a37c5..01a6fc2 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -221,13 +221,13 @@ public class AudioTrack * Accessed by native methods: provides access to C++ AudioTrack object. */ @SuppressWarnings("unused") - private int mNativeTrackInJavaObj; + private long mNativeTrackInJavaObj; /** * Accessed by native methods: provides access to the JNI data (i.e. resources used by * the native AudioTrack object, but not stored in it). */ @SuppressWarnings("unused") - private int mJniData; + private long mJniData; //-------------------------------------------------------------------------- diff --git a/media/java/android/media/FaceDetector.java b/media/java/android/media/FaceDetector.java index cf900ce..61991e3 100644 --- a/media/java/android/media/FaceDetector.java +++ b/media/java/android/media/FaceDetector.java @@ -191,9 +191,9 @@ public class FaceDetector { native private void fft_get_face(Face face, int i); native private void fft_destroy(); - private int mFD; - private int mSDK; - private int mDCR; + private long mFD; + private long mSDK; + private long mDCR; private int mWidth; private int mHeight; private int mMaxFaces; diff --git a/media/java/android/media/JetPlayer.java b/media/java/android/media/JetPlayer.java index 06cda34..bd91fc5 100644 --- a/media/java/android/media/JetPlayer.java +++ b/media/java/android/media/JetPlayer.java @@ -127,7 +127,7 @@ public class JetPlayer * Accessed by native methods: provides access to C++ JetPlayer object */ @SuppressWarnings("unused") - private int mNativePlayerInJavaObj; + private long mNativePlayerInJavaObj; //-------------------------------------------- diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index 5175830..ddf88df 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -644,5 +644,5 @@ final public class MediaCodec { native_init(); } - private int mNativeContext; + private long mNativeContext; } diff --git a/media/java/android/media/MediaCrypto.java b/media/java/android/media/MediaCrypto.java index 40a1326..c7c3fc2 100644 --- a/media/java/android/media/MediaCrypto.java +++ b/media/java/android/media/MediaCrypto.java @@ -88,5 +88,5 @@ public final class MediaCrypto { native_init(); } - private int mNativeContext; + private long mNativeContext; } diff --git a/media/java/android/media/MediaExtractor.java b/media/java/android/media/MediaExtractor.java index e558c07..c3e5035 100644 --- a/media/java/android/media/MediaExtractor.java +++ b/media/java/android/media/MediaExtractor.java @@ -352,5 +352,5 @@ final public class MediaExtractor { native_init(); } - private int mNativeContext; + private long mNativeContext; } diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java index 9014453..db27d09 100644 --- a/media/java/android/media/MediaMetadataRetriever.java +++ b/media/java/android/media/MediaMetadataRetriever.java @@ -42,7 +42,7 @@ public class MediaMetadataRetriever // The field below is accessed by native methods @SuppressWarnings("unused") - private int mNativeContext; + private long mNativeContext; private static final int EMBEDDED_PICTURE_TYPE_ANY = 0xFFFF; diff --git a/media/java/android/media/MediaMuxer.java b/media/java/android/media/MediaMuxer.java index 6dd4d3c..e5c97e7 100644 --- a/media/java/android/media/MediaMuxer.java +++ b/media/java/android/media/MediaMuxer.java @@ -65,8 +65,6 @@ import java.util.Map; final public class MediaMuxer { - private long mNativeContext; - static { System.loadLibrary("media_jni"); } diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index 706258a..b34cea8 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -572,8 +572,8 @@ public class MediaPlayer implements SubtitleController.Listener // macro invocation in IMediaPlayer.cpp private final static String IMEDIA_PLAYER = "android.media.IMediaPlayer"; - private int mNativeContext; // accessed by native methods - private int mNativeSurfaceTexture; // accessed by native methods + private long mNativeContext; // accessed by native methods + private long mNativeSurfaceTexture; // accessed by native methods private int mListenerContext; // accessed by native methods private SurfaceHolder mSurfaceHolder; private EventHandler mEventHandler; diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index 8dcbd6b..5a9d577 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -81,7 +81,7 @@ public class MediaRecorder // The two fields below are accessed by native methods @SuppressWarnings("unused") - private int mNativeContext; + private long mNativeContext; @SuppressWarnings("unused") private Surface mSurface; diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index de3041e..53835e2 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -301,7 +301,7 @@ public class MediaScanner // 148 and up don't seem to have been defined yet. }; - private int mNativeContext; + private long mNativeContext; private Context mContext; private String mPackageName; private IContentProvider mMediaProvider; diff --git a/media/java/android/media/RemoteDisplay.java b/media/java/android/media/RemoteDisplay.java index 7afce1a..4e937a5 100644 --- a/media/java/android/media/RemoteDisplay.java +++ b/media/java/android/media/RemoteDisplay.java @@ -38,12 +38,12 @@ public final class RemoteDisplay { private final Listener mListener; private final Handler mHandler; - private int mPtr; + private long mPtr; - private native int nativeListen(String iface); - private native void nativeDispose(int ptr); - private native void nativePause(int ptr); - private native void nativeResume(int ptr); + private native long nativeListen(String iface); + private native void nativeDispose(long ptr); + private native void nativePause(long ptr); + private native void nativeResume(long ptr); private RemoteDisplay(Listener listener, Handler handler) { mListener = listener; diff --git a/media/java/android/media/SoundPool.java b/media/java/android/media/SoundPool.java index 06af5de..fbfc574 100644 --- a/media/java/android/media/SoundPool.java +++ b/media/java/android/media/SoundPool.java @@ -443,7 +443,7 @@ public class SoundPool { private final static String TAG = "SoundPool"; private final static boolean DEBUG = false; - private int mNativeContext; // accessed by native methods + private long mNativeContext; // accessed by native methods private EventHandler mEventHandler; private SoundPool.OnLoadCompleteListener mOnLoadCompleteListener; diff --git a/media/java/android/media/ToneGenerator.java b/media/java/android/media/ToneGenerator.java index 5592105..713f147 100644 --- a/media/java/android/media/ToneGenerator.java +++ b/media/java/android/media/ToneGenerator.java @@ -887,5 +887,5 @@ public class ToneGenerator protected void finalize() { native_finalize(); } @SuppressWarnings("unused") - private int mNativeContext; // accessed by native methods + private long mNativeContext; // accessed by native methods } diff --git a/media/java/android/media/audiofx/AudioEffect.java b/media/java/android/media/audiofx/AudioEffect.java index 1e1ef8c..cc121a3 100644 --- a/media/java/android/media/audiofx/AudioEffect.java +++ b/media/java/android/media/audiofx/AudioEffect.java @@ -315,8 +315,8 @@ public class AudioEffect { private int mId; // accessed by native methods - private int mNativeAudioEffect; - private int mJniData; + private long mNativeAudioEffect; + private long mJniData; /** * Effect descriptor diff --git a/media/java/android/media/audiofx/Visualizer.java b/media/java/android/media/audiofx/Visualizer.java index fb7f718..ff04201 100644 --- a/media/java/android/media/audiofx/Visualizer.java +++ b/media/java/android/media/audiofx/Visualizer.java @@ -184,8 +184,8 @@ public class Visualizer { private OnServerDiedListener mServerDiedListener = null; // accessed by native methods - private int mNativeVisualizer; - private int mJniData; + private long mNativeVisualizer; + private long mJniData; //-------------------------------------------------------------------------- // Constructor, Finalize diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java index f4fccbe..2b0b3e2 100644 --- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java +++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java @@ -118,7 +118,7 @@ class MediaArtistNativeHelper { private boolean mErrorFlagSet = false; @SuppressWarnings("unused") - private int mManualEditContext; + private long mManualEditContext; /* Listeners */ diff --git a/media/java/android/mtp/MtpDatabase.java b/media/java/android/mtp/MtpDatabase.java index cf1238a..9ceefc3 100755 --- a/media/java/android/mtp/MtpDatabase.java +++ b/media/java/android/mtp/MtpDatabase.java @@ -1036,7 +1036,7 @@ public class MtpDatabase { } // used by the JNI code - private int mNativeContext; + private long mNativeContext; private native final void native_setup(); private native final void native_finalize(); diff --git a/media/java/android/mtp/MtpDevice.java b/media/java/android/mtp/MtpDevice.java index 3272fed..8310579 100644 --- a/media/java/android/mtp/MtpDevice.java +++ b/media/java/android/mtp/MtpDevice.java @@ -237,7 +237,7 @@ public final class MtpDevice { } // used by the JNI code - private int mNativeContext; + private long mNativeContext; private native boolean native_open(String deviceName, int fd); private native void native_close(); diff --git a/media/java/android/mtp/MtpServer.java b/media/java/android/mtp/MtpServer.java index f561cc0..266f78e 100644 --- a/media/java/android/mtp/MtpServer.java +++ b/media/java/android/mtp/MtpServer.java @@ -22,7 +22,7 @@ package android.mtp; */ public class MtpServer implements Runnable { - private int mNativeContext; // accessed by native methods + private long mNativeContext; // accessed by native methods static { System.loadLibrary("media_jni"); diff --git a/media/jni/android_media_AmrInputStream.cpp b/media/jni/android_media_AmrInputStream.cpp index b5220fe..3df6530 100644 --- a/media/jni/android_media_AmrInputStream.cpp +++ b/media/jni/android_media_AmrInputStream.cpp @@ -49,17 +49,17 @@ struct GsmAmrEncoderState { int32_t mLastModeUsed; }; -static jint android_media_AmrInputStream_GsmAmrEncoderNew +static jlong android_media_AmrInputStream_GsmAmrEncoderNew (JNIEnv *env, jclass clazz) { GsmAmrEncoderState* gae = new GsmAmrEncoderState(); if (gae == NULL) { jniThrowRuntimeException(env, "Out of memory"); } - return (jint)gae; + return (jlong)gae; } static void android_media_AmrInputStream_GsmAmrEncoderInitialize - (JNIEnv *env, jclass clazz, jint gae) { + (JNIEnv *env, jclass clazz, jlong gae) { GsmAmrEncoderState *state = (GsmAmrEncoderState *) gae; int32_t nResult = AMREncodeInit(&state->mEncState, &state->mSidState, false); if (nResult != OK) { @@ -70,7 +70,7 @@ static void android_media_AmrInputStream_GsmAmrEncoderInitialize static jint android_media_AmrInputStream_GsmAmrEncoderEncode (JNIEnv *env, jclass clazz, - jint gae, jbyteArray pcm, jint pcmOffset, jbyteArray amr, jint amrOffset) { + jlong gae, jbyteArray pcm, jint pcmOffset, jbyteArray amr, jint amrOffset) { jbyte inBuf[BYTES_PER_FRAME]; jbyte outBuf[MAX_OUTPUT_BUFFER_SIZE]; @@ -86,7 +86,7 @@ static jint android_media_AmrInputStream_GsmAmrEncoderEncode if (length < 0) { jniThrowExceptionFmt(env, "java/io/IOException", "Failed to encode a frame with error code: %d", length); - return -1; + return (jint)-1; } // The 1st byte of PV AMR frames are WMF (Wireless Multimedia Forum) @@ -101,30 +101,30 @@ static jint android_media_AmrInputStream_GsmAmrEncoderEncode env->SetByteArrayRegion(amr, amrOffset, length, outBuf); - return length; + return (jint)length; } static void android_media_AmrInputStream_GsmAmrEncoderCleanup - (JNIEnv *env, jclass clazz, jint gae) { - GsmAmrEncoderState *state = (GsmAmrEncoderState *)gae; + (JNIEnv *env, jclass clazz, jlong gae) { + GsmAmrEncoderState *state = (GsmAmrEncoderState *) gae; AMREncodeExit(&state->mEncState, &state->mSidState); state->mEncState = NULL; state->mSidState = NULL; } static void android_media_AmrInputStream_GsmAmrEncoderDelete - (JNIEnv *env, jclass clazz, jint gae) { + (JNIEnv *env, jclass clazz, jlong gae) { delete (GsmAmrEncoderState*)gae; } // ---------------------------------------------------------------------------- static JNINativeMethod gMethods[] = { - {"GsmAmrEncoderNew", "()I", (void*)android_media_AmrInputStream_GsmAmrEncoderNew}, - {"GsmAmrEncoderInitialize", "(I)V", (void*)android_media_AmrInputStream_GsmAmrEncoderInitialize}, - {"GsmAmrEncoderEncode", "(I[BI[BI)I", (void*)android_media_AmrInputStream_GsmAmrEncoderEncode}, - {"GsmAmrEncoderCleanup", "(I)V", (void*)android_media_AmrInputStream_GsmAmrEncoderCleanup}, - {"GsmAmrEncoderDelete", "(I)V", (void*)android_media_AmrInputStream_GsmAmrEncoderDelete}, + {"GsmAmrEncoderNew", "()J", (void*)android_media_AmrInputStream_GsmAmrEncoderNew}, + {"GsmAmrEncoderInitialize", "(J)V", (void*)android_media_AmrInputStream_GsmAmrEncoderInitialize}, + {"GsmAmrEncoderEncode", "(J[BI[BI)I", (void*)android_media_AmrInputStream_GsmAmrEncoderEncode}, + {"GsmAmrEncoderCleanup", "(J)V", (void*)android_media_AmrInputStream_GsmAmrEncoderCleanup}, + {"GsmAmrEncoderDelete", "(J)V", (void*)android_media_AmrInputStream_GsmAmrEncoderDelete}, }; diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp index 0030dbd..d475eee 100644 --- a/media/jni/android_media_ImageReader.cpp +++ b/media/jni/android_media_ImageReader.cpp @@ -707,6 +707,7 @@ static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz, } status_t res = consumer->lockNextBuffer(buffer); if (res != NO_ERROR) { + ctx->returnLockedBuffer(buffer); if (res != BAD_VALUE /*no buffers*/) { if (res == NOT_ENOUGH_DATA) { return ACQUIRE_MAX_IMAGES; diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp index b8d437c..221ea57 100644 --- a/media/jni/android_media_MediaCodec.cpp +++ b/media/jni/android_media_MediaCodec.cpp @@ -328,20 +328,20 @@ using namespace android; static sp<JMediaCodec> setMediaCodec( JNIEnv *env, jobject thiz, const sp<JMediaCodec> &codec) { - sp<JMediaCodec> old = (JMediaCodec *)env->GetIntField(thiz, gFields.context); + sp<JMediaCodec> old = (JMediaCodec *)env->GetLongField(thiz, gFields.context); if (codec != NULL) { codec->incStrong(thiz); } if (old != NULL) { old->decStrong(thiz); } - env->SetIntField(thiz, gFields.context, (int)codec.get()); + env->SetLongField(thiz, gFields.context, (jlong)codec.get()); return old; } static sp<JMediaCodec> getMediaCodec(JNIEnv *env, jobject thiz) { - return (JMediaCodec *)env->GetIntField(thiz, gFields.context); + return (JMediaCodec *)env->GetLongField(thiz, gFields.context); } static void android_media_MediaCodec_release(JNIEnv *env, jobject thiz) { @@ -710,7 +710,7 @@ static jint android_media_MediaCodec_dequeueInputBuffer( status_t err = codec->dequeueInputBuffer(&index, timeoutUs); if (err == OK) { - return index; + return (jint) index; } return throwExceptionAsNecessary(env, err); @@ -732,7 +732,7 @@ static jint android_media_MediaCodec_dequeueOutputBuffer( env, bufferInfo, &index, timeoutUs); if (err == OK) { - return index; + return (jint) index; } return throwExceptionAsNecessary(env, err); @@ -885,7 +885,7 @@ static void android_media_MediaCodec_native_init(JNIEnv *env) { env, env->FindClass("android/media/MediaCodec")); CHECK(clazz.get() != NULL); - gFields.context = env->GetFieldID(clazz.get(), "mNativeContext", "I"); + gFields.context = env->GetFieldID(clazz.get(), "mNativeContext", "J"); CHECK(gFields.context != NULL); clazz.reset(env->FindClass("android/media/MediaCodec$CryptoInfo")); diff --git a/media/jni/android_media_MediaCrypto.cpp b/media/jni/android_media_MediaCrypto.cpp index d0f56ea..a6f8dcd 100644 --- a/media/jni/android_media_MediaCrypto.cpp +++ b/media/jni/android_media_MediaCrypto.cpp @@ -38,7 +38,7 @@ struct fields_t { static fields_t gFields; static sp<JCrypto> getCrypto(JNIEnv *env, jobject thiz) { - return (JCrypto *)env->GetIntField(thiz, gFields.context); + return (JCrypto *)env->GetLongField(thiz, gFields.context); } JCrypto::JCrypto( @@ -146,14 +146,14 @@ using namespace android; static sp<JCrypto> setCrypto( JNIEnv *env, jobject thiz, const sp<JCrypto> &crypto) { - sp<JCrypto> old = (JCrypto *)env->GetIntField(thiz, gFields.context); + sp<JCrypto> old = (JCrypto *)env->GetLongField(thiz, gFields.context); if (crypto != NULL) { crypto->incStrong(thiz); } if (old != NULL) { old->decStrong(thiz); } - env->SetIntField(thiz, gFields.context, (int)crypto.get()); + env->SetLongField(thiz, gFields.context, (jlong)crypto.get()); return old; } @@ -166,7 +166,7 @@ static void android_media_MediaCrypto_native_init(JNIEnv *env) { jclass clazz = env->FindClass("android/media/MediaCrypto"); CHECK(clazz != NULL); - gFields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + gFields.context = env->GetFieldID(clazz, "mNativeContext", "J"); CHECK(gFields.context != NULL); } @@ -232,7 +232,7 @@ static jboolean android_media_MediaCrypto_isCryptoSchemeSupportedNative( env, "java/lang/IllegalArgumentException", NULL); - return false; + return JNI_FALSE; } jboolean isCopy; @@ -243,27 +243,27 @@ static jboolean android_media_MediaCrypto_isCryptoSchemeSupportedNative( env->ReleaseByteArrayElements(uuidObj, uuid, 0); uuid = NULL; - return result; + return result ? JNI_TRUE : JNI_FALSE; } static jboolean android_media_MediaCrypto_requiresSecureDecoderComponent( JNIEnv *env, jobject thiz, jstring mimeObj) { if (mimeObj == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return JNI_FALSE; } sp<JCrypto> crypto = getCrypto(env, thiz); if (crypto == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return JNI_FALSE; } const char *mime = env->GetStringUTFChars(mimeObj, NULL); if (mime == NULL) { - return false; + return JNI_FALSE; } bool result = crypto->requiresSecureDecoderComponent(mime); @@ -271,7 +271,7 @@ static jboolean android_media_MediaCrypto_requiresSecureDecoderComponent( env->ReleaseStringUTFChars(mimeObj, mime); mime = NULL; - return result; + return result ? JNI_TRUE : JNI_FALSE; } static JNINativeMethod gMethods[] = { diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp index 6d90ccb..052d97d 100644 --- a/media/jni/android_media_MediaDrm.cpp +++ b/media/jni/android_media_MediaDrm.cpp @@ -186,6 +186,7 @@ void JNIDrmListener::notify(DrmPlugin::EventType eventType, int extra, nativeParcel->setData(obj->data(), obj->dataSize()); env->CallStaticVoidMethod(mClass, gFields.post_event, mObject, jeventType, extra, jParcel); + env->DeleteLocalRef(jParcel); } } @@ -491,7 +492,7 @@ static sp<JDrm> setDrm( if (old != NULL) { old->decStrong(thiz); } - env->SetIntField(thiz, gFields.context, (int)drm.get()); + env->SetLongField(thiz, gFields.context, reinterpret_cast<jlong>(drm.get())); return old; } diff --git a/media/jni/android_media_MediaExtractor.cpp b/media/jni/android_media_MediaExtractor.cpp index 1ac45d4..705de88 100644 --- a/media/jni/android_media_MediaExtractor.cpp +++ b/media/jni/android_media_MediaExtractor.cpp @@ -88,7 +88,7 @@ class JavaDataSourceBridge : public DataSource { env->GetByteArrayRegion(byteArrayObj, 0, size, (jbyte*) buffer); env->DeleteLocalRef(byteArrayObj); if (env->ExceptionCheck()) { - ALOGW("Exception occurred while reading %d at %lld", size, offset); + ALOGW("Exception occurred while reading %zu at %lld", size, offset); LOGW_EX(env); env->ExceptionClear(); return -1; @@ -198,7 +198,7 @@ status_t JMediaExtractor::readSampleData( void *dst = env->GetDirectBufferAddress(byteBuf); - jlong dstSize; + size_t dstSize; jbyteArray byteArray = NULL; if (dst == NULL) { @@ -219,9 +219,9 @@ status_t JMediaExtractor::readSampleData( jboolean isCopy; dst = env->GetByteArrayElements(byteArray, &isCopy); - dstSize = env->GetArrayLength(byteArray); + dstSize = (size_t) env->GetArrayLength(byteArray); } else { - dstSize = env->GetDirectBufferCapacity(byteBuf); + dstSize = (size_t) env->GetDirectBufferCapacity(byteBuf); } if (dstSize < offset) { @@ -299,7 +299,7 @@ using namespace android; static sp<JMediaExtractor> setMediaExtractor( JNIEnv *env, jobject thiz, const sp<JMediaExtractor> &extractor) { sp<JMediaExtractor> old = - (JMediaExtractor *)env->GetIntField(thiz, gFields.context); + (JMediaExtractor *)env->GetLongField(thiz, gFields.context); if (extractor != NULL) { extractor->incStrong(thiz); @@ -307,13 +307,13 @@ static sp<JMediaExtractor> setMediaExtractor( if (old != NULL) { old->decStrong(thiz); } - env->SetIntField(thiz, gFields.context, (int)extractor.get()); + env->SetLongField(thiz, gFields.context, (jlong)extractor.get()); return old; } static sp<JMediaExtractor> getMediaExtractor(JNIEnv *env, jobject thiz) { - return (JMediaExtractor *)env->GetIntField(thiz, gFields.context); + return (JMediaExtractor *)env->GetLongField(thiz, gFields.context); } static void android_media_MediaExtractor_release(JNIEnv *env, jobject thiz) { @@ -329,7 +329,7 @@ static jint android_media_MediaExtractor_getTrackCount( return -1; } - return extractor->countTracks(); + return (jint) extractor->countTracks(); } static jobject android_media_MediaExtractor_getTrackFormatNative( @@ -430,19 +430,19 @@ static jboolean android_media_MediaExtractor_advance( if (extractor == NULL) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return false; + return JNI_FALSE; } status_t err = extractor->advance(); if (err == ERROR_END_OF_STREAM) { - return false; + return JNI_FALSE; } else if (err != OK) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return JNI_FALSE; } - return true; + return JNI_TRUE; } static jint android_media_MediaExtractor_readSampleData( @@ -461,10 +461,10 @@ static jint android_media_MediaExtractor_readSampleData( return -1; } else if (err != OK) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return -1; } - return sampleSize; + return (jint) sampleSize; } static jint android_media_MediaExtractor_getSampleTrackIndex( @@ -483,10 +483,10 @@ static jint android_media_MediaExtractor_getSampleTrackIndex( return -1; } else if (err != OK) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return -1; } - return trackIndex; + return (jint) trackIndex; } static jlong android_media_MediaExtractor_getSampleTime( @@ -505,10 +505,10 @@ static jlong android_media_MediaExtractor_getSampleTime( return -1ll; } else if (err != OK) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return -1ll; } - return sampleTimeUs; + return (jlong) sampleTimeUs; } static jint android_media_MediaExtractor_getSampleFlags( @@ -517,20 +517,20 @@ static jint android_media_MediaExtractor_getSampleFlags( if (extractor == NULL) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return -1ll; + return -1; } uint32_t sampleFlags; status_t err = extractor->getSampleFlags(&sampleFlags); if (err == ERROR_END_OF_STREAM) { - return -1ll; + return -1; } else if (err != OK) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return -1; } - return sampleFlags; + return (jint) sampleFlags; } static jboolean android_media_MediaExtractor_getSampleCryptoInfo( @@ -539,27 +539,27 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo( if (extractor == NULL) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return -1ll; + return JNI_FALSE; } sp<MetaData> meta; status_t err = extractor->getSampleMeta(&meta); if (err != OK) { - return false; + return JNI_FALSE; } uint32_t type; const void *data; size_t size; if (!meta->findData(kKeyEncryptedSizes, &type, &data, &size)) { - return false; + return JNI_FALSE; } size_t numSubSamples = size / sizeof(size_t); if (numSubSamples == 0) { - return false; + return JNI_FALSE; } jintArray numBytesOfEncryptedDataObj = env->NewIntArray(numSubSamples); @@ -576,7 +576,7 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo( if (meta->findData(kKeyPlainSizes, &type, &data, &size)) { if (size != encSize) { // The two must be of the same length. - return false; + return JNI_FALSE; } numBytesOfPlainDataObj = env->NewIntArray(numSubSamples); @@ -593,7 +593,7 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo( if (meta->findData(kKeyCryptoKey, &type, &data, &size)) { if (size != 16) { // Keys must be 16 bytes in length. - return false; + return JNI_FALSE; } keyObj = env->NewByteArray(size); @@ -608,7 +608,7 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo( if (meta->findData(kKeyCryptoIV, &type, &data, &size)) { if (size != 16) { // IVs must be 16 bytes in length. - return false; + return JNI_FALSE; } ivObj = env->NewByteArray(size); @@ -634,14 +634,14 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo( ivObj, mode); - return true; + return JNI_TRUE; } static void android_media_MediaExtractor_native_init(JNIEnv *env) { jclass clazz = env->FindClass("android/media/MediaExtractor"); CHECK(clazz != NULL); - gFields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + gFields.context = env->GetFieldID(clazz, "mNativeContext", "J"); CHECK(gFields.context != NULL); clazz = env->FindClass("android/media/MediaCodec$CryptoInfo"); @@ -770,7 +770,7 @@ static jlong android_media_MediaExtractor_getCachedDurationUs( return -1ll; } - return cachedDurationUs; + return (jlong) cachedDurationUs; } static jboolean android_media_MediaExtractor_hasCacheReachedEOS( @@ -779,16 +779,16 @@ static jboolean android_media_MediaExtractor_hasCacheReachedEOS( if (extractor == NULL) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return true; + return JNI_TRUE; } int64_t cachedDurationUs; bool eos; if (!extractor->getCachedDuration(&cachedDurationUs, &eos)) { - return true; + return JNI_TRUE; } - return eos; + return eos ? JNI_TRUE : JNI_FALSE; } static void android_media_MediaExtractor_native_finalize( diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp index 297dadf..a52b24d 100644 --- a/media/jni/android_media_MediaMetadataRetriever.cpp +++ b/media/jni/android_media_MediaMetadataRetriever.cpp @@ -67,15 +67,15 @@ static void process_media_retriever_call(JNIEnv *env, status_t opStatus, const c static MediaMetadataRetriever* getRetriever(JNIEnv* env, jobject thiz) { // No lock is needed, since it is called internally by other methods that are protected - MediaMetadataRetriever* retriever = (MediaMetadataRetriever*) env->GetIntField(thiz, fields.context); + MediaMetadataRetriever* retriever = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context); return retriever; } -static void setRetriever(JNIEnv* env, jobject thiz, int retriever) +static void setRetriever(JNIEnv* env, jobject thiz, MediaMetadataRetriever* retriever) { // No lock is needed, since it is called internally by other methods that are protected - MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetIntField(thiz, fields.context); - env->SetIntField(thiz, fields.context, retriever); + MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context); + env->SetLongField(thiz, fields.context, (jlong) retriever); } static void @@ -146,10 +146,10 @@ static void android_media_MediaMetadataRetriever_setDataSourceFD(JNIEnv *env, jo int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); if (offset < 0 || length < 0 || fd < 0) { if (offset < 0) { - ALOGE("negative offset (%lld)", offset); + ALOGE("negative offset (%lld)", (long long)offset); } if (length < 0) { - ALOGE("negative length (%lld)", length); + ALOGE("negative length (%lld)", (long long)length); } if (fd < 0) { ALOGE("invalid file descriptor"); @@ -264,7 +264,7 @@ static jobject android_media_MediaMetadataRetriever_getFrameAtTime(JNIEnv *env, config); SkBitmap *bitmap = - (SkBitmap *) env->GetIntField(jBitmap, fields.nativeBitmap); + (SkBitmap *) env->GetLongField(jBitmap, fields.nativeBitmap); bitmap->lockPixels(); rotate((uint16_t*)bitmap->getPixels(), @@ -359,7 +359,7 @@ static void android_media_MediaMetadataRetriever_release(JNIEnv *env, jobject th Mutex::Autolock lock(sLock); MediaMetadataRetriever* retriever = getRetriever(env, thiz); delete retriever; - setRetriever(env, thiz, 0); + setRetriever(env, thiz, (MediaMetadataRetriever*) 0); } static void android_media_MediaMetadataRetriever_native_finalize(JNIEnv *env, jobject thiz) @@ -379,7 +379,7 @@ static void android_media_MediaMetadataRetriever_native_init(JNIEnv *env) return; } - fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.context = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.context == NULL) { return; } @@ -406,7 +406,7 @@ static void android_media_MediaMetadataRetriever_native_init(JNIEnv *env) if (fields.createScaledBitmapMethod == NULL) { return; } - fields.nativeBitmap = env->GetFieldID(fields.bitmapClazz, "mNativeBitmap", "I"); + fields.nativeBitmap = env->GetFieldID(fields.bitmapClazz, "mNativeBitmap", "J"); if (fields.nativeBitmap == NULL) { return; } @@ -435,7 +435,7 @@ static void android_media_MediaMetadataRetriever_native_setup(JNIEnv *env, jobje jniThrowException(env, "java/lang/RuntimeException", "Out of memory"); return; } - setRetriever(env, thiz, (int)retriever); + setRetriever(env, thiz, retriever); } // JNI mapping between Java methods and native methods diff --git a/media/jni/android_media_MediaMuxer.cpp b/media/jni/android_media_MediaMuxer.cpp index c58503b..2c16a05 100644 --- a/media/jni/android_media_MediaMuxer.cpp +++ b/media/jni/android_media_MediaMuxer.cpp @@ -31,7 +31,6 @@ namespace android { struct fields_t { - jfieldID context; jmethodID arrayID; }; @@ -252,12 +251,6 @@ int register_android_media_MediaMuxer(JNIEnv *env) { int err = AndroidRuntime::registerNativeMethods(env, "android/media/MediaMuxer", gMethods, NELEM(gMethods)); - jclass clazz = env->FindClass("android/media/MediaMuxer"); - CHECK(clazz != NULL); - - gFields.context = env->GetFieldID(clazz, "mNativeContext", "J"); - CHECK(gFields.context != NULL); - jclass byteBufClass = env->FindClass("java/nio/ByteBuffer"); CHECK(byteBufClass != NULL); diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index 4be9cd6..9d0d5a6 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -133,21 +133,21 @@ void JNIMediaPlayerListener::notify(int msg, int ext1, int ext2, const Parcel *o static sp<MediaPlayer> getMediaPlayer(JNIEnv* env, jobject thiz) { Mutex::Autolock l(sLock); - MediaPlayer* const p = (MediaPlayer*)env->GetIntField(thiz, fields.context); + MediaPlayer* const p = (MediaPlayer*)env->GetLongField(thiz, fields.context); return sp<MediaPlayer>(p); } static sp<MediaPlayer> setMediaPlayer(JNIEnv* env, jobject thiz, const sp<MediaPlayer>& player) { Mutex::Autolock l(sLock); - sp<MediaPlayer> old = (MediaPlayer*)env->GetIntField(thiz, fields.context); + sp<MediaPlayer> old = (MediaPlayer*)env->GetLongField(thiz, fields.context); if (player.get()) { player->incStrong((void*)setMediaPlayer); } if (old != 0) { old->decStrong((void*)setMediaPlayer); } - env->SetIntField(thiz, fields.context, (int)player.get()); + env->SetLongField(thiz, fields.context, (jlong)player.get()); return old; } @@ -244,7 +244,7 @@ android_media_MediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fil static sp<IGraphicBufferProducer> getVideoSurfaceTexture(JNIEnv* env, jobject thiz) { - IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetIntField(thiz, fields.surface_texture); + IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetLongField(thiz, fields.surface_texture); return sp<IGraphicBufferProducer>(p); } @@ -293,7 +293,7 @@ setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface, jboolean mediaPlaye } } - env->SetIntField(thiz, fields.surface_texture, (int)new_st.get()); + env->SetLongField(thiz, fields.surface_texture, (jlong)new_st.get()); // This will fail if the media player has not been initialized yet. This // can be the case if setDisplay() on MediaPlayer.java has been called @@ -384,7 +384,7 @@ android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz) sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return false; + return JNI_FALSE; } const jboolean is_playing = mp->isPlaying(); @@ -393,7 +393,7 @@ android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz) } static void -android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, int msec) +android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, jint msec) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { @@ -404,7 +404,7 @@ android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, int msec) process_media_player_call( env, thiz, mp->seekTo(msec), NULL, NULL ); } -static int +static jint android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -418,10 +418,10 @@ android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz) w = 0; } ALOGV("getVideoWidth: %d", w); - return w; + return (jint) w; } -static int +static jint android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -435,11 +435,11 @@ android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz) h = 0; } ALOGV("getVideoHeight: %d", h); - return h; + return (jint) h; } -static int +static jint android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -450,10 +450,10 @@ android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz) int msec; process_media_player_call( env, thiz, mp->getCurrentPosition(&msec), NULL, NULL ); ALOGV("getCurrentPosition: %d (msec)", msec); - return msec; + return (jint) msec; } -static int +static jint android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -464,7 +464,7 @@ android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz) int msec; process_media_player_call( env, thiz, mp->getDuration(&msec), NULL, NULL ); ALOGV("getDuration: %d (msec)", msec); - return msec; + return (jint) msec; } static void @@ -480,7 +480,7 @@ android_media_MediaPlayer_reset(JNIEnv *env, jobject thiz) } static void -android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, int streamtype) +android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, jint streamtype) { ALOGV("setAudioStreamType: %d", streamtype); sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -510,21 +510,21 @@ android_media_MediaPlayer_isLooping(JNIEnv *env, jobject thiz) sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return false; + return JNI_FALSE; } - return mp->isLooping(); + return mp->isLooping() ? JNI_TRUE : JNI_FALSE; } static void -android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, float leftVolume, float rightVolume) +android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, jfloat leftVolume, jfloat rightVolume) { - ALOGV("setVolume: left %f right %f", leftVolume, rightVolume); + ALOGV("setVolume: left %f right %f", (float) leftVolume, (float) rightVolume); sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); return; } - process_media_player_call( env, thiz, mp->setVolume(leftVolume, rightVolume), NULL, NULL ); + process_media_player_call( env, thiz, mp->setVolume((float) leftVolume, (float) rightVolume), NULL, NULL ); } // Sends the request and reply parcels to the media player via the @@ -544,7 +544,7 @@ android_media_MediaPlayer_invoke(JNIEnv *env, jobject thiz, // Don't use process_media_player_call which use the async loop to // report errors, instead returns the status. - return media_player->invoke(*request, reply); + return (jint) media_player->invoke(*request, reply); } // Sends the new filter to the client. @@ -564,7 +564,7 @@ android_media_MediaPlayer_setMetadataFilter(JNIEnv *env, jobject thiz, jobject r return UNKNOWN_ERROR; } - return media_player->setMetadataFilter(*filter); + return (jint) media_player->setMetadataFilter(*filter); } static jboolean @@ -574,14 +574,14 @@ android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update sp<MediaPlayer> media_player = getMediaPlayer(env, thiz); if (media_player == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return false; + return JNI_FALSE; } Parcel *metadata = parcelForJavaObject(env, reply); if (metadata == NULL ) { jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null"); - return false; + return JNI_FALSE; } metadata->freeData(); @@ -589,7 +589,11 @@ android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update // metadata. Note however that the parcel actually starts with the // return code so you should not rewind the parcel using // setDataPosition(0). - return media_player->getMetadata(update_only, apply_filter, metadata) == OK; + if (media_player->getMetadata(update_only, apply_filter, metadata) == OK) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } // This function gets some field IDs, which in turn causes class initialization. @@ -605,7 +609,7 @@ android_media_MediaPlayer_native_init(JNIEnv *env) return; } - fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.context = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.context == NULL) { return; } @@ -616,7 +620,7 @@ android_media_MediaPlayer_native_init(JNIEnv *env) return; } - fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "I"); + fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "J"); if (fields.surface_texture == NULL) { return; } @@ -696,7 +700,7 @@ static jint android_media_MediaPlayer_get_audio_session_id(JNIEnv *env, jobject return 0; } - return mp->getAudioSessionId(); + return (jint) mp->getAudioSessionId(); } static void @@ -733,7 +737,7 @@ android_media_MediaPlayer_pullBatteryData(JNIEnv *env, jobject thiz, jobject jav Parcel *reply = parcelForJavaObject(env, java_reply); - return service->pullBatteryData(reply); + return (jint) service->pullBatteryData(reply); } static jint @@ -772,7 +776,7 @@ android_media_MediaPlayer_setRetransmitEndpoint(JNIEnv *env, jobject thiz, jniThrowException(env, "java/lang/IllegalStateException", NULL); } - return ret; + return (jint) ret; } static void @@ -826,16 +830,19 @@ android_media_MediaPlayer_updateProxyConfig( jstring exclusionListObj = (jstring)env->CallObjectMethod( proxyProps, fields.proxyConfigGetExclusionList); - const char *exclusionList = - env->GetStringUTFChars(exclusionListObj, NULL); - if (host != NULL && exclusionListObj != NULL) { - thisplayer->updateProxyConfig(host, port, exclusionList); - } + const char *exclusionList = env->GetStringUTFChars(exclusionListObj, NULL); + + if (exclusionList != NULL) { + thisplayer->updateProxyConfig(host, port, exclusionList); - if (exclusionList != NULL) { - env->ReleaseStringUTFChars(exclusionListObj, exclusionList); - exclusionList = NULL; + env->ReleaseStringUTFChars(exclusionListObj, exclusionList); + exclusionList = NULL; + } else { + thisplayer->updateProxyConfig(host, port, ""); + } + } else if (host != NULL) { + thisplayer->updateProxyConfig(host, port, ""); } if (host != NULL) { diff --git a/media/jni/android_media_MediaProfiles.cpp b/media/jni/android_media_MediaProfiles.cpp index 3fbb8ba..48a9132 100644 --- a/media/jni/android_media_MediaProfiles.cpp +++ b/media/jni/android_media_MediaProfiles.cpp @@ -48,7 +48,7 @@ static jint android_media_MediaProfiles_native_get_num_file_formats(JNIEnv *env, jobject thiz) { ALOGV("native_get_num_file_formats"); - return sProfiles->getOutputFileFormats().size(); + return (jint) sProfiles->getOutputFileFormats().size(); } static jint @@ -119,7 +119,7 @@ static jint android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv *env, jobject thiz) { ALOGV("native_get_num_audio_encoders"); - return sProfiles->getAudioEncoders().size(); + return (jint) sProfiles->getAudioEncoders().size(); } static jobject @@ -223,18 +223,18 @@ android_media_MediaProfiles_native_has_camcorder_profile(JNIEnv *env, jobject th { ALOGV("native_has_camcorder_profile: %d %d", id, quality); if (!isCamcorderQualityKnown(quality)) { - return false; + return JNI_FALSE; } camcorder_quality q = static_cast<camcorder_quality>(quality); - return sProfiles->hasCamcorderProfile(id, q); + return sProfiles->hasCamcorderProfile(id, q) ? JNI_TRUE : JNI_FALSE; } static jint android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv *env, jobject thiz) { ALOGV("native_get_num_video_decoders"); - return sProfiles->getVideoDecoders().size(); + return (jint) sProfiles->getVideoDecoders().size(); } static jint @@ -255,7 +255,7 @@ static jint android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv *env, jobject thiz) { ALOGV("native_get_num_audio_decoders"); - return sProfiles->getAudioDecoders().size(); + return (jint) sProfiles->getAudioDecoders().size(); } static jint @@ -276,7 +276,7 @@ static jint android_media_MediaProfiles_native_get_num_image_encoding_quality_levels(JNIEnv *env, jobject thiz, jint cameraId) { ALOGV("native_get_num_image_encoding_quality_levels"); - return sProfiles->getImageEncodingQualityLevels(cameraId).size(); + return (jint) sProfiles->getImageEncodingQualityLevels(cameraId).size(); } static jint @@ -284,7 +284,7 @@ android_media_MediaProfiles_native_get_image_encoding_quality_level(JNIEnv *env, { ALOGV("native_get_image_encoding_quality_level"); Vector<int> levels = sProfiles->getImageEncodingQualityLevels(cameraId); - if (index < 0 || index >= levels.size()) { + if (index < 0 || index >= (jint) levels.size()) { jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); return -1; } diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp index 9888591..0cfd2ff 100644 --- a/media/jni/android_media_MediaRecorder.cpp +++ b/media/jni/android_media_MediaRecorder.cpp @@ -128,21 +128,21 @@ static bool process_media_recorder_call(JNIEnv *env, status_t opStatus, const ch static sp<MediaRecorder> getMediaRecorder(JNIEnv* env, jobject thiz) { Mutex::Autolock l(sLock); - MediaRecorder* const p = (MediaRecorder*)env->GetIntField(thiz, fields.context); + MediaRecorder* const p = (MediaRecorder*)env->GetLongField(thiz, fields.context); return sp<MediaRecorder>(p); } static sp<MediaRecorder> setMediaRecorder(JNIEnv* env, jobject thiz, const sp<MediaRecorder>& recorder) { Mutex::Autolock l(sLock); - sp<MediaRecorder> old = (MediaRecorder*)env->GetIntField(thiz, fields.context); + sp<MediaRecorder> old = (MediaRecorder*)env->GetLongField(thiz, fields.context); if (recorder.get()) { recorder->incStrong(thiz); } if (old != 0) { old->decStrong(thiz); } - env->SetIntField(thiz, fields.context, (int)recorder.get()); + env->SetLongField(thiz, fields.context, (jlong)recorder.get()); return old; } @@ -334,14 +334,14 @@ android_media_MediaRecorder_prepare(JNIEnv *env, jobject thiz) process_media_recorder_call(env, mr->prepare(), "java/io/IOException", "prepare failed."); } -static int +static jint android_media_MediaRecorder_native_getMaxAmplitude(JNIEnv *env, jobject thiz) { ALOGV("getMaxAmplitude"); sp<MediaRecorder> mr = getMediaRecorder(env, thiz); int result = 0; process_media_recorder_call(env, mr->getMaxAmplitude(&result), "java/lang/RuntimeException", "getMaxAmplitude failed."); - return result; + return (jint) result; } static void @@ -392,7 +392,7 @@ android_media_MediaRecorder_native_init(JNIEnv *env) return; } - fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.context = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.context == NULL) { return; } diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp index 4e3d14e..84028b7 100644 --- a/media/jni/android_media_MediaScanner.cpp +++ b/media/jni/android_media_MediaScanner.cpp @@ -226,12 +226,12 @@ private: static MediaScanner *getNativeScanner_l(JNIEnv* env, jobject thiz) { - return (MediaScanner *) env->GetIntField(thiz, fields.context); + return (MediaScanner *) env->GetLongField(thiz, fields.context); } static void setNativeScanner_l(JNIEnv* env, jobject thiz, MediaScanner *s) { - env->SetIntField(thiz, fields.context, (int)s); + env->SetLongField(thiz, fields.context, (jlong)s); } static void @@ -381,7 +381,7 @@ android_media_MediaScanner_native_init(JNIEnv *env) return; } - fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.context = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.context == NULL) { return; } @@ -398,7 +398,7 @@ android_media_MediaScanner_native_setup(JNIEnv *env, jobject thiz) return; } - env->SetIntField(thiz, fields.context, (int)mp); + env->SetLongField(thiz, fields.context, (jlong)mp); } static void diff --git a/media/jni/android_mtp_MtpDatabase.cpp b/media/jni/android_mtp_MtpDatabase.cpp index 77c7966..72ce3cc 100644 --- a/media/jni/android_mtp_MtpDatabase.cpp +++ b/media/jni/android_mtp_MtpDatabase.cpp @@ -77,7 +77,7 @@ static jfieldID field_mStringValues; MtpDatabase* getMtpDatabase(JNIEnv *env, jobject database) { - return (MtpDatabase *)env->GetIntField(database, field_context); + return (MtpDatabase *)env->GetLongField(database, field_context); } // ---------------------------------------------------------------------------- @@ -1075,17 +1075,17 @@ static void android_mtp_MtpDatabase_setup(JNIEnv *env, jobject thiz) { MyMtpDatabase* database = new MyMtpDatabase(env, thiz); - env->SetIntField(thiz, field_context, (int)database); + env->SetLongField(thiz, field_context, (jlong)database); checkAndClearExceptionFromCallback(env, __FUNCTION__); } static void android_mtp_MtpDatabase_finalize(JNIEnv *env, jobject thiz) { - MyMtpDatabase* database = (MyMtpDatabase *)env->GetIntField(thiz, field_context); + MyMtpDatabase* database = (MyMtpDatabase *)env->GetLongField(thiz, field_context); database->cleanup(env); delete database; - env->SetIntField(thiz, field_context, 0); + env->SetLongField(thiz, field_context, 0); checkAndClearExceptionFromCallback(env, __FUNCTION__); } @@ -1217,7 +1217,7 @@ int register_android_mtp_MtpDatabase(JNIEnv *env) return -1; } - field_context = env->GetFieldID(clazz, "mNativeContext", "I"); + field_context = env->GetFieldID(clazz, "mNativeContext", "J"); if (field_context == NULL) { ALOGE("Can't find MtpDatabase.mNativeContext"); return -1; diff --git a/media/jni/android_mtp_MtpDevice.cpp b/media/jni/android_mtp_MtpDevice.cpp index b61b66c..8e013a0 100644 --- a/media/jni/android_mtp_MtpDevice.cpp +++ b/media/jni/android_mtp_MtpDevice.cpp @@ -88,7 +88,7 @@ static jfieldID field_objectInfo_keywords; MtpDevice* get_device_from_object(JNIEnv* env, jobject javaDevice) { - return (MtpDevice*)env->GetIntField(javaDevice, field_context); + return (MtpDevice*)env->GetLongField(javaDevice, field_context); } static void checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) { @@ -106,15 +106,15 @@ android_mtp_MtpDevice_open(JNIEnv *env, jobject thiz, jstring deviceName, jint f { const char *deviceNameStr = env->GetStringUTFChars(deviceName, NULL); if (deviceNameStr == NULL) { - return false; + return JNI_FALSE; } MtpDevice* device = MtpDevice::open(deviceNameStr, fd); env->ReleaseStringUTFChars(deviceName, deviceNameStr); if (device) - env->SetIntField(thiz, field_context, (int)device); - return (device != NULL); + env->SetLongField(thiz, field_context, (jlong)device); + return (jboolean)(device != NULL); } static void @@ -124,7 +124,7 @@ android_mtp_MtpDevice_close(JNIEnv *env, jobject thiz) if (device) { device->close(); delete device; - env->SetIntField(thiz, field_context, 0); + env->SetLongField(thiz, field_context, 0); } } @@ -356,10 +356,11 @@ static jboolean android_mtp_MtpDevice_delete_object(JNIEnv *env, jobject thiz, jint object_id) { MtpDevice* device = get_device_from_object(env, thiz); - if (device) - return device->deleteObject(object_id); - else - return NULL; + if (device && device->deleteObject(object_id)) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } static jlong @@ -367,7 +368,7 @@ android_mtp_MtpDevice_get_parent(JNIEnv *env, jobject thiz, jint object_id) { MtpDevice* device = get_device_from_object(env, thiz); if (device) - return device->getParent(object_id); + return (jlong)device->getParent(object_id); else return -1; } @@ -377,7 +378,7 @@ android_mtp_MtpDevice_get_storage_id(JNIEnv *env, jobject thiz, jint object_id) { MtpDevice* device = get_device_from_object(env, thiz); if (device) - return device->getStorageID(object_id); + return (jlong)device->getStorageID(object_id); else return -1; } @@ -389,15 +390,15 @@ android_mtp_MtpDevice_import_file(JNIEnv *env, jobject thiz, jint object_id, jst if (device) { const char *destPathStr = env->GetStringUTFChars(dest_path, NULL); if (destPathStr == NULL) { - return false; + return JNI_FALSE; } - bool result = device->readObject(object_id, destPathStr, AID_SDCARD_RW, 0664); + jboolean result = device->readObject(object_id, destPathStr, AID_SDCARD_RW, 0664); env->ReleaseStringUTFChars(dest_path, destPathStr); return result; } - return false; + return JNI_FALSE; } // ---------------------------------------------------------------------------- @@ -618,7 +619,7 @@ int register_android_mtp_MtpDevice(JNIEnv *env) ALOGE("Can't find android/mtp/MtpDevice"); return -1; } - field_context = env->GetFieldID(clazz, "mNativeContext", "I"); + field_context = env->GetFieldID(clazz, "mNativeContext", "J"); if (field_context == NULL) { ALOGE("Can't find MtpDevice.mNativeContext"); return -1; diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp index 5252a3a..9d7f1c2 100644 --- a/media/jni/android_mtp_MtpServer.cpp +++ b/media/jni/android_mtp_MtpServer.cpp @@ -53,7 +53,7 @@ static Mutex sMutex; extern MtpDatabase* getMtpDatabase(JNIEnv *env, jobject database); static inline MtpServer* getMtpServer(JNIEnv *env, jobject thiz) { - return (MtpServer*)env->GetIntField(thiz, field_MtpServer_nativeContext); + return (MtpServer*)env->GetLongField(thiz, field_MtpServer_nativeContext); } static void @@ -63,7 +63,7 @@ android_mtp_MtpServer_setup(JNIEnv *env, jobject thiz, jobject javaDatabase, jbo if (fd >= 0) { MtpServer* server = new MtpServer(fd, getMtpDatabase(env, javaDatabase), usePtp, AID_MEDIA_RW, 0664, 0775); - env->SetIntField(thiz, field_MtpServer_nativeContext, (int)server); + env->SetLongField(thiz, field_MtpServer_nativeContext, (jlong)server); } else { ALOGE("could not open MTP driver, errno: %d", errno); } @@ -87,7 +87,7 @@ android_mtp_MtpServer_cleanup(JNIEnv *env, jobject thiz) MtpServer* server = getMtpServer(env, thiz); if (server) { delete server; - env->SetIntField(thiz, field_MtpServer_nativeContext, 0); + env->SetLongField(thiz, field_MtpServer_nativeContext, 0); } else { ALOGE("server is null in cleanup"); } @@ -226,7 +226,7 @@ int register_android_mtp_MtpServer(JNIEnv *env) ALOGE("Can't find android/mtp/MtpServer"); return -1; } - field_MtpServer_nativeContext = env->GetFieldID(clazz, "mNativeContext", "I"); + field_MtpServer_nativeContext = env->GetFieldID(clazz, "mNativeContext", "J"); if (field_MtpServer_nativeContext == NULL) { ALOGE("Can't find MtpServer.mNativeContext"); return -1; diff --git a/media/jni/audioeffect/android_media_AudioEffect.cpp b/media/jni/audioeffect/android_media_AudioEffect.cpp index bcab4f3..be37aa8 100644 --- a/media/jni/audioeffect/android_media_AudioEffect.cpp +++ b/media/jni/audioeffect/android_media_AudioEffect.cpp @@ -214,7 +214,7 @@ android_media_AudioEffect_native_init(JNIEnv *env) // nativeTrackInJavaObj fields.fidNativeAudioEffect = env->GetFieldID( fields.clazzEffect, - "mNativeAudioEffect", "I"); + "mNativeAudioEffect", "J"); if (fields.fidNativeAudioEffect == NULL) { ALOGE("Can't find AudioEffect.%s", "mNativeAudioEffect"); return; @@ -222,7 +222,7 @@ android_media_AudioEffect_native_init(JNIEnv *env) // fidJniData; fields.fidJniData = env->GetFieldID( fields.clazzEffect, - "mJniData", "I"); + "mJniData", "J"); if (fields.fidJniData == NULL) { ALOGE("Can't find AudioEffect.%s", "mJniData"); return; @@ -388,11 +388,11 @@ android_media_AudioEffect_native_setup(JNIEnv *env, jobject thiz, jobject weak_t env->SetObjectArrayElement(javadesc, 0, jdesc); - env->SetIntField(thiz, fields.fidNativeAudioEffect, (int)lpAudioEffect); + env->SetLongField(thiz, fields.fidNativeAudioEffect, (jlong)lpAudioEffect); - env->SetIntField(thiz, fields.fidJniData, (int)lpJniStorage); + env->SetLongField(thiz, fields.fidJniData, (jlong)lpJniStorage); - return AUDIOEFFECT_SUCCESS; + return (jint) AUDIOEFFECT_SUCCESS; // failures: setup_failure: @@ -404,12 +404,12 @@ setup_failure: if (lpAudioEffect) { delete lpAudioEffect; } - env->SetIntField(thiz, fields.fidNativeAudioEffect, 0); + env->SetLongField(thiz, fields.fidNativeAudioEffect, 0); if (lpJniStorage) { delete lpJniStorage; } - env->SetIntField(thiz, fields.fidJniData, 0); + env->SetLongField(thiz, fields.fidJniData, 0); if (uuidStr != NULL) { env->ReleaseStringUTFChars(uuid, uuidStr); @@ -419,27 +419,27 @@ setup_failure: env->ReleaseStringUTFChars(type, typeStr); } - return lStatus; + return (jint)lStatus; } // ---------------------------------------------------------------------------- static void android_media_AudioEffect_native_finalize(JNIEnv *env, jobject thiz) { - ALOGV("android_media_AudioEffect_native_finalize jobject: %x\n", (int)thiz); + ALOGV("android_media_AudioEffect_native_finalize jobject: %p\n", thiz); // delete the AudioEffect object - AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField( + AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField( thiz, fields.fidNativeAudioEffect); if (lpAudioEffect) { - ALOGV("deleting AudioEffect: %x\n", (int)lpAudioEffect); + ALOGV("deleting AudioEffect: %p\n", lpAudioEffect); delete lpAudioEffect; } // delete the JNI data - AudioEffectJniStorage* lpJniStorage = (AudioEffectJniStorage *)env->GetIntField( + AudioEffectJniStorage* lpJniStorage = (AudioEffectJniStorage *)env->GetLongField( thiz, fields.fidJniData); if (lpJniStorage) { - ALOGV("deleting pJniStorage: %x\n", (int)lpJniStorage); + ALOGV("deleting pJniStorage: %p\n", lpJniStorage); delete lpJniStorage; } } @@ -451,15 +451,15 @@ static void android_media_AudioEffect_native_release(JNIEnv *env, jobject thiz) android_media_AudioEffect_native_finalize(env, thiz); // + reset the native resources in the Java object so any attempt to access // them after a call to release fails. - env->SetIntField(thiz, fields.fidNativeAudioEffect, 0); - env->SetIntField(thiz, fields.fidJniData, 0); + env->SetLongField(thiz, fields.fidNativeAudioEffect, 0); + env->SetLongField(thiz, fields.fidJniData, 0); } static jint android_media_AudioEffect_native_setEnabled(JNIEnv *env, jobject thiz, jboolean enabled) { // retrieve the AudioEffect object - AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField( + AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField( thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { @@ -468,23 +468,27 @@ android_media_AudioEffect_native_setEnabled(JNIEnv *env, jobject thiz, jboolean return AUDIOEFFECT_ERROR_NO_INIT; } - return translateError(lpAudioEffect->setEnabled(enabled)); + return (jint) translateError(lpAudioEffect->setEnabled(enabled)); } static jboolean android_media_AudioEffect_native_getEnabled(JNIEnv *env, jobject thiz) { // retrieve the AudioEffect object - AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField( + AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField( thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { jniThrowException(env, "java/lang/IllegalStateException", "Unable to retrieve AudioEffect pointer for getEnabled()"); - return false; + return JNI_FALSE; } - return (jboolean)lpAudioEffect->getEnabled(); + if (lpAudioEffect->getEnabled()) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } @@ -492,24 +496,24 @@ static jboolean android_media_AudioEffect_native_hasControl(JNIEnv *env, jobject thiz) { // retrieve the AudioEffect object - AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField( + AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField( thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { jniThrowException(env, "java/lang/IllegalStateException", "Unable to retrieve AudioEffect pointer for hasControl()"); - return false; + return JNI_FALSE; } if (lpAudioEffect->initCheck() == NO_ERROR) { - return true; + return JNI_TRUE; } else { - return false; + return JNI_FALSE; } } static jint android_media_AudioEffect_native_setParameter(JNIEnv *env, - jobject thiz, int psize, jbyteArray pJavaParam, int vsize, + jobject thiz, jint psize, jbyteArray pJavaParam, jint vsize, jbyteArray pJavaValue) { // retrieve the AudioEffect object jbyte* lpValue = NULL; @@ -518,7 +522,7 @@ static jint android_media_AudioEffect_native_setParameter(JNIEnv *env, effect_param_t *p; int voffset; - AudioEffect* lpAudioEffect = (AudioEffect *) env->GetIntField(thiz, + AudioEffect* lpAudioEffect = (AudioEffect *) env->GetLongField(thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { @@ -567,7 +571,7 @@ setParameter_Exit: if (lpValue != NULL) { env->ReleasePrimitiveArrayCritical(pJavaValue, lpValue, 0); } - return translateError(lStatus); + return (jint) translateError(lStatus); } static jint @@ -581,7 +585,7 @@ android_media_AudioEffect_native_getParameter(JNIEnv *env, effect_param_t *p; int voffset; - AudioEffect* lpAudioEffect = (AudioEffect *) env->GetIntField(thiz, + AudioEffect* lpAudioEffect = (AudioEffect *) env->GetLongField(thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { @@ -637,7 +641,7 @@ getParameter_Exit: if (lStatus == NO_ERROR) { return vsize; } - return translateError(lStatus); + return (jint) translateError(lStatus); } static jint android_media_AudioEffect_native_command(JNIEnv *env, jobject thiz, @@ -648,7 +652,7 @@ static jint android_media_AudioEffect_native_command(JNIEnv *env, jobject thiz, jint lStatus = AUDIOEFFECT_ERROR_BAD_VALUE; // retrieve the AudioEffect object - AudioEffect* lpAudioEffect = (AudioEffect *) env->GetIntField(thiz, + AudioEffect* lpAudioEffect = (AudioEffect *) env->GetLongField(thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { diff --git a/media/jni/audioeffect/android_media_Visualizer.cpp b/media/jni/audioeffect/android_media_Visualizer.cpp index 40cd06b..8463d94 100644 --- a/media/jni/audioeffect/android_media_Visualizer.cpp +++ b/media/jni/audioeffect/android_media_Visualizer.cpp @@ -231,7 +231,7 @@ static void captureCallback(void* user, static Visualizer *getVisualizer(JNIEnv* env, jobject thiz) { - Visualizer *v = (Visualizer *)env->GetIntField( + Visualizer *v = (Visualizer *)env->GetLongField( thiz, fields.fidNativeVisualizer); if (v == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -282,7 +282,7 @@ android_media_visualizer_native_init(JNIEnv *env) // nativeTrackInJavaObj fields.fidNativeVisualizer = env->GetFieldID( fields.clazzEffect, - "mNativeVisualizer", "I"); + "mNativeVisualizer", "J"); if (fields.fidNativeVisualizer == NULL) { ALOGE("Can't find Visualizer.%s", "mNativeVisualizer"); return; @@ -290,7 +290,7 @@ android_media_visualizer_native_init(JNIEnv *env) // fidJniData; fields.fidJniData = env->GetFieldID( fields.clazzEffect, - "mJniData", "I"); + "mJniData", "J"); if (fields.fidJniData == NULL) { ALOGE("Can't find Visualizer.%s", "mJniData"); return; @@ -391,9 +391,9 @@ android_media_visualizer_native_setup(JNIEnv *env, jobject thiz, jobject weak_th env->ReleasePrimitiveArrayCritical(jId, nId, 0); nId = NULL; - env->SetIntField(thiz, fields.fidNativeVisualizer, (int)lpVisualizer); + env->SetLongField(thiz, fields.fidNativeVisualizer, (jlong)lpVisualizer); - env->SetIntField(thiz, fields.fidJniData, (int)lpJniStorage); + env->SetLongField(thiz, fields.fidJniData, (jlong)lpJniStorage); return VISUALIZER_SUCCESS; @@ -407,33 +407,33 @@ setup_failure: if (lpVisualizer) { delete lpVisualizer; } - env->SetIntField(thiz, fields.fidNativeVisualizer, 0); + env->SetLongField(thiz, fields.fidNativeVisualizer, 0); if (lpJniStorage) { delete lpJniStorage; } - env->SetIntField(thiz, fields.fidJniData, 0); + env->SetLongField(thiz, fields.fidJniData, 0); - return lStatus; + return (jint) lStatus; } // ---------------------------------------------------------------------------- static void android_media_visualizer_native_finalize(JNIEnv *env, jobject thiz) { - ALOGV("android_media_visualizer_native_finalize jobject: %x\n", (int)thiz); + ALOGV("android_media_visualizer_native_finalize jobject: %p\n", thiz); // delete the Visualizer object - Visualizer* lpVisualizer = (Visualizer *)env->GetIntField( + Visualizer* lpVisualizer = (Visualizer *)env->GetLongField( thiz, fields.fidNativeVisualizer); if (lpVisualizer) { - ALOGV("deleting Visualizer: %x\n", (int)lpVisualizer); + ALOGV("deleting Visualizer: %p\n", lpVisualizer); delete lpVisualizer; } // delete the JNI data - visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetIntField( + visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetLongField( thiz, fields.fidJniData); if (lpJniStorage) { - ALOGV("deleting pJniStorage: %x\n", (int)lpJniStorage); + ALOGV("deleting pJniStorage: %p\n", lpJniStorage); delete lpJniStorage; } } @@ -445,8 +445,8 @@ static void android_media_visualizer_native_release(JNIEnv *env, jobject thiz) android_media_visualizer_native_finalize(env, thiz); // + reset the native resources in the Java object so any attempt to access // them after a call to release fails. - env->SetIntField(thiz, fields.fidNativeVisualizer, 0); - env->SetIntField(thiz, fields.fidJniData, 0); + env->SetLongField(thiz, fields.fidNativeVisualizer, 0); + env->SetLongField(thiz, fields.fidJniData, 0); } static jint @@ -460,7 +460,7 @@ android_media_visualizer_native_setEnabled(JNIEnv *env, jobject thiz, jboolean e jint retVal = translateError(lpVisualizer->setEnabled(enabled)); if (!enabled) { - visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetIntField( + visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetLongField( thiz, fields.fidJniData); if (NULL != lpJniStorage) @@ -475,10 +475,14 @@ android_media_visualizer_native_getEnabled(JNIEnv *env, jobject thiz) { Visualizer* lpVisualizer = getVisualizer(env, thiz); if (lpVisualizer == NULL) { - return false; + return JNI_FALSE; } - return (jboolean)lpVisualizer->getEnabled(); + if (lpVisualizer->getEnabled()) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } static jintArray @@ -496,7 +500,7 @@ android_media_visualizer_native_getCaptureSizeRange(JNIEnv *env, jobject thiz) static jint android_media_visualizer_native_getMaxCaptureRate(JNIEnv *env, jobject thiz) { - return Visualizer::getMaxCaptureRate(); + return (jint) Visualizer::getMaxCaptureRate(); } static jint @@ -517,7 +521,7 @@ android_media_visualizer_native_getCaptureSize(JNIEnv *env, jobject thiz) if (lpVisualizer == NULL) { return -1; } - return lpVisualizer->getCaptureSize(); + return (jint) lpVisualizer->getCaptureSize(); } static jint @@ -538,7 +542,7 @@ android_media_visualizer_native_getScalingMode(JNIEnv *env, jobject thiz) if (lpVisualizer == NULL) { return -1; } - return lpVisualizer->getScalingMode(); + return (jint)lpVisualizer->getScalingMode(); } static jint @@ -568,7 +572,7 @@ android_media_visualizer_native_getSamplingRate(JNIEnv *env, jobject thiz) if (lpVisualizer == NULL) { return -1; } - return lpVisualizer->getSamplingRate(); + return (jint) lpVisualizer->getSamplingRate(); } static jint @@ -634,7 +638,7 @@ android_media_setPeriodicCapture(JNIEnv *env, jobject thiz, jint rate, jboolean if (lpVisualizer == NULL) { return VISUALIZER_ERROR_NO_INIT; } - visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetIntField(thiz, + visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetLongField(thiz, fields.fidJniData); if (lpJniStorage == NULL) { return VISUALIZER_ERROR_NO_INIT; diff --git a/media/jni/mediaeditor/VideoEditorClasses.cpp b/media/jni/mediaeditor/VideoEditorClasses.cpp index d8099dd..d29fad3 100644 --- a/media/jni/mediaeditor/VideoEditorClasses.cpp +++ b/media/jni/mediaeditor/VideoEditorClasses.cpp @@ -609,7 +609,7 @@ VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(EffectSettings, EFFECT_SETTINGS_CLASS_NAME) VIDEOEDIT_JAVA_DEFINE_FIELDS(Engine) { - VIDEOEDIT_JAVA_FIELD_INIT("mManualEditContext", "I") + VIDEOEDIT_JAVA_FIELD_INIT("mManualEditContext", "J") }; VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(Engine, MANUAL_EDIT_ENGINE_CLASS_NAME) @@ -3096,7 +3096,7 @@ videoEditClasses_getContext( if (*pResult) { // Retrieve the context pointer. - pContext = (void *)pEnv->GetIntField(object, fieldIds.context); + pContext = (void *)pEnv->GetLongField(object, fieldIds.context); } // Return the context pointer. @@ -3132,15 +3132,15 @@ videoEditClasses_setContext( { // Set the context field. VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", - "The context value from JAVA before setting is = 0x%x", - pEnv->GetIntField(object, fieldIds.context)); + "The context value from JAVA before setting is = %p", + (void *)pEnv->GetLongField(object, fieldIds.context)); - pEnv->SetIntField(object, fieldIds.context, (int)pContext); - M4OSA_TRACE1_1("The context value in JNI is = 0x%x",pContext); + pEnv->SetLongField(object, fieldIds.context, (jlong)pContext); + M4OSA_TRACE1_1("The context value in JNI is = %p",pContext); VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", - "The context value from JAVA after setting is = 0x%x", - pEnv->GetIntField(object, fieldIds.context)); + "The context value from JAVA after setting is = %p", + (void *)pEnv->GetLongField(object, fieldIds.context)); } } diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp index c1ad516..058012b 100644 --- a/media/jni/mediaeditor/VideoEditorMain.cpp +++ b/media/jni/mediaeditor/VideoEditorMain.cpp @@ -170,7 +170,7 @@ static void videoEditor_stopEncoding( static void videoEditor_release( JNIEnv* pEnv, jobject thiz); -static int videoEditor_getPixels( +static jint videoEditor_getPixels( JNIEnv* env, jobject thiz, jstring path, @@ -178,7 +178,7 @@ static int videoEditor_getPixels( M4OSA_UInt32 width, M4OSA_UInt32 height, M4OSA_UInt32 timeMS); -static int videoEditor_getPixelsList( +static jint videoEditor_getPixelsList( JNIEnv* env, jobject thiz, jstring path, @@ -209,7 +209,7 @@ videoEditor_populateSettings( jobject object, jobject audioSettingObject); -static int videoEditor_stopPreview(JNIEnv* pEnv, +static jint videoEditor_stopPreview(JNIEnv* pEnv, jobject thiz); static jobject @@ -218,7 +218,7 @@ videoEditor_getProperties( jobject thiz, jstring file); -static int videoEditor_renderPreviewFrame(JNIEnv* pEnv, +static jint videoEditor_renderPreviewFrame(JNIEnv* pEnv, jobject thiz, jobject mSurface, jlong fromMs, @@ -231,7 +231,7 @@ static int videoEditor_registerManualEditMethods( static void jniPreviewProgressCallback(void* cookie, M4OSA_UInt32 msgType, void *argc); -static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, +static jint videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, jobject thiz, jobject mSurface, jstring filePath, @@ -241,7 +241,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, jint surfaceHeight, jlong fromMs); -static int videoEditor_generateAudioWaveFormSync ( JNIEnv* pEnv, +static jint videoEditor_generateAudioWaveFormSync ( JNIEnv* pEnv, jobject thiz, jstring pcmfilePath, jstring outGraphfilePath, @@ -258,7 +258,7 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext, M4OSA_Char* infilePath, M4OSA_Char* pcmfilePath ); -static int +static jint videoEditor_generateClip( JNIEnv* pEnv, jobject thiz, @@ -572,7 +572,7 @@ static M4OSA_ERR checkClipVideoProfileAndLevel(M4DECODER_VideoDecoders *pDecoder return result; } -static int videoEditor_stopPreview(JNIEnv* pEnv, +static jint videoEditor_stopPreview(JNIEnv* pEnv, jobject thiz) { ManualEditContext* pContext = M4OSA_NULL; @@ -594,7 +594,7 @@ static int videoEditor_stopPreview(JNIEnv* pEnv, pContext->mOverlayFileName = NULL; } - return lastProgressTimeMs; + return (jint)lastProgressTimeMs; } static void videoEditor_clearSurface(JNIEnv* pEnv, @@ -654,7 +654,7 @@ static void videoEditor_clearSurface(JNIEnv* pEnv, } -static int videoEditor_renderPreviewFrame(JNIEnv* pEnv, +static jint videoEditor_renderPreviewFrame(JNIEnv* pEnv, jobject thiz, jobject mSurface, jlong fromMs, @@ -976,10 +976,10 @@ static int videoEditor_renderPreviewFrame(JNIEnv* pEnv, free(yuvPlane); } - return tnTimeMs; + return (jint)tnTimeMs; } -static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, +static jint videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, jobject thiz, jobject mSurface, jstring filePath, @@ -1033,7 +1033,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, /* get thumbnail*/ result = ThumbnailOpen(&tnContext,(const M4OSA_Char*)pString, M4OSA_TRUE); if (result != M4NO_ERROR || tnContext == M4OSA_NULL) { - return timeMs; + return (jint)timeMs; } framesizeYuv = ((frameWidth)*(frameHeight)*1.5); @@ -1046,7 +1046,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, ThumbnailClose(tnContext); pMessage = videoEditJava_getErrorName(M4ERR_ALLOC); jniThrowException(pEnv, "java/lang/RuntimeException", pMessage); - return timeMs; + return (jint)timeMs; } result = ThumbnailGetPixels16(tnContext, (M4OSA_Int16 *)pixelArray, @@ -1055,7 +1055,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, if (result != M4NO_ERROR) { free(pixelArray); ThumbnailClose(tnContext); - return fromMs; + return (jint)fromMs; } #ifdef DUMPTOFILESYSTEM @@ -1131,10 +1131,10 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, pEnv->ReleaseStringUTFChars(filePath, pString); } - return timeMs; + return (jint)timeMs; } -int videoEditor_generateAudioRawFile( JNIEnv* pEnv, +jint videoEditor_generateAudioRawFile( JNIEnv* pEnv, jobject thiz, jstring infilePath, jstring pcmfilePath) @@ -1178,7 +1178,7 @@ int videoEditor_generateAudioRawFile( JNIEnv* pEnv, pEnv->ReleaseStringUTFChars(pcmfilePath, pStringOutPCMFilePath); } - return result; + return (jint)result; } M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext, @@ -2182,7 +2182,7 @@ videoEditor_getProperties( return object; } -static int videoEditor_getPixels( +static jint videoEditor_getPixels( JNIEnv* env, jobject thiz, jstring path, @@ -2234,10 +2234,10 @@ static int videoEditor_getPixels( env->ReleaseStringUTFChars(path, pString); } - return timeMS; + return (jint)timeMS; } -static int videoEditor_getPixelsList( +static jint videoEditor_getPixelsList( JNIEnv* env, jobject thiz, jstring path, @@ -2257,7 +2257,7 @@ static int videoEditor_getPixelsList( const char *pString = env->GetStringUTFChars(path, NULL); if (pString == M4OSA_NULL) { jniThrowException(env, "java/lang/RuntimeException", "Input string null"); - return M4ERR_ALLOC; + return (jint)M4ERR_ALLOC; } err = ThumbnailOpen(&mContext,(const M4OSA_Char*)pString, M4OSA_FALSE); @@ -2266,7 +2266,7 @@ static int videoEditor_getPixelsList( if (pString != NULL) { env->ReleaseStringUTFChars(path, pString); } - return err; + return (jint)err; } jlong duration = (endTime - startTime); @@ -2307,7 +2307,7 @@ static int videoEditor_getPixelsList( "ThumbnailGetPixels32 failed"); } - return err; + return (jint)err; } static M4OSA_ERR @@ -2892,7 +2892,7 @@ M4OSA_ERR videoEditor_processClip( } /*+ PROGRESS CB */ -static int +static jint videoEditor_generateClip( JNIEnv* pEnv, jobject thiz, @@ -2934,7 +2934,7 @@ videoEditor_generateClip( } ALOGV("videoEditor_generateClip END 0x%x", (unsigned int) result); - return result; + return (jint)result; } static void @@ -3556,7 +3556,7 @@ M4OSA_ERR M4MA_generateAudioGraphFile(JNIEnv* pEnv, M4OSA_Char* pInputFileURL, return err; } -static int videoEditor_generateAudioWaveFormSync (JNIEnv* pEnv, jobject thiz, +static jint videoEditor_generateAudioWaveFormSync (JNIEnv* pEnv, jobject thiz, jstring pcmfilePath, jstring outGraphfilePath, jint frameDuration, jint channels, @@ -3619,7 +3619,7 @@ out: VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR", "videoEditor_generateAudioWaveFormSync pContext->bSkipState "); - return result; + return (jint)result; } /******** End Audio Graph *******/ diff --git a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp index 2604850..9cc55ab 100644 --- a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp +++ b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp @@ -34,11 +34,11 @@ static struct fields_t { } fields; static inline SoundPool* MusterSoundPool(JNIEnv *env, jobject thiz) { - return (SoundPool*)env->GetIntField(thiz, fields.mNativeContext); + return (SoundPool*)env->GetLongField(thiz, fields.mNativeContext); } // ---------------------------------------------------------------------------- -static int +static jint android_media_SoundPool_SoundPoolImpl_load_URL(JNIEnv *env, jobject thiz, jstring path, jint priority) { ALOGV("android_media_SoundPool_SoundPoolImpl_load_URL"); @@ -50,29 +50,29 @@ android_media_SoundPool_SoundPoolImpl_load_URL(JNIEnv *env, jobject thiz, jstrin const char* s = env->GetStringUTFChars(path, NULL); int id = ap->load(s, priority); env->ReleaseStringUTFChars(path, s); - return id; + return (jint) id; } -static int +static jint android_media_SoundPool_SoundPoolImpl_load_FD(JNIEnv *env, jobject thiz, jobject fileDescriptor, jlong offset, jlong length, jint priority) { ALOGV("android_media_SoundPool_SoundPoolImpl_load_FD"); SoundPool *ap = MusterSoundPool(env, thiz); if (ap == NULL) return 0; - return ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor), + return (jint) ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor), int64_t(offset), int64_t(length), int(priority)); } -static bool +static jboolean android_media_SoundPool_SoundPoolImpl_unload(JNIEnv *env, jobject thiz, jint sampleID) { ALOGV("android_media_SoundPool_SoundPoolImpl_unload\n"); SoundPool *ap = MusterSoundPool(env, thiz); - if (ap == NULL) return 0; - return ap->unload(sampleID); + if (ap == NULL) return JNI_FALSE; + return ap->unload(sampleID) ? JNI_TRUE : JNI_FALSE; } -static int +static jint android_media_SoundPool_SoundPoolImpl_play(JNIEnv *env, jobject thiz, jint sampleID, jfloat leftVolume, jfloat rightVolume, jint priority, jint loop, jfloat rate) @@ -80,7 +80,7 @@ android_media_SoundPool_SoundPoolImpl_play(JNIEnv *env, jobject thiz, jint sampl ALOGV("android_media_SoundPool_SoundPoolImpl_play\n"); SoundPool *ap = MusterSoundPool(env, thiz); if (ap == NULL) return 0; - return ap->play(sampleID, leftVolume, rightVolume, priority, loop, rate); + return (jint) ap->play(sampleID, leftVolume, rightVolume, priority, loop, rate); } static void @@ -130,22 +130,22 @@ android_media_SoundPool_SoundPoolImpl_stop(JNIEnv *env, jobject thiz, jint chann static void android_media_SoundPool_SoundPoolImpl_setVolume(JNIEnv *env, jobject thiz, jint channelID, - float leftVolume, float rightVolume) + jfloat leftVolume, jfloat rightVolume) { ALOGV("android_media_SoundPool_SoundPoolImpl_setVolume"); SoundPool *ap = MusterSoundPool(env, thiz); if (ap == NULL) return; - ap->setVolume(channelID, leftVolume, rightVolume); + ap->setVolume(channelID, (float) leftVolume, (float) rightVolume); } static void android_media_SoundPool_SoundPoolImpl_setPriority(JNIEnv *env, jobject thiz, jint channelID, - int priority) + jint priority) { ALOGV("android_media_SoundPool_SoundPoolImpl_setPriority"); SoundPool *ap = MusterSoundPool(env, thiz); if (ap == NULL) return; - ap->setPriority(channelID, priority); + ap->setPriority(channelID, (int) priority); } static void @@ -160,12 +160,12 @@ android_media_SoundPool_SoundPoolImpl_setLoop(JNIEnv *env, jobject thiz, jint ch static void android_media_SoundPool_SoundPoolImpl_setRate(JNIEnv *env, jobject thiz, jint channelID, - float rate) + jfloat rate) { ALOGV("android_media_SoundPool_SoundPoolImpl_setRate"); SoundPool *ap = MusterSoundPool(env, thiz); if (ap == NULL) return; - ap->setRate(channelID, rate); + ap->setRate(channelID, (float) rate); } static void android_media_callback(SoundPoolEvent event, SoundPool* soundPool, void* user) @@ -185,7 +185,7 @@ android_media_SoundPool_SoundPoolImpl_native_setup(JNIEnv *env, jobject thiz, jo } // save pointer to SoundPool C++ object in opaque field in Java object - env->SetIntField(thiz, fields.mNativeContext, (int)ap); + env->SetLongField(thiz, fields.mNativeContext, (jlong) ap); // set callback with weak reference jobject globalWeakRef = env->NewGlobalRef(weakRef); @@ -208,7 +208,7 @@ android_media_SoundPool_SoundPoolImpl_release(JNIEnv *env, jobject thiz) // clear callback and native context ap->setCallback(NULL, NULL); - env->SetIntField(thiz, fields.mNativeContext, 0); + env->SetLongField(thiz, fields.mNativeContext, 0); delete ap; } } @@ -299,7 +299,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) goto bail; } - fields.mNativeContext = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.mNativeContext = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.mNativeContext == NULL) { ALOGE("Can't find SoundPoolImpl.mNativeContext"); goto bail; diff --git a/media/mca/filterfw/jni/jni_gl_environment.cpp b/media/mca/filterfw/jni/jni_gl_environment.cpp index 9abf191..6da7b7c 100644 --- a/media/mca/filterfw/jni/jni_gl_environment.cpp +++ b/media/mca/filterfw/jni/jni_gl_environment.cpp @@ -119,12 +119,12 @@ static sp<MediaRecorder> getMediaRecorder(JNIEnv* env, jobject jmediarecorder) { return NULL; } - jfieldID context = env->GetFieldID(clazz, "mNativeContext", "I"); + jfieldID context = env->GetFieldID(clazz, "mNativeContext", "J"); if (context == NULL) { return NULL; } - MediaRecorder* const p = (MediaRecorder*)env->GetIntField(jmediarecorder, context); + MediaRecorder* const p = (MediaRecorder*)env->GetLongField(jmediarecorder, context); env->DeleteLocalRef(clazz); return sp<MediaRecorder>(p); } diff --git a/native/android/input.cpp b/native/android/input.cpp index e9d08b4..fc52138 100644 --- a/native/android/input.cpp +++ b/native/android/input.cpp @@ -273,7 +273,7 @@ float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, int ident, ALooper_callbackFunc callback, void* data) { InputQueue* iq = static_cast<InputQueue*>(queue); - Looper* l = static_cast<Looper*>(looper); + Looper* l = reinterpret_cast<Looper*>(looper); iq->attachLooper(l, ident, callback, data); } diff --git a/native/android/looper.cpp b/native/android/looper.cpp index 455e950..24cb234 100644 --- a/native/android/looper.cpp +++ b/native/android/looper.cpp @@ -25,20 +25,28 @@ using android::Looper; using android::sp; using android::IPCThreadState; +static inline Looper* ALooper_to_Looper(ALooper* alooper) { + return reinterpret_cast<Looper*>(alooper); +} + +static inline ALooper* Looper_to_ALooper(Looper* looper) { + return reinterpret_cast<ALooper*>(looper); +} + ALooper* ALooper_forThread() { - return Looper::getForThread().get(); + return Looper_to_ALooper(Looper::getForThread().get()); } ALooper* ALooper_prepare(int opts) { - return Looper::prepare(opts).get(); + return Looper_to_ALooper(Looper::prepare(opts).get()); } void ALooper_acquire(ALooper* looper) { - static_cast<Looper*>(looper)->incStrong((void*)ALooper_acquire); + ALooper_to_Looper(looper)->incStrong((void*)ALooper_acquire); } void ALooper_release(ALooper* looper) { - static_cast<Looper*>(looper)->decStrong((void*)ALooper_acquire); + ALooper_to_Looper(looper)->decStrong((void*)ALooper_acquire); } int ALooper_pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData) { @@ -64,14 +72,14 @@ int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outDat } void ALooper_wake(ALooper* looper) { - static_cast<Looper*>(looper)->wake(); + ALooper_to_Looper(looper)->wake(); } int ALooper_addFd(ALooper* looper, int fd, int ident, int events, ALooper_callbackFunc callback, void* data) { - return static_cast<Looper*>(looper)->addFd(fd, ident, events, callback, data); + return ALooper_to_Looper(looper)->addFd(fd, ident, events, callback, data); } int ALooper_removeFd(ALooper* looper, int fd) { - return static_cast<Looper*>(looper)->removeFd(fd); + return ALooper_to_Looper(looper)->removeFd(fd); } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java index 6e9e83e..d882eca 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java @@ -274,7 +274,7 @@ public class KeyguardSimPukView extends KeyguardAbsKeyInputView private boolean checkPuk() { // make sure the puk is at least 8 digits long. - if (mPasswordEntry.getText().length() >= 8) { + if (mPasswordEntry.getText().length() == 8) { mPukText = mPasswordEntry.getText().toString(); return true; } diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml index a1d8f22..da3ca0f 100644 --- a/packages/SettingsProvider/res/values/defaults.xml +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -173,4 +173,8 @@ 0 means no timeout; battery sounds will always play >0 is milliseconds of screen-off time after which battery sounds will not play --> <integer name="def_low_battery_sound_timeout">0</integer> + + <!-- Default for Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE --> + <integer name="def_wifi_scan_always_available">0</integer> + </resources> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 09c21f3..ed86f42 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -2274,6 +2274,9 @@ public class DatabaseHelper extends SQLiteOpenHelper { loadIntegerSetting(stmt, Settings.Global.LOW_BATTERY_SOUND_TIMEOUT, R.integer.def_low_battery_sound_timeout); + loadIntegerSetting(stmt, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, + R.integer.def_wifi_scan_always_available); + // --- New global settings start here } finally { if (stmt != null) stmt.close(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 839016d..9589e8b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -521,6 +521,11 @@ public class NavigationBarView extends LinearLayout { Log.d(TAG, "reorient(): rot=" + mDisplay.getRotation()); } + // swap to x coordinate if orientation is not in vertical + if (mDelegateHelper != null) { + mDelegateHelper.setSwapXY(!mVertical); + } + setNavigationIconHints(mNavigationIconHints, true); } diff --git a/services/java/com/android/server/AssetAtlasService.java b/services/java/com/android/server/AssetAtlasService.java index 26b4652..3fb006b 100644 --- a/services/java/com/android/server/AssetAtlasService.java +++ b/services/java/com/android/server/AssetAtlasService.java @@ -288,8 +288,8 @@ public class AssetAtlasService extends IAssetAtlas.Stub { } canvas.drawBitmap(bitmap, 0.0f, 0.0f, null); canvas.restore(); - - atlasMap[mapIndex++] = bitmap.mNativeBitmap; + // TODO: Change mAtlasMap to long[] to support 64-bit systems + atlasMap[mapIndex++] = (int) bitmap.mNativeBitmap; atlasMap[mapIndex++] = entry.x; atlasMap[mapIndex++] = entry.y; atlasMap[mapIndex++] = entry.rotated ? 1 : 0; diff --git a/services/java/com/android/server/LightsService.java b/services/java/com/android/server/LightsService.java index 89bfcac..a1d655b 100644 --- a/services/java/com/android/server/LightsService.java +++ b/services/java/com/android/server/LightsService.java @@ -201,13 +201,13 @@ public class LightsService { } }; - private static native int init_native(); - private static native void finalize_native(int ptr); + private static native long init_native(); + private static native void finalize_native(long ptr); - private static native void setLight_native(int ptr, int light, int color, int mode, + private static native void setLight_native(long ptr, int light, int color, int mode, int onMS, int offMS, int brightnessMode); private final Context mContext; - private int mNativePointer; + private long mNativePointer; } diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index e60231a..816ae69 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -877,7 +877,7 @@ class MountService extends IMountService.Stub /* Send the media unmounted event first */ if (DEBUG_EVENTS) Slog.i(TAG, "Sending unmounted event first"); updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTED); - sendStorageIntent(Environment.MEDIA_UNMOUNTED, volume, UserHandle.ALL); + sendStorageIntent(Intent.ACTION_MEDIA_UNMOUNTED, volume, UserHandle.ALL); if (DEBUG_EVENTS) Slog.i(TAG, "Sending media removed"); updatePublicVolumeState(volume, Environment.MEDIA_REMOVED); @@ -1164,6 +1164,7 @@ class MountService extends IMountService.Stub private void sendStorageIntent(String action, StorageVolume volume, UserHandle user) { final Intent intent = new Intent(action, Uri.parse("file://" + volume.getPath())); intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, volume); + intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); Slog.d(TAG, "sendStorageIntent " + intent + " to " + user); mContext.sendBroadcastAsUser(intent, user); } @@ -1411,7 +1412,7 @@ class MountService extends IMountService.Stub public void unregisterListener(IMountServiceListener listener) { synchronized (mListeners) { for(MountServiceBinderListener bl : mListeners) { - if (bl.mListener == listener) { + if (bl.mListener.asBinder() == listener.asBinder()) { mListeners.remove(mListeners.indexOf(bl)); listener.asBinder().unlinkToDeath(bl, 0); return; diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index a42cbcf..d895137 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -1133,7 +1133,7 @@ public class SystemServer { * running as root and we need to be the system user to set * the property. http://b/11463182 */ - SystemProperties.set("persist.sys.dalvik.vm.lib", + SystemProperties.set("persist.sys.dalvik.vm.lib.1", VMRuntime.getRuntime().vmLibrary()); if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) { diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index 47593f2..d651a62 100644..100755 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -1094,6 +1094,7 @@ final class ActivityStack { if (!r.visible) { if (DEBUG_VISBILITY) Slog.v( TAG, "Starting and making visible: " + r); + r.visible = true; mWindowManager.setAppVisibility(r.appToken, true); } if (r != starting) { @@ -1144,7 +1145,7 @@ final class ActivityStack { } else if (isActivityOverHome(r)) { if (DEBUG_VISBILITY) Slog.v(TAG, "Showing home: at " + r); showHomeBehindStack = true; - behindFullscreen = !isHomeStack(); + behindFullscreen = !isHomeStack() && r.frontOfTask && task.mOnTopOfHome; } } else { if (DEBUG_VISBILITY) Slog.v( @@ -2526,6 +2527,7 @@ final class ActivityStack { // activity into the stopped state and then finish it. if (localLOGV) Slog.v(TAG, "Enqueueing pending finish: " + r); mStackSupervisor.mFinishingActivities.add(r); + r.resumeKeyDispatchingLocked(); mStackSupervisor.getFocusedStack().resumeTopActivityLocked(null); return r; } diff --git a/services/java/com/android/server/am/CompatModePackages.java b/services/java/com/android/server/am/CompatModePackages.java index 59e6787..4d5577b 100644 --- a/services/java/com/android/server/am/CompatModePackages.java +++ b/services/java/com/android/server/am/CompatModePackages.java @@ -64,9 +64,14 @@ public final class CompatModePackages { XmlPullParser parser = Xml.newPullParser(); parser.setInput(fis, null); int eventType = parser.getEventType(); - while (eventType != XmlPullParser.START_TAG) { + while (eventType != XmlPullParser.START_TAG && + eventType != XmlPullParser.END_DOCUMENT) { eventType = parser.next(); } + if (eventType == XmlPullParser.END_DOCUMENT) { + return; + } + String tagName = parser.getName(); if ("compat-packages".equals(tagName)) { eventType = parser.next(); diff --git a/services/java/com/android/server/am/UsageStatsService.java b/services/java/com/android/server/am/UsageStatsService.java index e96d8b1..09cb344 100644 --- a/services/java/com/android/server/am/UsageStatsService.java +++ b/services/java/com/android/server/am/UsageStatsService.java @@ -396,9 +396,14 @@ public final class UsageStatsService extends IUsageStats.Stub { XmlPullParser parser = Xml.newPullParser(); parser.setInput(fis, null); int eventType = parser.getEventType(); - while (eventType != XmlPullParser.START_TAG) { + while (eventType != XmlPullParser.START_TAG && + eventType != XmlPullParser.END_DOCUMENT) { eventType = parser.next(); } + if (eventType == XmlPullParser.END_DOCUMENT) { + return; + } + String tagName = parser.getName(); if ("usage-history".equals(tagName)) { String pkg = null; diff --git a/services/java/com/android/server/content/SyncStorageEngine.java b/services/java/com/android/server/content/SyncStorageEngine.java index 5ebf9ea..124bc60 100644 --- a/services/java/com/android/server/content/SyncStorageEngine.java +++ b/services/java/com/android/server/content/SyncStorageEngine.java @@ -1697,9 +1697,15 @@ public class SyncStorageEngine extends Handler { XmlPullParser parser = Xml.newPullParser(); parser.setInput(fis, null); int eventType = parser.getEventType(); - while (eventType != XmlPullParser.START_TAG) { + while (eventType != XmlPullParser.START_TAG && + eventType != XmlPullParser.END_DOCUMENT) { eventType = parser.next(); } + if (eventType == XmlPullParser.END_DOCUMENT) { + Log.i(TAG, "No initial accounts"); + return; + } + String tagName = parser.getName(); if ("accounts".equals(tagName)) { String listen = parser.getAttributeValue(null, XML_ATTR_LISTEN_FOR_TICKLES); diff --git a/services/java/com/android/server/input/InputApplicationHandle.java b/services/java/com/android/server/input/InputApplicationHandle.java index 42c1052..3cf7edc 100644 --- a/services/java/com/android/server/input/InputApplicationHandle.java +++ b/services/java/com/android/server/input/InputApplicationHandle.java @@ -26,7 +26,7 @@ public final class InputApplicationHandle { // Pointer to the native input application handle. // This field is lazily initialized via JNI. @SuppressWarnings("unused") - private int ptr; + private long ptr; // The window manager's application window token. public final Object appWindowToken; diff --git a/services/java/com/android/server/input/InputManagerService.java b/services/java/com/android/server/input/InputManagerService.java index 3145805..9178664 100644 --- a/services/java/com/android/server/input/InputManagerService.java +++ b/services/java/com/android/server/input/InputManagerService.java @@ -107,7 +107,7 @@ public class InputManagerService extends IInputManager.Stub private static final int MSG_RELOAD_DEVICE_ALIASES = 5; // Pointer to native input manager service object. - private final int mPtr; + private final long mPtr; private final Context mContext; private final InputManagerHandler mHandler; @@ -146,46 +146,46 @@ public class InputManagerService extends IInputManager.Stub IInputFilter mInputFilter; // guarded by mInputFilterLock InputFilterHost mInputFilterHost; // guarded by mInputFilterLock - private static native int nativeInit(InputManagerService service, + private static native long nativeInit(InputManagerService service, Context context, MessageQueue messageQueue); - private static native void nativeStart(int ptr); - private static native void nativeSetDisplayViewport(int ptr, boolean external, + private static native void nativeStart(long ptr); + private static native void nativeSetDisplayViewport(long ptr, boolean external, int displayId, int rotation, int logicalLeft, int logicalTop, int logicalRight, int logicalBottom, int physicalLeft, int physicalTop, int physicalRight, int physicalBottom, int deviceWidth, int deviceHeight); - private static native int nativeGetScanCodeState(int ptr, + private static native int nativeGetScanCodeState(long ptr, int deviceId, int sourceMask, int scanCode); - private static native int nativeGetKeyCodeState(int ptr, + private static native int nativeGetKeyCodeState(long ptr, int deviceId, int sourceMask, int keyCode); - private static native int nativeGetSwitchState(int ptr, + private static native int nativeGetSwitchState(long ptr, int deviceId, int sourceMask, int sw); - private static native boolean nativeHasKeys(int ptr, + private static native boolean nativeHasKeys(long ptr, int deviceId, int sourceMask, int[] keyCodes, boolean[] keyExists); - private static native void nativeRegisterInputChannel(int ptr, InputChannel inputChannel, + private static native void nativeRegisterInputChannel(long ptr, InputChannel inputChannel, InputWindowHandle inputWindowHandle, boolean monitor); - private static native void nativeUnregisterInputChannel(int ptr, InputChannel inputChannel); - private static native void nativeSetInputFilterEnabled(int ptr, boolean enable); - private static native int nativeInjectInputEvent(int ptr, InputEvent event, + private static native void nativeUnregisterInputChannel(long ptr, InputChannel inputChannel); + private static native void nativeSetInputFilterEnabled(long ptr, boolean enable); + private static native int nativeInjectInputEvent(long ptr, InputEvent event, int injectorPid, int injectorUid, int syncMode, int timeoutMillis, int policyFlags); - private static native void nativeSetInputWindows(int ptr, InputWindowHandle[] windowHandles); - private static native void nativeSetInputDispatchMode(int ptr, boolean enabled, boolean frozen); - private static native void nativeSetSystemUiVisibility(int ptr, int visibility); - private static native void nativeSetFocusedApplication(int ptr, + private static native void nativeSetInputWindows(long ptr, InputWindowHandle[] windowHandles); + private static native void nativeSetInputDispatchMode(long ptr, boolean enabled, boolean frozen); + private static native void nativeSetSystemUiVisibility(long ptr, int visibility); + private static native void nativeSetFocusedApplication(long ptr, InputApplicationHandle application); - private static native boolean nativeTransferTouchFocus(int ptr, + private static native boolean nativeTransferTouchFocus(long ptr, InputChannel fromChannel, InputChannel toChannel); - private static native void nativeSetPointerSpeed(int ptr, int speed); - private static native void nativeSetShowTouches(int ptr, boolean enabled); - private static native void nativeVibrate(int ptr, int deviceId, long[] pattern, + private static native void nativeSetPointerSpeed(long ptr, int speed); + private static native void nativeSetShowTouches(long ptr, boolean enabled); + private static native void nativeVibrate(long ptr, int deviceId, long[] pattern, int repeat, int token); - private static native void nativeCancelVibrate(int ptr, int deviceId, int token); - private static native void nativeReloadKeyboardLayouts(int ptr); - private static native void nativeReloadDeviceAliases(int ptr); - private static native String nativeDump(int ptr); - private static native void nativeMonitor(int ptr); + private static native void nativeCancelVibrate(long ptr, int deviceId, int token); + private static native void nativeReloadKeyboardLayouts(long ptr); + private static native void nativeReloadDeviceAliases(long ptr); + private static native String nativeDump(long ptr); + private static native void nativeMonitor(long ptr); // Input event injection constants defined in InputDispatcher.h. private static final int INPUT_EVENT_INJECTION_SUCCEEDED = 0; diff --git a/services/java/com/android/server/input/InputWindowHandle.java b/services/java/com/android/server/input/InputWindowHandle.java index 9eb9a33..9a70f38 100644 --- a/services/java/com/android/server/input/InputWindowHandle.java +++ b/services/java/com/android/server/input/InputWindowHandle.java @@ -28,7 +28,7 @@ public final class InputWindowHandle { // Pointer to the native input window handle. // This field is lazily initialized via JNI. @SuppressWarnings("unused") - private int ptr; + private long ptr; // The input application handle. public final InputApplicationHandle inputApplicationHandle; diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index 5761f6c..7e244b9 100755 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -3657,6 +3657,12 @@ public class PackageManagerService extends IPackageManager.Stub { // An updated system app will not have the PARSE_IS_SYSTEM flag set // initially parseFlags |= PackageParser.PARSE_IS_SYSTEM; + + // An updated privileged app will not have the PARSE_IS_PRIVILEGED + // flag set initially + if ((updatedPkg.pkgFlags & ApplicationInfo.FLAG_PRIVILEGED) != 0) { + parseFlags |= PackageParser.PARSE_IS_PRIVILEGED; + } } // Verify certificates against what was last scanned if (!collectCertificatesLI(pp, ps, pkg, scanFile, parseFlags)) { diff --git a/services/java/com/android/server/usb/UsbHostManager.java b/services/java/com/android/server/usb/UsbHostManager.java index 10272f2..dfaad0b 100644 --- a/services/java/com/android/server/usb/UsbHostManager.java +++ b/services/java/com/android/server/usb/UsbHostManager.java @@ -96,6 +96,7 @@ public class UsbHostManager { /* Called from JNI in monitorUsbHostBus() to report new USB devices */ private void usbDeviceAdded(String deviceName, int vendorID, int productID, int deviceClass, int deviceSubclass, int deviceProtocol, + String manufacturerName, String productName, String serialNumber, /* array of quintuples containing id, class, subclass, protocol and number of endpoints for each interface */ int[] interfaceValues, @@ -151,7 +152,8 @@ public class UsbHostManager { } UsbDevice device = new UsbDevice(deviceName, vendorID, productID, - deviceClass, deviceSubclass, deviceProtocol, interfaces); + deviceClass, deviceSubclass, deviceProtocol, + manufacturerName, productName, serialNumber, interfaces); mDevices.put(deviceName, device); getCurrentSettings().deviceAttached(device); } diff --git a/services/java/com/android/server/usb/UsbSettingsManager.java b/services/java/com/android/server/usb/UsbSettingsManager.java index 9b5b312..ff4857b 100644 --- a/services/java/com/android/server/usb/UsbSettingsManager.java +++ b/services/java/com/android/server/usb/UsbSettingsManager.java @@ -108,13 +108,23 @@ class UsbSettingsManager { public final int mSubclass; // USB device protocol (or -1 for unspecified) public final int mProtocol; - - public DeviceFilter(int vid, int pid, int clasz, int subclass, int protocol) { + // USB device manufacturer name string (or null for unspecified) + public final String mManufacturerName; + // USB device product name string (or null for unspecified) + public final String mProductName; + // USB device serial number string (or null for unspecified) + public final String mSerialNumber; + + public DeviceFilter(int vid, int pid, int clasz, int subclass, int protocol, + String manufacturer, String product, String serialnum) { mVendorId = vid; mProductId = pid; mClass = clasz; mSubclass = subclass; mProtocol = protocol; + mManufacturerName = manufacturer; + mProductName = product; + mSerialNumber = serialnum; } public DeviceFilter(UsbDevice device) { @@ -123,6 +133,9 @@ class UsbSettingsManager { mClass = device.getDeviceClass(); mSubclass = device.getDeviceSubclass(); mProtocol = device.getDeviceProtocol(); + mManufacturerName = device.getManufacturerName(); + mProductName = device.getProductName(); + mSerialNumber = device.getSerialNumber(); } public static DeviceFilter read(XmlPullParser parser) @@ -132,27 +145,52 @@ class UsbSettingsManager { int deviceClass = -1; int deviceSubclass = -1; int deviceProtocol = -1; + String manufacturerName = null; + String productName = null; + String serialNumber = null; int count = parser.getAttributeCount(); for (int i = 0; i < count; i++) { String name = parser.getAttributeName(i); - // All attribute values are ints - int value = Integer.parseInt(parser.getAttributeValue(i)); - - if ("vendor-id".equals(name)) { - vendorId = value; - } else if ("product-id".equals(name)) { - productId = value; - } else if ("class".equals(name)) { - deviceClass = value; - } else if ("subclass".equals(name)) { - deviceSubclass = value; - } else if ("protocol".equals(name)) { - deviceProtocol = value; + String value = parser.getAttributeValue(i); + // Attribute values are ints or strings + if ("manufacturer-name".equals(name)) { + manufacturerName = value; + } else if ("product-name".equals(name)) { + productName = value; + } else if ("serial-number".equals(name)) { + serialNumber = value; + } else { + int intValue = -1; + int radix = 10; + if (value != null && value.length() > 2 && value.charAt(0) == '0' && + (value.charAt(1) == 'x' || value.charAt(1) == 'X')) { + // allow hex values starting with 0x or 0X + radix = 16; + value = value.substring(2); + } + try { + intValue = Integer.parseInt(value, radix); + } catch (NumberFormatException e) { + Slog.e(TAG, "invalid number for field " + name, e); + continue; + } + if ("vendor-id".equals(name)) { + vendorId = intValue; + } else if ("product-id".equals(name)) { + productId = intValue; + } else if ("class".equals(name)) { + deviceClass = intValue; + } else if ("subclass".equals(name)) { + deviceSubclass = intValue; + } else if ("protocol".equals(name)) { + deviceProtocol = intValue; + } } } return new DeviceFilter(vendorId, productId, - deviceClass, deviceSubclass, deviceProtocol); + deviceClass, deviceSubclass, deviceProtocol, + manufacturerName, productName, serialNumber); } public void write(XmlSerializer serializer) throws IOException { @@ -172,6 +210,15 @@ class UsbSettingsManager { if (mProtocol != -1) { serializer.attribute(null, "protocol", Integer.toString(mProtocol)); } + if (mManufacturerName != null) { + serializer.attribute(null, "manufacturer-name", mManufacturerName); + } + if (mProductName != null) { + serializer.attribute(null, "product-name", mProductName); + } + if (mSerialNumber != null) { + serializer.attribute(null, "serial-number", mSerialNumber); + } serializer.endTag(null, "usb-device"); } @@ -184,6 +231,15 @@ class UsbSettingsManager { public boolean matches(UsbDevice device) { if (mVendorId != -1 && device.getVendorId() != mVendorId) return false; if (mProductId != -1 && device.getProductId() != mProductId) return false; + if (mManufacturerName != null && device.getManufacturerName() == null) return false; + if (mProductName != null && device.getProductName() == null) return false; + if (mSerialNumber != null && device.getSerialNumber() == null) return false; + if (mManufacturerName != null && device.getManufacturerName() != null && + !mManufacturerName.equals(device.getManufacturerName())) return false; + if (mProductName != null && device.getProductName() != null && + !mProductName.equals(device.getProductName())) return false; + if (mSerialNumber != null && device.getSerialNumber() != null && + !mSerialNumber.equals(device.getSerialNumber())) return false; // check device class/subclass/protocol if (matches(device.getDeviceClass(), device.getDeviceSubclass(), @@ -203,6 +259,15 @@ class UsbSettingsManager { public boolean matches(DeviceFilter f) { if (mVendorId != -1 && f.mVendorId != mVendorId) return false; if (mProductId != -1 && f.mProductId != mProductId) return false; + if (f.mManufacturerName != null && mManufacturerName == null) return false; + if (f.mProductName != null && mProductName == null) return false; + if (f.mSerialNumber != null && mSerialNumber == null) return false; + if (mManufacturerName != null && f.mManufacturerName != null && + !mManufacturerName.equals(f.mManufacturerName)) return false; + if (mProductName != null && f.mProductName != null && + !mProductName.equals(f.mProductName)) return false; + if (mSerialNumber != null && f.mSerialNumber != null && + !mSerialNumber.equals(f.mSerialNumber)) return false; // check device class/subclass/protocol return matches(f.mClass, f.mSubclass, f.mProtocol); @@ -217,19 +282,67 @@ class UsbSettingsManager { } if (obj instanceof DeviceFilter) { DeviceFilter filter = (DeviceFilter)obj; - return (filter.mVendorId == mVendorId && - filter.mProductId == mProductId && - filter.mClass == mClass && - filter.mSubclass == mSubclass && - filter.mProtocol == mProtocol); + + if (filter.mVendorId != mVendorId || + filter.mProductId != mProductId || + filter.mClass != mClass || + filter.mSubclass != mSubclass || + filter.mProtocol != mProtocol) { + return(false); + } + if ((filter.mManufacturerName != null && + mManufacturerName == null) || + (filter.mManufacturerName == null && + mManufacturerName != null) || + (filter.mProductName != null && + mProductName == null) || + (filter.mProductName == null && + mProductName != null) || + (filter.mSerialNumber != null && + mSerialNumber == null) || + (filter.mSerialNumber == null && + mSerialNumber != null)) { + return(false); + } + if ((filter.mManufacturerName != null && + mManufacturerName != null && + !mManufacturerName.equals(filter.mManufacturerName)) || + (filter.mProductName != null && + mProductName != null && + !mProductName.equals(filter.mProductName)) || + (filter.mSerialNumber != null && + mSerialNumber != null && + !mSerialNumber.equals(filter.mSerialNumber))) { + return(false); + } + return(true); } if (obj instanceof UsbDevice) { UsbDevice device = (UsbDevice)obj; - return (device.getVendorId() == mVendorId && - device.getProductId() == mProductId && - device.getDeviceClass() == mClass && - device.getDeviceSubclass() == mSubclass && - device.getDeviceProtocol() == mProtocol); + if (device.getVendorId() != mVendorId || + device.getProductId() != mProductId || + device.getDeviceClass() != mClass || + device.getDeviceSubclass() != mSubclass || + device.getDeviceProtocol() != mProtocol) { + return(false); + } + if ((mManufacturerName != null && device.getManufacturerName() == null) || + (mManufacturerName == null && device.getManufacturerName() != null) || + (mProductName != null && device.getProductName() == null) || + (mProductName == null && device.getProductName() != null) || + (mSerialNumber != null && device.getSerialNumber() == null) || + (mSerialNumber == null && device.getSerialNumber() != null)) { + return(false); + } + if ((device.getManufacturerName() != null && + !mManufacturerName.equals(device.getManufacturerName())) || + (device.getProductName() != null && + !mProductName.equals(device.getProductName())) || + (device.getSerialNumber() != null && + !mSerialNumber.equals(device.getSerialNumber()))) { + return(false); + } + return true; } return false; } @@ -244,7 +357,9 @@ class UsbSettingsManager { public String toString() { return "DeviceFilter[mVendorId=" + mVendorId + ",mProductId=" + mProductId + ",mClass=" + mClass + ",mSubclass=" + mSubclass + - ",mProtocol=" + mProtocol + "]"; + ",mProtocol=" + mProtocol + ",mManufacturerName=" + mManufacturerName + + ",mProductName=" + mProductName + ",mSerialNumber=" + mSerialNumber + + "]"; } } diff --git a/services/jni/com_android_server_AssetAtlasService.cpp b/services/jni/com_android_server_AssetAtlasService.cpp index 885d21e..4a1b55d 100644 --- a/services/jni/com_android_server_AssetAtlasService.cpp +++ b/services/jni/com_android_server_AssetAtlasService.cpp @@ -54,11 +54,11 @@ static struct { jfieldID mNativeCanvas; } gCanvasFinalizerClassInfo; -#define GET_INT(object, field) \ - env->GetIntField(object, field) +#define GET_LONG(object, field) \ + env->GetLongField(object, field) -#define SET_INT(object, field, value) \ - env->SetIntField(object, field, value) +#define SET_LONG(object, field, value) \ + env->SetLongField(object, field, value) // ---------------------------------------------------------------------------- // Canvas management @@ -67,9 +67,9 @@ static struct { static inline void swapCanvasPtr(JNIEnv* env, jobject canvasObj, SkCanvas* newCanvas) { jobject canvasFinalizerObj = env->GetObjectField(canvasObj, gCanvasClassInfo.mFinalizer); SkCanvas* previousCanvas = reinterpret_cast<SkCanvas*>( - GET_INT(canvasObj, gCanvasClassInfo.mNativeCanvas)); - SET_INT(canvasObj, gCanvasClassInfo.mNativeCanvas, (int) newCanvas); - SET_INT(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (int) newCanvas); + GET_LONG(canvasObj, gCanvasClassInfo.mNativeCanvas)); + SET_LONG(canvasObj, gCanvasClassInfo.mNativeCanvas, (long) newCanvas); + SET_LONG(canvasFinalizerObj, gCanvasFinalizerClassInfo.mNativeCanvas, (long) newCanvas); SkSafeUnref(previousCanvas); } @@ -261,10 +261,10 @@ int register_android_server_AssetAtlasService(JNIEnv* env) { FIND_CLASS(clazz, "android/graphics/Canvas"); GET_FIELD_ID(gCanvasClassInfo.mFinalizer, clazz, "mFinalizer", "Landroid/graphics/Canvas$CanvasFinalizer;"); - GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I"); + GET_FIELD_ID(gCanvasClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J"); FIND_CLASS(clazz, "android/graphics/Canvas$CanvasFinalizer"); - GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "I"); + GET_FIELD_ID(gCanvasFinalizerClassInfo.mNativeCanvas, clazz, "mNativeCanvas", "J"); return jniRegisterNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); } diff --git a/services/jni/com_android_server_LightsService.cpp b/services/jni/com_android_server_LightsService.cpp index 401e1aa..69793f7 100644 --- a/services/jni/com_android_server_LightsService.cpp +++ b/services/jni/com_android_server_LightsService.cpp @@ -60,7 +60,7 @@ static light_device_t* get_device(hw_module_t* module, char const* name) } } -static jint init_native(JNIEnv *env, jobject clazz) +static jlong init_native(JNIEnv *env, jobject clazz) { int err; hw_module_t* module; @@ -90,10 +90,10 @@ static jint init_native(JNIEnv *env, jobject clazz) memset(devices, 0, sizeof(Devices)); } - return (jint)devices; + return (jlong)devices; } -static void finalize_native(JNIEnv *env, jobject clazz, int ptr) +static void finalize_native(JNIEnv *env, jobject clazz, jlong ptr) { Devices* devices = (Devices*)ptr; if (devices == NULL) { @@ -103,8 +103,8 @@ static void finalize_native(JNIEnv *env, jobject clazz, int ptr) free(devices); } -static void setLight_native(JNIEnv *env, jobject clazz, int ptr, - int light, int colorARGB, int flashMode, int onMS, int offMS, int brightnessMode) +static void setLight_native(JNIEnv *env, jobject clazz, jlong ptr, + jint light, jint colorARGB, jint flashMode, jint onMS, jint offMS, jint brightnessMode) { Devices* devices = (Devices*)ptr; light_state_t state; @@ -127,9 +127,9 @@ static void setLight_native(JNIEnv *env, jobject clazz, int ptr, } static JNINativeMethod method_table[] = { - { "init_native", "()I", (void*)init_native }, - { "finalize_native", "(I)V", (void*)finalize_native }, - { "setLight_native", "(IIIIIII)V", (void*)setLight_native }, + { "init_native", "()J", (void*)init_native }, + { "finalize_native", "(J)V", (void*)finalize_native }, + { "setLight_native", "(JIIIIII)V", (void*)setLight_native }, }; int register_android_server_LightsService(JNIEnv *env) diff --git a/services/jni/com_android_server_UsbHostManager.cpp b/services/jni/com_android_server_UsbHostManager.cpp index 639790b..f1fa6cf 100644 --- a/services/jni/com_android_server_UsbHostManager.cpp +++ b/services/jni/com_android_server_UsbHostManager.cpp @@ -73,6 +73,9 @@ static int usb_device_added(const char *devname, void* client_data) { uint8_t deviceClass = deviceDesc->bDeviceClass; uint8_t deviceSubClass = deviceDesc->bDeviceSubClass; uint8_t protocol = deviceDesc->bDeviceProtocol; + char *manufacturer = usb_device_get_manufacturer_name(device); + char *product = usb_device_get_product_name(device); + char *serial = usb_device_get_serial(device); usb_descriptor_iter_init(device, &iter); @@ -109,12 +112,19 @@ static int usb_device_added(const char *devname, void* client_data) { env->SetIntArrayRegion(endpointArray, 0, length, endpointValues.array()); jstring deviceName = env->NewStringUTF(devname); + jstring manufacturerName = env->NewStringUTF(manufacturer); + jstring productName = env->NewStringUTF(product); + jstring serialNumber = env->NewStringUTF(serial); env->CallVoidMethod(thiz, method_usbDeviceAdded, deviceName, vendorId, productId, deviceClass, - deviceSubClass, protocol, interfaceArray, endpointArray); + deviceSubClass, protocol, manufacturerName, + productName, serialNumber, interfaceArray, endpointArray); env->DeleteLocalRef(interfaceArray); env->DeleteLocalRef(endpointArray); + env->DeleteLocalRef(serialNumber); + env->DeleteLocalRef(productName); + env->DeleteLocalRef(manufacturerName); env->DeleteLocalRef(deviceName); checkAndClearExceptionFromCallback(env, __FUNCTION__); @@ -179,7 +189,7 @@ int register_android_server_UsbHostManager(JNIEnv *env) ALOGE("Can't find com/android/server/usb/UsbHostManager"); return -1; } - method_usbDeviceAdded = env->GetMethodID(clazz, "usbDeviceAdded", "(Ljava/lang/String;IIIII[I[I)V"); + method_usbDeviceAdded = env->GetMethodID(clazz, "usbDeviceAdded", "(Ljava/lang/String;IIIIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;[I[I)V"); if (method_usbDeviceAdded == NULL) { ALOGE("Can't find usbDeviceAdded"); return -1; diff --git a/services/jni/com_android_server_input_InputApplicationHandle.cpp b/services/jni/com_android_server_input_InputApplicationHandle.cpp index b9681ab..f943d16 100644 --- a/services/jni/com_android_server_input_InputApplicationHandle.cpp +++ b/services/jni/com_android_server_input_InputApplicationHandle.cpp @@ -90,7 +90,7 @@ sp<InputApplicationHandle> android_server_InputApplicationHandle_getHandle( AutoMutex _l(gHandleMutex); - int ptr = env->GetIntField(inputApplicationHandleObj, gInputApplicationHandleClassInfo.ptr); + jlong ptr = env->GetLongField(inputApplicationHandleObj, gInputApplicationHandleClassInfo.ptr); NativeInputApplicationHandle* handle; if (ptr) { handle = reinterpret_cast<NativeInputApplicationHandle*>(ptr); @@ -98,8 +98,8 @@ sp<InputApplicationHandle> android_server_InputApplicationHandle_getHandle( jweak objWeak = env->NewWeakGlobalRef(inputApplicationHandleObj); handle = new NativeInputApplicationHandle(objWeak); handle->incStrong((void*)android_server_InputApplicationHandle_getHandle); - env->SetIntField(inputApplicationHandleObj, gInputApplicationHandleClassInfo.ptr, - reinterpret_cast<int>(handle)); + env->SetLongField(inputApplicationHandleObj, gInputApplicationHandleClassInfo.ptr, + reinterpret_cast<jlong>(handle)); } return handle; } @@ -110,9 +110,9 @@ sp<InputApplicationHandle> android_server_InputApplicationHandle_getHandle( static void android_server_InputApplicationHandle_nativeDispose(JNIEnv* env, jobject obj) { AutoMutex _l(gHandleMutex); - int ptr = env->GetIntField(obj, gInputApplicationHandleClassInfo.ptr); + jlong ptr = env->GetLongField(obj, gInputApplicationHandleClassInfo.ptr); if (ptr) { - env->SetIntField(obj, gInputApplicationHandleClassInfo.ptr, 0); + env->SetLongField(obj, gInputApplicationHandleClassInfo.ptr, 0); NativeInputApplicationHandle* handle = reinterpret_cast<NativeInputApplicationHandle*>(ptr); handle->decStrong((void*)android_server_InputApplicationHandle_getHandle); @@ -143,7 +143,7 @@ int register_android_server_InputApplicationHandle(JNIEnv* env) { FIND_CLASS(clazz, "com/android/server/input/InputApplicationHandle"); GET_FIELD_ID(gInputApplicationHandleClassInfo.ptr, clazz, - "ptr", "I"); + "ptr", "J"); GET_FIELD_ID(gInputApplicationHandleClassInfo.name, clazz, "name", "Ljava/lang/String;"); diff --git a/services/jni/com_android_server_input_InputManagerService.cpp b/services/jni/com_android_server_input_InputManagerService.cpp index 4ab2086..10ad278 100644 --- a/services/jni/com_android_server_input_InputManagerService.cpp +++ b/services/jni/com_android_server_input_InputManagerService.cpp @@ -977,7 +977,7 @@ void NativeInputManager::loadPointerResources(PointerResources* outResources) { // ---------------------------------------------------------------------------- -static jint nativeInit(JNIEnv* env, jclass clazz, +static jlong nativeInit(JNIEnv* env, jclass clazz, jobject serviceObj, jobject contextObj, jobject messageQueueObj) { sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, messageQueueObj); if (messageQueue == NULL) { @@ -988,10 +988,10 @@ static jint nativeInit(JNIEnv* env, jclass clazz, NativeInputManager* im = new NativeInputManager(contextObj, serviceObj, messageQueue->getLooper()); im->incStrong(0); - return reinterpret_cast<jint>(im); + return reinterpret_cast<jlong>(im); } -static void nativeStart(JNIEnv* env, jclass clazz, jint ptr) { +static void nativeStart(JNIEnv* env, jclass clazz, jlong ptr) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); status_t result = im->getInputManager()->start(); @@ -1000,7 +1000,7 @@ static void nativeStart(JNIEnv* env, jclass clazz, jint ptr) { } } -static void nativeSetDisplayViewport(JNIEnv* env, jclass clazz, jint ptr, jboolean external, +static void nativeSetDisplayViewport(JNIEnv* env, jclass clazz, jlong ptr, jboolean external, jint displayId, jint orientation, jint logicalLeft, jint logicalTop, jint logicalRight, jint logicalBottom, jint physicalLeft, jint physicalTop, jint physicalRight, jint physicalBottom, @@ -1024,31 +1024,31 @@ static void nativeSetDisplayViewport(JNIEnv* env, jclass clazz, jint ptr, jboole } static jint nativeGetScanCodeState(JNIEnv* env, jclass clazz, - jint ptr, jint deviceId, jint sourceMask, jint scanCode) { + jlong ptr, jint deviceId, jint sourceMask, jint scanCode) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); - return im->getInputManager()->getReader()->getScanCodeState( + return (jint) im->getInputManager()->getReader()->getScanCodeState( deviceId, uint32_t(sourceMask), scanCode); } static jint nativeGetKeyCodeState(JNIEnv* env, jclass clazz, - jint ptr, jint deviceId, jint sourceMask, jint keyCode) { + jlong ptr, jint deviceId, jint sourceMask, jint keyCode) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); - return im->getInputManager()->getReader()->getKeyCodeState( + return (jint) im->getInputManager()->getReader()->getKeyCodeState( deviceId, uint32_t(sourceMask), keyCode); } static jint nativeGetSwitchState(JNIEnv* env, jclass clazz, - jint ptr, jint deviceId, jint sourceMask, jint sw) { + jlong ptr, jint deviceId, jint sourceMask, jint sw) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); - return im->getInputManager()->getReader()->getSwitchState( + return (jint) im->getInputManager()->getReader()->getSwitchState( deviceId, uint32_t(sourceMask), sw); } static jboolean nativeHasKeys(JNIEnv* env, jclass clazz, - jint ptr, jint deviceId, jint sourceMask, jintArray keyCodes, jbooleanArray outFlags) { + jlong ptr, jint deviceId, jint sourceMask, jintArray keyCodes, jbooleanArray outFlags) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); int32_t* codes = env->GetIntArrayElements(keyCodes, NULL); @@ -1056,8 +1056,12 @@ static jboolean nativeHasKeys(JNIEnv* env, jclass clazz, jsize numCodes = env->GetArrayLength(keyCodes); jboolean result; if (numCodes == env->GetArrayLength(keyCodes)) { - result = im->getInputManager()->getReader()->hasKeys( - deviceId, uint32_t(sourceMask), numCodes, codes, flags); + if (im->getInputManager()->getReader()->hasKeys( + deviceId, uint32_t(sourceMask), numCodes, codes, flags)) { + result = JNI_TRUE; + } else { + result = JNI_FALSE; + } } else { result = JNI_FALSE; } @@ -1082,7 +1086,7 @@ static void handleInputChannelDisposed(JNIEnv* env, } static void nativeRegisterInputChannel(JNIEnv* env, jclass clazz, - jint ptr, jobject inputChannelObj, jobject inputWindowHandleObj, jboolean monitor) { + jlong ptr, jobject inputChannelObj, jobject inputWindowHandleObj, jboolean monitor) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env, @@ -1111,7 +1115,7 @@ static void nativeRegisterInputChannel(JNIEnv* env, jclass clazz, } static void nativeUnregisterInputChannel(JNIEnv* env, jclass clazz, - jint ptr, jobject inputChannelObj) { + jlong ptr, jobject inputChannelObj) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env, @@ -1132,14 +1136,14 @@ static void nativeUnregisterInputChannel(JNIEnv* env, jclass clazz, } static void nativeSetInputFilterEnabled(JNIEnv* env, jclass clazz, - jint ptr, jboolean enabled) { + jlong ptr, jboolean enabled) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->getInputManager()->getDispatcher()->setInputFilterEnabled(enabled); } static jint nativeInjectInputEvent(JNIEnv* env, jclass clazz, - jint ptr, jobject inputEventObj, jint injectorPid, jint injectorUid, + jlong ptr, jobject inputEventObj, jint injectorPid, jint injectorUid, jint syncMode, jint timeoutMillis, jint policyFlags) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); @@ -1151,7 +1155,7 @@ static jint nativeInjectInputEvent(JNIEnv* env, jclass clazz, return INPUT_EVENT_INJECTION_FAILED; } - return im->getInputManager()->getDispatcher()->injectInputEvent( + return (jint) im->getInputManager()->getDispatcher()->injectInputEvent( & keyEvent, injectorPid, injectorUid, syncMode, timeoutMillis, uint32_t(policyFlags)); } else if (env->IsInstanceOf(inputEventObj, gMotionEventClassInfo.clazz)) { @@ -1161,7 +1165,7 @@ static jint nativeInjectInputEvent(JNIEnv* env, jclass clazz, return INPUT_EVENT_INJECTION_FAILED; } - return im->getInputManager()->getDispatcher()->injectInputEvent( + return (jint) im->getInputManager()->getDispatcher()->injectInputEvent( motionEvent, injectorPid, injectorUid, syncMode, timeoutMillis, uint32_t(policyFlags)); } else { @@ -1171,35 +1175,35 @@ static jint nativeInjectInputEvent(JNIEnv* env, jclass clazz, } static void nativeSetInputWindows(JNIEnv* env, jclass clazz, - jint ptr, jobjectArray windowHandleObjArray) { + jlong ptr, jobjectArray windowHandleObjArray) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->setInputWindows(env, windowHandleObjArray); } static void nativeSetFocusedApplication(JNIEnv* env, jclass clazz, - jint ptr, jobject applicationHandleObj) { + jlong ptr, jobject applicationHandleObj) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->setFocusedApplication(env, applicationHandleObj); } static void nativeSetInputDispatchMode(JNIEnv* env, - jclass clazz, jint ptr, jboolean enabled, jboolean frozen) { + jclass clazz, jlong ptr, jboolean enabled, jboolean frozen) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->setInputDispatchMode(enabled, frozen); } static void nativeSetSystemUiVisibility(JNIEnv* env, - jclass clazz, jint ptr, jint visibility) { + jclass clazz, jlong ptr, jint visibility) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->setSystemUiVisibility(visibility); } static jboolean nativeTransferTouchFocus(JNIEnv* env, - jclass clazz, jint ptr, jobject fromChannelObj, jobject toChannelObj) { + jclass clazz, jlong ptr, jobject fromChannelObj, jobject toChannelObj) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); sp<InputChannel> fromChannel = @@ -1208,29 +1212,33 @@ static jboolean nativeTransferTouchFocus(JNIEnv* env, android_view_InputChannel_getInputChannel(env, toChannelObj); if (fromChannel == NULL || toChannel == NULL) { - return false; + return JNI_FALSE; } - return im->getInputManager()->getDispatcher()-> - transferTouchFocus(fromChannel, toChannel); + if (im->getInputManager()->getDispatcher()-> + transferTouchFocus(fromChannel, toChannel)) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } static void nativeSetPointerSpeed(JNIEnv* env, - jclass clazz, jint ptr, jint speed) { + jclass clazz, jlong ptr, jint speed) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->setPointerSpeed(speed); } static void nativeSetShowTouches(JNIEnv* env, - jclass clazz, jint ptr, jboolean enabled) { + jclass clazz, jlong ptr, jboolean enabled) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->setShowTouches(enabled); } static void nativeVibrate(JNIEnv* env, - jclass clazz, jint ptr, jint deviceId, jlongArray patternObj, + jclass clazz, jlong ptr, jint deviceId, jlongArray patternObj, jint repeat, jint token) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); @@ -1247,7 +1255,7 @@ static void nativeVibrate(JNIEnv* env, nsecs_t pattern[patternSize]; for (size_t i = 0; i < patternSize; i++) { pattern[i] = max(jlong(0), min(patternMillis[i], - MAX_VIBRATE_PATTERN_DELAY_NSECS / 1000000LL)) * 1000000LL; + (jlong)(MAX_VIBRATE_PATTERN_DELAY_NSECS / 1000000LL))) * 1000000LL; } env->ReleasePrimitiveArrayCritical(patternObj, patternMillis, JNI_ABORT); @@ -1255,14 +1263,14 @@ static void nativeVibrate(JNIEnv* env, } static void nativeCancelVibrate(JNIEnv* env, - jclass clazz, jint ptr, jint deviceId, jint token) { + jclass clazz, jlong ptr, jint deviceId, jint token) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->getInputManager()->getReader()->cancelVibrate(deviceId, token); } static void nativeReloadKeyboardLayouts(JNIEnv* env, - jclass clazz, jint ptr) { + jclass clazz, jlong ptr) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->getInputManager()->getReader()->requestRefreshConfiguration( @@ -1270,14 +1278,14 @@ static void nativeReloadKeyboardLayouts(JNIEnv* env, } static void nativeReloadDeviceAliases(JNIEnv* env, - jclass clazz, jint ptr) { + jclass clazz, jlong ptr) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->getInputManager()->getReader()->requestRefreshConfiguration( InputReaderConfiguration::CHANGE_DEVICE_ALIAS); } -static jstring nativeDump(JNIEnv* env, jclass clazz, jint ptr) { +static jstring nativeDump(JNIEnv* env, jclass clazz, jlong ptr) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); String8 dump; @@ -1285,7 +1293,7 @@ static jstring nativeDump(JNIEnv* env, jclass clazz, jint ptr) { return env->NewStringUTF(dump.string()); } -static void nativeMonitor(JNIEnv* env, jclass clazz, jint ptr) { +static void nativeMonitor(JNIEnv* env, jclass clazz, jlong ptr) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->getInputManager()->getReader()->monitor(); @@ -1297,54 +1305,54 @@ static void nativeMonitor(JNIEnv* env, jclass clazz, jint ptr) { static JNINativeMethod gInputManagerMethods[] = { /* name, signature, funcPtr */ { "nativeInit", - "(Lcom/android/server/input/InputManagerService;Landroid/content/Context;Landroid/os/MessageQueue;)I", + "(Lcom/android/server/input/InputManagerService;Landroid/content/Context;Landroid/os/MessageQueue;)J", (void*) nativeInit }, - { "nativeStart", "(I)V", + { "nativeStart", "(J)V", (void*) nativeStart }, - { "nativeSetDisplayViewport", "(IZIIIIIIIIIIII)V", + { "nativeSetDisplayViewport", "(JZIIIIIIIIIIII)V", (void*) nativeSetDisplayViewport }, - { "nativeGetScanCodeState", "(IIII)I", + { "nativeGetScanCodeState", "(JIII)I", (void*) nativeGetScanCodeState }, - { "nativeGetKeyCodeState", "(IIII)I", + { "nativeGetKeyCodeState", "(JIII)I", (void*) nativeGetKeyCodeState }, - { "nativeGetSwitchState", "(IIII)I", + { "nativeGetSwitchState", "(JIII)I", (void*) nativeGetSwitchState }, - { "nativeHasKeys", "(III[I[Z)Z", + { "nativeHasKeys", "(JII[I[Z)Z", (void*) nativeHasKeys }, { "nativeRegisterInputChannel", - "(ILandroid/view/InputChannel;Lcom/android/server/input/InputWindowHandle;Z)V", + "(JLandroid/view/InputChannel;Lcom/android/server/input/InputWindowHandle;Z)V", (void*) nativeRegisterInputChannel }, - { "nativeUnregisterInputChannel", "(ILandroid/view/InputChannel;)V", + { "nativeUnregisterInputChannel", "(JLandroid/view/InputChannel;)V", (void*) nativeUnregisterInputChannel }, - { "nativeSetInputFilterEnabled", "(IZ)V", + { "nativeSetInputFilterEnabled", "(JZ)V", (void*) nativeSetInputFilterEnabled }, - { "nativeInjectInputEvent", "(ILandroid/view/InputEvent;IIIII)I", + { "nativeInjectInputEvent", "(JLandroid/view/InputEvent;IIIII)I", (void*) nativeInjectInputEvent }, - { "nativeSetInputWindows", "(I[Lcom/android/server/input/InputWindowHandle;)V", + { "nativeSetInputWindows", "(J[Lcom/android/server/input/InputWindowHandle;)V", (void*) nativeSetInputWindows }, - { "nativeSetFocusedApplication", "(ILcom/android/server/input/InputApplicationHandle;)V", + { "nativeSetFocusedApplication", "(JLcom/android/server/input/InputApplicationHandle;)V", (void*) nativeSetFocusedApplication }, - { "nativeSetInputDispatchMode", "(IZZ)V", + { "nativeSetInputDispatchMode", "(JZZ)V", (void*) nativeSetInputDispatchMode }, - { "nativeSetSystemUiVisibility", "(II)V", + { "nativeSetSystemUiVisibility", "(JI)V", (void*) nativeSetSystemUiVisibility }, - { "nativeTransferTouchFocus", "(ILandroid/view/InputChannel;Landroid/view/InputChannel;)Z", + { "nativeTransferTouchFocus", "(JLandroid/view/InputChannel;Landroid/view/InputChannel;)Z", (void*) nativeTransferTouchFocus }, - { "nativeSetPointerSpeed", "(II)V", + { "nativeSetPointerSpeed", "(JI)V", (void*) nativeSetPointerSpeed }, - { "nativeSetShowTouches", "(IZ)V", + { "nativeSetShowTouches", "(JZ)V", (void*) nativeSetShowTouches }, - { "nativeVibrate", "(II[JII)V", + { "nativeVibrate", "(JI[JII)V", (void*) nativeVibrate }, - { "nativeCancelVibrate", "(III)V", + { "nativeCancelVibrate", "(JII)V", (void*) nativeCancelVibrate }, - { "nativeReloadKeyboardLayouts", "(I)V", + { "nativeReloadKeyboardLayouts", "(J)V", (void*) nativeReloadKeyboardLayouts }, - { "nativeReloadDeviceAliases", "(I)V", + { "nativeReloadDeviceAliases", "(J)V", (void*) nativeReloadDeviceAliases }, - { "nativeDump", "(I)Ljava/lang/String;", + { "nativeDump", "(J)Ljava/lang/String;", (void*) nativeDump }, - { "nativeMonitor", "(I)V", + { "nativeMonitor", "(J)V", (void*) nativeMonitor }, }; diff --git a/services/jni/com_android_server_input_InputWindowHandle.cpp b/services/jni/com_android_server_input_InputWindowHandle.cpp index 82e3dad..b80183c 100644 --- a/services/jni/com_android_server_input_InputWindowHandle.cpp +++ b/services/jni/com_android_server_input_InputWindowHandle.cpp @@ -173,7 +173,7 @@ sp<NativeInputWindowHandle> android_server_InputWindowHandle_getHandle( AutoMutex _l(gHandleMutex); - int ptr = env->GetIntField(inputWindowHandleObj, gInputWindowHandleClassInfo.ptr); + jlong ptr = env->GetLongField(inputWindowHandleObj, gInputWindowHandleClassInfo.ptr); NativeInputWindowHandle* handle; if (ptr) { handle = reinterpret_cast<NativeInputWindowHandle*>(ptr); @@ -187,8 +187,8 @@ sp<NativeInputWindowHandle> android_server_InputWindowHandle_getHandle( jweak objWeak = env->NewWeakGlobalRef(inputWindowHandleObj); handle = new NativeInputWindowHandle(inputApplicationHandle, objWeak); handle->incStrong((void*)android_server_InputWindowHandle_getHandle); - env->SetIntField(inputWindowHandleObj, gInputWindowHandleClassInfo.ptr, - reinterpret_cast<int>(handle)); + env->SetLongField(inputWindowHandleObj, gInputWindowHandleClassInfo.ptr, + reinterpret_cast<jlong>(handle)); } return handle; } @@ -199,9 +199,9 @@ sp<NativeInputWindowHandle> android_server_InputWindowHandle_getHandle( static void android_server_InputWindowHandle_nativeDispose(JNIEnv* env, jobject obj) { AutoMutex _l(gHandleMutex); - int ptr = env->GetIntField(obj, gInputWindowHandleClassInfo.ptr); + jlong ptr = env->GetLongField(obj, gInputWindowHandleClassInfo.ptr); if (ptr) { - env->SetIntField(obj, gInputWindowHandleClassInfo.ptr, 0); + env->SetLongField(obj, gInputWindowHandleClassInfo.ptr, 0); NativeInputWindowHandle* handle = reinterpret_cast<NativeInputWindowHandle*>(ptr); handle->decStrong((void*)android_server_InputWindowHandle_getHandle); @@ -232,7 +232,7 @@ int register_android_server_InputWindowHandle(JNIEnv* env) { FIND_CLASS(clazz, "com/android/server/input/InputWindowHandle"); GET_FIELD_ID(gInputWindowHandleClassInfo.ptr, clazz, - "ptr", "I"); + "ptr", "J"); GET_FIELD_ID(gInputWindowHandleClassInfo.inputApplicationHandle, clazz, diff --git a/services/jni/com_android_server_location_GpsLocationProvider.cpp b/services/jni/com_android_server_location_GpsLocationProvider.cpp index aec254b..e9ba116 100644 --- a/services/jni/com_android_server_location_GpsLocationProvider.cpp +++ b/services/jni/com_android_server_location_GpsLocationProvider.cpp @@ -387,7 +387,11 @@ static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env, } static jboolean android_location_GpsLocationProvider_is_supported(JNIEnv* env, jclass clazz) { - return (sGpsInterface != NULL); + if (sGpsInterface != NULL) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject obj) @@ -398,7 +402,7 @@ static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject o // fail if the main interface fails to initialize if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0) - return false; + return JNI_FALSE; // if XTRA initialization fails we will disable it by sGpsXtraInterface to NULL, // but continue to allow the rest of the GPS interface to work. @@ -413,7 +417,7 @@ static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject o if (sGpsGeofencingInterface) sGpsGeofencingInterface->init(&sGpsGeofenceCallbacks); - return true; + return JNI_TRUE; } static void android_location_GpsLocationProvider_cleanup(JNIEnv* env, jobject obj) @@ -425,27 +429,42 @@ static void android_location_GpsLocationProvider_cleanup(JNIEnv* env, jobject ob static jboolean android_location_GpsLocationProvider_set_position_mode(JNIEnv* env, jobject obj, jint mode, jint recurrence, jint min_interval, jint preferred_accuracy, jint preferred_time) { - if (sGpsInterface) - return (sGpsInterface->set_position_mode(mode, recurrence, min_interval, preferred_accuracy, - preferred_time) == 0); + if (sGpsInterface) { + if (sGpsInterface->set_position_mode(mode, recurrence, min_interval, preferred_accuracy, + preferred_time) == 0) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } + } else - return false; + return JNI_FALSE; } static jboolean android_location_GpsLocationProvider_start(JNIEnv* env, jobject obj) { - if (sGpsInterface) - return (sGpsInterface->start() == 0); + if (sGpsInterface) { + if (sGpsInterface->start() == 0) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } + } else - return false; + return JNI_FALSE; } static jboolean android_location_GpsLocationProvider_stop(JNIEnv* env, jobject obj) { - if (sGpsInterface) - return (sGpsInterface->stop() == 0); + if (sGpsInterface) { + if (sGpsInterface->stop() == 0) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } + } else - return false; + return JNI_FALSE; } static void android_location_GpsLocationProvider_delete_aiding_data(JNIEnv* env, jobject obj, jint flags) @@ -482,7 +501,7 @@ static jint android_location_GpsLocationProvider_read_sv_status(JNIEnv* env, job env->ReleaseFloatArrayElements(elevArray, elev, 0); env->ReleaseFloatArrayElements(azumArray, azim, 0); env->ReleaseIntArrayElements(maskArray, mask, 0); - return num_svs; + return (jint) num_svs; } static void android_location_GpsLocationProvider_agps_set_reference_location_cellid(JNIEnv* env, @@ -552,7 +571,7 @@ static jint android_location_GpsLocationProvider_read_nmea(JNIEnv* env, jobject length = buffer_size; memcpy(nmea, sNmeaString, length); env->ReleasePrimitiveArrayCritical(nmeaArray, nmea, JNI_ABORT); - return length; + return (jint) length; } static void android_location_GpsLocationProvider_inject_time(JNIEnv* env, jobject obj, @@ -571,7 +590,11 @@ static void android_location_GpsLocationProvider_inject_location(JNIEnv* env, jo static jboolean android_location_GpsLocationProvider_supports_xtra(JNIEnv* env, jobject obj) { - return (sGpsXtraInterface != NULL); + if (sGpsXtraInterface != NULL) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } static void android_location_GpsLocationProvider_inject_xtra_data(JNIEnv* env, jobject obj, @@ -658,7 +681,7 @@ static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* e } static void android_location_GpsLocationProvider_update_network_state(JNIEnv* env, jobject obj, - jboolean connected, int type, jboolean roaming, jboolean available, jstring extraInfo, jstring apn) + jboolean connected, jint type, jboolean roaming, jboolean available, jstring extraInfo, jstring apn) { if (sAGpsRilInterface && sAGpsRilInterface->update_network_state) { diff --git a/telephony/java/android/telephony/CellSignalStrengthCdma.java b/telephony/java/android/telephony/CellSignalStrengthCdma.java index c945094..46d09f6 100644 --- a/telephony/java/android/telephony/CellSignalStrengthCdma.java +++ b/telephony/java/android/telephony/CellSignalStrengthCdma.java @@ -21,7 +21,7 @@ import android.os.Parcelable; import android.telephony.Rlog; /** - * LTE signal strength related information. + * Signal strength related information. */ public final class CellSignalStrengthCdma extends CellSignalStrength implements Parcelable { @@ -136,7 +136,7 @@ public final class CellSignalStrengthCdma extends CellSignalStrength implements } /** - * Get the LTE signal level as an asu value between 0..97, 99 is unknown + * Get the signal level as an asu value between 0..97, 99 is unknown * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69 */ @Override diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index 632efe0..8a6faed 100644 --- a/tools/aapt/Command.cpp +++ b/tools/aapt/Command.cpp @@ -505,7 +505,7 @@ int doDump(Bundle* bundle) const char* filename = bundle->getFileSpecEntry(1); AssetManager assets; - void* assetsCookie; + int32_t assetsCookie; if (!assets.addAssetPath(String8(filename), &assetsCookie)) { fprintf(stderr, "ERROR: dump failed because assets could not be loaded\n"); return 1; diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index f2e5254..6ced8b3 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -1342,7 +1342,7 @@ status_t compileResourceFile(Bundle* bundle, curType = string16; curFormat = ResTable_map::TYPE_REFERENCE|ResTable_map::TYPE_STRING; curIsStyled = true; - curIsPseudolocalizable = true; + curIsPseudolocalizable = (translatable != false16); } else if (strcmp16(block.getElementName(&len), drawable16.string()) == 0) { curTag = &drawable16; curType = drawable16; @@ -1408,15 +1408,24 @@ status_t compileResourceFile(Bundle* bundle, // Check whether these strings need valid formats. // (simplified form of what string16 does above) size_t n = block.getAttributeCount(); + + // Pseudolocalizable by default, unless this string array isn't + // translatable. + curIsPseudolocalizable = true; for (size_t i = 0; i < n; i++) { size_t length; const uint16_t* attr = block.getAttributeName(i, &length); - if (strcmp16(attr, translatable16.string()) == 0 - || strcmp16(attr, formatted16.string()) == 0) { + if (strcmp16(attr, translatable16.string()) == 0) { + const uint16_t* value = block.getAttributeStringValue(i, &length); + if (strcmp16(value, false16.string()) == 0) { + curIsPseudolocalizable = false; + } + } + + if (strcmp16(attr, formatted16.string()) == 0) { const uint16_t* value = block.getAttributeStringValue(i, &length); if (strcmp16(value, false16.string()) == 0) { curIsFormatted = false; - break; } } } @@ -1426,7 +1435,6 @@ status_t compileResourceFile(Bundle* bundle, curFormat = ResTable_map::TYPE_REFERENCE|ResTable_map::TYPE_STRING; curIsBag = true; curIsBagReplaceOnOverwrite = true; - curIsPseudolocalizable = true; } else if (strcmp16(block.getElementName(&len), integer_array16.string()) == 0) { curTag = &integer_array16; curType = array16; diff --git a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java index 7b444aa..224eac6 100644 --- a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java +++ b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java @@ -36,24 +36,24 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /*package*/ class PropertyValuesHolder_Delegate { @LayoutlibDelegate - /*package*/ static int nGetIntMethod(Class<?> targetClass, String methodName) { + /*package*/ static long nGetIntMethod(Class<?> targetClass, String methodName) { // return 0 to force PropertyValuesHolder to use Java reflection. return 0; } @LayoutlibDelegate - /*package*/ static int nGetFloatMethod(Class<?> targetClass, String methodName) { + /*package*/ static long nGetFloatMethod(Class<?> targetClass, String methodName) { // return 0 to force PropertyValuesHolder to use Java reflection. return 0; } @LayoutlibDelegate - /*package*/ static void nCallIntMethod(Object target, int methodID, int arg) { + /*package*/ static void nCallIntMethod(Object target, long methodID, int arg) { // do nothing } @LayoutlibDelegate - /*package*/ static void nCallFloatMethod(Object target, int methodID, float arg) { + /*package*/ static void nCallFloatMethod(Object target, long methodID, float arg) { // do nothing } } diff --git a/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java index a50a2bd..34ae825 100644 --- a/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java @@ -61,7 +61,7 @@ public class AvoidXfermode_Delegate extends Xfermode_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate(int opColor, int tolerance, int nativeMode) { + /*package*/ static long nativeCreate(int opColor, int tolerance, int nativeMode) { AvoidXfermode_Delegate newDelegate = new AvoidXfermode_Delegate(); return sManager.addNewDelegate(newDelegate); } diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java index 04ce9d0..f5c4677 100644 --- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java @@ -151,13 +151,13 @@ import java.util.Set; } @LayoutlibDelegate - /*package*/ static Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts) { + /*package*/ static Bitmap nativeDecodeAsset(long asset, Rect padding, Options opts) { opts.inBitmap = null; return null; } @LayoutlibDelegate - /*package*/ static Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts, + /*package*/ static Bitmap nativeDecodeAsset(long asset, Rect padding, Options opts, boolean applyScale, float scale) { opts.inBitmap = null; return null; diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java index 65a75b0..cdbbe46 100644 --- a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java @@ -65,7 +65,7 @@ public class BitmapShader_Delegate extends Shader_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate(int native_bitmap, int shaderTileModeX, + /*package*/ static long nativeCreate(long native_bitmap, int shaderTileModeX, int shaderTileModeY) { Bitmap_Delegate bitmap = Bitmap_Delegate.getDelegate(native_bitmap); if (bitmap == null) { @@ -80,7 +80,7 @@ public class BitmapShader_Delegate extends Shader_Delegate { } @LayoutlibDelegate - /*package*/ static int nativePostCreate(int native_shader, int native_bitmap, + /*package*/ static long nativePostCreate(long native_shader, long native_bitmap, int shaderTileModeX, int shaderTileModeY) { // pass, not needed. return 0; diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java index 93284db..f6abaa1 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java @@ -83,7 +83,7 @@ public final class Bitmap_Delegate { /** * Returns the native delegate associated to a given an int referencing a {@link Bitmap} object. */ - public static Bitmap_Delegate getDelegate(int native_bitmap) { + public static Bitmap_Delegate getDelegate(long native_bitmap) { return sManager.getDelegate(native_bitmap); } @@ -274,7 +274,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static Bitmap nativeCopy(int srcBitmap, int nativeConfig, boolean isMutable) { + /*package*/ static Bitmap nativeCopy(long srcBitmap, int nativeConfig, boolean isMutable) { Bitmap_Delegate srcBmpDelegate = sManager.getDelegate(srcBitmap); if (srcBmpDelegate == null) { return null; @@ -303,18 +303,18 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeDestructor(int nativeBitmap) { + /*package*/ static void nativeDestructor(long nativeBitmap) { sManager.removeJavaReferenceFor(nativeBitmap); } @LayoutlibDelegate - /*package*/ static boolean nativeRecycle(int nativeBitmap) { + /*package*/ static boolean nativeRecycle(long nativeBitmap) { sManager.removeJavaReferenceFor(nativeBitmap); return true; } @LayoutlibDelegate - /*package*/ static boolean nativeCompress(int nativeBitmap, int format, int quality, + /*package*/ static boolean nativeCompress(long nativeBitmap, int format, int quality, OutputStream stream, byte[] tempStorage) { Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "Bitmap.compress() is not supported", null /*data*/); @@ -322,7 +322,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeErase(int nativeBitmap, int color) { + /*package*/ static void nativeErase(long nativeBitmap, int color) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -342,7 +342,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static int nativeWidth(int nativeBitmap) { + /*package*/ static int nativeWidth(long nativeBitmap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -353,7 +353,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static int nativeHeight(int nativeBitmap) { + /*package*/ static int nativeHeight(long nativeBitmap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -364,7 +364,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static int nativeRowBytes(int nativeBitmap) { + /*package*/ static int nativeRowBytes(long nativeBitmap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -375,7 +375,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static int nativeConfig(int nativeBitmap) { + /*package*/ static int nativeConfig(long nativeBitmap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -386,7 +386,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeHasAlpha(int nativeBitmap) { + /*package*/ static boolean nativeHasAlpha(long nativeBitmap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -397,7 +397,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeHasMipMap(int nativeBitmap) { + /*package*/ static boolean nativeHasMipMap(long nativeBitmap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -408,7 +408,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static int nativeGetPixel(int nativeBitmap, int x, int y) { + /*package*/ static int nativeGetPixel(long nativeBitmap, int x, int y) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -419,7 +419,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeGetPixels(int nativeBitmap, int[] pixels, int offset, + /*package*/ static void nativeGetPixels(long nativeBitmap, int[] pixels, int offset, int stride, int x, int y, int width, int height) { Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -431,7 +431,7 @@ public final class Bitmap_Delegate { @LayoutlibDelegate - /*package*/ static void nativeSetPixel(int nativeBitmap, int x, int y, int color) { + /*package*/ static void nativeSetPixel(long nativeBitmap, int x, int y, int color) { Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { return; @@ -441,7 +441,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeSetPixels(int nativeBitmap, int[] colors, int offset, + /*package*/ static void nativeSetPixels(long nativeBitmap, int[] colors, int offset, int stride, int x, int y, int width, int height) { Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -452,21 +452,21 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeCopyPixelsToBuffer(int nativeBitmap, Buffer dst) { + /*package*/ static void nativeCopyPixelsToBuffer(long nativeBitmap, Buffer dst) { // FIXME implement native delegate Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Bitmap.copyPixelsToBuffer is not supported.", null, null /*data*/); } @LayoutlibDelegate - /*package*/ static void nativeCopyPixelsFromBuffer(int nb, Buffer src) { + /*package*/ static void nativeCopyPixelsFromBuffer(long nb, Buffer src) { // FIXME implement native delegate Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Bitmap.copyPixelsFromBuffer is not supported.", null, null /*data*/); } @LayoutlibDelegate - /*package*/ static int nativeGenerationId(int nativeBitmap) { + /*package*/ static int nativeGenerationId(long nativeBitmap) { Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { return 0; @@ -486,7 +486,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeWriteToParcel(int nativeBitmap, boolean isMutable, + /*package*/ static boolean nativeWriteToParcel(long nativeBitmap, boolean isMutable, int density, Parcel p) { // This is only called when sending a bitmap through aidl, so really this should not // be called. @@ -497,7 +497,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static Bitmap nativeExtractAlpha(int nativeBitmap, int nativePaint, + /*package*/ static Bitmap nativeExtractAlpha(long nativeBitmap, long nativePaint, int[] offsetXY) { Bitmap_Delegate bitmap = sManager.getDelegate(nativeBitmap); if (bitmap == null) { @@ -525,12 +525,12 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static void nativePrepareToDraw(int nativeBitmap) { + /*package*/ static void nativePrepareToDraw(long nativeBitmap) { // nothing to be done here. } @LayoutlibDelegate - /*package*/ static void nativeSetHasAlpha(int nativeBitmap, boolean hasAlpha) { + /*package*/ static void nativeSetHasAlpha(long nativeBitmap, boolean hasAlpha) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -541,7 +541,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeSetHasMipMap(int nativeBitmap, boolean hasMipMap) { + /*package*/ static void nativeSetHasMipMap(long nativeBitmap, boolean hasMipMap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -552,7 +552,7 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeSameAs(int nb0, int nb1) { + /*package*/ static boolean nativeSameAs(long nb0, long nb1) { Bitmap_Delegate delegate1 = sManager.getDelegate(nb0); if (delegate1 == null) { return false; @@ -605,7 +605,7 @@ public final class Bitmap_Delegate { private static Bitmap createBitmap(Bitmap_Delegate delegate, Set<BitmapCreateFlags> createFlags, int density) { // get its native_int - int nativeInt = sManager.addNewDelegate(delegate); + long nativeInt = sManager.addNewDelegate(delegate); int width = delegate.mImage.getWidth(); int height = delegate.mImage.getHeight(); diff --git a/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java index 4becba1..d2569c7 100644 --- a/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java @@ -55,7 +55,7 @@ public class BlurMaskFilter_Delegate extends MaskFilter_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeConstructor(float radius, int style) { + /*package*/ static long nativeConstructor(float radius, int style) { BlurMaskFilter_Delegate newDelegate = new BlurMaskFilter_Delegate(); return sManager.addNewDelegate(newDelegate); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java index 62b47bd..3111f0d 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java @@ -77,7 +77,7 @@ public final class Canvas_Delegate { /** * Returns the native delegate associated to a given an int referencing a {@link Canvas} object. */ - public static Canvas_Delegate getDelegate(int native_canvas) { + public static Canvas_Delegate getDelegate(long native_canvas) { return sManager.getDelegate(native_canvas); } @@ -310,7 +310,7 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static int initRaster(int nativeBitmapOrZero) { + /*package*/ static long initRaster(long nativeBitmapOrZero) { if (nativeBitmapOrZero > 0) { // get the Bitmap from the int Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(nativeBitmapOrZero); @@ -328,7 +328,7 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void copyNativeCanvasState(int srcCanvas, int dstCanvas) { + /*package*/ static void copyNativeCanvasState(long srcCanvas, long dstCanvas) { // get the delegate from the native int. Canvas_Delegate srcCanvasDelegate = sManager.getDelegate(srcCanvas); if (srcCanvasDelegate == null) { @@ -344,8 +344,8 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static int native_saveLayer(int nativeCanvas, RectF bounds, - int paint, int layerFlags) { + /*package*/ static long native_saveLayer(long nativeCanvas, RectF bounds, + long paint, int layerFlags) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); if (canvasDelegate == null) { @@ -361,9 +361,9 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static int native_saveLayer(int nativeCanvas, float l, + /*package*/ static long native_saveLayer(long nativeCanvas, float l, float t, float r, float b, - int paint, int layerFlags) { + long paint, int layerFlags) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); if (canvasDelegate == null) { @@ -380,7 +380,7 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static int native_saveLayerAlpha(int nativeCanvas, + /*package*/ static long native_saveLayerAlpha(long nativeCanvas, RectF bounds, int alpha, int layerFlags) { // get the delegate from the native int. @@ -393,7 +393,7 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static int native_saveLayerAlpha(int nativeCanvas, float l, + /*package*/ static long native_saveLayerAlpha(long nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags) { // get the delegate from the native int. @@ -407,7 +407,7 @@ public final class Canvas_Delegate { @LayoutlibDelegate - /*package*/ static void native_concat(int nCanvas, int nMatrix) { + /*package*/ static void native_concat(long nCanvas, long nMatrix) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas); if (canvasDelegate == null) { @@ -435,7 +435,7 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setMatrix(int nCanvas, int nMatrix) { + /*package*/ static void native_setMatrix(long nCanvas, long nMatrix) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas); if (canvasDelegate == null) { @@ -465,7 +465,7 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_clipRect(int nCanvas, + /*package*/ static boolean native_clipRect(long nCanvas, float left, float top, float right, float bottom, int regionOp) { @@ -480,8 +480,8 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_clipPath(int nativeCanvas, - int nativePath, + /*package*/ static boolean native_clipPath(long nativeCanvas, + long nativePath, int regionOp) { Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); if (canvasDelegate == null) { @@ -497,8 +497,8 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_clipRegion(int nativeCanvas, - int nativeRegion, + /*package*/ static boolean native_clipRegion(long nativeCanvas, + long nativeRegion, int regionOp) { Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); if (canvasDelegate == null) { @@ -514,7 +514,7 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeSetDrawFilter(int nativeCanvas, int nativeFilter) { + /*package*/ static void nativeSetDrawFilter(long nativeCanvas, long nativeFilter) { Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); if (canvasDelegate == null) { return; @@ -530,7 +530,7 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_getClipBounds(int nativeCanvas, + /*package*/ static boolean native_getClipBounds(long nativeCanvas, Rect bounds) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); @@ -551,7 +551,7 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_getCTM(int canvas, int matrix) { + /*package*/ static void native_getCTM(long canvas, long matrix) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(canvas); if (canvasDelegate == null) { @@ -568,21 +568,21 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_quickReject(int nativeCanvas, + /*package*/ static boolean native_quickReject(long nativeCanvas, RectF rect) { // FIXME properly implement quickReject return false; } @LayoutlibDelegate - /*package*/ static boolean native_quickReject(int nativeCanvas, - int path) { + /*package*/ static boolean native_quickReject(long nativeCanvas, + long path) { // FIXME properly implement quickReject return false; } @LayoutlibDelegate - /*package*/ static boolean native_quickReject(int nativeCanvas, + /*package*/ static boolean native_quickReject(long nativeCanvas, float left, float top, float right, float bottom) { // FIXME properly implement quickReject @@ -590,25 +590,25 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawRGB(int nativeCanvas, int r, int g, int b) { + /*package*/ static void native_drawRGB(long nativeCanvas, int r, int g, int b) { native_drawColor(nativeCanvas, 0xFF000000 | r << 16 | (g&0xFF) << 8 | (b&0xFF), PorterDuff.Mode.SRC_OVER.nativeInt); } @LayoutlibDelegate - /*package*/ static void native_drawARGB(int nativeCanvas, int a, int r, int g, int b) { + /*package*/ static void native_drawARGB(long nativeCanvas, int a, int r, int g, int b) { native_drawColor(nativeCanvas, a << 24 | (r&0xFF) << 16 | (g&0xFF) << 8 | (b&0xFF), PorterDuff.Mode.SRC_OVER.nativeInt); } @LayoutlibDelegate - /*package*/ static void native_drawColor(int nativeCanvas, int color) { + /*package*/ static void native_drawColor(long nativeCanvas, int color) { native_drawColor(nativeCanvas, color, PorterDuff.Mode.SRC_OVER.nativeInt); } @LayoutlibDelegate - /*package*/ static void native_drawColor(int nativeCanvas, final int color, final int mode) { + /*package*/ static void native_drawColor(long nativeCanvas, final int color, final int mode) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); if (canvasDelegate == null) { @@ -639,16 +639,16 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawPaint(int nativeCanvas, int paint) { + /*package*/ static void native_drawPaint(long nativeCanvas, long paint) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Canvas.drawPaint is not supported.", null, null /*data*/); } @LayoutlibDelegate - /*package*/ static void native_drawLine(int nativeCanvas, + /*package*/ static void native_drawLine(long nativeCanvas, final float startX, final float startY, final float stopX, final float stopY, - int paint) { + long paint) { draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/, new GcSnapshot.Drawable() { @@ -660,14 +660,13 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawRect(int nativeCanvas, RectF rect, - int paint) { + /*package*/ static void native_drawRect(long nativeCanvas, RectF rect, long paint) { native_drawRect(nativeCanvas, rect.left, rect.top, rect.right, rect.bottom, paint); } @LayoutlibDelegate - /*package*/ static void native_drawRect(int nativeCanvas, - final float left, final float top, final float right, final float bottom, int paint) { + /*package*/ static void native_drawRect(long nativeCanvas, + final float left, final float top, final float right, final float bottom, long paint) { draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/, new GcSnapshot.Drawable() { @@ -692,7 +691,7 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawOval(int nativeCanvas, final RectF oval, int paint) { + /*package*/ static void native_drawOval(long nativeCanvas, final RectF oval, long paint) { if (oval.right > oval.left && oval.bottom > oval.top) { draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/, new GcSnapshot.Drawable() { @@ -718,17 +717,17 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawCircle(int nativeCanvas, - float cx, float cy, float radius, int paint) { + /*package*/ static void native_drawCircle(long nativeCanvas, + float cx, float cy, float radius, long paint) { native_drawOval(nativeCanvas, new RectF(cx - radius, cy - radius, cx + radius, cy + radius), paint); } @LayoutlibDelegate - /*package*/ static void native_drawArc(int nativeCanvas, + /*package*/ static void native_drawArc(long nativeCanvas, final RectF oval, final float startAngle, final float sweep, - final boolean useCenter, int paint) { + final boolean useCenter, long paint) { if (oval.right > oval.left && oval.bottom > oval.top) { draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/, new GcSnapshot.Drawable() { @@ -757,8 +756,8 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawRoundRect(int nativeCanvas, - final RectF rect, final float rx, final float ry, int paint) { + /*package*/ static void native_drawRoundRect(long nativeCanvas, + final RectF rect, final float rx, final float ry, long paint) { draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/, new GcSnapshot.Drawable() { @@ -787,7 +786,7 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawPath(int nativeCanvas, int path, int paint) { + /*package*/ static void native_drawPath(long nativeCanvas, long path, long paint) { final Path_Delegate pathDelegate = Path_Delegate.getDelegate(path); if (pathDelegate == null) { return; @@ -814,9 +813,9 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawBitmap(Canvas thisCanvas, int nativeCanvas, int bitmap, + /*package*/ static void native_drawBitmap(Canvas thisCanvas, long nativeCanvas, long bitmap, float left, float top, - int nativePaintOrZero, + long nativePaintOrZero, int canvasDensity, int screenDensity, int bitmapDensity) { @@ -836,9 +835,9 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawBitmap(Canvas thisCanvas, int nativeCanvas, int bitmap, + /*package*/ static void native_drawBitmap(Canvas thisCanvas, long nativeCanvas, long bitmap, Rect src, RectF dst, - int nativePaintOrZero, + long nativePaintOrZero, int screenDensity, int bitmapDensity) { // get the delegate from the native int. @@ -861,9 +860,9 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawBitmap(int nativeCanvas, int bitmap, + /*package*/ static void native_drawBitmap(long nativeCanvas, long bitmap, Rect src, Rect dst, - int nativePaintOrZero, + long nativePaintOrZero, int screenDensity, int bitmapDensity) { // get the delegate from the native int. @@ -886,11 +885,11 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawBitmap(int nativeCanvas, int[] colors, + /*package*/ static void native_drawBitmap(long nativeCanvas, int[] colors, int offset, int stride, final float x, final float y, int width, int height, boolean hasAlpha, - int nativePaintOrZero) { + long nativePaintOrZero) { // create a temp BufferedImage containing the content. final BufferedImage image = new BufferedImage(width, height, @@ -912,8 +911,8 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeDrawBitmapMatrix(int nCanvas, int nBitmap, - int nMatrix, int nPaint) { + /*package*/ static void nativeDrawBitmapMatrix(long nCanvas, long nBitmap, + long nMatrix, long nPaint) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas); if (canvasDelegate == null) { @@ -953,30 +952,30 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeDrawBitmapMesh(int nCanvas, int nBitmap, + /*package*/ static void nativeDrawBitmapMesh(long nCanvas, long nBitmap, int meshWidth, int meshHeight, float[] verts, int vertOffset, int[] colors, - int colorOffset, int nPaint) { + int colorOffset, long nPaint) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Canvas.drawBitmapMesh is not supported.", null, null /*data*/); } @LayoutlibDelegate - /*package*/ static void nativeDrawVertices(int nCanvas, int mode, int n, + /*package*/ static void nativeDrawVertices(long nCanvas, int mode, int n, float[] verts, int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices, int indexOffset, - int indexCount, int nPaint) { + int indexCount, long nPaint) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Canvas.drawVertices is not supported.", null, null /*data*/); } @LayoutlibDelegate - /*package*/ static void native_drawText(int nativeCanvas, + /*package*/ static void native_drawText(long nativeCanvas, final char[] text, final int index, final int count, - final float startX, final float startY, final int flags, int paint) { + final float startX, final float startY, final int flags, long paint) { draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/, new GcSnapshot.Drawable() { @@ -1005,8 +1004,8 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawText(int nativeCanvas, String text, - int start, int end, float x, float y, final int flags, int paint) { + /*package*/ static void native_drawText(long nativeCanvas, String text, + int start, int end, float x, float y, final int flags, long paint) { int count = end - start; char[] buffer = TemporaryBuffer.obtain(count); TextUtils.getChars(text, start, end, buffer, 0); @@ -1015,9 +1014,9 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawTextRun(int nativeCanvas, String text, + /*package*/ static void native_drawTextRun(long nativeCanvas, String text, int start, int end, int contextStart, int contextEnd, - float x, float y, int flags, int paint) { + float x, float y, int flags, long paint) { int count = end - start; char[] buffer = TemporaryBuffer.obtain(count); TextUtils.getChars(text, start, end, buffer, 0); @@ -1026,56 +1025,56 @@ public final class Canvas_Delegate { } @LayoutlibDelegate - /*package*/ static void native_drawTextRun(int nativeCanvas, char[] text, + /*package*/ static void native_drawTextRun(long nativeCanvas, char[] text, int start, int count, int contextStart, int contextCount, - float x, float y, int flags, int paint) { + float x, float y, int flags, long paint) { native_drawText(nativeCanvas, text, start, count, x, y, flags, paint); } @LayoutlibDelegate - /*package*/ static void native_drawPosText(int nativeCanvas, + /*package*/ static void native_drawPosText(long nativeCanvas, char[] text, int index, int count, float[] pos, - int paint) { + long paint) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Canvas.drawPosText is not supported.", null, null /*data*/); } @LayoutlibDelegate - /*package*/ static void native_drawPosText(int nativeCanvas, + /*package*/ static void native_drawPosText(long nativeCanvas, String text, float[] pos, - int paint) { + long paint) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Canvas.drawPosText is not supported.", null, null /*data*/); } @LayoutlibDelegate - /*package*/ static void native_drawTextOnPath(int nativeCanvas, + /*package*/ static void native_drawTextOnPath(long nativeCanvas, char[] text, int index, - int count, int path, + int count, long path, float hOffset, float vOffset, int bidiFlags, - int paint) { + long paint) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Canvas.drawTextOnPath is not supported.", null, null /*data*/); } @LayoutlibDelegate - /*package*/ static void native_drawTextOnPath(int nativeCanvas, - String text, int path, + /*package*/ static void native_drawTextOnPath(long nativeCanvas, + String text, long path, float hOffset, float vOffset, - int flags, int paint) { + int flags, long paint) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Canvas.drawTextOnPath is not supported.", null, null /*data*/); } @LayoutlibDelegate - /*package*/ static void finalizer(int nativeCanvas) { + /*package*/ static void finalizer(long nativeCanvas) { // get the delegate from the native int so that it can be disposed. Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); if (canvasDelegate == null) { @@ -1095,7 +1094,7 @@ public final class Canvas_Delegate { * <p>Note that the drawable may actually be executed several times if there are * layers involved (see {@link #saveLayer(RectF, int, int)}. */ - private static void draw(int nCanvas, int nPaint, boolean compositeOnly, boolean forceSrcMode, + private static void draw(long nCanvas, long nPaint, boolean compositeOnly, boolean forceSrcMode, GcSnapshot.Drawable drawable) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas); @@ -1115,7 +1114,7 @@ public final class Canvas_Delegate { * <p>Note that the drawable may actually be executed several times if there are * layers involved (see {@link #saveLayer(RectF, int, int)}. */ - private static void draw(int nCanvas, GcSnapshot.Drawable drawable) { + private static void draw(long nCanvas, GcSnapshot.Drawable drawable) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas); if (canvasDelegate == null) { @@ -1193,9 +1192,9 @@ public final class Canvas_Delegate { } private static void drawBitmap( - int nativeCanvas, + long nativeCanvas, Bitmap_Delegate bitmap, - int nativePaintOrZero, + long nativePaintOrZero, final int sleft, final int stop, final int sright, final int sbottom, final int dleft, final int dtop, final int dright, final int dbottom) { // get the delegate from the native int. diff --git a/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java index e5a7ab6..d6b3da1 100644 --- a/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java @@ -46,7 +46,7 @@ public abstract class ColorFilter_Delegate { // ---- Public Helper methods ---- - public static ColorFilter_Delegate getDelegate(int nativeShader) { + public static ColorFilter_Delegate getDelegate(long nativeShader) { return sManager.getDelegate(nativeShader); } @@ -56,7 +56,7 @@ public abstract class ColorFilter_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static void finalizer(int native_instance, int nativeColorFilter) { + /*package*/ static void finalizer(long native_instance, long nativeColorFilter) { sManager.removeJavaReferenceFor(native_instance); } diff --git a/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java index 2de344b..ca8f450 100644 --- a/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java @@ -55,13 +55,13 @@ public class ColorMatrixColorFilter_Delegate extends ColorFilter_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeColorMatrixFilter(float[] array) { + /*package*/ static long nativeColorMatrixFilter(float[] array) { ColorMatrixColorFilter_Delegate newDelegate = new ColorMatrixColorFilter_Delegate(); return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate - /*package*/ static int nColorMatrixFilter(int nativeFilter, float[] array) { + /*package*/ static long nColorMatrixFilter(long nativeFilter, float[] array) { // pass return 0; } diff --git a/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java index 7c04a87..bc3df7d 100644 --- a/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java @@ -62,7 +62,7 @@ public class ComposePathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate(int outerpe, int innerpe) { + /*package*/ static long nativeCreate(long outerpe, long innerpe) { ComposePathEffect_Delegate newDelegate = new ComposePathEffect_Delegate(); return sManager.addNewDelegate(newDelegate); } diff --git a/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java index f6e1d00..fae8aef 100644 --- a/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java @@ -63,15 +63,15 @@ public class ComposeShader_Delegate extends Shader_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate1(int native_shaderA, int native_shaderB, - int native_mode) { + /*package*/ static long nativeCreate1(long native_shaderA, long native_shaderB, + long native_mode) { // FIXME not supported yet. ComposeShader_Delegate newDelegate = new ComposeShader_Delegate(); return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate - /*package*/ static int nativeCreate2(int native_shaderA, int native_shaderB, + /*package*/ static long nativeCreate2(long native_shaderA, long native_shaderB, int porterDuffMode) { // FIXME not supported yet. ComposeShader_Delegate newDelegate = new ComposeShader_Delegate(); @@ -79,15 +79,15 @@ public class ComposeShader_Delegate extends Shader_Delegate { } @LayoutlibDelegate - /*package*/ static int nativePostCreate1(int native_shader, int native_skiaShaderA, - int native_skiaShaderB, int native_mode) { + /*package*/ static long nativePostCreate1(long native_shader, long native_skiaShaderA, + long native_skiaShaderB, long native_mode) { // pass, not needed. return 0; } @LayoutlibDelegate - /*package*/ static int nativePostCreate2(int native_shader, int native_skiaShaderA, - int native_skiaShaderB, int porterDuffMode) { + /*package*/ static long nativePostCreate2(long native_shader, long native_skiaShaderA, + long native_skiaShaderB, int porterDuffMode) { // pass, not needed. return 0; } diff --git a/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java index b0f8168..73745c3 100644 --- a/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java @@ -62,7 +62,7 @@ public class CornerPathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate(float radius) { + /*package*/ static long nativeCreate(float radius) { CornerPathEffect_Delegate newDelegate = new CornerPathEffect_Delegate(); return sManager.addNewDelegate(newDelegate); } diff --git a/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java index d97c2ec..881afde 100644 --- a/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java @@ -73,7 +73,7 @@ public final class DashPathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate(float intervals[], float phase) { + /*package*/ static long nativeCreate(float intervals[], float phase) { DashPathEffect_Delegate newDelegate = new DashPathEffect_Delegate(intervals, phase); return sManager.addNewDelegate(newDelegate); } diff --git a/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java index ec4a810..46109f3 100644 --- a/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java @@ -62,7 +62,7 @@ public class DiscretePathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate(float length, float deviation) { + /*package*/ static long nativeCreate(float length, float deviation) { DiscretePathEffect_Delegate newDelegate = new DiscretePathEffect_Delegate(); return sManager.addNewDelegate(newDelegate); } diff --git a/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java index 870c46b..2e10740 100644 --- a/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java @@ -46,7 +46,7 @@ public abstract class DrawFilter_Delegate { // ---- Public Helper methods ---- - public static DrawFilter_Delegate getDelegate(int nativeDrawFilter) { + public static DrawFilter_Delegate getDelegate(long nativeDrawFilter) { return sManager.getDelegate(nativeDrawFilter); } @@ -56,7 +56,7 @@ public abstract class DrawFilter_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static void nativeDestructor(int nativeDrawFilter) { + /*package*/ static void nativeDestructor(long nativeDrawFilter) { sManager.removeJavaReferenceFor(nativeDrawFilter); } diff --git a/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java index ebc1c1d..e5040cc 100644 --- a/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java @@ -55,7 +55,7 @@ public class EmbossMaskFilter_Delegate extends MaskFilter_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeConstructor(float[] direction, float ambient, + /*package*/ static long nativeConstructor(float[] direction, float ambient, float specular, float blurRadius) { EmbossMaskFilter_Delegate newDelegate = new EmbossMaskFilter_Delegate(); return sManager.addNewDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java index 51e0576..10cc572 100644 --- a/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java @@ -55,13 +55,13 @@ public class LayerRasterizer_Delegate extends Rasterizer_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeConstructor() { + /*package*/ static long nativeConstructor() { LayerRasterizer_Delegate newDelegate = new LayerRasterizer_Delegate(); return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate - /*package*/ static void nativeAddLayer(int native_layer, int native_paint, float dx, float dy) { + /*package*/ static void nativeAddLayer(long native_layer, long native_paint, float dx, float dy) { } diff --git a/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java index 0ee883d..defaac3 100644 --- a/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java @@ -55,13 +55,13 @@ public class LightingColorFilter_Delegate extends ColorFilter_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int native_CreateLightingFilter(int mul, int add) { + /*package*/ static long native_CreateLightingFilter(int mul, int add) { LightingColorFilter_Delegate newDelegate = new LightingColorFilter_Delegate(); return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate - /*package*/ static int nCreateLightingFilter(int nativeFilter, int mul, int add) { + /*package*/ static int nCreateLightingFilter(long nativeFilter, int mul, int add) { // pass return 0; } diff --git a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java index f117fca..ac77377 100644 --- a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java @@ -54,7 +54,7 @@ public final class LinearGradient_Delegate extends Gradient_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate1(LinearGradient thisGradient, + /*package*/ static long nativeCreate1(LinearGradient thisGradient, float x0, float y0, float x1, float y1, int colors[], float positions[], int tileMode) { LinearGradient_Delegate newDelegate = new LinearGradient_Delegate(x0, y0, x1, y1, @@ -63,7 +63,7 @@ public final class LinearGradient_Delegate extends Gradient_Delegate { } @LayoutlibDelegate - /*package*/ static int nativeCreate2(LinearGradient thisGradient, + /*package*/ static long nativeCreate2(LinearGradient thisGradient, float x0, float y0, float x1, float y1, int color0, int color1, int tileMode) { return nativeCreate1(thisGradient, @@ -72,16 +72,16 @@ public final class LinearGradient_Delegate extends Gradient_Delegate { } @LayoutlibDelegate - /*package*/ static int nativePostCreate1(LinearGradient thisGradient, - int native_shader, float x0, float y0, float x1, float y1, + /*package*/ static long nativePostCreate1(LinearGradient thisGradient, + long native_shader, float x0, float y0, float x1, float y1, int colors[], float positions[], int tileMode) { // nothing to be done here. return 0; } @LayoutlibDelegate - /*package*/ static int nativePostCreate2(LinearGradient thisGradient, - int native_shader, float x0, float y0, float x1, float y1, + /*package*/ static long nativePostCreate2(LinearGradient thisGradient, + long native_shader, float x0, float y0, float x1, float y1, int color0, int color1, int tileMode) { // nothing to be done here. return 0; diff --git a/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java index c2f27e4..e726c59 100644 --- a/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java @@ -46,7 +46,7 @@ public abstract class MaskFilter_Delegate { // ---- Public Helper methods ---- - public static MaskFilter_Delegate getDelegate(int nativeShader) { + public static MaskFilter_Delegate getDelegate(long nativeShader) { return sManager.getDelegate(nativeShader); } @@ -56,7 +56,7 @@ public abstract class MaskFilter_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static void nativeDestructor(int native_filter) { + /*package*/ static void nativeDestructor(long native_filter) { sManager.removeJavaReferenceFor(native_filter); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java index 5df2a21..ebfe9bc 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java @@ -53,7 +53,7 @@ public final class Matrix_Delegate { // ---- Public Helper methods ---- - public static Matrix_Delegate getDelegate(int native_instance) { + public static Matrix_Delegate getDelegate(long native_instance) { return sManager.getDelegate(native_instance); } @@ -174,7 +174,7 @@ public final class Matrix_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int native_create(int native_src_or_zero) { + /*package*/ static long native_create(long native_src_or_zero) { // create the delegate Matrix_Delegate newDelegate = new Matrix_Delegate(); @@ -193,7 +193,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_isIdentity(int native_object) { + /*package*/ static boolean native_isIdentity(long native_object) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -203,7 +203,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_rectStaysRect(int native_object) { + /*package*/ static boolean native_rectStaysRect(long native_object) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return true; @@ -213,7 +213,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_reset(int native_object) { + /*package*/ static void native_reset(long native_object) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return; @@ -223,7 +223,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_set(int native_object, int other) { + /*package*/ static void native_set(long native_object, long other) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return; @@ -238,7 +238,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setTranslate(int native_object, float dx, float dy) { + /*package*/ static void native_setTranslate(long native_object, float dx, float dy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return; @@ -248,7 +248,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setScale(int native_object, float sx, float sy, + /*package*/ static void native_setScale(long native_object, float sx, float sy, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -259,7 +259,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setScale(int native_object, float sx, float sy) { + /*package*/ static void native_setScale(long native_object, float sx, float sy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return; @@ -277,7 +277,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setRotate(int native_object, float degrees, float px, float py) { + /*package*/ static void native_setRotate(long native_object, float degrees, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return; @@ -287,7 +287,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setRotate(int native_object, float degrees) { + /*package*/ static void native_setRotate(long native_object, float degrees) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return; @@ -297,7 +297,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setSinCos(int native_object, float sinValue, float cosValue, + /*package*/ static void native_setSinCos(long native_object, float sinValue, float cosValue, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -316,7 +316,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setSinCos(int native_object, float sinValue, float cosValue) { + /*package*/ static void native_setSinCos(long native_object, float sinValue, float cosValue) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return; @@ -326,7 +326,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setSkew(int native_object, float kx, float ky, + /*package*/ static void native_setSkew(long native_object, float kx, float ky, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -337,7 +337,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setSkew(int native_object, float kx, float ky) { + /*package*/ static void native_setSkew(long native_object, float kx, float ky) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return; @@ -355,7 +355,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_setConcat(int native_object, int a, int b) { + /*package*/ static boolean native_setConcat(long native_object, long a, long b) { if (a == native_object) { return native_preConcat(native_object, b); } else if (b == native_object) { @@ -383,7 +383,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_preTranslate(int native_object, float dx, float dy) { + /*package*/ static boolean native_preTranslate(long native_object, float dx, float dy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -394,7 +394,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_preScale(int native_object, float sx, float sy, + /*package*/ static boolean native_preScale(long native_object, float sx, float sy, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -406,7 +406,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_preScale(int native_object, float sx, float sy) { + /*package*/ static boolean native_preScale(long native_object, float sx, float sy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -417,7 +417,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_preRotate(int native_object, float degrees, + /*package*/ static boolean native_preRotate(long native_object, float degrees, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -429,7 +429,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_preRotate(int native_object, float degrees) { + /*package*/ static boolean native_preRotate(long native_object, float degrees) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -444,7 +444,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_preSkew(int native_object, float kx, float ky, + /*package*/ static boolean native_preSkew(long native_object, float kx, float ky, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -456,7 +456,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_preSkew(int native_object, float kx, float ky) { + /*package*/ static boolean native_preSkew(long native_object, float kx, float ky) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -467,7 +467,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_preConcat(int native_object, int other_matrix) { + /*package*/ static boolean native_preConcat(long native_object, long other_matrix) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -483,7 +483,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_postTranslate(int native_object, float dx, float dy) { + /*package*/ static boolean native_postTranslate(long native_object, float dx, float dy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -494,7 +494,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_postScale(int native_object, float sx, float sy, + /*package*/ static boolean native_postScale(long native_object, float sx, float sy, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -506,7 +506,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_postScale(int native_object, float sx, float sy) { + /*package*/ static boolean native_postScale(long native_object, float sx, float sy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -517,7 +517,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_postRotate(int native_object, float degrees, + /*package*/ static boolean native_postRotate(long native_object, float degrees, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -529,7 +529,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_postRotate(int native_object, float degrees) { + /*package*/ static boolean native_postRotate(long native_object, float degrees) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -540,7 +540,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_postSkew(int native_object, float kx, float ky, + /*package*/ static boolean native_postSkew(long native_object, float kx, float ky, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -552,7 +552,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_postSkew(int native_object, float kx, float ky) { + /*package*/ static boolean native_postSkew(long native_object, float kx, float ky) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -563,7 +563,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_postConcat(int native_object, int other_matrix) { + /*package*/ static boolean native_postConcat(long native_object, long other_matrix) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -579,7 +579,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_setRectToRect(int native_object, RectF src, + /*package*/ static boolean native_setRectToRect(long native_object, RectF src, RectF dst, int stf) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -644,7 +644,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_setPolyToPoly(int native_object, float[] src, int srcIndex, + /*package*/ static boolean native_setPolyToPoly(long native_object, float[] src, int srcIndex, float[] dst, int dstIndex, int pointCount) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, @@ -654,7 +654,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_invert(int native_object, int inverse) { + /*package*/ static boolean native_invert(long native_object, long inverse) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -682,7 +682,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_mapPoints(int native_object, float[] dst, int dstIndex, + /*package*/ static void native_mapPoints(long native_object, float[] dst, int dstIndex, float[] src, int srcIndex, int ptCount, boolean isPts) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -697,7 +697,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_mapRect(int native_object, RectF dst, RectF src) { + /*package*/ static boolean native_mapRect(long native_object, RectF dst, RectF src) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return false; @@ -707,7 +707,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static float native_mapRadius(int native_object, float radius) { + /*package*/ static float native_mapRadius(long native_object, float radius) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return 0.f; @@ -723,7 +723,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_getValues(int native_object, float[] values) { + /*package*/ static void native_getValues(long native_object, float[] values) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return; @@ -733,7 +733,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setValues(int native_object, float[] values) { + /*package*/ static void native_setValues(long native_object, float[] values) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { return; @@ -743,7 +743,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_equals(int native_a, int native_b) { + /*package*/ static boolean native_equals(long native_a, long native_b) { Matrix_Delegate a = sManager.getDelegate(native_a); if (a == null) { return false; @@ -764,7 +764,7 @@ public final class Matrix_Delegate { } @LayoutlibDelegate - /*package*/ static void finalizer(int native_instance) { + /*package*/ static void finalizer(long native_instance) { sManager.removeJavaReferenceFor(native_instance); } diff --git a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java index fa68796..a5c52e5 100644 --- a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java @@ -158,7 +158,7 @@ public final class NinePatch_Delegate { } @LayoutlibDelegate - /*package*/ static int validateNinePatchChunk(int bitmap, byte[] chunk) { + /*package*/ static long validateNinePatchChunk(long bitmap, byte[] chunk) { // the default JNI implementation only checks that the byte[] has the same // size as the C struct it represent. Since we cannot do the same check (serialization // will return different size depending on content), we do nothing. @@ -167,13 +167,13 @@ public final class NinePatch_Delegate { return sManager.addNewDelegate(newDelegate); } - /*package*/ static void nativeFinalize(int chunk) { + /*package*/ static void nativeFinalize(long chunk) { sManager.removeJavaReferenceFor(chunk); } @LayoutlibDelegate - /*package*/ static void nativeDraw(int canvas_instance, RectF loc, int bitmap_instance, - int chunk, int paint_instance_or_null, int destDensity, int srcDensity) { + /*package*/ static void nativeDraw(long canvas_instance, RectF loc, long bitmap_instance, + long chunk, long paint_instance_or_null, int destDensity, int srcDensity) { draw(canvas_instance, (int) loc.left, (int) loc.top, (int) loc.width(), (int) loc.height(), bitmap_instance, chunk, paint_instance_or_null, @@ -181,8 +181,8 @@ public final class NinePatch_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeDraw(int canvas_instance, Rect loc, int bitmap_instance, - int chunk, int paint_instance_or_null, int destDensity, int srcDensity) { + /*package*/ static void nativeDraw(long canvas_instance, Rect loc, long bitmap_instance, + long chunk, long paint_instance_or_null, int destDensity, int srcDensity) { draw(canvas_instance, loc.left, loc.top, loc.width(), loc.height(), bitmap_instance, chunk, paint_instance_or_null, @@ -190,15 +190,15 @@ public final class NinePatch_Delegate { } @LayoutlibDelegate - /*package*/ static int nativeGetTransparentRegion(int bitmap, int chunk, Rect location) { + /*package*/ static long nativeGetTransparentRegion(long bitmap, long chunk, Rect location) { return 0; } // ---- Private Helper methods ---- - private static void draw(int canvas_instance, + private static void draw(long canvas_instance, final int left, final int top, final int right, final int bottom, - int bitmap_instance, int chunk, int paint_instance_or_null, + long bitmap_instance, long chunk, long paint_instance_or_null, final int destDensity, final int srcDensity) { // get the delegate from the native int. final Bitmap_Delegate bitmap_delegate = Bitmap_Delegate.getDelegate(bitmap_instance); diff --git a/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java index 71d346a..fa20746 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java @@ -55,7 +55,7 @@ public class PaintFlagsDrawFilter_Delegate extends DrawFilter_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeConstructor(int clearBits, int setBits) { + /*package*/ static long nativeConstructor(int clearBits, int setBits) { PaintFlagsDrawFilter_Delegate newDelegate = new PaintFlagsDrawFilter_Delegate(); return sManager.addNewDelegate(newDelegate); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java index 41953ed..ca8e8aa 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java @@ -96,7 +96,7 @@ public class Paint_Delegate { // ---- Public Helper methods ---- - public static Paint_Delegate getDelegate(int native_paint) { + public static Paint_Delegate getDelegate(long native_paint) { return sManager.getDelegate(native_paint); } @@ -640,13 +640,13 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_init() { + /*package*/ static long native_init() { Paint_Delegate newDelegate = new Paint_Delegate(); return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate - /*package*/ static int native_initWithPaint(int paint) { + /*package*/ static long native_initWithPaint(long paint) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(paint); if (delegate == null) { @@ -658,7 +658,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static void native_reset(int native_object) { + /*package*/ static void native_reset(long native_object) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -669,7 +669,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static void native_set(int native_dst, int native_src) { + /*package*/ static void native_set(long native_dst, long native_src) { // get the delegate from the native int. Paint_Delegate delegate_dst = sManager.getDelegate(native_dst); if (delegate_dst == null) { @@ -686,7 +686,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_getStyle(int native_object) { + /*package*/ static long native_getStyle(long native_object) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -697,7 +697,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setStyle(int native_object, int style) { + /*package*/ static void native_setStyle(long native_object, int style) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -708,7 +708,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_getStrokeCap(int native_object) { + /*package*/ static long native_getStrokeCap(long native_object) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -719,7 +719,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setStrokeCap(int native_object, int cap) { + /*package*/ static void native_setStrokeCap(long native_object, int cap) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -730,7 +730,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_getStrokeJoin(int native_object) { + /*package*/ static long native_getStrokeJoin(long native_object) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -741,7 +741,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setStrokeJoin(int native_object, int join) { + /*package*/ static void native_setStrokeJoin(long native_object, int join) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -752,7 +752,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_getFillPath(int native_object, int src, int dst) { + /*package*/ static boolean native_getFillPath(long native_object, long src, long dst) { Paint_Delegate paint = sManager.getDelegate(native_object); if (paint == null) { return false; @@ -778,7 +778,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_setShader(int native_object, int shader) { + /*package*/ static long native_setShader(long native_object, long shader) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -791,7 +791,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_setColorFilter(int native_object, int filter) { + /*package*/ static long native_setColorFilter(long native_object, long filter) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -810,7 +810,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_setXfermode(int native_object, int xfermode) { + /*package*/ static long native_setXfermode(long native_object, long xfermode) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -823,7 +823,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_setPathEffect(int native_object, int effect) { + /*package*/ static long native_setPathEffect(long native_object, long effect) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -836,7 +836,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_setMaskFilter(int native_object, int maskfilter) { + /*package*/ static long native_setMaskFilter(long native_object, long maskfilter) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -855,7 +855,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_setTypeface(int native_object, int typeface) { + /*package*/ static long native_setTypeface(long native_object, long typeface) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -868,7 +868,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_setRasterizer(int native_object, int rasterizer) { + /*package*/ static long native_setRasterizer(long native_object, long rasterizer) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -887,7 +887,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_getTextAlign(int native_object) { + /*package*/ static long native_getTextAlign(long native_object) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -898,7 +898,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setTextAlign(int native_object, int align) { + /*package*/ static void native_setTextAlign(long native_object, int align) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -909,7 +909,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setTextLocale(int native_object, String locale) { + /*package*/ static void native_setTextLocale(long native_object, String locale) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -920,7 +920,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_getTextWidths(int native_object, char[] text, int index, + /*package*/ static long native_getTextWidths(long native_object, char[] text, int index, int count, int bidiFlags, float[] widths) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -962,21 +962,21 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_getTextWidths(int native_object, String text, int start, + /*package*/ static long native_getTextWidths(long native_object, String text, int start, int end, int bidiFlags, float[] widths) { return native_getTextWidths(native_object, text.toCharArray(), start, end - start, bidiFlags, widths); } @LayoutlibDelegate - /* package */static int native_getTextGlyphs(int native_object, String text, int start, + /* package */static long native_getTextGlyphs(long native_object, String text, int start, int end, int contextStart, int contextEnd, int flags, char[] glyphs) { // FIXME return 0; } @LayoutlibDelegate - /*package*/ static float native_getTextRunAdvances(int native_object, + /*package*/ static float native_getTextRunAdvances(long native_object, char[] text, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex) { @@ -996,7 +996,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static float native_getTextRunAdvances(int native_object, + /*package*/ static float native_getTextRunAdvances(long native_object, String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex) { // FIXME: support contextStart and contextEnd @@ -1009,7 +1009,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_getTextRunCursor(Paint thisPaint, int native_object, char[] text, + /*package*/ static long native_getTextRunCursor(Paint thisPaint, long native_object, char[] text, int contextStart, int contextLength, int flags, int offset, int cursorOpt) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, @@ -1018,7 +1018,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static int native_getTextRunCursor(Paint thisPaint, int native_object, String text, + /*package*/ static long native_getTextRunCursor(Paint thisPaint, long native_object, String text, int contextStart, int contextEnd, int flags, int offset, int cursorOpt) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, @@ -1027,30 +1027,30 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static void native_getTextPath(int native_object, int bidiFlags, - char[] text, int index, int count, float x, float y, int path) { + /*package*/ static void native_getTextPath(long native_object, int bidiFlags, + char[] text, int index, int count, float x, float y, long path) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Paint.getTextPath is not supported.", null, null /*data*/); } @LayoutlibDelegate - /*package*/ static void native_getTextPath(int native_object, int bidiFlags, - String text, int start, int end, float x, float y, int path) { + /*package*/ static void native_getTextPath(long native_object, int bidiFlags, + String text, int start, int end, float x, float y, long path) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Paint.getTextPath is not supported.", null, null /*data*/); } @LayoutlibDelegate - /*package*/ static void nativeGetStringBounds(int nativePaint, String text, int start, + /*package*/ static void nativeGetStringBounds(long nativePaint, String text, int start, int end, int bidiFlags, Rect bounds) { nativeGetCharArrayBounds(nativePaint, text.toCharArray(), start, end - start, bidiFlags, bounds); } @LayoutlibDelegate - /*package*/ static void nativeGetCharArrayBounds(int nativePaint, char[] text, int index, + /*package*/ static void nativeGetCharArrayBounds(long nativePaint, char[] text, int index, int count, int bidiFlags, Rect bounds) { // get the delegate from the native int. @@ -1064,7 +1064,7 @@ public class Paint_Delegate { } @LayoutlibDelegate - /*package*/ static void finalizer(int nativePaint) { + /*package*/ static void finalizer(long nativePaint) { sManager.removeJavaReferenceFor(nativePaint); } diff --git a/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java index c448f0e..fd9ba62 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java @@ -62,7 +62,7 @@ public class PathDashPathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate(int native_path, float advance, float phase, + /*package*/ static long nativeCreate(long native_path, float advance, float phase, int native_style) { PathDashPathEffect_Delegate newDelegate = new PathDashPathEffect_Delegate(); return sManager.addNewDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java index bd2b6de..000481e 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java @@ -48,7 +48,7 @@ public abstract class PathEffect_Delegate { // ---- Public Helper methods ---- - public static PathEffect_Delegate getDelegate(int nativeShader) { + public static PathEffect_Delegate getDelegate(long nativeShader) { return sManager.getDelegate(nativeShader); } @@ -60,7 +60,7 @@ public abstract class PathEffect_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static void nativeDestructor(int native_patheffect) { + /*package*/ static void nativeDestructor(long native_patheffect) { sManager.removeJavaReferenceFor(native_patheffect); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java index 64f19d3..f3b56d9 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java @@ -63,7 +63,7 @@ public final class Path_Delegate { // ---- Public Helper methods ---- - public static Path_Delegate getDelegate(int nPath) { + public static Path_Delegate getDelegate(long nPath) { return sManager.getDelegate(nPath); } @@ -88,7 +88,7 @@ public final class Path_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int init1() { + /*package*/ static long init1() { // create the delegate Path_Delegate newDelegate = new Path_Delegate(); @@ -96,7 +96,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static int init2(int nPath) { + /*package*/ static long init2(long nPath) { // create the delegate Path_Delegate newDelegate = new Path_Delegate(); @@ -110,7 +110,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_reset(int nPath) { + /*package*/ static void native_reset(long nPath) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -120,14 +120,14 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_rewind(int nPath) { + /*package*/ static void native_rewind(long nPath) { // call out to reset since there's nothing to optimize in // terms of data structs. native_reset(nPath); } @LayoutlibDelegate - /*package*/ static void native_set(int native_dst, int native_src) { + /*package*/ static void native_set(long native_dst, long native_src) { Path_Delegate pathDstDelegate = sManager.getDelegate(native_dst); if (pathDstDelegate == null) { return; @@ -142,7 +142,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static int native_getFillType(int nPath) { + /*package*/ static long native_getFillType(long nPath) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return 0; @@ -152,7 +152,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_setFillType(int nPath, int ft) { + /*package*/ static void native_setFillType(long nPath, int ft) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -162,7 +162,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_isEmpty(int nPath) { + /*package*/ static boolean native_isEmpty(long nPath) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return true; @@ -172,7 +172,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static boolean native_isRect(int nPath, RectF rect) { + /*package*/ static boolean native_isRect(long nPath, RectF rect) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return false; @@ -192,7 +192,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_computeBounds(int nPath, RectF bounds) { + /*package*/ static void native_computeBounds(long nPath, RectF bounds) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -202,13 +202,13 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_incReserve(int nPath, int extraPtCount) { + /*package*/ static void native_incReserve(long nPath, int extraPtCount) { // since we use a java2D path, there's no way to pre-allocate new points, // so we do nothing. } @LayoutlibDelegate - /*package*/ static void native_moveTo(int nPath, float x, float y) { + /*package*/ static void native_moveTo(long nPath, float x, float y) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -218,7 +218,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_rMoveTo(int nPath, float dx, float dy) { + /*package*/ static void native_rMoveTo(long nPath, float dx, float dy) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -228,7 +228,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_lineTo(int nPath, float x, float y) { + /*package*/ static void native_lineTo(long nPath, float x, float y) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -238,7 +238,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_rLineTo(int nPath, float dx, float dy) { + /*package*/ static void native_rLineTo(long nPath, float dx, float dy) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -248,7 +248,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_quadTo(int nPath, float x1, float y1, float x2, float y2) { + /*package*/ static void native_quadTo(long nPath, float x1, float y1, float x2, float y2) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -258,7 +258,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_rQuadTo(int nPath, float dx1, float dy1, float dx2, float dy2) { + /*package*/ static void native_rQuadTo(long nPath, float dx1, float dy1, float dx2, float dy2) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -268,7 +268,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_cubicTo(int nPath, float x1, float y1, + /*package*/ static void native_cubicTo(long nPath, float x1, float y1, float x2, float y2, float x3, float y3) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -279,7 +279,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_rCubicTo(int nPath, float x1, float y1, + /*package*/ static void native_rCubicTo(long nPath, float x1, float y1, float x2, float y2, float x3, float y3) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -290,7 +290,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_arcTo(int nPath, RectF oval, + /*package*/ static void native_arcTo(long nPath, RectF oval, float startAngle, float sweepAngle, boolean forceMoveTo) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -301,7 +301,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_close(int nPath) { + /*package*/ static void native_close(long nPath) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -311,7 +311,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_addRect(int nPath, RectF rect, int dir) { + /*package*/ static void native_addRect(long nPath, RectF rect, int dir) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -321,7 +321,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_addRect(int nPath, + /*package*/ static void native_addRect(long nPath, float left, float top, float right, float bottom, int dir) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -332,7 +332,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_addOval(int nPath, RectF oval, int dir) { + /*package*/ static void native_addOval(long nPath, RectF oval, int dir) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -343,7 +343,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_addCircle(int nPath, float x, float y, float radius, int dir) { + /*package*/ static void native_addCircle(long nPath, float x, float y, float radius, int dir) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -355,7 +355,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_addArc(int nPath, RectF oval, + /*package*/ static void native_addArc(long nPath, RectF oval, float startAngle, float sweepAngle) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -370,7 +370,7 @@ public final class Path_Delegate { @LayoutlibDelegate /*package*/ static void native_addRoundRect( - int nPath, RectF rect, float rx, float ry, int dir) { + long nPath, RectF rect, float rx, float ry, int dir) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -382,7 +382,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_addRoundRect(int nPath, RectF rect, float[] radii, int dir) { + /*package*/ static void native_addRoundRect(long nPath, RectF rect, float[] radii, int dir) { // Java2D doesn't support different rounded corners in each corner, so just use the // first value. native_addRoundRect(nPath, rect, radii[0], radii[1], dir); @@ -401,17 +401,17 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_addPath(int nPath, int src, float dx, float dy) { + /*package*/ static void native_addPath(long nPath, int src, float dx, float dy) { addPath(nPath, src, AffineTransform.getTranslateInstance(dx, dy)); } @LayoutlibDelegate - /*package*/ static void native_addPath(int nPath, int src) { + /*package*/ static void native_addPath(long nPath, int src) { addPath(nPath, src, null /*transform*/); } @LayoutlibDelegate - /*package*/ static void native_addPath(int nPath, int src, int matrix) { + /*package*/ static void native_addPath(long nPath, int src, long matrix) { Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(matrix); if (matrixDelegate == null) { return; @@ -421,7 +421,7 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_offset(int nPath, float dx, float dy, int dst_path) { + /*package*/ static void native_offset(long nPath, float dx, float dy, long dst_path) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -434,12 +434,12 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_offset(int nPath, float dx, float dy) { + /*package*/ static void native_offset(long nPath, float dx, float dy) { native_offset(nPath, dx, dy, 0); } @LayoutlibDelegate - /*package*/ static void native_setLastPoint(int nPath, float dx, float dy) { + /*package*/ static void native_setLastPoint(long nPath, float dx, float dy) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -450,8 +450,8 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_transform(int nPath, int matrix, - int dst_path) { + /*package*/ static void native_transform(long nPath, long matrix, + long dst_path) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { return; @@ -469,12 +469,12 @@ public final class Path_Delegate { } @LayoutlibDelegate - /*package*/ static void native_transform(int nPath, int matrix) { + /*package*/ static void native_transform(long nPath, long matrix) { native_transform(nPath, matrix, 0); } @LayoutlibDelegate - /*package*/ static void finalizer(int nPath) { + /*package*/ static void finalizer(long nPath) { sManager.removeJavaReferenceFor(nPath); } @@ -522,7 +522,7 @@ public final class Path_Delegate { return null; } - private static void addPath(int destPath, int srcPath, AffineTransform transform) { + private static void addPath(long destPath, long srcPath, AffineTransform transform) { Path_Delegate destPathDelegate = sManager.getDelegate(destPath); if (destPathDelegate == null) { return; diff --git a/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java index 4ab044b..f27144f 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java @@ -61,7 +61,7 @@ public class PixelXorXfermode_Delegate extends Xfermode_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate(int opColor) { + /*package*/ static long nativeCreate(int opColor) { PixelXorXfermode_Delegate newDelegate = new PixelXorXfermode_Delegate(); return sManager.addNewDelegate(newDelegate); } diff --git a/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java index c45dbaa..6049919 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java @@ -55,13 +55,13 @@ public class PorterDuffColorFilter_Delegate extends ColorFilter_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int native_CreatePorterDuffFilter(int srcColor, int porterDuffMode) { + /*package*/ static long native_CreatePorterDuffFilter(int srcColor, int porterDuffMode) { PorterDuffColorFilter_Delegate newDelegate = new PorterDuffColorFilter_Delegate(); return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate - /*package*/ static int nCreatePorterDuffFilter(int nativeFilter, int srcColor, + /*package*/ static long nCreatePorterDuffFilter(long nativeFilter, int srcColor, int porterDuffMode) { // pass return 0; diff --git a/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java index 4301c1a..a89fd57 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java @@ -127,7 +127,7 @@ public class PorterDuffXfermode_Delegate extends Xfermode_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreateXfermode(int mode) { + /*package*/ static long nativeCreateXfermode(int mode) { PorterDuffXfermode_Delegate newDelegate = new PorterDuffXfermode_Delegate(mode); return sManager.addNewDelegate(newDelegate); } diff --git a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java index 3fe45fa..4f16dcf 100644 --- a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java @@ -54,7 +54,7 @@ public class RadialGradient_Delegate extends Gradient_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate1(float x, float y, float radius, + /*package*/ static long nativeCreate1(float x, float y, float radius, int colors[], float positions[], int tileMode) { RadialGradient_Delegate newDelegate = new RadialGradient_Delegate(x, y, radius, colors, positions, Shader_Delegate.getTileMode(tileMode)); @@ -62,21 +62,21 @@ public class RadialGradient_Delegate extends Gradient_Delegate { } @LayoutlibDelegate - /*package*/ static int nativeCreate2(float x, float y, float radius, + /*package*/ static long nativeCreate2(float x, float y, float radius, int color0, int color1, int tileMode) { return nativeCreate1(x, y, radius, new int[] { color0, color1 }, null /*positions*/, tileMode); } @LayoutlibDelegate - /*package*/ static int nativePostCreate1(int native_shader, float x, float y, float radius, + /*package*/ static long nativePostCreate1(long native_shader, float x, float y, float radius, int colors[], float positions[], int tileMode) { // nothing to be done here. return 0; } @LayoutlibDelegate - /*package*/ static int nativePostCreate2(int native_shader, float x, float y, float radius, + /*package*/ static long nativePostCreate2(long native_shader, float x, float y, float radius, int color0, int color1, int tileMode) { // nothing to be done here. return 0; diff --git a/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java index 2812b6b..a742840 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java @@ -46,7 +46,7 @@ public abstract class Rasterizer_Delegate { // ---- Public Helper methods ---- - public static Rasterizer_Delegate getDelegate(int nativeShader) { + public static Rasterizer_Delegate getDelegate(long nativeShader) { return sManager.getDelegate(nativeShader); } @@ -56,7 +56,7 @@ public abstract class Rasterizer_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static void finalizer(int native_instance) { + /*package*/ static void finalizer(long native_instance) { sManager.removeJavaReferenceFor(native_instance); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java index cb31b8f..ea23649 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java @@ -57,7 +57,7 @@ public class Region_Delegate { // ---- Public Helper methods ---- - public static Region_Delegate getDelegate(int nativeShader) { + public static Region_Delegate getDelegate(long nativeShader) { return sManager.getDelegate(nativeShader); } @@ -264,18 +264,18 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static int nativeConstructor() { + /*package*/ static long nativeConstructor() { Region_Delegate newDelegate = new Region_Delegate(); return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate - /*package*/ static void nativeDestructor(int native_region) { + /*package*/ static void nativeDestructor(long native_region) { sManager.removeJavaReferenceFor(native_region); } @LayoutlibDelegate - /*package*/ static boolean nativeSetRegion(int native_dst, int native_src) { + /*package*/ static boolean nativeSetRegion(long native_dst, long native_src) { Region_Delegate dstRegion = sManager.getDelegate(native_dst); if (dstRegion == null) { return true; @@ -293,7 +293,7 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeSetRect(int native_dst, + /*package*/ static boolean nativeSetRect(long native_dst, int left, int top, int right, int bottom) { Region_Delegate dstRegion = sManager.getDelegate(native_dst); if (dstRegion == null) { @@ -305,7 +305,7 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeSetPath(int native_dst, int native_path, int native_clip) { + /*package*/ static boolean nativeSetPath(long native_dst, long native_path, long native_clip) { Region_Delegate dstRegion = sManager.getDelegate(native_dst); if (dstRegion == null) { return true; @@ -327,7 +327,7 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeGetBounds(int native_region, Rect rect) { + /*package*/ static boolean nativeGetBounds(long native_region, Rect rect) { Region_Delegate region = sManager.getDelegate(native_region); if (region == null) { return true; @@ -347,7 +347,7 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeGetBoundaryPath(int native_region, int native_path) { + /*package*/ static boolean nativeGetBoundaryPath(long native_region, long native_path) { Region_Delegate region = sManager.getDelegate(native_region); if (region == null) { return false; @@ -368,7 +368,7 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeOp(int native_dst, + /*package*/ static boolean nativeOp(long native_dst, int left, int top, int right, int bottom, int op) { Region_Delegate region = sManager.getDelegate(native_dst); if (region == null) { @@ -387,7 +387,7 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeOp(int native_dst, Rect rect, int native_region, int op) { + /*package*/ static boolean nativeOp(long native_dst, Rect rect, long native_region, int op) { Region_Delegate region = sManager.getDelegate(native_dst); if (region == null) { return false; @@ -405,8 +405,8 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeOp(int native_dst, - int native_region1, int native_region2, int op) { + /*package*/ static boolean nativeOp(long native_dst, + long native_region1, long native_region2, int op) { Region_Delegate dstRegion = sManager.getDelegate(native_dst); if (dstRegion == null) { return true; @@ -434,7 +434,7 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static int nativeCreateFromParcel(Parcel p) { + /*package*/ static long nativeCreateFromParcel(Parcel p) { // This is only called by Region.CREATOR (Parcelable.Creator<Region>), which is only // used during aidl call so really this should not be called. Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, @@ -444,7 +444,7 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeWriteToParcel(int native_region, + /*package*/ static boolean nativeWriteToParcel(long native_region, Parcel p) { // This is only called when sending a region through aidl, so really this should not // be called. @@ -455,7 +455,7 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static boolean nativeEquals(int native_r1, int native_r2) { + /*package*/ static boolean nativeEquals(long native_r1, long native_r2) { Region_Delegate region1 = sManager.getDelegate(native_r1); if (region1 == null) { return false; @@ -470,7 +470,7 @@ public class Region_Delegate { } @LayoutlibDelegate - /*package*/ static String nativeToString(int native_region) { + /*package*/ static String nativeToString(long native_region) { Region_Delegate region = sManager.getDelegate(native_region); if (region == null) { return "not found"; diff --git a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java index 368c0384..70a0a43 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java @@ -49,7 +49,7 @@ public abstract class Shader_Delegate { // ---- Public Helper methods ---- - public static Shader_Delegate getDelegate(int nativeShader) { + public static Shader_Delegate getDelegate(long nativeShader) { return sManager.getDelegate(nativeShader); } @@ -76,13 +76,13 @@ public abstract class Shader_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static void nativeDestructor(int native_shader, int native_skiaShader) { + /*package*/ static void nativeDestructor(long native_shader, long native_skiaShader) { sManager.removeJavaReferenceFor(native_shader); } @LayoutlibDelegate - /*package*/ static void nativeSetLocalMatrix(int native_shader, int native_skiaShader, - int matrix_instance) { + /*package*/ static void nativeSetLocalMatrix(long native_shader, long native_skiaShader, + long matrix_instance) { // get the delegate from the native int. Shader_Delegate shaderDelegate = sManager.getDelegate(native_shader); if (shaderDelegate == null) { diff --git a/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java index 410df0c..6d2e9b4 100644 --- a/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java @@ -62,7 +62,7 @@ public class SumPathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate(int first, int second) { + /*package*/ static long nativeCreate(long first, long second) { SumPathEffect_Delegate newDelegate = new SumPathEffect_Delegate(); return sManager.addNewDelegate(newDelegate); } diff --git a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java index 13ae12e..f2b3e8d 100644 --- a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java @@ -52,25 +52,25 @@ public class SweepGradient_Delegate extends Gradient_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static int nativeCreate1(float x, float y, int colors[], float positions[]) { + /*package*/ static long nativeCreate1(float x, float y, int colors[], float positions[]) { SweepGradient_Delegate newDelegate = new SweepGradient_Delegate(x, y, colors, positions); return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate - /*package*/ static int nativeCreate2(float x, float y, int color0, int color1) { + /*package*/ static long nativeCreate2(float x, float y, int color0, int color1) { return nativeCreate1(x, y, new int[] { color0, color1 }, null /*positions*/); } @LayoutlibDelegate - /*package*/ static int nativePostCreate1(int native_shader, float cx, float cy, + /*package*/ static long nativePostCreate1(long native_shader, float cx, float cy, int[] colors, float[] positions) { // nothing to be done here. return 0; } @LayoutlibDelegate - /*package*/ static int nativePostCreate2(int native_shader, float cx, float cy, + /*package*/ static long nativePostCreate2(long native_shader, float cx, float cy, int color0, int color1) { // nothing to be done here. return 0; diff --git a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java index 8701cc8..a25fb59 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java @@ -75,7 +75,7 @@ public final class Typeface_Delegate { sPostInitDelegate.clear(); } - public static Typeface_Delegate getDelegate(int nativeTypeface) { + public static Typeface_Delegate getDelegate(long nativeTypeface) { return sManager.getDelegate(nativeTypeface); } @@ -83,7 +83,7 @@ public final class Typeface_Delegate { return getFonts(typeface.native_instance); } - public static List<Font> getFonts(int native_int) { + public static List<Font> getFonts(long native_int) { Typeface_Delegate delegate = sManager.getDelegate(native_int); if (delegate == null) { return null; @@ -99,7 +99,7 @@ public final class Typeface_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static synchronized int nativeCreate(String familyName, int style) { + /*package*/ static synchronized long nativeCreate(String familyName, int style) { if (familyName == null) { familyName = DEFAULT_FAMILY; } @@ -118,7 +118,7 @@ public final class Typeface_Delegate { } @LayoutlibDelegate - /*package*/ static synchronized int nativeCreateFromTypeface(int native_instance, int style) { + /*package*/ static synchronized long nativeCreateFromTypeface(long native_instance, int style) { Typeface_Delegate delegate = sManager.getDelegate(native_instance); if (delegate == null) { return 0; @@ -138,14 +138,14 @@ public final class Typeface_Delegate { } @LayoutlibDelegate - /*package*/ static synchronized int nativeCreateFromAsset(AssetManager mgr, String path) { + /*package*/ static synchronized long nativeCreateFromAsset(AssetManager mgr, String path) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Typeface.createFromAsset() is not supported.", null /*throwable*/, null /*data*/); return 0; } @LayoutlibDelegate - /*package*/ static synchronized int nativeCreateFromFile(String path) { + /*package*/ static synchronized long nativeCreateFromFile(String path) { if (path.startsWith(SYSTEM_FONTS) ) { String relativePath = path.substring(SYSTEM_FONTS.length()); File f = new File(sFontLoader.getOsFontsLocation(), relativePath); @@ -174,12 +174,12 @@ public final class Typeface_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeUnref(int native_instance) { + /*package*/ static void nativeUnref(long native_instance) { sManager.removeJavaReferenceFor(native_instance); } @LayoutlibDelegate - /*package*/ static int nativeGetStyle(int native_instance) { + /*package*/ static int nativeGetStyle(long native_instance) { Typeface_Delegate delegate = sManager.getDelegate(native_instance); if (delegate == null) { return 0; diff --git a/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java index 962d69c..94a6d76 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java @@ -48,7 +48,7 @@ public abstract class Xfermode_Delegate { // ---- Public Helper methods ---- - public static Xfermode_Delegate getDelegate(int native_instance) { + public static Xfermode_Delegate getDelegate(long native_instance) { return sManager.getDelegate(native_instance); } @@ -60,7 +60,7 @@ public abstract class Xfermode_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static void finalizer(int native_instance) { + /*package*/ static void finalizer(long native_instance) { sManager.removeJavaReferenceFor(native_instance); } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java index ae1217d..261cc98 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java @@ -94,7 +94,7 @@ public final class DelegateManager<T> { * @param native_object the native int. * @return the delegate or null if not found. */ - public T getDelegate(int native_object) { + public T getDelegate(long native_object) { if (native_object > 0) { T delegate = mDelegates.get(native_object); @@ -116,8 +116,8 @@ public final class DelegateManager<T> { * @param newDelegate the delegate to add * @return a unique native int to identify the delegate */ - public int addNewDelegate(T newDelegate) { - int native_object = ++mDelegateCounter; + public long addNewDelegate(T newDelegate) { + long native_object = ++mDelegateCounter; mDelegates.put(native_object, newDelegate); assert !mJavaReferences.contains(newDelegate); mJavaReferences.add(newDelegate); @@ -133,7 +133,7 @@ public final class DelegateManager<T> { * Removes the main reference on the given delegate. * @param native_object the native integer representing the delegate. */ - public void removeJavaReferenceFor(int native_object) { + public void removeJavaReferenceFor(long native_object) { T delegate = getDelegate(native_object); if (Debug.DEBUG) { diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java index 4d0c9ce..53e1640 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java @@ -30,13 +30,14 @@ import java.lang.ref.WeakReference; * * The code is taken from {@link SparseArray} directly and adapted to use weak references. * - * Because our usage means that we never actually call {@link #remove(int)} or {@link #delete(int)}, - * we must manually check if there are reclaimed references to trigger an internal compact step - * (which is normally only triggered when an item is manually removed). + * Because our usage means that we never actually call {@link #remove(long)} or + * {@link #delete(long)}, we must manually check if there are reclaimed references to + * trigger an internal compact step (which is normally only triggered when an item is manually + * removed). * - * SparseArrays map integers to Objects. Unlike a normal array of Objects, + * SparseArrays map integral values to Objects. Unlike a normal array of Objects, * there can be gaps in the indices. It is intended to be more efficient - * than using a HashMap to map Integers to Objects. + * than using a HashMap to map Integers (or Longs) to Objects. */ @SuppressWarnings("unchecked") public class SparseWeakArray<E> { @@ -58,9 +59,9 @@ public class SparseWeakArray<E> { * number of mappings. */ public SparseWeakArray(int initialCapacity) { - initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity); + initialCapacity = ArrayUtils.idealLongArraySize(initialCapacity); - mKeys = new int[initialCapacity]; + mKeys = new long[initialCapacity]; mValues = new WeakReference[initialCapacity]; mSize = 0; } @@ -69,7 +70,7 @@ public class SparseWeakArray<E> { * Gets the Object mapped from the specified key, or <code>null</code> * if no such mapping has been made. */ - public E get(int key) { + public E get(long key) { return get(key, null); } @@ -77,7 +78,7 @@ public class SparseWeakArray<E> { * Gets the Object mapped from the specified key, or the specified Object * if no such mapping has been made. */ - public E get(int key, E valueIfKeyNotFound) { + public E get(long key, E valueIfKeyNotFound) { int i = binarySearch(mKeys, 0, mSize, key); if (i < 0 || mValues[i] == DELETED || mValues[i].get() == null) { @@ -90,7 +91,7 @@ public class SparseWeakArray<E> { /** * Removes the mapping from the specified key, if there was any. */ - public void delete(int key) { + public void delete(long key) { int i = binarySearch(mKeys, 0, mSize, key); if (i >= 0) { @@ -102,9 +103,9 @@ public class SparseWeakArray<E> { } /** - * Alias for {@link #delete(int)}. + * Alias for {@link #delete(long)}. */ - public void remove(int key) { + public void remove(long key) { delete(key); } @@ -121,7 +122,7 @@ public class SparseWeakArray<E> { private void gc() { int n = mSize; int o = 0; - int[] keys = mKeys; + long[] keys = mKeys; WeakReference<?>[] values = mValues; for (int i = 0; i < n; i++) { @@ -142,9 +143,9 @@ public class SparseWeakArray<E> { mGarbage = false; mSize = o; - int newSize = ArrayUtils.idealIntArraySize(mSize); + int newSize = ArrayUtils.idealLongArraySize(mSize); if (newSize < mKeys.length) { - int[] nkeys = new int[newSize]; + long[] nkeys = new long[newSize]; WeakReference<?>[] nvalues = new WeakReference[newSize]; System.arraycopy(mKeys, 0, nkeys, 0, newSize); @@ -160,7 +161,7 @@ public class SparseWeakArray<E> { * replacing the previous mapping from the specified key if there * was one. */ - public void put(int key, E value) { + public void put(long key, E value) { int i = binarySearch(mKeys, 0, mSize, key); if (i >= 0) { @@ -182,9 +183,9 @@ public class SparseWeakArray<E> { } if (mSize >= mKeys.length) { - int n = ArrayUtils.idealIntArraySize(mSize + 1); + int n = ArrayUtils.idealLongArraySize(mSize + 1); - int[] nkeys = new int[n]; + long[] nkeys = new long[n]; WeakReference<?>[] nvalues = new WeakReference[n]; // Log.e("SparseArray", "grow " + mKeys.length + " to " + n); @@ -224,7 +225,7 @@ public class SparseWeakArray<E> { * the key from the <code>index</code>th key-value mapping that this * SparseArray stores. */ - public int keyAt(int index) { + public long keyAt(int index) { if (mGarbage) { gc(); } @@ -263,7 +264,7 @@ public class SparseWeakArray<E> { * specified key, or a negative number if the specified * key is not mapped. */ - public int indexOfKey(int key) { + public int indexOfKey(long key) { if (mGarbage) { gc(); } @@ -310,7 +311,7 @@ public class SparseWeakArray<E> { * Puts a key/value pair into the array, optimizing for the case where * the key is greater than all existing keys in the array. */ - public void append(int key, E value) { + public void append(long key, E value) { if (mSize != 0 && key <= mKeys[mSize - 1]) { put(key, value); return; @@ -322,9 +323,9 @@ public class SparseWeakArray<E> { int pos = mSize; if (pos >= mKeys.length) { - int n = ArrayUtils.idealIntArraySize(pos + 1); + int n = ArrayUtils.idealLongArraySize(pos + 1); - int[] nkeys = new int[n]; + long[] nkeys = new long[n]; WeakReference<?>[] nvalues = new WeakReference[n]; // Log.e("SparseArray", "grow " + mKeys.length + " to " + n); @@ -350,7 +351,7 @@ public class SparseWeakArray<E> { return false; } - private static int binarySearch(int[] a, int start, int len, int key) { + private static int binarySearch(long[] a, int start, int len, long key) { int high = start + len, low = start - 1, guess; while (high - low > 1) { @@ -370,7 +371,7 @@ public class SparseWeakArray<E> { return ~high; } - private int[] mKeys; + private long[] mKeys; private WeakReference<?>[] mValues; private int mSize; } |