Track 64bit changes to android/graphics.

All pointers are now 64bits wide, so should be
represented as java longs and not ints.

Also changed DelegateManager and SparseWeakArray to
reflect the new world order.

(cherry picked from commit 88a8364c386c694f7ad56662ef89713dbf7c9d63)

Change-Id: Ic2f55dd6235751169c5014f9d2ccf3f544259a87
diff --git a/bridge/src/android/graphics/AvoidXfermode_Delegate.java b/bridge/src/android/graphics/AvoidXfermode_Delegate.java
index a50a2bd..34ae825 100644
--- a/bridge/src/android/graphics/AvoidXfermode_Delegate.java
+++ b/bridge/src/android/graphics/AvoidXfermode_Delegate.java
@@ -61,7 +61,7 @@
     // ---- 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/bridge/src/android/graphics/BitmapShader_Delegate.java b/bridge/src/android/graphics/BitmapShader_Delegate.java
index 65a75b0..cdbbe46 100644
--- a/bridge/src/android/graphics/BitmapShader_Delegate.java
+++ b/bridge/src/android/graphics/BitmapShader_Delegate.java
@@ -65,7 +65,7 @@
     // ---- 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 @@
     }
 
     @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/bridge/src/android/graphics/Bitmap_Delegate.java b/bridge/src/android/graphics/Bitmap_Delegate.java
