Loading tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java +6 −72 Original line number Diff line number Diff line Loading @@ -131,20 +131,6 @@ public final class Canvas_Delegate { return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate /*package*/ static long initCanvas(long nativeCanvas) { // get the delegate from the native int. Canvas_Delegate nativeCanvasDelegate = sManager.getDelegate(nativeCanvas); if (nativeCanvasDelegate == null) { return 0; } Canvas_Delegate newDelegate = new Canvas_Delegate(); // TODO: actually copy the canvas state. return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate /*package*/ static void native_setBitmap(long canvas, long bitmap, boolean copyState) { Loading Loading @@ -497,24 +483,6 @@ public final class Canvas_Delegate { return false; } @LayoutlibDelegate /*package*/ static void native_drawRGB(long nativeCanvas, int r, int g, int b) { native_drawColor(nativeCanvas, 0xFF000000 | r << 16 | (g&0xFF) << 8 | (b&0xFF), PorterDuff.Mode.SRC_OVER.nativeInt); } @LayoutlibDelegate /*package*/ static void native_drawARGB(long nativeCanvas, int a, int r, int g, int b) { native_drawColor(nativeCanvas, a << 24 | (r&0xFF) << 16 | (g&0xFF) << 8 | (b&0xFF), PorterDuff.Mode.SRC_OVER.nativeInt); } @LayoutlibDelegate /*package*/ static void native_drawColor(long nativeCanvas, int color) { native_drawColor(nativeCanvas, color, PorterDuff.Mode.SRC_OVER.nativeInt); } @LayoutlibDelegate /*package*/ static void native_drawColor(long nativeCanvas, final int color, final int mode) { // get the delegate from the native int. Loading Loading @@ -772,52 +740,18 @@ public final class Canvas_Delegate { @LayoutlibDelegate /*package*/ static void native_drawBitmap(Canvas thisCanvas, long nativeCanvas, long bitmap, Rect src, RectF dst, long nativePaintOrZero, int screenDensity, int bitmapDensity) { float srcLeft, float srcTop, float srcRight, float srcBottom, float dstLeft, float dstTop, float dstRight, float dstBottom, long nativePaintOrZero, int screenDensity, int bitmapDensity) { // get the delegate from the native int. Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap); if (bitmapDelegate == null) { return; } BufferedImage image = bitmapDelegate.getImage(); if (src == null) { drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, 0, 0, image.getWidth(), image.getHeight(), (int)dst.left, (int)dst.top, (int)dst.right, (int)dst.bottom); } else { drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, src.left, src.top, src.width(), src.height(), (int)dst.left, (int)dst.top, (int)dst.right, (int)dst.bottom); } } @LayoutlibDelegate /*package*/ static void native_drawBitmap(long nativeCanvas, long bitmap, Rect src, Rect dst, long nativePaintOrZero, int screenDensity, int bitmapDensity) { // get the delegate from the native int. Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap); if (bitmapDelegate == null) { return; } BufferedImage image = bitmapDelegate.getImage(); if (src == null) { drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, 0, 0, image.getWidth(), image.getHeight(), dst.left, dst.top, dst.right, dst.bottom); } else { drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, src.left, src.top, src.width(), src.height(), dst.left, dst.top, dst.right, dst.bottom); } (int)srcLeft, (int)srcTop, (int)srcRight, (int)srcBottom, (int)dstLeft, (int)dstTop, (int)dstRight, (int)dstBottom); } @LayoutlibDelegate Loading tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java +3 −3 Original line number Diff line number Diff line Loading @@ -215,9 +215,9 @@ public final class NinePatch_Delegate { 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), Canvas_Delegate.native_drawBitmap(null, canvas_instance, bitmap_instance, 0f, 0f, (float)image.getWidth(), (float)image.getHeight(), (float)left, (float)top, (float)right, (float)bottom, paint_instance_or_null, destDensity, srcDensity); return; } Loading tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java +16 −0 Original line number Diff line number Diff line Loading @@ -1084,6 +1084,22 @@ public class Paint_Delegate { sManager.removeJavaReferenceFor(nativePaint); } @LayoutlibDelegate /*package*/ static float native_getLetterSpacing(long nativePaint) { // TODO: throw a fidelity warning. return 0; } @LayoutlibDelegate /*package*/ static void native_setLetterSpacing(long nativePaint, float letterSpacing) { // pass. } @LayoutlibDelegate /*package*/ static void native_setFontFeatureSettings(long nativePaint, String settings) { // pass. } // ---- Private delegate/helper methods ---- /*package*/ Paint_Delegate() { Loading tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java +6 −3 Original line number Diff line number Diff line Loading @@ -76,19 +76,22 @@ public abstract class Shader_Delegate { // ---- native methods ---- @LayoutlibDelegate /*package*/ static void nativeDestructor(long native_shader) { /*package*/ static void nativeDestructor(long native_shader, long native_with_local_matrix) { // TODO: check what's native_with_local_matrix sManager.removeJavaReferenceFor(native_shader); } @LayoutlibDelegate /*package*/ static void nativeSetLocalMatrix(long native_shader, long matrix_instance) { /*package*/ static long nativeSetLocalMatrix(long native_shader, long native_with_local_matrix, long matrix_instance) { // get the delegate from the native int. Shader_Delegate shaderDelegate = sManager.getDelegate(native_shader); if (shaderDelegate == null) { return; return 0; } shaderDelegate.mLocalMatrix = Matrix_Delegate.getDelegate(matrix_instance); return 0; } // ---- Private delegate/helper methods ---- Loading tools/layoutlib/bridge/src/android/text/format/Time_Delegate.java +0 −85 Original line number Diff line number Diff line Loading @@ -39,91 +39,6 @@ public class Time_Delegate { // Format used by toString() private static final String FORMAT = "%1$tY%1$tm%1$tdT%1$tH%1$tM%1$tS<%1$tZ>"; @LayoutlibDelegate /*package*/ static long normalize(Time thisTime, boolean ignoreDst) { long millis = toMillis(thisTime, ignoreDst); set(thisTime, millis); return millis; } @LayoutlibDelegate /*package*/ static void switchTimezone(Time thisTime, String timezone) { Calendar c = timeToCalendar(thisTime); c.setTimeZone(TimeZone.getTimeZone(timezone)); calendarToTime(c, thisTime); } @LayoutlibDelegate /*package*/ static int nativeCompare(Time a, Time b) { return timeToCalendar(a).compareTo(timeToCalendar(b)); } @LayoutlibDelegate /*package*/ static String format1(Time thisTime, String format) { try { // Change the format by adding changing '%' to "%1$t". This is required to tell the // formatter which argument to use from the argument list. '%%' is left as is. In the // replacement string, $0 refers to matched pattern. \\1 means '1', written this way to // separate it from 0. \\$ means '$', written this way to suppress the special meaning // of $. return String.format( p.matcher(format).replaceAll("$0\\1\\$t"), timeToCalendar(thisTime)); } catch (UnknownFormatConversionException e) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_STRFTIME, "Unrecognized format", e, format); return format; } } /** * Return the current time in YYYYMMDDTHHMMSS<tz> format */ @LayoutlibDelegate /*package*/ static String toString(Time thisTime) { Calendar c = timeToCalendar(thisTime); return String.format(FORMAT, c); } @LayoutlibDelegate /*package*/ static boolean nativeParse(Time thisTime, String s) { Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "android.text.format.Time.parse() not supported.", null); return false; } @LayoutlibDelegate /*package*/ static boolean nativeParse3339(Time thisTime, String s) { Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "android.text.format.Time.parse3339() not supported.", null); return false; } @LayoutlibDelegate /*package*/ static void setToNow(Time thisTime) { calendarToTime(getCalendarInstance(thisTime), thisTime); } @LayoutlibDelegate /*package*/ static long toMillis(Time thisTime, boolean ignoreDst) { // TODO: Respect ignoreDst. return timeToCalendar(thisTime).getTimeInMillis(); } @LayoutlibDelegate /*package*/ static void set(Time thisTime, long millis) { Calendar c = getCalendarInstance(thisTime); c.setTimeInMillis(millis); calendarToTime(c,thisTime); } @LayoutlibDelegate /*package*/ static String format2445(Time thisTime) { Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "android.text.format.Time.format2445() not supported.", null); return ""; } // ---- private helper methods ---- private static Calendar timeToCalendar(Time time) { Loading Loading
tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java +6 −72 Original line number Diff line number Diff line Loading @@ -131,20 +131,6 @@ public final class Canvas_Delegate { return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate /*package*/ static long initCanvas(long nativeCanvas) { // get the delegate from the native int. Canvas_Delegate nativeCanvasDelegate = sManager.getDelegate(nativeCanvas); if (nativeCanvasDelegate == null) { return 0; } Canvas_Delegate newDelegate = new Canvas_Delegate(); // TODO: actually copy the canvas state. return sManager.addNewDelegate(newDelegate); } @LayoutlibDelegate /*package*/ static void native_setBitmap(long canvas, long bitmap, boolean copyState) { Loading Loading @@ -497,24 +483,6 @@ public final class Canvas_Delegate { return false; } @LayoutlibDelegate /*package*/ static void native_drawRGB(long nativeCanvas, int r, int g, int b) { native_drawColor(nativeCanvas, 0xFF000000 | r << 16 | (g&0xFF) << 8 | (b&0xFF), PorterDuff.Mode.SRC_OVER.nativeInt); } @LayoutlibDelegate /*package*/ static void native_drawARGB(long nativeCanvas, int a, int r, int g, int b) { native_drawColor(nativeCanvas, a << 24 | (r&0xFF) << 16 | (g&0xFF) << 8 | (b&0xFF), PorterDuff.Mode.SRC_OVER.nativeInt); } @LayoutlibDelegate /*package*/ static void native_drawColor(long nativeCanvas, int color) { native_drawColor(nativeCanvas, color, PorterDuff.Mode.SRC_OVER.nativeInt); } @LayoutlibDelegate /*package*/ static void native_drawColor(long nativeCanvas, final int color, final int mode) { // get the delegate from the native int. Loading Loading @@ -772,52 +740,18 @@ public final class Canvas_Delegate { @LayoutlibDelegate /*package*/ static void native_drawBitmap(Canvas thisCanvas, long nativeCanvas, long bitmap, Rect src, RectF dst, long nativePaintOrZero, int screenDensity, int bitmapDensity) { float srcLeft, float srcTop, float srcRight, float srcBottom, float dstLeft, float dstTop, float dstRight, float dstBottom, long nativePaintOrZero, int screenDensity, int bitmapDensity) { // get the delegate from the native int. Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap); if (bitmapDelegate == null) { return; } BufferedImage image = bitmapDelegate.getImage(); if (src == null) { drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, 0, 0, image.getWidth(), image.getHeight(), (int)dst.left, (int)dst.top, (int)dst.right, (int)dst.bottom); } else { drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, src.left, src.top, src.width(), src.height(), (int)dst.left, (int)dst.top, (int)dst.right, (int)dst.bottom); } } @LayoutlibDelegate /*package*/ static void native_drawBitmap(long nativeCanvas, long bitmap, Rect src, Rect dst, long nativePaintOrZero, int screenDensity, int bitmapDensity) { // get the delegate from the native int. Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap); if (bitmapDelegate == null) { return; } BufferedImage image = bitmapDelegate.getImage(); if (src == null) { drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, 0, 0, image.getWidth(), image.getHeight(), dst.left, dst.top, dst.right, dst.bottom); } else { drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, src.left, src.top, src.width(), src.height(), dst.left, dst.top, dst.right, dst.bottom); } (int)srcLeft, (int)srcTop, (int)srcRight, (int)srcBottom, (int)dstLeft, (int)dstTop, (int)dstRight, (int)dstBottom); } @LayoutlibDelegate Loading
tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java +3 −3 Original line number Diff line number Diff line Loading @@ -215,9 +215,9 @@ public final class NinePatch_Delegate { 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), Canvas_Delegate.native_drawBitmap(null, canvas_instance, bitmap_instance, 0f, 0f, (float)image.getWidth(), (float)image.getHeight(), (float)left, (float)top, (float)right, (float)bottom, paint_instance_or_null, destDensity, srcDensity); return; } Loading
tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java +16 −0 Original line number Diff line number Diff line Loading @@ -1084,6 +1084,22 @@ public class Paint_Delegate { sManager.removeJavaReferenceFor(nativePaint); } @LayoutlibDelegate /*package*/ static float native_getLetterSpacing(long nativePaint) { // TODO: throw a fidelity warning. return 0; } @LayoutlibDelegate /*package*/ static void native_setLetterSpacing(long nativePaint, float letterSpacing) { // pass. } @LayoutlibDelegate /*package*/ static void native_setFontFeatureSettings(long nativePaint, String settings) { // pass. } // ---- Private delegate/helper methods ---- /*package*/ Paint_Delegate() { Loading
tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java +6 −3 Original line number Diff line number Diff line Loading @@ -76,19 +76,22 @@ public abstract class Shader_Delegate { // ---- native methods ---- @LayoutlibDelegate /*package*/ static void nativeDestructor(long native_shader) { /*package*/ static void nativeDestructor(long native_shader, long native_with_local_matrix) { // TODO: check what's native_with_local_matrix sManager.removeJavaReferenceFor(native_shader); } @LayoutlibDelegate /*package*/ static void nativeSetLocalMatrix(long native_shader, long matrix_instance) { /*package*/ static long nativeSetLocalMatrix(long native_shader, long native_with_local_matrix, long matrix_instance) { // get the delegate from the native int. Shader_Delegate shaderDelegate = sManager.getDelegate(native_shader); if (shaderDelegate == null) { return; return 0; } shaderDelegate.mLocalMatrix = Matrix_Delegate.getDelegate(matrix_instance); return 0; } // ---- Private delegate/helper methods ---- Loading
tools/layoutlib/bridge/src/android/text/format/Time_Delegate.java +0 −85 Original line number Diff line number Diff line Loading @@ -39,91 +39,6 @@ public class Time_Delegate { // Format used by toString() private static final String FORMAT = "%1$tY%1$tm%1$tdT%1$tH%1$tM%1$tS<%1$tZ>"; @LayoutlibDelegate /*package*/ static long normalize(Time thisTime, boolean ignoreDst) { long millis = toMillis(thisTime, ignoreDst); set(thisTime, millis); return millis; } @LayoutlibDelegate /*package*/ static void switchTimezone(Time thisTime, String timezone) { Calendar c = timeToCalendar(thisTime); c.setTimeZone(TimeZone.getTimeZone(timezone)); calendarToTime(c, thisTime); } @LayoutlibDelegate /*package*/ static int nativeCompare(Time a, Time b) { return timeToCalendar(a).compareTo(timeToCalendar(b)); } @LayoutlibDelegate /*package*/ static String format1(Time thisTime, String format) { try { // Change the format by adding changing '%' to "%1$t". This is required to tell the // formatter which argument to use from the argument list. '%%' is left as is. In the // replacement string, $0 refers to matched pattern. \\1 means '1', written this way to // separate it from 0. \\$ means '$', written this way to suppress the special meaning // of $. return String.format( p.matcher(format).replaceAll("$0\\1\\$t"), timeToCalendar(thisTime)); } catch (UnknownFormatConversionException e) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_STRFTIME, "Unrecognized format", e, format); return format; } } /** * Return the current time in YYYYMMDDTHHMMSS<tz> format */ @LayoutlibDelegate /*package*/ static String toString(Time thisTime) { Calendar c = timeToCalendar(thisTime); return String.format(FORMAT, c); } @LayoutlibDelegate /*package*/ static boolean nativeParse(Time thisTime, String s) { Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "android.text.format.Time.parse() not supported.", null); return false; } @LayoutlibDelegate /*package*/ static boolean nativeParse3339(Time thisTime, String s) { Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "android.text.format.Time.parse3339() not supported.", null); return false; } @LayoutlibDelegate /*package*/ static void setToNow(Time thisTime) { calendarToTime(getCalendarInstance(thisTime), thisTime); } @LayoutlibDelegate /*package*/ static long toMillis(Time thisTime, boolean ignoreDst) { // TODO: Respect ignoreDst. return timeToCalendar(thisTime).getTimeInMillis(); } @LayoutlibDelegate /*package*/ static void set(Time thisTime, long millis) { Calendar c = getCalendarInstance(thisTime); c.setTimeInMillis(millis); calendarToTime(c,thisTime); } @LayoutlibDelegate /*package*/ static String format2445(Time thisTime) { Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "android.text.format.Time.format2445() not supported.", null); return ""; } // ---- private helper methods ---- private static Calendar timeToCalendar(Time time) { Loading