diff options
50 files changed, 540 insertions, 271 deletions
diff --git a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java index 7d41d1c..7b444aa 100644 --- a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java +++ b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java @@ -17,6 +17,7 @@ package android.animation; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.animation.PropertyValuesHolder @@ -34,20 +35,24 @@ import com.android.layoutlib.bridge.impl.DelegateManager; */ /*package*/ class PropertyValuesHolder_Delegate { + @LayoutlibDelegate /*package*/ static int nGetIntMethod(Class<?> targetClass, String methodName) { // return 0 to force PropertyValuesHolder to use Java reflection. return 0; } + @LayoutlibDelegate /*package*/ static int nGetFloatMethod(Class<?> targetClass, String methodName) { // return 0 to force PropertyValuesHolder to use Java reflection. return 0; } + @LayoutlibDelegate /*package*/ static void nCallIntMethod(Object target, int methodID, int arg) { // do nothing } + @LayoutlibDelegate /*package*/ static void nCallFloatMethod(Object target, int methodID, float arg) { // do nothing } diff --git a/tools/layoutlib/bridge/src/android/app/Fragment_Delegate.java b/tools/layoutlib/bridge/src/android/app/Fragment_Delegate.java index 60ad645..aabd3f1 100644 --- a/tools/layoutlib/bridge/src/android/app/Fragment_Delegate.java +++ b/tools/layoutlib/bridge/src/android/app/Fragment_Delegate.java @@ -17,6 +17,7 @@ package android.app; import com.android.ide.common.rendering.api.IProjectCallback; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.content.Context; import android.os.Bundle; @@ -48,6 +49,7 @@ public class Fragment_Delegate { * Like {@link #instantiate(Context, String, Bundle)} but with a null * argument Bundle. */ + @LayoutlibDelegate /*package*/ static Fragment instantiate(Context context, String fname) { return instantiate(context, fname, null); } @@ -66,6 +68,7 @@ public class Fragment_Delegate { * the given fragment class. This is a runtime exception; it is not * normally expected to happen. */ + @LayoutlibDelegate /*package*/ static Fragment instantiate(Context context, String fname, Bundle args) { try { if (sProjectCallback != null) { diff --git a/tools/layoutlib/bridge/src/android/content/res/Resources_Theme_Delegate.java b/tools/layoutlib/bridge/src/android/content/res/Resources_Theme_Delegate.java index 03f3980..413894b 100644 --- a/tools/layoutlib/bridge/src/android/content/res/Resources_Theme_Delegate.java +++ b/tools/layoutlib/bridge/src/android/content/res/Resources_Theme_Delegate.java @@ -17,6 +17,7 @@ package android.content.res; import com.android.layoutlib.bridge.impl.RenderSessionImpl; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.content.res.Resources.NotFoundException; import android.content.res.Resources.Theme; @@ -32,12 +33,14 @@ import android.util.TypedValue; */ public class Resources_Theme_Delegate { + @LayoutlibDelegate /*package*/ static TypedArray obtainStyledAttributes( Resources thisResources, Theme thisTheme, int[] attrs) { return RenderSessionImpl.getCurrentContext().obtainStyledAttributes(attrs); } + @LayoutlibDelegate /*package*/ static TypedArray obtainStyledAttributes( Resources thisResources, Theme thisTheme, int resid, int[] attrs) @@ -45,6 +48,7 @@ public class Resources_Theme_Delegate { return RenderSessionImpl.getCurrentContext().obtainStyledAttributes(resid, attrs); } + @LayoutlibDelegate /*package*/ static TypedArray obtainStyledAttributes( Resources thisResources, Theme thisTheme, AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { @@ -52,6 +56,7 @@ public class Resources_Theme_Delegate { set, attrs, defStyleAttr, defStyleRes); } + @LayoutlibDelegate /*package*/ static boolean resolveAttribute( Resources thisResources, Theme thisTheme, int resid, TypedValue outValue, diff --git a/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java index 190eb37..e193477 100644 --- a/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/AvoidXfermode_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.Composite; @@ -59,6 +60,7 @@ public class AvoidXfermode_Delegate extends Xfermode_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate(int opColor, int tolerance, int nativeMode) { AvoidXfermode_Delegate newDelegate = new AvoidXfermode_Delegate(); return sManager.addDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java index c4fffc8..080b85f 100644 --- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java @@ -21,6 +21,7 @@ import com.android.layoutlib.bridge.android.BridgeResources.NinePatchInputStream import com.android.layoutlib.bridge.impl.DelegateManager; import com.android.ninepatch.NinePatchChunk; import com.android.resources.Density; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.graphics.BitmapFactory.Options; @@ -42,6 +43,7 @@ import java.io.InputStream; // ------ Java delegates ------ + @LayoutlibDelegate /*package*/ static Bitmap finishDecode(Bitmap bm, Rect outPadding, Options opts) { if (bm == null || opts == null) { return bm; @@ -82,10 +84,12 @@ import java.io.InputStream; // ------ Native Delegates ------ + @LayoutlibDelegate /*package*/ static void nativeSetDefaultConfig(int nativeConfig) { // pass } + @LayoutlibDelegate /*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage, Rect padding, Options opts) { Bitmap bm = null; @@ -129,29 +133,34 @@ import java.io.InputStream; return bm; } + @LayoutlibDelegate /*package*/ static Bitmap nativeDecodeFileDescriptor(FileDescriptor fd, Rect padding, Options opts) { opts.inBitmap = null; return null; } + @LayoutlibDelegate /*package*/ static Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts) { opts.inBitmap = null; return null; } + @LayoutlibDelegate /*package*/ static Bitmap nativeDecodeByteArray(byte[] data, int offset, int length, Options opts) { opts.inBitmap = null; return null; } + @LayoutlibDelegate /*package*/ static byte[] nativeScaleNinePatch(byte[] chunk, float scale, Rect pad) { // don't scale for now. This should not be called anyway since we re-implement // BitmapFactory.finishDecode(); return chunk; } + @LayoutlibDelegate /*package*/ static boolean nativeIsSeekable(FileDescriptor fd) { return true; } diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java index 73c5a1a..c6fde7b 100644 --- a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java @@ -19,6 +19,7 @@ package android.graphics; import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.graphics.Shader.TileMode; @@ -63,6 +64,7 @@ public class BitmapShader_Delegate extends Shader_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate(int native_bitmap, int shaderTileModeX, int shaderTileModeY) { Bitmap_Delegate bitmap = Bitmap_Delegate.getDelegate(native_bitmap); @@ -77,6 +79,7 @@ public class BitmapShader_Delegate extends Shader_Delegate { return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static int nativePostCreate(int native_shader, int native_bitmap, int shaderTileModeX, int shaderTileModeY) { // pass, not needed. diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java index 3e80614..9da8c1a 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java @@ -20,6 +20,7 @@ import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; import com.android.resources.Density; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; @@ -196,6 +197,7 @@ public final class Bitmap_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static Bitmap nativeCreate(int[] colors, int offset, int stride, int width, int height, int nativeConfig, boolean mutable) { int imageType = getBufferedImageType(nativeConfig); @@ -213,6 +215,7 @@ public final class Bitmap_Delegate { return createBitmap(delegate, mutable, Bitmap.getDefaultDensity()); } + @LayoutlibDelegate /*package*/ static Bitmap nativeCopy(int srcBitmap, int nativeConfig, boolean isMutable) { Bitmap_Delegate srcBmpDelegate = sManager.getDelegate(srcBitmap); if (srcBmpDelegate == null) { @@ -240,14 +243,17 @@ public final class Bitmap_Delegate { return createBitmap(delegate, isMutable, Bitmap.getDefaultDensity()); } + @LayoutlibDelegate /*package*/ static void nativeDestructor(int nativeBitmap) { sManager.removeDelegate(nativeBitmap); } + @LayoutlibDelegate /*package*/ static void nativeRecycle(int nativeBitmap) { sManager.removeDelegate(nativeBitmap); } + @LayoutlibDelegate /*package*/ static boolean nativeCompress(int nativeBitmap, int format, int quality, OutputStream stream, byte[] tempStorage) { Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, @@ -255,6 +261,7 @@ public final class Bitmap_Delegate { return true; } + @LayoutlibDelegate /*package*/ static void nativeErase(int nativeBitmap, int color) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); @@ -274,6 +281,7 @@ public final class Bitmap_Delegate { } } + @LayoutlibDelegate /*package*/ static int nativeWidth(int nativeBitmap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); @@ -284,6 +292,7 @@ public final class Bitmap_Delegate { return delegate.mImage.getWidth(); } + @LayoutlibDelegate /*package*/ static int nativeHeight(int nativeBitmap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); @@ -294,6 +303,7 @@ public final class Bitmap_Delegate { return delegate.mImage.getHeight(); } + @LayoutlibDelegate /*package*/ static int nativeRowBytes(int nativeBitmap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); @@ -304,6 +314,7 @@ public final class Bitmap_Delegate { return delegate.mImage.getWidth(); } + @LayoutlibDelegate /*package*/ static int nativeConfig(int nativeBitmap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); @@ -314,6 +325,7 @@ public final class Bitmap_Delegate { return delegate.mConfig.nativeInt; } + @LayoutlibDelegate /*package*/ static boolean nativeHasAlpha(int nativeBitmap) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); @@ -324,6 +336,7 @@ public final class Bitmap_Delegate { return delegate.mHasAlpha; } + @LayoutlibDelegate /*package*/ static int nativeGetPixel(int nativeBitmap, int x, int y) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); @@ -334,6 +347,7 @@ public final class Bitmap_Delegate { return delegate.mImage.getRGB(x, y); } + @LayoutlibDelegate /*package*/ static void nativeGetPixels(int nativeBitmap, int[] pixels, int offset, int stride, int x, int y, int width, int height) { Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); @@ -345,6 +359,7 @@ public final class Bitmap_Delegate { } + @LayoutlibDelegate /*package*/ static void nativeSetPixel(int nativeBitmap, int x, int y, int color) { Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -354,6 +369,7 @@ public final class Bitmap_Delegate { delegate.getImage().setRGB(x, y, color); } + @LayoutlibDelegate /*package*/ static void nativeSetPixels(int nativeBitmap, int[] colors, int offset, int stride, int x, int y, int width, int height) { Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); @@ -364,16 +380,19 @@ public final class Bitmap_Delegate { delegate.getImage().setRGB(x, y, width, height, colors, offset, stride); } + @LayoutlibDelegate /*package*/ static void nativeCopyPixelsToBuffer(int nativeBitmap, Buffer dst) { // FIXME implement native delegate throw new UnsupportedOperationException("Native delegate needed for Bitmap.nativeCopyPixelsToBuffer"); } + @LayoutlibDelegate /*package*/ static void nativeCopyPixelsFromBuffer(int nb, Buffer src) { // FIXME implement native delegate throw new UnsupportedOperationException("Native delegate needed for Bitmap.nativeCopyPixelsFromBuffer"); } + @LayoutlibDelegate /*package*/ static int nativeGenerationId(int nativeBitmap) { Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); if (delegate == null) { @@ -383,6 +402,7 @@ public final class Bitmap_Delegate { return delegate.mGenerationId; } + @LayoutlibDelegate /*package*/ static Bitmap nativeCreateFromParcel(Parcel p) { // This is only called by Bitmap.CREATOR (Parcelable.Creator<Bitmap>), which is only // used during aidl call so really this should not be called. @@ -392,6 +412,7 @@ public final class Bitmap_Delegate { return null; } + @LayoutlibDelegate /*package*/ static boolean nativeWriteToParcel(int nativeBitmap, boolean isMutable, int density, Parcel p) { // This is only called when sending a bitmap through aidl, so really this should not @@ -402,6 +423,7 @@ public final class Bitmap_Delegate { return false; } + @LayoutlibDelegate /*package*/ static Bitmap nativeExtractAlpha(int nativeBitmap, int nativePaint, int[] offsetXY) { Bitmap_Delegate bitmap = sManager.getDelegate(nativeBitmap); @@ -429,10 +451,12 @@ public final class Bitmap_Delegate { Density.DEFAULT_DENSITY /*density*/); } + @LayoutlibDelegate /*package*/ static void nativePrepareToDraw(int nativeBitmap) { // nothing to be done here. } + @LayoutlibDelegate /*package*/ static void nativeSetHasAlpha(int nativeBitmap, boolean hasAlpha) { // get the delegate from the native int. Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap); @@ -443,6 +467,7 @@ public final class Bitmap_Delegate { delegate.mHasAlpha = hasAlpha; } + @LayoutlibDelegate /*package*/ static boolean nativeSameAs(int nb0, int nb1) { Bitmap_Delegate delegate1 = sManager.getDelegate(nb0); if (delegate1 == null) { diff --git a/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java index 34824b4..92d0d0a 100644 --- a/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/BlurMaskFilter_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.BlurMaskFilter @@ -53,6 +54,7 @@ public class BlurMaskFilter_Delegate extends MaskFilter_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeConstructor(float radius, int style) { BlurMaskFilter_Delegate newDelegate = new BlurMaskFilter_Delegate(); return sManager.addDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java index 5a6902c..bb98843 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java @@ -20,6 +20,7 @@ import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; import com.android.layoutlib.bridge.impl.GcSnapshot; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.graphics.Bitmap.Config; import android.graphics.Paint_Delegate.FontInfo; @@ -99,6 +100,7 @@ public final class Canvas_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static boolean isOpaque(Canvas thisCanvas) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas); @@ -109,6 +111,7 @@ public final class Canvas_Delegate { return canvasDelegate.mBitmap.getConfig() == Config.RGB_565; } + @LayoutlibDelegate /*package*/ static int getWidth(Canvas thisCanvas) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas); @@ -119,6 +122,7 @@ public final class Canvas_Delegate { return canvasDelegate.mBitmap.getImage().getWidth(); } + @LayoutlibDelegate /*package*/ static int getHeight(Canvas thisCanvas) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas); @@ -129,7 +133,8 @@ public final class Canvas_Delegate { return canvasDelegate.mBitmap.getImage().getHeight(); } - /*package*/ static void translate(Canvas thisCanvas, float dx, float dy) { + @LayoutlibDelegate + /*package*/ static void translate(Canvas thisCanvas, float dx, float dy) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas); if (canvasDelegate == null) { @@ -139,6 +144,7 @@ public final class Canvas_Delegate { canvasDelegate.getSnapshot().translate(dx, dy); } + @LayoutlibDelegate /*package*/ static void rotate(Canvas thisCanvas, float degrees) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas); @@ -149,7 +155,8 @@ public final class Canvas_Delegate { canvasDelegate.getSnapshot().rotate(Math.toRadians(degrees)); } - /*package*/ static void scale(Canvas thisCanvas, float sx, float sy) { + @LayoutlibDelegate + /*package*/ static void scale(Canvas thisCanvas, float sx, float sy) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas); if (canvasDelegate == null) { @@ -159,7 +166,8 @@ public final class Canvas_Delegate { canvasDelegate.getSnapshot().scale(sx, sy); } - /*package*/ static void skew(Canvas thisCanvas, float kx, float ky) { + @LayoutlibDelegate + /*package*/ static void skew(Canvas thisCanvas, float kx, float ky) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas); if (canvasDelegate == null) { @@ -182,15 +190,18 @@ public final class Canvas_Delegate { g.setTransform(currentTx); } + @LayoutlibDelegate /*package*/ static boolean clipRect(Canvas thisCanvas, RectF rect) { return clipRect(thisCanvas, rect.left, rect.top, rect.right, rect.bottom); } + @LayoutlibDelegate /*package*/ static boolean clipRect(Canvas thisCanvas, Rect rect) { return clipRect(thisCanvas, (float) rect.left, (float) rect.top, (float) rect.right, (float) rect.bottom); } + @LayoutlibDelegate /*package*/ static boolean clipRect(Canvas thisCanvas, float left, float top, float right, float bottom) { // get the delegate from the native int. @@ -202,16 +213,19 @@ public final class Canvas_Delegate { return canvasDelegate.clipRect(left, top, right, bottom, Region.Op.INTERSECT.nativeInt); } + @LayoutlibDelegate /*package*/ static boolean clipRect(Canvas thisCanvas, int left, int top, int right, int bottom) { return clipRect(thisCanvas, (float) left, (float) top, (float) right, (float) bottom); } + @LayoutlibDelegate /*package*/ static int save(Canvas thisCanvas) { return save(thisCanvas, Canvas.MATRIX_SAVE_FLAG | Canvas.CLIP_SAVE_FLAG); } + @LayoutlibDelegate /*package*/ static int save(Canvas thisCanvas, int saveFlags) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas); @@ -222,6 +236,7 @@ public final class Canvas_Delegate { return canvasDelegate.save(saveFlags); } + @LayoutlibDelegate /*package*/ static void restore(Canvas thisCanvas) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas); @@ -232,6 +247,7 @@ public final class Canvas_Delegate { canvasDelegate.restore(); } + @LayoutlibDelegate /*package*/ static int getSaveCount(Canvas thisCanvas) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas); @@ -242,6 +258,7 @@ public final class Canvas_Delegate { return canvasDelegate.getSnapshot().size(); } + @LayoutlibDelegate /*package*/ static void restoreToCount(Canvas thisCanvas, int saveCount) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas); @@ -252,17 +269,20 @@ public final class Canvas_Delegate { canvasDelegate.restoreTo(saveCount); } + @LayoutlibDelegate /*package*/ static void drawPoints(Canvas thisCanvas, float[] pts, int offset, int count, Paint paint) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void drawPoint(Canvas thisCanvas, float x, float y, Paint paint) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void drawLines(Canvas thisCanvas, final float[] pts, final int offset, final int count, Paint paint) { @@ -277,10 +297,12 @@ public final class Canvas_Delegate { }); } + @LayoutlibDelegate /*package*/ static void freeCaches() { // nothing to be done here. } + @LayoutlibDelegate /*package*/ static int initRaster(int nativeBitmapOrZero) { if (nativeBitmapOrZero > 0) { // get the Bitmap from the int @@ -298,6 +320,7 @@ public final class Canvas_Delegate { } } + @LayoutlibDelegate /*package*/ static void native_setBitmap(int nativeCanvas, int bitmap) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); @@ -314,6 +337,7 @@ public final class Canvas_Delegate { canvasDelegate.setBitmap(bitmapDelegate); } + @LayoutlibDelegate /*package*/ static int native_saveLayer(int nativeCanvas, RectF bounds, int paint, int layerFlags) { // get the delegate from the native int. @@ -330,6 +354,7 @@ public final class Canvas_Delegate { return canvasDelegate.saveLayer(bounds, paintDelegate, layerFlags); } + @LayoutlibDelegate /*package*/ static int native_saveLayer(int nativeCanvas, float l, float t, float r, float b, int paint, int layerFlags) { @@ -348,6 +373,7 @@ public final class Canvas_Delegate { paintDelegate, layerFlags); } + @LayoutlibDelegate /*package*/ static int native_saveLayerAlpha(int nativeCanvas, RectF bounds, int alpha, int layerFlags) { @@ -360,6 +386,7 @@ public final class Canvas_Delegate { return canvasDelegate.saveLayerAlpha(bounds, alpha, layerFlags); } + @LayoutlibDelegate /*package*/ static int native_saveLayerAlpha(int nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags) { @@ -373,6 +400,7 @@ public final class Canvas_Delegate { } + @LayoutlibDelegate /*package*/ static void native_concat(int nCanvas, int nMatrix) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas); @@ -400,6 +428,7 @@ public final class Canvas_Delegate { snapshot.setTransform(currentTx); } + @LayoutlibDelegate /*package*/ static void native_setMatrix(int nCanvas, int nMatrix) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas); @@ -429,6 +458,7 @@ public final class Canvas_Delegate { } } + @LayoutlibDelegate /*package*/ static boolean native_clipRect(int nCanvas, float left, float top, float right, float bottom, @@ -443,6 +473,7 @@ public final class Canvas_Delegate { return canvasDelegate.clipRect(left, top, right, bottom, regionOp); } + @LayoutlibDelegate /*package*/ static boolean native_clipPath(int nativeCanvas, int nativePath, int regionOp) { @@ -459,6 +490,7 @@ public final class Canvas_Delegate { return canvasDelegate.mSnapshot.clip(pathDelegate.getJavaShape(), regionOp); } + @LayoutlibDelegate /*package*/ static boolean native_clipRegion(int nativeCanvas, int nativeRegion, int regionOp) { @@ -475,6 +507,7 @@ public final class Canvas_Delegate { return canvasDelegate.mSnapshot.clip(region.getJavaArea(), regionOp); } + @LayoutlibDelegate /*package*/ static void nativeSetDrawFilter(int nativeCanvas, int nativeFilter) { Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); @@ -498,6 +531,7 @@ public final class Canvas_Delegate { } } + @LayoutlibDelegate /*package*/ static boolean native_getClipBounds(int nativeCanvas, Rect bounds) { // get the delegate from the native int. @@ -518,6 +552,7 @@ public final class Canvas_Delegate { return false; } + @LayoutlibDelegate /*package*/ static void native_getCTM(int canvas, int matrix) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(canvas); @@ -534,6 +569,7 @@ public final class Canvas_Delegate { matrixDelegate.set(Matrix_Delegate.makeValues(transform)); } + @LayoutlibDelegate /*package*/ static boolean native_quickReject(int nativeCanvas, RectF rect, int native_edgeType) { @@ -541,6 +577,7 @@ public final class Canvas_Delegate { return false; } + @LayoutlibDelegate /*package*/ static boolean native_quickReject(int nativeCanvas, int path, int native_edgeType) { @@ -548,6 +585,7 @@ public final class Canvas_Delegate { return false; } + @LayoutlibDelegate /*package*/ static boolean native_quickReject(int nativeCanvas, float left, float top, float right, float bottom, @@ -556,21 +594,25 @@ public final class Canvas_Delegate { return false; } + @LayoutlibDelegate /*package*/ static void native_drawRGB(int 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) { 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) { native_drawColor(nativeCanvas, color, PorterDuff.Mode.SRC_OVER.nativeInt); } + @LayoutlibDelegate /*package*/ static void native_drawColor(int nativeCanvas, final int color, final int mode) { // get the delegate from the native int. Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); @@ -600,11 +642,13 @@ public final class Canvas_Delegate { }); } + @LayoutlibDelegate /*package*/ static void native_drawPaint(int nativeCanvas, int paint) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_drawLine(int nativeCanvas, final float startX, final float startY, final float stopX, final float stopY, int paint) { @@ -617,11 +661,13 @@ public final class Canvas_Delegate { }); } + @LayoutlibDelegate /*package*/ static void native_drawRect(int nativeCanvas, RectF rect, int 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) { @@ -646,6 +692,7 @@ public final class Canvas_Delegate { }); } + @LayoutlibDelegate /*package*/ static void native_drawOval(int nativeCanvas, final RectF oval, int paint) { if (oval.right > oval.left && oval.bottom > oval.top) { draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/, @@ -670,6 +717,7 @@ public final class Canvas_Delegate { } } + @LayoutlibDelegate /*package*/ static void native_drawCircle(int nativeCanvas, float cx, float cy, float radius, int paint) { @@ -678,6 +726,7 @@ public final class Canvas_Delegate { paint); } + @LayoutlibDelegate /*package*/ static void native_drawArc(int nativeCanvas, RectF oval, float startAngle, float sweep, boolean useCenter, int paint) { @@ -685,6 +734,7 @@ public final class Canvas_Delegate { throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_drawRoundRect(int nativeCanvas, final RectF rect, final float rx, final float ry, int paint) { @@ -713,6 +763,7 @@ public final class Canvas_Delegate { }); } + @LayoutlibDelegate /*package*/ static void native_drawPath(int nativeCanvas, int path, int paint) { final Path_Delegate pathDelegate = Path_Delegate.getDelegate(path); @@ -739,6 +790,7 @@ public final class Canvas_Delegate { }); } + @LayoutlibDelegate /*package*/ static void native_drawBitmap(Canvas thisCanvas, int nativeCanvas, int bitmap, float left, float top, int nativePaintOrZero, @@ -760,6 +812,7 @@ public final class Canvas_Delegate { (int)left, (int)top, (int)right, (int)bottom); } + @LayoutlibDelegate /*package*/ static void native_drawBitmap(Canvas thisCanvas, int nativeCanvas, int bitmap, Rect src, RectF dst, int nativePaintOrZero, @@ -784,6 +837,7 @@ public final class Canvas_Delegate { } } + @LayoutlibDelegate /*package*/ static void native_drawBitmap(int nativeCanvas, int bitmap, Rect src, Rect dst, int nativePaintOrZero, @@ -808,6 +862,7 @@ public final class Canvas_Delegate { } } + @LayoutlibDelegate /*package*/ static void native_drawBitmap(int nativeCanvas, int[] colors, int offset, int stride, final float x, final float y, int width, int height, @@ -832,6 +887,7 @@ public final class Canvas_Delegate { }); } + @LayoutlibDelegate /*package*/ static void nativeDrawBitmapMatrix(int nCanvas, int nBitmap, int nMatrix, int nPaint) { // get the delegate from the native int. @@ -871,6 +927,7 @@ public final class Canvas_Delegate { }, paintDelegate, true /*compositeOnly*/, false /*forceSrcMode*/); } + @LayoutlibDelegate /*package*/ static void nativeDrawBitmapMesh(int nCanvas, int nBitmap, int meshWidth, int meshHeight, float[] verts, int vertOffset, @@ -879,6 +936,7 @@ public final class Canvas_Delegate { throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void nativeDrawVertices(int nCanvas, int mode, int n, float[] verts, int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices, @@ -887,6 +945,7 @@ public final class Canvas_Delegate { throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_drawText(int nativeCanvas, final char[] text, final int index, final int count, final float startX, final float startY, int flags, int paint) { @@ -986,6 +1045,7 @@ public final class Canvas_Delegate { }); } + @LayoutlibDelegate /*package*/ static void native_drawText(int nativeCanvas, String text, int start, int end, float x, float y, int flags, int paint) { @@ -996,6 +1056,7 @@ public final class Canvas_Delegate { native_drawText(nativeCanvas, buffer, 0, count, x, y, flags, paint); } + @LayoutlibDelegate /*package*/ static void native_drawTextRun(int nativeCanvas, String text, int start, int end, int contextStart, int contextEnd, float x, float y, int flags, int paint) { @@ -1006,12 +1067,14 @@ public final class Canvas_Delegate { native_drawText(nativeCanvas, buffer, start, end, x, y, flags, paint); } + @LayoutlibDelegate /*package*/ static void native_drawTextRun(int nativeCanvas, char[] text, int start, int count, int contextStart, int contextCount, float x, float y, int flags, int paint) { native_drawText(nativeCanvas, text, start, count, x, y, flags, paint); } + @LayoutlibDelegate /*package*/ static void native_drawPosText(int nativeCanvas, char[] text, int index, int count, float[] pos, @@ -1020,6 +1083,7 @@ public final class Canvas_Delegate { throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_drawPosText(int nativeCanvas, String text, float[] pos, int paint) { @@ -1027,6 +1091,7 @@ public final class Canvas_Delegate { throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_drawTextOnPath(int nativeCanvas, char[] text, int index, int count, int path, @@ -1037,6 +1102,7 @@ public final class Canvas_Delegate { throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_drawTextOnPath(int nativeCanvas, String text, int path, float hOffset, @@ -1046,12 +1112,14 @@ public final class Canvas_Delegate { throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_drawPicture(int nativeCanvas, int nativePicture) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void finalizer(int nativeCanvas) { // get the delegate from the native int so that it can be disposed. Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas); diff --git a/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java index 3df170f..789c6e6 100644 --- a/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/ColorFilter_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.ColorFilter @@ -54,6 +55,7 @@ public abstract class ColorFilter_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static void finalizer(int native_instance, int nativeColorFilter) { sManager.removeDelegate(native_instance); } diff --git a/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java index 4284327..462b1e6 100644 --- a/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/ColorMatrixColorFilter_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.ColorMatrixColorFilter @@ -53,11 +54,13 @@ public class ColorMatrixColorFilter_Delegate extends ColorFilter_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeColorMatrixFilter(float[] array) { ColorMatrixColorFilter_Delegate newDelegate = new ColorMatrixColorFilter_Delegate(); return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static int nColorMatrixFilter(int nativeFilter, float[] array) { // pass return 0; diff --git a/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java index 39cbbc6..2bdaa5b 100644 --- a/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/ComposePathEffect_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.Stroke; @@ -60,6 +61,7 @@ public class ComposePathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate(int outerpe, int innerpe) { ComposePathEffect_Delegate newDelegate = new ComposePathEffect_Delegate(); return sManager.addDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java index b4baa6f..a2ecb8f 100644 --- a/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/ComposeShader_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.Paint; @@ -61,6 +62,7 @@ public class ComposeShader_Delegate extends Shader_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate1(int native_shaderA, int native_shaderB, int native_mode) { // FIXME not supported yet. @@ -68,6 +70,7 @@ public class ComposeShader_Delegate extends Shader_Delegate { return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static int nativeCreate2(int native_shaderA, int native_shaderB, int porterDuffMode) { // FIXME not supported yet. @@ -75,19 +78,20 @@ public class ComposeShader_Delegate extends Shader_Delegate { return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static int nativePostCreate1(int native_shader, int native_skiaShaderA, int native_skiaShaderB, int native_mode) { // pass, not needed. return 0; } + @LayoutlibDelegate /*package*/ static int nativePostCreate2(int native_shader, int native_skiaShaderA, int native_skiaShaderB, int porterDuffMode) { // pass, not needed. return 0; } - // ---- Private delegate/helper methods ---- } diff --git a/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java index 0307cfb..c677de8 100644 --- a/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/CornerPathEffect_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.Stroke; @@ -60,6 +61,7 @@ public class CornerPathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate(float radius) { CornerPathEffect_Delegate newDelegate = new CornerPathEffect_Delegate(); return sManager.addDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java index 5a704a7..12a4d4a 100644 --- a/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/DashPathEffect_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.BasicStroke; import java.awt.Stroke; @@ -71,6 +72,7 @@ public final class DashPathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate(float intervals[], float phase) { DashPathEffect_Delegate newDelegate = new DashPathEffect_Delegate(intervals, phase); return sManager.addDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java index 04d7170..ac69712 100644 --- a/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/DiscretePathEffect_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.Stroke; @@ -60,6 +61,7 @@ public class DiscretePathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate(float length, float deviation) { DiscretePathEffect_Delegate newDelegate = new DiscretePathEffect_Delegate(); return sManager.addDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java index ddf20b6..a98f0a9 100644 --- a/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/DrawFilter_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.DrawFilter @@ -54,6 +55,7 @@ public abstract class DrawFilter_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static void nativeDestructor(int nativeDrawFilter) { sManager.removeDelegate(nativeDrawFilter); } diff --git a/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java index 82f1da3..31f8bbf 100644 --- a/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/EmbossMaskFilter_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.EmbossMaskFilter @@ -53,6 +54,7 @@ public class EmbossMaskFilter_Delegate extends MaskFilter_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeConstructor(float[] direction, float ambient, float specular, float blurRadius) { EmbossMaskFilter_Delegate newDelegate = new EmbossMaskFilter_Delegate(); diff --git a/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java index 132004f9..fcb62a8 100644 --- a/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/LayerRasterizer_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.LayerRasterizer @@ -53,11 +54,13 @@ public class LayerRasterizer_Delegate extends Rasterizer_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeConstructor() { LayerRasterizer_Delegate newDelegate = new LayerRasterizer_Delegate(); return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static void nativeAddLayer(int native_layer, int native_paint, float dx, float dy) { } diff --git a/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java index ba2cfad..b272534 100644 --- a/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/LightingColorFilter_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.LightingColorFilter @@ -53,11 +54,13 @@ public class LightingColorFilter_Delegate extends ColorFilter_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int native_CreateLightingFilter(int mul, int add) { LightingColorFilter_Delegate newDelegate = new LightingColorFilter_Delegate(); return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static int nCreateLightingFilter(int nativeFilter, int mul, int add) { // pass return 0; diff --git a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java index 9525dcf..8060577 100644 --- a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java @@ -19,6 +19,7 @@ package android.graphics; import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.graphics.Shader.TileMode; @@ -52,6 +53,7 @@ public final class LinearGradient_Delegate extends Gradient_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate1(LinearGradient thisGradient, float x0, float y0, float x1, float y1, int colors[], float positions[], int tileMode) { @@ -59,6 +61,8 @@ public final class LinearGradient_Delegate extends Gradient_Delegate { colors, positions, Shader_Delegate.getTileMode(tileMode)); return sManager.addDelegate(newDelegate); } + + @LayoutlibDelegate /*package*/ static int nativeCreate2(LinearGradient thisGradient, float x0, float y0, float x1, float y1, int color0, int color1, int tileMode) { @@ -66,12 +70,16 @@ public final class LinearGradient_Delegate extends Gradient_Delegate { x0, y0, x1, y1, new int[] { color0, color1}, null /*positions*/, tileMode); } + + @LayoutlibDelegate /*package*/ static int nativePostCreate1(LinearGradient thisGradient, int 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, int color0, int color1, int tileMode) { diff --git a/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java index c582a91..4adca27 100644 --- a/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/MaskFilter_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.MaskFilter @@ -54,6 +55,7 @@ public abstract class MaskFilter_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static void nativeDestructor(int native_filter) { sManager.removeDelegate(native_filter); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java index 2d77d40..68a476f 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java @@ -20,6 +20,7 @@ package android.graphics; import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.graphics.Matrix.ScaleToFit; @@ -172,6 +173,7 @@ public final class Matrix_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int native_create(int native_src_or_zero) { // create the delegate Matrix_Delegate newDelegate = new Matrix_Delegate(); @@ -190,6 +192,7 @@ public final class Matrix_Delegate { return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static boolean native_isIdentity(int native_object) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -199,6 +202,7 @@ public final class Matrix_Delegate { return d.isIdentity(); } + @LayoutlibDelegate /*package*/ static boolean native_rectStaysRect(int native_object) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -208,6 +212,7 @@ public final class Matrix_Delegate { return (d.computeTypeMask() & kRectStaysRect_Mask) != 0; } + @LayoutlibDelegate /*package*/ static void native_reset(int native_object) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -217,6 +222,7 @@ public final class Matrix_Delegate { reset(d.mValues); } + @LayoutlibDelegate /*package*/ static void native_set(int native_object, int other) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -231,6 +237,7 @@ public final class Matrix_Delegate { System.arraycopy(src.mValues, 0, d.mValues, 0, MATRIX_SIZE); } + @LayoutlibDelegate /*package*/ static void native_setTranslate(int native_object, float dx, float dy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -240,6 +247,7 @@ public final class Matrix_Delegate { setTranslate(d.mValues, dx, dy); } + @LayoutlibDelegate /*package*/ static void native_setScale(int native_object, float sx, float sy, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); @@ -250,6 +258,7 @@ public final class Matrix_Delegate { d.mValues = getScale(sx, sy, px, py); } + @LayoutlibDelegate /*package*/ static void native_setScale(int native_object, float sx, float sy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -267,6 +276,7 @@ public final class Matrix_Delegate { d.mValues[8] = 1; } + @LayoutlibDelegate /*package*/ static void native_setRotate(int native_object, float degrees, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -276,6 +286,7 @@ public final class Matrix_Delegate { d.mValues = getRotate(degrees, px, py); } + @LayoutlibDelegate /*package*/ static void native_setRotate(int native_object, float degrees) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -285,6 +296,7 @@ public final class Matrix_Delegate { setRotate(d.mValues, degrees); } + @LayoutlibDelegate /*package*/ static void native_setSinCos(int native_object, float sinValue, float cosValue, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); @@ -303,6 +315,7 @@ public final class Matrix_Delegate { d.postTransform(getTranslate(px, py)); } + @LayoutlibDelegate /*package*/ static void native_setSinCos(int native_object, float sinValue, float cosValue) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -312,6 +325,7 @@ public final class Matrix_Delegate { setRotate(d.mValues, sinValue, cosValue); } + @LayoutlibDelegate /*package*/ static void native_setSkew(int native_object, float kx, float ky, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); @@ -322,6 +336,7 @@ public final class Matrix_Delegate { d.mValues = getSkew(kx, ky, px, py); } + @LayoutlibDelegate /*package*/ static void native_setSkew(int native_object, float kx, float ky) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -339,6 +354,7 @@ public final class Matrix_Delegate { d.mValues[8] = 1; } + @LayoutlibDelegate /*package*/ static boolean native_setConcat(int native_object, int a, int b) { if (a == native_object) { return native_preConcat(native_object, b); @@ -366,6 +382,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_preTranslate(int native_object, float dx, float dy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -376,6 +393,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_preScale(int native_object, float sx, float sy, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); @@ -387,6 +405,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_preScale(int native_object, float sx, float sy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -397,6 +416,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_preRotate(int native_object, float degrees, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); @@ -408,6 +428,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_preRotate(int native_object, float degrees) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -422,6 +443,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_preSkew(int native_object, float kx, float ky, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); @@ -433,6 +455,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_preSkew(int native_object, float kx, float ky) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -443,6 +466,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_preConcat(int native_object, int other_matrix) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -458,6 +482,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_postTranslate(int native_object, float dx, float dy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -468,6 +493,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_postScale(int native_object, float sx, float sy, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); @@ -479,6 +505,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_postScale(int native_object, float sx, float sy) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -489,6 +516,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_postRotate(int native_object, float degrees, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); @@ -500,6 +528,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_postRotate(int native_object, float degrees) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -510,6 +539,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_postSkew(int native_object, float kx, float ky, float px, float py) { Matrix_Delegate d = sManager.getDelegate(native_object); @@ -521,6 +551,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_postSkew(int native_object, float kx, float ky) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -531,6 +562,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_postConcat(int native_object, int other_matrix) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -546,6 +578,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_setRectToRect(int native_object, RectF src, RectF dst, int stf) { Matrix_Delegate d = sManager.getDelegate(native_object); @@ -610,6 +643,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean native_setPolyToPoly(int native_object, float[] src, int srcIndex, float[] dst, int dstIndex, int pointCount) { // FIXME @@ -619,6 +653,7 @@ public final class Matrix_Delegate { return false; } + @LayoutlibDelegate /*package*/ static boolean native_invert(int native_object, int inverse) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -646,6 +681,7 @@ public final class Matrix_Delegate { } } + @LayoutlibDelegate /*package*/ static void native_mapPoints(int native_object, float[] dst, int dstIndex, float[] src, int srcIndex, int ptCount, boolean isPts) { Matrix_Delegate d = sManager.getDelegate(native_object); @@ -660,6 +696,7 @@ public final class Matrix_Delegate { } } + @LayoutlibDelegate /*package*/ static boolean native_mapRect(int native_object, RectF dst, RectF src) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -669,6 +706,7 @@ public final class Matrix_Delegate { return d.mapRect(dst, src); } + @LayoutlibDelegate /*package*/ static float native_mapRadius(int native_object, float radius) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -684,6 +722,7 @@ public final class Matrix_Delegate { return (float) Math.sqrt(l1 * l2); } + @LayoutlibDelegate /*package*/ static void native_getValues(int native_object, float[] values) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -693,6 +732,7 @@ public final class Matrix_Delegate { System.arraycopy(d.mValues, 0, d.mValues, 0, MATRIX_SIZE); } + @LayoutlibDelegate /*package*/ static void native_setValues(int native_object, float[] values) { Matrix_Delegate d = sManager.getDelegate(native_object); if (d == null) { @@ -702,6 +742,7 @@ public final class Matrix_Delegate { System.arraycopy(values, 0, d.mValues, 0, MATRIX_SIZE); } + @LayoutlibDelegate /*package*/ static boolean native_equals(int native_a, int native_b) { Matrix_Delegate a = sManager.getDelegate(native_a); if (a == null) { @@ -722,6 +763,7 @@ public final class Matrix_Delegate { return true; } + @LayoutlibDelegate /*package*/ static void finalizer(int native_instance) { sManager.removeDelegate(native_instance); } diff --git a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java index 61ed71e..5e882ce 100644 --- a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java @@ -21,6 +21,7 @@ import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; import com.android.layoutlib.bridge.impl.GcSnapshot; import com.android.ninepatch.NinePatchChunk; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.graphics.drawable.NinePatchDrawable; @@ -137,6 +138,7 @@ public final class NinePatch_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static boolean isNinePatchChunk(byte[] chunk) { NinePatchChunk chunkObject = getChunk(chunk); if (chunkObject != null) { @@ -146,12 +148,14 @@ public final class NinePatch_Delegate { return false; } + @LayoutlibDelegate /*package*/ static void validateNinePatchChunk(int 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. } + @LayoutlibDelegate /*package*/ static void nativeDraw(int canvas_instance, RectF loc, int bitmap_instance, byte[] c, int paint_instance_or_null, int destDensity, int srcDensity) { draw(canvas_instance, @@ -160,6 +164,7 @@ public final class NinePatch_Delegate { destDensity, srcDensity); } + @LayoutlibDelegate /*package*/ static void nativeDraw(int canvas_instance, Rect loc, int bitmap_instance, byte[] c, int paint_instance_or_null, int destDensity, int srcDensity) { draw(canvas_instance, @@ -168,54 +173,53 @@ public final class NinePatch_Delegate { destDensity, srcDensity); } - private static void draw(int canvas_instance, - final int left, final int top, final int right, final int bottom, - int bitmap_instance, byte[] c, int 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); - if (bitmap_delegate == null) { - return; - } - - if (c == null) { - // not a 9-patch? - BufferedImage image = bitmap_delegate.getImage(); - Canvas_Delegate.native_drawBitmap(canvas_instance, bitmap_instance, - new Rect(0, 0, image.getWidth(), image.getHeight()), - new Rect(left, top, right, bottom), - paint_instance_or_null, destDensity, srcDensity); - return; - } - - final NinePatchChunk chunkObject = getChunk(c); - assert chunkObject != null; - if (chunkObject == null) { - return; - } - - Canvas_Delegate canvas_delegate = Canvas_Delegate.getDelegate(canvas_instance); - if (canvas_delegate == null) { - return; - } - - // this one can be null - Paint_Delegate paint_delegate = Paint_Delegate.getDelegate(paint_instance_or_null); - - canvas_delegate.getSnapshot().draw(new GcSnapshot.Drawable() { - public void draw(Graphics2D graphics, Paint_Delegate paint) { - chunkObject.draw(bitmap_delegate.getImage(), graphics, - left, top, right - left, bottom - top, destDensity, srcDensity); - } - }, paint_delegate, true /*compositeOnly*/, false /*forceSrcMode*/); - - } - + @LayoutlibDelegate /*package*/ static int nativeGetTransparentRegion(int bitmap, byte[] chunk, Rect location) { return 0; } // ---- Private Helper methods ---- + private static void draw(int canvas_instance, + final int left, final int top, final int right, final int bottom, + int bitmap_instance, byte[] c, int 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); + if (bitmap_delegate == null) { + return; + } + + if (c == null) { + // not a 9-patch? + BufferedImage image = bitmap_delegate.getImage(); + Canvas_Delegate.native_drawBitmap(canvas_instance, bitmap_instance, + new Rect(0, 0, image.getWidth(), image.getHeight()), + new Rect(left, top, right, bottom), + paint_instance_or_null, destDensity, srcDensity); + return; + } + + final NinePatchChunk chunkObject = getChunk(c); + assert chunkObject != null; + if (chunkObject == null) { + return; + } + + Canvas_Delegate canvas_delegate = Canvas_Delegate.getDelegate(canvas_instance); + if (canvas_delegate == null) { + return; + } + + // this one can be null + Paint_Delegate paint_delegate = Paint_Delegate.getDelegate(paint_instance_or_null); + + canvas_delegate.getSnapshot().draw(new GcSnapshot.Drawable() { + public void draw(Graphics2D graphics, Paint_Delegate paint) { + chunkObject.draw(bitmap_delegate.getImage(), graphics, + left, top, right - left, bottom - top, destDensity, srcDensity); + } + }, paint_delegate, true /*compositeOnly*/, false /*forceSrcMode*/); + } } diff --git a/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java index ec92507..dfcb591 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PaintFlagsDrawFilter_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.PaintFlagsDrawFilter @@ -53,6 +54,7 @@ public class PaintFlagsDrawFilter_Delegate extends DrawFilter_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeConstructor(int clearBits, int setBits) { PaintFlagsDrawFilter_Delegate newDelegate = new PaintFlagsDrawFilter_Delegate(); return sManager.addDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java index 87164fb..39c8a37 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java @@ -19,6 +19,7 @@ package android.graphics; import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.graphics.Paint.FontMetrics; import android.graphics.Paint.FontMetricsInt; @@ -241,6 +242,7 @@ public class Paint_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int getFlags(Paint thisPaint) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -251,6 +253,7 @@ public class Paint_Delegate { return delegate.mFlags; } + @LayoutlibDelegate /*package*/ static void setFlags(Paint thisPaint, int flags) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -261,38 +264,47 @@ public class Paint_Delegate { delegate.mFlags = flags; } + @LayoutlibDelegate /*package*/ static void setFilterBitmap(Paint thisPaint, boolean filter) { setFlag(thisPaint, Paint.FILTER_BITMAP_FLAG, filter); } + @LayoutlibDelegate /*package*/ static void setAntiAlias(Paint thisPaint, boolean aa) { setFlag(thisPaint, Paint.ANTI_ALIAS_FLAG, aa); } + @LayoutlibDelegate /*package*/ static void setSubpixelText(Paint thisPaint, boolean subpixelText) { setFlag(thisPaint, Paint.SUBPIXEL_TEXT_FLAG, subpixelText); } + @LayoutlibDelegate /*package*/ static void setUnderlineText(Paint thisPaint, boolean underlineText) { setFlag(thisPaint, Paint.UNDERLINE_TEXT_FLAG, underlineText); } + @LayoutlibDelegate /*package*/ static void setStrikeThruText(Paint thisPaint, boolean strikeThruText) { setFlag(thisPaint, Paint.STRIKE_THRU_TEXT_FLAG, strikeThruText); } + @LayoutlibDelegate /*package*/ static void setFakeBoldText(Paint thisPaint, boolean fakeBoldText) { setFlag(thisPaint, Paint.FAKE_BOLD_TEXT_FLAG, fakeBoldText); } + @LayoutlibDelegate /*package*/ static void setDither(Paint thisPaint, boolean dither) { setFlag(thisPaint, Paint.DITHER_FLAG, dither); } + @LayoutlibDelegate /*package*/ static void setLinearText(Paint thisPaint, boolean linearText) { setFlag(thisPaint, Paint.LINEAR_TEXT_FLAG, linearText); } + @LayoutlibDelegate /*package*/ static int getColor(Paint thisPaint) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -303,6 +315,7 @@ public class Paint_Delegate { return delegate.mColor; } + @LayoutlibDelegate /*package*/ static void setColor(Paint thisPaint, int color) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -313,6 +326,7 @@ public class Paint_Delegate { delegate.mColor = color; } + @LayoutlibDelegate /*package*/ static int getAlpha(Paint thisPaint) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -323,6 +337,7 @@ public class Paint_Delegate { return delegate.getAlpha(); } + @LayoutlibDelegate /*package*/ static void setAlpha(Paint thisPaint, int a) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -333,6 +348,7 @@ public class Paint_Delegate { delegate.setAlpha(a); } + @LayoutlibDelegate /*package*/ static float getStrokeWidth(Paint thisPaint) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -343,6 +359,7 @@ public class Paint_Delegate { return delegate.mStrokeWidth; } + @LayoutlibDelegate /*package*/ static void setStrokeWidth(Paint thisPaint, float width) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -353,6 +370,7 @@ public class Paint_Delegate { delegate.mStrokeWidth = width; } + @LayoutlibDelegate /*package*/ static float getStrokeMiter(Paint thisPaint) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -363,6 +381,7 @@ public class Paint_Delegate { return delegate.mStrokeMiter; } + @LayoutlibDelegate /*package*/ static void setStrokeMiter(Paint thisPaint, float miter) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -373,6 +392,7 @@ public class Paint_Delegate { delegate.mStrokeMiter = miter; } + @LayoutlibDelegate /*package*/ static void nSetShadowLayer(Paint thisPaint, float radius, float dx, float dy, int color) { // FIXME @@ -380,6 +400,7 @@ public class Paint_Delegate { "Paint.setShadowLayer is not supported.", null, null /*data*/); } + @LayoutlibDelegate /*package*/ static float getTextSize(Paint thisPaint) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -390,6 +411,7 @@ public class Paint_Delegate { return delegate.mTextSize; } + @LayoutlibDelegate /*package*/ static void setTextSize(Paint thisPaint, float textSize) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -401,6 +423,7 @@ public class Paint_Delegate { delegate.updateFontObject(); } + @LayoutlibDelegate /*package*/ static float getTextScaleX(Paint thisPaint) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -411,6 +434,7 @@ public class Paint_Delegate { return delegate.mTextScaleX; } + @LayoutlibDelegate /*package*/ static void setTextScaleX(Paint thisPaint, float scaleX) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -422,6 +446,7 @@ public class Paint_Delegate { delegate.updateFontObject(); } + @LayoutlibDelegate /*package*/ static float getTextSkewX(Paint thisPaint) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -432,6 +457,7 @@ public class Paint_Delegate { return delegate.mTextSkewX; } + @LayoutlibDelegate /*package*/ static void setTextSkewX(Paint thisPaint, float skewX) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -443,6 +469,7 @@ public class Paint_Delegate { delegate.updateFontObject(); } + @LayoutlibDelegate /*package*/ static float ascent(Paint thisPaint) { // get the delegate Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -459,6 +486,7 @@ public class Paint_Delegate { return 0; } + @LayoutlibDelegate /*package*/ static float descent(Paint thisPaint) { // get the delegate Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -475,6 +503,7 @@ public class Paint_Delegate { } + @LayoutlibDelegate /*package*/ static float getFontMetrics(Paint thisPaint, FontMetrics metrics) { // get the delegate Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -485,6 +514,7 @@ public class Paint_Delegate { return delegate.getFontMetrics(metrics); } + @LayoutlibDelegate /*package*/ static int getFontMetricsInt(Paint thisPaint, FontMetricsInt fmi) { // get the delegate Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint); @@ -509,6 +539,7 @@ public class Paint_Delegate { return 0; } + @LayoutlibDelegate /*package*/ static float native_measureText(Paint thisPaint, char[] text, int index, int count) { // WARNING: the logic in this method is similar to Canvas.drawText. @@ -523,32 +554,37 @@ public class Paint_Delegate { return delegate.measureText(text, index, count); } + @LayoutlibDelegate /*package*/ static float native_measureText(Paint thisPaint, String text, int start, int end) { return native_measureText(thisPaint, text.toCharArray(), start, end - start); } + @LayoutlibDelegate /*package*/ static float native_measureText(Paint thisPaint, String text) { return native_measureText(thisPaint, text.toCharArray(), 0, text.length()); } + @LayoutlibDelegate /*package*/ static int native_breakText(Paint thisPaint, char[] text, int index, int count, float maxWidth, float[] measuredWidth) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static int native_breakText(Paint thisPaint, String text, boolean measureForwards, float maxWidth, float[] measuredWidth) { // FIXME throw new UnsupportedOperationException(); } - + @LayoutlibDelegate /*package*/ static int native_init() { Paint_Delegate newDelegate = new Paint_Delegate(); return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static int native_initWithPaint(int paint) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(paint); @@ -560,6 +596,7 @@ public class Paint_Delegate { return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static void native_reset(int native_object) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -570,6 +607,7 @@ public class Paint_Delegate { delegate.reset(); } + @LayoutlibDelegate /*package*/ static void native_set(int native_dst, int native_src) { // get the delegate from the native int. Paint_Delegate delegate_dst = sManager.getDelegate(native_dst); @@ -586,6 +624,7 @@ public class Paint_Delegate { delegate_dst.set(delegate_src); } + @LayoutlibDelegate /*package*/ static int native_getStyle(int native_object) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -596,6 +635,7 @@ public class Paint_Delegate { return delegate.mStyle; } + @LayoutlibDelegate /*package*/ static void native_setStyle(int native_object, int style) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -606,6 +646,7 @@ public class Paint_Delegate { delegate.mStyle = style; } + @LayoutlibDelegate /*package*/ static int native_getStrokeCap(int native_object) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -616,6 +657,7 @@ public class Paint_Delegate { return delegate.mCap; } + @LayoutlibDelegate /*package*/ static void native_setStrokeCap(int native_object, int cap) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -626,6 +668,7 @@ public class Paint_Delegate { delegate.mCap = cap; } + @LayoutlibDelegate /*package*/ static int native_getStrokeJoin(int native_object) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -636,6 +679,7 @@ public class Paint_Delegate { return delegate.mJoin; } + @LayoutlibDelegate /*package*/ static void native_setStrokeJoin(int native_object, int join) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -646,6 +690,7 @@ public class Paint_Delegate { delegate.mJoin = join; } + @LayoutlibDelegate /*package*/ static boolean native_getFillPath(int native_object, int src, int dst) { Paint_Delegate paint = sManager.getDelegate(native_object); if (paint == null) { @@ -671,6 +716,7 @@ public class Paint_Delegate { return true; } + @LayoutlibDelegate /*package*/ static int native_setShader(int native_object, int shader) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -681,6 +727,7 @@ public class Paint_Delegate { return delegate.mShader = shader; } + @LayoutlibDelegate /*package*/ static int native_setColorFilter(int native_object, int filter) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -700,6 +747,7 @@ public class Paint_Delegate { return filter; } + @LayoutlibDelegate /*package*/ static int native_setXfermode(int native_object, int xfermode) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -710,6 +758,7 @@ public class Paint_Delegate { return delegate.mXfermode = xfermode; } + @LayoutlibDelegate /*package*/ static int native_setPathEffect(int native_object, int effect) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -720,6 +769,7 @@ public class Paint_Delegate { return delegate.mPathEffect = effect; } + @LayoutlibDelegate /*package*/ static int native_setMaskFilter(int native_object, int maskfilter) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -739,6 +789,7 @@ public class Paint_Delegate { return maskfilter; } + @LayoutlibDelegate /*package*/ static int native_setTypeface(int native_object, int typeface) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -751,6 +802,7 @@ public class Paint_Delegate { return delegate.mTypeface; } + @LayoutlibDelegate /*package*/ static int native_setRasterizer(int native_object, int rasterizer) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -770,6 +822,7 @@ public class Paint_Delegate { return rasterizer; } + @LayoutlibDelegate /*package*/ static int native_getTextAlign(int native_object) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -780,6 +833,7 @@ public class Paint_Delegate { return delegate.mTextAlign; } + @LayoutlibDelegate /*package*/ static void native_setTextAlign(int native_object, int align) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); @@ -790,6 +844,7 @@ public class Paint_Delegate { delegate.mTextAlign = align; } + @LayoutlibDelegate /*package*/ static float native_getFontMetrics(int native_paint, FontMetrics metrics) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_paint); @@ -800,18 +855,21 @@ public class Paint_Delegate { return delegate.getFontMetrics(metrics); } + @LayoutlibDelegate /*package*/ static int native_getTextWidths(int native_object, char[] text, int index, int count, float[] widths) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static int native_getTextWidths(int native_object, String text, int start, int end, float[] widths) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static float native_getTextRunAdvances(int native_object, char[] text, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex) { @@ -855,6 +913,7 @@ public class Paint_Delegate { } + @LayoutlibDelegate /*package*/ static float native_getTextRunAdvances(int native_object, String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex) { @@ -867,42 +926,49 @@ public class Paint_Delegate { contextEnd - contextStart, flags, advances, advancesIndex); } + @LayoutlibDelegate /*package*/ static int native_getTextRunCursor(Paint thisPaint, int native_object, char[] text, int contextStart, int contextLength, int flags, int offset, int cursorOpt) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static int native_getTextRunCursor(Paint thisPaint, int native_object, String text, int contextStart, int contextEnd, int flags, int offset, int cursorOpt) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_getTextPath(int native_object, int bidiFlags, char[] text, int index, int count, float x, float y, int path) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_getTextPath(int native_object, int bidiFlags, String text, int start, int end, float x, float y, int path) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void nativeGetStringBounds(int nativePaint, String text, int start, int end, Rect bounds) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void nativeGetCharArrayBounds(int nativePaint, char[] text, int index, int count, Rect bounds) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void finalizer(int nativePaint) { sManager.removeDelegate(nativePaint); } diff --git a/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java index d12bfea..98a5386 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PathDashPathEffect_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.Stroke; @@ -60,6 +61,7 @@ public class PathDashPathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate(int native_path, float advance, float phase, int native_style) { PathDashPathEffect_Delegate newDelegate = new PathDashPathEffect_Delegate(); diff --git a/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java index c588423..bbbebdd 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PathEffect_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.Stroke; @@ -58,6 +59,7 @@ public abstract class PathEffect_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static void nativeDestructor(int native_patheffect) { sManager.removeDelegate(native_patheffect); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java index a4e43c1..6c15a1a 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java @@ -19,6 +19,7 @@ package android.graphics; import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.graphics.Path.Direction; import android.graphics.Path.FillType; @@ -84,6 +85,7 @@ public final class Path_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int init1() { // create the delegate Path_Delegate newDelegate = new Path_Delegate(); @@ -91,6 +93,7 @@ public final class Path_Delegate { return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static int init2(int nPath) { // create the delegate Path_Delegate newDelegate = new Path_Delegate(); @@ -104,6 +107,7 @@ public final class Path_Delegate { return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static void native_reset(int nPath) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -113,12 +117,14 @@ public final class Path_Delegate { pathDelegate.mPath.reset(); } + @LayoutlibDelegate /*package*/ static void native_rewind(int 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) { Path_Delegate pathDstDelegate = sManager.getDelegate(native_dst); if (pathDstDelegate == null) { @@ -133,6 +139,7 @@ public final class Path_Delegate { pathDstDelegate.set(pathSrcDelegate); } + @LayoutlibDelegate /*package*/ static int native_getFillType(int nPath) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -142,6 +149,7 @@ public final class Path_Delegate { return pathDelegate.mFillType.nativeInt; } + @LayoutlibDelegate /*package*/ static void native_setFillType(int nPath, int ft) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -151,6 +159,7 @@ public final class Path_Delegate { pathDelegate.mFillType = Path.sFillTypeArray[ft]; } + @LayoutlibDelegate /*package*/ static boolean native_isEmpty(int nPath) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -160,6 +169,7 @@ public final class Path_Delegate { return pathDelegate.isEmpty(); } + @LayoutlibDelegate /*package*/ static boolean native_isRect(int nPath, RectF rect) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -179,6 +189,7 @@ public final class Path_Delegate { return false; } + @LayoutlibDelegate /*package*/ static void native_computeBounds(int nPath, RectF bounds) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -188,11 +199,13 @@ public final class Path_Delegate { pathDelegate.fillBounds(bounds); } + @LayoutlibDelegate /*package*/ static void native_incReserve(int 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) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -202,6 +215,7 @@ public final class Path_Delegate { pathDelegate.moveTo(x, y); } + @LayoutlibDelegate /*package*/ static void native_rMoveTo(int nPath, float dx, float dy) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -211,6 +225,7 @@ public final class Path_Delegate { pathDelegate.rMoveTo(dx, dy); } + @LayoutlibDelegate /*package*/ static void native_lineTo(int nPath, float x, float y) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -220,6 +235,7 @@ public final class Path_Delegate { pathDelegate.lineTo(x, y); } + @LayoutlibDelegate /*package*/ static void native_rLineTo(int nPath, float dx, float dy) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -229,6 +245,7 @@ public final class Path_Delegate { pathDelegate.rLineTo(dx, dy); } + @LayoutlibDelegate /*package*/ static void native_quadTo(int nPath, float x1, float y1, float x2, float y2) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -238,6 +255,7 @@ public final class Path_Delegate { pathDelegate.quadTo(x1, y1, x2, y2); } + @LayoutlibDelegate /*package*/ static void native_rQuadTo(int nPath, float dx1, float dy1, float dx2, float dy2) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -247,6 +265,7 @@ public final class Path_Delegate { pathDelegate.rQuadTo(dx1, dy1, dx2, dy2); } + @LayoutlibDelegate /*package*/ static void native_cubicTo(int nPath, float x1, float y1, float x2, float y2, float x3, float y3) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); @@ -257,6 +276,7 @@ public final class Path_Delegate { pathDelegate.cubicTo(x1, y1, x2, y2, x3, y3); } + @LayoutlibDelegate /*package*/ static void native_rCubicTo(int nPath, float x1, float y1, float x2, float y2, float x3, float y3) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); @@ -267,6 +287,7 @@ public final class Path_Delegate { pathDelegate.rCubicTo(x1, y1, x2, y2, x3, y3); } + @LayoutlibDelegate /*package*/ static void native_arcTo(int nPath, RectF oval, float startAngle, float sweepAngle, boolean forceMoveTo) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); @@ -277,6 +298,7 @@ public final class Path_Delegate { pathDelegate.arcTo(oval, startAngle, sweepAngle, forceMoveTo); } + @LayoutlibDelegate /*package*/ static void native_close(int nPath) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -286,6 +308,7 @@ public final class Path_Delegate { pathDelegate.close(); } + @LayoutlibDelegate /*package*/ static void native_addRect(int nPath, RectF rect, int dir) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -295,6 +318,7 @@ public final class Path_Delegate { pathDelegate.addRect(rect.left, rect.top, rect.right, rect.bottom, dir); } + @LayoutlibDelegate /*package*/ static void native_addRect(int nPath, float left, float top, float right, float bottom, int dir) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); @@ -305,47 +329,56 @@ public final class Path_Delegate { pathDelegate.addRect(left, top, right, bottom, dir); } + @LayoutlibDelegate /*package*/ static void native_addOval(int nPath, RectF oval, int dir) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_addCircle(int nPath, float x, float y, float radius, int dir) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_addArc(int nPath, RectF oval, float startAngle, float sweepAngle) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_addRoundRect(int nPath, RectF rect, float rx, float ry, int dir) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_addRoundRect(int nPath, RectF r, float[] radii, int dir) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_addPath(int nPath, int src, float dx, float dy) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_addPath(int nPath, int src) { native_addPath(nPath, src, 0, 0); } + @LayoutlibDelegate /*package*/ static void native_addPath(int nPath, int src, int matrix) { // FIXME throw new UnsupportedOperationException(); } + @LayoutlibDelegate /*package*/ static void native_offset(int nPath, float dx, float dy, int dst_path) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -358,10 +391,12 @@ public final class Path_Delegate { pathDelegate.offset(dx, dy, dstDelegate); } + @LayoutlibDelegate /*package*/ static void native_offset(int nPath, float dx, float dy) { native_offset(nPath, dx, dy, 0); } + @LayoutlibDelegate /*package*/ static void native_setLastPoint(int nPath, float dx, float dy) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); if (pathDelegate == null) { @@ -372,6 +407,7 @@ public final class Path_Delegate { pathDelegate.mLastY = dy; } + @LayoutlibDelegate /*package*/ static void native_transform(int nPath, int matrix, int dst_path) { Path_Delegate pathDelegate = sManager.getDelegate(nPath); @@ -390,10 +426,12 @@ public final class Path_Delegate { pathDelegate.transform(matrixDelegate, dstDelegate); } + @LayoutlibDelegate /*package*/ static void native_transform(int nPath, int matrix) { native_transform(nPath, matrix, 0); } + @LayoutlibDelegate /*package*/ static void finalizer(int nPath) { sManager.removeDelegate(nPath); } diff --git a/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java index 516a2b9..bbb20e9 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PixelXorXfermode_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.Composite; @@ -59,6 +60,7 @@ public class PixelXorXfermode_Delegate extends Xfermode_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate(int opColor) { PixelXorXfermode_Delegate newDelegate = new PixelXorXfermode_Delegate(); return sManager.addDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java index 9038636..33f6c44 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.PorterDuffColorFilter @@ -53,11 +54,13 @@ public class PorterDuffColorFilter_Delegate extends ColorFilter_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int native_CreatePorterDuffFilter(int srcColor, int porterDuffMode) { PorterDuffColorFilter_Delegate newDelegate = new PorterDuffColorFilter_Delegate(); return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static int nCreatePorterDuffFilter(int nativeFilter, int srcColor, int porterDuffMode) { // pass diff --git a/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java index 147e1d0..116a773 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java @@ -19,6 +19,7 @@ package android.graphics; import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.AlphaComposite; import java.awt.Composite; @@ -125,6 +126,7 @@ public class PorterDuffXfermode_Delegate extends Xfermode_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreateXfermode(int mode) { PorterDuffXfermode_Delegate newDelegate = new PorterDuffXfermode_Delegate(mode); return sManager.addDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java index ffdf5dd..8723ed1 100644 --- a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java @@ -19,6 +19,7 @@ package android.graphics; import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.graphics.Shader.TileMode; @@ -52,6 +53,7 @@ public class RadialGradient_Delegate extends Gradient_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate1(float x, float y, float radius, int colors[], float positions[], int tileMode) { RadialGradient_Delegate newDelegate = new RadialGradient_Delegate(x, y, radius, @@ -59,18 +61,21 @@ public class RadialGradient_Delegate extends Gradient_Delegate { return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static int 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, 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, int color0, int color1, int tileMode) { // nothing to be done here. diff --git a/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java index 9fd67be..2826278 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Rasterizer_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.Rasterizer @@ -54,6 +55,7 @@ public abstract class Rasterizer_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static void finalizer(int native_instance) { sManager.removeDelegate(native_instance); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java index d2b6b27..7b91215 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java @@ -19,6 +19,7 @@ package android.graphics; import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.os.Parcel; @@ -136,6 +137,7 @@ public class Region_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static boolean isEmpty(Region thisRegion) { Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion); if (regionDelegate == null) { @@ -145,6 +147,7 @@ public class Region_Delegate { return regionDelegate.mArea.isEmpty(); } + @LayoutlibDelegate /*package*/ static boolean isRect(Region thisRegion) { Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion); if (regionDelegate == null) { @@ -154,6 +157,7 @@ public class Region_Delegate { return regionDelegate.mArea.isRectangular(); } + @LayoutlibDelegate /*package*/ static boolean isComplex(Region thisRegion) { Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion); if (regionDelegate == null) { @@ -163,6 +167,7 @@ public class Region_Delegate { return regionDelegate.mArea.isSingular() == false; } + @LayoutlibDelegate /*package*/ static boolean contains(Region thisRegion, int x, int y) { Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion); if (regionDelegate == null) { @@ -172,6 +177,7 @@ public class Region_Delegate { return regionDelegate.mArea.contains(x, y); } + @LayoutlibDelegate /*package*/ static boolean quickContains(Region thisRegion, int left, int top, int right, int bottom) { Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion); @@ -183,6 +189,7 @@ public class Region_Delegate { regionDelegate.mArea.contains(left, top, right - left, bottom - top); } + @LayoutlibDelegate /*package*/ static boolean quickReject(Region thisRegion, int left, int top, int right, int bottom) { Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion); @@ -194,6 +201,7 @@ public class Region_Delegate { regionDelegate.mArea.intersects(left, top, right - left, bottom - top) == false; } + @LayoutlibDelegate /*package*/ static boolean quickReject(Region thisRegion, Region rgn) { Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion); if (regionDelegate == null) { @@ -211,6 +219,7 @@ public class Region_Delegate { } + @LayoutlibDelegate /*package*/ static void translate(Region thisRegion, int dx, int dy, Region dst) { Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion); if (regionDelegate == null) { @@ -232,6 +241,7 @@ public class Region_Delegate { } } + @LayoutlibDelegate /*package*/ static void scale(Region thisRegion, float scale, Region dst) { Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion); if (regionDelegate == null) { @@ -253,15 +263,18 @@ public class Region_Delegate { } } + @LayoutlibDelegate /*package*/ static int nativeConstructor() { Region_Delegate newDelegate = new Region_Delegate(); return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static void nativeDestructor(int native_region) { sManager.removeDelegate(native_region); } + @LayoutlibDelegate /*package*/ static boolean nativeSetRegion(int native_dst, int native_src) { Region_Delegate dstRegion = sManager.getDelegate(native_dst); if (dstRegion == null) { @@ -279,6 +292,7 @@ public class Region_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean nativeSetRect(int native_dst, int left, int top, int right, int bottom) { Region_Delegate dstRegion = sManager.getDelegate(native_dst); @@ -290,6 +304,7 @@ public class Region_Delegate { return dstRegion.mArea.getBounds().isEmpty() == false; } + @LayoutlibDelegate /*package*/ static boolean nativeSetPath(int native_dst, int native_path, int native_clip) { Region_Delegate dstRegion = sManager.getDelegate(native_dst); if (dstRegion == null) { @@ -311,6 +326,7 @@ public class Region_Delegate { return dstRegion.mArea.getBounds().isEmpty() == false; } + @LayoutlibDelegate /*package*/ static boolean nativeGetBounds(int native_region, Rect rect) { Region_Delegate region = sManager.getDelegate(native_region); if (region == null) { @@ -330,6 +346,7 @@ public class Region_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean nativeGetBoundaryPath(int native_region, int native_path) { Region_Delegate region = sManager.getDelegate(native_region); if (region == null) { @@ -350,6 +367,7 @@ public class Region_Delegate { return true; } + @LayoutlibDelegate /*package*/ static boolean nativeOp(int native_dst, int left, int top, int right, int bottom, int op) { Region_Delegate region = sManager.getDelegate(native_dst); @@ -368,6 +386,7 @@ public class Region_Delegate { return region.mArea.getBounds().isEmpty() == false; } + @LayoutlibDelegate /*package*/ static boolean nativeOp(int native_dst, Rect rect, int native_region, int op) { Region_Delegate region = sManager.getDelegate(native_dst); if (region == null) { @@ -385,6 +404,7 @@ public class Region_Delegate { return region.mArea.getBounds().isEmpty() == false; } + @LayoutlibDelegate /*package*/ static boolean nativeOp(int native_dst, int native_region1, int native_region2, int op) { Region_Delegate dstRegion = sManager.getDelegate(native_dst); @@ -413,6 +433,7 @@ public class Region_Delegate { } + @LayoutlibDelegate /*package*/ static int 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. @@ -422,6 +443,7 @@ public class Region_Delegate { return 0; } + @LayoutlibDelegate /*package*/ static boolean nativeWriteToParcel(int native_region, Parcel p) { // This is only called when sending a region through aidl, so really this should not @@ -432,6 +454,7 @@ public class Region_Delegate { return false; } + @LayoutlibDelegate /*package*/ static boolean nativeEquals(int native_r1, int native_r2) { Region_Delegate region1 = sManager.getDelegate(native_r1); if (region1 == null) { @@ -446,6 +469,7 @@ public class Region_Delegate { return region1.mArea.equals(region2.mArea); } + @LayoutlibDelegate /*package*/ static String nativeToString(int native_region) { Region_Delegate region = sManager.getDelegate(native_region); if (region == null) { diff --git a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java index 7903ac9..a1b8bdd 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.graphics.Shader.TileMode; @@ -74,36 +75,12 @@ public abstract class Shader_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static void nativeDestructor(int native_shader, int native_skiaShader) { sManager.removeDelegate(native_shader); } - /*package*/ static boolean nativeGetLocalMatrix(int native_shader, int matrix_instance) { - // get the delegate from the native int. - Shader_Delegate shaderDelegate = sManager.getDelegate(native_shader); - if (shaderDelegate == null) { - return false; - } - - // can be null if shader has no matrix (int is 0) - Matrix_Delegate localMatrixDelegate = Matrix_Delegate.getDelegate( - shaderDelegate.mLocalMatrix); - - // can be null if the int is 0. - Matrix_Delegate destMatrixDelegate = Matrix_Delegate.getDelegate(matrix_instance); - if (destMatrixDelegate != null) { - if (localMatrixDelegate != null) { - destMatrixDelegate.set(localMatrixDelegate); - } else { - // since there's no local matrix, it's considered to be the identity, reset - // the destination matrix - destMatrixDelegate.reset(); - } - } - - return localMatrixDelegate == null || localMatrixDelegate.isIdentity(); - } - + @LayoutlibDelegate /*package*/ static void nativeSetLocalMatrix(int native_shader, int native_skiaShader, int matrix_instance) { // get the delegate from the native int. diff --git a/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java index 0f92ca5..0c9ee48 100644 --- a/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/SumPathEffect_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.Stroke; @@ -60,6 +61,7 @@ public class SumPathEffect_Delegate extends PathEffect_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate(int first, int second) { SumPathEffect_Delegate newDelegate = new SumPathEffect_Delegate(); return sManager.addDelegate(newDelegate); diff --git a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java index 048990a..382e34c 100644 --- a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java @@ -19,6 +19,7 @@ package android.graphics; import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.graphics.SweepGradient @@ -50,21 +51,25 @@ public class SweepGradient_Delegate extends Gradient_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static int nativeCreate1(float x, float y, int colors[], float positions[]) { SweepGradient_Delegate newDelegate = new SweepGradient_Delegate(x, y, colors, positions); return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static int 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, int[] colors, float[] positions) { // nothing to be done here. return 0; } + @LayoutlibDelegate /*package*/ static int nativePostCreate2(int native_shader, float cx, float cy, int color0, int color1) { // nothing to be done here. diff --git a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java index 00a2a57..1992341 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java @@ -20,6 +20,7 @@ import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; import com.android.layoutlib.bridge.impl.FontLoader; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import android.content.res.AssetManager; @@ -88,6 +89,7 @@ public final class Typeface_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static synchronized int nativeCreate(String familyName, int style) { if (familyName == null) { familyName = DEFAULT_FAMILY; @@ -106,6 +108,7 @@ public final class Typeface_Delegate { return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static synchronized int nativeCreateFromTypeface(int native_instance, int style) { Typeface_Delegate delegate = sManager.getDelegate(native_instance); if (delegate == null) { @@ -125,22 +128,26 @@ public final class Typeface_Delegate { return sManager.addDelegate(newDelegate); } + @LayoutlibDelegate /*package*/ static synchronized int 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) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Typeface.createFromFile() is not supported.", null /*throwable*/, null /*data*/); return 0; } + @LayoutlibDelegate /*package*/ static void nativeUnref(int native_instance) { sManager.removeDelegate(native_instance); } + @LayoutlibDelegate /*package*/ static int nativeGetStyle(int native_instance) { Typeface_Delegate delegate = sManager.getDelegate(native_instance); if (delegate == null) { @@ -150,6 +157,7 @@ public final class Typeface_Delegate { return delegate.mStyle; } + @LayoutlibDelegate /*package*/ static void setGammaForText(float blackGamma, float whiteGamma) { // This is for device testing only: pass } diff --git a/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java index 312318a..88df027 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Xfermode_Delegate.java @@ -17,6 +17,7 @@ package android.graphics; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.awt.Composite; @@ -58,6 +59,7 @@ public abstract class Xfermode_Delegate { // ---- native methods ---- + @LayoutlibDelegate /*package*/ static void finalizer(int native_instance) { sManager.removeDelegate(native_instance); } diff --git a/tools/layoutlib/bridge/src/android/os/Build_Delegate.java b/tools/layoutlib/bridge/src/android/os/Build_Delegate.java index f71860f..ff82a5e 100644 --- a/tools/layoutlib/bridge/src/android/os/Build_Delegate.java +++ b/tools/layoutlib/bridge/src/android/os/Build_Delegate.java @@ -18,6 +18,7 @@ package android.os; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import java.util.Map; @@ -33,6 +34,7 @@ import java.util.Map; */ public class Build_Delegate { + @LayoutlibDelegate /*package*/ static String getString(String property) { Map<String, String> properties = Bridge.getPlatformProperties(); String value = properties.get(property); diff --git a/tools/layoutlib/bridge/src/android/os/Handler_Delegate.java b/tools/layoutlib/bridge/src/android/os/Handler_Delegate.java index 4d4ec7f..2152c8a 100644 --- a/tools/layoutlib/bridge/src/android/os/Handler_Delegate.java +++ b/tools/layoutlib/bridge/src/android/os/Handler_Delegate.java @@ -16,6 +16,8 @@ package android.os; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; + /** * Delegate overriding selected methods of android.os.Handler @@ -29,6 +31,7 @@ public class Handler_Delegate { // -------- Delegate methods + @LayoutlibDelegate /*package*/ static boolean sendMessageAtTime(Handler handler, Message msg, long uptimeMillis) { // get the callback IHandlerCallback callback = sCallbacks.get(); diff --git a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java index be222fc..63711a7 100644 --- a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java +++ b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java @@ -17,6 +17,7 @@ package android.os; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.os.SystemClock @@ -31,6 +32,7 @@ import com.android.layoutlib.bridge.impl.DelegateManager; public class SystemClock_Delegate { private static long sBootTime = System.currentTimeMillis(); + @LayoutlibDelegate /*package*/ static boolean setCurrentTimeMillis(long millis) { return true; } @@ -42,6 +44,7 @@ public class SystemClock_Delegate { * * @return milliseconds of non-sleep uptime since boot. */ + @LayoutlibDelegate /*package*/ static long uptimeMillis() { return System.currentTimeMillis() - sBootTime; } @@ -51,6 +54,7 @@ public class SystemClock_Delegate { * * @return elapsed milliseconds since boot. */ + @LayoutlibDelegate /*package*/ static long elapsedRealtime() { return System.currentTimeMillis() - sBootTime; } @@ -60,6 +64,7 @@ public class SystemClock_Delegate { * * @return elapsed milliseconds in the thread */ + @LayoutlibDelegate /*package*/ static long currentThreadTimeMillis() { return System.currentTimeMillis(); } diff --git a/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java b/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java index 9ca1338..1df78c2 100644 --- a/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java +++ b/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java @@ -17,6 +17,7 @@ package android.util; import com.android.layoutlib.bridge.impl.DelegateManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /** * Delegate implementing the native methods of android.util.FloatMath @@ -40,6 +41,7 @@ import com.android.layoutlib.bridge.impl.DelegateManager; * @param value to be converted * @return the floor of value */ + @LayoutlibDelegate /*package*/ static float floor(float value) { return (float)Math.floor(value); } @@ -51,6 +53,7 @@ import com.android.layoutlib.bridge.impl.DelegateManager; * @param value to be converted * @return the ceiling of value */ + @LayoutlibDelegate /*package*/ static float ceil(float value) { return (float)Math.ceil(value); } @@ -61,6 +64,7 @@ import com.android.layoutlib.bridge.impl.DelegateManager; * @param angle to compute the cosine of, in radians * @return the sine of angle */ + @LayoutlibDelegate /*package*/ static float sin(float angle) { return (float)Math.sin(angle); } @@ -71,6 +75,7 @@ import com.android.layoutlib.bridge.impl.DelegateManager; * @param angle to compute the cosine of, in radians * @return the cosine of angle */ + @LayoutlibDelegate /*package*/ static float cos(float angle) { return (float)Math.cos(angle); } @@ -82,6 +87,7 @@ import com.android.layoutlib.bridge.impl.DelegateManager; * @param value to compute sqrt of * @return the square root of value */ + @LayoutlibDelegate /*package*/ static float sqrt(float value) { return (float)Math.sqrt(value); } diff --git a/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java b/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java index 3946a2f..0f3cf57 100644 --- a/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java +++ b/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java @@ -17,6 +17,7 @@ package android.view; import com.android.layoutlib.bridge.android.BridgeInflater; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -38,6 +39,7 @@ public class LayoutInflater_Delegate { * Recursive method used to descend down the xml hierarchy and instantiate * views, instantiate their children, and then call onFinishInflate(). */ + @LayoutlibDelegate /*package*/ static void rInflate(LayoutInflater thisInflater, XmlPullParser parser, View parent, final AttributeSet attrs, boolean finishInflate) throws XmlPullParserException, IOException { diff --git a/tools/layoutlib/bridge/src/android/view/View_Delegate.java b/tools/layoutlib/bridge/src/android/view/View_Delegate.java index ee6694c..8215f7c 100644 --- a/tools/layoutlib/bridge/src/android/view/View_Delegate.java +++ b/tools/layoutlib/bridge/src/android/view/View_Delegate.java @@ -16,6 +16,8 @@ package android.view; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; + /** * Delegate used to provide new implementation of a select few methods of {@link View} * @@ -25,6 +27,7 @@ package android.view; */ public class View_Delegate { + @LayoutlibDelegate /*package*/ static boolean isInEditMode(View thisView) { return true; } diff --git a/tools/layoutlib/bridge/src/com/android/internal/util/XmlUtils_Delegate.java b/tools/layoutlib/bridge/src/com/android/internal/util/XmlUtils_Delegate.java index 7fa1679..bf998b8 100644 --- a/tools/layoutlib/bridge/src/com/android/internal/util/XmlUtils_Delegate.java +++ b/tools/layoutlib/bridge/src/com/android/internal/util/XmlUtils_Delegate.java @@ -16,6 +16,8 @@ package com.android.internal.util; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; + /** * Delegate used to provide new implementation of a select few methods of {@link XmlUtils} @@ -25,6 +27,8 @@ package com.android.internal.util; * */ public class XmlUtils_Delegate { + + @LayoutlibDelegate /*package*/ static final int convertValueToInt(CharSequence charSeq, int defaultValue) { if (null == charSeq) return defaultValue; diff --git a/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java index ab01a394..e6dc646 100644 --- a/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java +++ b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java @@ -16,6 +16,8 @@ package libcore.icu; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; + import java.util.Locale; /** @@ -27,80 +29,101 @@ import java.util.Locale; */ public class ICU_Delegate { + // --- Java delegates + + @LayoutlibDelegate /*package*/ static String toLowerCase(String s, String localeName) { return s.toLowerCase(); } + @LayoutlibDelegate /*package*/ static String toUpperCase(String s, String localeName) { return s.toUpperCase(); } // --- Native methods accessing ICU's database. + @LayoutlibDelegate /*package*/ static String[] getAvailableBreakIteratorLocalesNative() { return new String[0]; } + @LayoutlibDelegate /*package*/ static String[] getAvailableCalendarLocalesNative() { return new String[0]; } + @LayoutlibDelegate /*package*/ static String[] getAvailableCollatorLocalesNative() { return new String[0]; } + @LayoutlibDelegate /*package*/ static String[] getAvailableDateFormatLocalesNative() { return new String[0]; } + @LayoutlibDelegate /*package*/ static String[] getAvailableLocalesNative() { return new String[0]; } + @LayoutlibDelegate /*package*/ static String[] getAvailableNumberFormatLocalesNative() { return new String[0]; } + @LayoutlibDelegate /*package*/ static String getCurrencyCodeNative(String locale) { return ""; } + @LayoutlibDelegate /*package*/ static int getCurrencyFractionDigitsNative(String currencyCode) { return 0; } + @LayoutlibDelegate /*package*/ static String getCurrencySymbolNative(String locale, String currencyCode) { return ""; } + @LayoutlibDelegate /*package*/ static String getDisplayCountryNative(String countryCode, String locale) { return ""; } + @LayoutlibDelegate /*package*/ static String getDisplayLanguageNative(String languageCode, String locale) { return ""; } + @LayoutlibDelegate /*package*/ static String getDisplayVariantNative(String variantCode, String locale) { return ""; } + @LayoutlibDelegate /*package*/ static String getISO3CountryNative(String locale) { return ""; } + @LayoutlibDelegate /*package*/ static String getISO3LanguageNative(String locale) { return ""; } + @LayoutlibDelegate /*package*/ static String[] getISOLanguagesNative() { return Locale.getISOLanguages(); } + @LayoutlibDelegate /*package*/ static String[] getISOCountriesNative() { return Locale.getISOCountries(); } + @LayoutlibDelegate /*package*/ static boolean initLocaleDataImpl(String locale, LocaleData result) { // Used by Calendar. diff --git a/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestClassReplacement.java b/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestClassReplacement.java deleted file mode 100644 index a068ae2..0000000 --- a/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestClassReplacement.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.layoutlib.bridge; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.Type; - -import junit.framework.TestCase; - -public class TestClassReplacement extends TestCase { - - public void testClassReplacements() { - // TODO: we want to test all the classes. For now only, no classes pass the test. -// final String[] classes = CreateInfo.RENAMED_CLASSES; - final String[] classes = new String[] { -// "android.graphics.Paint", "android.graphics._Original_Paint", -// "android.graphics.Canvas", "android.graphics._Original_Canvas", - }; - final int count = classes.length; - for (int i = 0 ; i < count ; i += 2) { - loadAndCompareClasses(classes[i], classes[i+1]); - } - } - - private void loadAndCompareClasses(String newClassName, String oldClassName) { - // load the classes - try { - Class<?> newClass = TestClassReplacement.class.getClassLoader().loadClass(newClassName); - Class<?> oldClass = TestClassReplacement.class.getClassLoader().loadClass(oldClassName); - - compare(newClass, oldClass); - } catch (ClassNotFoundException e) { - fail("Failed to load class: " + e.getMessage()); - } - } - - private void compare(Class<?> newClass, Class<?> oldClass) { - // first compare the methods. - Method[] newClassMethods = newClass.getDeclaredMethods(); - Method[] oldClassMethods = oldClass.getDeclaredMethods(); - - for (Method oldMethod : oldClassMethods) { - // we ignore anything that starts with native. This is because the class we are looking - // at has already been modified to remove the native modifiers. - if (oldMethod.getName().startsWith("native")) { - continue; - } - - // or static and private - int privateStatic = Modifier.STATIC | Modifier.PRIVATE; - if ((oldMethod.getModifiers() & privateStatic) == privateStatic) { - continue; - } - - boolean found = false; - for (Method newMethod : newClassMethods) { - - if (compareMethods(newClass, newMethod, oldClass, oldMethod)) { - found = true; - break; - } - } - - if (found == false) { - // compute a full class name that's long but not too long. - StringBuilder sb = new StringBuilder(oldMethod.getName() + "("); - Type[] params = oldMethod.getGenericParameterTypes(); - for (int j = 0; j < params.length; j++) { - if (params[j] instanceof Class) { - Class theClass = (Class)params[j]; - sb.append(theClass.getName()); - int dimensions = 0; - while (theClass.isArray()) { - dimensions++; - theClass = theClass.getComponentType(); - } - for (int i = 0; i < dimensions; i++) { - sb.append("[]"); - } - - } else { - sb.append(params[j].toString()); - } - if (j < (params.length - 1)) - sb.append(","); - } - sb.append(")"); - - fail(String.format("Missing %1$s.%2$s", newClass.getName(), sb.toString())); - } - } - - // TODO: check (somehow?) that the methods that were removed from the original class - // have been put back in the new class! - // For this we need the original unmodified class (ie renamed, but w/o the methods removed) - } - - private boolean compareMethods(Class<?> newClass, Method newMethod, - Class<?> oldClass, Method oldMethod) { - // first check the name of the method - if (newMethod.getName().equals(oldMethod.getName()) == false) { - return false; - } - - // check the return value - Class<?> oldReturnType = oldMethod.getReturnType(); - // if it's the old class, or if it's a inner class of the oldclass, we need to change this. - oldReturnType = adapt(oldReturnType, newClass, oldClass); - - // compare the return types - Class<?> newReturnType = newMethod.getReturnType(); - if (newReturnType.equals(oldReturnType) == false) { - return false; - } - - // now check the parameters type. - Class<?>[] oldParameters = oldMethod.getParameterTypes(); - Class<?>[] newParemeters = newMethod.getParameterTypes(); - if (oldParameters.length != newParemeters.length) { - return false; - } - - for (int i = 0 ; i < oldParameters.length ; i++) { - if (newParemeters[i].equals(adapt(oldParameters[i], newClass, oldClass)) == false) { - return false; - } - } - - return true; - } - - /** - * Adapts a class to deal with renamed classes. - * <p/>For instance if old class is <code>android.graphics._Original_Paint</code> and the - * new class is <code>android.graphics.Paint</code> and the class to adapt is - * <code>android.graphics._Original_Paint$Cap</code>, then the method will return a - * {@link Class} object representing <code>android.graphics.Paint$Cap</code>. - * <p/> - * This method will also ensure that all renamed classes contains all the proper inner classes - * that they should be declaring. - * @param theClass the class to adapt - * @param newClass the new class object - * @param oldClass the old class object - * @return the adapted class. - * @throws ClassNotFoundException - */ - private Class<?> adapt(Class<?> theClass, Class<?> newClass, Class<?> oldClass) { - // only look for a new class if it's not primitive as Class.forName() would fail otherwise. - if (theClass.isPrimitive() == false) { - String n = theClass.getName().replace(oldClass.getName(), newClass.getName()); - try { - return Class.forName(n); - } catch (ClassNotFoundException e) { - fail("Missing class: " + n); - } - } - - return theClass; - } -} diff --git a/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestDelegates.java b/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestDelegates.java index a4140e3..d3218db 100644 --- a/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestDelegates.java +++ b/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestDelegates.java @@ -21,6 +21,8 @@ import com.android.tools.layoutlib.create.CreateInfo; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.List; import junit.framework.TestCase; @@ -78,10 +80,15 @@ public class TestDelegates extends TestCase { } private void compare(Class<?> originalClass, Class<?> delegateClass) throws SecurityException { - Method[] originalMethods = originalClass.getDeclaredMethods(); + List<Method> checkedDelegateMethods = new ArrayList<Method>(); + // loop on the methods of the original class, and for the ones that are annotated + // with @LayoutlibDelegate, look for a matching method in the delegate class. + // The annotation is automatically added by layoutlib_create when it replace a method + // by a call to a delegate + Method[] originalMethods = originalClass.getDeclaredMethods(); for (Method originalMethod : originalMethods) { - // look for methods that were native: they have the LayoutlibDelegate annotation + // look for methods that are delegated: they have the LayoutlibDelegate annotation if (originalMethod.getAnnotation(LayoutlibDelegate.class) == null) { continue; } @@ -114,6 +121,14 @@ public class TestDelegates extends TestCase { Method delegateMethod = delegateClass.getDeclaredMethod(originalMethod.getName(), parameters); + // check that the method has the annotation + assertNotNull( + String.format( + "Delegate method %1$s for class %2$s does not have the @LayoutlibDelegate annotation", + delegateMethod.getName(), + originalClass.getName()), + delegateMethod.getAnnotation(LayoutlibDelegate.class)); + // check that the method is static assertTrue( String.format( @@ -121,28 +136,62 @@ public class TestDelegates extends TestCase { delegateMethod.getName(), originalClass.getName()), (delegateMethod.getModifiers() & Modifier.STATIC) == Modifier.STATIC); + + // add the method as checked. + checkedDelegateMethods.add(delegateMethod); } catch (NoSuchMethodException e) { - // compute a full class name that's long but not too long. - StringBuilder sb = new StringBuilder(originalMethod.getName() + "("); - for (int j = 0; j < parameters.length; j++) { - Class<?> theClass = parameters[j]; - sb.append(theClass.getName()); - int dimensions = 0; - while (theClass.isArray()) { - dimensions++; - theClass = theClass.getComponentType(); - } - for (int i = 0; i < dimensions; i++) { - sb.append("[]"); - } - if (j < (parameters.length - 1)) { - sb.append(","); - } - } - sb.append(")"); - - fail(String.format("Missing %1$s.%2$s", delegateClass.getName(), sb.toString())); + String name = getMethodName(originalMethod, parameters); + fail(String.format("Missing %1$s.%2$s", delegateClass.getName(), name)); + } + } + + // look for dead (delegate) code. + // This looks for all methods in the delegate class, and if they have the + // @LayoutlibDelegate annotation, make sure they have been previously found as a + // match for a method in the original class. + // If not, this means the method is a delegate for a method that either doesn't exist + // anymore or is not delegated anymore. + Method[] delegateMethods = delegateClass.getDeclaredMethods(); + for (Method delegateMethod : delegateMethods) { + // look for methods that are delegates: they have the LayoutlibDelegate annotation + if (delegateMethod.getAnnotation(LayoutlibDelegate.class) == null) { + continue; } + + assertTrue( + String.format( + "Delegate method %1$s.%2$s is not used anymore and must be removed", + delegateClass.getName(), + getMethodName(delegateMethod)), + checkedDelegateMethods.contains(delegateMethod)); } + + } + + private String getMethodName(Method method) { + return getMethodName(method, method.getParameterTypes()); + } + + private String getMethodName(Method method, Class<?>[] parameters) { + // compute a full class name that's long but not too long. + StringBuilder sb = new StringBuilder(method.getName() + "("); + for (int j = 0; j < parameters.length; j++) { + Class<?> theClass = parameters[j]; + sb.append(theClass.getName()); + int dimensions = 0; + while (theClass.isArray()) { + dimensions++; + theClass = theClass.getComponentType(); + } + for (int i = 0; i < dimensions; i++) { + sb.append("[]"); + } + if (j < (parameters.length - 1)) { + sb.append(","); + } + } + sb.append(")"); + + return sb.toString(); } } |