index 93284db..f6abaa1 100644
--- a/bridge/src/android/graphics/Bitmap_Delegate.java
+++ b/bridge/src/android/graphics/Bitmap_Delegate.java
@@ -83,7 +83,7 @@
     /**
      * 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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
 
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     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/bridge/src/android/graphics/BlurMaskFilter_Delegate.java b/bridge/src/android/graphics/BlurMaskFilter_Delegate.java
index 4becba1..d2569c7 100644
--- a/bridge/src/android/graphics/BlurMaskFilter_Delegate.java
+++ b/bridge/src/android/graphics/BlurMaskFilter_Delegate.java
@@ -55,7 +55,7 @@
     // ---- 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/bridge/src/android/graphics/Canvas_Delegate.java b/bridge/src/android/graphics/Canvas_Delegate.java
index 62b47bd..ba771dd 100644
--- a/bridge/src/android/graphics/Canvas_Delegate.java
+++ b/bridge/src/android/graphics/Canvas_Delegate.java
@@ -77,7 +77,7 @@
     /**
      * 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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
 
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @LayoutlibDelegate
-    /*package*/ static void native_drawPath(int nativeCanvas, int path, int paint) {
+    /*package*/ static void native_drawPath(long nativeCanvas, int path, long paint) {
         final Path_Delegate pathDelegate = Path_Delegate.getDelegate(path);
         if (pathDelegate == null) {
             return;
@@ -814,9 +813,9 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
      * <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 @@
      * <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 @@
     }
 
     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/bridge/src/android/graphics/ColorFilter_Delegate.java b/bridge/src/android/graphics/ColorFilter_Delegate.java
index e5a7ab6..d6b3da1 100644
--- a/bridge/src/android/graphics/ColorFilter_Delegate.java
+++ b/bridge/src/android/graphics/ColorFilter_Delegate.java
@@ -46,7 +46,7 @@
 
     // ---- 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 @@
     // ---- 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/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java b/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java
index 2de344b..ca8f450 100644
--- a/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java
+++ b/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java
@@ -55,13 +55,13 @@
     // ---- 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/bridge/src/android/graphics/ComposePathEffect_Delegate.java b/bridge/src/android/graphics/ComposePathEffect_Delegate.java
index 7c04a87..bc3df7d 100644
--- a/bridge/src/android/graphics/ComposePathEffect_Delegate.java
+++ b/bridge/src/android/graphics/ComposePathEffect_Delegate.java
@@ -62,7 +62,7 @@
     // ---- 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/bridge/src/android/graphics/ComposeShader_Delegate.java b/bridge/src/android/graphics/ComposeShader_Delegate.java
index f6e1d00..fae8aef 100644
--- a/bridge/src/android/graphics/ComposeShader_Delegate.java
+++ b/bridge/src/android/graphics/ComposeShader_Delegate.java
@@ -63,15 +63,15 @@
     // ---- 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 @@
     }
 
     @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/bridge/src/android/graphics/CornerPathEffect_Delegate.java b/bridge/src/android/graphics/CornerPathEffect_Delegate.java
index b0f8168..73745c3 100644
--- a/bridge/src/android/graphics/CornerPathEffect_Delegate.java
+++ b/bridge/src/android/graphics/CornerPathEffect_Delegate.java
@@ -62,7 +62,7 @@
     // ---- 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/bridge/src/android/graphics/DashPathEffect_Delegate.java b/bridge/src/android/graphics/DashPathEffect_Delegate.java
index d97c2ec..881afde 100644
--- a/bridge/src/android/graphics/DashPathEffect_Delegate.java
+++ b/bridge/src/android/graphics/DashPathEffect_Delegate.java
@@ -73,7 +73,7 @@
     // ---- 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/bridge/src/android/graphics/DiscretePathEffect_Delegate.java b/bridge/src/android/graphics/DiscretePathEffect_Delegate.java
index ec4a810..46109f3 100644
--- a/bridge/src/android/graphics/DiscretePathEffect_Delegate.java
+++ b/bridge/src/android/graphics/DiscretePathEffect_Delegate.java
@@ -62,7 +62,7 @@
     // ---- 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/bridge/src/android/graphics/DrawFilter_Delegate.java b/bridge/src/android/graphics/DrawFilter_Delegate.java
index 870c46b..2e10740 100644
--- a/bridge/src/android/graphics/DrawFilter_Delegate.java
+++ b/bridge/src/android/graphics/DrawFilter_Delegate.java
@@ -46,7 +46,7 @@
 
     // ---- 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 @@
     // ---- native methods ----
 
     @LayoutlibDelegate
-    /*package*/ static void nativeDestructor(int nativeDrawFilter) {
+    /*package*/ static void nativeDestructor(long nativeDrawFilter) {
         sManager.removeJavaReferenceFor(nativeDrawFilter);
     }
 
diff --git a/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java b/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java
index ebc1c1d..e5040cc 100644
--- a/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java
+++ b/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java
@@ -55,7 +55,7 @@
     // ---- 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/bridge/src/android/graphics/LayerRasterizer_Delegate.java b/bridge/src/android/graphics/LayerRasterizer_Delegate.java
index 51e0576..10cc572 100644
--- a/bridge/src/android/graphics/LayerRasterizer_Delegate.java
+++ b/bridge/src/android/graphics/LayerRasterizer_Delegate.java
@@ -55,13 +55,13 @@
     // ---- 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/bridge/src/android/graphics/LightingColorFilter_Delegate.java b/bridge/src/android/graphics/LightingColorFilter_Delegate.java
index 0ee883d..defaac3 100644
--- a/bridge/src/android/graphics/LightingColorFilter_Delegate.java
+++ b/bridge/src/android/graphics/LightingColorFilter_Delegate.java
@@ -55,13 +55,13 @@
     // ---- 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/bridge/src/android/graphics/LinearGradient_Delegate.java b/bridge/src/android/graphics/LinearGradient_Delegate.java
index f117fca..ac77377 100644
--- a/bridge/src/android/graphics/LinearGradient_Delegate.java
+++ b/bridge/src/android/graphics/LinearGradient_Delegate.java
@@ -54,7 +54,7 @@
     // ---- 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 @@
     }
 
     @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 @@
     }
 
     @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/bridge/src/android/graphics/MaskFilter_Delegate.java b/bridge/src/android/graphics/MaskFilter_Delegate.java
index c2f27e4..e726c59 100644
--- a/bridge/src/android/graphics/MaskFilter_Delegate.java
+++ b/bridge/src/android/graphics/MaskFilter_Delegate.java
@@ -46,7 +46,7 @@
 
     // ---- 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 @@
     // ---- native methods ----
 
     @LayoutlibDelegate
