summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-09-04 15:02:06 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-04 15:02:06 -0700
commitde66e670a7753283fd5cdc75c2cd42c93cd499c0 (patch)
treef898e4a410f610ac3eacd048393b9d97d46d9658 /tools
parent035ce2ca92742894f7f906c93d7d217c647aa19a (diff)
parent5eb51defe39f765d6ebe868dba7f187f7dd990f6 (diff)
downloadframeworks_base-de66e670a7753283fd5cdc75c2cd42c93cd499c0.zip
frameworks_base-de66e670a7753283fd5cdc75c2cd42c93cd499c0.tar.gz
frameworks_base-de66e670a7753283fd5cdc75c2cd42c93cd499c0.tar.bz2
Merge "Add some new native deletage to layoutlib." into jb-mr1-dev
Diffstat (limited to 'tools')
-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);
+ }
}