summaryrefslogtreecommitdiffstats
path: root/tools/layoutlib/bridge
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-09-04 13:59:17 -0700
committerXavier Ducrohet <xav@android.com>2012-09-04 15:00:52 -0700
commit5eb51defe39f765d6ebe868dba7f187f7dd990f6 (patch)
treeb9ac2e0fcfa5e65d3558236751ff8018b467232f /tools/layoutlib/bridge
parent34a75df63533914bbca95a82d2c89ca374b2645d (diff)
downloadframeworks_base-5eb51defe39f765d6ebe868dba7f187f7dd990f6.zip
frameworks_base-5eb51defe39f765d6ebe868dba7f187f7dd990f6.tar.gz
frameworks_base-5eb51defe39f765d6ebe868dba7f187f7dd990f6.tar.bz2
Add some new native deletage to layoutlib.
Change-Id: Ib53df6c944ecd9680bf929afe03b08bcaa61ad70
Diffstat (limited to 'tools/layoutlib/bridge')
-rw-r--r--tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java11
-rw-r--r--tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java38
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);
+ }
}