AArch64: Make graphics classes 64-bit compatible

This a merger of two commits submitted to AOSP by
the following authors:

ashok.bhat@arm.com, david.butcher@arm.coma
craig.barber@arm.com, kevin.petit@arm.com and
marcus.oakland@arm.com

Due to the very large number of internal conflicts, I
have chosen to cherry-pick this change instead
of letting it merge through AOSP because the merge
conflict resolution would be very hard to review.

Commit messages below:

================================================
AArch64: Make graphics classes 64-bit compatible

Changes in this patch include

[x] Long is used to store native pointers as they can
    be 64-bit.

[x] Some minor changes have been done to conform with
    standard JNI practice (e.g. use of jint instead of int
    in JNI function prototypes)

[x] AssetAtlasManager is not completely 64-bit compatible
    yet. Specifically mAtlasMap member has to be converted
    to hold native pointer using long. Added a TODO to
    AssetAtlasManager.java to indicate the change required.

Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Craig Barber <craig.barber@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>

==================================================================

AArch64: Use long for pointers in graphics/Camera

For storing pointers, long is used in
android/graphics/Camera class, as native
pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use of
jint instead of int in JNI function prototypes)

Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>

===================================================================

Change-Id: Id5793fa0ebc17ee8b1eecf4b3f327977fdccff71
diff --git a/core/java/android/view/DisplayList.java b/core/java/android/view/DisplayList.java
index 8dd6a91..439fc6c 100644
--- a/core/java/android/view/DisplayList.java
+++ b/core/java/android/view/DisplayList.java
@@ -364,7 +364,7 @@
         return mValid && mFinalizer != null;
     }
 
-    int getNativeDisplayList() {
+    long getNativeDisplayList() {
         if (!mValid || mFinalizer == null) {
             throw new IllegalStateException("The display list is not valid.");
         }
@@ -1029,73 +1029,73 @@
     // Native methods
     ///////////////////////////////////////////////////////////////////////////
 
-    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);
 
     // Properties
 
-    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 nSetProjectToContainedVolume(int displayList, boolean shouldProject);
-    private static native void nSetIsContainedVolume(int displayList, boolean isContainedVolume);
-    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 nSetProjectToContainedVolume(long displayList, boolean shouldProject);
+    private static native void nSetIsContainedVolume(long displayList, boolean isContainedVolume);
+    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 nSetTranslationZ(int displayList, float translationZ);
-    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 nSetTranslationZ(long displayList, float translationZ);
+    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 translationZ,
             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 void nSetStaticMatrix(long displayList, long nativeMatrix);
+    private static native void nSetAnimationMatrix(long displayList, long 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 nGetTranslationZ(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 nOutput(int displayList);
+    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 nGetTranslationZ(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);
+    private static native void nOutput(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/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index 449318e..3384359 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -49,7 +49,7 @@
     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 @@
     /**
      * 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 @@
         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;
         }
 
@@ -175,26 +175,26 @@
         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
@@ -231,7 +231,7 @@
     /**
      * Returns the native OpenGLRenderer object.
      */
-    int getRenderer() {
+    long getRenderer() {
         return mRenderer;
     }
 
@@ -247,7 +247,7 @@
         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) {
@@ -259,8 +259,8 @@
         }
     }
 
-    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
@@ -268,7 +268,7 @@
         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
@@ -288,45 +288,45 @@
         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
@@ -400,11 +400,11 @@
     // 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
     public int drawDisplayList(DisplayList displayList, Rect dirty, int flags) {
@@ -412,7 +412,7 @@
                 dirty, flags);
     }
 
-    private static native int nDrawDisplayList(int renderer, int displayList,
+    private static native int nDrawDisplayList(long renderer, long displayList,
             Rect dirty, int flags);
 
     ///////////////////////////////////////////////////////////////////////////
@@ -426,7 +426,7 @@
         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);
@@ -436,8 +436,8 @@
         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
@@ -478,14 +478,14 @@
         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
@@ -498,7 +498,7 @@
         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
@@ -533,21 +533,21 @@
         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
@@ -572,35 +572,35 @@
         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
@@ -608,14 +608,14 @@
         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
@@ -631,7 +631,7 @@
         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) {
@@ -642,7 +642,7 @@
         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);
@@ -650,7 +650,7 @@
         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,
@@ -659,7 +659,7 @@
             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);
@@ -669,8 +669,8 @@
         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) {
@@ -681,7 +681,7 @@
         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,
@@ -692,7 +692,7 @@
         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
@@ -700,21 +700,21 @@
         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
@@ -731,8 +731,8 @@
         }
     }
 
-    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() {
@@ -755,9 +755,9 @@
         }
     }
 
-    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) {
@@ -771,7 +771,7 @@
         // 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 {
@@ -786,7 +786,7 @@
         // 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 {
@@ -794,8 +794,8 @@
         }
     }
 
-    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) {
@@ -803,15 +803,15 @@
         // 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) {
@@ -819,7 +819,7 @@
         // 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 {
@@ -827,8 +827,8 @@
         }
     }
 
-    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) {
@@ -836,7 +836,7 @@
         // 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) {
@@ -863,7 +863,7 @@
         // 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) {
@@ -884,9 +884,9 @@
         }
     }
 
-    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,
@@ -914,7 +914,7 @@
         // 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 {
@@ -922,8 +922,8 @@
         }
     }
 
-    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,
@@ -953,7 +953,7 @@
 
         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 {
@@ -961,9 +961,9 @@
         }
     }
 
-    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) {
@@ -975,8 +975,8 @@
         }
     }
 