-    /*package*/ static void nativeDestructor(int native_filter) {
+    /*package*/ static void nativeDestructor(long native_filter) {
         sManager.removeJavaReferenceFor(native_filter);
     }
 
diff --git a/bridge/src/android/graphics/Matrix_Delegate.java b/bridge/src/android/graphics/Matrix_Delegate.java
index 5df2a21..1d66586 100644
--- a/bridge/src/android/graphics/Matrix_Delegate.java
+++ b/bridge/src/android/graphics/Matrix_Delegate.java
@@ -53,7 +53,7 @@
 
     // ---- 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 @@
     // ---- 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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @LayoutlibDelegate
-    /*package*/ static boolean native_invert(int native_object, int inverse) {
+    /*package*/ static boolean native_invert(long native_object, int inverse) {
         Matrix_Delegate d = sManager.getDelegate(native_object);
         if (d == null) {
             return false;
@@ -682,7 +682,7 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @LayoutlibDelegate
-    /*package*/ static void finalizer(int native_instance) {
+    /*package*/ static void finalizer(long native_instance) {
         sManager.removeJavaReferenceFor(native_instance);
     }
 
diff --git a/bridge/src/android/graphics/NinePatch_Delegate.java b/bridge/src/android/graphics/NinePatch_Delegate.java
index fa68796..a5c52e5 100644
--- a/bridge/src/android/graphics/NinePatch_Delegate.java
+++ b/bridge/src/android/graphics/NinePatch_Delegate.java
@@ -158,7 +158,7 @@
     }
 
     @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 @@
         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 @@
     }
 
     @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 @@
     }
 
     @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/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java b/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java
index 71d346a..fa20746 100644
--- a/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java
+++ b/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java
@@ -55,7 +55,7 @@
     // ---- 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/bridge/src/android/graphics/Paint_Delegate.java b/bridge/src/android/graphics/Paint_Delegate.java
index 41953ed..ca8e8aa 100644
--- a/bridge/src/android/graphics/Paint_Delegate.java
+++ b/bridge/src/android/graphics/Paint_Delegate.java
@@ -96,7 +96,7 @@
 
     // ---- 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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @LayoutlibDelegate
-    /*package*/ static void finalizer(int nativePaint) {
+    /*package*/ static void finalizer(long nativePaint) {
         sManager.removeJavaReferenceFor(nativePaint);
     }
 
diff --git a/bridge/src/android/graphics/PathDashPathEffect_Delegate.java b/bridge/src/android/graphics/PathDashPathEffect_Delegate.java
index c448f0e..fd9ba62 100644
--- a/bridge/src/android/graphics/PathDashPathEffect_Delegate.java
+++ b/bridge/src/android/graphics/PathDashPathEffect_Delegate.java
@@ -62,7 +62,7 @@
     // ---- 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/bridge/src/android/graphics/PathEffect_Delegate.java b/bridge/src/android/graphics/PathEffect_Delegate.java
index bd2b6de..000481e 100644
--- a/bridge/src/android/graphics/PathEffect_Delegate.java
+++ b/bridge/src/android/graphics/PathEffect_Delegate.java
@@ -48,7 +48,7 @@
 
     // ---- 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 @@
     // ---- native methods ----
 
     @LayoutlibDelegate
-    /*package*/ static void nativeDestructor(int native_patheffect) {
+    /*package*/ static void nativeDestructor(long native_patheffect) {
         sManager.removeJavaReferenceFor(native_patheffect);
     }
 
diff --git a/bridge/src/android/graphics/Path_Delegate.java b/bridge/src/android/graphics/Path_Delegate.java
index 64f19d3..f3b56d9 100644
--- a/bridge/src/android/graphics/Path_Delegate.java
+++ b/bridge/src/android/graphics/Path_Delegate.java
@@ -63,7 +63,7 @@
 
     // ---- 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 @@
     // ---- native methods ----
 
     @LayoutlibDelegate
-    /*package*/ static int init1() {
+    /*package*/ static long init1() {
         // create the delegate
         Path_Delegate newDelegate = new Path_Delegate();
 
@@ -96,7 +96,7 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
         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/bridge/src/android/graphics/PixelXorXfermode_Delegate.java b/bridge/src/android/graphics/PixelXorXfermode_Delegate.java
index 4ab044b..f27144f 100644
--- a/bridge/src/android/graphics/PixelXorXfermode_Delegate.java
+++ b/bridge/src/android/graphics/PixelXorXfermode_Delegate.java
@@ -61,7 +61,7 @@
     // ---- 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/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java b/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java
index c45dbaa..6049919 100644
--- a/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java
+++ b/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java
@@ -55,13 +55,13 @@
     // ---- 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/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java b/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java
index 4301c1a..a89fd57 100644
--- a/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java
+++ b/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java
@@ -127,7 +127,7 @@
     // ---- 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/bridge/src/android/graphics/RadialGradient_Delegate.java b/bridge/src/android/graphics/RadialGradient_Delegate.java
index 3fe45fa..4f16dcf 100644
--- a/bridge/src/android/graphics/RadialGradient_Delegate.java
+++ b/bridge/src/android/graphics/RadialGradient_Delegate.java
@@ -54,7 +54,7 @@
     // ---- 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 @@
     }
 
     @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/bridge/src/android/graphics/Rasterizer_Delegate.java b/bridge/src/android/graphics/Rasterizer_Delegate.java
index 2812b6b..a742840 100644
--- a/bridge/src/android/graphics/Rasterizer_Delegate.java
+++ b/bridge/src/android/graphics/Rasterizer_Delegate.java
@@ -46,7 +46,7 @@
 
     // ---- 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 @@
     // ---- native methods ----
 
     @LayoutlibDelegate
-    /*package*/ static void finalizer(int native_instance) {
+    /*package*/ static void finalizer(long native_instance) {
         sManager.removeJavaReferenceFor(native_instance);
     }
 
diff --git a/bridge/src/android/graphics/Region_Delegate.java b/bridge/src/android/graphics/Region_Delegate.java
index cb31b8f..ea23649 100644
--- a/bridge/src/android/graphics/Region_Delegate.java
+++ b/bridge/src/android/graphics/Region_Delegate.java
@@ -57,7 +57,7 @@
 
     // ---- 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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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/bridge/src/android/graphics/Shader_Delegate.java b/bridge/src/android/graphics/Shader_Delegate.java
index 368c0384..70a0a43 100644
--- a/bridge/src/android/graphics/Shader_Delegate.java
+++ b/bridge/src/android/graphics/Shader_Delegate.java
@@ -49,7 +49,7 @@
 
     // ---- 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 @@
     // ---- 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/bridge/src/android/graphics/SumPathEffect_Delegate.java b/bridge/src/android/graphics/SumPathEffect_Delegate.java
index 410df0c..6d2e9b4 100644
--- a/bridge/src/android/graphics/SumPathEffect_Delegate.java
+++ b/bridge/src/android/graphics/SumPathEffect_Delegate.java
@@ -62,7 +62,7 @@
     // ---- 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/bridge/src/android/graphics/SweepGradient_Delegate.java b/bridge/src/android/graphics/SweepGradient_Delegate.java
index 13ae12e..f2b3e8d 100644
--- a/bridge/src/android/graphics/SweepGradient_Delegate.java
+++ b/bridge/src/android/graphics/SweepGradient_Delegate.java
@@ -52,25 +52,25 @@
     // ---- 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/bridge/src/android/graphics/Typeface_Delegate.java b/bridge/src/android/graphics/Typeface_Delegate.java
index 8701cc8..a25fb59 100644
--- a/bridge/src/android/graphics/Typeface_Delegate.java
+++ b/bridge/src/android/graphics/Typeface_Delegate.java
@@ -75,7 +75,7 @@
         sPostInitDelegate.clear();
     }
 
-    public static Typeface_Delegate getDelegate(int nativeTypeface) {
+    public static Typeface_Delegate getDelegate(long nativeTypeface) {
         return sManager.getDelegate(nativeTypeface);
     }
 
@@ -83,7 +83,7 @@
         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 @@
     // ---- 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 @@
     }
 
     @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 @@
     }
 
     @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 @@
     }
 
     @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/bridge/src/android/graphics/Xfermode_Delegate.java b/bridge/src/android/graphics/Xfermode_Delegate.java
index 962d69c..94a6d76 100644
--- a/bridge/src/android/graphics/Xfermode_Delegate.java
+++ b/bridge/src/android/graphics/Xfermode_Delegate.java
@@ -48,7 +48,7 @@
 
     // ---- 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 @@
     // ---- native methods ----
 
     @LayoutlibDelegate
-    /*package*/ static void finalizer(int native_instance) {
+    /*package*/ static void finalizer(long native_instance) {
         sManager.removeJavaReferenceFor(native_instance);
     }
 
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java b/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java
index ae1217d..261cc98 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java
@@ -94,7 +94,7 @@
      * @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 @@
      * @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 @@
      * 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/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java b/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java
index 4d0c9ce..53e1640 100644
--- a/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java
+++ b/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java
@@ -30,13 +30,14 @@
  *
  * 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 @@
      * 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 @@
      * 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 @@
      * 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 @@
     /**
      * 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 @@
     }
 
     /**
-     * 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 @@
     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 @@
         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 @@
      * 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 @@
             }
 
             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 @@
      * 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 @@
      * 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 @@
      * 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 @@
 
         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 @@
         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 @@
             return ~high;
     }
 
-    private int[] mKeys;
+    private long[] mKeys;
     private WeakReference<?>[] mValues;
     private int mSize;
 }