diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java | 11 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java | 38 |
2 files changed, 49 insertions, 0 deletions
diff --git a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java index bd332a6..26cb97b 100644 --- a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java +++ b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java @@ -31,6 +31,7 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate; */ public class SystemClock_Delegate { private static long sBootTime = System.currentTimeMillis(); + private static long sBootTimeNano = System.nanoTime(); @LayoutlibDelegate /*package*/ static boolean setCurrentTimeMillis(long millis) { @@ -60,6 +61,16 @@ public class SystemClock_Delegate { } /** + * Returns nanoseconds since boot, including time spent in sleep. + * + * @return elapsed nanoseconds since boot. + */ + @LayoutlibDelegate + /*package*/ static long elapsedRealtimeNano() { + return System.nanoTime() - sBootTimeNano; + } + + /** * Returns milliseconds running in the current thread. * * @return elapsed milliseconds in the thread diff --git a/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java b/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java index 1df78c2..8b4c60b 100644 --- a/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java +++ b/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java @@ -91,4 +91,42 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /*package*/ static float sqrt(float value) { return (float)Math.sqrt(value); } + + /** + * Returns the closest float approximation of the raising "e" to the power + * of the argument. + * + * @param value to compute the exponential of + * @return the exponential of value + */ + @LayoutlibDelegate + /*package*/ static float exp(float value) { + return (float)Math.exp(value); + } + + /** + * Returns the closest float approximation of the result of raising {@code + * x} to the power of {@code y}. + * + * @param x the base of the operation. + * @param y the exponent of the operation. + * @return {@code x} to the power of {@code y}. + */ + @LayoutlibDelegate + /*package*/ static float pow(float x, float y) { + return (float)Math.pow(x, y); + } + + /** + * Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i> + * {@code y}</i><sup>{@code 2}</sup>{@code )}. + * + * @param x a float number + * @param y a float number + * @return the hypotenuse + */ + @LayoutlibDelegate + /*package*/ static float hypot(float x, float y) { + return (float)Math.sqrt(x*x + y*y); + } } |