-    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) {
@@ -988,7 +988,7 @@
         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) {
@@ -1015,8 +1015,8 @@
         }
     }
 
-    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) {
@@ -1033,8 +1033,8 @@
         }
     }
 
-    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) {
@@ -1059,8 +1059,8 @@
         }
     }
 
-    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);
@@ -1071,7 +1071,7 @@
         }
     }
 
-    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) {
@@ -1138,8 +1138,8 @@
         }
     }
 
-    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
@@ -1156,8 +1156,8 @@
         }
     }
 
-    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
@@ -1174,8 +1174,8 @@
         }
     }
 
-    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) {
@@ -1188,8 +1188,8 @@
         }
     }
 
-    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) {
@@ -1217,8 +1217,8 @@
         }
     }
 
-    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) {
@@ -1234,8 +1234,8 @@
         }
     }
     
-    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) {
@@ -1274,8 +1274,8 @@
         }
     }
 
-    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) {
@@ -1304,8 +1304,8 @@
         }
     }
 
-    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) {
@@ -1320,8 +1320,8 @@
         }
     }
 
-    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,
@@ -1342,8 +1342,8 @@
         }
     }
 
-    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,
@@ -1376,8 +1376,8 @@
         }
     }
 
-    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,
@@ -1457,10 +1457,10 @@
         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/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 @@
  * 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 @@
      * 
      * @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 @@
     }
 
     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 97efa18..b7b6883 100644
--- a/core/java/android/view/GLES20RecordingCanvas.java
+++ b/core/java/android/view/GLES20RecordingCanvas.java
@@ -58,7 +58,7 @@
         mDisplayList.clearReferences();
     }
 
-    int end(int nativeDisplayList) {
+    long end(long nativeDisplayList) {
         return getDisplayList(nativeDisplayList);
     }
 
diff --git a/core/java/android/view/GLRenderer.java b/core/java/android/view/GLRenderer.java
index 986c296..449bad6 100644
--- a/core/java/android/view/GLRenderer.java
+++ b/core/java/android/view/GLRenderer.java
@@ -1406,14 +1406,14 @@
     }
 
     @Override
-    void detachFunctor(int functor) {
+    void detachFunctor(long functor) {
         if (mCanvas != null) {
             mCanvas.detachFunctor(functor);
         }
     }
 
     @Override
-    void attachFunctor(View.AttachInfo attachInfo, int functor) {
+    void attachFunctor(View.AttachInfo attachInfo, long functor) {
         if (mCanvas != null) {
             mCanvas.attachFunctor(functor);
             mFunctorsRunnable.attachInfo = attachInfo;
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 @@
     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 @@
      * @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 @@
     /**
      * 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 @@
             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 @@
         }
     };
 
-    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 2e972c5..a3c7b63 100644
--- a/core/java/android/view/HardwareCanvas.java
+++ b/core/java/android/view/HardwareCanvas.java
@@ -107,7 +107,7 @@
      *
      * @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;
     }
@@ -132,12 +132,12 @@
      * @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.
@@ -145,12 +145,12 @@
      * @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 676ac10..2013494 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -453,9 +453,9 @@
      * @param functor The native functor to remove from the execution queue.
      *
      * @see HardwareCanvas#callDrawGLFunction(int)
-     * @see #attachFunctor(android.view.View.AttachInfo, int)
+     * @see #attachFunctor(android.view.View.AttachInfo, long)
      */
-    abstract void detachFunctor(int functor);
+    abstract void detachFunctor(long functor);
 
     /**
      * Schedules the specified functor in the functors execution queue.
@@ -464,10 +464,10 @@
      * @param functor The native functor to insert in the execution queue.
      *
      * @see HardwareCanvas#callDrawGLFunction(int)
-     * @see #detachFunctor(int)
+     * @see #detachFunctor(long)
      *
      */
-    abstract void attachFunctor(View.AttachInfo attachInfo, int functor);
+    abstract void attachFunctor(View.AttachInfo attachInfo, long functor);
 
     /**
      * Initializes the hardware renderer for the specified surface and setup the
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index a2775d4..fdaae01 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -37,19 +37,19 @@
 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>() {
@@ -76,8 +76,8 @@
     // 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();
 
@@ -140,7 +140,7 @@
     }
 
     /* called from android_view_Surface_createFromIGraphicBufferProducer() */
-    private Surface(int nativeObject) {
+    private Surface(long nativeObject) {
         synchronized (mLock) {
             setNativeObjectLocked(nativeObject);
         }
@@ -271,8 +271,8 @@
             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");
@@ -317,12 +317,12 @@
             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) {
@@ -344,7 +344,7 @@
             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);
@@ -401,7 +401,7 @@
         }
     }
 
-    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 914a5ca..a6f856c 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -32,11 +32,11 @@
 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);
@@ -47,21 +47,21 @@
     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(
@@ -76,7 +76,7 @@
 
     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
 
     /* flags used in constructor (keep in sync with ISurfaceComposerClient.h) */
 
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index bf81811..161fe33 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -127,7 +127,7 @@
     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.
@@ -834,6 +834,6 @@
     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/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index 567f862..2c9f1d9 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -217,12 +217,12 @@
     }
 
     @Override
-    void detachFunctor(int functor) {
+    void detachFunctor(long functor) {
         nDetachFunctor(mNativeProxy, functor);
     }
 
     @Override
-    void attachFunctor(AttachInfo attachInfo, int functor) {
+    void attachFunctor(AttachInfo attachInfo, long functor) {
         nAttachFunctor(mNativeProxy, functor);
     }