Merge "Add API to control scan always mode" into jb-mr2-dev
diff --git a/api/current.txt b/api/current.txt
index 131c911..ad2a623 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -6159,6 +6159,7 @@
ctor public Loader(android.content.Context);
method public void abandon();
method public boolean cancelLoad();
+ method public void commitContentChanged();
method public java.lang.String dataToString(D);
method public void deliverCancellation();
method public void deliverResult(D);
@@ -6179,6 +6180,7 @@
method public void registerListener(int, android.content.Loader.OnLoadCompleteListener<D>);
method public void registerOnLoadCanceledListener(android.content.Loader.OnLoadCanceledListener<D>);
method public void reset();
+ method public void rollbackContentChanged();
method public final void startLoading();
method public void stopLoading();
method public boolean takeContentChanged();
@@ -24953,6 +24955,14 @@
field public static final int ORIENTATION_UNKNOWN = -1; // 0xffffffff
}
+ public abstract interface Overlay {
+ method public abstract void add(android.graphics.drawable.Drawable);
+ method public abstract void add(android.view.View);
+ method public abstract void clear();
+ method public abstract void remove(android.graphics.drawable.Drawable);
+ method public abstract void remove(android.view.View);
+ }
+
public class ScaleGestureDetector {
ctor public ScaleGestureDetector(android.content.Context, android.view.ScaleGestureDetector.OnScaleGestureListener);
method public float getCurrentSpan();
@@ -25257,6 +25267,7 @@
method public int getNextFocusUpId();
method public android.view.View.OnFocusChangeListener getOnFocusChangeListener();
method public int getOverScrollMode();
+ method public android.view.Overlay getOverlay();
method public int getPaddingBottom();
method public int getPaddingEnd();
method public int getPaddingLeft();
@@ -29854,8 +29865,8 @@
method public void setFormat12Hour(java.lang.CharSequence);
method public void setFormat24Hour(java.lang.CharSequence);
method public void setTimeZone(java.lang.String);
- field public static final java.lang.CharSequence DEFAULT_FORMAT_12_HOUR;
- field public static final java.lang.CharSequence DEFAULT_FORMAT_24_HOUR;
+ field public static final deprecated java.lang.CharSequence DEFAULT_FORMAT_12_HOUR;
+ field public static final deprecated java.lang.CharSequence DEFAULT_FORMAT_24_HOUR;
}
public class TextSwitcher extends android.widget.ViewSwitcher {
diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp
index 6fe358c..0668be6 100644
--- a/cmds/app_process/app_main.cpp
+++ b/cmds/app_process/app_main.cpp
@@ -13,7 +13,9 @@
#include <cutils/process_name.h>
#include <cutils/memory.h>
#include <android_runtime/AndroidRuntime.h>
+#include <sys/personality.h>
+#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -128,8 +130,32 @@
strlcpy(const_cast<char *>(argv0), newArgv0, strlen(argv0));
}
-int main(int argc, const char* const argv[])
+int main(int argc, char* const argv[])
{
+#ifdef __arm__
+ /*
+ * b/7188322 - Temporarily revert to the compat memory layout
+ * to avoid breaking third party apps.
+ *
+ * THIS WILL GO AWAY IN A FUTURE ANDROID RELEASE.
+ *
+ * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=7dbaa466
+ * changes the kernel mapping from bottom up to top-down.
+ * This breaks some programs which improperly embed
+ * an out of date copy of Android's linker.
+ */
+ if (getenv("NO_ADDR_COMPAT_LAYOUT_FIXUP") == NULL) {
+ int current = personality(0xFFFFFFFF);
+ if ((current & ADDR_COMPAT_LAYOUT) == 0) {
+ personality(current | ADDR_COMPAT_LAYOUT);
+ setenv("NO_ADDR_COMPAT_LAYOUT_FIXUP", "1", 1);
+ execv("/system/bin/app_process", argv);
+ return -1;
+ }
+ }
+ unsetenv("NO_ADDR_COMPAT_LAYOUT_FIXUP");
+#endif
+
// These are global variables in ProcessState.cpp
mArgC = argc;
mArgV = argv;
diff --git a/cmds/svc/src/com/android/commands/svc/PowerCommand.java b/cmds/svc/src/com/android/commands/svc/PowerCommand.java
index 58105fa..da8586c 100644
--- a/cmds/svc/src/com/android/commands/svc/PowerCommand.java
+++ b/cmds/svc/src/com/android/commands/svc/PowerCommand.java
@@ -36,12 +36,18 @@
return shortHelp() + "\n"
+ "\n"
+ "usage: svc power stayon [true|false|usb|ac|wireless]\n"
- + " Set the 'keep awake while plugged in' setting.\n";
+ + " Set the 'keep awake while plugged in' setting.\n"
+ + " svc power reboot [reason]\n"
+ + " Perform a runtime shutdown and reboot device with specified reason.\n"
+ + " svc power shutdown\n"
+ + " Perform a runtime shutdown and power off the device.\n";
}
public void run(String[] args) {
fail: {
if (args.length >= 2) {
+ IPowerManager pm = IPowerManager.Stub.asInterface(
+ ServiceManager.getService(Context.POWER_SERVICE));
if ("stayon".equals(args[1]) && args.length == 3) {
int val;
if ("true".equals(args[2])) {
@@ -60,8 +66,6 @@
} else {
break fail;
}
- IPowerManager pm
- = IPowerManager.Stub.asInterface(ServiceManager.getService(Context.POWER_SERVICE));
try {
if (val != 0) {
// if the request is not to set it to false, wake up the screen so that
@@ -74,6 +78,26 @@
System.err.println("Faild to set setting: " + e);
}
return;
+ } else if ("reboot".equals(args[1])) {
+ String mode = null;
+ if (args.length == 3) {
+ mode = args[2];
+ }
+ try {
+ // no confirm, wait till device is rebooted
+ pm.reboot(false, mode, true);
+ } catch (RemoteException e) {
+ System.err.println("Failed to reboot.");
+ }
+ return;
+ } else if ("shutdown".equals(args[1])) {
+ try {
+ // no confirm, wait till device is off
+ pm.shutdown(false, true);
+ } catch (RemoteException e) {
+ System.err.println("Failed to shutdown.");
+ }
+ return;
}
}
}
diff --git a/core/java/android/animation/AnimatorInflater.java b/core/java/android/animation/AnimatorInflater.java
index ed4036d..d753e32 100644
--- a/core/java/android/animation/AnimatorInflater.java
+++ b/core/java/android/animation/AnimatorInflater.java
@@ -185,7 +185,7 @@
TypedArray a =
context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.Animator);
- long duration = a.getInt(com.android.internal.R.styleable.Animator_duration, 0);
+ long duration = a.getInt(com.android.internal.R.styleable.Animator_duration, 300);
long startDelay = a.getInt(com.android.internal.R.styleable.Animator_startOffset, 0);
diff --git a/core/java/android/animation/KeyframeSet.java b/core/java/android/animation/KeyframeSet.java
index 6172aab..4026f7f 100644
--- a/core/java/android/animation/KeyframeSet.java
+++ b/core/java/android/animation/KeyframeSet.java
@@ -21,6 +21,7 @@
import android.animation.Keyframe.IntKeyframe;
import android.animation.Keyframe.FloatKeyframe;
import android.animation.Keyframe.ObjectKeyframe;
+import android.util.Log;
/**
* This class holds a collection of Keyframe objects and is called by ValueAnimator to calculate
@@ -56,24 +57,36 @@
} else {
keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f, values[0]);
for (int i = 1; i < numKeyframes; ++i) {
- keyframes[i] = (IntKeyframe) Keyframe.ofInt((float) i / (numKeyframes - 1), values[i]);
+ keyframes[i] =
+ (IntKeyframe) Keyframe.ofInt((float) i / (numKeyframes - 1), values[i]);
}
}
return new IntKeyframeSet(keyframes);
}
public static KeyframeSet ofFloat(float... values) {
+ boolean badValue = false;
int numKeyframes = values.length;
FloatKeyframe keyframes[] = new FloatKeyframe[Math.max(numKeyframes,2)];
if (numKeyframes == 1) {
keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f);
keyframes[1] = (FloatKeyframe) Keyframe.ofFloat(1f, values[0]);
+ if (Float.isNaN(values[0])) {
+ badValue = true;
+ }
} else {
keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f, values[0]);
for (int i = 1; i < numKeyframes; ++i) {
- keyframes[i] = (FloatKeyframe) Keyframe.ofFloat((float) i / (numKeyframes - 1), values[i]);
+ keyframes[i] =
+ (FloatKeyframe) Keyframe.ofFloat((float) i / (numKeyframes - 1), values[i]);
+ if (Float.isNaN(values[i])) {
+ badValue = true;
+ }
}
}
+ if (badValue) {
+ Log.w("Animator", "Bad value (NaN) in float animator");
+ }
return new FloatKeyframeSet(keyframes);
}
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index f7460c4..4a58072 100644
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -1015,6 +1015,7 @@
mRunning = false;
mStarted = false;
mStartListenersCalled = false;
+ mPlayingBackwards = false;
}
/**
diff --git a/core/java/android/bluetooth/BluetoothTetheringDataTracker.java b/core/java/android/bluetooth/BluetoothTetheringDataTracker.java
index 3ba4f26..43c2392 100644
--- a/core/java/android/bluetooth/BluetoothTetheringDataTracker.java
+++ b/core/java/android/bluetooth/BluetoothTetheringDataTracker.java
@@ -373,4 +373,14 @@
public void setDependencyMet(boolean met) {
// not supported on this network
}
+
+ @Override
+ public void addStackedLink(LinkProperties link) {
+ mLinkProperties.addStackedLink(link);
+ }
+
+ @Override
+ public void removeStackedLink(LinkProperties link) {
+ mLinkProperties.removeStackedLink(link);
+ }
}
diff --git a/core/java/android/content/AsyncTaskLoader.java b/core/java/android/content/AsyncTaskLoader.java
index 188c786..612c67f 100644
--- a/core/java/android/content/AsyncTaskLoader.java
+++ b/core/java/android/content/AsyncTaskLoader.java
@@ -231,6 +231,7 @@
onCanceled(data);
if (mCancellingTask == task) {
if (DEBUG) Slog.v(TAG, "Cancelled task is now canceled!");
+ rollbackContentChanged();
mLastLoadCompleteTime = SystemClock.uptimeMillis();
mCancellingTask = null;
if (DEBUG) Slog.v(TAG, "Delivering cancellation");
@@ -248,6 +249,7 @@
// This cursor has been abandoned; just cancel the new data.
onCanceled(data);
} else {
+ commitContentChanged();
mLastLoadCompleteTime = SystemClock.uptimeMillis();
mTask = null;
if (DEBUG) Slog.v(TAG, "Delivering result");
diff --git a/core/java/android/content/Loader.java b/core/java/android/content/Loader.java
index 3052414..911e49c 100644
--- a/core/java/android/content/Loader.java
+++ b/core/java/android/content/Loader.java
@@ -58,6 +58,7 @@
boolean mAbandoned = false;
boolean mReset = true;
boolean mContentChanged = false;
+ boolean mProcessingChange = false;
/**
* An implementation of a ContentObserver that takes care of connecting
@@ -439,6 +440,7 @@
mStarted = false;
mAbandoned = false;
mContentChanged = false;
+ mProcessingChange = false;
}
/**
@@ -458,9 +460,34 @@
public boolean takeContentChanged() {
boolean res = mContentChanged;
mContentChanged = false;
+ mProcessingChange |= res;
return res;
}
-
+
+ /**
+ * Commit that you have actually fully processed a content change that
+ * was returned by {@link #takeContentChanged}. This is for use with
+ * {@link #rollbackContentChanged()} to handle situations where a load
+ * is cancelled. Call this when you have completely processed a load
+ * without it being cancelled.
+ */
+ public void commitContentChanged() {
+ mProcessingChange = false;
+ }
+
+ /**
+ * Report that you have abandoned the processing of a content change that
+ * was returned by {@link #takeContentChanged()} and would like to rollback
+ * to the state where there is again a pending content change. This is
+ * to handle the case where a data load due to a content change has been
+ * canceled before its data was delivered back to the loader.
+ */
+ public void rollbackContentChanged() {
+ if (mProcessingChange) {
+ mContentChanged = true;
+ }
+ }
+
/**
* Called when {@link ForceLoadContentObserver} detects a change. The
* default implementation checks to see if the loader is currently started;
@@ -512,9 +539,14 @@
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
writer.print(prefix); writer.print("mId="); writer.print(mId);
writer.print(" mListener="); writer.println(mListener);
- writer.print(prefix); writer.print("mStarted="); writer.print(mStarted);
- writer.print(" mContentChanged="); writer.print(mContentChanged);
- writer.print(" mAbandoned="); writer.print(mAbandoned);
- writer.print(" mReset="); writer.println(mReset);
+ if (mStarted || mContentChanged || mProcessingChange) {
+ writer.print(prefix); writer.print("mStarted="); writer.print(mStarted);
+ writer.print(" mContentChanged="); writer.print(mContentChanged);
+ writer.print(" mProcessingChange="); writer.println(mProcessingChange);
+ }
+ if (mAbandoned || mReset) {
+ writer.print(prefix); writer.print("mAbandoned="); writer.print(mAbandoned);
+ writer.print(" mReset="); writer.println(mReset);
+ }
}
}
\ No newline at end of file
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 805b05e..0152615 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -1739,6 +1739,15 @@
}
/**
+ * Return true if given resource identifier includes a package.
+ *
+ * @hide
+ */
+ public static boolean resourceHasPackage(int resid) {
+ return (resid >>> 24) != 0;
+ }
+
+ /**
* Return the full name for a given resource identifier. This name is
* a single string of the form "package:type/entry".
*
diff --git a/core/java/android/inputmethodservice/IInputMethodWrapper.java b/core/java/android/inputmethodservice/IInputMethodWrapper.java
index d59c7b8..1128230 100644
--- a/core/java/android/inputmethodservice/IInputMethodWrapper.java
+++ b/core/java/android/inputmethodservice/IInputMethodWrapper.java
@@ -54,7 +54,7 @@
implements HandlerCaller.Callback {
private static final String TAG = "InputMethodWrapper";
private static final boolean DEBUG = false;
-
+
private static final int DO_DUMP = 1;
private static final int DO_ATTACH_TOKEN = 10;
private static final int DO_SET_INPUT_CONTEXT = 20;
@@ -284,12 +284,6 @@
flags, resultReceiver));
}
- @Override
- public void removeSoftInputMessages() {
- mCaller.removeMessages(DO_SHOW_SOFT_INPUT);
- mCaller.removeMessages(DO_HIDE_SOFT_INPUT);
- }
-
public void changeInputMethodSubtype(InputMethodSubtype subtype) {
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_CHANGE_INPUTMETHOD_SUBTYPE,
subtype));
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 288ceff..2b15afd 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -39,7 +39,6 @@
import android.util.Log;
import android.util.PrintWriterPrinter;
import android.util.Printer;
-import android.util.Slog;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -49,6 +48,7 @@
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
+import android.view.WindowManager.BadTokenException;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.EditorInfo;
@@ -352,7 +352,6 @@
* Take care of attaching the given window token provided by the system.
*/
public void attachToken(IBinder token) {
- Slog.i(TAG, "attachToken: Existing token=" + mToken + " new token=" + token);
if (mToken == null) {
mToken = token;
mWindow.setToken(token);
@@ -419,11 +418,17 @@
* Handle a request by the system to show the soft input area.
*/
public void showSoftInput(int flags, ResultReceiver resultReceiver) {
- if (true || DEBUG) Slog.v(TAG, "showSoftInput()");
+ if (DEBUG) Log.v(TAG, "showSoftInput()");
boolean wasVis = isInputViewShown();
mShowInputFlags = 0;
if (onShowInputRequested(flags, false)) {
- showWindow(true);
+ try {
+ showWindow(true);
+ } catch (BadTokenException e) {
+ if (DEBUG) Log.v(TAG, "BadTokenException: IME is done.");
+ mWindowVisible = false;
+ mWindowAdded = false;
+ }
}
// If user uses hard keyboard, IME button should always be shown.
boolean showing = onEvaluateInputViewShown();
@@ -1390,7 +1395,7 @@
}
public void showWindow(boolean showInput) {
- if (true || DEBUG) Slog.v(TAG, "Showing window: showInput=" + showInput
+ if (DEBUG) Log.v(TAG, "Showing window: showInput=" + showInput
+ " mShowInputRequested=" + mShowInputRequested
+ " mWindowAdded=" + mWindowAdded
+ " mWindowCreated=" + mWindowCreated
diff --git a/core/java/android/net/BaseNetworkStateTracker.java b/core/java/android/net/BaseNetworkStateTracker.java
index 4b60f07..a554611 100644
--- a/core/java/android/net/BaseNetworkStateTracker.java
+++ b/core/java/android/net/BaseNetworkStateTracker.java
@@ -155,4 +155,14 @@
public void setDependencyMet(boolean met) {
// Base tracker doesn't handle dependencies
}
+
+ @Override
+ public void addStackedLink(LinkProperties link) {
+ mLinkProperties.addStackedLink(link);
+ }
+
+ @Override
+ public void removeStackedLink(LinkProperties link) {
+ mLinkProperties.removeStackedLink(link);
+ }
}
diff --git a/core/java/android/net/DhcpStateMachine.java b/core/java/android/net/DhcpStateMachine.java
index 518dd4b..1ebf393 100644
--- a/core/java/android/net/DhcpStateMachine.java
+++ b/core/java/android/net/DhcpStateMachine.java
@@ -50,7 +50,7 @@
public class DhcpStateMachine extends StateMachine {
private static final String TAG = "DhcpStateMachine";
- private static final boolean DBG = true;
+ private static final boolean DBG = false;
/* A StateMachine that controls the DhcpStateMachine */
@@ -349,7 +349,6 @@
private boolean runDhcp(DhcpAction dhcpAction) {
boolean success = false;
DhcpResults dhcpResults = new DhcpResults();
- dhcpResults.linkProperties.mLogMe = true;
if (dhcpAction == DhcpAction.START) {
/* Stop any existing DHCP daemon before starting new */
@@ -359,7 +358,7 @@
} else if (dhcpAction == DhcpAction.RENEW) {
if (DBG) Log.d(TAG, "DHCP renewal on " + mInterfaceName);
success = NetworkUtils.runDhcpRenew(mInterfaceName, dhcpResults);
- dhcpResults.updateFromDhcpRequest(mDhcpResults);
+ if (success) dhcpResults.updateFromDhcpRequest(mDhcpResults);
}
if (success) {
if (DBG) Log.d(TAG, "DHCP succeeded on " + mInterfaceName);
diff --git a/core/java/android/net/DummyDataStateTracker.java b/core/java/android/net/DummyDataStateTracker.java
index 39440c2..db8f0bc 100644
--- a/core/java/android/net/DummyDataStateTracker.java
+++ b/core/java/android/net/DummyDataStateTracker.java
@@ -203,6 +203,16 @@
// not supported on this network
}
+ @Override
+ public void addStackedLink(LinkProperties link) {
+ mLinkProperties.addStackedLink(link);
+ }
+
+ @Override
+ public void removeStackedLink(LinkProperties link) {
+ mLinkProperties.removeStackedLink(link);
+ }
+
static private void log(String s) {
Slog.d(TAG, s);
}
diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java
index 8947162..b744a47 100644
--- a/core/java/android/net/EthernetDataTracker.java
+++ b/core/java/android/net/EthernetDataTracker.java
@@ -407,4 +407,14 @@
public void setDependencyMet(boolean met) {
// not supported on this network
}
+
+ @Override
+ public void addStackedLink(LinkProperties link) {
+ mLinkProperties.addStackedLink(link);
+ }
+
+ @Override
+ public void removeStackedLink(LinkProperties link) {
+ mLinkProperties.removeStackedLink(link);
+ }
}
diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java
index 9292e5f..4457a22 100644
--- a/core/java/android/net/LinkProperties.java
+++ b/core/java/android/net/LinkProperties.java
@@ -20,13 +20,15 @@
import android.os.Parcelable;
import android.os.Parcel;
import android.text.TextUtils;
-import android.util.Log;
import java.net.InetAddress;
+import java.net.Inet4Address;
+
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Hashtable;
/**
* Describes the properties of a network link.
@@ -48,17 +50,26 @@
* don't care which is used. The gateways will be
* selected based on the destination address and the
* source address has no relavence.
+ *
+ * Links can also be stacked on top of each other.
+ * This can be used, for example, to represent a tunnel
+ * interface that runs on top of a physical interface.
+ *
* @hide
*/
public class LinkProperties implements Parcelable {
-
+ // The interface described by the network link.
private String mIfaceName;
private Collection<LinkAddress> mLinkAddresses = new ArrayList<LinkAddress>();
private Collection<InetAddress> mDnses = new ArrayList<InetAddress>();
private String mDomains;
private Collection<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
private ProxyProperties mHttpProxy;
- public boolean mLogMe;
+
+ // Stores the properties of links that are "stacked" above this link.
+ // Indexed by interface name to allow modification and to prevent duplicates being added.
+ private Hashtable<String, LinkProperties> mStackedLinks =
+ new Hashtable<String, LinkProperties>();
public static class CompareResult<T> {
public Collection<T> removed = new ArrayList<T>();
@@ -77,7 +88,6 @@
public LinkProperties() {
clear();
- mLogMe = false;
}
// copy constructor instead of clone
@@ -90,18 +100,13 @@
for (RouteInfo r : source.getRoutes()) mRoutes.add(r);
mHttpProxy = (source.getHttpProxy() == null) ?
null : new ProxyProperties(source.getHttpProxy());
+ for (LinkProperties l: source.mStackedLinks.values()) {
+ addStackedLink(l);
+ }
}
}
public void setInterfaceName(String iface) {
- if (mLogMe) {
- Log.d("LinkProperties", "setInterfaceName from " + mIfaceName +
- " to " + iface);
- for (StackTraceElement e : Thread.currentThread().getStackTrace()) {
- Log.d("LinkProperties", " " + e.toString());
- }
- }
-
mIfaceName = iface;
ArrayList<RouteInfo> newRoutes = new ArrayList<RouteInfo>(mRoutes.size());
for (RouteInfo route : mRoutes) {
@@ -165,10 +170,25 @@
}
}
+ /**
+ * Returns all the routes on this link.
+ */
public Collection<RouteInfo> getRoutes() {
return Collections.unmodifiableCollection(mRoutes);
}
+ /**
+ * Returns all the routes on this link and all the links stacked above it.
+ */
+ public Collection<RouteInfo> getAllRoutes() {
+ Collection<RouteInfo> routes = new ArrayList();
+ routes.addAll(mRoutes);
+ for (LinkProperties stacked: mStackedLinks.values()) {
+ routes.addAll(stacked.getAllRoutes());
+ }
+ return routes;
+ }
+
public void setHttpProxy(ProxyProperties proxy) {
mHttpProxy = proxy;
}
@@ -176,20 +196,54 @@
return mHttpProxy;
}
- public void clear() {
- if (mLogMe) {
- Log.d("LinkProperties", "clear from " + mIfaceName);
- for (StackTraceElement e : Thread.currentThread().getStackTrace()) {
- Log.d("LinkProperties", " " + e.toString());
- }
+ /**
+ * Adds a stacked link.
+ *
+ * If there is already a stacked link with the same interfacename as link,
+ * that link is replaced with link. Otherwise, link is added to the list
+ * of stacked links. If link is null, nothing changes.
+ *
+ * @param link The link to add.
+ */
+ public void addStackedLink(LinkProperties link) {
+ if (link != null && link.getInterfaceName() != null) {
+ mStackedLinks.put(link.getInterfaceName(), link);
}
+ }
+ /**
+ * Removes a stacked link.
+ *
+ * If there a stacked link with the same interfacename as link, it is
+ * removed. Otherwise, nothing changes.
+ *
+ * @param link The link to add.
+ */
+ public void removeStackedLink(LinkProperties link) {
+ if (link != null && link.getInterfaceName() != null) {
+ mStackedLinks.remove(link.getInterfaceName());
+ }
+ }
+
+ /**
+ * Returns all the links stacked on top of this link.
+ */
+ public Collection<LinkProperties> getStackedLinks() {
+ Collection<LinkProperties> stacked = new ArrayList<LinkProperties>();
+ for (LinkProperties link : mStackedLinks.values()) {
+ stacked.add(new LinkProperties(link));
+ }
+ return Collections.unmodifiableCollection(stacked);
+ }
+
+ public void clear() {
mIfaceName = null;
mLinkAddresses.clear();
mDnses.clear();
mDomains = null;
mRoutes.clear();
mHttpProxy = null;
+ mStackedLinks.clear();
}
/**
@@ -219,7 +273,29 @@
routes += "] ";
String proxy = (mHttpProxy == null ? "" : "HttpProxy: " + mHttpProxy.toString() + " ");
- return ifaceName + linkAddresses + routes + dns + domainName + proxy;
+ String stacked = "";
+ if (mStackedLinks.values().size() > 0) {
+ stacked += " Stacked: [";
+ for (LinkProperties link: mStackedLinks.values()) {
+ stacked += " [" + link.toString() + " ],";
+ }
+ stacked += "] ";
+ }
+ return ifaceName + linkAddresses + routes + dns + domainName + proxy + stacked;
+ }
+
+ /**
+ * Returns true if this link has an IPv4 address.
+ *
+ * @return {@code true} if there is an IPv4 address, {@code false} otherwise.
+ */
+ public boolean hasIPv4Address() {
+ for (LinkAddress address : mLinkAddresses) {
+ if (address.getAddress() instanceof Inet4Address) {
+ return true;
+ }
+ }
+ return false;
}
/**
@@ -286,6 +362,26 @@
getHttpProxy().equals(target.getHttpProxy());
}
+ /**
+ * Compares this {@code LinkProperties} stacked links against the target
+ *
+ * @param target LinkProperties to compare.
+ * @return {@code true} if both are identical, {@code false} otherwise.
+ */
+ public boolean isIdenticalStackedLinks(LinkProperties target) {
+ if (!mStackedLinks.keys().equals(target.mStackedLinks.keys())) {
+ return false;
+ }
+ for (LinkProperties stacked : mStackedLinks.values()) {
+ // Hashtable values can never be null.
+ String iface = stacked.getInterfaceName();
+ if (!stacked.equals(target.mStackedLinks.get(iface))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
@Override
/**
* Compares this {@code LinkProperties} instance against the target
@@ -298,6 +394,10 @@
* 1. Duplicated elements. eg, (A, B, B) and (A, A, B) are equal.
* 2. Worst case performance is O(n^2).
*
+ * This method does not check that stacked interfaces are equal, because
+ * stacked interfaces are not so much a property of the link as a
+ * description of connections between links.
+ *
* @param obj the object to be tested for equality.
* @return {@code true} if both objects are equal, {@code false} otherwise.
*/
@@ -312,7 +412,8 @@
isIdenticalAddresses(target) &&
isIdenticalDnses(target) &&
isIdenticalRoutes(target) &&
- isIdenticalHttpProxy(target);
+ isIdenticalHttpProxy(target) &&
+ isIdenticalStackedLinks(target);
}
/**
@@ -394,10 +495,10 @@
*/
CompareResult<RouteInfo> result = new CompareResult<RouteInfo>();
- result.removed = new ArrayList<RouteInfo>(mRoutes);
+ result.removed = getAllRoutes();
result.added.clear();
if (target != null) {
- for (RouteInfo r : target.getRoutes()) {
+ for (RouteInfo r : target.getAllRoutes()) {
if (! result.removed.remove(r)) {
result.added.add(r);
}
@@ -419,7 +520,8 @@
+ mDnses.size() * 37
+ ((null == mDomains) ? 0 : mDomains.hashCode())
+ mRoutes.size() * 41
- + ((null == mHttpProxy) ? 0 : mHttpProxy.hashCode()));
+ + ((null == mHttpProxy) ? 0 : mHttpProxy.hashCode())
+ + mStackedLinks.hashCode() * 47);
}
/**
@@ -449,6 +551,8 @@
} else {
dest.writeByte((byte)0);
}
+ ArrayList<LinkProperties> stackedLinks = new ArrayList(mStackedLinks.values());
+ dest.writeList(stackedLinks);
}
/**
@@ -481,6 +585,11 @@
if (in.readByte() == 1) {
netProp.setHttpProxy((ProxyProperties)in.readParcelable(null));
}
+ ArrayList<LinkProperties> stackedLinks = new ArrayList<LinkProperties>();
+ in.readList(stackedLinks, LinkProperties.class.getClassLoader());
+ for (LinkProperties stackedLink: stackedLinks) {
+ netProp.addStackedLink(stackedLink);
+ }
return netProp;
}
diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java
index b35d61c..faf739b 100644
--- a/core/java/android/net/MobileDataStateTracker.java
+++ b/core/java/android/net/MobileDataStateTracker.java
@@ -522,6 +522,16 @@
}
@Override
+ public void addStackedLink(LinkProperties link) {
+ mLinkProperties.addStackedLink(link);
+ }
+
+ @Override
+ public void removeStackedLink(LinkProperties link) {
+ mLinkProperties.removeStackedLink(link);
+ }
+
+ @Override
public String toString() {
final CharArrayWriter writer = new CharArrayWriter();
final PrintWriter pw = new PrintWriter(writer);
diff --git a/core/java/android/net/NetworkStateTracker.java b/core/java/android/net/NetworkStateTracker.java
index 0a0c1e0..b22159c 100644
--- a/core/java/android/net/NetworkStateTracker.java
+++ b/core/java/android/net/NetworkStateTracker.java
@@ -197,4 +197,14 @@
* An external dependency has been met/unmet
*/
public void setDependencyMet(boolean met);
+
+ /**
+ * Informs the state tracker that another interface is stacked on top of it.
+ **/
+ public void addStackedLink(LinkProperties link);
+
+ /**
+ * Informs the state tracker that a stacked interface has been removed.
+ **/
+ public void removeStackedLink(LinkProperties link);
}
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java
index 2bec1c1..9666d9a 100644
--- a/core/java/android/os/FileUtils.java
+++ b/core/java/android/os/FileUtils.java
@@ -16,6 +16,8 @@
package android.os;
+import android.util.Log;
+
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -25,6 +27,8 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.regex.Pattern;
import java.util.zip.CRC32;
import java.util.zip.CheckedInputStream;
@@ -34,6 +38,8 @@
* @hide
*/
public class FileUtils {
+ private static final String TAG = "FileUtils";
+
public static final int S_IRWXU = 00700;
public static final int S_IRUSR = 00400;
public static final int S_IWUSR = 00200;
@@ -161,7 +167,8 @@
} else if (max < 0) { // "tail" mode: keep the last N
int len;
boolean rolled = false;
- byte[] last = null, data = null;
+ byte[] last = null;
+ byte[] data = null;
do {
if (last != null) rolled = true;
byte[] tmp = last; last = data; data = tmp;
@@ -237,4 +244,40 @@
}
}
}
+
+ /**
+ * Delete older files in a directory until only those matching the given
+ * constraints remain.
+ *
+ * @param minCount Always keep at least this many files.
+ * @param minAge Always keep files younger than this age.
+ */
+ public static void deleteOlderFiles(File dir, int minCount, long minAge) {
+ if (minCount < 0 || minAge < 0) {
+ throw new IllegalArgumentException("Constraints must be positive or 0");
+ }
+
+ final File[] files = dir.listFiles();
+ if (files == null) return;
+
+ // Sort with newest files first
+ Arrays.sort(files, new Comparator<File>() {
+ @Override
+ public int compare(File lhs, File rhs) {
+ return (int) (rhs.lastModified() - lhs.lastModified());
+ }
+ });
+
+ // Keep at least minCount files
+ for (int i = minCount; i < files.length; i++) {
+ final File file = files[i];
+
+ // Keep files newer than minAge
+ final long age = System.currentTimeMillis() - file.lastModified();
+ if (age > minAge) {
+ Log.d(TAG, "Deleting old file " + file);
+ file.delete();
+ }
+ }
+ }
}
diff --git a/core/java/android/text/GraphicsOperations.java b/core/java/android/text/GraphicsOperations.java
index 60545e5..831ccc5 100644
--- a/core/java/android/text/GraphicsOperations.java
+++ b/core/java/android/text/GraphicsOperations.java
@@ -38,7 +38,7 @@
* {@hide}
*/
void drawTextRun(Canvas c, int start, int end, int contextStart, int contextEnd,
- float x, float y, Paint p);
+ float x, float y, int flags, Paint p);
/**
* Just like {@link Paint#measureText}.
@@ -55,12 +55,19 @@
* @hide
*/
float getTextRunAdvances(int start, int end, int contextStart, int contextEnd,
- float[] advances, int advancesIndex, Paint paint);
+ int flags, float[] advances, int advancesIndex, Paint paint);
+
+ /**
+ * Just like {@link Paint#getTextRunAdvances}.
+ * @hide
+ */
+ float getTextRunAdvances(int start, int end, int contextStart, int contextEnd,
+ int flags, float[] advances, int advancesIndex, Paint paint, int reserved);
/**
* Just like {@link Paint#getTextRunCursor}.
* @hide
*/
- int getTextRunCursor(int contextStart, int contextEnd, int offset,
+ int getTextRunCursor(int contextStart, int contextEnd, int flags, int offset,
int cursorOpt, Paint p);
}
diff --git a/core/java/android/text/MeasuredText.java b/core/java/android/text/MeasuredText.java
index 0c881a4..bd9310c1 100644
--- a/core/java/android/text/MeasuredText.java
+++ b/core/java/android/text/MeasuredText.java
@@ -159,15 +159,18 @@
mPos = p + len;
if (mEasy) {
- return paint.getTextRunAdvances(mChars, p, len, p, len, mWidths, p);
+ int flags = mDir == Layout.DIR_LEFT_TO_RIGHT
+ ? Canvas.DIRECTION_LTR : Canvas.DIRECTION_RTL;
+ return paint.getTextRunAdvances(mChars, p, len, p, len, flags, mWidths, p);
}
float totalAdvance = 0;
int level = mLevels[p];
for (int q = p, i = p + 1, e = p + len;; ++i) {
if (i == e || mLevels[i] != level) {
+ int flags = (level & 0x1) == 0 ? Canvas.DIRECTION_LTR : Canvas.DIRECTION_RTL;
totalAdvance +=
- paint.getTextRunAdvances(mChars, q, i - q, q, i - q, mWidths, q);
+ paint.getTextRunAdvances(mChars, q, i - q, q, i - q, flags, mWidths, q);
if (i == e) {
break;
}
diff --git a/core/java/android/text/SpannableStringBuilder.java b/core/java/android/text/SpannableStringBuilder.java
index 9e43671..0f30d25 100644
--- a/core/java/android/text/SpannableStringBuilder.java
+++ b/core/java/android/text/SpannableStringBuilder.java
@@ -1130,20 +1130,20 @@
* {@hide}
*/
public void drawTextRun(Canvas c, int start, int end, int contextStart, int contextEnd,
- float x, float y, Paint p) {
+ float x, float y, int flags, Paint p) {
checkRange("drawTextRun", start, end);
int contextLen = contextEnd - contextStart;
int len = end - start;
if (contextEnd <= mGapStart) {
- c.drawTextRun(mText, start, len, contextStart, contextLen, x, y, p);
+ c.drawTextRun(mText, start, len, contextStart, contextLen, x, y, flags, p);
} else if (contextStart >= mGapStart) {
c.drawTextRun(mText, start + mGapLength, len, contextStart + mGapLength,
- contextLen, x, y, p);
+ contextLen, x, y, flags, p);
} else {
char[] buf = TextUtils.obtain(contextLen);
getChars(contextStart, contextEnd, buf, 0);
- c.drawTextRun(buf, start - contextStart, len, 0, contextLen, x, y, p);
+ c.drawTextRun(buf, start - contextStart, len, 0, contextLen, x, y, flags, p);
TextUtils.recycle(buf);
}
}
@@ -1200,7 +1200,7 @@
* Don't call this yourself -- exists for Paint to use internally.
* {@hide}
*/
- public float getTextRunAdvances(int start, int end, int contextStart, int contextEnd,
+ public float getTextRunAdvances(int start, int end, int contextStart, int contextEnd, int flags,
float[] advances, int advancesPos, Paint p) {
float ret;
@@ -1210,15 +1210,44 @@
if (end <= mGapStart) {
ret = p.getTextRunAdvances(mText, start, len, contextStart, contextLen,
- advances, advancesPos);
+ flags, advances, advancesPos);
} else if (start >= mGapStart) {
ret = p.getTextRunAdvances(mText, start + mGapLength, len,
- contextStart + mGapLength, contextLen, advances, advancesPos);
+ contextStart + mGapLength, contextLen, flags, advances, advancesPos);
} else {
char[] buf = TextUtils.obtain(contextLen);
getChars(contextStart, contextEnd, buf, 0);
ret = p.getTextRunAdvances(buf, start - contextStart, len,
- 0, contextLen, advances, advancesPos);
+ 0, contextLen, flags, advances, advancesPos);
+ TextUtils.recycle(buf);
+ }
+
+ return ret;
+ }
+
+ /**
+ * Don't call this yourself -- exists for Paint to use internally.
+ * {@hide}
+ */
+ public float getTextRunAdvances(int start, int end, int contextStart, int contextEnd, int flags,
+ float[] advances, int advancesPos, Paint p, int reserved) {
+
+ float ret;
+
+ int contextLen = contextEnd - contextStart;
+ int len = end - start;
+
+ if (end <= mGapStart) {
+ ret = p.getTextRunAdvances(mText, start, len, contextStart, contextLen,
+ flags, advances, advancesPos, reserved);
+ } else if (start >= mGapStart) {
+ ret = p.getTextRunAdvances(mText, start + mGapLength, len,
+ contextStart + mGapLength, contextLen, flags, advances, advancesPos, reserved);
+ } else {
+ char[] buf = TextUtils.obtain(contextLen);
+ getChars(contextStart, contextEnd, buf, 0);
+ ret = p.getTextRunAdvances(buf, start - contextStart, len,
+ 0, contextLen, flags, advances, advancesPos, reserved);
TextUtils.recycle(buf);
}
@@ -1241,7 +1270,7 @@
*
* @param contextStart the start index of the context
* @param contextEnd the (non-inclusive) end index of the context
- * @param flags reserved
+ * @param flags either DIRECTION_RTL or DIRECTION_LTR
* @param offset the cursor position to move from
* @param cursorOpt how to move the cursor, one of CURSOR_AFTER,
* CURSOR_AT_OR_AFTER, CURSOR_BEFORE,
@@ -1252,30 +1281,22 @@
*/
@Deprecated
public int getTextRunCursor(int contextStart, int contextEnd, int flags, int offset,
- int cursorOpt, Paint p) {
- return getTextRunCursor(contextStart, contextEnd, offset, cursorOpt, p);
- }
-
- /**
- * @hide
- */
- public int getTextRunCursor(int contextStart, int contextEnd, int offset,
- int cursorOpt, Paint p) {
+ int cursorOpt, Paint p) {
int ret;
int contextLen = contextEnd - contextStart;
if (contextEnd <= mGapStart) {
ret = p.getTextRunCursor(mText, contextStart, contextLen,
- offset, cursorOpt);
+ flags, offset, cursorOpt);
} else if (contextStart >= mGapStart) {
ret = p.getTextRunCursor(mText, contextStart + mGapLength, contextLen,
- offset + mGapLength, cursorOpt) - mGapLength;
+ flags, offset + mGapLength, cursorOpt) - mGapLength;
} else {
char[] buf = TextUtils.obtain(contextLen);
getChars(contextStart, contextEnd, buf, 0);
ret = p.getTextRunCursor(buf, 0, contextLen,
- offset - contextStart, cursorOpt) + contextStart;
+ flags, offset - contextStart, cursorOpt) + contextStart;
TextUtils.recycle(buf);
}
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java
index e34a0ef..1fecf81 100644
--- a/core/java/android/text/TextLine.java
+++ b/core/java/android/text/TextLine.java
@@ -664,13 +664,14 @@
}
}
+ int flags = runIsRtl ? Paint.DIRECTION_RTL : Paint.DIRECTION_LTR;
int cursorOpt = after ? Paint.CURSOR_AFTER : Paint.CURSOR_BEFORE;
if (mCharsValid) {
return wp.getTextRunCursor(mChars, spanStart, spanLimit - spanStart,
- offset, cursorOpt);
+ flags, offset, cursorOpt);
} else {
return wp.getTextRunCursor(mText, mStart + spanStart,
- mStart + spanLimit, mStart + offset, cursorOpt) - mStart;
+ mStart + spanLimit, flags, mStart + offset, cursorOpt) - mStart;
}
}
@@ -737,13 +738,15 @@
int contextLen = contextEnd - contextStart;
if (needWidth || (c != null && (wp.bgColor != 0 || wp.underlineColor != 0 || runIsRtl))) {
+ int flags = runIsRtl ? Paint.DIRECTION_RTL : Paint.DIRECTION_LTR;
if (mCharsValid) {
ret = wp.getTextRunAdvances(mChars, start, runLen,
- contextStart, contextLen, null, 0);
+ contextStart, contextLen, flags, null, 0);
} else {
int delta = mStart;
- ret = wp.getTextRunAdvances(mText, delta + start, delta + end,
- delta + contextStart, delta + contextEnd, null, 0);
+ ret = wp.getTextRunAdvances(mText, delta + start,
+ delta + end, delta + contextStart, delta + contextEnd,
+ flags, null, 0);
}
}
@@ -783,7 +786,8 @@
wp.setAntiAlias(previousAntiAlias);
}
- drawTextRun(c, wp, start, end, contextStart, contextEnd, x, y + wp.baselineShift);
+ drawTextRun(c, wp, start, end, contextStart, contextEnd, runIsRtl,
+ x, y + wp.baselineShift);
}
return runIsRtl ? -ret : ret;
@@ -966,21 +970,23 @@
* @param end the end of the run
* @param contextStart the start of context for the run
* @param contextEnd the end of the context for the run
+ * @param runIsRtl true if the run is right-to-left
* @param x the x position of the left edge of the run
* @param y the baseline of the run
*/
private void drawTextRun(Canvas c, TextPaint wp, int start, int end,
- int contextStart, int contextEnd, float x, int y) {
+ int contextStart, int contextEnd, boolean runIsRtl, float x, int y) {
+ int flags = runIsRtl ? Canvas.DIRECTION_RTL : Canvas.DIRECTION_LTR;
if (mCharsValid) {
int count = end - start;
int contextCount = contextEnd - contextStart;
c.drawTextRun(mChars, start, count, contextStart, contextCount,
- x, y, wp);
+ x, y, flags, wp);
} else {
int delta = mStart;
c.drawTextRun(mText, delta + start, delta + end,
- delta + contextStart, delta + contextEnd, x, y, wp);
+ delta + contextStart, delta + contextEnd, x, y, flags, wp);
}
}
diff --git a/core/java/android/text/bidi/BidiFormatter.java b/core/java/android/text/bidi/BidiFormatter.java
index 370cbf7..c5a77a6 100644
--- a/core/java/android/text/bidi/BidiFormatter.java
+++ b/core/java/android/text/bidi/BidiFormatter.java
@@ -172,9 +172,9 @@
* A class for building a BidiFormatter with non-default options.
*/
public static final class Builder {
- private boolean isRtlContext;
- private int flags;
- private TextDirectionHeuristic textDirectionHeuristic;
+ private boolean mIsRtlContext;
+ private int mFlags;
+ private TextDirectionHeuristic mTextDirectionHeuristic;
/**
* Constructor.
@@ -208,9 +208,9 @@
* @param isRtlContext Whether the context is RTL or not.
*/
private void initialize(boolean isRtlContext) {
- this.isRtlContext = isRtlContext;
- textDirectionHeuristic = DEFAULT_TEXT_DIRECTION_HEURISTIC;
- this.flags = DEFAULT_FLAGS;
+ mIsRtlContext = isRtlContext;
+ mTextDirectionHeuristic = DEFAULT_TEXT_DIRECTION_HEURISTIC;
+ mFlags = DEFAULT_FLAGS;
}
/**
@@ -219,9 +219,9 @@
*/
public Builder stereoReset(boolean stereoReset) {
if (stereoReset) {
- flags |= FLAG_STEREO_RESET;
+ mFlags |= FLAG_STEREO_RESET;
} else {
- flags &= ~FLAG_STEREO_RESET;
+ mFlags &= ~FLAG_STEREO_RESET;
}
return this;
}
@@ -234,7 +234,7 @@
* @return the builder itself.
*/
public Builder setTextDirectionHeuristic(TextDirectionHeuristic heuristic) {
- this.textDirectionHeuristic = heuristic;
+ mTextDirectionHeuristic = heuristic;
return this;
}
@@ -246,11 +246,11 @@
* @return A BidiFormatter with the specified options.
*/
public BidiFormatter build() {
- if (flags == DEFAULT_FLAGS &&
- textDirectionHeuristic == DEFAULT_TEXT_DIRECTION_HEURISTIC) {
- return getDefaultInstanceFromContext(isRtlContext);
+ if (mFlags == DEFAULT_FLAGS &&
+ mTextDirectionHeuristic == DEFAULT_TEXT_DIRECTION_HEURISTIC) {
+ return getDefaultInstanceFromContext(mIsRtlContext);
}
- return new BidiFormatter(isRtlContext, flags, textDirectionHeuristic);
+ return new BidiFormatter(mIsRtlContext, mFlags, mTextDirectionHeuristic);
}
}
@@ -268,9 +268,9 @@
DEFAULT_FLAGS,
DEFAULT_TEXT_DIRECTION_HEURISTIC);
- private final boolean isRtlContext;
- private final int flags;
- private final TextDirectionHeuristic defaultTextDirectionHeuristic;
+ private final boolean mIsRtlContext;
+ private final int mFlags;
+ private final TextDirectionHeuristic mDefaultTextDirectionHeuristic;
/**
* Factory for creating an instance of BidiFormatter given the context directionality.
@@ -296,16 +296,16 @@
* @param heuristic The default text direction heuristic.
*/
private BidiFormatter(boolean isRtlContext, int flags, TextDirectionHeuristic heuristic) {
- this.isRtlContext = isRtlContext;
- this.flags = flags;
- this.defaultTextDirectionHeuristic = heuristic;
+ mIsRtlContext = isRtlContext;
+ mFlags = flags;
+ mDefaultTextDirectionHeuristic = heuristic;
}
/**
* @return Whether the context directionality is RTL
*/
public boolean isRtlContext() {
- return isRtlContext;
+ return mIsRtlContext;
}
/**
@@ -313,7 +313,7 @@
* bidi-wrapped, not just after it.
*/
public boolean getStereoReset() {
- return (flags & FLAG_STEREO_RESET) != 0;
+ return (mFlags & FLAG_STEREO_RESET) != 0;
}
/**
@@ -384,7 +384,7 @@
* context; else, the empty string.
*/
public String dirAttr(boolean isRtl) {
- return (isRtl != isRtlContext) ? (isRtl ? DIR_RTL_STRING : DIR_LTR_STRING) : EMPTY_STRING;
+ return (isRtl != mIsRtlContext) ? (isRtl ? DIR_RTL_STRING : DIR_LTR_STRING) : EMPTY_STRING;
}
/**
@@ -401,7 +401,7 @@
* else, the empty string.
*/
public String markAfter(String str) {
- return markAfter(str, defaultTextDirectionHeuristic);
+ return markAfter(str, mDefaultTextDirectionHeuristic);
}
/**
@@ -417,10 +417,10 @@
public String markAfter(String str, TextDirectionHeuristic heuristic) {
final boolean isRtl = heuristic.isRtl(str, 0, str.length());
// getExitDir() is called only if needed (short-circuit).
- if (!isRtlContext && (isRtl || getExitDir(str) == DIR_RTL)) {
+ if (!mIsRtlContext && (isRtl || getExitDir(str) == DIR_RTL)) {
return LRM_STRING;
}
- if (isRtlContext && (!isRtl || getExitDir(str) == DIR_LTR)) {
+ if (mIsRtlContext && (!isRtl || getExitDir(str) == DIR_LTR)) {
return RLM_STRING;
}
return EMPTY_STRING;
@@ -440,7 +440,7 @@
* else, the empty string.
*/
public String markBefore(String str) {
- return markBefore(str, defaultTextDirectionHeuristic);
+ return markBefore(str, mDefaultTextDirectionHeuristic);
}
/**
@@ -456,10 +456,10 @@
public String markBefore(String str, TextDirectionHeuristic heuristic) {
final boolean isRtl = heuristic.isRtl(str, 0, str.length());
// getEntryDir() is called only if needed (short-circuit).
- if (!isRtlContext && (isRtl || getEntryDir(str) == DIR_RTL)) {
+ if (!mIsRtlContext && (isRtl || getEntryDir(str) == DIR_RTL)) {
return LRM_STRING;
}
- if (isRtlContext && (!isRtl || getEntryDir(str) == DIR_LTR)) {
+ if (mIsRtlContext && (!isRtl || getEntryDir(str) == DIR_LTR)) {
return RLM_STRING;
}
return EMPTY_STRING;
@@ -470,7 +470,7 @@
* directionality, RLM for RTL context directionality).
*/
public String mark() {
- return isRtlContext ? RLM_STRING : LRM_STRING;
+ return mIsRtlContext ? RLM_STRING : LRM_STRING;
}
/**
@@ -478,7 +478,7 @@
* returns "left".
*/
public String startEdge() {
- return isRtlContext ? RIGHT : LEFT;
+ return mIsRtlContext ? RIGHT : LEFT;
}
/**
@@ -486,7 +486,7 @@
* returns "right".
*/
public String endEdge() {
- return isRtlContext ? LEFT : RIGHT;
+ return mIsRtlContext ? LEFT : RIGHT;
}
/**
@@ -497,7 +497,7 @@
* false.
*/
public boolean isRtl(String str) {
- return defaultTextDirectionHeuristic.isRtl(str, 0, str.length());
+ return mDefaultTextDirectionHeuristic.isRtl(str, 0, str.length());
}
/**
@@ -536,7 +536,7 @@
result.append(markBefore(origStr,
isRtl ? TextDirectionHeuristics.RTL : TextDirectionHeuristics.LTR));
}
- if (isRtl != isRtlContext) {
+ if (isRtl != mIsRtlContext) {
result.append("<span ").append(dirAttr(isRtl)).append('>').append(str).append("</span>");
} else {
result.append(str);
@@ -570,7 +570,7 @@
* @return Input string after applying the above processing.
*/
public String spanWrap(String str, boolean isolate) {
- return spanWrap(str, defaultTextDirectionHeuristic, isolate);
+ return spanWrap(str, mDefaultTextDirectionHeuristic, isolate);
}
/**
@@ -581,7 +581,7 @@
* @return Input string after applying the above processing.
*/
public String spanWrap(String str) {
- return spanWrap(str, defaultTextDirectionHeuristic, true /* isolate */);
+ return spanWrap(str, mDefaultTextDirectionHeuristic, true /* isolate */);
}
/**
@@ -620,7 +620,7 @@
result.append(markBefore(str,
isRtl ? TextDirectionHeuristics.RTL : TextDirectionHeuristics.LTR));
}
- if (isRtl != isRtlContext) {
+ if (isRtl != mIsRtlContext) {
result.append(isRtl ? RLE : LRE);
result.append(str);
result.append(PDF);
@@ -656,7 +656,7 @@
* @return Input string after applying the above processing.
*/
public String unicodeWrap(String str, boolean isolate) {
- return unicodeWrap(str, defaultTextDirectionHeuristic, isolate);
+ return unicodeWrap(str, mDefaultTextDirectionHeuristic, isolate);
}
/**
@@ -667,7 +667,7 @@
* @return Input string after applying the above processing.
*/
public String unicodeWrap(String str) {
- return unicodeWrap(str, defaultTextDirectionHeuristic, true /* isolate */);
+ return unicodeWrap(str, mDefaultTextDirectionHeuristic, true /* isolate */);
}
/**
diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java
index be4663d..f813df3 100644
--- a/core/java/android/text/format/DateFormat.java
+++ b/core/java/android/text/format/DateFormat.java
@@ -43,11 +43,17 @@
* for both formatting and parsing dates. For the canonical documentation
* of format strings, see {@link java.text.SimpleDateFormat}.
*
- * <p>The format methods in this class implement a subset of Unicode
+ * <p>The {@code format} methods in this class implement a subset of Unicode
* <a href="http://www.unicode.org/reports/tr35/#Date_Format_Patterns">UTS #35</a> patterns.
- * The subset supported by this class includes the following format characters:
- * {@code acdEHhLKkLMmsyz}. See {@link java.text.SimpleDateFormat} for more documentation
- * about patterns, or if you need a more compete implementation.
+ * The subset currently supported by this class includes the following format characters:
+ * {@code acdEHhLKkLMmsyz}. Up to API level 17, only {@code adEhkMmszy} were supported.
+ * Note that this class incorrectly implements {@code k} as if it were {@code H} for backwards
+ * compatibility.
+ *
+ * <p>See {@link java.text.SimpleDateFormat} for more documentation
+ * about patterns, or if you need a more complete or correct implementation.
+ * Note that the non-{@code format} methods in this class are implemented by
+ * {@code SimpleDateFormat}.
*/
public class DateFormat {
/** @deprecated Use a literal {@code '} instead. */
@@ -74,7 +80,11 @@
@Deprecated
public static final char HOUR = 'h';
- /** @deprecated Use a literal {@code 'k'} instead. */
+ /**
+ * @deprecated Use a literal {@code 'H'} (for compatibility with {@link SimpleDateFormat}
+ * and Unicode) or {@code 'k'} (for compatibility with Android releases up to and including
+ * Jelly Bean MR-1) instead. Note that the two are incompatible.
+ */
@Deprecated
public static final char HOUR_OF_DAY = 'k';
@@ -160,9 +170,18 @@
* @return the {@link java.text.DateFormat} object that properly formats the time.
*/
public static java.text.DateFormat getTimeFormat(Context context) {
+ return new java.text.SimpleDateFormat(getTimeFormatString(context));
+ }
+
+ /**
+ * Returns a String pattern that can be used to format the time according
+ * to the current locale and the user's 12-/24-hour clock preference.
+ * @param context the application context
+ * @hide
+ */
+ public static String getTimeFormatString(Context context) {
LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale);
- boolean is24 = is24HourFormat(context);
- return new java.text.SimpleDateFormat(is24 ? d.timeFormat24 : d.timeFormat12);
+ return is24HourFormat(context) ? d.timeFormat24 : d.timeFormat12;
}
/**
@@ -451,10 +470,13 @@
}
break;
case 'H': // hour in day (0-23)
- case 'k': // hour in day (1-24)
+ case 'k': // hour in day (1-24) [but see note below]
{
int hour = inDate.get(Calendar.HOUR_OF_DAY);
- if (c == 'k' && hour == 0) {
+ // Historically on Android 'k' was interpreted as 'H', which wasn't
+ // implemented, so pretty much all callers that want to format 24-hour
+ // times are abusing 'k'. http://b/8359981.
+ if (false && c == 'k' && hour == 0) {
hour = 24;
}
replacement = zeroPad(hour, count);
diff --git a/core/java/android/text/format/DateUtils.java b/core/java/android/text/format/DateUtils.java
index 6c8a737..7e9d811 100644
--- a/core/java/android/text/format/DateUtils.java
+++ b/core/java/android/text/format/DateUtils.java
@@ -288,36 +288,6 @@
}
/**
- * Return a localized string for the month of the year, for
- * contexts where the month is not formatted together with
- * a day of the month.
- *
- * @param month One of {@link Calendar#JANUARY Calendar.JANUARY},
- * {@link Calendar#FEBRUARY Calendar.FEBRUARY}, etc.
- * @param abbrev One of {@link #LENGTH_LONG}, {@link #LENGTH_MEDIUM},
- * or {@link #LENGTH_SHORTEST}.
- * Undefined lengths will return {@link #LENGTH_MEDIUM}
- * but may return something different in the future.
- * @return Localized month of the year.
- * @hide Pending API council approval
- * @deprecated use {@link java.text.SimpleDateFormat} instead.
- */
- @Deprecated
- public static String getStandaloneMonthString(int month, int abbrev) {
- LocaleData d = LocaleData.get(Locale.getDefault());
- String[] names;
- switch (abbrev) {
- case LENGTH_LONG: names = d.longStandAloneMonthNames; break;
- case LENGTH_MEDIUM: names = d.shortMonthNames; break;
- case LENGTH_SHORT: names = d.shortMonthNames; break;
- case LENGTH_SHORTER: names = d.shortMonthNames; break;
- case LENGTH_SHORTEST: names = d.tinyStandAloneMonthNames; break;
- default: names = d.shortMonthNames; break;
- }
- return names[month];
- }
-
- /**
* Returns a string describing the elapsed time since startTime.
* @param startTime some time in the past.
* @return a String object containing the elapsed time.
@@ -551,18 +521,6 @@
}
/**
- * Format a time so it appears like it would in the status bar clock.
- * @deprecated use {@link #DateFormat.getTimeFormat(Context)} instead.
- * @hide
- */
- public static final CharSequence timeString(long millis) {
- synchronized (sLock) {
- initFormatStringsLocked();
- return sStatusTimeFormat.format(millis);
- }
- }
-
- /**
* Return given duration in a human-friendly format. For example, "4
* minutes" or "1 second". Returns only largest meaningful unit of time,
* from seconds up to hours.
@@ -676,18 +634,6 @@
}
/**
- * @hide
- * @deprecated use {@link android.text.format.Time}
- */
- public static Calendar newCalendar(boolean zulu)
- {
- if (zulu)
- return Calendar.getInstance(TimeZone.getTimeZone("GMT"));
-
- return Calendar.getInstance();
- }
-
- /**
* @return true if the supplied when is today else false
*/
public static boolean isToday(long when) {
@@ -705,23 +651,6 @@
}
/**
- * @hide
- * @deprecated use {@link android.text.format.Time}
- * Return true if this date string is local time
- */
- public static boolean isUTC(String s)
- {
- if (s.length() == 16 && s.charAt(15) == 'Z') {
- return true;
- }
- if (s.length() == 9 && s.charAt(8) == 'Z') {
- // XXX not sure if this case possible/valid
- return true;
- }
- return false;
- }
-
- /**
* Return a string containing the date and time in RFC2445 format.
* Ensures that the time is written in UTC. The Calendar class doesn't
* really help out with this, so this is slower than it ought to be.
@@ -815,17 +744,6 @@
}
/**
- * @hide
- * @deprecated use {@link android.text.format.Time}
- */
- public static void assign(Calendar lval, Calendar rval)
- {
- // there should be a faster way.
- lval.clear();
- lval.setTimeInMillis(rval.getTimeInMillis());
- }
-
- /**
* Formats a date or a time range according to the local conventions.
* <p>
* Note that this is a convenience method. Using it involves creating an
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index 6c48e43..c369ebe 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -1162,14 +1162,14 @@
int modifiers = setupModifiers(paint);
try {
- nDrawText(mRenderer, text, index, count, x, y, paint.mNativePaint);
+ nDrawText(mRenderer, text, index, count, x, y, paint.mBidiFlags, paint.mNativePaint);
} finally {
if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
}
}
private static native void nDrawText(int renderer, char[] text, int index, int count,
- float x, float y, int paint);
+ float x, float y, int bidiFlags, int paint);
@Override
public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
@@ -1177,14 +1177,16 @@
try {
if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) {
- nDrawText(mRenderer, text.toString(), start, end, x, y, paint.mNativePaint);
+ nDrawText(mRenderer, text.toString(), start, end, x, y, paint.mBidiFlags,
+ paint.mNativePaint);
} else if (text instanceof GraphicsOperations) {
((GraphicsOperations) text).drawText(this, start, end, x, y,
paint);
} else {
char[] buf = TemporaryBuffer.obtain(end - start);
TextUtils.getChars(text, start, end, buf, 0);
- nDrawText(mRenderer, buf, 0, end - start, x, y, paint.mNativePaint);
+ nDrawText(mRenderer, buf, 0, end - start, x, y,
+ paint.mBidiFlags, paint.mNativePaint);
TemporaryBuffer.recycle(buf);
}
} finally {
@@ -1200,20 +1202,21 @@
int modifiers = setupModifiers(paint);
try {
- nDrawText(mRenderer, text, start, end, x, y, paint.mNativePaint);
+ nDrawText(mRenderer, text, start, end, x, y, paint.mBidiFlags, paint.mNativePaint);
} finally {
if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
}
}
private static native void nDrawText(int renderer, String text, int start, int end,
- float x, float y, int paint);
+ float x, float y, int bidiFlags, int paint);
@Override
public void drawText(String text, float x, float y, Paint paint) {
int modifiers = setupModifiers(paint);
try {
- nDrawText(mRenderer, text, 0, text.length(), x, y, paint.mNativePaint);
+ nDrawText(mRenderer, text, 0, text.length(), x, y, paint.mBidiFlags,
+ paint.mNativePaint);
} finally {
if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
}
@@ -1229,14 +1232,14 @@
int modifiers = setupModifiers(paint);
try {
nDrawTextOnPath(mRenderer, text, index, count, path.mNativePath, hOffset, vOffset,
- paint.mNativePaint);
+ paint.mBidiFlags, paint.mNativePaint);
} finally {
if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
}
}
private static native void nDrawTextOnPath(int renderer, char[] text, int index, int count,
- int path, float hOffset, float vOffset, int nativePaint);
+ int path, float hOffset, float vOffset, int bidiFlags, int nativePaint);
@Override
public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) {
@@ -1245,25 +1248,28 @@
int modifiers = setupModifiers(paint);
try {
nDrawTextOnPath(mRenderer, text, 0, text.length(), path.mNativePath, hOffset, vOffset,
- paint.mNativePaint);
+ paint.mBidiFlags, paint.mNativePaint);
} finally {
if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
}
}
private static native void nDrawTextOnPath(int renderer, String text, int start, int end,
- int path, float hOffset, float vOffset, int nativePaint);
+ int path, float hOffset, float vOffset, int bidiFlags, int nativePaint);
@Override
public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount,
- float x, float y, Paint paint) {
+ float x, float y, int dir, Paint paint) {
if ((index | count | text.length - index - count) < 0) {
throw new IndexOutOfBoundsException();
}
+ if (dir != DIRECTION_LTR && dir != DIRECTION_RTL) {
+ throw new IllegalArgumentException("Unknown direction: " + dir);
+ }
int modifiers = setupModifiers(paint);
try {
- nDrawTextRun(mRenderer, text, index, count, contextIndex, contextCount, x, y,
+ nDrawTextRun(mRenderer, text, index, count, contextIndex, contextCount, x, y, dir,
paint.mNativePaint);
} finally {
if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
@@ -1271,31 +1277,32 @@
}
private static native void nDrawTextRun(int renderer, char[] text, int index, int count,
- int contextIndex, int contextCount, float x, float y, int nativePaint);
+ int contextIndex, int contextCount, float x, float y, int dir, int nativePaint);
@Override
public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd,
- float x, float y, Paint paint) {
+ float x, float y, int dir, Paint paint) {
if ((start | end | end - start | text.length() - end) < 0) {
throw new IndexOutOfBoundsException();
}
int modifiers = setupModifiers(paint);
try {
+ int flags = dir == 0 ? 0 : 1;
if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) {
nDrawTextRun(mRenderer, text.toString(), start, end, contextStart,
- contextEnd, x, y, paint.mNativePaint);
+ contextEnd, x, y, flags, paint.mNativePaint);
} else if (text instanceof GraphicsOperations) {
((GraphicsOperations) text).drawTextRun(this, start, end,
- contextStart, contextEnd, x, y, paint);
+ contextStart, contextEnd, x, y, flags, paint);
} else {
int contextLen = contextEnd - contextStart;
int len = end - start;
char[] buf = TemporaryBuffer.obtain(contextLen);
TextUtils.getChars(text, contextStart, contextEnd, buf, 0);
nDrawTextRun(mRenderer, buf, start - contextStart, len, 0, contextLen,
- x, y, paint.mNativePaint);
+ x, y, flags, paint.mNativePaint);
TemporaryBuffer.recycle(buf);
}
} finally {
@@ -1304,7 +1311,7 @@
}
private static native void nDrawTextRun(int renderer, String text, int start, int end,
- int contextStart, int contextEnd, float x, float y, int nativePaint);
+ int contextStart, int contextEnd, float x, float y, int flags, int nativePaint);
@Override
public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset,
diff --git a/core/java/android/view/GLES20RecordingCanvas.java b/core/java/android/view/GLES20RecordingCanvas.java
index 947cf44..7da2451 100644
--- a/core/java/android/view/GLES20RecordingCanvas.java
+++ b/core/java/android/view/GLES20RecordingCanvas.java
@@ -267,15 +267,15 @@
@Override
public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount,
- float x, float y, Paint paint) {
- super.drawTextRun(text, index, count, contextIndex, contextCount, x, y, paint);
+ float x, float y, int dir, Paint paint) {
+ super.drawTextRun(text, index, count, contextIndex, contextCount, x, y, dir, paint);
recordShaderBitmap(paint);
}
@Override
public void drawTextRun(CharSequence text, int start, int end, int contextStart,
- int contextEnd, float x, float y, Paint paint) {
- super.drawTextRun(text, start, end, contextStart, contextEnd, x, y, paint);
+ int contextEnd, float x, float y, int dir, Paint paint) {
+ super.drawTextRun(text, start, end, contextStart, contextEnd, x, y, dir, paint);
recordShaderBitmap(paint);
}
diff --git a/core/java/android/view/Overlay.java b/core/java/android/view/Overlay.java
new file mode 100644
index 0000000..f15d4d2
--- /dev/null
+++ b/core/java/android/view/Overlay.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2013 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 android.view;
+
+import android.graphics.drawable.Drawable;
+
+/**
+ * An overlay is an extra layer that sits on top of a View (the "host view") which is drawn after
+ * all other content in that view (including children, if the view is a ViewGroup). Interaction
+ * with the overlay layer is done in terms of adding/removing views and drawables. Invalidation and
+ * redrawing of the overlay layer (and its host view) is handled differently for views versus
+ * drawables in the overlay. Views invalidate themselves as usual, causing appropriate redrawing
+ * to occur automatically. Drawables, on the other hand, do not manage invalidation, so changes to
+ * drawable objects should be accompanied by appropriate calls to invalidate() on the host view.
+ *
+ * @see android.view.View#getOverlay()
+ */
+public interface Overlay {
+
+ /**
+ * Adds a Drawable to the overlay. The bounds of the drawable should be relative to
+ * the host view. Any drawable added to the overlay should be removed when it is no longer
+ * needed or no longer visible. There is no automatic invalidation of the host view; changes to
+ * the drawable should be accompanied by appropriate invalidation calls to the host view
+ * to cause the proper area of the view, and the overlay, to be redrawn.
+ *
+ * @param drawable The Drawable to be added to the overlay. This drawable will be
+ * drawn when the view redraws its overlay.
+ * @see #remove(android.graphics.drawable.Drawable)
+ * @see #add(View)
+ */
+ void add(Drawable drawable);
+
+ /**
+ * Removes the specified Drawable from the overlay.
+ *
+ * @param drawable The Drawable to be removed from the overlay.
+ * @see #add(android.graphics.drawable.Drawable)
+ */
+ void remove(Drawable drawable);
+
+ /**
+ * Adds a View to the overlay. The bounds of the added view should be relative to
+ * the host view. Any view added to the overlay should be removed when it is no longer
+ * needed or no longer visible. The view must not be parented elsewhere when it is added
+ * to the overlay.
+ *
+ * @param view The View to be added to the overlay. The added view will be
+ * drawn when the overlay is drawn.
+ * @see #remove(View)
+ * @see #add(android.graphics.drawable.Drawable)
+ */
+ void add(View view);
+
+ /**
+ * Removes the specified View from the overlay.
+ *
+ * @param view The View to be removed from the overlay.
+ * @see #add(View)
+ */
+ void remove(View view);
+
+ /**
+ * Removes all views and drawables from the overlay.
+ */
+ void clear();
+}
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 0492d29..edfef56 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -72,6 +72,9 @@
// mNativeSurface.
int mNativeObject; // package scope only for SurfaceControl access
+ // protects the native state
+ private final Object mNativeObjectLock = new Object();
+
private int mGenerationId; // incremented each time mNativeSurface changes
@SuppressWarnings("UnusedDeclaration")
private final Canvas mCanvas = new CompatibleCanvas();
@@ -157,12 +160,14 @@
* This will make the surface invalid.
*/
public void release() {
- if (mNativeObject != 0) {
- nativeRelease(mNativeObject);
- mNativeObject = 0;
- mGenerationId++;
+ synchronized (mNativeObjectLock) {
+ if (mNativeObject != 0) {
+ nativeRelease(mNativeObject);
+ mNativeObject = 0;
+ mGenerationId++;
+ }
+ mCloseGuard.close();
}
- mCloseGuard.close();
}
/**
@@ -182,8 +187,10 @@
* Otherwise returns false.
*/
public boolean isValid() {
- if (mNativeObject == 0) return false;
- return nativeIsValid(mNativeObject);
+ synchronized (mNativeObjectLock) {
+ if (mNativeObject == 0) return false;
+ return nativeIsValid(mNativeObject);
+ }
}
/**
@@ -204,8 +211,10 @@
* @hide
*/
public boolean isConsumerRunningBehind() {
- checkNotReleased();
- return nativeIsConsumerRunningBehind(mNativeObject);
+ synchronized (mNativeObjectLock) {
+ checkNotReleasedLocked();
+ return nativeIsConsumerRunningBehind(mNativeObject);
+ }
}
/**
@@ -225,8 +234,10 @@
*/
public Canvas lockCanvas(Rect inOutDirty)
throws OutOfResourcesException, IllegalArgumentException {
- checkNotReleased();
- return nativeLockCanvas(mNativeObject, inOutDirty);
+ synchronized (mNativeObjectLock) {
+ checkNotReleasedLocked();
+ return nativeLockCanvas(mNativeObject, inOutDirty);
+ }
}
/**
@@ -236,8 +247,10 @@
* @param canvas The canvas previously obtained from {@link #lockCanvas}.
*/
public void unlockCanvasAndPost(Canvas canvas) {
- checkNotReleased();
- nativeUnlockCanvasAndPost(mNativeObject, canvas);
+ synchronized (mNativeObjectLock) {
+ checkNotReleasedLocked();
+ nativeUnlockCanvasAndPost(mNativeObject, canvas);
+ }
}
/**
@@ -278,38 +291,40 @@
throw new NullPointerException(
"SurfaceControl native object is null. Are you using a released SurfaceControl?");
}
- mNativeObject = nativeCopyFrom(mNativeObject, other.mNativeObject);
- if (mNativeObject == 0) {
- // nativeCopyFrom released our reference
- mCloseGuard.close();
+ synchronized (mNativeObjectLock) {
+ mNativeObject = nativeCopyFrom(mNativeObject, other.mNativeObject);
+ if (mNativeObject == 0) {
+ // nativeCopyFrom released our reference
+ mCloseGuard.close();
+ }
+ mGenerationId++;
}
- mGenerationId++;
}
/**
- * Transfer the native state from 'other' to this surface, releasing it
- * from 'other'. This is for use in the client side for drawing into a
- * surface; not guaranteed to work on the window manager side.
- * This is for use by the client to move the underlying surface from
- * one Surface object to another, in particular in SurfaceFlinger.
- * @hide.
+ * This is intended to be used by {@link SurfaceView.updateWindow} only.
+ * @param other access is not thread safe
+ * @hide
+ * @deprecated
*/
+ @Deprecated
public void transferFrom(Surface other) {
if (other == null) {
throw new IllegalArgumentException("other must not be null");
}
if (other != this) {
- if (mNativeObject != 0) {
- // release our reference to our native object
- nativeRelease(mNativeObject);
+ synchronized (mNativeObjectLock) {
+ if (mNativeObject != 0) {
+ // release our reference to our native object
+ nativeRelease(mNativeObject);
+ }
+ // transfer the reference from other to us
+ if (other.mNativeObject != 0 && mNativeObject == 0) {
+ mCloseGuard.open("release");
+ }
+ mNativeObject = other.mNativeObject;
+ mGenerationId++;
}
- // transfer the reference from other to us
- if (other.mNativeObject != 0 && mNativeObject == 0) {
- mCloseGuard.open("release");
- }
- mNativeObject = other.mNativeObject;
- mGenerationId++;
-
other.mNativeObject = 0;
other.mGenerationId++;
other.mCloseGuard.close();
@@ -325,13 +340,15 @@
if (source == null) {
throw new IllegalArgumentException("source must not be null");
}
- mName = source.readString();
- int nativeObject = nativeReadFromParcel(mNativeObject, source);
- if (nativeObject !=0 && mNativeObject == 0) {
- mCloseGuard.open("release");
+ synchronized (mNativeObjectLock) {
+ mName = source.readString();
+ int nativeObject = nativeReadFromParcel(mNativeObject, source);
+ if (nativeObject !=0 && mNativeObject == 0) {
+ mCloseGuard.open("release");
+ }
+ mNativeObject = nativeObject;
+ mGenerationId++;
}
- mNativeObject = nativeObject;
- mGenerationId++;
}
@Override
@@ -339,8 +356,10 @@
if (dest == null) {
throw new IllegalArgumentException("dest must not be null");
}
- dest.writeString(mName);
- nativeWriteToParcel(mNativeObject, dest);
+ synchronized (mNativeObjectLock) {
+ dest.writeString(mName);
+ nativeWriteToParcel(mNativeObject, dest);
+ }
if ((flags & Parcelable.PARCELABLE_WRITE_RETURN_VALUE) != 0) {
release();
}
@@ -433,7 +452,7 @@
}
}
- private void checkNotReleased() {
+ private void checkNotReleasedLocked() {
if (mNativeObject == 0) throw new NullPointerException(
"mNativeObject is null. Have you called release() already?");
}
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index df07dcd..e869d09 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -574,7 +574,8 @@
* @param maxLayer The highest (top-most Z order) surface layer to
* include in the screenshot.
* @return Returns a Bitmap containing the screen contents, or null
- * if an error occurs.
+ * if an error occurs. Make sure to call Bitmap.recycle() as soon as
+ * possible, once its content is not needed anymore.
*/
public static Bitmap screenshot(int width, int height, int minLayer, int maxLayer) {
// TODO: should take the display as a parameter
@@ -586,6 +587,14 @@
/**
* Like {@link SurfaceControl#screenshot(int, int, int, int)} but includes all
* Surfaces in the screenshot.
+ *
+ * @param width The desired width of the returned bitmap; the raw
+ * screen will be scaled down to this size.
+ * @param height The desired height of the returned bitmap; the raw
+ * screen will be scaled down to this size.
+ * @return Returns a Bitmap containing the screen contents, or null
+ * if an error occurs. Make sure to call Bitmap.recycle() as soon as
+ * possible, once its content is not needed anymore.
*/
public static Bitmap screenshot(int width, int height) {
// TODO: should take the display as a parameter
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 2e60f51..34f5a2b 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -3223,6 +3223,12 @@
AccessibilityDelegate mAccessibilityDelegate;
/**
+ * The view's overlay layer. Developers get a reference to the overlay via getOverlay()
+ * and add/remove objects to/from the overlay directly through the Overlay methods.
+ */
+ ViewOverlay mOverlay;
+
+ /**
* Consistency verifier for debugging purposes.
* @hide
*/
@@ -5038,7 +5044,8 @@
}
if ((mAttachInfo.mAccessibilityFetchFlags
- & AccessibilityNodeInfo.FLAG_REPORT_VIEW_IDS) != 0) {
+ & AccessibilityNodeInfo.FLAG_REPORT_VIEW_IDS) != 0
+ && Resources.resourceHasPackage(mID)) {
try {
String viewId = getResources().getResourceName(mID);
info.setViewIdResourceName(viewId);
@@ -6068,8 +6075,7 @@
mTransientStateCount = 0;
Log.e(VIEW_LOG_TAG, "hasTransientState decremented below 0: " +
"unmatched pair of setHasTransientState calls");
- }
- if ((hasTransientState && mTransientStateCount == 1) ||
+ } else if ((hasTransientState && mTransientStateCount == 1) ||
(!hasTransientState && mTransientStateCount == 0)) {
// update flag if we've just incremented up from 0 or decremented down to 0
mPrivateFlags2 = (mPrivateFlags2 & ~PFLAG2_HAS_TRANSIENT_STATE) |
@@ -9589,7 +9595,7 @@
mDisplayList.setTop(mTop);
}
- onSizeChanged(width, mBottom - mTop, width, oldHeight);
+ sizeChange(width, mBottom - mTop, width, oldHeight);
if (!matrixIsIdentity) {
if ((mPrivateFlags & PFLAG_PIVOT_EXPLICITLY_SET) == 0) {
@@ -9662,7 +9668,7 @@
mDisplayList.setBottom(mBottom);
}
- onSizeChanged(width, mBottom - mTop, width, oldHeight);
+ sizeChange(width, mBottom - mTop, width, oldHeight);
if (!matrixIsIdentity) {
if ((mPrivateFlags & PFLAG_PIVOT_EXPLICITLY_SET) == 0) {
@@ -9729,7 +9735,7 @@
mDisplayList.setLeft(left);
}
- onSizeChanged(mRight - mLeft, height, oldWidth, height);
+ sizeChange(mRight - mLeft, height, oldWidth, height);
if (!matrixIsIdentity) {
if ((mPrivateFlags & PFLAG_PIVOT_EXPLICITLY_SET) == 0) {
@@ -9793,7 +9799,7 @@
mDisplayList.setRight(mRight);
}
- onSizeChanged(mRight - mLeft, height, oldWidth, height);
+ sizeChange(mRight - mLeft, height, oldWidth, height);
if (!matrixIsIdentity) {
if ((mPrivateFlags & PFLAG_PIVOT_EXPLICITLY_SET) == 0) {
@@ -11553,7 +11559,10 @@
final int scrollY = mScrollY;
final int inside = (viewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0;
- int left, top, right, bottom;
+ int left;
+ int top;
+ int right;
+ int bottom;
if (drawHorizontalScrollBar) {
int size = scrollBar.getSize(false);
@@ -12088,6 +12097,9 @@
void dispatchAttachedToWindow(AttachInfo info, int visibility) {
//System.out.println("Attached! " + this);
mAttachInfo = info;
+ if (mOverlay != null) {
+ mOverlay.mAttachInfo = info;
+ }
mWindowAttachCount++;
// We will need to evaluate the drawable state at least once.
mPrivateFlags |= PFLAG_DRAWABLE_STATE_DIRTY;
@@ -12156,6 +12168,9 @@
}
mAttachInfo = null;
+ if (mOverlay != null) {
+ mOverlay.mAttachInfo = null;
+ }
}
/**
@@ -12811,6 +12826,9 @@
// Fast path for layouts with no backgrounds
if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) {
dispatchDraw(canvas);
+ if (mOverlay != null && !mOverlay.isEmpty()) {
+ mOverlay.draw(canvas);
+ }
} else {
draw(canvas);
}
@@ -13124,6 +13142,9 @@
if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) {
mPrivateFlags &= ~PFLAG_DIRTY_MASK;
dispatchDraw(canvas);
+ if (mOverlay != null && !mOverlay.isEmpty()) {
+ mOverlay.draw(canvas);
+ }
} else {
draw(canvas);
}
@@ -13879,6 +13900,10 @@
// Step 6, draw decorations (scrollbars)
onDrawScrollBars(canvas);
+ if (mOverlay != null && !mOverlay.isEmpty()) {
+ mOverlay.dispatchDraw(canvas);
+ }
+
// we're done...
return;
}
@@ -14018,6 +14043,37 @@
// Step 6, draw decorations (scrollbars)
onDrawScrollBars(canvas);
+
+ if (mOverlay != null && !mOverlay.isEmpty()) {
+ mOverlay.dispatchDraw(canvas);
+ }
+ }
+
+ /**
+ * Called by the addToOverlay() methods to create, attach, and size the overlay as necessary
+ */
+ private void setupOverlay() {
+ if (mOverlay == null) {
+ mOverlay = new ViewOverlay(mContext, this);
+ mOverlay.mAttachInfo = mAttachInfo;
+ mOverlay.setRight(mRight);
+ mOverlay.setBottom(mBottom);
+ }
+ }
+
+ /**
+ * Returns the overlay for this view, creating it if it does not yet exist. Adding drawables
+ * and/or views to the overlay will cause them to be displayed whenever the view itself is
+ * redrawn. Objects in the overlay should be actively managed: remove them when they should
+ * not be displayed anymore and invalidate this view appropriately when overlay drawables
+ * change. The overlay will always have the same size as its host view.
+ *
+ * @return The Overlay object for this view.
+ * @see Overlay
+ */
+ public Overlay getOverlay() {
+ setupOverlay();
+ return mOverlay;
}
/**
@@ -14273,7 +14329,7 @@
mTransformationInfo.mMatrixDirty = true;
}
}
- onSizeChanged(newWidth, newHeight, oldWidth, oldHeight);
+ sizeChange(newWidth, newHeight, oldWidth, oldHeight);
}
if ((mViewFlags & VISIBILITY_MASK) == VISIBLE) {
@@ -14297,6 +14353,14 @@
return changed;
}
+ private void sizeChange(int newWidth, int newHeight, int oldWidth, int oldHeight) {
+ onSizeChanged(newWidth, newHeight, oldWidth, oldHeight);
+ if (mOverlay != null) {
+ mOverlay.setRight(mRight);
+ mOverlay.setBottom(mBottom);
+ }
+ }
+
/**
* Finalize inflating a view from XML. This is called as the last phase
* of inflation, after all child views have been added.
@@ -16926,6 +16990,14 @@
*
* @attr ref android.R.styleable#View_textDirection
*/
+ @ViewDebug.ExportedProperty(category = "text", mapping = {
+ @ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"),
+ @ViewDebug.IntToString(from = TEXT_DIRECTION_FIRST_STRONG, to = "FIRST_STRONG"),
+ @ViewDebug.IntToString(from = TEXT_DIRECTION_ANY_RTL, to = "ANY_RTL"),
+ @ViewDebug.IntToString(from = TEXT_DIRECTION_LTR, to = "LTR"),
+ @ViewDebug.IntToString(from = TEXT_DIRECTION_RTL, to = "RTL"),
+ @ViewDebug.IntToString(from = TEXT_DIRECTION_LOCALE, to = "LOCALE")
+ })
public int getTextDirection() {
return (mPrivateFlags2 & PFLAG2_TEXT_DIRECTION_RESOLVED_MASK) >> PFLAG2_TEXT_DIRECTION_RESOLVED_MASK_SHIFT;
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 442dfdb..d63f7bc 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -1869,7 +1869,7 @@
removePointersFromTouchTargets(idBitsToAssign);
final int childrenCount = mChildrenCount;
- if (childrenCount != 0) {
+ if (childrenCount != 0 || mOverlay != null) {
// Find a child that can receive the event.
// Scan children from front to back.
final View[] children = mChildren;
@@ -1906,6 +1906,27 @@
break;
}
}
+ if (mOverlay != null && newTouchTarget == null) {
+ // Check to see whether the overlay can handle the event
+ final View child = mOverlay;
+ if (canViewReceivePointerEvents(child) &&
+ isTransformedTouchPointInView(x, y, child, null)) {
+ newTouchTarget = getTouchTarget(child);
+ if (newTouchTarget != null) {
+ newTouchTarget.pointerIdBits |= idBitsToAssign;
+ } else {
+ resetCancelNextUpFlag(child);
+ if (dispatchTransformedTouchEvent(ev, false, child,
+ idBitsToAssign)) {
+ mLastTouchDownTime = ev.getDownTime();
+ mLastTouchDownX = ev.getX();
+ mLastTouchDownY = ev.getY();
+ newTouchTarget = addTouchTarget(child, idBitsToAssign);
+ alreadyDispatchedToNewTouchTarget = true;
+ }
+ }
+ }
+ }
}
if (newTouchTarget == null && mFirstTouchTarget != null) {
@@ -3022,6 +3043,13 @@
child.mRecreateDisplayList = false;
}
}
+ if (mOverlay != null) {
+ mOverlay.mRecreateDisplayList = (mOverlay.mPrivateFlags & PFLAG_INVALIDATED)
+ == PFLAG_INVALIDATED;
+ mOverlay.mPrivateFlags &= ~PFLAG_INVALIDATED;
+ mOverlay.getDisplayList();
+ mOverlay.mRecreateDisplayList = false;
+ }
}
/**
diff --git a/core/java/android/view/ViewOverlay.java b/core/java/android/view/ViewOverlay.java
new file mode 100644
index 0000000..8c2ab9d
--- /dev/null
+++ b/core/java/android/view/ViewOverlay.java
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) 2013 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 android.view;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+
+import java.util.ArrayList;
+
+/**
+ * ViewOverlay is a container that View uses to host all objects (views and drawables) that
+ * are added to its "overlay", gotten through {@link View#getOverlay()}. Views and drawables are
+ * added to the overlay via the add/remove methods in this class. These views and drawables are
+ * then drawn whenever the view itself is drawn, after which it will draw its overlay (if it
+ * exists).
+ *
+ * Besides managing and drawing the list of drawables, this class serves two purposes:
+ * (1) it noops layout calls because children are absolutely positioned and
+ * (2) it forwards all invalidation calls to its host view. The invalidation redirect is
+ * necessary because the overlay is not a child of the host view and invalidation cannot
+ * therefore follow the normal path up through the parent hierarchy.
+ *
+ * @hide
+ */
+class ViewOverlay extends ViewGroup implements Overlay {
+
+ /**
+ * The View for which this is an overlay. Invalidations of the overlay are redirected to
+ * this host view.
+ */
+ View mHostView;
+
+ /**
+ * The set of drawables to draw when the overlay is rendered.
+ */
+ ArrayList<Drawable> mDrawables = null;
+
+ ViewOverlay(Context context, View host) {
+ super(context);
+ mHostView = host;
+ mParent = mHostView.getParent();
+ }
+
+ @Override
+ public void add(Drawable drawable) {
+ if (mDrawables == null) {
+ mDrawables = new ArrayList<Drawable>();
+ }
+ if (!mDrawables.contains(drawable)) {
+ // Make each drawable unique in the overlay; can't add it more than once
+ mDrawables.add(drawable);
+ invalidate(drawable.getBounds());
+ }
+ }
+
+ @Override
+ public void remove(Drawable drawable) {
+ if (mDrawables != null) {
+ mDrawables.remove(drawable);
+ invalidate(drawable.getBounds());
+ }
+ }
+
+ @Override
+ public void add(View child) {
+ super.addView(child);
+ }
+
+ @Override
+ public void remove(View view) {
+ super.removeView(view);
+ }
+
+ @Override
+ public void clear() {
+ removeAllViews();
+ mDrawables.clear();
+ }
+
+ boolean isEmpty() {
+ if (getChildCount() == 0 && (mDrawables == null || mDrawables.size() == 0)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
+ super.dispatchDraw(canvas);
+ final int numDrawables = (mDrawables == null) ? 0 : mDrawables.size();
+ for (int i = 0; i < numDrawables; ++i) {
+ mDrawables.get(i).draw(canvas);
+ }
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ // Noop: children are positioned absolutely
+ }
+
+ /*
+ The following invalidation overrides exist for the purpose of redirecting invalidation to
+ the host view. The overlay is not parented to the host view (since a View cannot be a parent),
+ so the invalidation cannot proceed through the normal parent hierarchy.
+ There is a built-in assumption that the overlay exactly covers the host view, therefore
+ the invalidation rectangles received do not need to be adjusted when forwarded to
+ the host view.
+ */
+
+ @Override
+ public void invalidate(Rect dirty) {
+ super.invalidate(dirty);
+ if (mHostView != null) {
+ dirty.offset(getLeft(), getTop());
+ mHostView.invalidate(dirty);
+ }
+ }
+
+ @Override
+ public void invalidate(int l, int t, int r, int b) {
+ super.invalidate(l, t, r, b);
+ if (mHostView != null) {
+ mHostView.invalidate(l, t, r, b);
+ }
+ }
+
+ @Override
+ public void invalidate() {
+ super.invalidate();
+ if (mHostView != null) {
+ mHostView.invalidate();
+ }
+ }
+
+ @Override
+ void invalidate(boolean invalidateCache) {
+ super.invalidate(invalidateCache);
+ if (mHostView != null) {
+ mHostView.invalidate(invalidateCache);
+ }
+ }
+
+ @Override
+ void invalidateViewProperty(boolean invalidateParent, boolean forceRedraw) {
+ super.invalidateViewProperty(invalidateParent, forceRedraw);
+ if (mHostView != null) {
+ mHostView.invalidateViewProperty(invalidateParent, forceRedraw);
+ }
+ }
+
+ @Override
+ protected void invalidateParentCaches() {
+ super.invalidateParentCaches();
+ if (mHostView != null) {
+ mHostView.invalidateParentCaches();
+ }
+ }
+
+ @Override
+ protected void invalidateParentIfNeeded() {
+ super.invalidateParentIfNeeded();
+ if (mHostView != null) {
+ mHostView.invalidateParentIfNeeded();
+ }
+ }
+
+ public void invalidateChildFast(View child, final Rect dirty) {
+ if (mHostView != null) {
+ // Note: This is not a "fast" invalidation. Would be nice to instead invalidate using DL
+ // properties and a dirty rect instead of causing a real invalidation of the host view
+ int left = child.mLeft;
+ int top = child.mTop;
+ if (!child.getMatrix().isIdentity()) {
+ child.transformRect(dirty);
+ }
+ dirty.offset(left, top);
+ mHostView.invalidate(dirty);
+ }
+ }
+
+ @Override
+ public ViewParent invalidateChildInParent(int[] location, Rect dirty) {
+ if (mHostView != null) {
+ mHostView.invalidate(dirty);
+ }
+ return null;
+ }
+}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index a937882..8808af0 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1947,20 +1947,16 @@
// Would not normally trigger another layout, so just let it pass through as usual
return true;
}
+ if (!mLayoutRequesters.contains(view)) {
+ mLayoutRequesters.add(view);
+ }
if (!mHandlingLayoutInLayoutRequest) {
- if (!mLayoutRequesters.contains(view)) {
- mLayoutRequesters.add(view);
- }
+ // Let the request proceed normally; it will be processed in a second layout pass
+ // if necessary
return true;
} else {
- Log.w("View", "requestLayout() called by " + view + " during second layout pass: " +
- "posting to next frame");
- view.post(new Runnable() {
- @Override
- public void run() {
- view.requestLayout();
- }
- });
+ // Don't let the request proceed during the second layout pass.
+ // It will post to the next frame instead.
return false;
}
}
@@ -1988,59 +1984,50 @@
// If no layout-request flags are set on the requesting views, there is no problem.
// If some requests are still pending, then we need to clear those flags and do
// a full request/measure/layout pass to handle this situation.
-
- // Check state of layout flags for all requesters
- ArrayList<View> mValidLayoutRequesters = null;
- for (int i = 0; i < numViewsRequestingLayout; ++i) {
- View view = mLayoutRequesters.get(i);
- if ((view.mPrivateFlags & View.PFLAG_FORCE_LAYOUT) == View.PFLAG_FORCE_LAYOUT) {
- while (view != null && view.mAttachInfo != null && view.mParent != null &&
- (view.mPrivateFlags & View.PFLAG_FORCE_LAYOUT) != 0) {
- if ((view.mViewFlags & View.VISIBILITY_MASK) != View.GONE) {
- // Only trigger new requests for non-GONE views
- Log.w(TAG, "requestLayout() improperly called during " +
- "layout: running second layout pass for " + view);
- if (mValidLayoutRequesters == null) {
- mValidLayoutRequesters = new ArrayList<View>();
- }
- mValidLayoutRequesters.add(view);
- break;
- }
- if (view.mParent instanceof View) {
- view = (View) view.mParent;
- } else {
- view = null;
- }
- }
- }
- }
- if (mValidLayoutRequesters != null) {
- // Clear flags throughout hierarchy, walking up from each flagged requester
- for (int i = 0; i < numViewsRequestingLayout; ++i) {
- View view = mLayoutRequesters.get(i);
- while (view != null &&
- (view.mPrivateFlags & View.PFLAG_FORCE_LAYOUT) != 0) {
- view.mPrivateFlags &= ~View.PFLAG_FORCE_LAYOUT;
- if (view.mParent instanceof View) {
- view = (View) view.mParent;
- } else {
- view = null;
- }
- }
- }
- // Process fresh layout requests, then measure and layout
+ ArrayList<View> validLayoutRequesters = getValidLayoutRequesters(mLayoutRequesters,
+ false);
+ if (validLayoutRequesters != null) {
+ // Set this flag to indicate that any further requests are happening during
+ // the second pass, which may result in posting those requests to the next
+ // frame instead
mHandlingLayoutInLayoutRequest = true;
- int numValidRequests = mValidLayoutRequesters.size();
+
+ // Process fresh layout requests, then measure and layout
+ int numValidRequests = validLayoutRequesters.size();
for (int i = 0; i < numValidRequests; ++i) {
- mValidLayoutRequesters.get(i).requestLayout();
+ final View view = validLayoutRequesters.get(i);
+ Log.w("View", "requestLayout() improperly called by " + view +
+ " during layout: running second layout pass");
+ view.requestLayout();
}
measureHierarchy(host, lp, mView.getContext().getResources(),
desiredWindowWidth, desiredWindowHeight);
mInLayout = true;
host.layout(0, 0, host.getMeasuredWidth(), host.getMeasuredHeight());
+
mHandlingLayoutInLayoutRequest = false;
+
+ // Check the valid requests again, this time without checking/clearing the
+ // layout flags, since requests happening during the second pass get noop'd
+ validLayoutRequesters = getValidLayoutRequesters(mLayoutRequesters, true);
+ if (validLayoutRequesters != null) {
+ final ArrayList<View> finalRequesters = validLayoutRequesters;
+ // Post second-pass requests to the next frame
+ getRunQueue().post(new Runnable() {
+ @Override
+ public void run() {
+ int numValidRequests = finalRequesters.size();
+ for (int i = 0; i < numValidRequests; ++i) {
+ final View view = finalRequesters.get(i);
+ Log.w("View", "requestLayout() improperly called by " + view +
+ " during second layout pass: posting in next frame");
+ view.requestLayout();
+ }
+ }
+ });
+ }
}
- mLayoutRequesters.clear();
+
}
} finally {
Trace.traceEnd(Trace.TRACE_TAG_VIEW);
@@ -2048,6 +2035,68 @@
mInLayout = false;
}
+ /**
+ * This method is called during layout when there have been calls to requestLayout() during
+ * layout. It walks through the list of views that requested layout to determine which ones
+ * still need it, based on visibility in the hierarchy and whether they have already been
+ * handled (as is usually the case with ListView children).
+ *
+ * @param layoutRequesters The list of views that requested layout during layout
+ * @param secondLayoutRequests Whether the requests were issued during the second layout pass.
+ * If so, the FORCE_LAYOUT flag was not set on requesters.
+ * @return A list of the actual views that still need to be laid out.
+ */
+ private ArrayList<View> getValidLayoutRequesters(ArrayList<View> layoutRequesters,
+ boolean secondLayoutRequests) {
+
+ int numViewsRequestingLayout = layoutRequesters.size();
+ ArrayList<View> validLayoutRequesters = null;
+ for (int i = 0; i < numViewsRequestingLayout; ++i) {
+ View view = layoutRequesters.get(i);
+ if (view != null && view.mAttachInfo != null && view.mParent != null &&
+ (secondLayoutRequests || (view.mPrivateFlags & View.PFLAG_FORCE_LAYOUT) ==
+ View.PFLAG_FORCE_LAYOUT)) {
+ boolean gone = false;
+ View parent = view;
+ // Only trigger new requests for views in a non-GONE hierarchy
+ while (parent != null) {
+ if ((parent.mViewFlags & View.VISIBILITY_MASK) == View.GONE) {
+ gone = true;
+ break;
+ }
+ if (parent.mParent instanceof View) {
+ parent = (View) parent.mParent;
+ } else {
+ parent = null;
+ }
+ }
+ if (!gone) {
+ if (validLayoutRequesters == null) {
+ validLayoutRequesters = new ArrayList<View>();
+ }
+ validLayoutRequesters.add(view);
+ }
+ }
+ }
+ if (!secondLayoutRequests) {
+ // If we're checking the layout flags, then we need to clean them up also
+ for (int i = 0; i < numViewsRequestingLayout; ++i) {
+ View view = layoutRequesters.get(i);
+ while (view != null &&
+ (view.mPrivateFlags & View.PFLAG_FORCE_LAYOUT) != 0) {
+ view.mPrivateFlags &= ~View.PFLAG_FORCE_LAYOUT;
+ if (view.mParent instanceof View) {
+ view = (View) view.mParent;
+ } else {
+ view = null;
+ }
+ }
+ }
+ }
+ layoutRequesters.clear();
+ return validLayoutRequesters;
+ }
+
public void requestTransparentRegion(View child) {
// the test below should not fail unless someone is messing with us
checkThread();
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 396fd68..3fa0940 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -6167,6 +6167,7 @@
private ArrayList<View> mSkippedScrap;
private SparseArray<View> mTransientStateViews;
+ private LongSparseArray<View> mTransientStateViewsById;
public void setViewTypeCount(int viewTypeCount) {
if (viewTypeCount < 1) {
@@ -6205,6 +6206,12 @@
mTransientStateViews.valueAt(i).forceLayout();
}
}
+ if (mTransientStateViewsById != null) {
+ final int count = mTransientStateViewsById.size();
+ for (int i = 0; i < count; i++) {
+ mTransientStateViewsById.valueAt(i).forceLayout();
+ }
+ }
}
public boolean shouldRecycleViewType(int viewType) {
@@ -6234,6 +6241,9 @@
if (mTransientStateViews != null) {
mTransientStateViews.clear();
}
+ if (mTransientStateViewsById != null) {
+ mTransientStateViewsById.clear();
+ }
}
/**
@@ -6281,16 +6291,21 @@
}
View getTransientStateView(int position) {
- if (mTransientStateViews == null) {
- return null;
+ if (mAdapter != null && mAdapterHasStableIds && mTransientStateViewsById != null) {
+ long id = mAdapter.getItemId(position);
+ View result = mTransientStateViewsById.get(id);
+ mTransientStateViewsById.remove(id);
+ return result;
}
- final int index = mTransientStateViews.indexOfKey(position);
- if (index < 0) {
- return null;
+ if (mTransientStateViews != null) {
+ final int index = mTransientStateViews.indexOfKey(position);
+ if (index >= 0) {
+ View result = mTransientStateViews.valueAt(index);
+ mTransientStateViews.removeAt(index);
+ return result;
+ }
}
- final View result = mTransientStateViews.valueAt(index);
- mTransientStateViews.removeAt(index);
- return result;
+ return null;
}
/**
@@ -6300,6 +6315,9 @@
if (mTransientStateViews != null) {
mTransientStateViews.clear();
}
+ if (mTransientStateViewsById != null) {
+ mTransientStateViewsById.clear();
+ }
}
/**
@@ -6342,11 +6360,20 @@
mSkippedScrap.add(scrap);
}
if (scrapHasTransientState) {
- if (mTransientStateViews == null) {
- mTransientStateViews = new SparseArray<View>();
- }
scrap.dispatchStartTemporaryDetach();
- mTransientStateViews.put(position, scrap);
+ if (mAdapter != null && mAdapterHasStableIds) {
+ if (mTransientStateViewsById == null) {
+ mTransientStateViewsById = new LongSparseArray<View>();
+ }
+ mTransientStateViewsById.put(lp.itemId, scrap);
+ } else if (!mDataChanged) {
+ // avoid putting views on transient state list during a data change;
+ // the layout positions may be out of sync with the adapter positions
+ if (mTransientStateViews == null) {
+ mTransientStateViews = new SparseArray<View>();
+ }
+ mTransientStateViews.put(position, scrap);
+ }
}
return;
}
@@ -6405,10 +6432,18 @@
removeDetachedView(victim, false);
}
if (scrapHasTransientState) {
- if (mTransientStateViews == null) {
- mTransientStateViews = new SparseArray<View>();
+ if (mAdapter != null && mAdapterHasStableIds) {
+ if (mTransientStateViewsById == null) {
+ mTransientStateViewsById = new LongSparseArray<View>();
+ }
+ long id = mAdapter.getItemId(mFirstActivePosition + i);
+ mTransientStateViewsById.put(id, victim);
+ } else {
+ if (mTransientStateViews == null) {
+ mTransientStateViews = new SparseArray<View>();
+ }
+ mTransientStateViews.put(mFirstActivePosition + i, victim);
}
- mTransientStateViews.put(mFirstActivePosition + i, victim);
}
continue;
}
@@ -6457,6 +6492,15 @@
}
}
}
+ if (mTransientStateViewsById != null) {
+ for (int i = 0; i < mTransientStateViewsById.size(); i++) {
+ final View v = mTransientStateViewsById.valueAt(i);
+ if (!v.hasTransientState()) {
+ mTransientStateViewsById.removeAt(i);
+ i--;
+ }
+ }
+ }
}
/**
diff --git a/core/java/android/widget/DigitalClock.java b/core/java/android/widget/DigitalClock.java
index c6b6dd6..b6c1e5b 100644
--- a/core/java/android/widget/DigitalClock.java
+++ b/core/java/android/widget/DigitalClock.java
@@ -39,8 +39,6 @@
// proportional fonts don't shake rendering
Calendar mCalendar;
- private final static String m12 = "h:mm:ss aa";
- private final static String m24 = "k:mm:ss";
@SuppressWarnings("FieldCanBeLocal") // We must keep a reference to this observer
private FormatChangeObserver mFormatChangeObserver;
@@ -102,19 +100,8 @@
mTickerStopped = true;
}
- /**
- * Pulls 12/24 mode from system settings
- */
- private boolean get24HourMode() {
- return android.text.format.DateFormat.is24HourFormat(getContext());
- }
-
private void setFormat() {
- if (get24HourMode()) {
- mFormat = m24;
- } else {
- mFormat = m12;
- }
+ mFormat = DateFormat.getTimeFormatString(getContext());
}
private class FormatChangeObserver extends ContentObserver {
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index dc305a5..0aeef63 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -316,7 +316,7 @@
private void setErrorIcon(Drawable icon) {
Drawables dr = mTextView.mDrawables;
if (dr == null) {
- mTextView.mDrawables = dr = new Drawables();
+ mTextView.mDrawables = dr = new Drawables(mTextView.getContext());
}
dr.setErrorDrawable(icon, mTextView);
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index 69e3177..7c40a64 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -1550,6 +1550,32 @@
setSelectedPositionInt(mNextSelectedPosition);
+ // Remember which child, if any, had accessibility focus. This must
+ // occur before recycling any views, since that will clear
+ // accessibility focus.
+ final ViewRootImpl viewRootImpl = getViewRootImpl();
+ if (viewRootImpl != null) {
+ final View accessFocusedView = viewRootImpl.getAccessibilityFocusedHost();
+ if (accessFocusedView != null) {
+ final View accessFocusedChild = findAccessibilityFocusedChild(
+ accessFocusedView);
+ if (accessFocusedChild != null) {
+ if (!dataChanged || isDirectChildHeaderOrFooter(accessFocusedChild)) {
+ // If the views won't be changing, try to maintain
+ // focus on the current view host and (if
+ // applicable) its virtual view.
+ accessibilityFocusLayoutRestoreView = accessFocusedView;
+ accessibilityFocusLayoutRestoreNode = viewRootImpl
+ .getAccessibilityFocusedVirtualView();
+ } else {
+ // Otherwise, try to maintain focus at the same
+ // position.
+ accessibilityFocusPosition = getPositionForView(accessFocusedChild);
+ }
+ }
+ }
+ }
+
// Pull all children into the RecycleBin.
// These views will be reused if possible
final int firstPosition = mFirstPosition;
@@ -1590,30 +1616,6 @@
requestFocus();
}
- // Remember which child, if any, had accessibility focus.
- final ViewRootImpl viewRootImpl = getViewRootImpl();
- if (viewRootImpl != null) {
- final View accessFocusedView = viewRootImpl.getAccessibilityFocusedHost();
- if (accessFocusedView != null) {
- final View accessFocusedChild = findAccessibilityFocusedChild(
- accessFocusedView);
- if (accessFocusedChild != null) {
- if (!dataChanged || isDirectChildHeaderOrFooter(accessFocusedChild)) {
- // If the views won't be changing, try to maintain
- // focus on the current view host and (if
- // applicable) its virtual view.
- accessibilityFocusLayoutRestoreView = accessFocusedView;
- accessibilityFocusLayoutRestoreNode = viewRootImpl
- .getAccessibilityFocusedVirtualView();
- } else {
- // Otherwise, try to maintain focus at the same
- // position.
- accessibilityFocusPosition = getPositionForView(accessFocusedChild);
- }
- }
- }
- }
-
// Clear out old views
detachAllViewsFromParent();
recycleBin.removeSkippedScrap();
diff --git a/core/java/android/widget/TextClock.java b/core/java/android/widget/TextClock.java
index 5bf21c0..a564c96 100644
--- a/core/java/android/widget/TextClock.java
+++ b/core/java/android/widget/TextClock.java
@@ -36,21 +36,24 @@
import java.util.Calendar;
import java.util.TimeZone;
+import libcore.icu.LocaleData;
+
import static android.view.ViewDebug.ExportedProperty;
import static android.widget.RemoteViews.*;
/**
* <p><code>TextClock</code> can display the current date and/or time as
* a formatted string.</p>
- *
+ *
* <p>This view honors the 24-hour format system setting. As such, it is
* possible and recommended to provide two different formatting patterns:
* one to display the date/time in 24-hour mode and one to display the
- * date/time in 12-hour mode.</p>
- *
+ * date/time in 12-hour mode. Most callers will want to use the defaults,
+ * though, which will be appropriate for the user's locale.</p>
+ *
* <p>It is possible to determine whether the system is currently in
* 24-hour mode by calling {@link #is24HourModeEnabled()}.</p>
- *
+ *
* <p>The rules used by this widget to decide how to format the date and
* time are the following:</p>
* <ul>
@@ -58,22 +61,24 @@
* <ul>
* <li>Use the value returned by {@link #getFormat24Hour()} when non-null</li>
* <li>Otherwise, use the value returned by {@link #getFormat12Hour()} when non-null</li>
- * <li>Otherwise, use {@link #DEFAULT_FORMAT_24_HOUR}</li>
+ * <li>Otherwise, use a default value appropriate for the user's locale, such as {@code h:mm a}</li>
* </ul>
* </li>
* <li>In 12-hour mode:
* <ul>
* <li>Use the value returned by {@link #getFormat12Hour()} when non-null</li>
* <li>Otherwise, use the value returned by {@link #getFormat24Hour()} when non-null</li>
- * <li>Otherwise, use {@link #DEFAULT_FORMAT_12_HOUR}</li>
+ * <li>Otherwise, use a default value appropriate for the user's locale, such as {@code HH:mm}</li>
* </ul>
* </li>
* </ul>
- *
+ *
* <p>The {@link CharSequence} instances used as formatting patterns when calling either
* {@link #setFormat24Hour(CharSequence)} or {@link #setFormat12Hour(CharSequence)} can
- * contain styling information. To do so, use a {@link android.text.Spanned} object.</p>
- *
+ * contain styling information. To do so, use a {@link android.text.Spanned} object.
+ * Note that if you customize these strings, it is your responsibility to supply strings
+ * appropriate for formatting dates and/or times in the user's locale.</p>
+ *
* @attr ref android.R.styleable#TextClock_format12Hour
* @attr ref android.R.styleable#TextClock_format24Hour
* @attr ref android.R.styleable#TextClock_timeZone
@@ -81,32 +86,34 @@
@RemoteView
public class TextClock extends TextView {
/**
- * The default formatting pattern in 12-hour mode. This pattenr is used
+ * The default formatting pattern in 12-hour mode. This pattern is used
* if {@link #setFormat12Hour(CharSequence)} is called with a null pattern
* or if no pattern was specified when creating an instance of this class.
- *
+ *
* This default pattern shows only the time, hours and minutes, and an am/pm
* indicator.
*
* @see #setFormat12Hour(CharSequence)
* @see #getFormat12Hour()
+ * @deprecated Let the system use locale-appropriate defaults instead.
*/
- public static final CharSequence DEFAULT_FORMAT_12_HOUR = "h:mm aa";
+ public static final CharSequence DEFAULT_FORMAT_12_HOUR = "h:mm a";
/**
- * The default formatting pattern in 24-hour mode. This pattenr is used
+ * The default formatting pattern in 24-hour mode. This pattern is used
* if {@link #setFormat24Hour(CharSequence)} is called with a null pattern
* or if no pattern was specified when creating an instance of this class.
*
* This default pattern shows only the time, hours and minutes.
- *
- * @see #setFormat24Hour(CharSequence)
- * @see #getFormat24Hour()
+ *
+ * @see #setFormat24Hour(CharSequence)
+ * @see #getFormat24Hour()
+ * @deprecated Let the system use locale-appropriate defaults instead.
*/
- public static final CharSequence DEFAULT_FORMAT_24_HOUR = "k:mm";
+ public static final CharSequence DEFAULT_FORMAT_24_HOUR = "H:mm";
- private CharSequence mFormat12 = DEFAULT_FORMAT_12_HOUR;
- private CharSequence mFormat24 = DEFAULT_FORMAT_24_HOUR;
+ private CharSequence mFormat12;
+ private CharSequence mFormat24;
@ExportedProperty
private CharSequence mFormat;
@@ -158,7 +165,7 @@
* Creates a new clock using the default patterns
* {@link #DEFAULT_FORMAT_24_HOUR} and {@link #DEFAULT_FORMAT_12_HOUR}
* respectively for the 24-hour and 12-hour modes.
- *
+ *
* @param context The Context the view is running in, through which it can
* access the current theme, resources, etc.
*/
@@ -171,7 +178,7 @@
/**
* Creates a new clock inflated from XML. This object's properties are
* intialized from the attributes specified in XML.
- *
+ *
* This constructor uses a default style of 0, so the only attribute values
* applied are those in the Context's Theme and the given AttributeSet.
*
@@ -201,14 +208,8 @@
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextClock, defStyle, 0);
try {
- CharSequence format;
-
- format = a.getText(R.styleable.TextClock_format12Hour);
- mFormat12 = format == null ? DEFAULT_FORMAT_12_HOUR : format;
-
- format = a.getText(R.styleable.TextClock_format24Hour);
- mFormat24 = format == null ? DEFAULT_FORMAT_24_HOUR : format;
-
+ mFormat12 = a.getText(R.styleable.TextClock_format12Hour);
+ mFormat24 = a.getText(R.styleable.TextClock_format24Hour);
mTimeZone = a.getString(R.styleable.TextClock_timeZone);
} finally {
a.recycle();
@@ -218,6 +219,16 @@
}
private void init() {
+ if (mFormat12 == null || mFormat24 == null) {
+ LocaleData ld = LocaleData.get(getContext().getResources().getConfiguration().locale);
+ if (mFormat12 == null) {
+ mFormat12 = ld.timeFormat12;
+ }
+ if (mFormat24 == null) {
+ mFormat24 = ld.timeFormat24;
+ }
+ }
+
createTime(mTimeZone);
// Wait until onAttachedToWindow() to handle the ticker
chooseFormat(false);
@@ -235,11 +246,11 @@
* Returns the formatting pattern used to display the date and/or time
* in 12-hour mode. The formatting pattern syntax is described in
* {@link DateFormat}.
- *
+ *
* @return A {@link CharSequence} or null.
- *
- * @see #setFormat12Hour(CharSequence)
- * @see #is24HourModeEnabled()
+ *
+ * @see #setFormat12Hour(CharSequence)
+ * @see #is24HourModeEnabled()
*/
@ExportedProperty
public CharSequence getFormat12Hour() {
@@ -257,12 +268,12 @@
* {@link #DEFAULT_FORMAT_12_HOUR} will be used instead.
*
* @param format A date/time formatting pattern as described in {@link DateFormat}
- *
+ *
* @see #getFormat12Hour()
* @see #is24HourModeEnabled()
* @see #DEFAULT_FORMAT_12_HOUR
* @see DateFormat
- *
+ *
* @attr ref android.R.styleable#TextClock_format12Hour
*/
@RemotableViewMethod
@@ -292,7 +303,7 @@
* Specifies the formatting pattern used to display the date and/or time
* in 24-hour mode. The formatting pattern syntax is described in
* {@link DateFormat}.
- *
+ *
* If this pattern is set to null, {@link #getFormat12Hour()} will be used
* even in 24-hour mode. If both 24-hour and 12-hour formatting patterns
* are set to null, {@link #DEFAULT_FORMAT_24_HOUR} and
@@ -301,7 +312,7 @@
* @param format A date/time formatting pattern as described in {@link DateFormat}
*
* @see #getFormat24Hour()
- * @see #is24HourModeEnabled()
+ * @see #is24HourModeEnabled()
* @see #DEFAULT_FORMAT_24_HOUR
* @see DateFormat
*
@@ -317,22 +328,22 @@
/**
* Indicates whether the system is currently using the 24-hour mode.
- *
+ *
* When the system is in 24-hour mode, this view will use the pattern
* returned by {@link #getFormat24Hour()}. In 12-hour mode, the pattern
* returned by {@link #getFormat12Hour()} is used instead.
- *
+ *
* If either one of the formats is null, the other format is used. If
* both formats are null, the default values {@link #DEFAULT_FORMAT_12_HOUR}
* and {@link #DEFAULT_FORMAT_24_HOUR} are used instead.
- *
+ *
* @return true if time should be displayed in 24-hour format, false if it
* should be displayed in 12-hour format.
- *
+ *
* @see #setFormat12Hour(CharSequence)
- * @see #getFormat12Hour()
+ * @see #getFormat12Hour()
* @see #setFormat24Hour(CharSequence)
- * @see #getFormat24Hour()
+ * @see #getFormat24Hour()
*/
public boolean is24HourModeEnabled() {
return DateFormat.is24HourFormat(getContext());
@@ -340,13 +351,13 @@
/**
* Indicates which time zone is currently used by this view.
- *
+ *
* @return The ID of the current time zone or null if the default time zone,
* as set by the user, must be used
*
* @see TimeZone
* @see java.util.TimeZone#getAvailableIDs()
- * @see #setTimeZone(String)
+ * @see #setTimeZone(String)
*/
public String getTimeZone() {
return mTimeZone;
@@ -378,7 +389,7 @@
/**
* Selects either one of {@link #getFormat12Hour()} or {@link #getFormat24Hour()}
* depending on whether the user has selected 24-hour format.
- *
+ *
* Calling this method does not schedule or unschedule the time ticker.
*/
private void chooseFormat() {
@@ -398,17 +409,19 @@
/**
* Selects either one of {@link #getFormat12Hour()} or {@link #getFormat24Hour()}
* depending on whether the user has selected 24-hour format.
- *
+ *
* @param handleTicker true if calling this method should schedule/unschedule the
* time ticker, false otherwise
*/
private void chooseFormat(boolean handleTicker) {
final boolean format24Requested = is24HourModeEnabled();
+ LocaleData ld = LocaleData.get(getContext().getResources().getConfiguration().locale);
+
if (format24Requested) {
- mFormat = abc(mFormat24, mFormat12, DEFAULT_FORMAT_24_HOUR);
+ mFormat = abc(mFormat24, mFormat12, ld.timeFormat24);
} else {
- mFormat = abc(mFormat12, mFormat24, DEFAULT_FORMAT_12_HOUR);
+ mFormat = abc(mFormat12, mFormat24, ld.timeFormat12);
}
boolean hadSeconds = mHasSeconds;
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index adacef2..1ab9943 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -136,6 +136,8 @@
import java.util.Locale;
import java.util.concurrent.locks.ReentrantLock;
+import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
+
/**
* Displays text to the user and optionally allows them to edit it. A TextView
* is a complete text editor, however the basic class is configured to not
@@ -294,6 +296,10 @@
Drawable mDrawableTop, mDrawableBottom, mDrawableLeft, mDrawableRight,
mDrawableStart, mDrawableEnd, mDrawableError, mDrawableTemp;
+ Drawable mDrawableLeftInitial, mDrawableRightInitial;
+ boolean mIsRtlCompatibilityMode;
+ boolean mOverride;
+
int mDrawableSizeTop, mDrawableSizeBottom, mDrawableSizeLeft, mDrawableSizeRight,
mDrawableSizeStart, mDrawableSizeEnd, mDrawableSizeError, mDrawableSizeTemp;
@@ -304,38 +310,64 @@
int mDrawableSaved = DRAWABLE_NONE;
+ public Drawables(Context context) {
+ final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion;
+ mIsRtlCompatibilityMode = (targetSdkVersion < JELLY_BEAN_MR1 ||
+ !context.getApplicationInfo().hasRtlSupport());
+ mOverride = false;
+ }
+
public void resolveWithLayoutDirection(int layoutDirection) {
- switch(layoutDirection) {
- case LAYOUT_DIRECTION_RTL:
- if (mDrawableStart != null) {
- mDrawableRight = mDrawableStart;
+ // First reset "left" and "right" drawables to their initial values
+ mDrawableLeft = mDrawableLeftInitial;
+ mDrawableRight = mDrawableRightInitial;
- mDrawableSizeRight = mDrawableSizeStart;
- mDrawableHeightRight = mDrawableHeightStart;
- }
- if (mDrawableEnd != null) {
- mDrawableLeft = mDrawableEnd;
+ if (mIsRtlCompatibilityMode) {
+ // Use "start" drawable as "left" drawable if the "left" drawable was not defined
+ if (mDrawableStart != null && mDrawableLeft == null) {
+ mDrawableLeft = mDrawableStart;
+ mDrawableSizeLeft = mDrawableSizeStart;
+ mDrawableHeightLeft = mDrawableHeightStart;
+ }
+ // Use "end" drawable as "right" drawable if the "right" drawable was not defined
+ if (mDrawableEnd != null && mDrawableRight == null) {
+ mDrawableRight = mDrawableEnd;
+ mDrawableSizeRight = mDrawableSizeEnd;
+ mDrawableHeightRight = mDrawableHeightEnd;
+ }
+ } else {
+ // JB-MR1+ normal case: "start" / "end" drawables are overriding "left" / "right"
+ // drawable if and only if they have been defined
+ switch(layoutDirection) {
+ case LAYOUT_DIRECTION_RTL:
+ if (mOverride) {
+ mDrawableRight = mDrawableStart;
+ mDrawableSizeRight = mDrawableSizeStart;
+ mDrawableHeightRight = mDrawableHeightStart;
+ }
- mDrawableSizeLeft = mDrawableSizeEnd;
- mDrawableHeightLeft = mDrawableHeightEnd;
- }
- break;
+ if (mOverride) {
+ mDrawableLeft = mDrawableEnd;
+ mDrawableSizeLeft = mDrawableSizeEnd;
+ mDrawableHeightLeft = mDrawableHeightEnd;
+ }
+ break;
- case LAYOUT_DIRECTION_LTR:
- default:
- if (mDrawableStart != null) {
- mDrawableLeft = mDrawableStart;
+ case LAYOUT_DIRECTION_LTR:
+ default:
+ if (mOverride) {
+ mDrawableLeft = mDrawableStart;
+ mDrawableSizeLeft = mDrawableSizeStart;
+ mDrawableHeightLeft = mDrawableHeightStart;
+ }
- mDrawableSizeLeft = mDrawableSizeStart;
- mDrawableHeightLeft = mDrawableHeightStart;
- }
- if (mDrawableEnd != null) {
- mDrawableRight = mDrawableEnd;
-
- mDrawableSizeRight = mDrawableSizeEnd;
- mDrawableHeightRight = mDrawableHeightEnd;
- }
- break;
+ if (mOverride) {
+ mDrawableRight = mDrawableEnd;
+ mDrawableSizeRight = mDrawableSizeEnd;
+ mDrawableHeightRight = mDrawableHeightEnd;
+ }
+ break;
+ }
}
applyErrorDrawableIfNeeded(layoutDirection);
updateDrawablesLayoutDirection(layoutDirection);
@@ -1154,6 +1186,7 @@
bufferType = BufferType.SPANNABLE;
}
+ // This call will save the initial left/right drawables
setCompoundDrawablesWithIntrinsicBounds(
drawableLeft, drawableTop, drawableRight, drawableBottom);
setRelativeDrawablesIfNeeded(drawableStart, drawableEnd);
@@ -1302,8 +1335,9 @@
if (hasRelativeDrawables) {
Drawables dr = mDrawables;
if (dr == null) {
- mDrawables = dr = new Drawables();
+ mDrawables = dr = new Drawables(getContext());
}
+ mDrawables.mOverride = true;
final Rect compoundRect = dr.mCompoundRect;
int[] state = getDrawableState();
if (start != null) {
@@ -1876,9 +1910,11 @@
}
} else {
if (dr == null) {
- mDrawables = dr = new Drawables();
+ mDrawables = dr = new Drawables(getContext());
}
+ mDrawables.mOverride = false;
+
if (dr.mDrawableLeft != left && dr.mDrawableLeft != null) {
dr.mDrawableLeft.setCallback(null);
}
@@ -1945,6 +1981,12 @@
}
}
+ // Save initial left/right drawables
+ if (dr != null) {
+ dr.mDrawableLeftInitial = left;
+ dr.mDrawableRightInitial = right;
+ }
+
invalidate();
requestLayout();
}
@@ -2045,9 +2087,11 @@
}
} else {
if (dr == null) {
- mDrawables = dr = new Drawables();
+ mDrawables = dr = new Drawables(getContext());
}
+ mDrawables.mOverride = true;
+
if (dr.mDrawableStart != start && dr.mDrawableStart != null) {
dr.mDrawableStart.setCallback(null);
}
@@ -2114,6 +2158,7 @@
}
}
+ resetResolvedDrawables();
resolveDrawables();
invalidate();
requestLayout();
@@ -2138,7 +2183,6 @@
@android.view.RemotableViewMethod
public void setCompoundDrawablesRelativeWithIntrinsicBounds(int start, int top, int end,
int bottom) {
- resetResolvedDrawables();
final Resources resources = getContext().getResources();
setCompoundDrawablesRelativeWithIntrinsicBounds(
start != 0 ? resources.getDrawable(start) : null,
@@ -2161,7 +2205,6 @@
public void setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable start, Drawable top,
Drawable end, Drawable bottom) {
- resetResolvedDrawables();
if (start != null) {
start.setBounds(0, 0, start.getIntrinsicWidth(), start.getIntrinsicHeight());
}
@@ -2230,7 +2273,7 @@
}
} else {
if (dr == null) {
- mDrawables = dr = new Drawables();
+ mDrawables = dr = new Drawables(getContext());
}
dr.mDrawablePadding = pad;
}
@@ -8813,11 +8856,11 @@
}
public void drawTextRun(Canvas c, int start, int end,
- int contextStart, int contextEnd, float x, float y, Paint p) {
+ int contextStart, int contextEnd, float x, float y, int flags, Paint p) {
int count = end - start;
int contextCount = contextEnd - contextStart;
c.drawTextRun(mChars, start + mStart, count, contextStart + mStart,
- contextCount, x, y, p);
+ contextCount, x, y, flags, p);
}
public float measureText(int start, int end, Paint p) {
@@ -8829,20 +8872,30 @@
}
public float getTextRunAdvances(int start, int end, int contextStart,
- int contextEnd, float[] advances, int advancesIndex,
+ int contextEnd, int flags, float[] advances, int advancesIndex,
Paint p) {
int count = end - start;
int contextCount = contextEnd - contextStart;
return p.getTextRunAdvances(mChars, start + mStart, count,
- contextStart + mStart, contextCount, advances,
+ contextStart + mStart, contextCount, flags, advances,
advancesIndex);
}
- public int getTextRunCursor(int contextStart, int contextEnd,
+ public float getTextRunAdvances(int start, int end, int contextStart,
+ int contextEnd, int flags, float[] advances, int advancesIndex,
+ Paint p, int reserved) {
+ int count = end - start;
+ int contextCount = contextEnd - contextStart;
+ return p.getTextRunAdvances(mChars, start + mStart, count,
+ contextStart + mStart, contextCount, flags, advances,
+ advancesIndex, reserved);
+ }
+
+ public int getTextRunCursor(int contextStart, int contextEnd, int flags,
int offset, int cursorOpt, Paint p) {
int contextCount = contextEnd - contextStart;
return p.getTextRunCursor(mChars, contextStart + mStart,
- contextCount, offset + mStart, cursorOpt);
+ contextCount, flags, offset + mStart, cursorOpt);
}
}
diff --git a/core/java/com/android/internal/util/StateMachine.java b/core/java/com/android/internal/util/StateMachine.java
index 2cdd579..dd57ef4 100644
--- a/core/java/com/android/internal/util/StateMachine.java
+++ b/core/java/com/android/internal/util/StateMachine.java
@@ -1257,6 +1257,15 @@
}
/**
+ * Constructor creates a StateMachine using the handler.
+ *
+ * @param name of the state machine
+ */
+ protected StateMachine(String name, Handler handler) {
+ initStateMachine(name, handler.getLooper());
+ }
+
+ /**
* Add a new state to the state machine
* @param state the state to add
* @param parent the parent of state
diff --git a/core/java/com/android/internal/view/IInputMethod.aidl b/core/java/com/android/internal/view/IInputMethod.aidl
index c2a7fc7..5db860b 100644
--- a/core/java/com/android/internal/view/IInputMethod.aidl
+++ b/core/java/com/android/internal/view/IInputMethod.aidl
@@ -33,28 +33,26 @@
* Service).
* {@hide}
*/
-interface IInputMethod {
- oneway void attachToken(IBinder token);
-
- oneway void bindInput(in InputBinding binding);
-
- oneway void unbindInput();
+oneway interface IInputMethod {
+ void attachToken(IBinder token);
- oneway void startInput(in IInputContext inputContext, in EditorInfo attribute);
+ void bindInput(in InputBinding binding);
- oneway void restartInput(in IInputContext inputContext, in EditorInfo attribute);
+ void unbindInput();
- oneway void createSession(IInputMethodCallback callback);
-
- oneway void setSessionEnabled(IInputMethodSession session, boolean enabled);
-
- oneway void revokeSession(IInputMethodSession session);
-
- oneway void showSoftInput(int flags, in ResultReceiver resultReceiver);
-
- oneway void hideSoftInput(int flags, in ResultReceiver resultReceiver);
+ void startInput(in IInputContext inputContext, in EditorInfo attribute);
- void removeSoftInputMessages();
+ void restartInput(in IInputContext inputContext, in EditorInfo attribute);
- oneway void changeInputMethodSubtype(in InputMethodSubtype subtype);
+ void createSession(IInputMethodCallback callback);
+
+ void setSessionEnabled(IInputMethodSession session, boolean enabled);
+
+ void revokeSession(IInputMethodSession session);
+
+ void showSoftInput(int flags, in ResultReceiver resultReceiver);
+
+ void hideSoftInput(int flags, in ResultReceiver resultReceiver);
+
+ void changeInputMethodSubtype(in InputMethodSubtype subtype);
}
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp
index 6640555..9a9f6c8 100644
--- a/core/jni/android/graphics/Canvas.cpp
+++ b/core/jni/android/graphics/Canvas.cpp
@@ -752,37 +752,37 @@
}
- static void drawText___CIIFFPaint(JNIEnv* env, jobject, SkCanvas* canvas,
+ static void drawText___CIIFFIPaint(JNIEnv* env, jobject, SkCanvas* canvas,
jcharArray text, int index, int count,
- jfloat x, jfloat y, SkPaint* paint) {
+ jfloat x, jfloat y, int flags, SkPaint* paint) {
jchar* textArray = env->GetCharArrayElements(text, NULL);
- drawTextWithGlyphs(canvas, textArray + index, 0, count, x, y, paint);
+ drawTextWithGlyphs(canvas, textArray + index, 0, count, x, y, flags, paint);
env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
}
- static void drawText__StringIIFFPaint(JNIEnv* env, jobject,
+ static void drawText__StringIIFFIPaint(JNIEnv* env, jobject,
SkCanvas* canvas, jstring text,
int start, int end,
- jfloat x, jfloat y, SkPaint* paint) {
+ jfloat x, jfloat y, int flags, SkPaint* paint) {
const jchar* textArray = env->GetStringChars(text, NULL);
- drawTextWithGlyphs(canvas, textArray, start, end, x, y, paint);
+ drawTextWithGlyphs(canvas, textArray, start, end, x, y, flags, paint);
env->ReleaseStringChars(text, textArray);
}
static void drawTextWithGlyphs(SkCanvas* canvas, const jchar* textArray,
int start, int end,
- jfloat x, jfloat y, SkPaint* paint) {
+ jfloat x, jfloat y, int flags, SkPaint* paint) {
jint count = end - start;
- drawTextWithGlyphs(canvas, textArray + start, 0, count, count, x, y, paint);
+ drawTextWithGlyphs(canvas, textArray + start, 0, count, count, x, y, flags, paint);
}
static void drawTextWithGlyphs(SkCanvas* canvas, const jchar* textArray,
int start, int count, int contextCount,
- jfloat x, jfloat y, SkPaint* paint) {
+ jfloat x, jfloat y, int flags, SkPaint* paint) {
sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
- textArray, start, count, contextCount);
+ textArray, start, count, contextCount, flags);
if (value == NULL) {
return;
}
@@ -793,7 +793,7 @@
x -= value->getTotalAdvance();
}
paint->setTextAlign(SkPaint::kLeft_Align);
- doDrawGlyphsPos(canvas, value->getGlyphs(), value->getPos(), 0, value->getGlyphsCount(), x, y, paint);
+ doDrawGlyphsPos(canvas, value->getGlyphs(), value->getPos(), 0, value->getGlyphsCount(), x, y, flags, paint);
doDrawTextDecorations(canvas, x, y, value->getTotalAdvance(), paint);
paint->setTextAlign(align);
}
@@ -835,8 +835,14 @@
}
}
+ static void doDrawGlyphs(SkCanvas* canvas, const jchar* glyphArray, int index, int count,
+ jfloat x, jfloat y, int flags, SkPaint* paint) {
+ // Beware: this needs Glyph encoding (already done on the Paint constructor)
+ canvas->drawText(glyphArray + index * 2, count * 2, x, y, *paint);
+ }
+
static void doDrawGlyphsPos(SkCanvas* canvas, const jchar* glyphArray, const jfloat* posArray,
- int index, int count, jfloat x, jfloat y, SkPaint* paint) {
+ int index, int count, jfloat x, jfloat y, int flags, SkPaint* paint) {
SkPoint* posPtr = new SkPoint[count];
for (int indx = 0; indx < count; indx++) {
posPtr[indx].fX = SkFloatToScalar(x + posArray[indx * 2]);
@@ -846,27 +852,27 @@
delete[] posPtr;
}
- static void drawTextRun___CIIIIFFPaint(
+ static void drawTextRun___CIIIIFFIPaint(
JNIEnv* env, jobject, SkCanvas* canvas, jcharArray text, int index,
int count, int contextIndex, int contextCount,
- jfloat x, jfloat y, SkPaint* paint) {
+ jfloat x, jfloat y, int dirFlags, SkPaint* paint) {
jchar* chars = env->GetCharArrayElements(text, NULL);
drawTextWithGlyphs(canvas, chars + contextIndex, index - contextIndex,
- count, contextCount, x, y, paint);
+ count, contextCount, x, y, dirFlags, paint);
env->ReleaseCharArrayElements(text, chars, JNI_ABORT);
}
- static void drawTextRun__StringIIIIFFPaint(
+ static void drawTextRun__StringIIIIFFIPaint(
JNIEnv* env, jobject obj, SkCanvas* canvas, jstring text, jint start,
jint end, jint contextStart, jint contextEnd,
- jfloat x, jfloat y, SkPaint* paint) {
+ jfloat x, jfloat y, jint dirFlags, SkPaint* paint) {
jint count = end - start;
jint contextCount = contextEnd - contextStart;
const jchar* chars = env->GetStringChars(text, NULL);
drawTextWithGlyphs(canvas, chars + contextStart, start - contextStart,
- count, contextCount, x, y, paint);
+ count, contextCount, x, y, dirFlags, paint);
env->ReleaseStringChars(text, chars);
}
@@ -929,19 +935,21 @@
static void drawTextOnPath___CIIPathFFPaint(JNIEnv* env, jobject,
SkCanvas* canvas, jcharArray text, int index, int count,
- SkPath* path, jfloat hOffset, jfloat vOffset, SkPaint* paint) {
+ SkPath* path, jfloat hOffset, jfloat vOffset, jint bidiFlags, SkPaint* paint) {
jchar* textArray = env->GetCharArrayElements(text, NULL);
- TextLayout::drawTextOnPath(paint, textArray + index, count, hOffset, vOffset, path, canvas);
+ TextLayout::drawTextOnPath(paint, textArray + index, count, bidiFlags, hOffset, vOffset,
+ path, canvas);
env->ReleaseCharArrayElements(text, textArray, 0);
}
static void drawTextOnPath__StringPathFFPaint(JNIEnv* env, jobject,
SkCanvas* canvas, jstring text, SkPath* path,
- jfloat hOffset, jfloat vOffset, SkPaint* paint) {
+ jfloat hOffset, jfloat vOffset, jint bidiFlags, SkPaint* paint) {
const jchar* text_ = env->GetStringChars(text, NULL);
int count = env->GetStringLength(text);
- TextLayout::drawTextOnPath(paint, text_, count, hOffset, vOffset, path, canvas);
+ TextLayout::drawTextOnPath(paint, text_, count, bidiFlags, hOffset, vOffset,
+ path, canvas);
env->ReleaseStringChars(text, text_);
}
@@ -1051,21 +1059,21 @@
(void*)SkCanvasGlue::drawBitmapMesh},
{"nativeDrawVertices", "(III[FI[FI[II[SIII)V",
(void*)SkCanvasGlue::drawVertices},
- {"native_drawText","(I[CIIFFI)V",
- (void*) SkCanvasGlue::drawText___CIIFFPaint},
- {"native_drawText","(ILjava/lang/String;IIFFI)V",
- (void*) SkCanvasGlue::drawText__StringIIFFPaint},
- {"native_drawTextRun","(I[CIIIIFFI)V",
- (void*) SkCanvasGlue::drawTextRun___CIIIIFFPaint},
- {"native_drawTextRun","(ILjava/lang/String;IIIIFFI)V",
- (void*) SkCanvasGlue::drawTextRun__StringIIIIFFPaint},
+ {"native_drawText","(I[CIIFFII)V",
+ (void*) SkCanvasGlue::drawText___CIIFFIPaint},
+ {"native_drawText","(ILjava/lang/String;IIFFII)V",
+ (void*) SkCanvasGlue::drawText__StringIIFFIPaint},
+ {"native_drawTextRun","(I[CIIIIFFII)V",
+ (void*) SkCanvasGlue::drawTextRun___CIIIIFFIPaint},
+ {"native_drawTextRun","(ILjava/lang/String;IIIIFFII)V",
+ (void*) SkCanvasGlue::drawTextRun__StringIIIIFFIPaint},
{"native_drawPosText","(I[CII[FI)V",
(void*) SkCanvasGlue::drawPosText___CII_FPaint},
{"native_drawPosText","(ILjava/lang/String;[FI)V",
(void*) SkCanvasGlue::drawPosText__String_FPaint},
- {"native_drawTextOnPath","(I[CIIIFFI)V",
+ {"native_drawTextOnPath","(I[CIIIFFII)V",
(void*) SkCanvasGlue::drawTextOnPath___CIIPathFFPaint},
- {"native_drawTextOnPath","(ILjava/lang/String;IFFI)V",
+ {"native_drawTextOnPath","(ILjava/lang/String;IFFII)V",
(void*) SkCanvasGlue::drawTextOnPath__StringPathFFPaint},
{"native_drawPicture", "(II)V", (void*) SkCanvasGlue::drawPicture},
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp
index 07f55e0..29a36de 100644
--- a/core/jni/android/graphics/Paint.cpp
+++ b/core/jni/android/graphics/Paint.cpp
@@ -401,7 +401,7 @@
jfloat result = 0;
TextLayout::getTextRunAdvances(paint, textArray, index, count, textLength,
- NULL /* dont need all advances */, &result);
+ paint->getFlags(), NULL /* dont need all advances */, &result);
env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray), JNI_ABORT);
return result;
@@ -426,7 +426,7 @@
jfloat width = 0;
TextLayout::getTextRunAdvances(paint, textArray, start, count, textLength,
- NULL /* dont need all advances */, &width);
+ paint->getFlags(), NULL /* dont need all advances */, &width);
env->ReleaseStringChars(text, textArray);
return width;
@@ -446,7 +446,7 @@
jfloat width = 0;
TextLayout::getTextRunAdvances(paint, textArray, 0, textLength, textLength,
- NULL /* dont need all advances */, &width);
+ paint->getFlags(), NULL /* dont need all advances */, &width);
env->ReleaseStringChars(text, textArray);
return width;
@@ -473,7 +473,7 @@
jfloat* widthsArray = autoWidths.ptr();
TextLayout::getTextRunAdvances(paint, text, 0, count, count,
- widthsArray, NULL /* dont need totalAdvance */);
+ paint->getFlags(), widthsArray, NULL /* dont need totalAdvance */);
return count;
}
@@ -494,8 +494,48 @@
return count;
}
+ static int doTextGlyphs(JNIEnv* env, SkPaint* paint, const jchar* text, jint start, jint count,
+ jint contextCount, jint flags, jcharArray glyphs) {
+ NPE_CHECK_RETURN_ZERO(env, paint);
+ NPE_CHECK_RETURN_ZERO(env, text);
+
+ if ((start | count | contextCount) < 0 || contextCount < count || !glyphs) {
+ doThrowAIOOBE(env);
+ return 0;
+ }
+ if (count == 0) {
+ return 0;
+ }
+ size_t glypthsLength = env->GetArrayLength(glyphs);
+ if ((size_t)count > glypthsLength) {
+ doThrowAIOOBE(env);
+ return 0;
+ }
+
+ jchar* glyphsArray = env->GetCharArrayElements(glyphs, NULL);
+
+ sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
+ text, start, count, contextCount, flags);
+ const jchar* shapedGlyphs = value->getGlyphs();
+ size_t glyphsCount = value->getGlyphsCount();
+ memcpy(glyphsArray, shapedGlyphs, sizeof(jchar) * glyphsCount);
+
+ env->ReleaseCharArrayElements(glyphs, glyphsArray, JNI_ABORT);
+ return glyphsCount;
+ }
+
+ static int getTextGlyphs__StringIIIII_C(JNIEnv* env, jobject clazz, SkPaint* paint,
+ jstring text, jint start, jint end, jint contextStart, jint contextEnd, jint flags,
+ jcharArray glyphs) {
+ const jchar* textArray = env->GetStringChars(text, NULL);
+ int count = doTextGlyphs(env, paint, textArray + contextStart, start - contextStart,
+ end - start, contextEnd - contextStart, flags, glyphs);
+ env->ReleaseStringChars(text, textArray);
+ return count;
+ }
+
static jfloat doTextRunAdvances(JNIEnv *env, SkPaint *paint, const jchar *text,
- jint start, jint count, jint contextCount,
+ jint start, jint count, jint contextCount, jint flags,
jfloatArray advances, jint advancesIndex) {
NPE_CHECK_RETURN_ZERO(env, paint);
NPE_CHECK_RETURN_ZERO(env, text);
@@ -517,7 +557,7 @@
jfloat advancesArray[count];
jfloat totalAdvance = 0;
- TextLayout::getTextRunAdvances(paint, text, start, count, contextCount,
+ TextLayout::getTextRunAdvances(paint, text, start, count, contextCount, flags,
advancesArray, &totalAdvance);
if (advances != NULL) {
@@ -526,32 +566,70 @@
return totalAdvance;
}
- static float getTextRunAdvances___CIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint,
+ static jfloat doTextRunAdvancesICU(JNIEnv *env, SkPaint *paint, const jchar *text,
+ jint start, jint count, jint contextCount, jint flags,
+ jfloatArray advances, jint advancesIndex) {
+ NPE_CHECK_RETURN_ZERO(env, paint);
+ NPE_CHECK_RETURN_ZERO(env, text);
+
+ if ((start | count | contextCount | advancesIndex) < 0 || contextCount < count) {
+ doThrowAIOOBE(env);
+ return 0;
+ }
+ if (count == 0) {
+ return 0;
+ }
+ if (advances) {
+ size_t advancesLength = env->GetArrayLength(advances);
+ if ((size_t)count > advancesLength) {
+ doThrowAIOOBE(env);
+ return 0;
+ }
+ }
+
+ jfloat advancesArray[count];
+ jfloat totalAdvance = 0;
+
+ TextLayout::getTextRunAdvancesICU(paint, text, start, count, contextCount, flags,
+ advancesArray, totalAdvance);
+
+ if (advances != NULL) {
+ env->SetFloatArrayRegion(advances, advancesIndex, count, advancesArray);
+ }
+ return totalAdvance;
+ }
+
+ static float getTextRunAdvances___CIIIII_FII(JNIEnv* env, jobject clazz, SkPaint* paint,
jcharArray text, jint index, jint count, jint contextIndex, jint contextCount,
- jfloatArray advances, jint advancesIndex) {
+ jint flags, jfloatArray advances, jint advancesIndex, jint reserved) {
jchar* textArray = env->GetCharArrayElements(text, NULL);
- jfloat result = doTextRunAdvances(env, paint, textArray + contextIndex,
- index - contextIndex, count, contextCount, advances, advancesIndex);
+ jfloat result = (reserved == 0) ?
+ doTextRunAdvances(env, paint, textArray + contextIndex, index - contextIndex,
+ count, contextCount, flags, advances, advancesIndex) :
+ doTextRunAdvancesICU(env, paint, textArray + contextIndex, index - contextIndex,
+ count, contextCount, flags, advances, advancesIndex);
env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
return result;
}
- static float getTextRunAdvances__StringIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint,
- jstring text, jint start, jint end, jint contextStart, jint contextEnd,
- jfloatArray advances, jint advancesIndex) {
+ static float getTextRunAdvances__StringIIIII_FII(JNIEnv* env, jobject clazz, SkPaint* paint,
+ jstring text, jint start, jint end, jint contextStart, jint contextEnd, jint flags,
+ jfloatArray advances, jint advancesIndex, jint reserved) {
const jchar* textArray = env->GetStringChars(text, NULL);
- jfloat result = doTextRunAdvances(env, paint, textArray + contextStart,
- start - contextStart, end - start, contextEnd - contextStart,
- advances, advancesIndex);
+ jfloat result = (reserved == 0) ?
+ doTextRunAdvances(env, paint, textArray + contextStart, start - contextStart,
+ end - start, contextEnd - contextStart, flags, advances, advancesIndex) :
+ doTextRunAdvancesICU(env, paint, textArray + contextStart, start - contextStart,
+ end - start, contextEnd - contextStart, flags, advances, advancesIndex);
env->ReleaseStringChars(text, textArray);
return result;
}
static jint doTextRunCursor(JNIEnv *env, SkPaint* paint, const jchar *text, jint start,
- jint count, jint offset, jint opt) {
+ jint count, jint flags, jint offset, jint opt) {
jfloat scalarArray[count];
- TextLayout::getTextRunAdvances(paint, text, start, count, start + count,
+ TextLayout::getTextRunAdvances(paint, text, start, count, start + count, flags,
scalarArray, NULL /* dont need totalAdvance */);
jint pos = offset - start;
@@ -592,39 +670,39 @@
}
static jint getTextRunCursor___C(JNIEnv* env, jobject clazz, SkPaint* paint, jcharArray text,
- jint contextStart, jint contextCount, jint offset, jint cursorOpt) {
+ jint contextStart, jint contextCount, jint flags, jint offset, jint cursorOpt) {
jchar* textArray = env->GetCharArrayElements(text, NULL);
- jint result = doTextRunCursor(env, paint, textArray, contextStart, contextCount,
+ jint result = doTextRunCursor(env, paint, textArray, contextStart, contextCount, flags,
offset, cursorOpt);
env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
return result;
}
static jint getTextRunCursor__String(JNIEnv* env, jobject clazz, SkPaint* paint, jstring text,
- jint contextStart, jint contextEnd, jint offset, jint cursorOpt) {
+ jint contextStart, jint contextEnd, jint flags, jint offset, jint cursorOpt) {
const jchar* textArray = env->GetStringChars(text, NULL);
jint result = doTextRunCursor(env, paint, textArray, contextStart,
- contextEnd - contextStart, offset, cursorOpt);
+ contextEnd - contextStart, flags, offset, cursorOpt);
env->ReleaseStringChars(text, textArray);
return result;
}
static void getTextPath(JNIEnv* env, SkPaint* paint, const jchar* text, jint count,
- jfloat x, jfloat y, SkPath *path) {
- TextLayout::getTextPath(paint, text, count, x, y, path);
+ jint bidiFlags, jfloat x, jfloat y, SkPath *path) {
+ TextLayout::getTextPath(paint, text, count, bidiFlags, x, y, path);
}
- static void getTextPath___C(JNIEnv* env, jobject clazz, SkPaint* paint,
+ static void getTextPath___C(JNIEnv* env, jobject clazz, SkPaint* paint, jint bidiFlags,
jcharArray text, int index, int count, jfloat x, jfloat y, SkPath* path) {
const jchar* textArray = env->GetCharArrayElements(text, NULL);
- getTextPath(env, paint, textArray + index, count, x, y, path);
+ getTextPath(env, paint, textArray + index, count, bidiFlags, x, y, path);
env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray), JNI_ABORT);
}
- static void getTextPath__String(JNIEnv* env, jobject clazz, SkPaint* paint,
+ static void getTextPath__String(JNIEnv* env, jobject clazz, SkPaint* paint, jint bidiFlags,
jstring text, int start, int end, jfloat x, jfloat y, SkPath* path) {
const jchar* textArray = env->GetStringChars(text, NULL);
- getTextPath(env, paint, textArray + start, end - start, x, y, path);
+ getTextPath(env, paint, textArray + start, end - start, bidiFlags, x, y, path);
env->ReleaseStringChars(text, textArray);
}
@@ -648,7 +726,7 @@
int count, float maxWidth, jfloatArray jmeasured,
SkPaint::TextBufferDirection tbd) {
sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(&paint,
- text, 0, count, count);
+ text, 0, count, count, paint.getFlags());
if (value == NULL) {
return 0;
}
@@ -720,7 +798,7 @@
SkIRect ir;
sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(&paint,
- text, 0, count, count);
+ text, 0, count, count, paint.getFlags());
if (value == NULL) {
return;
}
@@ -808,15 +886,19 @@
{"native_breakText","(Ljava/lang/String;ZF[F)I", (void*) SkPaintGlue::breakTextS},
{"native_getTextWidths","(I[CII[F)I", (void*) SkPaintGlue::getTextWidths___CII_F},
{"native_getTextWidths","(ILjava/lang/String;II[F)I", (void*) SkPaintGlue::getTextWidths__StringII_F},
- {"native_getTextRunAdvances","(I[CIIII[FI)F",
- (void*) SkPaintGlue::getTextRunAdvances___CIIII_FI},
- {"native_getTextRunAdvances","(ILjava/lang/String;IIII[FI)F",
- (void*) SkPaintGlue::getTextRunAdvances__StringIIII_FI},
- {"native_getTextRunCursor", "(I[CIIII)I", (void*) SkPaintGlue::getTextRunCursor___C},
- {"native_getTextRunCursor", "(ILjava/lang/String;IIII)I",
+ {"native_getTextRunAdvances","(I[CIIIII[FII)F",
+ (void*) SkPaintGlue::getTextRunAdvances___CIIIII_FII},
+ {"native_getTextRunAdvances","(ILjava/lang/String;IIIII[FII)F",
+ (void*) SkPaintGlue::getTextRunAdvances__StringIIIII_FII},
+
+
+ {"native_getTextGlyphs","(ILjava/lang/String;IIIII[C)I",
+ (void*) SkPaintGlue::getTextGlyphs__StringIIIII_C},
+ {"native_getTextRunCursor", "(I[CIIIII)I", (void*) SkPaintGlue::getTextRunCursor___C},
+ {"native_getTextRunCursor", "(ILjava/lang/String;IIIII)I",
(void*) SkPaintGlue::getTextRunCursor__String},
- {"native_getTextPath","(I[CIIFFI)V", (void*) SkPaintGlue::getTextPath___C},
- {"native_getTextPath","(ILjava/lang/String;IIFFI)V", (void*) SkPaintGlue::getTextPath__String},
+ {"native_getTextPath","(II[CIIFFI)V", (void*) SkPaintGlue::getTextPath___C},
+ {"native_getTextPath","(IILjava/lang/String;IIFFI)V", (void*) SkPaintGlue::getTextPath__String},
{"nativeGetStringBounds", "(ILjava/lang/String;IILandroid/graphics/Rect;)V",
(void*) SkPaintGlue::getStringBounds },
{"nativeGetCharArrayBounds", "(I[CIILandroid/graphics/Rect;)V",
diff --git a/core/jni/android/graphics/TextLayout.cpp b/core/jni/android/graphics/TextLayout.cpp
index b77236c..2beedad 100644
--- a/core/jni/android/graphics/TextLayout.cpp
+++ b/core/jni/android/graphics/TextLayout.cpp
@@ -28,13 +28,33 @@
namespace android {
+// Returns true if we might need layout. If bidiFlags force LTR, assume no layout, if
+// bidiFlags indicate there probably is RTL, assume we do, otherwise scan the text
+// looking for a character >= the first RTL character in unicode and assume we do if
+// we find one.
+bool TextLayout::needsLayout(const jchar* text, jint len, jint bidiFlags) {
+ if (bidiFlags == kBidi_Force_LTR) {
+ return false;
+ }
+ if ((bidiFlags == kBidi_RTL) || (bidiFlags == kBidi_Default_RTL) ||
+ bidiFlags == kBidi_Force_RTL) {
+ return true;
+ }
+ for (int i = 0; i < len; ++i) {
+ if (text[i] >= UNICODE_FIRST_RTL_CHAR) {
+ return true;
+ }
+ }
+ return false;
+}
+
// Draws or gets the path of a paragraph of text on a single line, running bidi and shaping.
// This will draw if canvas is not null, otherwise path must be non-null and it will create
// a path representing the text that would have been drawn.
void TextLayout::handleText(SkPaint *paint, const jchar* text, jsize len,
- jfloat x, jfloat y, SkPath *path) {
+ jint bidiFlags, jfloat x, jfloat y, SkPath *path) {
sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
- text, 0, len, len);
+ text, 0, len, len, bidiFlags);
if (value == NULL) {
return ;
}
@@ -45,10 +65,10 @@
}
void TextLayout::getTextRunAdvances(SkPaint* paint, const jchar* chars, jint start,
- jint count, jint contextCount,
+ jint count, jint contextCount, jint dirFlags,
jfloat* resultAdvances, jfloat* resultTotalAdvance) {
sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
- chars, start, count, contextCount);
+ chars, start, count, contextCount, dirFlags);
if (value == NULL) {
return ;
}
@@ -60,20 +80,29 @@
}
}
-void TextLayout::getTextPath(SkPaint *paint, const jchar *text, jsize len,
- jfloat x, jfloat y, SkPath *path) {
- handleText(paint, text, len, x, y, path);
+void TextLayout::getTextRunAdvancesICU(SkPaint* paint, const jchar* chars, jint start,
+ jint count, jint contextCount, jint dirFlags,
+ jfloat* resultAdvances, jfloat& resultTotalAdvance) {
+ // Compute advances and return them
+ computeAdvancesWithICU(paint, chars, start, count, contextCount, dirFlags,
+ resultAdvances, &resultTotalAdvance);
}
+void TextLayout::getTextPath(SkPaint *paint, const jchar *text, jsize len,
+ jint bidiFlags, jfloat x, jfloat y, SkPath *path) {
+ handleText(paint, text, len, bidiFlags, x, y, path);
+}
+
+
void TextLayout::drawTextOnPath(SkPaint* paint, const jchar* text, int count,
- jfloat hOffset, jfloat vOffset,
+ int bidiFlags, jfloat hOffset, jfloat vOffset,
SkPath* path, SkCanvas* canvas) {
SkScalar h_ = SkFloatToScalar(hOffset);
SkScalar v_ = SkFloatToScalar(vOffset);
sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
- text, 0, count, count);
+ text, 0, count, count, bidiFlags);
if (value == NULL) {
return;
}
@@ -82,4 +111,73 @@
canvas->drawTextOnPathHV(value->getGlyphs(), value->getGlyphsCount() * 2, *path, h_, v_, *paint);
}
+void TextLayout::computeAdvancesWithICU(SkPaint* paint, const UChar* chars,
+ size_t start, size_t count, size_t contextCount, int dirFlags,
+ jfloat* outAdvances, jfloat* outTotalAdvance) {
+ SkAutoSTMalloc<CHAR_BUFFER_SIZE, jchar> tempBuffer(contextCount);
+ jchar* buffer = tempBuffer.get();
+ SkScalar* scalarArray = (SkScalar*)outAdvances;
+
+ // this is where we'd call harfbuzz
+ // for now we just use ushape.c
+ size_t widths;
+ const jchar* text;
+ if (dirFlags & 0x1) { // rtl, call arabic shaping in case
+ UErrorCode status = U_ZERO_ERROR;
+ // Use fixed length since we need to keep start and count valid
+ u_shapeArabic(chars, contextCount, buffer, contextCount,
+ U_SHAPE_LENGTH_FIXED_SPACES_NEAR |
+ U_SHAPE_TEXT_DIRECTION_LOGICAL | U_SHAPE_LETTERS_SHAPE |
+ U_SHAPE_X_LAMALEF_SUB_ALTERNATE, &status);
+ // we shouldn't fail unless there's an out of memory condition,
+ // in which case we're hosed anyway
+ for (int i = start, e = i + count; i < e; ++i) {
+ if (buffer[i] == UNICODE_NOT_A_CHAR) {
+ buffer[i] = UNICODE_ZWSP; // zero-width-space for skia
+ }
+ }
+ text = buffer + start;
+ widths = paint->getTextWidths(text, count << 1, scalarArray);
+ } else {
+ text = chars + start;
+ widths = paint->getTextWidths(text, count << 1, scalarArray);
+ }
+
+ jfloat totalAdvance = 0;
+ if (widths < count) {
+#if DEBUG_ADVANCES
+ ALOGD("ICU -- count=%d", widths);
+#endif
+ // Skia operates on code points, not code units, so surrogate pairs return only
+ // one value. Expand the result so we have one value per UTF-16 code unit.
+
+ // Note, skia's getTextWidth gets confused if it encounters a surrogate pair,
+ // leaving the remaining widths zero. Not nice.
+ for (size_t i = 0, p = 0; i < widths; ++i) {
+ totalAdvance += outAdvances[p++] = SkScalarToFloat(scalarArray[i]);
+ if (p < count &&
+ text[p] >= UNICODE_FIRST_LOW_SURROGATE &&
+ text[p] < UNICODE_FIRST_PRIVATE_USE &&
+ text[p-1] >= UNICODE_FIRST_HIGH_SURROGATE &&
+ text[p-1] < UNICODE_FIRST_LOW_SURROGATE) {
+ outAdvances[p++] = 0;
+ }
+#if DEBUG_ADVANCES
+ ALOGD("icu-adv = %f - total = %f", outAdvances[i], totalAdvance);
+#endif
+ }
+ } else {
+#if DEBUG_ADVANCES
+ ALOGD("ICU -- count=%d", count);
+#endif
+ for (size_t i = 0; i < count; i++) {
+ totalAdvance += outAdvances[i] = SkScalarToFloat(scalarArray[i]);
+#if DEBUG_ADVANCES
+ ALOGD("icu-adv = %f - total = %f", outAdvances[i], totalAdvance);
+#endif
+ }
+ }
+ *outTotalAdvance = totalAdvance;
+}
+
}
diff --git a/core/jni/android/graphics/TextLayout.h b/core/jni/android/graphics/TextLayout.h
index fa388c8..a0f9402 100644
--- a/core/jni/android/graphics/TextLayout.h
+++ b/core/jni/android/graphics/TextLayout.h
@@ -42,6 +42,17 @@
#define USE_TEXT_LAYOUT_CACHE 1
enum {
+ kBidi_LTR = 0,
+ kBidi_RTL = 1,
+ kBidi_Default_LTR = 2,
+ kBidi_Default_RTL = 3,
+ kBidi_Force_LTR = 4,
+ kBidi_Force_RTL = 5,
+
+ kBidi_Mask = 0x7
+};
+
+enum {
kDirection_LTR = 0,
kDirection_RTL = 1,
@@ -52,18 +63,28 @@
public:
static void getTextRunAdvances(SkPaint* paint, const jchar* chars, jint start,
- jint count, jint contextCount,
+ jint count, jint contextCount, jint dirFlags,
jfloat* resultAdvances, jfloat* resultTotalAdvance);
+ static void getTextRunAdvancesICU(SkPaint* paint, const jchar* chars, jint start,
+ jint count, jint contextCount, jint dirFlags,
+ jfloat* resultAdvances, jfloat& resultTotalAdvance);
+
static void getTextPath(SkPaint* paint, const jchar* text, jsize len,
- jfloat x, jfloat y, SkPath* path);
+ jint bidiFlags, jfloat x, jfloat y, SkPath* path);
static void drawTextOnPath(SkPaint* paint, const jchar* text, jsize len,
- jfloat hOffset, jfloat vOffset,
+ int bidiFlags, jfloat hOffset, jfloat vOffset,
SkPath* path, SkCanvas* canvas);
private:
+ static bool needsLayout(const jchar* text, jint len, jint bidiFlags);
+
static void handleText(SkPaint* paint, const jchar* text, jsize len,
- jfloat x, jfloat y, SkPath* path);
+ int bidiFlags, jfloat x, jfloat y, SkPath* path);
+
+ static void computeAdvancesWithICU(SkPaint* paint, const UChar* chars,
+ size_t start, size_t count, size_t contextCount, int dirFlags,
+ jfloat* outAdvances, jfloat* outTotalAdvance);
};
} // namespace android
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index 1a8612e..1ace23e 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -87,7 +87,7 @@
* Caching
*/
sp<TextLayoutValue> TextLayoutCache::getValue(const SkPaint* paint,
- const jchar* text, jint start, jint count, jint contextCount) {
+ const jchar* text, jint start, jint count, jint contextCount, jint dirFlags) {
AutoMutex _l(mLock);
nsecs_t startTime = 0;
if (mDebugEnabled) {
@@ -95,7 +95,7 @@
}
// Create the key
- TextLayoutCacheKey key(paint, text, start, count, contextCount);
+ TextLayoutCacheKey key(paint, text, start, count, contextCount, dirFlags);
// Get value from cache if possible
sp<TextLayoutValue> value = mCache.get(key);
@@ -111,7 +111,7 @@
// Compute advances and store them
mShaper->computeValues(value.get(), paint,
reinterpret_cast<const UChar*>(key.getText()), start, count,
- size_t(contextCount));
+ size_t(contextCount), int(dirFlags));
if (mDebugEnabled) {
value->setElapsedTime(systemTime(SYSTEM_TIME_MONOTONIC) - startTime);
@@ -218,13 +218,14 @@
* TextLayoutCacheKey
*/
TextLayoutCacheKey::TextLayoutCacheKey(): start(0), count(0), contextCount(0),
- typeface(NULL), textSize(0), textSkewX(0), textScaleX(0), flags(0),
+ dirFlags(0), typeface(NULL), textSize(0), textSkewX(0), textScaleX(0), flags(0),
hinting(SkPaint::kNo_Hinting), variant(SkPaint::kDefault_Variant), language() {
}
TextLayoutCacheKey::TextLayoutCacheKey(const SkPaint* paint, const UChar* text,
- size_t start, size_t count, size_t contextCount) :
- start(start), count(count), contextCount(contextCount) {
+ size_t start, size_t count, size_t contextCount, int dirFlags) :
+ start(start), count(count), contextCount(contextCount),
+ dirFlags(dirFlags) {
textCopy.setTo(text, contextCount);
typeface = paint->getTypeface();
textSize = paint->getTextSize();
@@ -241,6 +242,7 @@
start(other.start),
count(other.count),
contextCount(other.contextCount),
+ dirFlags(other.dirFlags),
typeface(other.typeface),
textSize(other.textSize),
textSkewX(other.textSkewX),
@@ -279,6 +281,9 @@
deltaInt = lhs.hinting - rhs.hinting;
if (deltaInt != 0) return (deltaInt);
+ deltaInt = lhs.dirFlags - rhs.dirFlags;
+ if (deltaInt) return (deltaInt);
+
deltaInt = lhs.variant - rhs.variant;
if (deltaInt) return (deltaInt);
@@ -354,9 +359,9 @@
}
void TextLayoutShaper::computeValues(TextLayoutValue* value, const SkPaint* paint, const UChar* chars,
- size_t start, size_t count, size_t contextCount) {
+ size_t start, size_t count, size_t contextCount, int dirFlags) {
- computeValues(paint, chars, start, count, contextCount,
+ computeValues(paint, chars, start, count, contextCount, dirFlags,
&value->mAdvances, &value->mTotalAdvance, &value->mGlyphs, &value->mPos);
#if DEBUG_ADVANCES
ALOGD("Advances - start = %d, count = %d, contextCount = %d, totalAdvance = %f", start, count,
@@ -365,7 +370,7 @@
}
void TextLayoutShaper::computeValues(const SkPaint* paint, const UChar* chars,
- size_t start, size_t count, size_t contextCount,
+ size_t start, size_t count, size_t contextCount, int dirFlags,
Vector<jfloat>* const outAdvances, jfloat* outTotalAdvance,
Vector<jchar>* const outGlyphs, Vector<jfloat>* const outPos) {
*outTotalAdvance = 0;
@@ -373,94 +378,110 @@
return;
}
- UBiDiLevel bidiReq = UBIDI_DEFAULT_LTR;
+ UBiDiLevel bidiReq = 0;
+ bool forceLTR = false;
+ bool forceRTL = false;
+
+ switch (dirFlags & kBidi_Mask) {
+ case kBidi_LTR: bidiReq = 0; break; // no ICU constant, canonical LTR level
+ case kBidi_RTL: bidiReq = 1; break; // no ICU constant, canonical RTL level
+ case kBidi_Default_LTR: bidiReq = UBIDI_DEFAULT_LTR; break;
+ case kBidi_Default_RTL: bidiReq = UBIDI_DEFAULT_RTL; break;
+ case kBidi_Force_LTR: forceLTR = true; break; // every char is LTR
+ case kBidi_Force_RTL: forceRTL = true; break; // every char is RTL
+ }
+
bool useSingleRun = false;
- bool isRTL = false;
-
- UBiDi* bidi = ubidi_open();
- if (bidi) {
- UErrorCode status = U_ZERO_ERROR;
+ bool isRTL = forceRTL;
+ if (forceLTR || forceRTL) {
+ useSingleRun = true;
+ } else {
+ UBiDi* bidi = ubidi_open();
+ if (bidi) {
+ UErrorCode status = U_ZERO_ERROR;
#if DEBUG_GLYPHS
- ALOGD("******** ComputeValues -- start");
- ALOGD(" -- string = '%s'", String8(chars + start, count).string());
- ALOGD(" -- start = %d", start);
- ALOGD(" -- count = %d", count);
- ALOGD(" -- contextCount = %d", contextCount);
- ALOGD(" -- bidiReq = %d", bidiReq);
+ ALOGD("******** ComputeValues -- start");
+ ALOGD(" -- string = '%s'", String8(chars + start, count).string());
+ ALOGD(" -- start = %d", start);
+ ALOGD(" -- count = %d", count);
+ ALOGD(" -- contextCount = %d", contextCount);
+ ALOGD(" -- bidiReq = %d", bidiReq);
#endif
- ubidi_setPara(bidi, chars, contextCount, bidiReq, NULL, &status);
- if (U_SUCCESS(status)) {
- int paraDir = ubidi_getParaLevel(bidi) & kDirection_Mask; // 0 if ltr, 1 if rtl
- ssize_t rc = ubidi_countRuns(bidi, &status);
+ ubidi_setPara(bidi, chars, contextCount, bidiReq, NULL, &status);
+ if (U_SUCCESS(status)) {
+ int paraDir = ubidi_getParaLevel(bidi) & kDirection_Mask; // 0 if ltr, 1 if rtl
+ ssize_t rc = ubidi_countRuns(bidi, &status);
#if DEBUG_GLYPHS
- ALOGD(" -- paraDir = %d", paraDir);
- ALOGD(" -- run-count = %d", int(rc));
+ ALOGD(" -- dirFlags = %d", dirFlags);
+ ALOGD(" -- paraDir = %d", paraDir);
+ ALOGD(" -- run-count = %d", int(rc));
#endif
- if (U_SUCCESS(status) && rc == 1) {
- // Normal case: one run, status is ok
- isRTL = (paraDir == 1);
- useSingleRun = true;
- } else if (!U_SUCCESS(status) || rc < 1) {
- ALOGW("Need to force to single run -- string = '%s',"
- " status = %d, rc = %d",
- String8(chars + start, count).string(), status, int(rc));
- isRTL = (paraDir == 1);
- useSingleRun = true;
- } else {
- int32_t end = start + count;
- for (size_t i = 0; i < size_t(rc); ++i) {
- int32_t startRun = -1;
- int32_t lengthRun = -1;
- UBiDiDirection runDir = ubidi_getVisualRun(bidi, i, &startRun, &lengthRun);
+ if (U_SUCCESS(status) && rc == 1) {
+ // Normal case: one run, status is ok
+ isRTL = (paraDir == 1);
+ useSingleRun = true;
+ } else if (!U_SUCCESS(status) || rc < 1) {
+ ALOGW("Need to force to single run -- string = '%s',"
+ " status = %d, rc = %d",
+ String8(chars + start, count).string(), status, int(rc));
+ isRTL = (paraDir == 1);
+ useSingleRun = true;
+ } else {
+ int32_t end = start + count;
+ for (size_t i = 0; i < size_t(rc); ++i) {
+ int32_t startRun = -1;
+ int32_t lengthRun = -1;
+ UBiDiDirection runDir = ubidi_getVisualRun(bidi, i, &startRun, &lengthRun);
- if (startRun == -1 || lengthRun == -1) {
- // Something went wrong when getting the visual run, need to clear
- // already computed data before doing a single run pass
- ALOGW("Visual run is not valid");
- outGlyphs->clear();
- outAdvances->clear();
- outPos->clear();
- *outTotalAdvance = 0;
- isRTL = (paraDir == 1);
- useSingleRun = true;
- break;
- }
+ if (startRun == -1 || lengthRun == -1) {
+ // Something went wrong when getting the visual run, need to clear
+ // already computed data before doing a single run pass
+ ALOGW("Visual run is not valid");
+ outGlyphs->clear();
+ outAdvances->clear();
+ outPos->clear();
+ *outTotalAdvance = 0;
+ isRTL = (paraDir == 1);
+ useSingleRun = true;
+ break;
+ }
- if (startRun >= end) {
- continue;
- }
- int32_t endRun = startRun + lengthRun;
- if (endRun <= int32_t(start)) {
- continue;
- }
- if (startRun < int32_t(start)) {
- startRun = int32_t(start);
- }
- if (endRun > end) {
- endRun = end;
- }
+ if (startRun >= end) {
+ continue;
+ }
+ int32_t endRun = startRun + lengthRun;
+ if (endRun <= int32_t(start)) {
+ continue;
+ }
+ if (startRun < int32_t(start)) {
+ startRun = int32_t(start);
+ }
+ if (endRun > end) {
+ endRun = end;
+ }
- lengthRun = endRun - startRun;
- isRTL = (runDir == UBIDI_RTL);
+ lengthRun = endRun - startRun;
+ isRTL = (runDir == UBIDI_RTL);
#if DEBUG_GLYPHS
- ALOGD("Processing Bidi Run = %d -- run-start = %d, run-len = %d, isRTL = %d",
- i, startRun, lengthRun, isRTL);
+ ALOGD("Processing Bidi Run = %d -- run-start = %d, run-len = %d, isRTL = %d",
+ i, startRun, lengthRun, isRTL);
#endif
- computeRunValues(paint, chars, startRun, lengthRun, contextCount, isRTL,
- outAdvances, outTotalAdvance, outGlyphs, outPos);
+ computeRunValues(paint, chars, startRun, lengthRun, contextCount, isRTL,
+ outAdvances, outTotalAdvance, outGlyphs, outPos);
+ }
}
+ } else {
+ ALOGW("Cannot set Para");
+ useSingleRun = true;
+ isRTL = (bidiReq = 1) || (bidiReq = UBIDI_DEFAULT_RTL);
}
+ ubidi_close(bidi);
} else {
- ALOGW("Cannot set Para");
+ ALOGW("Cannot ubidi_open()");
useSingleRun = true;
isRTL = (bidiReq = 1) || (bidiReq = UBIDI_DEFAULT_RTL);
}
- ubidi_close(bidi);
- } else {
- ALOGW("Cannot ubidi_open()");
- useSingleRun = true;
- isRTL = (bidiReq = 1) || (bidiReq = UBIDI_DEFAULT_RTL);
}
// Default single run case
@@ -897,11 +918,11 @@
}
sp<TextLayoutValue> TextLayoutEngine::getValue(const SkPaint* paint, const jchar* text,
- jint start, jint count, jint contextCount) {
+ jint start, jint count, jint contextCount, jint dirFlags) {
sp<TextLayoutValue> value;
#if USE_TEXT_LAYOUT_CACHE
value = mTextLayoutCache->getValue(paint, text, start, count,
- contextCount);
+ contextCount, dirFlags);
if (value == NULL) {
ALOGE("Cannot get TextLayoutCache value for text = '%s'",
String8(text + start, count).string());
@@ -909,7 +930,7 @@
#else
value = new TextLayoutValue(count);
mShaper->computeValues(value.get(), paint,
- reinterpret_cast<const UChar*>(text), start, count, contextCount);
+ reinterpret_cast<const UChar*>(text), start, count, contextCount, dirFlags);
#endif
return value;
}
diff --git a/core/jni/android/graphics/TextLayoutCache.h b/core/jni/android/graphics/TextLayoutCache.h
index 6858c0e..f9b9900 100644
--- a/core/jni/android/graphics/TextLayoutCache.h
+++ b/core/jni/android/graphics/TextLayoutCache.h
@@ -70,7 +70,7 @@
TextLayoutCacheKey();
TextLayoutCacheKey(const SkPaint* paint, const UChar* text, size_t start, size_t count,
- size_t contextCount);
+ size_t contextCount, int dirFlags);
TextLayoutCacheKey(const TextLayoutCacheKey& other);
@@ -97,6 +97,7 @@
size_t start;
size_t count;
size_t contextCount;
+ int dirFlags;
SkTypeface* typeface;
SkScalar textSize;
SkScalar textSkewX;
@@ -180,7 +181,7 @@
virtual ~TextLayoutShaper();
void computeValues(TextLayoutValue* value, const SkPaint* paint, const UChar* chars,
- size_t start, size_t count, size_t contextCount);
+ size_t start, size_t count, size_t contextCount, int dirFlags);
void purgeCaches();
@@ -214,7 +215,7 @@
size_t shapeFontRun(const SkPaint* paint);
void computeValues(const SkPaint* paint, const UChar* chars,
- size_t start, size_t count, size_t contextCount,
+ size_t start, size_t count, size_t contextCount, int dirFlags,
Vector<jfloat>* const outAdvances, jfloat* outTotalAdvance,
Vector<jchar>* const outGlyphs, Vector<jfloat>* const outPos);
@@ -251,7 +252,7 @@
void operator()(TextLayoutCacheKey& text, sp<TextLayoutValue>& desc);
sp<TextLayoutValue> getValue(const SkPaint* paint, const jchar* text, jint start,
- jint count, jint contextCount);
+ jint count, jint contextCount, jint dirFlags);
/**
* Clear the cache
@@ -303,7 +304,7 @@
* the call. Be careful of this when doing optimization.
**/
sp<TextLayoutValue> getValue(const SkPaint* paint, const jchar* text, jint start,
- jint count, jint contextCount);
+ jint count, jint contextCount, jint dirFlags);
void purgeCaches();
diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp
index f5f22b2..faae11e 100644
--- a/core/jni/android_net_NetUtils.cpp
+++ b/core/jni/android_net_NetUtils.cpp
@@ -136,6 +136,10 @@
result = ::dhcp_do_request(nameStr, ipaddr, gateway, &prefixLength,
dns, server, &lease, vendorInfo, domains);
}
+ if (result != 0) {
+ ALOGD("dhcp_do_request failed");
+ }
+
env->ReleaseStringUTFChars(ifname, nameStr);
if (result == 0) {
env->CallVoidMethod(dhcpResults, dhcpResultsFieldIds.clear);
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index ba62f6d..10c92ba 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -568,9 +568,9 @@
// ----------------------------------------------------------------------------
static void renderText(OpenGLRenderer* renderer, const jchar* text, int count,
- jfloat x, jfloat y, SkPaint* paint) {
+ jfloat x, jfloat y, int flags, SkPaint* paint) {
sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
- text, 0, count, count);
+ text, 0, count, count, flags);
if (value == NULL) {
return;
}
@@ -584,9 +584,9 @@
}
static void renderTextOnPath(OpenGLRenderer* renderer, const jchar* text, int count,
- SkPath* path, jfloat hOffset, jfloat vOffset, SkPaint* paint) {
+ SkPath* path, jfloat hOffset, jfloat vOffset, int flags, SkPaint* paint) {
sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
- text, 0, count, count);
+ text, 0, count, count, flags);
if (value == NULL) {
return;
}
@@ -599,9 +599,9 @@
static void renderTextRun(OpenGLRenderer* renderer, const jchar* text,
jint start, jint count, jint contextCount, jfloat x, jfloat y,
- SkPaint* paint) {
+ int flags, SkPaint* paint) {
sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
- text, start, count, contextCount);
+ text, start, count, contextCount, flags);
if (value == NULL) {
return;
}
@@ -616,62 +616,64 @@
static void android_view_GLES20Canvas_drawTextArray(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer, jcharArray text, jint index, jint count,
- jfloat x, jfloat y, SkPaint* paint) {
+ jfloat x, jfloat y, jint flags, SkPaint* paint) {
jchar* textArray = env->GetCharArrayElements(text, NULL);
- renderText(renderer, textArray + index, count, x, y, paint);
+ renderText(renderer, textArray + index, count, x, y, flags, paint);
env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
}
static void android_view_GLES20Canvas_drawText(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer, jstring text, jint start, jint end,
- jfloat x, jfloat y, SkPaint* paint) {
+ jfloat x, jfloat y, jint flags, SkPaint* paint) {
const jchar* textArray = env->GetStringChars(text, NULL);
- renderText(renderer, textArray + start, end - start, x, y, paint);
+ renderText(renderer, textArray + start, end - start, x, y, flags, paint);
env->ReleaseStringChars(text, textArray);
}
static void android_view_GLES20Canvas_drawTextArrayOnPath(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer, jcharArray text, jint index, jint count,
- SkPath* path, jfloat hOffset, jfloat vOffset, SkPaint* paint) {
+ SkPath* path, jfloat hOffset, jfloat vOffset, jint flags, SkPaint* paint) {
jchar* textArray = env->GetCharArrayElements(text, NULL);
renderTextOnPath(renderer, textArray + index, count, path,
- hOffset, vOffset, paint);
+ hOffset, vOffset, flags, paint);
env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
}
static void android_view_GLES20Canvas_drawTextOnPath(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer, jstring text, jint start, jint end,
- SkPath* path, jfloat hOffset, jfloat vOffset, SkPaint* paint) {
+ SkPath* path, jfloat hOffset, jfloat vOffset, jint flags, SkPaint* paint) {
const jchar* textArray = env->GetStringChars(text, NULL);
renderTextOnPath(renderer, textArray + start, end - start, path,
- hOffset, vOffset, paint);
+ hOffset, vOffset, flags, paint);
env->ReleaseStringChars(text, textArray);
}
static void android_view_GLES20Canvas_drawTextRunArray(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer, jcharArray text, jint index, jint count,
- jint contextIndex, jint contextCount, jfloat x, jfloat y, SkPaint* paint) {
+ jint contextIndex, jint contextCount, jfloat x, jfloat y, jint dirFlags,
+ SkPaint* paint) {
jchar* textArray = env->GetCharArrayElements(text, NULL);
renderTextRun(renderer, textArray + contextIndex, index - contextIndex,
- count, contextCount, x, y, paint);
+ count, contextCount, x, y, dirFlags, paint);
env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
}
static void android_view_GLES20Canvas_drawTextRun(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer, jstring text, jint start, jint end,
- jint contextStart, int contextEnd, jfloat x, jfloat y, SkPaint* paint) {
+ jint contextStart, int contextEnd, jfloat x, jfloat y, jint dirFlags,
+ SkPaint* paint) {
const jchar* textArray = env->GetStringChars(text, NULL);
jint count = end - start;
jint contextCount = contextEnd - contextStart;
renderTextRun(renderer, textArray + contextStart, start - contextStart,
- count, contextCount, x, y, paint);
+ count, contextCount, x, y, dirFlags, paint);
env->ReleaseStringChars(text, textArray);
}
static void renderPosText(OpenGLRenderer* renderer, const jchar* text, int count,
- const jfloat* positions, SkPaint* paint) {
+ const jfloat* positions, jint dirFlags, SkPaint* paint) {
sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
- text, 0, count, count);
+ text, 0, count, count, dirFlags);
if (value == NULL) {
return;
}
@@ -689,7 +691,7 @@
jchar* textArray = env->GetCharArrayElements(text, NULL);
jfloat* positions = env->GetFloatArrayElements(pos, NULL);
- renderPosText(renderer, textArray + index, count, positions, paint);
+ renderPosText(renderer, textArray + index, count, positions, kBidi_LTR, paint);
env->ReleaseFloatArrayElements(pos, positions, JNI_ABORT);
env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
@@ -701,7 +703,7 @@
const jchar* textArray = env->GetStringChars(text, NULL);
jfloat* positions = env->GetFloatArrayElements(pos, NULL);
- renderPosText(renderer, textArray + start, end - start, positions, paint);
+ renderPosText(renderer, textArray + start, end - start, positions, kBidi_LTR, paint);
env->ReleaseFloatArrayElements(pos, positions, JNI_ABORT);
env->ReleaseStringChars(text, textArray);
@@ -1005,16 +1007,16 @@
{ "nSetupPaintFilter", "(III)V", (void*) android_view_GLES20Canvas_setupPaintFilter },
{ "nResetPaintFilter", "(I)V", (void*) android_view_GLES20Canvas_resetPaintFilter },
- { "nDrawText", "(I[CIIFFI)V", (void*) android_view_GLES20Canvas_drawTextArray },
- { "nDrawText", "(ILjava/lang/String;IIFFI)V",
+ { "nDrawText", "(I[CIIFFII)V", (void*) android_view_GLES20Canvas_drawTextArray },
+ { "nDrawText", "(ILjava/lang/String;IIFFII)V",
(void*) android_view_GLES20Canvas_drawText },
- { "nDrawTextOnPath", "(I[CIIIFFI)V", (void*) android_view_GLES20Canvas_drawTextArrayOnPath },
- { "nDrawTextOnPath", "(ILjava/lang/String;IIIFFI)V",
+ { "nDrawTextOnPath", "(I[CIIIFFII)V", (void*) android_view_GLES20Canvas_drawTextArrayOnPath },
+ { "nDrawTextOnPath", "(ILjava/lang/String;IIIFFII)V",
(void*) android_view_GLES20Canvas_drawTextOnPath },
- { "nDrawTextRun", "(I[CIIIIFFI)V", (void*) android_view_GLES20Canvas_drawTextRunArray },
- { "nDrawTextRun", "(ILjava/lang/String;IIIIFFI)V",
+ { "nDrawTextRun", "(I[CIIIIFFII)V", (void*) android_view_GLES20Canvas_drawTextRunArray },
+ { "nDrawTextRun", "(ILjava/lang/String;IIIIFFII)V",
(void*) android_view_GLES20Canvas_drawTextRun },
{ "nDrawPosText", "(I[CII[FI)V", (void*) android_view_GLES20Canvas_drawPosTextArray },
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index 4671282..a41a389 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -55,6 +55,7 @@
static struct {
jclass clazz;
jfieldID mNativeObject;
+ jfieldID mNativeObjectLock;
jfieldID mCanvas;
jmethodID ctor;
} gSurfaceClassInfo;
@@ -90,8 +91,15 @@
}
sp<Surface> android_view_Surface_getSurface(JNIEnv* env, jobject surfaceObj) {
- return reinterpret_cast<Surface *>(
- env->GetIntField(surfaceObj, gSurfaceClassInfo.mNativeObject));
+ sp<Surface> sur;
+ jobject lock = env->GetObjectField(surfaceObj,
+ gSurfaceClassInfo.mNativeObjectLock);
+ if (env->MonitorEnter(lock) == JNI_OK) {
+ sur = reinterpret_cast<Surface *>(
+ env->GetIntField(surfaceObj, gSurfaceClassInfo.mNativeObject));
+ env->MonitorExit(lock);
+ }
+ return sur;
}
jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env,
@@ -399,6 +407,8 @@
gSurfaceClassInfo.clazz = jclass(env->NewGlobalRef(clazz));
gSurfaceClassInfo.mNativeObject =
env->GetFieldID(gSurfaceClassInfo.clazz, "mNativeObject", "I");
+ gSurfaceClassInfo.mNativeObjectLock =
+ env->GetFieldID(gSurfaceClassInfo.clazz, "mNativeObjectLock", "Ljava/lang/Object;");
gSurfaceClassInfo.mCanvas =
env->GetFieldID(gSurfaceClassInfo.clazz, "mCanvas", "Landroid/graphics/Canvas;");
gSurfaceClassInfo.ctor = env->GetMethodID(gSurfaceClassInfo.clazz, "<init>", "(I)V");
diff --git a/core/res/res/values-cs/strings.xml b/core/res/res/values-cs/strings.xml
index aef7bdc..102815f 100644
--- a/core/res/res/values-cs/strings.xml
+++ b/core/res/res/values-cs/strings.xml
@@ -885,7 +885,7 @@
<string name="permdesc_readHistoryBookmarks" msgid="8462378226600439658">"Umožňuje aplikaci číst historii všech adres URL navštívených v Prohlížeči a všechny záložky v Prohlížeči. Poznámka: Pro prohlížeče třetí strany a jiné aplikace umožňující procházení webu toto oprávnění platit nemusí."</string>
<string name="permlab_writeHistoryBookmarks" msgid="3714785165273314490">"psaní webových záložek a historie"</string>
<string name="permdesc_writeHistoryBookmarks" product="tablet" msgid="6825527469145760922">"Umožňuje aplikaci upravit historii prohlížeče nebo záložky uložené v tabletu. Aplikace s tímto oprávněním může vymazat či pozměnit data prohlížeče. Poznámka: Pro prohlížeče třetí strany a jiné aplikace umožňující procházení webu toto oprávnění platit nemusí."</string>
- <string name="permdesc_writeHistoryBookmarks" product="default" msgid="8497389531014185509">"Umožňuje aplikaci upravit historii prohlížeče nebo záložky uložené v telefonu. Aplikace s tímto oprávněním může vymazat či pozměnit data prohlížeče .Poznámka: Pro prohlížeče třetí strany a jiné aplikace umožňující procházení webu toto oprávnění platit nemusí."</string>
+ <string name="permdesc_writeHistoryBookmarks" product="default" msgid="8497389531014185509">"Umožňuje aplikaci upravit historii prohlížeče nebo záložky uložené v telefonu. Aplikace s tímto oprávněním může vymazat či pozměnit data prohlížeče. Poznámka: Pro prohlížeče třetí strany a jiné aplikace umožňující procházení webu toto oprávnění platit nemusí."</string>
<string name="permlab_setAlarm" msgid="1379294556362091814">"nastavení budíku"</string>
<string name="permdesc_setAlarm" msgid="316392039157473848">"Umožňuje aplikaci nastavit budík v nainstalované aplikaci budík. Některé aplikace budík tuto funkci nemusí obsahovat."</string>
<string name="permlab_addVoicemail" msgid="5525660026090959044">"přidat hlasovou zprávu"</string>
diff --git a/core/res/res/values-es-rUS/strings.xml b/core/res/res/values-es-rUS/strings.xml
index 1fc59b6..eeb6878 100644
--- a/core/res/res/values-es-rUS/strings.xml
+++ b/core/res/res/values-es-rUS/strings.xml
@@ -329,7 +329,7 @@
<string name="permdesc_confirm_full_backup" msgid="1748762171637699562">"Permite que la aplicación inicie la IU de confirmación de copia de seguridad completa. No todas las aplicaciones pueden utilizar este permiso."</string>
<string name="permlab_internalSystemWindow" msgid="2148563628140193231">"mostrar ventanas no autorizadas"</string>
<string name="permdesc_internalSystemWindow" msgid="7458387759461466397">"Permite que la aplicación cree ventanas para la interfaz de usuario interna del sistema. Las aplicaciones normales no deben usar este permiso."</string>
- <string name="permlab_systemAlertWindow" msgid="3543347980839518613">"destacar sobre otras aplicaciones"</string>
+ <string name="permlab_systemAlertWindow" msgid="3543347980839518613">"mostrar sobre otras aplicaciones"</string>
<string name="permdesc_systemAlertWindow" msgid="8584678381972820118">"Permite a la aplicación escribir por encima de otras aplicaciones o partes de la interfaz de usuario que pueden interferir en tu uso de la interfaz en cualquier aplicación o cambiar lo que crees que ves en otras aplicaciones."</string>
<string name="permlab_setAnimationScale" msgid="2805103241153907174">"modificar la velocidad de la animación global"</string>
<string name="permdesc_setAnimationScale" msgid="7690063428924343571">"Permite que la aplicación cambie la velocidad de animación global (animaciones más rápidas o más lentas) en cualquier momento."</string>
diff --git a/core/res/res/values-pl/strings.xml b/core/res/res/values-pl/strings.xml
index 98d7477..8aedc15 100644
--- a/core/res/res/values-pl/strings.xml
+++ b/core/res/res/values-pl/strings.xml
@@ -1188,7 +1188,7 @@
<string name="dlg_confirm_kill_storage_users_text" msgid="5100428757107469454">"Po włączeniu nośnika USB niektóre używane aplikacje zostaną zatrzymane i mogą być niedostępne do chwili jego wyłączenia."</string>
<string name="dlg_error_title" msgid="7323658469626514207">"Operacja USB zakończona niepowodzeniem"</string>
<string name="dlg_ok" msgid="7376953167039865701">"OK"</string>
- <string name="usb_mtp_notification_title" msgid="3699913097391550394">"Podłączono jako urządzenie multimedialne."</string>
+ <string name="usb_mtp_notification_title" msgid="3699913097391550394">"Podłączono urządzenie multimedialne"</string>
<string name="usb_ptp_notification_title" msgid="1960817192216064833">"Podłączono jako aparat."</string>
<string name="usb_cd_installer_notification_title" msgid="6774712827892090754">"Podłączono jako nośnik instalacyjny."</string>
<string name="usb_accessory_notification_title" msgid="7848236974087653666">"Podłączono akcesorium USB"</string>
@@ -1320,7 +1320,7 @@
<string name="sync_really_delete" msgid="2572600103122596243">"Usuń elementy."</string>
<string name="sync_undo_deletes" msgid="2941317360600338602">"Cofnij usunięcia"</string>
<string name="sync_do_nothing" msgid="3743764740430821845">"Nie wykonuj teraz żadnych czynności."</string>
- <string name="choose_account_label" msgid="5655203089746423927">"Wybierz konto."</string>
+ <string name="choose_account_label" msgid="5655203089746423927">"Wybierz konto"</string>
<string name="add_account_label" msgid="2935267344849993553">"Dodaj konto"</string>
<string name="add_account_button_label" msgid="3611982894853435874">"Dodaj konto"</string>
<string name="number_picker_increment_button" msgid="2412072272832284313">"Zwiększ"</string>
diff --git a/core/res/res/values-ro/strings.xml b/core/res/res/values-ro/strings.xml
index 88c56bc..4fb58b8 100644
--- a/core/res/res/values-ro/strings.xml
+++ b/core/res/res/values-ro/strings.xml
@@ -40,7 +40,7 @@
<string name="serviceEnabledFor" msgid="6856228140453471041">"Serviciul a fost activat pentru:"</string>
<string name="serviceDisabled" msgid="1937553226592516411">"Serviciul a fost dezactivat."</string>
<string name="serviceRegistered" msgid="6275019082598102493">"Înregistrarea a reuşit."</string>
- <string name="serviceErased" msgid="1288584695297200972">"Ştergerea a reuşit."</string>
+ <string name="serviceErased" msgid="1288584695297200972">"Ștergerea a reuşit."</string>
<string name="passwordIncorrect" msgid="7612208839450128715">"Parolă incorectă."</string>
<string name="mmiComplete" msgid="8232527495411698359">"MMI finalizat."</string>
<string name="badPin" msgid="9015277645546710014">"Codul PIN vechi introdus nu este corect."</string>
@@ -129,8 +129,8 @@
<string name="contentServiceSync" msgid="8353523060269335667">"Sincronizare"</string>
<string name="contentServiceSyncNotificationTitle" msgid="397743349191901458">"Sincronizare"</string>
<string name="contentServiceTooManyDeletesNotificationDesc" msgid="8100981435080696431">"Prea multe ştergeri <xliff:g id="CONTENT_TYPE">%s</xliff:g>."</string>
- <string name="low_memory" product="tablet" msgid="6494019234102154896">"Stocarea pe tabletă este plină. Ştergeţi câteva fişiere pentru a elibera spaţiu."</string>
- <string name="low_memory" product="default" msgid="3475999286680000541">"Stocarea pe telefon este plină. Ştergeţi câteva fişiere pentru a elibera spaţiu."</string>
+ <string name="low_memory" product="tablet" msgid="6494019234102154896">"Stocarea pe tabletă este plină. Ștergeţi câteva fişiere pentru a elibera spaţiu."</string>
+ <string name="low_memory" product="default" msgid="3475999286680000541">"Stocarea pe telefon este plină. Ștergeţi câteva fişiere pentru a elibera spaţiu."</string>
<string name="me" msgid="6545696007631404292">"Eu"</string>
<string name="power_dialog" product="tablet" msgid="8545351420865202853">"Opţiuni tablet PC"</string>
<string name="power_dialog" product="default" msgid="1319919075463988638">"Opţiuni telefon"</string>
@@ -628,9 +628,9 @@
<string name="policydesc_resetPassword" msgid="605963962301904458">"Editaţi parola de deblocare a ecranului."</string>
<string name="policylab_forceLock" msgid="2274085384704248431">"Blocaţi ecranul"</string>
<string name="policydesc_forceLock" msgid="1141797588403827138">"Stabiliţi modul şi timpul în care se blochează ecranul."</string>
- <string name="policylab_wipeData" msgid="3910545446758639713">"Ştergere integrală date"</string>
- <string name="policydesc_wipeData" product="tablet" msgid="4306184096067756876">"Ştergeţi datele de pe tabletă fără avertisment, efectuând resetarea configurării din fabrică."</string>
- <string name="policydesc_wipeData" product="default" msgid="5096895604574188391">"Ştergeţi datele din telefon fără avertisment, efectuând resetarea configurării din fabrică."</string>
+ <string name="policylab_wipeData" msgid="3910545446758639713">"Ștergere integrală date"</string>
+ <string name="policydesc_wipeData" product="tablet" msgid="4306184096067756876">"Ștergeţi datele de pe tabletă fără avertisment, efectuând resetarea configurării din fabrică."</string>
+ <string name="policydesc_wipeData" product="default" msgid="5096895604574188391">"Ștergeţi datele din telefon fără avertisment, efectuând resetarea configurării din fabrică."</string>
<string name="policylab_setGlobalProxy" msgid="2784828293747791446">"Setaţi serverul proxy global pentru dispozitiv"</string>
<string name="policydesc_setGlobalProxy" msgid="6387497466660154931">"Setaţi serverul proxy global pentru dispozitiv care să fie utilizat cât timp politica este activă. Numai primul administrator al dispozitivului poate seta serverul proxy global activ."</string>
<string name="policylab_expirePassword" msgid="885279151847254056">"Expirare parolă blocare ecran"</string>
@@ -916,7 +916,7 @@
<string name="search_go" msgid="8298016669822141719">"Căutaţi"</string>
<string name="searchview_description_search" msgid="6749826639098512120">"Căutaţi"</string>
<string name="searchview_description_query" msgid="5911778593125355124">"Interogare de căutare"</string>
- <string name="searchview_description_clear" msgid="1330281990951833033">"Ştergeţi interogarea"</string>
+ <string name="searchview_description_clear" msgid="1330281990951833033">"Ștergeţi interogarea"</string>
<string name="searchview_description_submit" msgid="2688450133297983542">"Trimiteţi interogarea"</string>
<string name="searchview_description_voice" msgid="2453203695674994440">"Căutare vocală"</string>
<string name="enable_explore_by_touch_warning_title" msgid="7460694070309730149">"Activaţi Exploraţi prin atingere?"</string>
@@ -1036,12 +1036,12 @@
<string name="copy" msgid="2681946229533511987">"Copiaţi"</string>
<string name="paste" msgid="5629880836805036433">"Inseraţi"</string>
<string name="replace" msgid="5781686059063148930">"Înlocuiţi..."</string>
- <string name="delete" msgid="6098684844021697789">"Ştergeţi"</string>
+ <string name="delete" msgid="6098684844021697789">"Ștergeţi"</string>
<string name="copyUrl" msgid="2538211579596067402">"Copiaţi adresa URL"</string>
<string name="selectTextMode" msgid="1018691815143165326">"Selectaţi text"</string>
<string name="textSelectionCABTitle" msgid="5236850394370820357">"Selectare text"</string>
<string name="addToDictionary" msgid="4352161534510057874">"Adăugaţi în dicţionar"</string>
- <string name="deleteText" msgid="6979668428458199034">"Ştergeţi"</string>
+ <string name="deleteText" msgid="6979668428458199034">"Ștergeţi"</string>
<string name="inputMethod" msgid="1653630062304567879">"Metodă de intrare"</string>
<string name="editTextMenuTitle" msgid="4909135564941815494">"Acţiuni pentru text"</string>
<string name="low_internal_storage_view_title" msgid="5576272496365684834">"Spaţiul de stocare aproape ocupat"</string>
@@ -1056,7 +1056,7 @@
<string name="capital_off" msgid="6815870386972805832">"DEZACTIVAT"</string>
<string name="whichApplication" msgid="4533185947064773386">"Finalizare acţiune utilizând"</string>
<string name="alwaysUse" msgid="4583018368000610438">"Se utilizează în mod prestabilit pentru această acţiune."</string>
- <string name="clearDefaultHintMsg" msgid="3252584689512077257">"Ştergeţi setările prestabilite din Setări de sistem > Aplicaţii > Descărcate."</string>
+ <string name="clearDefaultHintMsg" msgid="3252584689512077257">"Ștergeţi setările prestabilite din Setări de sistem > Aplicaţii > Descărcate."</string>
<string name="chooseActivity" msgid="7486876147751803333">"Alegeţi o acţiune"</string>
<string name="chooseUsbActivity" msgid="6894748416073583509">"Alegeţi o aplicaţie pentru dispozitivul USB"</string>
<string name="noApplications" msgid="2991814273936504689">"Această acţiune nu poate fi efectuată de nicio aplicaţie."</string>
@@ -1201,7 +1201,7 @@
<string name="adb_active_notification_title" msgid="6729044778949189918">"Depanarea USB este conectată"</string>
<string name="adb_active_notification_message" msgid="1016654627626476142">"Atingeţi pentru a dezactiva depanarea USB."</string>
<string name="select_input_method" msgid="4653387336791222978">"Alegeți metoda de introducere de text"</string>
- <string name="configure_input_methods" msgid="9091652157722495116">"Configurați metode introducere"</string>
+ <string name="configure_input_methods" msgid="9091652157722495116">"Setați metode introducere text"</string>
<string name="use_physical_keyboard" msgid="6203112478095117625">"Tastatură fizică"</string>
<string name="hardware" msgid="7517821086888990278">"Hardware"</string>
<string name="select_keyboard_layout_notification_title" msgid="1407367017263030773">"Selectaţi aspectul tastaturii"</string>
@@ -1317,7 +1317,7 @@
<string name="gpsVerifNo" msgid="1146564937346454865">"Nu"</string>
<string name="sync_too_many_deletes" msgid="5296321850662746890">"Limita pentru ştergere a fost depăşită"</string>
<string name="sync_too_many_deletes_desc" msgid="496551671008694245">"Există <xliff:g id="NUMBER_OF_DELETED_ITEMS">%1$d</xliff:g> (de) elemente şterse pentru <xliff:g id="TYPE_OF_SYNC">%2$s</xliff:g>, contul <xliff:g id="ACCOUNT_NAME">%3$s</xliff:g>. Ce doriţi să faceţi?"</string>
- <string name="sync_really_delete" msgid="2572600103122596243">"Ştergeţi elementele"</string>
+ <string name="sync_really_delete" msgid="2572600103122596243">"Ștergeţi elementele"</string>
<string name="sync_undo_deletes" msgid="2941317360600338602">"Anulaţi aceste ştergeri"</string>
<string name="sync_do_nothing" msgid="3743764740430821845">"Nu trebuie să luaţi nicio măsură deocamdată"</string>
<string name="choose_account_label" msgid="5655203089746423927">"Alegeţi un cont"</string>
@@ -1341,7 +1341,7 @@
<string name="date_picker_decrement_year_button" msgid="4482021813491121717">"Reduceţi valoarea pentru an"</string>
<string name="keyboardview_keycode_alt" msgid="4856868820040051939">"Alt"</string>
<string name="keyboardview_keycode_cancel" msgid="1203984017245783244">"Anulaţi"</string>
- <string name="keyboardview_keycode_delete" msgid="3337914833206635744">"Ştergeţi"</string>
+ <string name="keyboardview_keycode_delete" msgid="3337914833206635744">"Ștergeţi"</string>
<string name="keyboardview_keycode_done" msgid="1992571118466679775">"Terminat"</string>
<string name="keyboardview_keycode_mode_change" msgid="4547387741906537519">"Schimbarea modului"</string>
<string name="keyboardview_keycode_shift" msgid="2270748814315147690">"Shift"</string>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 4a1d12d..badd3d7 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3081,12 +3081,12 @@
<!-- Specifies the formatting pattern used to show the time and/or date
in 12-hour mode. Please refer to {@link android.text.format.DateFormat}
for a complete description of accepted formatting patterns.
- The default pattern is "h:mm aa". -->
+ The default pattern is a locale-appropriate equivalent of "h:mm a". -->
<attr name="format12Hour" format="string"/>
<!-- Specifies the formatting pattern used to show the time and/or date
in 24-hour mode. Please refer to {@link android.text.format.DateFormat}
for a complete description of accepted formatting patterns.
- The default pattern is "k:mm". -->
+ The default pattern is a locale-appropriate equivalent of "H:mm". -->
<attr name="format24Hour" format="string"/>
<!-- Specifies the time zone to use. When this attribute is specified, the
TextClock will ignore the time zone of the system. To use the user's
diff --git a/core/res/res/xml/apns.xml b/core/res/res/xml/apns.xml
index 8c7245c..249b598 100644
--- a/core/res/res/xml/apns.xml
+++ b/core/res/res/xml/apns.xml
@@ -20,6 +20,6 @@
<!-- If you edit this version, also edit the version in the partner-supplied
apns-conf.xml configuration file -->
-<apns version="7">
+<apns version="8">
</apns>
diff --git a/core/tests/coretests/src/android/net/LinkPropertiesTest.java b/core/tests/coretests/src/android/net/LinkPropertiesTest.java
index fffaa00..274ac6b 100644
--- a/core/tests/coretests/src/android/net/LinkPropertiesTest.java
+++ b/core/tests/coretests/src/android/net/LinkPropertiesTest.java
@@ -22,6 +22,7 @@
import junit.framework.TestCase;
import java.net.InetAddress;
+import java.util.ArrayList;
public class LinkPropertiesTest extends TestCase {
private static String ADDRV4 = "75.208.6.1";
@@ -256,4 +257,30 @@
assertEquals(3, lp.compareRoutes(lp2).added.size());
assertEquals(3, lp.compareRoutes(lp2).removed.size());
}
+
+ @SmallTest
+ public void testStackedInterfaces() {
+ LinkProperties rmnet0 = new LinkProperties();
+ rmnet0.setInterfaceName("rmnet0");
+
+ LinkProperties clat4 = new LinkProperties();
+ clat4.setInterfaceName("clat4");
+
+ assertEquals(0, rmnet0.getStackedLinks().size());
+ rmnet0.addStackedLink(clat4);
+ assertEquals(1, rmnet0.getStackedLinks().size());
+ rmnet0.addStackedLink(clat4);
+ assertEquals(1, rmnet0.getStackedLinks().size());
+ assertEquals(0, clat4.getStackedLinks().size());
+
+ // Modify an item in the returned collection to see what happens.
+ for (LinkProperties link : rmnet0.getStackedLinks()) {
+ if (link.getInterfaceName().equals("clat4")) {
+ link.setInterfaceName("newname");
+ }
+ }
+ for (LinkProperties link : rmnet0.getStackedLinks()) {
+ assertFalse("newname".equals(link.getInterfaceName()));
+ }
+ }
}
diff --git a/core/tests/coretests/src/android/os/FileUtilsTest.java b/core/tests/coretests/src/android/os/FileUtilsTest.java
index 4d0b892..0f2b803 100644
--- a/core/tests/coretests/src/android/os/FileUtilsTest.java
+++ b/core/tests/coretests/src/android/os/FileUtilsTest.java
@@ -16,61 +16,65 @@
package android.os;
+import static android.text.format.DateUtils.DAY_IN_MILLIS;
+import static android.text.format.DateUtils.HOUR_IN_MILLIS;
+import static android.text.format.DateUtils.WEEK_IN_MILLIS;
+
import android.content.Context;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
+import com.google.android.collect.Sets;
+
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
+import java.util.Arrays;
+import java.util.HashSet;
+import libcore.io.IoUtils;
+
+@MediumTest
public class FileUtilsTest extends AndroidTestCase {
private static final String TEST_DATA =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ private File mDir;
private File mTestFile;
private File mCopyFile;
@Override
protected void setUp() throws Exception {
super.setUp();
- File testDir = getContext().getDir("testing", Context.MODE_PRIVATE);
- mTestFile = new File(testDir, "test.file");
- mCopyFile = new File(testDir, "copy.file");
- FileWriter writer = new FileWriter(mTestFile);
- try {
- writer.write(TEST_DATA, 0, TEST_DATA.length());
- } finally {
- writer.close();
- }
+ mDir = getContext().getDir("testing", Context.MODE_PRIVATE);
+ mTestFile = new File(mDir, "test.file");
+ mCopyFile = new File(mDir, "copy.file");
}
@Override
protected void tearDown() throws Exception {
- if (mTestFile.exists()) mTestFile.delete();
- if (mCopyFile.exists()) mCopyFile.delete();
+ IoUtils.deleteContents(mDir);
}
// TODO: test setPermissions(), getPermissions()
- @MediumTest
public void testCopyFile() throws Exception {
+ stageFile(mTestFile, TEST_DATA);
assertFalse(mCopyFile.exists());
FileUtils.copyFile(mTestFile, mCopyFile);
assertTrue(mCopyFile.exists());
assertEquals(TEST_DATA, FileUtils.readTextFile(mCopyFile, 0, null));
}
- @MediumTest
public void testCopyToFile() throws Exception {
final String s = "Foo Bar";
assertFalse(mCopyFile.exists());
- FileUtils.copyToFile(new ByteArrayInputStream(s.getBytes()), mCopyFile); assertTrue(mCopyFile.exists());
+ FileUtils.copyToFile(new ByteArrayInputStream(s.getBytes()), mCopyFile);
+ assertTrue(mCopyFile.exists());
assertEquals(s, FileUtils.readTextFile(mCopyFile, 0, null));
}
- @MediumTest
public void testIsFilenameSafe() throws Exception {
assertTrue(FileUtils.isFilenameSafe(new File("foobar")));
assertTrue(FileUtils.isFilenameSafe(new File("a_b-c=d.e/0,1+23")));
@@ -78,8 +82,9 @@
assertFalse(FileUtils.isFilenameSafe(new File("foo\nbar")));
}
- @MediumTest
public void testReadTextFile() throws Exception {
+ stageFile(mTestFile, TEST_DATA);
+
assertEquals(TEST_DATA, FileUtils.readTextFile(mTestFile, 0, null));
assertEquals("ABCDE", FileUtils.readTextFile(mTestFile, 5, null));
@@ -97,8 +102,8 @@
assertEquals(TEST_DATA, FileUtils.readTextFile(mTestFile, -100, "<>"));
}
- @MediumTest
public void testReadTextFileWithZeroLengthFile() throws Exception {
+ stageFile(mTestFile, TEST_DATA);
new FileOutputStream(mTestFile).close(); // Zero out the file
assertEquals("", FileUtils.readTextFile(mTestFile, 0, null));
assertEquals("", FileUtils.readTextFile(mTestFile, 1, "<>"));
@@ -106,4 +111,81 @@
assertEquals("", FileUtils.readTextFile(mTestFile, -1, "<>"));
assertEquals("", FileUtils.readTextFile(mTestFile, -10, "<>"));
}
+
+ public void testDeleteOlderEmptyDir() throws Exception {
+ FileUtils.deleteOlderFiles(mDir, 10, WEEK_IN_MILLIS);
+ assertDirContents();
+ }
+
+ public void testDeleteOlderTypical() throws Exception {
+ touch("file1", HOUR_IN_MILLIS);
+ touch("file2", 1 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ touch("file3", 2 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ touch("file4", 3 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ touch("file5", 4 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ FileUtils.deleteOlderFiles(mDir, 3, DAY_IN_MILLIS);
+ assertDirContents("file1", "file2", "file3");
+ }
+
+ public void testDeleteOlderInFuture() throws Exception {
+ touch("file1", -HOUR_IN_MILLIS);
+ touch("file2", HOUR_IN_MILLIS);
+ touch("file3", WEEK_IN_MILLIS);
+ FileUtils.deleteOlderFiles(mDir, 0, DAY_IN_MILLIS);
+ assertDirContents("file1", "file2");
+
+ touch("file1", -HOUR_IN_MILLIS);
+ touch("file2", HOUR_IN_MILLIS);
+ touch("file3", WEEK_IN_MILLIS);
+ FileUtils.deleteOlderFiles(mDir, 0, DAY_IN_MILLIS);
+ assertDirContents("file1", "file2");
+ }
+
+ public void testDeleteOlderOnlyAge() throws Exception {
+ touch("file1", HOUR_IN_MILLIS);
+ touch("file2", 1 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ touch("file3", 2 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ touch("file4", 3 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ touch("file5", 4 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ FileUtils.deleteOlderFiles(mDir, 0, DAY_IN_MILLIS);
+ assertDirContents("file1");
+ }
+
+ public void testDeleteOlderOnlyCount() throws Exception {
+ touch("file1", HOUR_IN_MILLIS);
+ touch("file2", 1 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ touch("file3", 2 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ touch("file4", 3 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ touch("file5", 4 * DAY_IN_MILLIS + HOUR_IN_MILLIS);
+ FileUtils.deleteOlderFiles(mDir, 2, 0);
+ assertDirContents("file1", "file2");
+ }
+
+ private void touch(String name, long age) throws Exception {
+ final File file = new File(mDir, name);
+ file.createNewFile();
+ file.setLastModified(System.currentTimeMillis() - age);
+ }
+
+ private void stageFile(File file, String data) throws Exception {
+ FileWriter writer = new FileWriter(file);
+ try {
+ writer.write(data, 0, data.length());
+ } finally {
+ writer.close();
+ }
+ }
+
+ private void assertDirContents(String... expected) {
+ final HashSet<String> expectedSet = Sets.newHashSet(expected);
+ String[] actual = mDir.list();
+ if (actual == null) actual = new String[0];
+
+ assertEquals(
+ "Expected " + Arrays.toString(expected) + " but actual " + Arrays.toString(actual),
+ expected.length, actual.length);
+ for (String actualFile : actual) {
+ assertTrue("Unexpected actual file " + actualFile, expectedSet.contains(actualFile));
+ }
+ }
}
diff --git a/core/tests/coretests/src/android/webkit/WebkitTest.java b/core/tests/coretests/src/android/webkit/WebkitTest.java
index 17b4088..4685e3c 100644
--- a/core/tests/coretests/src/android/webkit/WebkitTest.java
+++ b/core/tests/coretests/src/android/webkit/WebkitTest.java
@@ -52,7 +52,7 @@
date.setTime(time);
c.setTime(date);
index = dateSorter.getIndex(time);
- Log.i(LOGTAG, "time: " + DateFormat.format("yyyy/MM/dd kk:mm:ss", c).toString() +
+ Log.i(LOGTAG, "time: " + DateFormat.format("yyyy/MM/dd HH:mm:ss", c).toString() +
" " + index + " " + dateSorter.getLabel(index));
}
}
diff --git a/docs/downloads/training/BitmapFun.zip b/docs/downloads/training/BitmapFun.zip
index 61b537d..48bea78 100644
--- a/docs/downloads/training/BitmapFun.zip
+++ b/docs/downloads/training/BitmapFun.zip
Binary files differ
diff --git a/docs/html/design/building-blocks/buttons.jd b/docs/html/design/building-blocks/buttons.jd
index 82e2477..9e82ed4 100644
--- a/docs/html/design/building-blocks/buttons.jd
+++ b/docs/html/design/building-blocks/buttons.jd
@@ -1,4 +1,5 @@
page.title=Buttons
+page.tags="button"
@jd:body
<p>A button consists of text and/or an image that clearly communicates what action will occur when the
diff --git a/docs/html/design/building-blocks/dialogs.jd b/docs/html/design/building-blocks/dialogs.jd
index a2ece2e..2f6ca27 100644
--- a/docs/html/design/building-blocks/dialogs.jd
+++ b/docs/html/design/building-blocks/dialogs.jd
@@ -1,4 +1,5 @@
page.title=Dialogs
+page.tags="dialog","alert","popup","toast"
@jd:body
<p>Dialogs prompt the user for decisions or additional information required by the app to continue a
diff --git a/docs/html/design/building-blocks/grid-lists.jd b/docs/html/design/building-blocks/grid-lists.jd
index 775ebcc..69a43b1 100644
--- a/docs/html/design/building-blocks/grid-lists.jd
+++ b/docs/html/design/building-blocks/grid-lists.jd
@@ -1,4 +1,5 @@
page.title=Grid Lists
+page.tags="gridview","layout"
@jd:body
<img src="{@docRoot}design/media/gridview_overview.png">
diff --git a/docs/html/design/building-blocks/lists.jd b/docs/html/design/building-blocks/lists.jd
index aaa86b8..16927a6 100644
--- a/docs/html/design/building-blocks/lists.jd
+++ b/docs/html/design/building-blocks/lists.jd
@@ -1,4 +1,5 @@
page.title=Lists
+page.tags="listview","layout"
@jd:body
<p>Lists present multiple line items in a vertical arrangement. They can be used for data selection as
diff --git a/docs/html/design/building-blocks/pickers.jd b/docs/html/design/building-blocks/pickers.jd
index b328df9..47363d0 100644
--- a/docs/html/design/building-blocks/pickers.jd
+++ b/docs/html/design/building-blocks/pickers.jd
@@ -1,4 +1,5 @@
page.title=Pickers
+page.tags="datepicker","timepicker"
@jd:body
<p>Pickers provide a simple way to select a single value from a set. In addition to touching the
diff --git a/docs/html/design/building-blocks/progress.jd b/docs/html/design/building-blocks/progress.jd
index 7342387..96cc1af 100644
--- a/docs/html/design/building-blocks/progress.jd
+++ b/docs/html/design/building-blocks/progress.jd
@@ -1,4 +1,5 @@
page.title=Progress & Activity
+page.tags="progressbar"
@jd:body
<p>Progress bars and activity indicators signal to users that something is happening that will take a moment.</p>
diff --git a/docs/html/design/building-blocks/scrolling.jd b/docs/html/design/building-blocks/scrolling.jd
index 7695157..66999f9 100644
--- a/docs/html/design/building-blocks/scrolling.jd
+++ b/docs/html/design/building-blocks/scrolling.jd
@@ -1,4 +1,5 @@
page.title=Scrolling
+page.tags="scrollview","listview"
@jd:body
<p>Scrolling allows the user to navigate to content in the overflow using a swipe gesture. The
diff --git a/docs/html/design/building-blocks/seek-bars.jd b/docs/html/design/building-blocks/seek-bars.jd
index 3407ddd..9d38e36 100644
--- a/docs/html/design/building-blocks/seek-bars.jd
+++ b/docs/html/design/building-blocks/seek-bars.jd
@@ -1,4 +1,5 @@
page.title=Seek Bars and Sliders
+page.tags="seekbar","progressbar"
@jd:body
<p>Interactive sliders make it possible to select a value from a continuous or discrete range of values
diff --git a/docs/html/design/building-blocks/spinners.jd b/docs/html/design/building-blocks/spinners.jd
index 279565f..8c80b91 100644
--- a/docs/html/design/building-blocks/spinners.jd
+++ b/docs/html/design/building-blocks/spinners.jd
@@ -1,4 +1,5 @@
page.title=Spinners
+page.tags="spinner","drop down"
@jd:body
<p>Spinners provide a quick way to select one value from a set. In the default state, a spinner shows
diff --git a/docs/html/design/building-blocks/switches.jd b/docs/html/design/building-blocks/switches.jd
index d9cfd07..6386bdf 100644
--- a/docs/html/design/building-blocks/switches.jd
+++ b/docs/html/design/building-blocks/switches.jd
@@ -1,4 +1,5 @@
page.title=Switches
+page.tags="switch","checkbox","radiobutton"
@jd:body
<p>Switches allow the user to select options. There are three kinds of switches: checkboxes, radio
diff --git a/docs/html/design/building-blocks/tabs.jd b/docs/html/design/building-blocks/tabs.jd
index 0a0f907..1fe2c62 100644
--- a/docs/html/design/building-blocks/tabs.jd
+++ b/docs/html/design/building-blocks/tabs.jd
@@ -1,4 +1,5 @@
page.title=Tabs
+page.tags="tabs","action bar","navigation"
@jd:body
<img src="{@docRoot}design/media/tabs_overview.png">
diff --git a/docs/html/design/building-blocks/text-fields.jd b/docs/html/design/building-blocks/text-fields.jd
index 563f247..c1bed78 100644
--- a/docs/html/design/building-blocks/text-fields.jd
+++ b/docs/html/design/building-blocks/text-fields.jd
@@ -1,4 +1,5 @@
page.title=Text Fields
+page.tags="text","edittext","input",
@jd:body
<p>Text fields allow the user to type text into your app. They can be either single line or multi-line.
diff --git a/docs/html/design/patterns/accessibility.jd b/docs/html/design/patterns/accessibility.jd
index 2c3333f..edf3843 100644
--- a/docs/html/design/patterns/accessibility.jd
+++ b/docs/html/design/patterns/accessibility.jd
@@ -1,4 +1,5 @@
page.title=Accessibility
+page.tags="accessibility","navigation"
@jd:body
<p>One of Android's missions is to organize the world's information and make it universally accessible and useful. Accessibility is the measure of how successfully a product can be used by people with varying abilities. Our mission applies to all users-including people with disabilities such as visual impairment, color deficiency, hearing loss, and limited dexterity.</p>
diff --git a/docs/html/design/patterns/actionbar.jd b/docs/html/design/patterns/actionbar.jd
index 265ccde..da9c3c3 100644
--- a/docs/html/design/patterns/actionbar.jd
+++ b/docs/html/design/patterns/actionbar.jd
@@ -1,4 +1,5 @@
page.title=Action Bar
+page.tags="actionbar","navigation"
@jd:body
<img src="{@docRoot}design/media/action_bar_pattern_overview.png">
diff --git a/docs/html/design/patterns/app-structure.jd b/docs/html/design/patterns/app-structure.jd
index 04af57b..e1bb819 100644
--- a/docs/html/design/patterns/app-structure.jd
+++ b/docs/html/design/patterns/app-structure.jd
@@ -1,4 +1,5 @@
page.title=Application Structure
+page.tags="navigation","layout"
@jd:body
<p>Apps come in many varieties that address very different needs. For example:</p>
diff --git a/docs/html/design/patterns/confirming-acknowledging.jd b/docs/html/design/patterns/confirming-acknowledging.jd
index ce0631b..f2e88ec 100644
--- a/docs/html/design/patterns/confirming-acknowledging.jd
+++ b/docs/html/design/patterns/confirming-acknowledging.jd
@@ -1,4 +1,5 @@
page.title=Confirming & Acknowledging
+page.tags="dialog","toast"
@jd:body
<p>In some situations, when a user invokes an action in your app, it's a good idea to <em>confirm</em> or <em>acknowledge</em> that action through text.</p>
diff --git a/docs/html/design/patterns/gestures.jd b/docs/html/design/patterns/gestures.jd
index e579cee..3ef133d 100644
--- a/docs/html/design/patterns/gestures.jd
+++ b/docs/html/design/patterns/gestures.jd
@@ -1,4 +1,5 @@
page.title=Gestures
+page.tags="gesture","input"
@jd:body
<p>Gestures allow users to interact with your app by manipulating the screen objects you provide. The
diff --git a/docs/html/design/patterns/multi-pane-layouts.jd b/docs/html/design/patterns/multi-pane-layouts.jd
index e607676..cbf29cb 100644
--- a/docs/html/design/patterns/multi-pane-layouts.jd
+++ b/docs/html/design/patterns/multi-pane-layouts.jd
@@ -1,4 +1,5 @@
page.title=Multi-pane Layouts
+page.tags="tablet","navigation","layout","fragment"
@jd:body
<p>When writing an app for Android, keep in mind that Android devices come in many different screen
diff --git a/docs/html/design/patterns/navigation.jd b/docs/html/design/patterns/navigation.jd
index 656e6e5..36debbe 100644
--- a/docs/html/design/patterns/navigation.jd
+++ b/docs/html/design/patterns/navigation.jd
@@ -1,4 +1,5 @@
page.title=Navigation with Back and Up
+page.tags="navigation","activity"
@jd:body
<p>Consistent navigation is an essential component of the overall user experience. Few things frustrate
diff --git a/docs/html/design/patterns/notifications.jd b/docs/html/design/patterns/notifications.jd
index 0665774..3ae827e 100644
--- a/docs/html/design/patterns/notifications.jd
+++ b/docs/html/design/patterns/notifications.jd
@@ -1,4 +1,5 @@
page.title=Notifications
+page.tags="notification"
@jd:body
<p>The notification system allows your app to keep the user informed about events, such as new chat messages or a calendar event. Think of notifications as a news channel that alerts the user to important events as they happen or a log that chronicles events while the user is not paying attention.</p>
diff --git a/docs/html/design/patterns/selection.jd b/docs/html/design/patterns/selection.jd
index e9d22e6..682ce56 100644
--- a/docs/html/design/patterns/selection.jd
+++ b/docs/html/design/patterns/selection.jd
@@ -1,4 +1,5 @@
page.title=Selection
+page.tags="actionmode","navigation"
@jd:body
<p>Android 3.0 changed the <em>long press</em> gesture—that is, a touch that's held in the same position for a moment—to be the global gesture to select data.. This affects the way you should
diff --git a/docs/html/design/patterns/settings.jd b/docs/html/design/patterns/settings.jd
index fef7585..f86cd39 100644
--- a/docs/html/design/patterns/settings.jd
+++ b/docs/html/design/patterns/settings.jd
@@ -1,4 +1,5 @@
page.title=Settings
+page.tags="settings","preferences"
@jd:body
<p>Settings is a place in your app where users indicate their preferences for how your app should
diff --git a/docs/html/design/patterns/swipe-views.jd b/docs/html/design/patterns/swipe-views.jd
index daddd31..b86d990 100644
--- a/docs/html/design/patterns/swipe-views.jd
+++ b/docs/html/design/patterns/swipe-views.jd
@@ -1,4 +1,5 @@
page.title=Swipe Views
+page.tags="viewpager","navigation"
@jd:body
<p>Efficient navigation is one of the cornerstones of a well-designed app. While apps are generally
diff --git a/docs/html/design/patterns/widgets.jd b/docs/html/design/patterns/widgets.jd
index 54726b1..a5979ce 100644
--- a/docs/html/design/patterns/widgets.jd
+++ b/docs/html/design/patterns/widgets.jd
@@ -1,4 +1,5 @@
page.title=Widgets
+page.tags="appwidget"
@jd:body
<p>Widgets are an essential aspect of home screen customization. You can imagine them as "at-a-glance" views of an app's most important data and functionality that is accessible right from the user's home screen. Users can move widgets across their home screen panels, and, if supported, resize them to tailor the amount of information within a widget to their preference.</p>
diff --git a/docs/html/guide/components/activities.jd b/docs/html/guide/components/activities.jd
index 2897804..1cbaa79 100644
--- a/docs/html/guide/components/activities.jd
+++ b/docs/html/guide/components/activities.jd
@@ -1,4 +1,5 @@
page.title=Activities
+page.tags="activity","intent"
@jd:body
<div id="qv-wrapper">
diff --git a/docs/html/guide/topics/graphics/hardware-accel.jd b/docs/html/guide/topics/graphics/hardware-accel.jd
index 01dd79a..9859c28 100644
--- a/docs/html/guide/topics/graphics/hardware-accel.jd
+++ b/docs/html/guide/topics/graphics/hardware-accel.jd
@@ -512,6 +512,13 @@
<td class="s7">✗</td>
<td class="s11">✗</td>
</tr>
+ <tr>
+ <td class="s10">Local matrix on ComposeShader</td>
+ <td class="s7">✗</td>
+ <td class="s11">✗</td>
+ <td class="s7">✗</td>
+ <td class="s11">✓</td>
+ </tr>
</tbody>
</table>
diff --git a/docs/html/guide/topics/manifest/data-element.jd b/docs/html/guide/topics/manifest/data-element.jd
index 8fd91de..766d2d7 100644
--- a/docs/html/guide/topics/manifest/data-element.jd
+++ b/docs/html/guide/topics/manifest/data-element.jd
@@ -85,6 +85,9 @@
The subtype can be the asterisk wildcard ({@code *}) to indicate that any
subtype matches.
+<p>It's common for an intent filter to declare a {@code <data>} that includes
+only the {@code android:mimeType} attribute.</p>
+
<p class="note">Note: MIME type matching in the Android framework is
case-sensitive, unlike formal RFC MIME types. As a result, you should always
specify MIME types using lowercase letters.</p>
diff --git a/docs/html/guide/topics/ui/actionbar.jd b/docs/html/guide/topics/ui/actionbar.jd
index 3115c8f..678a512 100644
--- a/docs/html/guide/topics/ui/actionbar.jd
+++ b/docs/html/guide/topics/ui/actionbar.jd
@@ -1,4 +1,5 @@
page.title=Action Bar
+page.tags="action bar","menu"
parent.title=User Interface
parent.link=index.html
@jd:body
diff --git a/docs/html/guide/topics/ui/binding.jd b/docs/html/guide/topics/ui/binding.jd
index e8b49d5..a4fd25c 100644
--- a/docs/html/guide/topics/ui/binding.jd
+++ b/docs/html/guide/topics/ui/binding.jd
@@ -10,13 +10,6 @@
<li><a href="#FillingTheLayout">Filling the Layout with Data</a></li>
<li><a href="#HandlingUserSelections">Handling User Selections</a></li>
</ol>
-
- <h2>Related tutorials</h2>
- <ol>
- <li><a href="{@docRoot}resources/tutorials/views/hello-spinner.html">Spinner</a></li>
- <li><a href="{@docRoot}resources/tutorials/views/hello-listview.html">List View</a></li>
- <li><a href="{@docRoot}resources/tutorials/views/hello-gridview.html">Grid View</a></li>
- </ol>
</div>
</div>
@@ -81,8 +74,8 @@
</pre>
<div class="special">
-<p>For more discussion on how to create different AdapterViews, read the following tutorials:
-<a href="{@docRoot}resources/tutorials/views/hello-spinner.html">Hello Spinner</a>,
-<a href="{@docRoot}resources/tutorials/views/hello-listview.html">Hello ListView</a>, and
-<a href="{@docRoot}resources/tutorials/views/hello-gridview.html">Hello GridView</a>.
+<p>For more discussion on how to create different AdapterViews, read the following guides:
+<a href="{@docRoot}guide/topics/ui/controls/spinner.html">Spinner</a>,
+<a href="{@docRoot}guide/topics/ui/layout/listview.html">List View</a>, and
+<a href="{@docRoot}guide/topics/ui/layout/gridview.html">Grid View</a>.
</div>
diff --git a/docs/html/guide/topics/ui/ui-events.jd b/docs/html/guide/topics/ui/ui-events.jd
index 707d4b1..6d41b15 100644
--- a/docs/html/guide/topics/ui/ui-events.jd
+++ b/docs/html/guide/topics/ui/ui-events.jd
@@ -13,10 +13,6 @@
<li><a href="#HandlingFocus">Handling Focus</a></li>
</ol>
- <h2>Related tutorials</h2>
- <ol>
- <li><a href="{@docRoot}resources/tutorials/views/hello-formstuff.html">Form Stuff</a></li>
- </ol>
</div>
</div>
diff --git a/docs/html/guide/webapps/webview.jd b/docs/html/guide/webapps/webview.jd
index d2b2532..c87be06 100644
--- a/docs/html/guide/webapps/webview.jd
+++ b/docs/html/guide/webapps/webview.jd
@@ -33,11 +33,6 @@
<li>{@link android.webkit.WebViewClient}</li>
</ol>
-<h2>Related tutorials</h2>
-<ol>
- <li><a href="{@docRoot}resources/tutorials/views/hello-webview.html">Web View</a></li>
-</ol>
-
</div>
</div>
diff --git a/docs/html/training/animation/index.jd b/docs/html/training/animation/index.jd
index 9cc7e6c..b2815fc 100644
--- a/docs/html/training/animation/index.jd
+++ b/docs/html/training/animation/index.jd
@@ -1,4 +1,5 @@
page.title=Adding Animations
+page.tags="animation","views","layout","user interface"
trainingnavtop=true
startpage=true
diff --git a/docs/html/training/basics/data-storage/databases.jd b/docs/html/training/basics/data-storage/databases.jd
index 8b11983..9976bb1 100644
--- a/docs/html/training/basics/data-storage/databases.jd
+++ b/docs/html/training/basics/data-storage/databases.jd
@@ -1,6 +1,4 @@
page.title=Saving Data in SQL Databases
-parent.title=Data Storage
-parent.link=index.html
trainingnavtop=true
previous.title=Saving Data in Files
diff --git a/docs/html/training/basics/data-storage/files.jd b/docs/html/training/basics/data-storage/files.jd
index dd081a6..52bea4c 100644
--- a/docs/html/training/basics/data-storage/files.jd
+++ b/docs/html/training/basics/data-storage/files.jd
@@ -1,6 +1,4 @@
page.title=Saving Files
-parent.title=Data Storage
-parent.link=index.html
trainingnavtop=true
diff --git a/docs/html/training/basics/data-storage/index.jd b/docs/html/training/basics/data-storage/index.jd
index 4334936..4ccad75 100644
--- a/docs/html/training/basics/data-storage/index.jd
+++ b/docs/html/training/basics/data-storage/index.jd
@@ -1,4 +1,5 @@
page.title=Saving Data
+page.tags="data storage","files","sql","database","preferences"
trainingnavtop=true
startpage=true
diff --git a/docs/html/training/basics/data-storage/shared-preferences.jd b/docs/html/training/basics/data-storage/shared-preferences.jd
index 099da67..a6717c4 100644
--- a/docs/html/training/basics/data-storage/shared-preferences.jd
+++ b/docs/html/training/basics/data-storage/shared-preferences.jd
@@ -1,6 +1,4 @@
page.title=Saving Key-Value Sets
-parent.title=Data Storage
-parent.link=index.html
trainingnavtop=true
diff --git a/docs/html/training/basics/fragments/communicating.jd b/docs/html/training/basics/fragments/communicating.jd
index eb9b368..b30045d 100644
--- a/docs/html/training/basics/fragments/communicating.jd
+++ b/docs/html/training/basics/fragments/communicating.jd
@@ -1,10 +1,6 @@
page.title=Communicating with Other Fragments
-parent.title=Building a Dynamic UI with Fragments
-parent.link=index.html
trainingnavtop=true
-previous.title=Building a Flexible UI
-previous.link=fragment-ui.html
@jd:body
diff --git a/docs/html/training/basics/fragments/creating.jd b/docs/html/training/basics/fragments/creating.jd
index 0646230..b5df4e1 100644
--- a/docs/html/training/basics/fragments/creating.jd
+++ b/docs/html/training/basics/fragments/creating.jd
@@ -1,12 +1,6 @@
page.title=Creating a Fragment
-parent.title=Building a Dynamic UI with Fragments
-parent.link=index.html
trainingnavtop=true
-previous.title=Using the Android Support Library
-previous.link=support-lib.html
-next.title=Building a Flexible UI
-next.link=fragment-ui.html
@jd:body
diff --git a/docs/html/training/basics/fragments/fragment-ui.jd b/docs/html/training/basics/fragments/fragment-ui.jd
index 4ec4de5..d648938 100644
--- a/docs/html/training/basics/fragments/fragment-ui.jd
+++ b/docs/html/training/basics/fragments/fragment-ui.jd
@@ -1,12 +1,6 @@
page.title=Building a Flexible UI
-parent.title=Building a Dynamic UI with Fragments
-parent.link=index.html
trainingnavtop=true
-previous.title=Create a Fragment
-previous.link=creating.html
-next.title=Communicating with Other Fragments
-next.link=communicating.html
@jd:body
diff --git a/docs/html/training/basics/fragments/index.jd b/docs/html/training/basics/fragments/index.jd
index bc93f43..1b82f2c 100644
--- a/docs/html/training/basics/fragments/index.jd
+++ b/docs/html/training/basics/fragments/index.jd
@@ -1,9 +1,8 @@
page.title=Building a Dynamic UI with Fragments
+page.tags="fragments", "user interface", "support library"
trainingnavtop=true
startpage=true
-next.title=Using the Android Support Library
-next.link=support-lib.html
@jd:body
diff --git a/docs/html/training/basics/fragments/support-lib.jd b/docs/html/training/basics/fragments/support-lib.jd
index cc867d3..b097de1 100644
--- a/docs/html/training/basics/fragments/support-lib.jd
+++ b/docs/html/training/basics/fragments/support-lib.jd
@@ -1,10 +1,7 @@
page.title=Using the Support Library
-parent.title=Building a Dynamic UI with Fragments
-parent.link=index.html
+page.tags="support library"
trainingnavtop=true
-next.title=Creating a Fragment
-next.link=creating.html
@jd:body
diff --git a/docs/html/training/basics/intents/index.jd b/docs/html/training/basics/intents/index.jd
index d94ff015..8876a33 100644
--- a/docs/html/training/basics/intents/index.jd
+++ b/docs/html/training/basics/intents/index.jd
@@ -1,9 +1,8 @@
page.title=Interacting with Other Apps
+page.tags="intents","activity"
trainingnavtop=true
startpage=true
-next.title=Sending the User to Another App
-next.link=sending.html
@jd:body
diff --git a/docs/html/training/basics/network-ops/index.jd b/docs/html/training/basics/network-ops/index.jd
index b213c03..cb3a390 100644
--- a/docs/html/training/basics/network-ops/index.jd
+++ b/docs/html/training/basics/network-ops/index.jd
@@ -1,4 +1,5 @@
page.title=Performing Network Operations
+page.tags="network","wireless"
trainingnavtop=true
startpage=true
diff --git a/docs/html/training/basics/supporting-devices/index.jd b/docs/html/training/basics/supporting-devices/index.jd
index 49ea81d..1e3eb42 100644
--- a/docs/html/training/basics/supporting-devices/index.jd
+++ b/docs/html/training/basics/supporting-devices/index.jd
@@ -1,9 +1,8 @@
page.title=Supporting Different Devices
+page.tags="resources","screens","versions","localization"
trainingnavtop=true
startpage=true
-next.title=Supporting Multiple Languages
-next.link=languages.html
@jd:body
diff --git a/docs/html/training/camera/index.jd b/docs/html/training/camera/index.jd
index 282bed8..fa754a0 100644
--- a/docs/html/training/camera/index.jd
+++ b/docs/html/training/camera/index.jd
@@ -1,4 +1,5 @@
page.title=Capturing Photos
+page.tags="camera","video"
trainingnavtop=true
startpage=true
diff --git a/docs/html/training/cloudsync/index.jd b/docs/html/training/cloudsync/index.jd
index 91885e8..55b275b 100644
--- a/docs/html/training/cloudsync/index.jd
+++ b/docs/html/training/cloudsync/index.jd
@@ -1,9 +1,8 @@
page.title=Syncing to the Cloud
+page.tags="cloud","sync","backup"
trainingnavtop=true
startpage=true
-next.title=Making the Most of Google Cloud Messaging
-next.link=gcm.html
@jd:body
diff --git a/docs/html/training/connect-devices-wirelessly/index.jd b/docs/html/training/connect-devices-wirelessly/index.jd
index 37cf633..f27b9c3 100644
--- a/docs/html/training/connect-devices-wirelessly/index.jd
+++ b/docs/html/training/connect-devices-wirelessly/index.jd
@@ -1,9 +1,8 @@
page.title=Connecting Devices Wirelessly
+page.tags="wifi","network","wireless"
trainingnavtop=true
startpage=true
-next.title=Using Network Service Discovery
-next.link=nsd.html
@jd:body
diff --git a/docs/html/training/displaying-bitmaps/cache-bitmap.jd b/docs/html/training/displaying-bitmaps/cache-bitmap.jd
index 417ec5b..b1608c3 100644
--- a/docs/html/training/displaying-bitmaps/cache-bitmap.jd
+++ b/docs/html/training/displaying-bitmaps/cache-bitmap.jd
@@ -3,10 +3,6 @@
parent.link=index.html
trainingnavtop=true
-next.title=Displaying Bitmaps in Your UI
-next.link=display-bitmap.html
-previous.title=Processing Bitmaps Off the UI Thread
-previous.link=process-bitmap.html
@jd:body
diff --git a/docs/html/training/displaying-bitmaps/display-bitmap.jd b/docs/html/training/displaying-bitmaps/display-bitmap.jd
index 4572c42..ed1836c 100644
--- a/docs/html/training/displaying-bitmaps/display-bitmap.jd
+++ b/docs/html/training/displaying-bitmaps/display-bitmap.jd
@@ -3,8 +3,6 @@
parent.link=index.html
trainingnavtop=true
-previous.title=Caching Bitmaps
-previous.link=cache-bitmap.html
@jd:body
diff --git a/docs/html/training/displaying-bitmaps/index.jd b/docs/html/training/displaying-bitmaps/index.jd
index b91172b..857edee 100644
--- a/docs/html/training/displaying-bitmaps/index.jd
+++ b/docs/html/training/displaying-bitmaps/index.jd
@@ -1,9 +1,8 @@
page.title=Displaying Bitmaps Efficiently
+page.tags="bitmaps","images","graphics"
trainingnavtop=true
startpage=true
-next.title=Loading Large Bitmaps Efficiently
-next.link=load-bitmap.html
@jd:body
@@ -26,7 +25,7 @@
</div>
</div>
-<p>This class covers some common techniques for processing and loading {@link
+<p>Learn how to use common techniques to process and load {@link
android.graphics.Bitmap} objects in a way that keeps your user interface (UI) components responsive
and avoids exceeding your application memory limit. If you're not careful, bitmaps can quickly
consume your available memory budget leading to an application crash due to the dreaded
@@ -70,6 +69,9 @@
<dd>This lesson walks you through using a memory and disk bitmap cache to improve the
responsiveness and fluidity of your UI when loading multiple bitmaps.</dd>
+ <dt><b><a href="manage-memory.html">Managing Bitmap Memory</a></b></dt>
+ <dd>This lesson explains how to manage bitmap memory to maximize your app's performance.</dd>
+
<dt><b><a href="display-bitmap.html">Displaying Bitmaps in Your UI</a></b></dt>
<dd>This lesson brings everything together, showing you how to load multiple bitmaps into
components like {@link android.support.v4.view.ViewPager} and {@link android.widget.GridView}
diff --git a/docs/html/training/displaying-bitmaps/load-bitmap.jd b/docs/html/training/displaying-bitmaps/load-bitmap.jd
index 283f272..633ffd2 100644
--- a/docs/html/training/displaying-bitmaps/load-bitmap.jd
+++ b/docs/html/training/displaying-bitmaps/load-bitmap.jd
@@ -3,8 +3,6 @@
parent.link=index.html
trainingnavtop=true
-next.title=Processing Bitmaps Off the UI Thread
-next.link=process-bitmap.html
@jd:body
@@ -167,4 +165,4 @@
<p>You can follow a similar process to decode bitmaps from other sources, by substituting the
appropriate {@link
android.graphics.BitmapFactory#decodeByteArray(byte[],int,int,android.graphics.BitmapFactory.Options)
-BitmapFactory.decode*} method as needed.</p>
\ No newline at end of file
+BitmapFactory.decode*} method as needed.</p>
diff --git a/docs/html/training/displaying-bitmaps/manage-memory.jd b/docs/html/training/displaying-bitmaps/manage-memory.jd
new file mode 100644
index 0000000..60ac2e6
--- /dev/null
+++ b/docs/html/training/displaying-bitmaps/manage-memory.jd
@@ -0,0 +1,297 @@
+page.title=Managing Bitmap Memory
+parent.title=Displaying Bitmaps Efficiently
+parent.link=index.html
+
+trainingnavtop=true
+
+@jd:body
+
+<div id="tb-wrapper">
+<div id="tb">
+
+<h2>This lesson teaches you to</h2>
+<ol>
+ <li><a href="#recycle">Manage Memory on Android 2.3.3 and Lower</a></li>
+ <li><a href="#inBitmap">Manage Memory on Android 3.0 and Higher</a></li>
+</ol>
+
+<h2>You should also read</h2>
+<ul>
+ <li><a href="http://android-developers.blogspot.com/2011/03/memory-analysis-for-android.html">Memory Analysis for Android Applications</a> blog post</li>
+ <li><a href="http://www.google.com/events/io/2011/sessions/memory-management-for-android-apps.html">Memory management for Android Apps</a> Google I/O presentation</li>
+ <li><a href="{@docRoot}design/patterns/swipe-views.html">Android Design: Swipe Views</a></li>
+ <li><a href="{@docRoot}design/building-blocks/grid-lists.html">Android Design: Grid Lists</a></li>
+</ul>
+
+<h2>Try it out</h2>
+
+<div class="download-box">
+ <a href="{@docRoot}shareables/training/BitmapFun.zip" class="button">Download the sample</a>
+ <p class="filename">BitmapFun.zip</p>
+</div>
+
+</div>
+</div>
+
+<p>In addition to the steps described in <a href="cache-bitmap.html">Caching Bitmaps</a>,
+there are specific things you can do to facilitate garbage collection
+and bitmap reuse. The recommended strategy depends on which version(s)
+of Android you are targeting. The {@code BitmapFun} sample app included with
+this class shows you how to design your app to work efficiently across
+different versions of Android.</p>
+
+<p>To set the stage for this lesson, here is how Android's management of
+bitmap memory has evolved:</p>
+<ul>
+ <li>
+On Android Android 2.2 (API level 8) and lower, when garbage
+collection occurs, your app's threads get stopped. This causes a lag that
+can degrade performance.
+<strong>Android 2.3 adds concurrent garbage collection, which means that
+the memory is reclaimed soon after a bitmap is no longer referenced.</strong>
+</li>
+
+ <li>On Android 2.3.3 (API level 10) and lower, the backing pixel data for a
+bitmap is stored in native memory. It is separate from the bitmap itself,
+which is stored in the Dalvik heap. The pixel data in native memory is
+not released in a predictable manner, potentially causing an application
+to briefly exceed its memory limits and crash.
+<strong>As of Android 3.0 (API Level 11), the pixel data is stored on the
+Dalvik heap along with the associated bitmap.</strong></li>
+
+</ul>
+
+<p>The following sections describe how to optimize bitmap memory
+management for different Android versions.</p>
+
+<h2 id="recycle">Manage Memory on Android 2.3.3 and Lower</h2>
+
+<p>On Android 2.3.3 (API level 10) and lower, using
+{@link android.graphics.Bitmap#recycle recycle()}
+is recommended. If you're displaying large amounts of bitmap data in your app,
+you're likely to run into
+{@link java.lang.OutOfMemoryError} errors. The
+{@link android.graphics.Bitmap#recycle recycle()} method allows an app
+to reclaim memory as soon as possible.</p>
+
+<p class="note"><strong>Caution:</strong> You should use
+{@link android.graphics.Bitmap#recycle recycle()} only when you are sure that the
+bitmap is no longer being used. If you call {@link android.graphics.Bitmap#recycle recycle()}
+and later attempt to draw the bitmap, you will get the error:
+{@code "Canvas: trying to use a recycled bitmap"}.</p>
+
+<p>The following code snippet gives an example of calling
+{@link android.graphics.Bitmap#recycle recycle()}. It uses reference counting
+(in the variables {@code mDisplayRefCount} and {@code mCacheRefCount}) to track
+whether a bitmap is currently being displayed or in the cache. The
+code recycles the bitmap when these conditions are met:</p>
+
+<ul>
+<li>The reference count for both {@code mDisplayRefCount} and
+{@code mCacheRefCount} is 0.</li>
+<li>The bitmap is not {@code null}, and it hasn't been recycled yet.</li>
+</ul>
+
+<pre>private int mCacheRefCount = 0;
+private int mDisplayRefCount = 0;
+...
+// Notify the drawable that the displayed state has changed.
+// Keep a count to determine when the drawable is no longer displayed.
+public void setIsDisplayed(boolean isDisplayed) {
+ synchronized (this) {
+ if (isDisplayed) {
+ mDisplayRefCount++;
+ mHasBeenDisplayed = true;
+ } else {
+ mDisplayRefCount--;
+ }
+ }
+ // Check to see if recycle() can be called.
+ checkState();
+}
+
+// Notify the drawable that the cache state has changed.
+// Keep a count to determine when the drawable is no longer being cached.
+public void setIsCached(boolean isCached) {
+ synchronized (this) {
+ if (isCached) {
+ mCacheRefCount++;
+ } else {
+ mCacheRefCount--;
+ }
+ }
+ // Check to see if recycle() can be called.
+ checkState();
+}
+
+private synchronized void checkState() {
+ // If the drawable cache and display ref counts = 0, and this drawable
+ // has been displayed, then recycle.
+ if (mCacheRefCount <= 0 && mDisplayRefCount <= 0 && mHasBeenDisplayed
+ && hasValidBitmap()) {
+ getBitmap().recycle();
+ }
+}
+
+private synchronized boolean hasValidBitmap() {
+ Bitmap bitmap = getBitmap();
+ return bitmap != null && !bitmap.isRecycled();
+}</pre>
+
+<h2 id="inBitmap">Manage Memory on Android 3.0 and Higher</h2>
+
+<p>Android 3.0 (API Level 11) introduces the
+{@link android.graphics.BitmapFactory.Options#inBitmap BitmapFactory.Options.inBitmap}
+field. If this option is set, decode methods that take the
+{@link android.graphics.BitmapFactory.Options Options} object
+will attempt to reuse an existing bitmap when loading content. This means
+that the bitmap's memory is reused, resulting in improved performance, and
+removing both memory allocation and de-allocation. There are some caveats in using
+{@link android.graphics.BitmapFactory.Options#inBitmap}:</p>
+<ul>
+ <li>The reused bitmap must be of the same size as the source content (to make
+sure that the same amount of memory is used), and in JPEG or PNG format
+(whether as a resource or as a stream).</li>
+
+
+<li>The {@link android.graphics.Bitmap.Config configuration} of the reused bitmap
+overrides the setting of
+{@link android.graphics.BitmapFactory.Options#inPreferredConfig}, if set. </li>
+
+ <li>You should always use the returned bitmap of the decode method,
+because you can't assume that reusing the bitmap worked (for example, if there is
+a size mismatch).</li>
+
+<h3>Save a bitmap for later use</h3>
+
+<p>The following snippet demonstrates how an existing bitmap is stored for possible
+later use in the sample app. When an app is running on Android 3.0 or higher and
+a bitmap is evicted from the {@link android.util.LruCache},
+a soft reference to the bitmap is placed
+in a {@link java.util.HashSet}, for possible reuse later with
+{@link android.graphics.BitmapFactory.Options#inBitmap}:
+
+<pre>HashSet<SoftReference<Bitmap>> mReusableBitmaps;
+private LruCache<String, BitmapDrawable> mMemoryCache;
+
+// If you're running on Honeycomb or newer, create
+// a HashSet of references to reusable bitmaps.
+if (Utils.hasHoneycomb()) {
+ mReusableBitmaps = new HashSet<SoftReference<Bitmap>>();
+}
+
+mMemoryCache = new LruCache<String, BitmapDrawable>(mCacheParams.memCacheSize) {
+
+ // Notify the removed entry that is no longer being cached.
+ @Override
+ protected void entryRemoved(boolean evicted, String key,
+ BitmapDrawable oldValue, BitmapDrawable newValue) {
+ if (RecyclingBitmapDrawable.class.isInstance(oldValue)) {
+ // The removed entry is a recycling drawable, so notify it
+ // that it has been removed from the memory cache.
+ ((RecyclingBitmapDrawable) oldValue).setIsCached(false);
+ } else {
+ // The removed entry is a standard BitmapDrawable.
+ if (Utils.hasHoneycomb()) {
+ // We're running on Honeycomb or later, so add the bitmap
+ // to a SoftReference set for possible use with inBitmap later.
+ mReusableBitmaps.add
+ (new SoftReference<Bitmap>(oldValue.getBitmap()));
+ }
+ }
+ }
+....
+}</pre>
+
+
+<h3>Use an existing bitmap</h3>
+<p>In the running app, decoder methods check to see if there is an existing
+bitmap they can use. For example:</p>
+
+<pre>public static Bitmap decodeSampledBitmapFromFile(String filename,
+ int reqWidth, int reqHeight, ImageCache cache) {
+
+ final BitmapFactory.Options options = new BitmapFactory.Options();
+ ...
+ BitmapFactory.decodeFile(filename, options);
+ ...
+
+ // If we're running on Honeycomb or newer, try to use inBitmap.
+ if (Utils.hasHoneycomb()) {
+ addInBitmapOptions(options, cache);
+ }
+ ...
+ return BitmapFactory.decodeFile(filename, options);
+}</pre
+
+<p>The next snippet shows the {@code addInBitmapOptions()} method that is called in the
+above snippet. It looks for an existing bitmap to set as the value for
+{@link android.graphics.BitmapFactory.Options#inBitmap}. Note that this
+method only sets a value for {@link android.graphics.BitmapFactory.Options#inBitmap}
+if it finds a suitable match (your code should never assume that a match will be found):</p>
+
+<pre>private static void addInBitmapOptions(BitmapFactory.Options options,
+ ImageCache cache) {
+ // inBitmap only works with mutable bitmaps, so force the decoder to
+ // return mutable bitmaps.
+ options.inMutable = true;
+
+ if (cache != null) {
+ // Try to find a bitmap to use for inBitmap.
+ Bitmap inBitmap = cache.getBitmapFromReusableSet(options);
+
+ if (inBitmap != null) {
+ // If a suitable bitmap has been found, set it as the value of
+ // inBitmap.
+ options.inBitmap = inBitmap;
+ }
+ }
+}
+
+// This method iterates through the reusable bitmaps, looking for one
+// to use for inBitmap:
+protected Bitmap getBitmapFromReusableSet(BitmapFactory.Options options) {
+ Bitmap bitmap = null;
+
+ if (mReusableBitmaps != null && !mReusableBitmaps.isEmpty()) {
+ final Iterator<SoftReference<Bitmap>> iterator
+ = mReusableBitmaps.iterator();
+ Bitmap item;
+
+ while (iterator.hasNext()) {
+ item = iterator.next().get();
+
+ if (null != item && item.isMutable()) {
+ // Check to see it the item can be used for inBitmap.
+ if (canUseForInBitmap(item, options)) {
+ bitmap = item;
+
+ // Remove from reusable set so it can't be used again.
+ iterator.remove();
+ break;
+ }
+ } else {
+ // Remove from the set if the reference has been cleared.
+ iterator.remove();
+ }
+ }
+ }
+ return bitmap;
+}</pre>
+
+<p>Finally, this method determines whether a candidate bitmap
+satisfies the size criteria to be used for
+{@link android.graphics.BitmapFactory.Options#inBitmap}:</p>
+
+<pre>private static boolean canUseForInBitmap(
+ Bitmap candidate, BitmapFactory.Options targetOptions) {
+ int width = targetOptions.outWidth / targetOptions.inSampleSize;
+ int height = targetOptions.outHeight / targetOptions.inSampleSize;
+
+ // Returns true if "candidate" can be used for inBitmap re-use with
+ // "targetOptions".
+ return candidate.getWidth() == width && candidate.getHeight() == height;
+}</pre>
+
+</body>
+</html>
diff --git a/docs/html/training/displaying-bitmaps/process-bitmap.jd b/docs/html/training/displaying-bitmaps/process-bitmap.jd
index d4fcff3..272b8bc 100644
--- a/docs/html/training/displaying-bitmaps/process-bitmap.jd
+++ b/docs/html/training/displaying-bitmaps/process-bitmap.jd
@@ -3,10 +3,6 @@
parent.link=index.html
trainingnavtop=true
-next.title=Caching Bitmaps
-next.link=cache-bitmap.html
-previous.title=Loading Large Bitmaps Efficiently
-previous.link=load-bitmap.html
@jd:body
diff --git a/docs/html/training/efficient-downloads/index.jd b/docs/html/training/efficient-downloads/index.jd
index a29be91..2ab93ae 100644
--- a/docs/html/training/efficient-downloads/index.jd
+++ b/docs/html/training/efficient-downloads/index.jd
@@ -1,9 +1,8 @@
page.title=Transferring Data Without Draining the Battery
+page.tags="battery","network","wireless"
trainingnavtop=true
startpage=true
-next.title=Optimizing Downloads for Efficient Network Access
-next.link=efficient-network-access.html
@jd:body
diff --git a/docs/html/training/graphics/opengl/index.jd b/docs/html/training/graphics/opengl/index.jd
index 23a734a..cf33d80 100644
--- a/docs/html/training/graphics/opengl/index.jd
+++ b/docs/html/training/graphics/opengl/index.jd
@@ -1,7 +1,6 @@
page.title=Displaying Graphics with OpenGL ES
+page=tags="open gl","graphics"
trainingnavtop=true
-next.title=Building an OpenGL ES Environment
-next.link=environment.html
@jd:body
diff --git a/docs/html/training/implementing-navigation/lateral.jd b/docs/html/training/implementing-navigation/lateral.jd
index 9a31d7a..c8f57a2 100644
--- a/docs/html/training/implementing-navigation/lateral.jd
+++ b/docs/html/training/implementing-navigation/lateral.jd
@@ -43,7 +43,8 @@
<p>Tabs allow the user to navigate between sibling screens by selecting the appropriate tab indicator available at the top of the display. In Android 3.0 and later, tabs are implemented using the {@link android.app.ActionBar} class, and are generally set up in {@link android.app.Activity#onCreate Activity.onCreate()}. In some cases, such as when horizontal space is limited and/or the number of tabs is large, an appropriate alternate presentation for tabs is a dropdown list (sometimes implemented using a {@link android.widget.Spinner}).</p>
-<p>In previous versions of Android, tabs could be implemented using a {@link android.widget.TabWidget} and {@link android.widget.TabHost}. For details, see the <a href="{@docRoot}resources/tutorials/views/hello-tabwidget.html">Hello, Views</a> tutorial.</p>
+<p>In previous versions of Android, tabs could be implemented using a
+{@link android.widget.TabWidget} and {@link android.widget.TabHost}.</p>
<p>As of Android 3.0, however, you should use either {@link android.app.ActionBar#NAVIGATION_MODE_TABS} or {@link android.app.ActionBar#NAVIGATION_MODE_LIST} along with the {@link android.app.ActionBar} class.</p>
diff --git a/docs/html/training/managing-audio/index.jd b/docs/html/training/managing-audio/index.jd
index 0f7bbfd..3e3bcf0 100644
--- a/docs/html/training/managing-audio/index.jd
+++ b/docs/html/training/managing-audio/index.jd
@@ -1,9 +1,8 @@
page.title=Managing Audio Playback
+page.tags="audio","media"
trainingnavtop=true
startpage=true
-next.title=Controlling Your App's Volume and Playback
-next.link=volume-playback.html
@jd:body
diff --git a/docs/html/training/sharing/index.jd b/docs/html/training/sharing/index.jd
index c2e8dbc..2aa22b6 100644
--- a/docs/html/training/sharing/index.jd
+++ b/docs/html/training/sharing/index.jd
@@ -1,9 +1,8 @@
page.title=Sharing Content
+page.tags="intents","share"
trainingnavtop=true
startpage=true
-next.title=Sending Content to Other Apps
-next.link=send.html
@jd:body
diff --git a/docs/html/training/training_toc.cs b/docs/html/training/training_toc.cs
index 79980be..985fc44 100644
--- a/docs/html/training/training_toc.cs
+++ b/docs/html/training/training_toc.cs
@@ -287,6 +287,10 @@
Caching Bitmaps
</a>
</li>
+ <li><a href="<?cs var:toroot ?>training/displaying-bitmaps/manage-memory.html">
+ Managing Bitmap Memory
+ </a>
+ </li>
<li><a href="<?cs var:toroot ?>training/displaying-bitmaps/display-bitmap.html">
Displaying Bitmaps in Your UI
</a></li>
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 9bb90f1..cc7f23f 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -62,6 +62,18 @@
@SuppressWarnings({"UnusedDeclaration"})
private int mSurfaceFormat;
+ /**
+ * Flag for drawTextRun indicating left-to-right run direction.
+ * @hide
+ */
+ public static final int DIRECTION_LTR = 0;
+
+ /**
+ * Flag for drawTextRun indicating right-to-left run direction.
+ * @hide
+ */
+ public static final int DIRECTION_RTL = 1;
+
// Maximum bitmap size as defined in Skia's native code
// (see SkCanvas.cpp, SkDraw.cpp)
private static final int MAXMIMUM_BITMAP_SIZE = 32766;
@@ -683,8 +695,16 @@
}
public enum EdgeType {
+
+ /**
+ * Black-and-White: Treat edges by just rounding to nearest pixel boundary
+ */
BW(0), //!< treat edges by just rounding to nearest pixel boundary
- AA(1); //!< treat edges by rounding-out, since they may be antialiased
+
+ /**
+ * Antialiased: Treat edges by rounding-out, since they may be antialiased
+ */
+ AA(1);
EdgeType(int nativeInt) {
this.nativeInt = nativeInt;
@@ -703,7 +723,9 @@
* therefore you can skip making the draw calls).
*
* @param rect the rect to compare with the current clip
- * @param type specifies how to treat the edges (BW or antialiased)
+ * @param type {@link Canvas.EdgeType#AA} if the path should be considered antialiased,
+ * since that means it may affect a larger area (more pixels) than
+ * non-antialiased ({@link Canvas.EdgeType#BW}).
* @return true if the rect (transformed by the canvas' matrix)
* does not intersect with the canvas' clip
*/
@@ -720,10 +742,9 @@
* (i.e. the bounds of the path intersects, but the path does not).
*
* @param path The path to compare with the current clip
- * @param type true if the path should be considered antialiased,
- * since that means it may
- * affect a larger area (more pixels) than
- * non-antialiased.
+ * @param type {@link Canvas.EdgeType#AA} if the path should be considered antialiased,
+ * since that means it may affect a larger area (more pixels) than
+ * non-antialiased ({@link Canvas.EdgeType#BW}).
* @return true if the path (transformed by the canvas' matrix)
* does not intersect with the canvas' clip
*/
@@ -745,9 +766,9 @@
* current clip
* @param bottom The bottom of the rectangle to compare with the
* current clip
- * @param type true if the rect should be considered antialiased,
- * since that means it may affect a larger area (more
- * pixels) than non-antialiased.
+ * @param type {@link Canvas.EdgeType#AA} if the path should be considered antialiased,
+ * since that means it may affect a larger area (more pixels) than
+ * non-antialiased ({@link Canvas.EdgeType#BW}).
* @return true if the rect (transformed by the canvas' matrix)
* does not intersect with the canvas' clip
*/
@@ -1333,7 +1354,8 @@
(text.length - index - count)) < 0) {
throw new IndexOutOfBoundsException();
}
- native_drawText(mNativeCanvas, text, index, count, x, y, paint.mNativePaint);
+ native_drawText(mNativeCanvas, text, index, count, x, y, paint.mBidiFlags,
+ paint.mNativePaint);
}
/**
@@ -1346,7 +1368,8 @@
* @param paint The paint used for the text (e.g. color, size, style)
*/
public void drawText(String text, float x, float y, Paint paint) {
- native_drawText(mNativeCanvas, text, 0, text.length(), x, y, paint.mNativePaint);
+ native_drawText(mNativeCanvas, text, 0, text.length(), x, y, paint.mBidiFlags,
+ paint.mNativePaint);
}
/**
@@ -1364,7 +1387,8 @@
if ((start | end | (end - start) | (text.length() - end)) < 0) {
throw new IndexOutOfBoundsException();
}
- native_drawText(mNativeCanvas, text, start, end, x, y, paint.mNativePaint);
+ native_drawText(mNativeCanvas, text, start, end, x, y, paint.mBidiFlags,
+ paint.mNativePaint);
}
/**
@@ -1383,14 +1407,16 @@
public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) {
- native_drawText(mNativeCanvas, text.toString(), start, end, x, y, paint.mNativePaint);
+ native_drawText(mNativeCanvas, text.toString(), start, end, x, y,
+ paint.mBidiFlags, paint.mNativePaint);
} else if (text instanceof GraphicsOperations) {
((GraphicsOperations) text).drawText(this, start, end, x, y,
paint);
} else {
char[] buf = TemporaryBuffer.obtain(end - start);
TextUtils.getChars(text, start, end, buf, 0);
- native_drawText(mNativeCanvas, buf, 0, end - start, x, y, paint.mNativePaint);
+ native_drawText(mNativeCanvas, buf, 0, end - start, x, y,
+ paint.mBidiFlags, paint.mNativePaint);
TemporaryBuffer.recycle(buf);
}
}
@@ -1411,11 +1437,13 @@
* + count.
* @param x the x position at which to draw the text
* @param y the y position at which to draw the text
+ * @param dir the run direction, either {@link #DIRECTION_LTR} or
+ * {@link #DIRECTION_RTL}.
* @param paint the paint
* @hide
*/
public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount,
- float x, float y, Paint paint) {
+ float x, float y, int dir, Paint paint) {
if (text == null) {
throw new NullPointerException("text is null");
@@ -1426,9 +1454,12 @@
if ((index | count | text.length - index - count) < 0) {
throw new IndexOutOfBoundsException();
}
+ if (dir != DIRECTION_LTR && dir != DIRECTION_RTL) {
+ throw new IllegalArgumentException("unknown dir: " + dir);
+ }
native_drawTextRun(mNativeCanvas, text, index, count,
- contextIndex, contextCount, x, y, paint.mNativePaint);
+ contextIndex, contextCount, x, y, dir, paint.mNativePaint);
}
/**
@@ -1444,11 +1475,12 @@
* position can be used for shaping context.
* @param x the x position at which to draw the text
* @param y the y position at which to draw the text
+ * @param dir the run direction, either 0 for LTR or 1 for RTL.
* @param paint the paint
* @hide
*/
public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd,
- float x, float y, Paint paint) {
+ float x, float y, int dir, Paint paint) {
if (text == null) {
throw new NullPointerException("text is null");
@@ -1460,20 +1492,22 @@
throw new IndexOutOfBoundsException();
}
+ int flags = dir == 0 ? 0 : 1;
+
if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) {
native_drawTextRun(mNativeCanvas, text.toString(), start, end,
- contextStart, contextEnd, x, y, paint.mNativePaint);
+ contextStart, contextEnd, x, y, flags, paint.mNativePaint);
} else if (text instanceof GraphicsOperations) {
((GraphicsOperations) text).drawTextRun(this, start, end,
- contextStart, contextEnd, x, y, paint);
+ contextStart, contextEnd, x, y, flags, paint);
} else {
int contextLen = contextEnd - contextStart;
int len = end - start;
char[] buf = TemporaryBuffer.obtain(contextLen);
TextUtils.getChars(text, contextStart, contextEnd, buf, 0);
native_drawTextRun(mNativeCanvas, buf, start - contextStart, len,
- 0, contextLen, x, y, paint.mNativePaint);
+ 0, contextLen, x, y, flags, paint.mNativePaint);
TemporaryBuffer.recycle(buf);
}
}
@@ -1539,7 +1573,8 @@
throw new ArrayIndexOutOfBoundsException();
}
native_drawTextOnPath(mNativeCanvas, text, index, count,
- path.ni(), hOffset, vOffset, paint.mNativePaint);
+ path.ni(), hOffset, vOffset,
+ paint.mBidiFlags, paint.mNativePaint);
}
/**
@@ -1558,7 +1593,7 @@
public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) {
if (text.length() > 0) {
native_drawTextOnPath(mNativeCanvas, text, path.ni(), hOffset, vOffset,
- paint.mNativePaint);
+ paint.mBidiFlags, paint.mNativePaint);
}
}
@@ -1720,18 +1755,18 @@
private static native void native_drawText(int nativeCanvas, char[] text,
int index, int count, float x,
- float y, int paint);
+ float y, int flags, int paint);
private static native void native_drawText(int nativeCanvas, String text,
int start, int end, float x,
- float y, int paint);
+ float y, int flags, int paint);
private static native void native_drawTextRun(int nativeCanvas, String text,
int start, int end, int contextStart, int contextEnd,
- float x, float y, int paint);
+ float x, float y, int flags, int paint);
private static native void native_drawTextRun(int nativeCanvas, char[] text,
int start, int count, int contextStart, int contextCount,
- float x, float y, int paint);
+ float x, float y, int flags, int paint);
private static native void native_drawPosText(int nativeCanvas,
char[] text, int index,
@@ -1744,13 +1779,13 @@
char[] text, int index,
int count, int path,
float hOffset,
- float vOffset,
+ float vOffset, int bidiFlags,
int paint);
private static native void native_drawTextOnPath(int nativeCanvas,
String text, int path,
float hOffset,
float vOffset,
- int paint);
+ int flags, int paint);
private static native void native_drawPicture(int nativeCanvas,
int nativePicture);
private static native void finalizer(int nativeCanvas);
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 8da20f2..216dc6c 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -69,6 +69,11 @@
*/
public int shadowColor;
+ /**
+ * @hide
+ */
+ public int mBidiFlags = BIDI_DEFAULT_LTR;
+
static final Style[] sStyleArray = {
Style.FILL, Style.STROKE, Style.FILL_AND_STROKE
};
@@ -115,6 +120,74 @@
public static final int HINTING_ON = 0x1;
/**
+ * Bidi flag to set LTR paragraph direction.
+ *
+ * @hide
+ */
+ public static final int BIDI_LTR = 0x0;
+
+ /**
+ * Bidi flag to set RTL paragraph direction.
+ *
+ * @hide
+ */
+ public static final int BIDI_RTL = 0x1;
+
+ /**
+ * Bidi flag to detect paragraph direction via heuristics, defaulting to
+ * LTR.
+ *
+ * @hide
+ */
+ public static final int BIDI_DEFAULT_LTR = 0x2;
+
+ /**
+ * Bidi flag to detect paragraph direction via heuristics, defaulting to
+ * RTL.
+ *
+ * @hide
+ */
+ public static final int BIDI_DEFAULT_RTL = 0x3;
+
+ /**
+ * Bidi flag to override direction to all LTR (ignore bidi).
+ *
+ * @hide
+ */
+ public static final int BIDI_FORCE_LTR = 0x4;
+
+ /**
+ * Bidi flag to override direction to all RTL (ignore bidi).
+ *
+ * @hide
+ */
+ public static final int BIDI_FORCE_RTL = 0x5;
+
+ /**
+ * Maximum Bidi flag value.
+ * @hide
+ */
+ private static final int BIDI_MAX_FLAG_VALUE = BIDI_FORCE_RTL;
+
+ /**
+ * Mask for bidi flags.
+ * @hide
+ */
+ private static final int BIDI_FLAG_MASK = 0x7;
+
+ /**
+ * Flag for getTextRunAdvances indicating left-to-right run direction.
+ * @hide
+ */
+ public static final int DIRECTION_LTR = 0;
+
+ /**
+ * Flag for getTextRunAdvances indicating right-to-left run direction.
+ * @hide
+ */
+ public static final int DIRECTION_RTL = 1;
+
+ /**
* Option for getTextRunCursor to compute the valid cursor after
* offset or the limit of the context, whichever is less.
* @hide
@@ -322,6 +395,7 @@
shadowRadius = 0;
shadowColor = 0;
+ mBidiFlags = BIDI_DEFAULT_LTR;
setTextLocale(Locale.getDefault());
}
@@ -361,6 +435,7 @@
shadowRadius = paint.shadowRadius;
shadowColor = paint.shadowColor;
+ mBidiFlags = paint.mBidiFlags;
mLocale = paint.mLocale;
}
@@ -377,6 +452,29 @@
}
/**
+ * Return the bidi flags on the paint.
+ *
+ * @return the bidi flags on the paint
+ * @hide
+ */
+ public int getBidiFlags() {
+ return mBidiFlags;
+ }
+
+ /**
+ * Set the bidi flags on the paint.
+ * @hide
+ */
+ public void setBidiFlags(int flags) {
+ // only flag value is the 3-bit BIDI control setting
+ flags &= BIDI_FLAG_MASK;
+ if (flags > BIDI_MAX_FLAG_VALUE) {
+ throw new IllegalArgumentException("unknown bidi flag: " + flags);
+ }
+ mBidiFlags = flags;
+ }
+
+ /**
* Return the paint's flags. Use the Flag enum to test flag values.
*
* @return the paint's flags (see enums ending in _Flag for bit masks)
@@ -1570,19 +1668,76 @@
}
/**
+ * Return the glyph Ids for the characters in the string.
+ *
+ * @param text The text to measure
+ * @param start The index of the first char to to measure
+ * @param end The end of the text slice to measure
+ * @param contextStart the index of the first character to use for shaping context,
+ * must be <= start
+ * @param contextEnd the index past the last character to use for shaping context,
+ * must be >= end
+ * @param flags the flags to control the advances, either {@link #DIRECTION_LTR}
+ * or {@link #DIRECTION_RTL}
+ * @param glyphs array to receive the glyph Ids of the characters.
+ * Must be at least a large as the text.
+ * @return the number of glyphs in the returned array
+ *
+ * @hide
+ *
+ * Used only for BiDi / RTL Tests
+ */
+ public int getTextGlyphs(String text, int start, int end, int contextStart, int contextEnd,
+ int flags, char[] glyphs) {
+ if (text == null) {
+ throw new IllegalArgumentException("text cannot be null");
+ }
+ if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
+ throw new IllegalArgumentException("unknown flags value: " + flags);
+ }
+ if ((start | end | contextStart | contextEnd | (end - start)
+ | (start - contextStart) | (contextEnd - end) | (text.length() - end)
+ | (text.length() - contextEnd)) < 0) {
+ throw new IndexOutOfBoundsException();
+ }
+ if (end - start > glyphs.length) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ return native_getTextGlyphs(mNativePaint, text, start, end, contextStart, contextEnd,
+ flags, glyphs);
+ }
+
+ /**
* Convenience overload that takes a char array instead of a
* String.
*
- * @see #getTextRunAdvances(String, int, int, int, int, float[], int)
+ * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int)
* @hide
*/
public float getTextRunAdvances(char[] chars, int index, int count,
- int contextIndex, int contextCount, float[] advances,
+ int contextIndex, int contextCount, int flags, float[] advances,
int advancesIndex) {
+ return getTextRunAdvances(chars, index, count, contextIndex, contextCount, flags,
+ advances, advancesIndex, 0 /* use Harfbuzz*/);
+ }
+
+ /**
+ * Convenience overload that takes a char array instead of a
+ * String.
+ *
+ * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int, int)
+ * @hide
+ */
+ public float getTextRunAdvances(char[] chars, int index, int count,
+ int contextIndex, int contextCount, int flags, float[] advances,
+ int advancesIndex, int reserved) {
if (chars == null) {
throw new IllegalArgumentException("text cannot be null");
}
+ if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
+ throw new IllegalArgumentException("unknown flags value: " + flags);
+ }
if ((index | count | contextIndex | contextCount | advancesIndex
| (index - contextIndex) | (contextCount - count)
| ((contextIndex + contextCount) - (index + count))
@@ -1597,13 +1752,13 @@
}
if (!mHasCompatScaling) {
return native_getTextRunAdvances(mNativePaint, chars, index, count,
- contextIndex, contextCount, advances, advancesIndex);
+ contextIndex, contextCount, flags, advances, advancesIndex, reserved);
}
final float oldSize = getTextSize();
setTextSize(oldSize * mCompatScaling);
float res = native_getTextRunAdvances(mNativePaint, chars, index, count,
- contextIndex, contextCount, advances, advancesIndex);
+ contextIndex, contextCount, flags, advances, advancesIndex, reserved);
setTextSize(oldSize);
if (advances != null) {
@@ -1618,12 +1773,26 @@
* Convenience overload that takes a CharSequence instead of a
* String.
*
- * @see #getTextRunAdvances(String, int, int, int, int, float[], int)
+ * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int)
* @hide
*/
public float getTextRunAdvances(CharSequence text, int start, int end,
- int contextStart, int contextEnd, float[] advances,
+ int contextStart, int contextEnd, int flags, float[] advances,
int advancesIndex) {
+ return getTextRunAdvances(text, start, end, contextStart, contextEnd, flags,
+ advances, advancesIndex, 0 /* use Harfbuzz */);
+ }
+
+ /**
+ * Convenience overload that takes a CharSequence instead of a
+ * String.
+ *
+ * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int)
+ * @hide
+ */
+ public float getTextRunAdvances(CharSequence text, int start, int end,
+ int contextStart, int contextEnd, int flags, float[] advances,
+ int advancesIndex, int reserved) {
if (text == null) {
throw new IllegalArgumentException("text cannot be null");
@@ -1638,16 +1807,16 @@
if (text instanceof String) {
return getTextRunAdvances((String) text, start, end,
- contextStart, contextEnd, advances, advancesIndex);
+ contextStart, contextEnd, flags, advances, advancesIndex, reserved);
}
if (text instanceof SpannedString ||
text instanceof SpannableString) {
return getTextRunAdvances(text.toString(), start, end,
- contextStart, contextEnd, advances, advancesIndex);
+ contextStart, contextEnd, flags, advances, advancesIndex, reserved);
}
if (text instanceof GraphicsOperations) {
return ((GraphicsOperations) text).getTextRunAdvances(start, end,
- contextStart, contextEnd, advances, advancesIndex, this);
+ contextStart, contextEnd, flags, advances, advancesIndex, this);
}
if (text.length() == 0 || end == start) {
return 0f;
@@ -1658,7 +1827,7 @@
char[] buf = TemporaryBuffer.obtain(contextLen);
TextUtils.getChars(text, contextStart, contextEnd, buf, 0);
float result = getTextRunAdvances(buf, start - contextStart, len,
- 0, contextLen, advances, advancesIndex);
+ 0, contextLen, flags, advances, advancesIndex, reserved);
TemporaryBuffer.recycle(buf);
return result;
}
@@ -1695,6 +1864,8 @@
* must be <= start
* @param contextEnd the index past the last character to use for shaping context,
* must be >= end
+ * @param flags the flags to control the advances, either {@link #DIRECTION_LTR}
+ * or {@link #DIRECTION_RTL}
* @param advances array to receive the advances, must have room for all advances,
* can be null if only total advance is needed
* @param advancesIndex the position in advances at which to put the
@@ -1704,11 +1875,63 @@
* @hide
*/
public float getTextRunAdvances(String text, int start, int end, int contextStart,
- int contextEnd, float[] advances, int advancesIndex) {
+ int contextEnd, int flags, float[] advances, int advancesIndex) {
+ return getTextRunAdvances(text, start, end, contextStart, contextEnd, flags,
+ advances, advancesIndex, 0 /* use Harfbuzz*/);
+ }
+
+ /**
+ * Returns the total advance width for the characters in the run
+ * between start and end, and if advances is not null, the advance
+ * assigned to each of these characters (java chars).
+ *
+ * <p>The trailing surrogate in a valid surrogate pair is assigned
+ * an advance of 0. Thus the number of returned advances is
+ * always equal to count, not to the number of unicode codepoints
+ * represented by the run.
+ *
+ * <p>In the case of conjuncts or combining marks, the total
+ * advance is assigned to the first logical character, and the
+ * following characters are assigned an advance of 0.
+ *
+ * <p>This generates the sum of the advances of glyphs for
+ * characters in a reordered cluster as the width of the first
+ * logical character in the cluster, and 0 for the widths of all
+ * other characters in the cluster. In effect, such clusters are
+ * treated like conjuncts.
+ *
+ * <p>The shaping bounds limit the amount of context available
+ * outside start and end that can be used for shaping analysis.
+ * These bounds typically reflect changes in bidi level or font
+ * metrics across which shaping does not occur.
+ *
+ * @param text the text to measure. Cannot be null.
+ * @param start the index of the first character to measure
+ * @param end the index past the last character to measure
+ * @param contextStart the index of the first character to use for shaping context,
+ * must be <= start
+ * @param contextEnd the index past the last character to use for shaping context,
+ * must be >= end
+ * @param flags the flags to control the advances, either {@link #DIRECTION_LTR}
+ * or {@link #DIRECTION_RTL}
+ * @param advances array to receive the advances, must have room for all advances,
+ * can be null if only total advance is needed
+ * @param advancesIndex the position in advances at which to put the
+ * advance corresponding to the character at start
+ * @param reserved int reserved value
+ * @return the total advance
+ *
+ * @hide
+ */
+ public float getTextRunAdvances(String text, int start, int end, int contextStart,
+ int contextEnd, int flags, float[] advances, int advancesIndex, int reserved) {
if (text == null) {
throw new IllegalArgumentException("text cannot be null");
}
+ if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
+ throw new IllegalArgumentException("unknown flags value: " + flags);
+ }
if ((start | end | contextStart | contextEnd | advancesIndex | (end - start)
| (start - contextStart) | (contextEnd - end)
| (text.length() - contextEnd)
@@ -1723,13 +1946,13 @@
if (!mHasCompatScaling) {
return native_getTextRunAdvances(mNativePaint, text, start, end,
- contextStart, contextEnd, advances, advancesIndex);
+ contextStart, contextEnd, flags, advances, advancesIndex, reserved);
}
final float oldSize = getTextSize();
setTextSize(oldSize * mCompatScaling);
float totalAdvance = native_getTextRunAdvances(mNativePaint, text, start, end,
- contextStart, contextEnd, advances, advancesIndex);
+ contextStart, contextEnd, flags, advances, advancesIndex, reserved);
setTextSize(oldSize);
if (advances != null) {
@@ -1758,6 +1981,7 @@
* @param text the text
* @param contextStart the start of the context
* @param contextLength the length of the context
+ * @param flags either {@link #DIRECTION_RTL} or {@link #DIRECTION_LTR}
* @param offset the cursor position to move from
* @param cursorOpt how to move the cursor, one of {@link #CURSOR_AFTER},
* {@link #CURSOR_AT_OR_AFTER}, {@link #CURSOR_BEFORE},
@@ -1766,7 +1990,7 @@
* @hide
*/
public int getTextRunCursor(char[] text, int contextStart, int contextLength,
- int offset, int cursorOpt) {
+ int flags, int offset, int cursorOpt) {
int contextEnd = contextStart + contextLength;
if (((contextStart | contextEnd | offset | (contextEnd - contextStart)
| (offset - contextStart) | (contextEnd - offset)
@@ -1776,7 +2000,7 @@
}
return native_getTextRunCursor(mNativePaint, text,
- contextStart, contextLength, offset, cursorOpt);
+ contextStart, contextLength, flags, offset, cursorOpt);
}
/**
@@ -1797,6 +2021,7 @@
* @param text the text
* @param contextStart the start of the context
* @param contextEnd the end of the context
+ * @param flags either {@link #DIRECTION_RTL} or {@link #DIRECTION_LTR}
* @param offset the cursor position to move from
* @param cursorOpt how to move the cursor, one of {@link #CURSOR_AFTER},
* {@link #CURSOR_AT_OR_AFTER}, {@link #CURSOR_BEFORE},
@@ -1805,22 +2030,22 @@
* @hide
*/
public int getTextRunCursor(CharSequence text, int contextStart,
- int contextEnd, int offset, int cursorOpt) {
+ int contextEnd, int flags, int offset, int cursorOpt) {
if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) {
return getTextRunCursor(text.toString(), contextStart, contextEnd,
- offset, cursorOpt);
+ flags, offset, cursorOpt);
}
if (text instanceof GraphicsOperations) {
return ((GraphicsOperations) text).getTextRunCursor(
- contextStart, contextEnd, offset, cursorOpt, this);
+ contextStart, contextEnd, flags, offset, cursorOpt, this);
}
int contextLen = contextEnd - contextStart;
char[] buf = TemporaryBuffer.obtain(contextLen);
TextUtils.getChars(text, contextStart, contextEnd, buf, 0);
- int result = getTextRunCursor(buf, 0, contextLen, offset - contextStart, cursorOpt);
+ int result = getTextRunCursor(buf, 0, contextLen, flags, offset - contextStart, cursorOpt);
TemporaryBuffer.recycle(buf);
return result;
}
@@ -1843,6 +2068,7 @@
* @param text the text
* @param contextStart the start of the context
* @param contextEnd the end of the context
+ * @param flags either {@link #DIRECTION_RTL} or {@link #DIRECTION_LTR}
* @param offset the cursor position to move from
* @param cursorOpt how to move the cursor, one of {@link #CURSOR_AFTER},
* {@link #CURSOR_AT_OR_AFTER}, {@link #CURSOR_BEFORE},
@@ -1851,7 +2077,7 @@
* @hide
*/
public int getTextRunCursor(String text, int contextStart, int contextEnd,
- int offset, int cursorOpt) {
+ int flags, int offset, int cursorOpt) {
if (((contextStart | contextEnd | offset | (contextEnd - contextStart)
| (offset - contextStart) | (contextEnd - offset)
| (text.length() - contextEnd) | cursorOpt) < 0)
@@ -1860,7 +2086,7 @@
}
return native_getTextRunCursor(mNativePaint, text,
- contextStart, contextEnd, offset, cursorOpt);
+ contextStart, contextEnd, flags, offset, cursorOpt);
}
/**
@@ -1881,7 +2107,7 @@
if ((index | count) < 0 || index + count > text.length) {
throw new ArrayIndexOutOfBoundsException();
}
- native_getTextPath(mNativePaint, text, index, count, x, y,
+ native_getTextPath(mNativePaint, mBidiFlags, text, index, count, x, y,
path.ni());
}
@@ -1903,7 +2129,7 @@
if ((start | end | (end - start) | (text.length() - end)) < 0) {
throw new IndexOutOfBoundsException();
}
- native_getTextPath(mNativePaint, text, start, end, x, y,
+ native_getTextPath(mNativePaint, mBidiFlags, text, start, end, x, y,
path.ni());
}
@@ -1995,22 +2221,26 @@
private static native int native_getTextWidths(int native_object,
String text, int start, int end, float[] widths);
+ private static native int native_getTextGlyphs(int native_object,
+ String text, int start, int end, int contextStart, int contextEnd,
+ int flags, char[] glyphs);
+
private static native float native_getTextRunAdvances(int native_object,
char[] text, int index, int count, int contextIndex, int contextCount,
- float[] advances, int advancesIndex);
+ int flags, float[] advances, int advancesIndex, int reserved);
private static native float native_getTextRunAdvances(int native_object,
String text, int start, int end, int contextStart, int contextEnd,
- float[] advances, int advancesIndex);
+ int flags, float[] advances, int advancesIndex, int reserved);
private native int native_getTextRunCursor(int native_object, char[] text,
- int contextStart, int contextLength, int offset, int cursorOpt);
+ int contextStart, int contextLength, int flags, int offset, int cursorOpt);
private native int native_getTextRunCursor(int native_object, String text,
- int contextStart, int contextEnd, int offset, int cursorOpt);
+ int contextStart, int contextEnd, int flags, int offset, int cursorOpt);
- private static native void native_getTextPath(int native_object, char[] text,
- int index, int count, float x, float y, int path);
- private static native void native_getTextPath(int native_object, String text,
- int start, int end, float x, float y, int path);
+ private static native void native_getTextPath(int native_object, int bidiFlags,
+ char[] text, int index, int count, float x, float y, int path);
+ private static native void native_getTextPath(int native_object, int bidiFlags,
+ String text, int start, int end, float x, float y, int path);
private static native void nativeGetStringBounds(int nativePaint,
String text, int start, int end, Rect bounds);
private static native void nativeGetCharArrayBounds(int nativePaint,
diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk
index 1618110..06e658d 100644
--- a/libs/hwui/Android.mk
+++ b/libs/hwui/Android.mk
@@ -34,7 +34,6 @@
ProgramCache.cpp \
RenderBufferCache.cpp \
ResourceCache.cpp \
- ShapeCache.cpp \
SkiaColorFilter.cpp \
SkiaShader.cpp \
Snapshot.cpp \
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index a1cc2e8..dc3a4e2 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -103,14 +103,9 @@
void Caches::initExtensions() {
if (mExtensions.hasDebugMarker()) {
eventMark = glInsertEventMarkerEXT;
- if ((drawDeferDisabled || drawReorderDisabled)) {
- startMark = glPushGroupMarkerEXT;
- endMark = glPopGroupMarkerEXT;
- } else {
- startMark = startMarkNull;
- endMark = endMarkNull;
- }
+ startMark = glPushGroupMarkerEXT;
+ endMark = glPopGroupMarkerEXT;
} else {
eventMark = eventMarkNull;
startMark = startMarkNull;
@@ -229,16 +224,6 @@
gradientCache.getSize(), gradientCache.getMaxSize());
log.appendFormat(" PathCache %8d / %8d\n",
pathCache.getSize(), pathCache.getMaxSize());
- log.appendFormat(" CircleShapeCache %8d / %8d\n",
- circleShapeCache.getSize(), circleShapeCache.getMaxSize());
- log.appendFormat(" OvalShapeCache %8d / %8d\n",
- ovalShapeCache.getSize(), ovalShapeCache.getMaxSize());
- log.appendFormat(" RoundRectShapeCache %8d / %8d\n",
- roundRectShapeCache.getSize(), roundRectShapeCache.getMaxSize());
- log.appendFormat(" RectShapeCache %8d / %8d\n",
- rectShapeCache.getSize(), rectShapeCache.getMaxSize());
- log.appendFormat(" ArcShapeCache %8d / %8d\n",
- arcShapeCache.getSize(), arcShapeCache.getMaxSize());
log.appendFormat(" TextDropShadowCache %8d / %8d\n", dropShadowCache.getSize(),
dropShadowCache.getMaxSize());
for (uint32_t i = 0; i < fontRenderer->getFontRendererCount(); i++) {
@@ -258,11 +243,6 @@
total += gradientCache.getSize();
total += pathCache.getSize();
total += dropShadowCache.getSize();
- total += roundRectShapeCache.getSize();
- total += circleShapeCache.getSize();
- total += ovalShapeCache.getSize();
- total += rectShapeCache.getSize();
- total += arcShapeCache.getSize();
for (uint32_t i = 0; i < fontRenderer->getFontRendererCount(); i++) {
total += fontRenderer->getFontRendererSize(i);
}
@@ -330,11 +310,6 @@
fontRenderer->flush();
textureCache.flush();
pathCache.clear();
- roundRectShapeCache.clear();
- circleShapeCache.clear();
- ovalShapeCache.clear();
- rectShapeCache.clear();
- arcShapeCache.clear();
// fall through
case kFlushMode_Layers:
layerCache.clear();
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index dc32a7e..63836c1 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -36,7 +36,6 @@
#include "GradientCache.h"
#include "PatchCache.h"
#include "ProgramCache.h"
-#include "ShapeCache.h"
#include "PathCache.h"
#include "TextDropShadowCache.h"
#include "FboCache.h"
@@ -269,11 +268,6 @@
GradientCache gradientCache;
ProgramCache programCache;
PathCache pathCache;
- RoundRectShapeCache roundRectShapeCache;
- CircleShapeCache circleShapeCache;
- OvalShapeCache ovalShapeCache;
- RectShapeCache rectShapeCache;
- ArcShapeCache arcShapeCache;
PatchCache patchCache;
TextDropShadowCache dropShadowCache;
FboCache fboCache;
diff --git a/libs/hwui/Debug.h b/libs/hwui/Debug.h
index 773fe82..46beb94 100644
--- a/libs/hwui/Debug.h
+++ b/libs/hwui/Debug.h
@@ -64,7 +64,7 @@
#define DEBUG_PATCHES_EMPTY_VERTICES 0
// Turn on to display debug info about shapes
-#define DEBUG_SHAPES 0
+#define DEBUG_PATHS 0
// Turn on to display debug info about textures
#define DEBUG_TEXTURES 0
diff --git a/libs/hwui/DeferredDisplayList.cpp b/libs/hwui/DeferredDisplayList.cpp
index a4e9950..5c5bf45 100644
--- a/libs/hwui/DeferredDisplayList.cpp
+++ b/libs/hwui/DeferredDisplayList.cpp
@@ -17,6 +17,8 @@
#define LOG_TAG "OpenGLRenderer"
#define ATRACE_TAG ATRACE_TAG_VIEW
+#include <SkCanvas.h>
+
#include <utils/Trace.h>
#include "Debug.h"
@@ -32,15 +34,15 @@
namespace android {
namespace uirenderer {
+/////////////////////////////////////////////////////////////////////////////////
+// Operation Batches
+/////////////////////////////////////////////////////////////////////////////////
+
class DrawOpBatch {
public:
- DrawOpBatch() {
- mOps.clear();
- }
+ DrawOpBatch() { mOps.clear(); }
- ~DrawOpBatch() {
- mOps.clear();
- }
+ virtual ~DrawOpBatch() { mOps.clear(); }
void add(DrawOp* op) {
// NOTE: ignore empty bounds special case, since we don't merge across those ops
@@ -48,8 +50,9 @@
mOps.add(op);
}
- bool intersects(Rect& rect) {
+ virtual bool intersects(Rect& rect) {
if (!rect.intersects(mBounds)) return false;
+
for (unsigned int i = 0; i < mOps.size(); i++) {
if (rect.intersects(mOps[i]->state.mBounds)) {
#if DEBUG_DEFER
@@ -64,27 +67,217 @@
return false;
}
- Vector<DrawOp*> mOps;
+ virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty) {
+ DEFER_LOGD("replaying draw batch %p", this);
+
+ status_t status = DrawGlInfo::kStatusDone;
+ DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
+ for (unsigned int i = 0; i < mOps.size(); i++) {
+ DrawOp* op = mOps[i];
+
+ renderer.restoreDisplayState(op->state, kStateDeferFlag_Draw);
+
+#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
+ renderer.eventMark(strlen(op->name()), op->name());
+#endif
+ status |= op->applyDraw(renderer, dirty, 0, op->state.mMultipliedAlpha);
+ logBuffer.writeCommand(0, op->name());
+ }
+ return status;
+ }
+
+ inline int count() const { return mOps.size(); }
private:
+ Vector<DrawOp*> mOps;
Rect mBounds;
};
-void DeferredDisplayList::clear() {
+class StateOpBatch : public DrawOpBatch {
+public:
+ // creates a single operation batch
+ StateOpBatch(StateOp* op) : mOp(op) {}
+
+ bool intersects(Rect& rect) {
+ // if something checks for intersection, it's trying to go backwards across a state op,
+ // something not currently supported - state ops are always barriers
+ CRASH();
+ return false;
+ }
+
+ virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty) {
+ DEFER_LOGD("replaying state op batch %p", this);
+ renderer.restoreDisplayState(mOp->state, 0);
+
+ // use invalid save count because it won't be used at flush time - RestoreToCountOp is the
+ // only one to use it, and we don't use that class at flush time, instead calling
+ // renderer.restoreToCount directly
+ int saveCount = -1;
+ mOp->applyState(renderer, saveCount);
+ return DrawGlInfo::kStatusDone;
+ }
+
+private:
+ StateOp* mOp;
+};
+
+class RestoreToCountBatch : public DrawOpBatch {
+public:
+ RestoreToCountBatch(int restoreCount) : mRestoreCount(restoreCount) {}
+
+ bool intersects(Rect& rect) {
+ // if something checks for intersection, it's trying to go backwards across a state op,
+ // something not currently supported - state ops are always barriers
+ CRASH();
+ return false;
+ }
+
+ virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty) {
+ DEFER_LOGD("batch %p restoring to count %d", this, mRestoreCount);
+ renderer.restoreToCount(mRestoreCount);
+
+ return DrawGlInfo::kStatusDone;
+ }
+
+private:
+ /*
+ * The count used here represents the flush() time saveCount. This is as opposed to the
+ * DisplayList record time, or defer() time values (which are RestoreToCountOp's mCount, and
+ * (saveCount + mCount) respectively). Since the count is different from the original
+ * RestoreToCountOp, we don't store a pointer to the op, as elsewhere.
+ */
+ const int mRestoreCount;
+};
+
+/////////////////////////////////////////////////////////////////////////////////
+// DeferredDisplayList
+/////////////////////////////////////////////////////////////////////////////////
+
+void DeferredDisplayList::resetBatchingState() {
for (int i = 0; i < kOpBatch_Count; i++) {
mBatchIndices[i] = -1;
}
+}
+
+void DeferredDisplayList::clear() {
+ resetBatchingState();
+ mComplexClipStackStart = -1;
+
for (unsigned int i = 0; i < mBatches.size(); i++) {
delete mBatches[i];
}
mBatches.clear();
+ mSaveStack.clear();
}
-void DeferredDisplayList::add(DrawOp* op, bool disallowReorder) {
- if (CC_UNLIKELY(disallowReorder)) {
- if (!mBatches.isEmpty()) {
- mBatches[0]->add(op);
- return;
+/////////////////////////////////////////////////////////////////////////////////
+// Operation adding
+/////////////////////////////////////////////////////////////////////////////////
+
+int DeferredDisplayList::getStateOpDeferFlags() const {
+ // For both clipOp and save(Layer)Op, we don't want to save drawing info, and only want to save
+ // the clip if we aren't recording a complex clip (and can thus trust it to be a rect)
+ return recordingComplexClip() ? 0 : kStateDeferFlag_Clip;
+}
+
+int DeferredDisplayList::getDrawOpDeferFlags() const {
+ return kStateDeferFlag_Draw | getStateOpDeferFlags();
+}
+
+/**
+ * When an clipping operation occurs that could cause a complex clip, record the operation and all
+ * subsequent clipOps, save/restores (if the clip flag is set). During a flush, instead of loading
+ * the clip from deferred state, we play back all of the relevant state operations that generated
+ * the complex clip.
+ *
+ * Note that we don't need to record the associated restore operation, since operations at defer
+ * time record whether they should store the renderer's current clip
+ */
+void DeferredDisplayList::addClip(OpenGLRenderer& renderer, ClipOp* op) {
+ if (recordingComplexClip() || op->canCauseComplexClip() || !renderer.hasRectToRectTransform()) {
+ DEFER_LOGD("%p Received complex clip operation %p", this, op);
+
+ // NOTE: defer clip op before setting mComplexClipStackStart so previous clip is recorded
+ storeStateOpBarrier(renderer, op);
+
+ if (!recordingComplexClip()) {
+ mComplexClipStackStart = renderer.getSaveCount() - 1;
+ DEFER_LOGD(" Starting complex clip region, start is %d", mComplexClipStackStart);
}
+ }
+}
+
+/**
+ * For now, we record save layer operations as barriers in the batch list, preventing drawing
+ * operations from reordering around the saveLayer and it's associated restore()
+ *
+ * In the future, we should send saveLayer commands (if they can be played out of order) and their
+ * contained drawing operations to a seperate list of batches, so that they may draw at the
+ * beginning of the frame. This would avoid targetting and removing an FBO in the middle of a frame.
+ *
+ * saveLayer operations should be pulled to the beginning of the frame if the canvas doesn't have a
+ * complex clip, and if the flags (kClip_SaveFlag & kClipToLayer_SaveFlag) are set.
+ */
+void DeferredDisplayList::addSaveLayer(OpenGLRenderer& renderer,
+ SaveLayerOp* op, int newSaveCount) {
+ DEFER_LOGD("%p adding saveLayerOp %p, flags %x, new count %d",
+ this, op, op->getFlags(), newSaveCount);
+
+ storeStateOpBarrier(renderer, op);
+ mSaveStack.push(newSaveCount);
+}
+
+/**
+ * Takes save op and it's return value - the new save count - and stores it into the stream as a
+ * barrier if it's needed to properly modify a complex clip
+ */
+void DeferredDisplayList::addSave(OpenGLRenderer& renderer, SaveOp* op, int newSaveCount) {
+ int saveFlags = op->getFlags();
+ DEFER_LOGD("%p adding saveOp %p, flags %x, new count %d", this, op, saveFlags, newSaveCount);
+
+ if (recordingComplexClip() && (saveFlags & SkCanvas::kClip_SaveFlag)) {
+ // store and replay the save operation, as it may be needed to correctly playback the clip
+ DEFER_LOGD(" adding save barrier with new save count %d", newSaveCount);
+ storeStateOpBarrier(renderer, op);
+ mSaveStack.push(newSaveCount);
+ }
+}
+
+/**
+ * saveLayer() commands must be associated with a restoreToCount batch that will clean up and draw
+ * the layer in the deferred list
+ *
+ * other save() commands which occur as children of a snapshot with complex clip will be deferred,
+ * and must be restored
+ *
+ * Either will act as a barrier to draw operation reordering, as we want to play back layer
+ * save/restore and complex canvas modifications (including save/restore) in order.
+ */
+void DeferredDisplayList::addRestoreToCount(OpenGLRenderer& renderer, int newSaveCount) {
+ DEFER_LOGD("%p addRestoreToCount %d", this, newSaveCount);
+
+ if (recordingComplexClip() && newSaveCount <= mComplexClipStackStart) {
+ mComplexClipStackStart = -1;
+ resetBatchingState();
+ }
+
+ if (mSaveStack.isEmpty() || newSaveCount > mSaveStack.top()) {
+ return;
+ }
+
+ while (!mSaveStack.isEmpty() && mSaveStack.top() >= newSaveCount) mSaveStack.pop();
+
+ storeRestoreToCountBarrier(mSaveStack.size() + 1);
+}
+
+void DeferredDisplayList::addDrawOp(OpenGLRenderer& renderer, DrawOp* op) {
+ if (renderer.storeDisplayState(op->state, getDrawOpDeferFlags())) {
+ return; // quick rejected
+ }
+
+ op->onDrawOpDeferred(renderer);
+
+ if (CC_UNLIKELY(renderer.getCaches().drawReorderDisabled)) {
+ // TODO: elegant way to reuse batches?
DrawOpBatch* b = new DrawOpBatch();
b->add(op);
mBatches.add(b);
@@ -138,9 +331,41 @@
targetBatch->add(op);
}
-status_t DeferredDisplayList::flush(OpenGLRenderer& renderer, Rect& dirty, int32_t flags,
- uint32_t level) {
- ATRACE_CALL();
+void DeferredDisplayList::storeStateOpBarrier(OpenGLRenderer& renderer, StateOp* op) {
+ DEFER_LOGD("%p adding state op barrier at pos %d", this, mBatches.size());
+
+ renderer.storeDisplayState(op->state, getStateOpDeferFlags());
+ mBatches.add(new StateOpBatch(op));
+ resetBatchingState();
+}
+
+void DeferredDisplayList::storeRestoreToCountBarrier(int newSaveCount) {
+ DEFER_LOGD("%p adding restore to count %d barrier, pos %d",
+ this, newSaveCount, mBatches.size());
+
+ mBatches.add(new RestoreToCountBatch(newSaveCount));
+ resetBatchingState();
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+// Replay / flush
+/////////////////////////////////////////////////////////////////////////////////
+
+static status_t replayBatchList(Vector<DrawOpBatch*>& batchList,
+ OpenGLRenderer& renderer, Rect& dirty) {
+ status_t status = DrawGlInfo::kStatusDone;
+
+ int opCount = 0;
+ for (unsigned int i = 0; i < batchList.size(); i++) {
+ status |= batchList[i]->replay(renderer, dirty);
+ opCount += batchList[i]->count();
+ }
+ DEFER_LOGD("--flushed, drew %d batches (total %d ops)", batchList.size(), opCount);
+ return status;
+}
+
+status_t DeferredDisplayList::flush(OpenGLRenderer& renderer, Rect& dirty) {
+ ATRACE_NAME("flush drawing commands");
status_t status = DrawGlInfo::kStatusDone;
if (isEmpty()) return status; // nothing to flush
@@ -148,29 +373,12 @@
DEFER_LOGD("--flushing");
renderer.eventMark("Flush");
- DrawModifiers restoreDrawModifiers = renderer.getDrawModifiers();
- int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
- int opCount = 0;
- for (unsigned int i = 0; i < mBatches.size(); i++) {
- DrawOpBatch* batch = mBatches[i];
- for (unsigned int j = 0; j < batch->mOps.size(); j++) {
- DrawOp* op = batch->mOps[j];
+ renderer.restoreToCount(1);
+ status |= replayBatchList(mBatches, renderer, dirty);
+ renderer.resetDrawModifiers();
- renderer.restoreDisplayState(op->state);
+ DEFER_LOGD("--flush complete, returning %x", status);
-#if DEBUG_DEFER
- op->output(2);
-#endif
- status |= op->applyDraw(renderer, dirty, level,
- op->state.mMultipliedAlpha >= 0, op->state.mMultipliedAlpha);
- opCount++;
- }
- }
-
- DEFER_LOGD("--flushed, drew %d batches (total %d ops)", mBatches.size(), opCount);
-
- renderer.restoreToCount(restoreTo);
- renderer.setDrawModifiers(restoreDrawModifiers);
clear();
return status;
}
diff --git a/libs/hwui/DeferredDisplayList.h b/libs/hwui/DeferredDisplayList.h
index 4fcb297..8e908fa 100644
--- a/libs/hwui/DeferredDisplayList.h
+++ b/libs/hwui/DeferredDisplayList.h
@@ -26,10 +26,13 @@
namespace android {
namespace uirenderer {
+class ClipOp;
class DrawOp;
+class SaveOp;
+class SaveLayerOp;
+class StateOp;
class DrawOpBatch;
class OpenGLRenderer;
-class SkiaShader;
class DeferredDisplayList {
public:
@@ -55,18 +58,42 @@
* Plays back all of the draw ops recorded into batches to the renderer.
* Adjusts the state of the renderer as necessary, and restores it when complete
*/
- status_t flush(OpenGLRenderer& renderer, Rect& dirty, int32_t flags,
- uint32_t level);
+ status_t flush(OpenGLRenderer& renderer, Rect& dirty);
+
+ void addClip(OpenGLRenderer& renderer, ClipOp* op);
+ void addSaveLayer(OpenGLRenderer& renderer, SaveLayerOp* op, int newSaveCount);
+ void addSave(OpenGLRenderer& renderer, SaveOp* op, int newSaveCount);
+ void addRestoreToCount(OpenGLRenderer& renderer, int newSaveCount);
/**
* Add a draw op into the DeferredDisplayList, reordering as needed (for performance) if
* disallowReorder is false, respecting draw order when overlaps occur
*/
- void add(DrawOp* op, bool disallowReorder);
+ void addDrawOp(OpenGLRenderer& renderer, DrawOp* op);
private:
+ /*
+ * Resets the batching back-pointers, creating a barrier in the operation stream so that no ops
+ * added in the future will be inserted into a batch that already exist.
+ */
+ void resetBatchingState();
+
void clear();
+ void storeStateOpBarrier(OpenGLRenderer& renderer, StateOp* op);
+ void storeRestoreToCountBarrier(int newSaveCount);
+
+ bool recordingComplexClip() const { return mComplexClipStackStart >= 0; }
+
+ int getStateOpDeferFlags() const;
+ int getDrawOpDeferFlags() const;
+
+ /*
+ *
+ * at defer time, stores the savecount of save/saveLayer ops that were
+ */
+ Vector<int> mSaveStack;
+ int mComplexClipStackStart;
Vector<DrawOpBatch*> mBatches;
int mBatchIndices[kOpBatch_Count];
diff --git a/libs/hwui/DisplayList.cpp b/libs/hwui/DisplayList.cpp
index 5781f4d..4944fe8 100644
--- a/libs/hwui/DisplayList.cpp
+++ b/libs/hwui/DisplayList.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include <SkCanvas.h>
+
#include "Debug.h"
#include "DisplayList.h"
#include "DisplayListOp.h"
@@ -61,6 +63,12 @@
void DisplayList::clearResources() {
mDisplayListData = NULL;
+
+ mClipRectOp = NULL;
+ mSaveLayerOp = NULL;
+ mSaveOp = NULL;
+ mRestoreToCountOp = NULL;
+
delete mTransformMatrix;
delete mTransformCamera;
delete mTransformMatrix3D;
@@ -115,9 +123,7 @@
}
for (size_t i = 0; i < mPaths.size(); i++) {
- SkPath* path = mPaths.itemAt(i);
- caches.pathCache.remove(path);
- delete path;
+ delete mPaths.itemAt(i);
}
for (size_t i = 0; i < mMatrices.size(); i++) {
@@ -156,6 +162,13 @@
return;
}
+ // allocate reusable ops for state-deferral
+ LinearAllocator& alloc = mDisplayListData->allocator;
+ mClipRectOp = new (alloc) ClipRectOp();
+ mSaveLayerOp = new (alloc) SaveLayerOp();
+ mSaveOp = new (alloc) SaveOp();
+ mRestoreToCountOp = new (alloc) RestoreToCountOp();
+
mFunctorCount = recorder.getFunctorCount();
Caches& caches = Caches::getInstance();
@@ -318,7 +331,7 @@
}
}
-void DisplayList::outputViewProperties(uint32_t level) {
+void DisplayList::outputViewProperties(const int level) {
updateMatrix();
if (mLeft != 0 || mTop != 0) {
ALOGD("%*sTranslate (left, top) %d, %d", level * 2, "", mLeft, mTop);
@@ -358,10 +371,17 @@
}
}
-status_t DisplayList::setViewProperties(OpenGLRenderer& renderer, Rect& dirty,
- int32_t flags, uint32_t level, DeferredDisplayList* deferredList) {
- status_t status = DrawGlInfo::kStatusDone;
-#if DEBUG_DISPLAYLIST
+/*
+ * For property operations, we pass a savecount of 0, since the operations aren't part of the
+ * displaylist, and thus don't have to compensate for the record-time/playback-time discrepancy in
+ * base saveCount (i.e., how RestoreToCount uses saveCount + mCount)
+ */
+#define PROPERTY_SAVECOUNT 0
+
+template <class T>
+void DisplayList::setViewProperties(OpenGLRenderer& renderer, T& handler,
+ const int level) {
+#if DEBUG_DISPLAY_LIST
outputViewProperties(level);
#endif
updateMatrix();
@@ -381,86 +401,121 @@
}
}
if (mAlpha < 1 && !mCaching) {
- if (deferredList) {
- // flush since we'll either enter a Layer, or set alpha, both not supported in deferral
- status |= deferredList->flush(renderer, dirty, flags, level);
- }
-
if (!mHasOverlappingRendering) {
renderer.setAlpha(mAlpha);
} else {
// TODO: should be able to store the size of a DL at record time and not
// have to pass it into this call. In fact, this information might be in the
// location/size info that we store with the new native transform data.
- int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
+ int saveFlags = SkCanvas::kHasAlphaLayer_SaveFlag;
if (mClipChildren) {
- flags |= SkCanvas::kClipToLayer_SaveFlag;
+ saveFlags |= SkCanvas::kClipToLayer_SaveFlag;
}
- renderer.saveLayerAlpha(0, 0, mRight - mLeft, mBottom - mTop,
- mMultipliedAlpha, flags);
+ handler(mSaveLayerOp->reinit(0, 0, mRight - mLeft, mBottom - mTop,
+ mMultipliedAlpha, SkXfermode::kSrcOver_Mode, saveFlags), PROPERTY_SAVECOUNT);
}
}
if (mClipChildren && !mCaching) {
- if (deferredList && CC_UNLIKELY(!renderer.hasRectToRectTransform())) {
- // flush, since clip will likely be a region
- status |= deferredList->flush(renderer, dirty, flags, level);
- }
- renderer.clipRect(0, 0, mRight - mLeft, mBottom - mTop,
- SkRegion::kIntersect_Op);
+ handler(mClipRectOp->reinit(0, 0, mRight - mLeft, mBottom - mTop, SkRegion::kIntersect_Op),
+ PROPERTY_SAVECOUNT);
}
- return status;
}
-status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level,
- DeferredDisplayList* deferredList) {
- status_t drawGlStatus = DrawGlInfo::kStatusDone;
+class DeferOperationHandler {
+public:
+ DeferOperationHandler(DeferStateStruct& deferStruct, int multipliedAlpha, int level)
+ : mDeferStruct(deferStruct), mMultipliedAlpha(multipliedAlpha), mLevel(level) {}
+ inline void operator()(DisplayListOp* operation, int saveCount) {
+ operation->defer(mDeferStruct, saveCount, mLevel, mMultipliedAlpha);
+ }
+private:
+ DeferStateStruct& mDeferStruct;
+ const int mMultipliedAlpha;
+ const int mLevel;
+};
+
+void DisplayList::defer(DeferStateStruct& deferStruct, const int level) {
+ DeferOperationHandler handler(deferStruct, mCaching ? mMultipliedAlpha : -1, level);
+ iterate<DeferOperationHandler>(deferStruct.mRenderer, handler, level);
+}
+
+class ReplayOperationHandler {
+public:
+ ReplayOperationHandler(ReplayStateStruct& replayStruct, int multipliedAlpha, int level)
+ : mReplayStruct(replayStruct), mMultipliedAlpha(multipliedAlpha), mLevel(level) {}
+ inline void operator()(DisplayListOp* operation, int saveCount) {
+#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
+ replayStruct.mRenderer.eventMark(operation->name());
+#endif
+ operation->replay(mReplayStruct, saveCount, mLevel, mMultipliedAlpha);
+ }
+private:
+ ReplayStateStruct& mReplayStruct;
+ const int mMultipliedAlpha;
+ const int mLevel;
+};
+
+void DisplayList::replay(ReplayStateStruct& replayStruct, const int level) {
+ ReplayOperationHandler handler(replayStruct, mCaching ? mMultipliedAlpha : -1, level);
+
+ replayStruct.mRenderer.startMark(mName.string());
+ iterate<ReplayOperationHandler>(replayStruct.mRenderer, handler, level);
+ replayStruct.mRenderer.endMark();
+
+ DISPLAY_LIST_LOGD("%*sDone (%p, %s), returning %d", level * 2, "", this, mName.string(),
+ replayStruct.mDrawGlStatus);
+}
+
+/**
+ * This function serves both defer and replay modes, and will organize the displayList's component
+ * operations for a single frame:
+ *
+ * Every 'simple' operation that affects just the matrix and alpha (or other factors of
+ * DeferredDisplayState) may be issued directly to the renderer, but complex operations (with custom
+ * defer logic) and operations in displayListOps are issued through the 'handler' which handles the
+ * defer vs replay logic, per operation
+ */
+template <class T>
+void DisplayList::iterate(OpenGLRenderer& renderer, T& handler, const int level) {
+ if (mSize == 0 || mAlpha <= 0) {
+ DISPLAY_LIST_LOGD("%*sEmpty display list (%p, %s)", level * 2, "", this, mName.string());
+ return;
+ }
#if DEBUG_DISPLAY_LIST
Rect* clipRect = renderer.getClipRect();
DISPLAY_LIST_LOGD("%*sStart display list (%p, %s), clipRect: %.0f, %.f, %.0f, %.0f",
- (level+1)*2, "", this, mName.string(), clipRect->left, clipRect->top,
+ level * 2, "", this, mName.string(), clipRect->left, clipRect->top,
clipRect->right, clipRect->bottom);
#endif
- renderer.startMark(mName.string());
+ int restoreTo = renderer.getSaveCount();
+ handler(mSaveOp->reinit(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag),
+ PROPERTY_SAVECOUNT);
- int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
- DISPLAY_LIST_LOGD("%*sSave %d %d", level * 2, "",
+ DISPLAY_LIST_LOGD("%*sSave %d %d", (level + 1) * 2, "",
SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
- drawGlStatus |= setViewProperties(renderer, dirty, flags, level, deferredList);
+ setViewProperties<T>(renderer, handler, level + 1);
if (renderer.quickRejectNoScissor(0, 0, mWidth, mHeight)) {
DISPLAY_LIST_LOGD("%*sRestoreToCount %d", level * 2, "", restoreTo);
- renderer.restoreToCount(restoreTo);
- renderer.endMark();
- return drawGlStatus;
+ handler(mRestoreToCountOp->reinit(restoreTo), PROPERTY_SAVECOUNT);
+ return;
}
DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
int saveCount = renderer.getSaveCount() - 1;
for (unsigned int i = 0; i < mDisplayListData->displayListOps.size(); i++) {
DisplayListOp *op = mDisplayListData->displayListOps[i];
-#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
- renderer.eventMark(strlen(op->name()), op->name());
-#endif
- drawGlStatus |= op->replay(renderer, dirty, flags,
- saveCount, level, mCaching, mMultipliedAlpha, deferredList);
+
+ handler(op, saveCount);
logBuffer.writeCommand(level, op->name());
}
- DISPLAY_LIST_LOGD("%*sRestoreToCount %d", level * 2, "", restoreTo);
+ DISPLAY_LIST_LOGD("%*sRestoreToCount %d", (level + 1) * 2, "", restoreTo);
+ handler(mRestoreToCountOp->reinit(restoreTo), PROPERTY_SAVECOUNT);
renderer.restoreToCount(restoreTo);
- renderer.endMark();
-
- DISPLAY_LIST_LOGD("%*sDone (%p, %s), returning %d", (level + 1) * 2, "", this, mName.string(),
- drawGlStatus);
-
- if (!level && CC_LIKELY(deferredList)) {
- drawGlStatus |= deferredList->flush(renderer, dirty, flags, level);
- }
-
- return drawGlStatus;
}
}; // namespace uirenderer
diff --git a/libs/hwui/DisplayList.h b/libs/hwui/DisplayList.h
index feee69c..5392587 100644
--- a/libs/hwui/DisplayList.h
+++ b/libs/hwui/DisplayList.h
@@ -24,6 +24,8 @@
#include <SkCamera.h>
#include <SkMatrix.h>
+#include <private/hwui/DrawGlInfo.h>
+
#include <utils/RefBase.h>
#include <utils/SortedVector.h>
#include <utils/String8.h>
@@ -57,10 +59,33 @@
class SkiaColorFilter;
class SkiaShader;
+class ClipRectOp;
+class SaveLayerOp;
+class SaveOp;
+class RestoreToCountOp;
+
+struct DeferStateStruct {
+ DeferStateStruct(DeferredDisplayList& deferredList, OpenGLRenderer& renderer, int replayFlags)
+ : mDeferredList(deferredList), mRenderer(renderer), mReplayFlags(replayFlags) {}
+ DeferredDisplayList& mDeferredList;
+ OpenGLRenderer& mRenderer;
+ const int mReplayFlags;
+};
+
+struct ReplayStateStruct {
+ ReplayStateStruct(OpenGLRenderer& renderer, Rect& dirty, int replayFlags)
+ : mRenderer(renderer), mDirty(dirty), mReplayFlags(replayFlags),
+ mDrawGlStatus(DrawGlInfo::kStatusDone) {}
+ OpenGLRenderer& mRenderer;
+ Rect& mDirty;
+ const int mReplayFlags;
+ status_t mDrawGlStatus;
+};
+
/**
* Refcounted structure that holds data used in display list stream
*/
-class DisplayListData: public LightRefBase<DisplayListData> {
+class DisplayListData : public LightRefBase<DisplayListData> {
public:
LinearAllocator allocator;
Vector<DisplayListOp*> displayListOps;
@@ -79,9 +104,6 @@
kReplayFlag_ClipChildren = 0x1
};
- status_t setViewProperties(OpenGLRenderer& renderer, Rect& dirty,
- int32_t flags, uint32_t level, DeferredDisplayList* deferredList);
- void outputViewProperties(uint32_t level);
ANDROID_API size_t getSize();
ANDROID_API static void destroyDisplayListDeferred(DisplayList* displayList);
@@ -89,8 +111,9 @@
void initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing = false);
- status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level = 0,
- DeferredDisplayList* deferredList = NULL);
+
+ void defer(DeferStateStruct& deferStruct, const int level);
+ void replay(ReplayStateStruct& replayStruct, const int level);
void output(uint32_t level = 0);
@@ -426,6 +449,14 @@
}
private:
+ void outputViewProperties(const int level);
+
+ template <class T>
+ inline void setViewProperties(OpenGLRenderer& renderer, T& handler, const int level);
+
+ template <class T>
+ inline void iterate(OpenGLRenderer& renderer, T& handler, const int level);
+
void init();
void clearResources();
@@ -490,6 +521,22 @@
SkMatrix* mStaticMatrix;
SkMatrix* mAnimationMatrix;
bool mCaching;
+
+ /**
+ * State operations - needed to defer displayList property operations (for example, when setting
+ * an alpha causes a SaveLayerAlpha to occur). These operations point into mDisplayListData's
+ * allocation, or null if uninitialized.
+ *
+ * These are initialized (via friend constructors) when a displayList is issued in either replay
+ * or deferred mode. If replaying, the ops are not used until the next frame. If deferring, the
+ * ops may be stored in the DeferredDisplayList to be played back a second time.
+ *
+ * They should be used at most once per frame (one call to iterate)
+ */
+ ClipRectOp* mClipRectOp;
+ SaveLayerOp* mSaveLayerOp;
+ SaveOp* mSaveOp;
+ RestoreToCountOp* mRestoreToCountOp;
}; // class DisplayList
}; // namespace uirenderer
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h
index 4e6b552..9988bb8 100644
--- a/libs/hwui/DisplayListOp.h
+++ b/libs/hwui/DisplayListOp.h
@@ -78,17 +78,26 @@
kOpLogFlag_JSON = 0x2 // TODO: add?
};
- // If a DeferredDisplayList is supplied, DrawOps will be stored until the list is flushed
- // NOTE: complex clips and layers prevent deferral
- virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, int saveCount,
- uint32_t level, bool caching, int multipliedAlpha,
- DeferredDisplayList* deferredList) = 0;
+ virtual void defer(DeferStateStruct& deferStruct, int saveCount,
+ int level, int multipliedAlpha) = 0;
- virtual void output(int level, uint32_t flags = 0) = 0;
+ virtual void replay(ReplayStateStruct& replayStruct, int saveCount,
+ int level, int multipliedAlpha) = 0;
+
+ virtual void output(int level, uint32_t logFlags = 0) = 0;
// NOTE: it would be nice to declare constants and overriding the implementation in each op to
// point at the constants, but that seems to require a .cpp file
virtual const char* name() = 0;
+
+ /**
+ * Stores the relevant canvas state of the object between deferral and replay (if the canvas
+ * state supports being stored) See OpenGLRenderer::simpleClipAndState()
+ *
+ * TODO: don't reserve space for StateOps that won't be deferred
+ */
+ DeferredDisplayState state;
+
};
class StateOp : public DisplayListOp {
@@ -97,28 +106,22 @@
virtual ~StateOp() {}
+ virtual void defer(DeferStateStruct& deferStruct, int saveCount,
+ int level, int multipliedAlpha) {
+ // default behavior only affects immediate, deferrable state, issue directly to renderer
+ applyState(deferStruct.mRenderer, saveCount);
+ }
+
/**
* State operations are applied directly to the renderer, but can cause the deferred drawing op
* list to flush
*/
- virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, int saveCount,
- uint32_t level, bool caching, int multipliedAlpha, DeferredDisplayList* deferredList) {
- status_t status = DrawGlInfo::kStatusDone;
- if (deferredList && requiresDrawOpFlush(renderer)) {
- // will be setting renderer state that affects ops in deferredList, so flush list first
- status |= deferredList->flush(renderer, dirty, flags, level);
- }
- applyState(renderer, saveCount);
- return status;
+ virtual void replay(ReplayStateStruct& replayStruct, int saveCount,
+ int level, int multipliedAlpha) {
+ applyState(replayStruct.mRenderer, saveCount);
}
virtual void applyState(OpenGLRenderer& renderer, int saveCount) = 0;
-
- /**
- * Returns true if it affects renderer drawing state in such a way to break deferral
- * see OpenGLRenderer::disallowDeferral()
- */
- virtual bool requiresDrawOpFlush(OpenGLRenderer& renderer) { return false; }
};
class DrawOp : public DisplayListOp {
@@ -126,36 +129,35 @@
DrawOp(SkPaint* paint)
: mPaint(paint), mQuickRejected(false) {}
- /** Draw operations are stored in the deferredList with information necessary for playback */
- virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, int saveCount,
- uint32_t level, bool caching, int multipliedAlpha, DeferredDisplayList* deferredList) {
- if (mQuickRejected && CC_LIKELY(flags & DisplayList::kReplayFlag_ClipChildren)) {
- return DrawGlInfo::kStatusDone;
+ virtual void defer(DeferStateStruct& deferStruct, int saveCount,
+ int level, int multipliedAlpha) {
+ if (mQuickRejected &&
+ CC_LIKELY(deferStruct.mReplayFlags & DisplayList::kReplayFlag_ClipChildren)) {
+ return;
}
- if (!deferredList || renderer.disallowDeferral()) {
- // dispatch draw immediately, since the renderer's state is too complex for deferral
- return applyDraw(renderer, dirty, level, caching, multipliedAlpha);
- }
-
- if (!caching) multipliedAlpha = -1;
state.mMultipliedAlpha = multipliedAlpha;
if (!getLocalBounds(state.mBounds)) {
// empty bounds signify bounds can't be calculated
state.mBounds.setEmpty();
}
- if (!renderer.storeDisplayState(state)) {
- // op wasn't quick-rejected, so defer
- deferredList->add(this, renderer.getCaches().drawReorderDisabled);
- onDrawOpDeferred(renderer);
- }
-
- return DrawGlInfo::kStatusDone;
+ deferStruct.mDeferredList.addDrawOp(deferStruct.mRenderer, this);
}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) = 0;
+ virtual void replay(ReplayStateStruct& replayStruct, int saveCount,
+ int level, int multipliedAlpha) {
+ if (mQuickRejected &&
+ CC_LIKELY(replayStruct.mReplayFlags & DisplayList::kReplayFlag_ClipChildren)) {
+ return;
+ }
+
+ replayStruct.mDrawGlStatus |= applyDraw(replayStruct.mRenderer, replayStruct.mDirty,
+ level, multipliedAlpha);
+ }
+
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) = 0;
virtual void onDrawOpDeferred(OpenGLRenderer& renderer) {
}
@@ -174,11 +176,6 @@
float strokeWidthOutset() { return mPaint->getStrokeWidth() * 0.5f; }
- /**
- * Stores the relevant canvas state of the object between deferral and replay (if the canvas
- * state supports being stored) See OpenGLRenderer::simpleClipAndState()
- */
- DeferredDisplayState state;
protected:
SkPaint* getPaint(OpenGLRenderer& renderer, bool alwaysCopy = false) {
return renderer.filterPaint(mPaint, alwaysCopy);
@@ -225,88 +222,113 @@
///////////////////////////////////////////////////////////////////////////////
class SaveOp : public StateOp {
+ friend class DisplayList; // give DisplayList private constructor/reinit access
public:
SaveOp(int flags)
: mFlags(flags) {}
+ virtual void defer(DeferStateStruct& deferStruct, int saveCount,
+ int level, int multipliedAlpha) {
+ int newSaveCount = deferStruct.mRenderer.save(mFlags);
+ deferStruct.mDeferredList.addSave(deferStruct.mRenderer, this, newSaveCount);
+ }
+
virtual void applyState(OpenGLRenderer& renderer, int saveCount) {
renderer.save(mFlags);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Save flags %x", mFlags);
}
virtual const char* name() { return "Save"; }
+ int getFlags() const { return mFlags; }
private:
+ SaveOp() {}
+ DisplayListOp* reinit(int flags) {
+ mFlags = flags;
+ return this;
+ }
+
int mFlags;
};
class RestoreToCountOp : public StateOp {
+ friend class DisplayList; // give DisplayList private constructor/reinit access
public:
RestoreToCountOp(int count)
: mCount(count) {}
- virtual void applyState(OpenGLRenderer& renderer, int saveCount) {
- renderer.restoreToCount(saveCount + mCount);
-
+ virtual void defer(DeferStateStruct& deferStruct, int saveCount,
+ int level, int multipliedAlpha) {
+ deferStruct.mDeferredList.addRestoreToCount(deferStruct.mRenderer, saveCount + mCount);
+ deferStruct.mRenderer.restoreToCount(saveCount + mCount);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void applyState(OpenGLRenderer& renderer, int saveCount) {
+ renderer.restoreToCount(saveCount + mCount);
+ }
+
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Restore to count %d", mCount);
}
virtual const char* name() { return "RestoreToCount"; }
- // Note: don't have to return true for requiresDrawOpFlush - even though restore can create a
- // complex clip, the clip and matrix are overridden by DeferredDisplayList::flush()
private:
+ RestoreToCountOp() {}
+ DisplayListOp* reinit(int count) {
+ mCount = count;
+ return this;
+ }
+
int mCount;
};
class SaveLayerOp : public StateOp {
+ friend class DisplayList; // give DisplayList private constructor/reinit access
public:
- SaveLayerOp(float left, float top, float right, float bottom, SkPaint* paint, int flags)
- : mArea(left, top, right, bottom), mPaint(paint), mFlags(flags) {}
+ SaveLayerOp(float left, float top, float right, float bottom,
+ int alpha, SkXfermode::Mode mode, int flags)
+ : mArea(left, top, right, bottom), mAlpha(alpha), mMode(mode), mFlags(flags) {}
+
+ virtual void defer(DeferStateStruct& deferStruct, int saveCount,
+ int level, int multipliedAlpha) {
+ // NOTE: don't bother with actual saveLayer, instead issuing it at flush time
+ int newSaveCount = deferStruct.mRenderer.save(mFlags);
+ deferStruct.mDeferredList.addSaveLayer(deferStruct.mRenderer, this, newSaveCount);
+ }
virtual void applyState(OpenGLRenderer& renderer, int saveCount) {
- SkPaint* paint = renderer.filterPaint(mPaint);
- renderer.saveLayer(mArea.left, mArea.top, mArea.right, mArea.bottom, paint, mFlags);
+ renderer.saveLayer(mArea.left, mArea.top, mArea.right, mArea.bottom, mAlpha, mMode, mFlags);
}
- virtual void output(int level, uint32_t flags = 0) {
- OP_LOG("SaveLayer of area " RECT_STRING, RECT_ARGS(mArea));
+ virtual void output(int level, uint32_t logFlags) {
+ OP_LOG("SaveLayer%s of area " RECT_STRING,
+ (isSaveLayerAlpha() ? "Alpha" : ""),RECT_ARGS(mArea));
}
- virtual const char* name() { return "SaveLayer"; }
- virtual bool requiresDrawOpFlush(OpenGLRenderer& renderer) { return true; }
+ virtual const char* name() { return isSaveLayerAlpha() ? "SaveLayerAlpha" : "SaveLayer"; }
+
+ int getFlags() { return mFlags; }
private:
- Rect mArea;
- SkPaint* mPaint;
- int mFlags;
-};
-
-class SaveLayerAlphaOp : public StateOp {
-public:
- SaveLayerAlphaOp(float left, float top, float right, float bottom, int alpha, int flags)
- : mArea(left, top, right, bottom), mAlpha(alpha), mFlags(flags) {}
-
- virtual void applyState(OpenGLRenderer& renderer, int saveCount) {
- renderer.saveLayerAlpha(mArea.left, mArea.top, mArea.right, mArea.bottom, mAlpha, mFlags);
+ // Special case, reserved for direct DisplayList usage
+ SaveLayerOp() {}
+ DisplayListOp* reinit(float left, float top, float right, float bottom,
+ int alpha, SkXfermode::Mode mode, int flags) {
+ mArea.set(left, top, right, bottom);
+ mAlpha = alpha;
+ mMode = mode;
+ mFlags = flags;
+ return this;
}
- virtual void output(int level, uint32_t flags = 0) {
- OP_LOG("SaveLayerAlpha of area " RECT_STRING, RECT_ARGS(mArea));
- }
-
- virtual const char* name() { return "SaveLayerAlpha"; }
- virtual bool requiresDrawOpFlush(OpenGLRenderer& renderer) { return true; }
-
-private:
+ bool isSaveLayerAlpha() { return mAlpha < 255 && mMode == SkXfermode::kSrcOver_Mode; }
Rect mArea;
int mAlpha;
+ SkXfermode::Mode mMode;
int mFlags;
};
@@ -319,7 +341,7 @@
renderer.translate(mDx, mDy);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Translate by %f %f", mDx, mDy);
}
@@ -339,7 +361,7 @@
renderer.rotate(mDegrees);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Rotate by %f degrees", mDegrees);
}
@@ -358,7 +380,7 @@
renderer.scale(mSx, mSy);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Scale by %f %f", mSx, mSy);
}
@@ -378,7 +400,7 @@
renderer.skew(mSx, mSy);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Skew by %f %f", mSx, mSy);
}
@@ -398,7 +420,7 @@
renderer.setMatrix(mMatrix);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("SetMatrix " MATRIX_STRING, MATRIX_ARGS(mMatrix));
}
@@ -417,7 +439,7 @@
renderer.concatMatrix(mMatrix);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("ConcatMatrix " MATRIX_STRING, MATRIX_ARGS(mMatrix));
}
@@ -427,75 +449,97 @@
SkMatrix* mMatrix;
};
-class ClipRectOp : public StateOp {
+class ClipOp : public StateOp {
+public:
+ ClipOp(SkRegion::Op op) : mOp(op) {}
+
+ virtual void defer(DeferStateStruct& deferStruct, int saveCount,
+ int level, int multipliedAlpha) {
+ // NOTE: must defer op BEFORE applying state, since it may read clip
+ deferStruct.mDeferredList.addClip(deferStruct.mRenderer, this);
+
+ // TODO: Can we avoid applying complex clips at defer time?
+ applyState(deferStruct.mRenderer, saveCount);
+ }
+
+ bool canCauseComplexClip() {
+ return ((mOp != SkRegion::kIntersect_Op) && (mOp != SkRegion::kReplace_Op)) || !isRect();
+ }
+
+protected:
+ ClipOp() {}
+ virtual bool isRect() { return false; }
+
+ SkRegion::Op mOp;
+};
+
+class ClipRectOp : public ClipOp {
+ friend class DisplayList; // give DisplayList private constructor/reinit access
public:
ClipRectOp(float left, float top, float right, float bottom, SkRegion::Op op)
- : mArea(left, top, right, bottom), mOp(op) {}
+ : ClipOp(op), mArea(left, top, right, bottom) {}
virtual void applyState(OpenGLRenderer& renderer, int saveCount) {
renderer.clipRect(mArea.left, mArea.top, mArea.right, mArea.bottom, mOp);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("ClipRect " RECT_STRING, RECT_ARGS(mArea));
}
virtual const char* name() { return "ClipRect"; }
- virtual bool requiresDrawOpFlush(OpenGLRenderer& renderer) {
- // TODO: currently, we flush when we *might* cause a clip region to exist. Ideally, we
- // should only flush when a non-rectangular clip would result
- return !renderer.hasRectToRectTransform() || !hasRectToRectOp();
- }
+protected:
+ virtual bool isRect() { return true; }
private:
- inline bool hasRectToRectOp() {
- return mOp == SkRegion::kIntersect_Op || mOp == SkRegion::kReplace_Op;
+ ClipRectOp() {}
+ DisplayListOp* reinit(float left, float top, float right, float bottom, SkRegion::Op op) {
+ mOp = op;
+ mArea.set(left, top, right, bottom);
+ return this;
}
+
Rect mArea;
- SkRegion::Op mOp;
};
-class ClipPathOp : public StateOp {
+class ClipPathOp : public ClipOp {
public:
ClipPathOp(SkPath* path, SkRegion::Op op)
- : mPath(path), mOp(op) {}
+ : ClipOp(op), mPath(path) {}
virtual void applyState(OpenGLRenderer& renderer, int saveCount) {
renderer.clipPath(mPath, mOp);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
SkRect bounds = mPath->getBounds();
OP_LOG("ClipPath bounds " RECT_STRING,
bounds.left(), bounds.top(), bounds.right(), bounds.bottom());
}
virtual const char* name() { return "ClipPath"; }
- virtual bool requiresDrawOpFlush(OpenGLRenderer& renderer) { return true; }
private:
SkPath* mPath;
- SkRegion::Op mOp;
};
-class ClipRegionOp : public StateOp {
+class ClipRegionOp : public ClipOp {
public:
ClipRegionOp(SkRegion* region, SkRegion::Op op)
- : mRegion(region), mOp(op) {}
+ : ClipOp(op), mRegion(region) {}
virtual void applyState(OpenGLRenderer& renderer, int saveCount) {
renderer.clipRegion(mRegion, mOp);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
SkIRect bounds = mRegion->getBounds();
OP_LOG("ClipRegion bounds %d %d %d %d",
bounds.left(), bounds.top(), bounds.right(), bounds.bottom());
}
virtual const char* name() { return "ClipRegion"; }
- virtual bool requiresDrawOpFlush(OpenGLRenderer& renderer) { return true; }
private:
SkRegion* mRegion;
@@ -508,7 +552,7 @@
renderer.resetShader();
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOGS("ResetShader");
}
@@ -523,7 +567,7 @@
renderer.setupShader(mShader);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("SetupShader, shader %p", mShader);
}
@@ -539,7 +583,7 @@
renderer.resetColorFilter();
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOGS("ResetColorFilter");
}
@@ -555,7 +599,7 @@
renderer.setupColorFilter(mColorFilter);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("SetupColorFilter, filter %p", mColorFilter);
}
@@ -571,7 +615,7 @@
renderer.resetShadow();
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOGS("ResetShadow");
}
@@ -587,7 +631,7 @@
renderer.setupShadow(mRadius, mDx, mDy, mColor);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("SetupShadow, radius %f, %f, %f, color %#x", mRadius, mDx, mDy, mColor);
}
@@ -606,7 +650,7 @@
renderer.resetPaintFilter();
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOGS("ResetPaintFilter");
}
@@ -622,7 +666,7 @@
renderer.setupPaintFilter(mClearBits, mSetBits);
}
- virtual void output(int level, uint32_t flags = 0) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("SetupPaintFilter, clear %#x, set %#x", mClearBits, mSetBits);
}
@@ -645,9 +689,9 @@
paint),
mBitmap(bitmap) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
- bool makeCopy = caching && multipliedAlpha < 255;
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
+ bool makeCopy = multipliedAlpha >= 0 && multipliedAlpha < 255;
SkPaint* paint = getPaint(renderer, makeCopy);
if (makeCopy) {
// The paint is safe to modify since we're working on a copy
@@ -657,7 +701,7 @@
return ret;
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw bitmap %p at %f %f", mBitmap, mLocalBounds.left, mLocalBounds.top);
}
@@ -679,12 +723,12 @@
transform.mapRect(mLocalBounds);
}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawBitmap(mBitmap, mMatrix, getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw bitmap %p matrix " MATRIX_STRING, mBitmap, MATRIX_ARGS(mMatrix));
}
@@ -705,14 +749,14 @@
: DrawBoundedOp(dstLeft, dstTop, dstRight, dstBottom, paint),
mBitmap(bitmap), mSrc(srcLeft, srcTop, srcRight, srcBottom) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawBitmap(mBitmap, mSrc.left, mSrc.top, mSrc.right, mSrc.bottom,
mLocalBounds.left, mLocalBounds.top, mLocalBounds.right, mLocalBounds.bottom,
getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw bitmap %p src="RECT_STRING", dst="RECT_STRING,
mBitmap, RECT_ARGS(mSrc), RECT_ARGS(mLocalBounds));
}
@@ -732,13 +776,13 @@
DrawBitmapDataOp(SkBitmap* bitmap, float left, float top, SkPaint* paint)
: DrawBitmapOp(bitmap, left, top, paint) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawBitmapData(mBitmap, mLocalBounds.left,
mLocalBounds.top, getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw bitmap %p", mBitmap);
}
@@ -756,13 +800,13 @@
mBitmap(bitmap), mMeshWidth(meshWidth), mMeshHeight(meshHeight),
mVertices(vertices), mColors(colors) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawBitmapMesh(mBitmap, mMeshWidth, mMeshHeight,
mVertices, mColors, getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw bitmap %p mesh %d x %d", mBitmap, mMeshWidth, mMeshHeight);
}
@@ -790,8 +834,8 @@
mColors(colors), mxDivsCount(width), myDivsCount(height),
mNumColors(numColors), mAlpha(alpha), mMode(mode) {};
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
// NOTE: not calling the virtual method, which takes a paint
return renderer.drawPatch(mBitmap, mxDivs, myDivs, mColors,
mxDivsCount, myDivsCount, mNumColors,
@@ -799,7 +843,7 @@
mLocalBounds.right, mLocalBounds.bottom, mAlpha, mMode);
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw patch "RECT_STRING, RECT_ARGS(mLocalBounds));
}
@@ -825,12 +869,12 @@
DrawColorOp(int color, SkXfermode::Mode mode)
: DrawOp(0), mColor(color), mMode(mode) {};
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawColor(mColor, mMode);
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw color %#x, mode %d", mColor, mMode);
}
@@ -869,13 +913,13 @@
DrawRectOp(float left, float top, float right, float bottom, SkPaint* paint)
: DrawStrokableOp(left, top, right, bottom, paint) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawRect(mLocalBounds.left, mLocalBounds.top,
mLocalBounds.right, mLocalBounds.bottom, getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Rect "RECT_STRING, RECT_ARGS(mLocalBounds));
}
@@ -888,12 +932,12 @@
: DrawBoundedOp(rects, count, paint),
mRects(rects), mCount(count) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawRects(mRects, mCount, getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Rects count %d", mCount);
}
@@ -914,13 +958,13 @@
float rx, float ry, SkPaint* paint)
: DrawStrokableOp(left, top, right, bottom, paint), mRx(rx), mRy(ry) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawRoundRect(mLocalBounds.left, mLocalBounds.top,
mLocalBounds.right, mLocalBounds.bottom, mRx, mRy, getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw RoundRect "RECT_STRING", rx %f, ry %f", RECT_ARGS(mLocalBounds), mRx, mRy);
}
@@ -937,12 +981,12 @@
: DrawStrokableOp(x - radius, y - radius, x + radius, y + radius, paint),
mX(x), mY(y), mRadius(radius) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawCircle(mX, mY, mRadius, getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Circle x %f, y %f, r %f", mX, mY, mRadius);
}
@@ -959,13 +1003,13 @@
DrawOvalOp(float left, float top, float right, float bottom, SkPaint* paint)
: DrawStrokableOp(left, top, right, bottom, paint) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawOval(mLocalBounds.left, mLocalBounds.top,
mLocalBounds.right, mLocalBounds.bottom, getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Oval "RECT_STRING, RECT_ARGS(mLocalBounds));
}
@@ -979,14 +1023,14 @@
: DrawStrokableOp(left, top, right, bottom, paint),
mStartAngle(startAngle), mSweepAngle(sweepAngle), mUseCenter(useCenter) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawArc(mLocalBounds.left, mLocalBounds.top,
mLocalBounds.right, mLocalBounds.bottom,
mStartAngle, mSweepAngle, mUseCenter, getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Arc "RECT_STRING", start %f, sweep %f, useCenter %d",
RECT_ARGS(mLocalBounds), mStartAngle, mSweepAngle, mUseCenter);
}
@@ -1011,8 +1055,8 @@
mLocalBounds.set(left, top, left + width, top + height);
}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawPath(mPath, getPaint(renderer));
}
@@ -1021,7 +1065,7 @@
renderer.getCaches().pathCache.precache(mPath, paint);
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Path %p in "RECT_STRING, mPath, RECT_ARGS(mLocalBounds));
}
@@ -1042,12 +1086,12 @@
mLocalBounds.outset(strokeWidthOutset());
}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawLines(mPoints, mCount, getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Lines count %d", mCount);
}
@@ -1069,12 +1113,12 @@
DrawPointsOp(float* points, int count, SkPaint* paint)
: DrawLinesOp(points, count, paint) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawPoints(mPoints, mCount, getPaint(renderer));
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Points count %d", mCount);
}
@@ -1086,7 +1130,7 @@
DrawSomeTextOp(const char* text, int bytesCount, int count, SkPaint* paint)
: DrawOp(paint), mText(text), mBytesCount(bytesCount), mCount(count) {};
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw some text, %d bytes", mBytesCount);
}
@@ -1116,8 +1160,8 @@
/* TODO: inherit from DrawBounded and init mLocalBounds */
}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawTextOnPath(mText, mBytesCount, mCount, mPath,
mHOffset, mVOffset, getPaint(renderer));
}
@@ -1138,8 +1182,8 @@
/* TODO: inherit from DrawBounded and init mLocalBounds */
}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawPosText(mText, mBytesCount, mCount, mPositions, getPaint(renderer));
}
@@ -1187,13 +1231,13 @@
}
}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
return renderer.drawText(mText, mBytesCount, mCount, mX, mY,
mPositions, getPaint(renderer), mLength);
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Text of count %d, bytes %d", mCount, mBytesCount);
}
@@ -1225,15 +1269,15 @@
DrawFunctorOp(Functor* functor)
: DrawOp(0), mFunctor(functor) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
renderer.startMark("GL functor");
status_t ret = renderer.callDrawGLFunction(mFunctor, dirty);
renderer.endMark();
return ret;
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Functor %p", mFunctor);
}
@@ -1249,21 +1293,26 @@
: DrawBoundedOp(0, 0, displayList->getWidth(), displayList->getHeight(), 0),
mDisplayList(displayList), mFlags(flags) {}
- virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, int saveCount,
- uint32_t level, bool caching, int multipliedAlpha, DeferredDisplayList* deferredList) {
+ virtual void defer(DeferStateStruct& deferStruct, int saveCount,
+ int level, int multipliedAlpha) {
if (mDisplayList && mDisplayList->isRenderable()) {
- return mDisplayList->replay(renderer, dirty, mFlags, level + 1, deferredList);
+ mDisplayList->defer(deferStruct, level + 1);
}
- return DrawGlInfo::kStatusDone;
}
- // NOT USED, since replay is overridden
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) { return DrawGlInfo::kStatusDone; }
+ virtual void replay(ReplayStateStruct& replayStruct, int saveCount,
+ int level, int multipliedAlpha) {
+ if (mDisplayList && mDisplayList->isRenderable()) {
+ mDisplayList->replay(replayStruct, level + 1);
+ }
+ }
- virtual void output(int level, uint32_t flags) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) { return DrawGlInfo::kStatusDone; }
+
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Display List %p, flags %#x", mDisplayList, mFlags);
- if (mDisplayList && (flags & kOpLogFlag_Recurse)) {
+ if (mDisplayList && (logFlags & kOpLogFlag_Recurse)) {
mDisplayList->output(level + 1);
}
}
@@ -1280,11 +1329,11 @@
DrawLayerOp(Layer* layer, float x, float y, SkPaint* paint)
: DrawOp(paint), mLayer(layer), mX(x), mY(y) {}
- virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
- bool caching, int multipliedAlpha) {
+ virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, int level,
+ int multipliedAlpha) {
int oldAlpha = -1;
- if (caching && multipliedAlpha < 255) {
+ if (multipliedAlpha >= 0 && multipliedAlpha < 255) {
oldAlpha = mLayer->getAlpha();
mLayer->setAlpha(multipliedAlpha);
}
@@ -1295,7 +1344,7 @@
return ret;
}
- virtual void output(int level, uint32_t flags) {
+ virtual void output(int level, uint32_t logFlags) {
OP_LOG("Draw Layer %p at %f %f", mLayer, mX, mY);
}
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index b011443..8b5b54c 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "OpenGLRenderer"
#include <SkCamera.h>
+#include <SkCanvas.h>
#include <private/hwui/DrawGlInfo.h>
@@ -175,14 +176,8 @@
}
int DisplayListRenderer::saveLayer(float left, float top, float right, float bottom,
- SkPaint* p, int flags) {
- addStateOp(new (alloc()) SaveLayerOp(left, top, right, bottom, p, flags));
- return OpenGLRenderer::save(flags);
-}
-
-int DisplayListRenderer::saveLayerAlpha(float left, float top, float right, float bottom,
- int alpha, int flags) {
- addStateOp(new (alloc()) SaveLayerAlphaOp(left, top, right, bottom, alpha, flags));
+ int alpha, SkXfermode::Mode mode, int flags) {
+ addStateOp(new (alloc()) SaveLayerOp(left, top, right, bottom, alpha, mode, flags));
return OpenGLRenderer::save(flags);
}
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 38619bf..73b9b66 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -79,9 +79,7 @@
virtual void restoreToCount(int saveCount);
virtual int saveLayer(float left, float top, float right, float bottom,
- SkPaint* p, int flags);
- virtual int saveLayerAlpha(float left, float top, float right, float bottom,
- int alpha, int flags);
+ int alpha, SkXfermode::Mode mode, int flags);
virtual void translate(float dx, float dy);
virtual void rotate(float degrees);
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index f0dcb30..009dcb9 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -55,10 +55,7 @@
mGammaTable = NULL;
mInitialized = false;
mMaxNumberOfQuads = 1024;
- mCurrentQuadIndex = 0;
- mLastQuadIndex = 0;
- mTextMesh = NULL;
mCurrentCacheTexture = NULL;
mLinearFiltering = false;
@@ -114,8 +111,6 @@
// Unbinding the buffer shouldn't be necessary but it crashes with some drivers
Caches::getInstance().unbindIndicesBuffer();
glDeleteBuffers(1, &mIndexBufferID);
-
- delete[] mTextMesh;
}
LruCache<Font::FontDescription, Font*>::Iterator it(mActiveFonts);
@@ -126,9 +121,7 @@
}
void FontRenderer::flushAllAndInvalidate() {
- if (mCurrentQuadIndex != 0) {
- issueDrawCommand();
- }
+ issueDrawCommand();
LruCache<Font::FontDescription, Font*>::Iterator it(mActiveFonts);
while (it.next()) {
@@ -236,6 +229,9 @@
// Large-glyph texture memory is allocated only as needed
cacheTexture->allocateTexture();
}
+ if (!cacheTexture->mesh()) {
+ cacheTexture->allocateMesh();
+ }
// Tells us whether the glyphs is B&W (1 bit per pixel)
// or anti-aliased (8 bits per pixel)
@@ -307,11 +303,12 @@
}
CacheTexture* FontRenderer::createCacheTexture(int width, int height, bool allocate) {
- CacheTexture* cacheTexture = new CacheTexture(width, height);
+ CacheTexture* cacheTexture = new CacheTexture(width, height, mMaxNumberOfQuads);
if (allocate) {
Caches::getInstance().activeTexture(0);
cacheTexture->allocateTexture();
+ cacheTexture->allocateMesh();
}
return cacheTexture;
@@ -356,12 +353,6 @@
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexBufferSizeBytes, indexBufferData, GL_STATIC_DRAW);
free(indexBufferData);
-
- uint32_t coordSize = 2;
- uint32_t uvSize = 2;
- uint32_t vertsPerQuad = 4;
- uint32_t vertexBufferSize = mMaxNumberOfQuads * vertsPerQuad * coordSize * uvSize;
- mTextMesh = new float[vertexBufferSize];
}
// We don't want to allocate anything unless we actually draw text
@@ -376,15 +367,6 @@
mInitialized = true;
}
-void FontRenderer::updateDrawParams() {
- if (mCurrentQuadIndex != mLastQuadIndex) {
- mDrawOffsets.add((uint16_t*)(mLastQuadIndex * sizeof(uint16_t) * 6));
- mDrawCounts.add(mCurrentQuadIndex - mLastQuadIndex);
- mDrawCacheTextures.add(mCurrentCacheTexture);
- mLastQuadIndex = mCurrentQuadIndex;
- }
-}
-
void FontRenderer::checkTextureUpdate() {
if (!mUploadTexture) {
return;
@@ -424,76 +406,58 @@
}
void FontRenderer::issueDrawCommand() {
- updateDrawParams();
- checkTextureUpdate();
+ bool first = true;
+ bool force = false;
+ GLuint lastId = 0;
Caches& caches = Caches::getInstance();
- caches.bindIndicesBuffer(mIndexBufferID);
- if (!mDrawn) {
- float* buffer = mTextMesh;
- int offset = 2;
- bool force = caches.unbindMeshBuffer();
- caches.bindPositionVertexPointer(force, buffer);
- caches.bindTexCoordsVertexPointer(force, buffer + offset);
- }
+ for (uint32_t i = 0; i < mCacheTextures.size(); i++) {
+ CacheTexture* texture = mCacheTextures[i];
+ if (texture->canDraw()) {
+ if (first) {
+ checkTextureUpdate();
+ caches.bindIndicesBuffer(mIndexBufferID);
- for (uint32_t i = 0; i < mDrawOffsets.size(); i++) {
- uint16_t* offset = mDrawOffsets[i];
- uint32_t count = mDrawCounts[i];
- CacheTexture* texture = mDrawCacheTextures[i];
+ if (!mDrawn) {
+ // If returns true, a VBO was bound and we must
+ // rebind our vertex attrib pointers even if
+ // they have the same values as the current pointers
+ force = caches.unbindMeshBuffer();
+ }
- caches.activeTexture(0);
- glBindTexture(GL_TEXTURE_2D, texture->getTextureId());
+ caches.activeTexture(0);
+ first = false;
+ }
- texture->setLinearFiltering(mLinearFiltering, false);
+ glBindTexture(GL_TEXTURE_2D, texture->getTextureId());
+ texture->setLinearFiltering(mLinearFiltering, false);
- glDrawElements(GL_TRIANGLES, count * 6, GL_UNSIGNED_SHORT, offset);
+ TextureVertex* mesh = texture->mesh();
+ caches.bindPositionVertexPointer(force, &mesh[0].position[0]);
+ caches.bindTexCoordsVertexPointer(force, &mesh[0].texture[0]);
+ force = false;
+
+ glDrawElements(GL_TRIANGLES, texture->meshElementCount(),
+ GL_UNSIGNED_SHORT, texture->indices());
+
+ texture->resetMesh();
+ }
}
mDrawn = true;
-
- mCurrentQuadIndex = 0;
- mLastQuadIndex = 0;
- mDrawOffsets.clear();
- mDrawCounts.clear();
- mDrawCacheTextures.clear();
}
void FontRenderer::appendMeshQuadNoClip(float x1, float y1, float u1, float v1,
float x2, float y2, float u2, float v2, float x3, float y3, float u3, float v3,
float x4, float y4, float u4, float v4, CacheTexture* texture) {
if (texture != mCurrentCacheTexture) {
- updateDrawParams();
// Now use the new texture id
mCurrentCacheTexture = texture;
}
- const uint32_t vertsPerQuad = 4;
- const uint32_t floatsPerVert = 4;
- float* currentPos = mTextMesh + mCurrentQuadIndex * vertsPerQuad * floatsPerVert;
-
- (*currentPos++) = x1;
- (*currentPos++) = y1;
- (*currentPos++) = u1;
- (*currentPos++) = v1;
-
- (*currentPos++) = x2;
- (*currentPos++) = y2;
- (*currentPos++) = u2;
- (*currentPos++) = v2;
-
- (*currentPos++) = x3;
- (*currentPos++) = y3;
- (*currentPos++) = u3;
- (*currentPos++) = v3;
-
- (*currentPos++) = x4;
- (*currentPos++) = y4;
- (*currentPos++) = u4;
- (*currentPos++) = v4;
-
- mCurrentQuadIndex++;
+ mCurrentCacheTexture->addQuad(x1, y1, u1, v1, x2, y2, u2, v2,
+ x3, y3, u3, v3, x4, y4, u4, v4);
}
void FontRenderer::appendMeshQuad(float x1, float y1, float u1, float v1,
@@ -514,7 +478,7 @@
mBounds->bottom = fmax(mBounds->bottom, y1);
}
- if (mCurrentQuadIndex == mMaxNumberOfQuads) {
+ if (mCurrentCacheTexture->endOfMesh()) {
issueDrawCommand();
}
}
@@ -532,7 +496,7 @@
mBounds->bottom = fmax(mBounds->bottom, fmax(y1, fmax(y2, fmax(y3, y4))));
}
- if (mCurrentQuadIndex == mMaxNumberOfQuads) {
+ if (mCurrentCacheTexture->endOfMesh()) {
issueDrawCommand();
}
}
@@ -609,9 +573,7 @@
mBounds = NULL;
mClip = NULL;
- if (mCurrentQuadIndex != 0) {
- issueDrawCommand();
- }
+ issueDrawCommand();
}
void FontRenderer::precache(SkPaint* paint, const char* text, int numGlyphs, const mat4& matrix) {
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index d0c44ef..080cc71 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -28,6 +28,7 @@
#include "font/CacheTexture.h"
#include "font/CachedGlyphInfo.h"
#include "font/Font.h"
+#include "utils/SortedList.h"
#include "Matrix.h"
#include "Properties.h"
@@ -143,7 +144,6 @@
void removeFont(const Font* font);
- void updateDrawParams();
void checkTextureUpdate();
void setTextureDirty() {
@@ -164,12 +164,7 @@
bool mUploadTexture;
- // Pointer to vertex data to speed up frame to frame work
- float* mTextMesh;
- uint32_t mCurrentQuadIndex;
- uint32_t mLastQuadIndex;
uint32_t mMaxNumberOfQuads;
-
uint32_t mIndexBufferID;
const Rect* mClip;
@@ -180,10 +175,6 @@
bool mLinearFiltering;
- Vector<uint16_t*> mDrawOffsets;
- Vector<uint32_t> mDrawCounts;
- Vector<CacheTexture*> mDrawCacheTextures;
-
// RS constructs
sp<RSC::RS> mRs;
sp<const RSC::Element> mRsElement;
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 7fe0a69..e31f6f6 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -112,10 +112,7 @@
OpenGLRenderer::OpenGLRenderer():
mCaches(Caches::getInstance()), mExtensions(Extensions::getInstance()) {
- mDrawModifiers.mShader = NULL;
- mDrawModifiers.mColorFilter = NULL;
- mDrawModifiers.mHasShadow = false;
- mDrawModifiers.mHasDrawFilter = false;
+ resetDrawModifiers();
memcpy(mMeshVertices, gMeshVertices, sizeof(gMeshVertices));
@@ -635,38 +632,17 @@
///////////////////////////////////////////////////////////////////////////////
int OpenGLRenderer::saveLayer(float left, float top, float right, float bottom,
- SkPaint* p, int flags) {
+ int alpha, SkXfermode::Mode mode, int flags) {
const GLuint previousFbo = mSnapshot->fbo;
const int count = saveSnapshot(flags);
if (!mSnapshot->isIgnored()) {
- int alpha = 255;
- SkXfermode::Mode mode;
-
- if (p) {
- alpha = p->getAlpha();
- mode = getXfermode(p->getXfermode());
- } else {
- mode = SkXfermode::kSrcOver_Mode;
- }
-
createLayer(left, top, right, bottom, alpha, mode, flags, previousFbo);
}
return count;
}
-int OpenGLRenderer::saveLayerAlpha(float left, float top, float right, float bottom,
- int alpha, int flags) {
- if (alpha >= 255) {
- return saveLayer(left, top, right, bottom, NULL, flags);
- } else {
- SkPaint paint;
- paint.setAlpha(alpha);
- return saveLayer(left, top, right, bottom, &paint, flags);
- }
-}
-
/**
* Layers are viewed by Skia are slightly different than layers in image editing
* programs (for instance.) When a layer is created, previously created layers
@@ -1225,36 +1201,55 @@
// State Deferral
///////////////////////////////////////////////////////////////////////////////
-bool OpenGLRenderer::storeDisplayState(DeferredDisplayState& state) {
+void OpenGLRenderer::resetDrawModifiers() {
+ mDrawModifiers.mShader = NULL;
+ mDrawModifiers.mColorFilter = NULL;
+ mDrawModifiers.mHasShadow = false;
+ mDrawModifiers.mHasDrawFilter = false;
+}
+
+bool OpenGLRenderer::storeDisplayState(DeferredDisplayState& state, int stateDeferFlags) {
const Rect& currentClip = *(mSnapshot->clipRect);
const mat4& currentMatrix = *(mSnapshot->transform);
- // state only has bounds initialized in local coordinates
- if (!state.mBounds.isEmpty()) {
- currentMatrix.mapRect(state.mBounds);
- if (!state.mBounds.intersect(currentClip)) {
- // quick rejected
- return true;
+ if (stateDeferFlags & kStateDeferFlag_Draw) {
+ // state has bounds initialized in local coordinates
+ if (!state.mBounds.isEmpty()) {
+ currentMatrix.mapRect(state.mBounds);
+ if (!state.mBounds.intersect(currentClip)) {
+ // quick rejected
+ return true;
+ }
+ } else {
+ state.mBounds.set(currentClip);
}
- } else {
- state.mBounds.set(currentClip);
+ state.mDrawModifiers = mDrawModifiers;
+ state.mAlpha = mSnapshot->alpha;
}
- state.mClip.set(currentClip);
+ if (stateDeferFlags & kStateDeferFlag_Clip) {
+ state.mClip.set(currentClip);
+ } else {
+ state.mClip.setEmpty();
+ }
+
+ // transform always deferred
state.mMatrix.load(currentMatrix);
- state.mDrawModifiers = mDrawModifiers;
return false;
}
-void OpenGLRenderer::restoreDisplayState(const DeferredDisplayState& state) {
+void OpenGLRenderer::restoreDisplayState(const DeferredDisplayState& state, int stateDeferFlags) {
currentTransform().load(state.mMatrix);
- // NOTE: a clip RECT will be saved and restored, but DeferredDisplayState doesn't support
- // complex clips. In the future, we should add support for deferral of operations clipped by
- // these. for now, we don't defer with complex clips (see OpenGLRenderer::disallowDeferral())
- mSnapshot->setClip(state.mClip.left, state.mClip.top, state.mClip.right, state.mClip.bottom);
- dirtyClip();
- mDrawModifiers = state.mDrawModifiers;
+ if (stateDeferFlags & kStateDeferFlag_Draw) {
+ mDrawModifiers = state.mDrawModifiers;
+ mSnapshot->alpha = state.mAlpha;
+ }
+
+ if (!state.mClip.isEmpty()) { //stateDeferFlags & kStateDeferFlag_Clip) {
+ mSnapshot->setClip(state.mClip.left, state.mClip.top, state.mClip.right, state.mClip.bottom);
+ dirtyClip();
+ }
}
///////////////////////////////////////////////////////////////////////////////
@@ -1805,16 +1800,21 @@
// Drawing
///////////////////////////////////////////////////////////////////////////////
-status_t OpenGLRenderer::drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t flags) {
+status_t OpenGLRenderer::drawDisplayList(DisplayList* displayList, Rect& dirty,
+ int32_t replayFlags) {
// All the usual checks and setup operations (quickReject, setupDraw, etc.)
// will be performed by the display list itself
if (displayList && displayList->isRenderable()) {
- if (CC_UNLIKELY(mCaches.drawDeferDisabled)) {
- return displayList->replay(*this, dirty, flags, 0);
+ if (true || CC_UNLIKELY(mCaches.drawDeferDisabled)) { // NOTE: temporary workaround
+ ReplayStateStruct replayStruct(*this, dirty, replayFlags);
+ displayList->replay(replayStruct, 0);
+ return replayStruct.mDrawGlStatus;
}
DeferredDisplayList deferredList;
- return displayList->replay(*this, dirty, flags, 0, &deferredList);
+ DeferStateStruct deferStruct(deferredList, *this, replayFlags);
+ displayList->defer(deferStruct, 0);
+ return deferredList.flush(*this, dirty);
}
return DrawGlInfo::kStatusDone;
@@ -2257,9 +2257,11 @@
// TODO: try clipping large paths to viewport
PathTessellator::tessellatePath(path, paint, mSnapshot->transform, vertexBuffer);
- SkRect bounds = path.getBounds();
- PathTessellator::expandBoundsForStroke(bounds, paint, false);
- dirtyLayer(bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom, currentTransform());
+ if (hasLayer()) {
+ SkRect bounds = path.getBounds();
+ PathTessellator::expandBoundsForStroke(bounds, paint, false);
+ dirtyLayer(bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom, currentTransform());
+ }
return drawVertexBuffer(vertexBuffer, paint);
}
@@ -2389,7 +2391,7 @@
if (p->getPathEffect() != 0) {
mCaches.activeTexture(0);
- const PathTexture* texture = mCaches.roundRectShapeCache.getRoundRect(
+ const PathTexture* texture = mCaches.pathCache.getRoundRect(
right - left, bottom - top, rx, ry, p);
return drawShape(left, top, texture, p);
}
@@ -2413,7 +2415,7 @@
}
if (p->getPathEffect() != 0) {
mCaches.activeTexture(0);
- const PathTexture* texture = mCaches.circleShapeCache.getCircle(radius, p);
+ const PathTexture* texture = mCaches.pathCache.getCircle(radius, p);
return drawShape(x - radius, y - radius, texture, p);
}
@@ -2434,7 +2436,7 @@
if (p->getPathEffect() != 0) {
mCaches.activeTexture(0);
- const PathTexture* texture = mCaches.ovalShapeCache.getOval(right - left, bottom - top, p);
+ const PathTexture* texture = mCaches.pathCache.getOval(right - left, bottom - top, p);
return drawShape(left, top, texture, p);
}
@@ -2460,7 +2462,7 @@
// TODO: support fills (accounting for concavity if useCenter && sweepAngle > 180)
if (p->getStyle() != SkPaint::kStroke_Style || p->getPathEffect() != 0 || useCenter) {
mCaches.activeTexture(0);
- const PathTexture* texture = mCaches.arcShapeCache.getArc(right - left, bottom - top,
+ const PathTexture* texture = mCaches.pathCache.getArc(right - left, bottom - top,
startAngle, sweepAngle, useCenter, p);
return drawShape(left, top, texture, p);
}
@@ -2495,7 +2497,7 @@
p->getStrokeMiter() != SkPaintDefaults_MiterLimit) {
mCaches.activeTexture(0);
const PathTexture* texture =
- mCaches.rectShapeCache.getRect(right - left, bottom - top, p);
+ mCaches.pathCache.getRect(right - left, bottom - top, p);
return drawShape(left, top, texture, p);
}
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index e961af2..3aa9975 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -65,6 +65,11 @@
int mPaintFilterSetBits;
};
+enum StateDeferFlags {
+ kStateDeferFlag_Draw = 0x1,
+ kStateDeferFlag_Clip = 0x2
+};
+
struct DeferredDisplayState {
Rect mBounds; // local bounds, mapped with matrix to be in screen space coordinates, clipped.
int mMultipliedAlpha; // -1 if invalid (because caching not set)
@@ -72,8 +77,8 @@
// the below are set and used by the OpenGLRenderer at record and deferred playback
Rect mClip;
mat4 mMatrix;
- SkiaShader* mShader;
DrawModifiers mDrawModifiers;
+ float mAlpha;
};
///////////////////////////////////////////////////////////////////////////////
@@ -188,10 +193,18 @@
virtual void restore();
virtual void restoreToCount(int saveCount);
+ ANDROID_API int saveLayer(float left, float top, float right, float bottom,
+ SkPaint* paint, int flags) {
+ SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode;
+ if (paint) mode = getXfermode(paint->getXfermode());
+ return saveLayer(left, top, right, bottom, paint ? paint->getAlpha() : 255, mode, flags);
+ }
+ ANDROID_API int saveLayerAlpha(float left, float top, float right, float bottom,
+ int alpha, int flags) {
+ return saveLayer(left, top, right, bottom, alpha, SkXfermode::kSrcOver_Mode, flags);
+ }
virtual int saveLayer(float left, float top, float right, float bottom,
- SkPaint* p, int flags);
- virtual int saveLayerAlpha(float left, float top, float right, float bottom,
- int alpha, int flags);
+ int alpha, SkXfermode::Mode mode, int flags);
virtual void translate(float dx, float dy);
virtual void rotate(float degrees);
@@ -211,7 +224,7 @@
virtual bool clipRegion(SkRegion* region, SkRegion::Op op);
virtual Rect* getClipRect();
- virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t flags);
+ virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t replayFlags);
virtual void outputDisplayList(DisplayList* displayList);
virtual status_t drawLayer(Layer* layer, float x, float y, SkPaint* paint);
virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
@@ -261,21 +274,11 @@
SkPaint* filterPaint(SkPaint* paint, bool alwaysCopy = false);
- bool disallowDeferral() {
- // returns true if the OpenGLRenderer's state can be completely represented by
- // a DeferredDisplayState object
- return !mSnapshot->clipRegion->isEmpty() ||
- mSnapshot->alpha < 1.0 ||
- (mSnapshot->flags & Snapshot::kFlagIsLayer) ||
- (mSnapshot->flags & Snapshot::kFlagFboTarget); // ensure we're not in a layer
- }
+ void resetDrawModifiers();
+ bool storeDisplayState(DeferredDisplayState& state, int stateDeferFlags);
+ void restoreDisplayState(const DeferredDisplayState& state, int stateDeferFlags);
- bool storeDisplayState(DeferredDisplayState& state);
- void restoreDisplayState(const DeferredDisplayState& state);
-
- const DrawModifiers& getDrawModifiers() { return mDrawModifiers; }
- void setDrawModifiers(const DrawModifiers& drawModifiers) { mDrawModifiers = drawModifiers; }
-
+ // TODO: what does this mean? no perspective? no rotate?
ANDROID_API bool isCurrentTransformSimple() {
return mSnapshot->transform->isSimple();
}
@@ -284,6 +287,11 @@
return mCaches;
}
+ // simple rect clip
+ bool isCurrentClipSimple() {
+ return mSnapshot->clipRegion->isEmpty();
+ }
+
/**
* Sets the alpha on the current snapshot. This alpha value will be modulated
* with other alpha values when drawing primitives.
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index fb687cd..490c22a 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2013 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.
@@ -15,19 +15,301 @@
*/
#define LOG_TAG "OpenGLRenderer"
+#define ATRACE_TAG ATRACE_TAG_VIEW
-#include <utils/Mutex.h>
+#include <SkBitmap.h>
+#include <SkCanvas.h>
+#include <SkPaint.h>
+#include <SkPath.h>
+#include <SkRect.h>
-#include <sys/sysinfo.h>
+#include <utils/JenkinsHash.h>
+#include <utils/Trace.h>
#include "Caches.h"
#include "PathCache.h"
-#include "Properties.h"
+
+#include "thread/Signal.h"
+#include "thread/Task.h"
+#include "thread/TaskProcessor.h"
namespace android {
namespace uirenderer {
///////////////////////////////////////////////////////////////////////////////
+// Cache entries
+///////////////////////////////////////////////////////////////////////////////
+
+PathDescription::PathDescription():
+ type(kShapeNone),
+ join(SkPaint::kDefault_Join),
+ cap(SkPaint::kDefault_Cap),
+ style(SkPaint::kFill_Style),
+ miter(4.0f),
+ strokeWidth(1.0f),
+ pathEffect(NULL) {
+ memset(&shape, 0, sizeof(Shape));
+}
+
+PathDescription::PathDescription(ShapeType type, SkPaint* paint):
+ type(type),
+ join(paint->getStrokeJoin()),
+ cap(paint->getStrokeCap()),
+ style(paint->getStyle()),
+ miter(paint->getStrokeMiter()),
+ strokeWidth(paint->getStrokeWidth()),
+ pathEffect(paint->getPathEffect()) {
+ memset(&shape, 0, sizeof(Shape));
+}
+
+hash_t PathDescription::hash() const {
+ uint32_t hash = JenkinsHashMix(0, type);
+ hash = JenkinsHashMix(hash, join);
+ hash = JenkinsHashMix(hash, cap);
+ hash = JenkinsHashMix(hash, style);
+ hash = JenkinsHashMix(hash, android::hash_type(miter));
+ hash = JenkinsHashMix(hash, android::hash_type(strokeWidth));
+ hash = JenkinsHashMix(hash, android::hash_type(pathEffect));
+ hash = JenkinsHashMixBytes(hash, (uint8_t*) &shape, sizeof(Shape));
+ return JenkinsHashWhiten(hash);
+}
+
+int PathDescription::compare(const PathDescription& rhs) const {
+ return memcmp(this, &rhs, sizeof(PathDescription));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Utilities
+///////////////////////////////////////////////////////////////////////////////
+
+bool PathCache::canDrawAsConvexPath(SkPath* path, SkPaint* paint) {
+ // NOTE: This should only be used after PathTessellator handles joins properly
+ return paint->getPathEffect() == NULL && path->getConvexity() == SkPath::kConvex_Convexity;
+}
+
+void PathCache::computePathBounds(const SkPath* path, const SkPaint* paint,
+ float& left, float& top, float& offset, uint32_t& width, uint32_t& height) {
+ const SkRect& bounds = path->getBounds();
+ PathCache::computeBounds(bounds, paint, left, top, offset, width, height);
+}
+
+void PathCache::computeBounds(const SkRect& bounds, const SkPaint* paint,
+ float& left, float& top, float& offset, uint32_t& width, uint32_t& height) {
+ const float pathWidth = fmax(bounds.width(), 1.0f);
+ const float pathHeight = fmax(bounds.height(), 1.0f);
+
+ left = bounds.fLeft;
+ top = bounds.fTop;
+
+ offset = (int) floorf(fmax(paint->getStrokeWidth(), 1.0f) * 1.5f + 0.5f);
+
+ width = uint32_t(pathWidth + offset * 2.0 + 0.5);
+ height = uint32_t(pathHeight + offset * 2.0 + 0.5);
+}
+
+static void initBitmap(SkBitmap& bitmap, uint32_t width, uint32_t height) {
+ bitmap.setConfig(SkBitmap::kA8_Config, width, height);
+ bitmap.allocPixels();
+ bitmap.eraseColor(0);
+}
+
+static void initPaint(SkPaint& paint) {
+ // Make sure the paint is opaque, color, alpha, filter, etc.
+ // will be applied later when compositing the alpha8 texture
+ paint.setColor(0xff000000);
+ paint.setAlpha(255);
+ paint.setColorFilter(NULL);
+ paint.setMaskFilter(NULL);
+ paint.setShader(NULL);
+ SkXfermode* mode = SkXfermode::Create(SkXfermode::kSrc_Mode);
+ SkSafeUnref(paint.setXfermode(mode));
+}
+
+static void drawPath(const SkPath *path, const SkPaint* paint, SkBitmap& bitmap,
+ float left, float top, float offset, uint32_t width, uint32_t height) {
+ initBitmap(bitmap, width, height);
+
+ SkPaint pathPaint(*paint);
+ initPaint(pathPaint);
+
+ SkCanvas canvas(bitmap);
+ canvas.translate(-left + offset, -top + offset);
+ canvas.drawPath(*path, pathPaint);
+}
+
+static PathTexture* createTexture(float left, float top, float offset,
+ uint32_t width, uint32_t height, uint32_t id) {
+ PathTexture* texture = new PathTexture();
+ texture->left = left;
+ texture->top = top;
+ texture->offset = offset;
+ texture->width = width;
+ texture->height = height;
+ texture->generation = id;
+ return texture;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Cache constructor/destructor
+///////////////////////////////////////////////////////////////////////////////
+
+PathCache::PathCache():
+ mCache(LruCache<PathDescription, PathTexture*>::kUnlimitedCapacity),
+ mSize(0), mMaxSize(MB(DEFAULT_PATH_CACHE_SIZE)) {
+ char property[PROPERTY_VALUE_MAX];
+ if (property_get(PROPERTY_PATH_CACHE_SIZE, property, NULL) > 0) {
+ INIT_LOGD(" Setting %s cache size to %sMB", name, property);
+ setMaxSize(MB(atof(property)));
+ } else {
+ INIT_LOGD(" Using default %s cache size of %.2fMB", name, DEFAULT_PATH_CACHE_SIZE);
+ }
+ init();
+}
+
+PathCache::~PathCache() {
+ mCache.clear();
+}
+
+void PathCache::init() {
+ mCache.setOnEntryRemovedListener(this);
+
+ GLint maxTextureSize;
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
+ mMaxTextureSize = maxTextureSize;
+
+ mDebugEnabled = readDebugLevel() & kDebugCaches;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Size management
+///////////////////////////////////////////////////////////////////////////////
+
+uint32_t PathCache::getSize() {
+ return mSize;
+}
+
+uint32_t PathCache::getMaxSize() {
+ return mMaxSize;
+}
+
+void PathCache::setMaxSize(uint32_t maxSize) {
+ mMaxSize = maxSize;
+ while (mSize > mMaxSize) {
+ mCache.removeOldest();
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Callbacks
+///////////////////////////////////////////////////////////////////////////////
+
+void PathCache::operator()(PathDescription& entry, PathTexture*& texture) {
+ removeTexture(texture);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Caching
+///////////////////////////////////////////////////////////////////////////////
+
+void PathCache::removeTexture(PathTexture* texture) {
+ if (texture) {
+ const uint32_t size = texture->width * texture->height;
+ mSize -= size;
+
+ PATH_LOGD("PathCache::delete name, size, mSize = %d, %d, %d",
+ texture->id, size, mSize);
+ if (mDebugEnabled) {
+ ALOGD("Shape deleted, size = %d", size);
+ }
+
+ if (texture->id) {
+ glDeleteTextures(1, &texture->id);
+ }
+ delete texture;
+ }
+}
+
+void PathCache::purgeCache(uint32_t width, uint32_t height) {
+ const uint32_t size = width * height;
+ // Don't even try to cache a bitmap that's bigger than the cache
+ if (size < mMaxSize) {
+ while (mSize + size > mMaxSize) {
+ mCache.removeOldest();
+ }
+ }
+}
+
+void PathCache::trim() {
+ while (mSize > mMaxSize) {
+ mCache.removeOldest();
+ }
+}
+
+PathTexture* PathCache::addTexture(const PathDescription& entry, const SkPath *path,
+ const SkPaint* paint) {
+ ATRACE_CALL();
+
+ float left, top, offset;
+ uint32_t width, height;
+ computePathBounds(path, paint, left, top, offset, width, height);
+
+ if (!checkTextureSize(width, height)) return NULL;
+
+ purgeCache(width, height);
+
+ SkBitmap bitmap;
+ drawPath(path, paint, bitmap, left, top, offset, width, height);
+
+ PathTexture* texture = createTexture(left, top, offset, width, height,
+ path->getGenerationID());
+ addTexture(entry, &bitmap, texture);
+
+ return texture;
+}
+
+void PathCache::addTexture(const PathDescription& entry, SkBitmap* bitmap, PathTexture* texture) {
+ generateTexture(*bitmap, texture);
+
+ uint32_t size = texture->width * texture->height;
+ if (size < mMaxSize) {
+ mSize += size;
+ PATH_LOGD("PathCache::get/create: name, size, mSize = %d, %d, %d",
+ texture->id, size, mSize);
+ if (mDebugEnabled) {
+ ALOGD("Shape created, size = %d", size);
+ }
+ mCache.put(entry, texture);
+ } else {
+ texture->cleanup = true;
+ }
+}
+
+void PathCache::clear() {
+ mCache.clear();
+}
+
+void PathCache::generateTexture(SkBitmap& bitmap, Texture* texture) {
+ SkAutoLockPixels alp(bitmap);
+ if (!bitmap.readyToDraw()) {
+ ALOGE("Cannot generate texture from bitmap");
+ return;
+ }
+
+ glGenTextures(1, &texture->id);
+
+ glBindTexture(GL_TEXTURE_2D, texture->id);
+ // Textures are Alpha8
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ texture->blend = true;
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texture->width, texture->height, 0,
+ GL_ALPHA, GL_UNSIGNED_BYTE, bitmap.getPixels());
+
+ texture->setFilter(GL_LINEAR);
+ texture->setWrap(GL_CLAMP_TO_EDGE);
+}
+
+///////////////////////////////////////////////////////////////////////////////
// Path precaching
///////////////////////////////////////////////////////////////////////////////
@@ -52,7 +334,7 @@
if (width <= mMaxTextureSize && height <= mMaxTextureSize) {
SkBitmap* bitmap = new SkBitmap();
- PathCache::drawPath(t->path, t->paint, *bitmap, left, top, offset, width, height);
+ drawPath(t->path, t->paint, *bitmap, left, top, offset, width, height);
t->setResult(bitmap);
} else {
texture->width = 0;
@@ -62,23 +344,17 @@
}
///////////////////////////////////////////////////////////////////////////////
-// Path cache
+// Paths
///////////////////////////////////////////////////////////////////////////////
-PathCache::PathCache(): ShapeCache<PathCacheEntry>("path",
- PROPERTY_PATH_CACHE_SIZE, DEFAULT_PATH_CACHE_SIZE) {
-}
-
-PathCache::~PathCache() {
-}
-
void PathCache::remove(SkPath* path) {
- Vector<PathCacheEntry> pathsToRemove;
- LruCache<PathCacheEntry, PathTexture*>::Iterator i(mCache);
+ Vector<PathDescription> pathsToRemove;
+ LruCache<PathDescription, PathTexture*>::Iterator i(mCache);
while (i.next()) {
- const PathCacheEntry& key = i.key();
- if (key.path == path || key.path == path->getSourcePath()) {
+ const PathDescription& key = i.key();
+ if (key.type == kShapePath &&
+ (key.shape.path.mPath == path || key.shape.path.mPath == path->getSourcePath())) {
pathsToRemove.push(key);
}
}
@@ -121,7 +397,9 @@
PathTexture* PathCache::get(SkPath* path, SkPaint* paint) {
path = getSourcePath(path);
- PathCacheEntry entry(path, paint);
+ PathDescription entry(kShapePath, paint);
+ entry.shape.path.mPath = path;
+
PathTexture* texture = mCache.get(entry);
if (!texture) {
@@ -159,7 +437,9 @@
path = getSourcePath(path);
- PathCacheEntry entry(path, paint);
+ PathDescription entry(kShapePath, paint);
+ entry.shape.path.mPath = path;
+
PathTexture* texture = mCache.get(entry);
bool generate = false;
@@ -193,5 +473,130 @@
}
}
+///////////////////////////////////////////////////////////////////////////////
+// Rounded rects
+///////////////////////////////////////////////////////////////////////////////
+
+PathTexture* PathCache::getRoundRect(float width, float height,
+ float rx, float ry, SkPaint* paint) {
+ PathDescription entry(kShapeRoundRect, paint);
+ entry.shape.roundRect.mWidth = width;
+ entry.shape.roundRect.mHeight = height;
+ entry.shape.roundRect.mRx = rx;
+ entry.shape.roundRect.mRy = ry;
+
+ PathTexture* texture = get(entry);
+
+ if (!texture) {
+ SkPath path;
+ SkRect r;
+ r.set(0.0f, 0.0f, width, height);
+ path.addRoundRect(r, rx, ry, SkPath::kCW_Direction);
+
+ texture = addTexture(entry, &path, paint);
+ }
+
+ return texture;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Circles
+///////////////////////////////////////////////////////////////////////////////
+
+PathTexture* PathCache::getCircle(float radius, SkPaint* paint) {
+ PathDescription entry(kShapeCircle, paint);
+ entry.shape.circle.mRadius = radius;
+
+ PathTexture* texture = get(entry);
+
+ if (!texture) {
+ SkPath path;
+ path.addCircle(radius, radius, radius, SkPath::kCW_Direction);
+
+ texture = addTexture(entry, &path, paint);
+ }
+
+ return texture;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Ovals
+///////////////////////////////////////////////////////////////////////////////
+
+PathTexture* PathCache::getOval(float width, float height, SkPaint* paint) {
+ PathDescription entry(kShapeOval, paint);
+ entry.shape.oval.mWidth = width;
+ entry.shape.oval.mHeight = height;
+
+ PathTexture* texture = get(entry);
+
+ if (!texture) {
+ SkPath path;
+ SkRect r;
+ r.set(0.0f, 0.0f, width, height);
+ path.addOval(r, SkPath::kCW_Direction);
+
+ texture = addTexture(entry, &path, paint);
+ }
+
+ return texture;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Rects
+///////////////////////////////////////////////////////////////////////////////
+
+PathTexture* PathCache::getRect(float width, float height, SkPaint* paint) {
+ PathDescription entry(kShapeRect, paint);
+ entry.shape.rect.mWidth = width;
+ entry.shape.rect.mHeight = height;
+
+ PathTexture* texture = get(entry);
+
+ if (!texture) {
+ SkPath path;
+ SkRect r;
+ r.set(0.0f, 0.0f, width, height);
+ path.addRect(r, SkPath::kCW_Direction);
+
+ texture = addTexture(entry, &path, paint);
+ }
+
+ return texture;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Arcs
+///////////////////////////////////////////////////////////////////////////////
+
+PathTexture* PathCache::getArc(float width, float height,
+ float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
+ PathDescription entry(kShapeArc, paint);
+ entry.shape.arc.mWidth = width;
+ entry.shape.arc.mHeight = height;
+ entry.shape.arc.mStartAngle = startAngle;
+ entry.shape.arc.mSweepAngle = sweepAngle;
+ entry.shape.arc.mUseCenter = useCenter;
+
+ PathTexture* texture = get(entry);
+
+ if (!texture) {
+ SkPath path;
+ SkRect r;
+ r.set(0.0f, 0.0f, width, height);
+ if (useCenter) {
+ path.moveTo(r.centerX(), r.centerY());
+ }
+ path.arcTo(r, startAngle, sweepAngle, !useCenter);
+ if (useCenter) {
+ path.close();
+ }
+
+ texture = addTexture(entry, &path, paint);
+ }
+
+ return texture;
+}
+
}; // namespace uirenderer
}; // namespace android
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index 27031a5..e6d92df 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2013 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.
@@ -17,17 +17,21 @@
#ifndef ANDROID_HWUI_PATH_CACHE_H
#define ANDROID_HWUI_PATH_CACHE_H
-#include <utils/Thread.h>
+#include <GLES2/gl2.h>
+
+#include <utils/LruCache.h>
+#include <utils/Mutex.h>
#include <utils/Vector.h>
#include "Debug.h"
-#include "ShapeCache.h"
-#include "thread/Signal.h"
-#include "thread/Task.h"
-#include "thread/TaskProcessor.h"
+#include "Properties.h"
+#include "Texture.h"
+class SkBitmap;
+class SkCanvas;
class SkPaint;
class SkPath;
+class SkRect;
namespace android {
namespace uirenderer {
@@ -35,56 +39,181 @@
class Caches;
///////////////////////////////////////////////////////////////////////////////
+// Defines
+///////////////////////////////////////////////////////////////////////////////
+
+// Debug
+#if DEBUG_PATHS
+ #define PATH_LOGD(...) ALOGD(__VA_ARGS__)
+#else
+ #define PATH_LOGD(...)
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
// Classes
///////////////////////////////////////////////////////////////////////////////
-struct PathCacheEntry: public ShapeCacheEntry {
- PathCacheEntry(SkPath* path, SkPaint* paint):
- ShapeCacheEntry(ShapeCacheEntry::kShapePath, paint) {
- this->path = path;
+/**
+ * Alpha texture used to represent a path.
+ */
+struct PathTexture: public Texture {
+ PathTexture(): Texture() {
}
- PathCacheEntry(): ShapeCacheEntry() {
- path = NULL;
+ ~PathTexture() {
+ clearTask();
}
- hash_t hash() const {
- uint32_t hash = ShapeCacheEntry::hash();
- hash = JenkinsHashMix(hash, android::hash_type(path));
- return JenkinsHashWhiten(hash);
+ /**
+ * Left coordinate of the path bounds.
+ */
+ float left;
+ /**
+ * Top coordinate of the path bounds.
+ */
+ float top;
+ /**
+ * Offset to draw the path at the correct origin.
+ */
+ float offset;
+
+ sp<Task<SkBitmap*> > task() const {
+ return mTask;
}
- int compare(const ShapeCacheEntry& r) const {
- int deltaInt = ShapeCacheEntry::compare(r);
- if (deltaInt != 0) return deltaInt;
-
- const PathCacheEntry& rhs = (const PathCacheEntry&) r;
- return path - rhs.path;
+ void setTask(const sp<Task<SkBitmap*> >& task) {
+ mTask = task;
}
- SkPath* path;
+ void clearTask() {
+ if (mTask != NULL) {
+ mTask.clear();
+ }
+ }
-}; // PathCacheEntry
+private:
+ sp<Task<SkBitmap*> > mTask;
+}; // struct PathTexture
-inline hash_t hash_type(const PathCacheEntry& entry) {
- return entry.hash();
-}
+enum ShapeType {
+ kShapeNone,
+ kShapeRect,
+ kShapeRoundRect,
+ kShapeCircle,
+ kShapeOval,
+ kShapeArc,
+ kShapePath
+};
+
+struct PathDescription {
+ ShapeType type;
+ SkPaint::Join join;
+ SkPaint::Cap cap;
+ SkPaint::Style style;
+ float miter;
+ float strokeWidth;
+ SkPathEffect* pathEffect;
+ union Shape {
+ struct Path {
+ SkPath* mPath;
+ } path;
+ struct RoundRect {
+ float mWidth;
+ float mHeight;
+ float mRx;
+ float mRy;
+ } roundRect;
+ struct Circle {
+ float mRadius;
+ } circle;
+ struct Oval {
+ float mWidth;
+ float mHeight;
+ } oval;
+ struct Rect {
+ float mWidth;
+ float mHeight;
+ } rect;
+ struct Arc {
+ float mWidth;
+ float mHeight;
+ float mStartAngle;
+ float mSweepAngle;
+ bool mUseCenter;
+ } arc;
+ } shape;
+
+ PathDescription();
+ PathDescription(ShapeType shapeType, SkPaint* paint);
+
+ hash_t hash() const;
+
+ int compare(const PathDescription& rhs) const;
+
+ bool operator==(const PathDescription& other) const {
+ return compare(other) == 0;
+ }
+
+ bool operator!=(const PathDescription& other) const {
+ return compare(other) != 0;
+ }
+
+ friend inline int strictly_order_type(
+ const PathDescription& lhs, const PathDescription& rhs) {
+ return lhs.compare(rhs) < 0;
+ }
+
+ friend inline int compare_type(const PathDescription& lhs, const PathDescription& rhs) {
+ return lhs.compare(rhs);
+ }
+
+ friend inline hash_t hash_type(const PathDescription& entry) {
+ return entry.hash();
+ }
+};
/**
- * A simple LRU path cache. The cache has a maximum size expressed in bytes.
+ * A simple LRU shape cache. The cache has a maximum size expressed in bytes.
* Any texture added to the cache causing the cache to grow beyond the maximum
* allowed size will also cause the oldest texture to be kicked out.
*/
-class PathCache: public ShapeCache<PathCacheEntry> {
+class PathCache: public OnEntryRemoved<PathDescription, PathTexture*> {
public:
PathCache();
~PathCache();
/**
- * Returns the texture associated with the specified path. If the texture
- * cannot be found in the cache, a new texture is generated.
+ * Used as a callback when an entry is removed from the cache.
+ * Do not invoke directly.
*/
+ void operator()(PathDescription& path, PathTexture*& texture);
+
+ /**
+ * Clears the cache. This causes all textures to be deleted.
+ */
+ void clear();
+
+ /**
+ * Sets the maximum size of the cache in bytes.
+ */
+ void setMaxSize(uint32_t maxSize);
+ /**
+ * Returns the maximum size of the cache in bytes.
+ */
+ uint32_t getMaxSize();
+ /**
+ * Returns the current size of the cache in bytes.
+ */
+ uint32_t getSize();
+
+ PathTexture* getRoundRect(float width, float height, float rx, float ry, SkPaint* paint);
+ PathTexture* getCircle(float radius, SkPaint* paint);
+ PathTexture* getOval(float width, float height, SkPaint* paint);
+ PathTexture* getRect(float width, float height, SkPaint* paint);
+ PathTexture* getArc(float width, float height, float startAngle, float sweepAngle,
+ bool useCenter, SkPaint* paint);
PathTexture* get(SkPath* path, SkPaint* paint);
+
/**
* Removes an entry.
*/
@@ -98,10 +227,63 @@
* Process deferred removals.
*/
void clearGarbage();
+ /**
+ * Trims the contents of the cache, removing items until it's under its
+ * specified limit.
+ *
+ * Trimming is used for caches that support pre-caching from a worker
+ * thread. During pre-caching the maximum limit of the cache can be
+ * exceeded for the duration of the frame. It is therefore required to
+ * trim the cache at the end of the frame to keep the total amount of
+ * memory used under control.
+ */
+ void trim();
+ /**
+ * Precaches the specified path using background threads.
+ */
void precache(SkPath* path, SkPaint* paint);
+ static bool canDrawAsConvexPath(SkPath* path, SkPaint* paint);
+ static void computePathBounds(const SkPath* path, const SkPaint* paint,
+ float& left, float& top, float& offset, uint32_t& width, uint32_t& height);
+ static void computeBounds(const SkRect& bounds, const SkPaint* paint,
+ float& left, float& top, float& offset, uint32_t& width, uint32_t& height);
+
private:
+ PathTexture* addTexture(const PathDescription& entry,
+ const SkPath *path, const SkPaint* paint);
+ PathTexture* addTexture(const PathDescription& entry, SkBitmap* bitmap);
+ void addTexture(const PathDescription& entry, SkBitmap* bitmap, PathTexture* texture);
+
+ PathTexture* get(const PathDescription& entry) {
+ return mCache.get(entry);
+ }
+
+ /**
+ * Ensures there is enough space in the cache for a texture of the specified
+ * dimensions.
+ */
+ void purgeCache(uint32_t width, uint32_t height);
+
+ void removeTexture(PathTexture* texture);
+
+ bool checkTextureSize(uint32_t width, uint32_t height) {
+ if (width > mMaxTextureSize || height > mMaxTextureSize) {
+ ALOGW("Shape too large to be rendered into a texture (%dx%d, max=%dx%d)",
+ width, height, mMaxTextureSize, mMaxTextureSize);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Generates the texture from a bitmap into the specified texture structure.
+ */
+ void generateTexture(SkBitmap& bitmap, Texture* texture);
+
+ void init();
+
class PathTask: public Task<SkBitmap*> {
public:
PathTask(SkPath* path, SkPaint* paint, PathTexture* texture):
@@ -128,6 +310,13 @@
uint32_t mMaxTextureSize;
};
+ LruCache<PathDescription, PathTexture*> mCache;
+ uint32_t mSize;
+ uint32_t mMaxSize;
+ GLuint mMaxTextureSize;
+
+ bool mDebugEnabled;
+
sp<PathProcessor> mProcessor;
Vector<SkPath*> mGarbage;
mutable Mutex mLock;
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index b8559bc8..e4b4f3c 100644
--- a/libs/hwui/Properties.h
+++ b/libs/hwui/Properties.h
@@ -115,12 +115,11 @@
#define PROPERTY_RENDER_BUFFER_CACHE_SIZE "ro.hwui.r_buffer_cache_size"
#define PROPERTY_GRADIENT_CACHE_SIZE "ro.hwui.gradient_cache_size"
#define PROPERTY_PATH_CACHE_SIZE "ro.hwui.path_cache_size"
-#define PROPERTY_SHAPE_CACHE_SIZE "ro.hwui.shape_cache_size"
#define PROPERTY_DROP_SHADOW_CACHE_SIZE "ro.hwui.drop_shadow_cache_size"
#define PROPERTY_FBO_CACHE_SIZE "ro.hwui.fbo_cache_size"
// These properties are defined in percentage (range 0..1)
-#define PROPERTY_TEXTURE_CACHE_FLUSH_RATE "ro.hwui.texture_cache_flush_rate"
+#define PROPERTY_TEXTURE_CACHE_FLUSH_RATE "ro.hwui.texture_cache_flushrate"
// These properties are defined in pixels
#define PROPERTY_TEXT_SMALL_CACHE_WIDTH "ro.hwui.text_small_cache_width"
@@ -159,8 +158,7 @@
#define DEFAULT_TEXTURE_CACHE_SIZE 24.0f
#define DEFAULT_LAYER_CACHE_SIZE 16.0f
#define DEFAULT_RENDER_BUFFER_CACHE_SIZE 2.0f
-#define DEFAULT_PATH_CACHE_SIZE 4.0f
-#define DEFAULT_SHAPE_CACHE_SIZE 1.0f
+#define DEFAULT_PATH_CACHE_SIZE 10.0f
#define DEFAULT_PATCH_CACHE_SIZE 512
#define DEFAULT_GRADIENT_CACHE_SIZE 0.5f
#define DEFAULT_DROP_SHADOW_CACHE_SIZE 2.0f
diff --git a/libs/hwui/ShapeCache.cpp b/libs/hwui/ShapeCache.cpp
deleted file mode 100644
index 5a23235..0000000
--- a/libs/hwui/ShapeCache.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#define LOG_TAG "OpenGLRenderer"
-
-#include "ShapeCache.h"
-
-namespace android {
-namespace uirenderer {
-
-///////////////////////////////////////////////////////////////////////////////
-// Rounded rects
-///////////////////////////////////////////////////////////////////////////////
-
-RoundRectShapeCache::RoundRectShapeCache(): ShapeCache<RoundRectShapeCacheEntry>(
- "round rect", PROPERTY_SHAPE_CACHE_SIZE, DEFAULT_SHAPE_CACHE_SIZE) {
-}
-
-PathTexture* RoundRectShapeCache::getRoundRect(float width, float height,
- float rx, float ry, SkPaint* paint) {
- RoundRectShapeCacheEntry entry(width, height, rx, ry, paint);
- PathTexture* texture = get(entry);
-
- if (!texture) {
- SkPath path;
- SkRect r;
- r.set(0.0f, 0.0f, width, height);
- path.addRoundRect(r, rx, ry, SkPath::kCW_Direction);
-
- texture = addTexture(entry, &path, paint);
- }
-
- return texture;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Circles
-///////////////////////////////////////////////////////////////////////////////
-
-CircleShapeCache::CircleShapeCache(): ShapeCache<CircleShapeCacheEntry>(
- "circle", PROPERTY_SHAPE_CACHE_SIZE, DEFAULT_SHAPE_CACHE_SIZE) {
-}
-
-PathTexture* CircleShapeCache::getCircle(float radius, SkPaint* paint) {
- CircleShapeCacheEntry entry(radius, paint);
- PathTexture* texture = get(entry);
-
- if (!texture) {
- SkPath path;
- path.addCircle(radius, radius, radius, SkPath::kCW_Direction);
-
- texture = addTexture(entry, &path, paint);
- }
-
- return texture;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Ovals
-///////////////////////////////////////////////////////////////////////////////
-
-OvalShapeCache::OvalShapeCache(): ShapeCache<OvalShapeCacheEntry>(
- "oval", PROPERTY_SHAPE_CACHE_SIZE, DEFAULT_SHAPE_CACHE_SIZE) {
-}
-
-PathTexture* OvalShapeCache::getOval(float width, float height, SkPaint* paint) {
- OvalShapeCacheEntry entry(width, height, paint);
- PathTexture* texture = get(entry);
-
- if (!texture) {
- SkPath path;
- SkRect r;
- r.set(0.0f, 0.0f, width, height);
- path.addOval(r, SkPath::kCW_Direction);
-
- texture = addTexture(entry, &path, paint);
- }
-
- return texture;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Rects
-///////////////////////////////////////////////////////////////////////////////
-
-RectShapeCache::RectShapeCache(): ShapeCache<RectShapeCacheEntry>(
- "rect", PROPERTY_SHAPE_CACHE_SIZE, DEFAULT_SHAPE_CACHE_SIZE) {
-}
-
-PathTexture* RectShapeCache::getRect(float width, float height, SkPaint* paint) {
- RectShapeCacheEntry entry(width, height, paint);
- PathTexture* texture = get(entry);
-
- if (!texture) {
- SkRect bounds;
- bounds.set(0.0f, 0.0f, width, height);
-
- float left, top, offset;
- uint32_t rectWidth, rectHeight;
- computeBounds(bounds, paint, left, top, offset, rectWidth, rectHeight);
-
- if (!checkTextureSize(rectWidth, rectHeight)) return NULL;
-
- purgeCache(rectWidth, rectHeight);
-
- SkBitmap bitmap;
- initBitmap(bitmap, rectWidth, rectHeight);
-
- SkPaint pathPaint(*paint);
- initPaint(pathPaint);
-
- SkCanvas canvas(bitmap);
- canvas.translate(-left + offset, -top + offset);
- canvas.drawRect(bounds, pathPaint);
-
- texture = createTexture(0, 0, offset, rectWidth, rectHeight, 0);
- addTexture(entry, &bitmap, texture);
- }
-
- return texture;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Arcs
-///////////////////////////////////////////////////////////////////////////////
-
-ArcShapeCache::ArcShapeCache(): ShapeCache<ArcShapeCacheEntry>(
- "arc", PROPERTY_SHAPE_CACHE_SIZE, DEFAULT_SHAPE_CACHE_SIZE) {
-}
-
-PathTexture* ArcShapeCache::getArc(float width, float height,
- float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
- ArcShapeCacheEntry entry(width, height, startAngle, sweepAngle, useCenter, paint);
- PathTexture* texture = get(entry);
-
- if (!texture) {
- SkPath path;
- SkRect r;
- r.set(0.0f, 0.0f, width, height);
- if (useCenter) {
- path.moveTo(r.centerX(), r.centerY());
- }
- path.arcTo(r, startAngle, sweepAngle, !useCenter);
- if (useCenter) {
- path.close();
- }
-
- texture = addTexture(entry, &path, paint);
- }
-
- return texture;
-}
-
-}; // namespace uirenderer
-}; // namespace android
diff --git a/libs/hwui/ShapeCache.h b/libs/hwui/ShapeCache.h
deleted file mode 100644
index 92314b0..0000000
--- a/libs/hwui/ShapeCache.h
+++ /dev/null
@@ -1,816 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_HWUI_SHAPE_CACHE_H
-#define ANDROID_HWUI_SHAPE_CACHE_H
-
-#define ATRACE_TAG ATRACE_TAG_VIEW
-
-#include <GLES2/gl2.h>
-
-#include <SkBitmap.h>
-#include <SkCanvas.h>
-#include <SkPaint.h>
-#include <SkPath.h>
-#include <SkRect.h>
-
-#include <utils/JenkinsHash.h>
-#include <utils/LruCache.h>
-#include <utils/Trace.h>
-
-#include "Debug.h"
-#include "Properties.h"
-#include "Texture.h"
-#include "thread/Task.h"
-
-namespace android {
-namespace uirenderer {
-
-///////////////////////////////////////////////////////////////////////////////
-// Defines
-///////////////////////////////////////////////////////////////////////////////
-
-// Debug
-#if DEBUG_SHAPES
- #define SHAPE_LOGD(...) ALOGD(__VA_ARGS__)
-#else
- #define SHAPE_LOGD(...)
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
-// Classes
-///////////////////////////////////////////////////////////////////////////////
-
-/**
- * Alpha texture used to represent a path.
- */
-struct PathTexture: public Texture {
- PathTexture(): Texture() {
- }
-
- ~PathTexture() {
- clearTask();
- }
-
- /**
- * Left coordinate of the path bounds.
- */
- float left;
- /**
- * Top coordinate of the path bounds.
- */
- float top;
- /**
- * Offset to draw the path at the correct origin.
- */
- float offset;
-
- sp<Task<SkBitmap*> > task() const {
- return mTask;
- }
-
- void setTask(const sp<Task<SkBitmap*> >& task) {
- mTask = task;
- }
-
- void clearTask() {
- if (mTask != NULL) {
- mTask.clear();
- }
- }
-
-private:
- sp<Task<SkBitmap*> > mTask;
-}; // struct PathTexture
-
-/**
- * Describe a shape in the shape cache.
- */
-struct ShapeCacheEntry {
- enum ShapeType {
- kShapeNone,
- kShapeRect,
- kShapeRoundRect,
- kShapeCircle,
- kShapeOval,
- kShapeArc,
- kShapePath
- };
-
- ShapeCacheEntry() {
- shapeType = kShapeNone;
- join = SkPaint::kDefault_Join;
- cap = SkPaint::kDefault_Cap;
- style = SkPaint::kFill_Style;
- miter = 4.0f;
- strokeWidth = 1.0f;
- pathEffect = NULL;
- }
-
- ShapeCacheEntry(ShapeType type, SkPaint* paint) {
- shapeType = type;
- join = paint->getStrokeJoin();
- cap = paint->getStrokeCap();
- miter = paint->getStrokeMiter();
- strokeWidth = paint->getStrokeWidth();
- style = paint->getStyle();
- pathEffect = paint->getPathEffect();
- }
-
- virtual ~ShapeCacheEntry() {
- }
-
- virtual hash_t hash() const {
- uint32_t hash = JenkinsHashMix(0, shapeType);
- hash = JenkinsHashMix(hash, join);
- hash = JenkinsHashMix(hash, cap);
- hash = JenkinsHashMix(hash, style);
- hash = JenkinsHashMix(hash, android::hash_type(miter));
- hash = JenkinsHashMix(hash, android::hash_type(strokeWidth));
- hash = JenkinsHashMix(hash, android::hash_type(pathEffect));
- return JenkinsHashWhiten(hash);
- }
-
- virtual int compare(const ShapeCacheEntry& rhs) const {
- int deltaInt = shapeType - rhs.shapeType;
- if (deltaInt != 0) return deltaInt;
-
- deltaInt = join - rhs.join;
- if (deltaInt != 0) return deltaInt;
-
- deltaInt = cap - rhs.cap;
- if (deltaInt != 0) return deltaInt;
-
- deltaInt = style - rhs.style;
- if (deltaInt != 0) return deltaInt;
-
- if (miter < rhs.miter) return -1;
- if (miter > rhs.miter) return +1;
-
- if (strokeWidth < rhs.strokeWidth) return -1;
- if (strokeWidth > rhs.strokeWidth) return +1;
-
- if (pathEffect < rhs.pathEffect) return -1;
- if (pathEffect > rhs.pathEffect) return +1;
-
- return 0;
- }
-
- bool operator==(const ShapeCacheEntry& other) const {
- return compare(other) == 0;
- }
-
- bool operator!=(const ShapeCacheEntry& other) const {
- return compare(other) != 0;
- }
-
- ShapeType shapeType;
- SkPaint::Join join;
- SkPaint::Cap cap;
- SkPaint::Style style;
- float miter;
- float strokeWidth;
- SkPathEffect* pathEffect;
-}; // struct ShapeCacheEntry
-
-// Cache support
-
-inline int strictly_order_type(const ShapeCacheEntry& lhs, const ShapeCacheEntry& rhs) {
- return lhs.compare(rhs) < 0;
-}
-
-inline int compare_type(const ShapeCacheEntry& lhs, const ShapeCacheEntry& rhs) {
- return lhs.compare(rhs);
-}
-
-inline hash_t hash_type(const ShapeCacheEntry& entry) {
- return entry.hash();
-}
-
-struct RoundRectShapeCacheEntry: public ShapeCacheEntry {
- RoundRectShapeCacheEntry(float width, float height, float rx, float ry, SkPaint* paint):
- ShapeCacheEntry(ShapeCacheEntry::kShapeRoundRect, paint) {
- mWidth = width;
- mHeight = height;
- mRx = rx;
- mRy = ry;
- }
-
- RoundRectShapeCacheEntry(): ShapeCacheEntry() {
- mWidth = 0;
- mHeight = 0;
- mRx = 0;
- mRy = 0;
- }
-
- hash_t hash() const {
- uint32_t hash = ShapeCacheEntry::hash();
- hash = JenkinsHashMix(hash, android::hash_type(mWidth));
- hash = JenkinsHashMix(hash, android::hash_type(mHeight));
- hash = JenkinsHashMix(hash, android::hash_type(mRx));
- hash = JenkinsHashMix(hash, android::hash_type(mRy));
- return JenkinsHashWhiten(hash);
- }
-
- int compare(const ShapeCacheEntry& r) const {
- int deltaInt = ShapeCacheEntry::compare(r);
- if (deltaInt != 0) return deltaInt;
-
- const RoundRectShapeCacheEntry& rhs = (const RoundRectShapeCacheEntry&) r;
-
- if (mWidth < rhs.mWidth) return -1;
- if (mWidth > rhs.mWidth) return +1;
-
- if (mHeight < rhs.mHeight) return -1;
- if (mHeight > rhs.mHeight) return +1;
-
- if (mRx < rhs.mRx) return -1;
- if (mRx > rhs.mRx) return +1;
-
- if (mRy < rhs.mRy) return -1;
- if (mRy > rhs.mRy) return +1;
-
- return 0;
- }
-
-private:
- float mWidth;
- float mHeight;
- float mRx;
- float mRy;
-}; // RoundRectShapeCacheEntry
-
-inline hash_t hash_type(const RoundRectShapeCacheEntry& entry) {
- return entry.hash();
-}
-
-struct CircleShapeCacheEntry: public ShapeCacheEntry {
- CircleShapeCacheEntry(float radius, SkPaint* paint):
- ShapeCacheEntry(ShapeCacheEntry::kShapeCircle, paint) {
- mRadius = radius;
- }
-
- CircleShapeCacheEntry(): ShapeCacheEntry() {
- mRadius = 0;
- }
-
- hash_t hash() const {
- uint32_t hash = ShapeCacheEntry::hash();
- hash = JenkinsHashMix(hash, android::hash_type(mRadius));
- return JenkinsHashWhiten(hash);
- }
-
- int compare(const ShapeCacheEntry& r) const {
- int deltaInt = ShapeCacheEntry::compare(r);
- if (deltaInt != 0) return deltaInt;
-
- const CircleShapeCacheEntry& rhs = (const CircleShapeCacheEntry&) r;
-
- if (mRadius < rhs.mRadius) return -1;
- if (mRadius > rhs.mRadius) return +1;
-
- return 0;
- }
-
-private:
- float mRadius;
-}; // CircleShapeCacheEntry
-
-inline hash_t hash_type(const CircleShapeCacheEntry& entry) {
- return entry.hash();
-}
-
-struct OvalShapeCacheEntry: public ShapeCacheEntry {
- OvalShapeCacheEntry(float width, float height, SkPaint* paint):
- ShapeCacheEntry(ShapeCacheEntry::kShapeOval, paint) {
- mWidth = width;
- mHeight = height;
- }
-
- OvalShapeCacheEntry(): ShapeCacheEntry() {
- mWidth = mHeight = 0;
- }
-
- hash_t hash() const {
- uint32_t hash = ShapeCacheEntry::hash();
- hash = JenkinsHashMix(hash, android::hash_type(mWidth));
- hash = JenkinsHashMix(hash, android::hash_type(mHeight));
- return JenkinsHashWhiten(hash);
- }
-
- int compare(const ShapeCacheEntry& r) const {
- int deltaInt = ShapeCacheEntry::compare(r);
- if (deltaInt != 0) return deltaInt;
-
- const OvalShapeCacheEntry& rhs = (const OvalShapeCacheEntry&) r;
-
- if (mWidth < rhs.mWidth) return -1;
- if (mWidth > rhs.mWidth) return +1;
-
- if (mHeight < rhs.mHeight) return -1;
- if (mHeight > rhs.mHeight) return +1;
-
- return 0;
- }
-
-private:
- float mWidth;
- float mHeight;
-}; // OvalShapeCacheEntry
-
-inline hash_t hash_type(const OvalShapeCacheEntry& entry) {
- return entry.hash();
-}
-
-struct RectShapeCacheEntry: public ShapeCacheEntry {
- RectShapeCacheEntry(float width, float height, SkPaint* paint):
- ShapeCacheEntry(ShapeCacheEntry::kShapeRect, paint) {
- mWidth = width;
- mHeight = height;
- }
-
- RectShapeCacheEntry(): ShapeCacheEntry() {
- mWidth = mHeight = 0;
- }
-
- hash_t hash() const {
- uint32_t hash = ShapeCacheEntry::hash();
- hash = JenkinsHashMix(hash, android::hash_type(mWidth));
- hash = JenkinsHashMix(hash, android::hash_type(mHeight));
- return JenkinsHashWhiten(hash);
- }
-
- int compare(const ShapeCacheEntry& r) const {
- int deltaInt = ShapeCacheEntry::compare(r);
- if (deltaInt != 0) return deltaInt;
-
- const RectShapeCacheEntry& rhs = (const RectShapeCacheEntry&) r;
-
- if (mWidth < rhs.mWidth) return -1;
- if (mWidth > rhs.mWidth) return +1;
-
- if (mHeight < rhs.mHeight) return -1;
- if (mHeight > rhs.mHeight) return +1;
-
- return 0;
- }
-
-private:
- float mWidth;
- float mHeight;
-}; // RectShapeCacheEntry
-
-inline hash_t hash_type(const RectShapeCacheEntry& entry) {
- return entry.hash();
-}
-
-struct ArcShapeCacheEntry: public ShapeCacheEntry {
- ArcShapeCacheEntry(float width, float height, float startAngle, float sweepAngle,
- bool useCenter, SkPaint* paint):
- ShapeCacheEntry(ShapeCacheEntry::kShapeArc, paint) {
- mWidth = width;
- mHeight = height;
- mStartAngle = startAngle;
- mSweepAngle = sweepAngle;
- mUseCenter = useCenter ? 1 : 0;
- }
-
- ArcShapeCacheEntry(): ShapeCacheEntry() {
- mWidth = 0;
- mHeight = 0;
- mStartAngle = 0;
- mSweepAngle = 0;
- mUseCenter = 0;
- }
-
- hash_t hash() const {
- uint32_t hash = ShapeCacheEntry::hash();
- hash = JenkinsHashMix(hash, android::hash_type(mWidth));
- hash = JenkinsHashMix(hash, android::hash_type(mHeight));
- hash = JenkinsHashMix(hash, android::hash_type(mStartAngle));
- hash = JenkinsHashMix(hash, android::hash_type(mSweepAngle));
- hash = JenkinsHashMix(hash, mUseCenter);
- return JenkinsHashWhiten(hash);
- }
-
- int compare(const ShapeCacheEntry& r) const {
- int deltaInt = ShapeCacheEntry::compare(r);
- if (deltaInt != 0) return deltaInt;
-
- const ArcShapeCacheEntry& rhs = (const ArcShapeCacheEntry&) r;
-
- if (mWidth < rhs.mWidth) return -1;
- if (mWidth > rhs.mWidth) return +1;
-
- if (mHeight < rhs.mHeight) return -1;
- if (mHeight > rhs.mHeight) return +1;
-
- if (mStartAngle < rhs.mStartAngle) return -1;
- if (mStartAngle > rhs.mStartAngle) return +1;
-
- if (mSweepAngle < rhs.mSweepAngle) return -1;
- if (mSweepAngle > rhs.mSweepAngle) return +1;
-
- return mUseCenter - rhs.mUseCenter;
- }
-
-private:
- float mWidth;
- float mHeight;
- float mStartAngle;
- float mSweepAngle;
- uint32_t mUseCenter;
-}; // ArcShapeCacheEntry
-
-inline hash_t hash_type(const ArcShapeCacheEntry& entry) {
- return entry.hash();
-}
-
-/**
- * A simple LRU shape cache. The cache has a maximum size expressed in bytes.
- * Any texture added to the cache causing the cache to grow beyond the maximum
- * allowed size will also cause the oldest texture to be kicked out.
- */
-template<typename Entry>
-class ShapeCache: public OnEntryRemoved<Entry, PathTexture*> {
-public:
- ShapeCache(const char* name, const char* propertyName, float defaultSize);
- ~ShapeCache();
-
- /**
- * Used as a callback when an entry is removed from the cache.
- * Do not invoke directly.
- */
- void operator()(Entry& path, PathTexture*& texture);
-
- /**
- * Clears the cache. This causes all textures to be deleted.
- */
- void clear();
-
- /**
- * Sets the maximum size of the cache in bytes.
- */
- void setMaxSize(uint32_t maxSize);
- /**
- * Returns the maximum size of the cache in bytes.
- */
- uint32_t getMaxSize();
- /**
- * Returns the current size of the cache in bytes.
- */
- uint32_t getSize();
-
- /**
- * Trims the contents of the cache, removing items until it's under its
- * specified limit.
- *
- * Trimming is used for caches that support pre-caching from a worker
- * thread. During pre-caching the maximum limit of the cache can be
- * exceeded for the duration of the frame. It is therefore required to
- * trim the cache at the end of the frame to keep the total amount of
- * memory used under control.
- *
- * Only the PathCache currently supports pre-caching.
- */
- void trim();
-
- static void computePathBounds(const SkPath* path, const SkPaint* paint,
- float& left, float& top, float& offset, uint32_t& width, uint32_t& height) {
- const SkRect& bounds = path->getBounds();
- computeBounds(bounds, paint, left, top, offset, width, height);
- }
-
- static void computeBounds(const SkRect& bounds, const SkPaint* paint,
- float& left, float& top, float& offset, uint32_t& width, uint32_t& height) {
- const float pathWidth = fmax(bounds.width(), 1.0f);
- const float pathHeight = fmax(bounds.height(), 1.0f);
-
- left = bounds.fLeft;
- top = bounds.fTop;
-
- offset = (int) floorf(fmax(paint->getStrokeWidth(), 1.0f) * 1.5f + 0.5f);
-
- width = uint32_t(pathWidth + offset * 2.0 + 0.5);
- height = uint32_t(pathHeight + offset * 2.0 + 0.5);
- }
-
- static void drawPath(const SkPath *path, const SkPaint* paint, SkBitmap& bitmap,
- float left, float top, float offset, uint32_t width, uint32_t height) {
- initBitmap(bitmap, width, height);
-
- SkPaint pathPaint(*paint);
- initPaint(pathPaint);
-
- SkCanvas canvas(bitmap);
- canvas.translate(-left + offset, -top + offset);
- canvas.drawPath(*path, pathPaint);
- }
-
-protected:
- PathTexture* addTexture(const Entry& entry, const SkPath *path, const SkPaint* paint);
- PathTexture* addTexture(const Entry& entry, SkBitmap* bitmap);
- void addTexture(const Entry& entry, SkBitmap* bitmap, PathTexture* texture);
-
- /**
- * Ensures there is enough space in the cache for a texture of the specified
- * dimensions.
- */
- void purgeCache(uint32_t width, uint32_t height);
-
- PathTexture* get(Entry entry) {
- return mCache.get(entry);
- }
-
- void removeTexture(PathTexture* texture);
-
- bool checkTextureSize(uint32_t width, uint32_t height) {
- if (width > mMaxTextureSize || height > mMaxTextureSize) {
- ALOGW("Shape %s too large to be rendered into a texture (%dx%d, max=%dx%d)",
- mName, width, height, mMaxTextureSize, mMaxTextureSize);
- return false;
- }
- return true;
- }
-
- static PathTexture* createTexture(float left, float top, float offset,
- uint32_t width, uint32_t height, uint32_t id) {
- PathTexture* texture = new PathTexture();
- texture->left = left;
- texture->top = top;
- texture->offset = offset;
- texture->width = width;
- texture->height = height;
- texture->generation = id;
- return texture;
- }
-
- static void initBitmap(SkBitmap& bitmap, uint32_t width, uint32_t height) {
- bitmap.setConfig(SkBitmap::kA8_Config, width, height);
- bitmap.allocPixels();
- bitmap.eraseColor(0);
- }
-
- static void initPaint(SkPaint& paint) {
- // Make sure the paint is opaque, color, alpha, filter, etc.
- // will be applied later when compositing the alpha8 texture
- paint.setColor(0xff000000);
- paint.setAlpha(255);
- paint.setColorFilter(NULL);
- paint.setMaskFilter(NULL);
- paint.setShader(NULL);
- SkXfermode* mode = SkXfermode::Create(SkXfermode::kSrc_Mode);
- SkSafeUnref(paint.setXfermode(mode));
- }
-
- LruCache<Entry, PathTexture*> mCache;
- uint32_t mSize;
- uint32_t mMaxSize;
- GLuint mMaxTextureSize;
-
- char* mName;
- bool mDebugEnabled;
-
-private:
- /**
- * Generates the texture from a bitmap into the specified texture structure.
- */
- void generateTexture(SkBitmap& bitmap, Texture* texture);
-
- void init();
-}; // class ShapeCache
-
-class RoundRectShapeCache: public ShapeCache<RoundRectShapeCacheEntry> {
-public:
- RoundRectShapeCache();
-
- PathTexture* getRoundRect(float width, float height, float rx, float ry, SkPaint* paint);
-}; // class RoundRectShapeCache
-
-class CircleShapeCache: public ShapeCache<CircleShapeCacheEntry> {
-public:
- CircleShapeCache();
-
- PathTexture* getCircle(float radius, SkPaint* paint);
-}; // class CircleShapeCache
-
-class OvalShapeCache: public ShapeCache<OvalShapeCacheEntry> {
-public:
- OvalShapeCache();
-
- PathTexture* getOval(float width, float height, SkPaint* paint);
-}; // class OvalShapeCache
-
-class RectShapeCache: public ShapeCache<RectShapeCacheEntry> {
-public:
- RectShapeCache();
-
- PathTexture* getRect(float width, float height, SkPaint* paint);
-}; // class RectShapeCache
-
-class ArcShapeCache: public ShapeCache<ArcShapeCacheEntry> {
-public:
- ArcShapeCache();
-
- PathTexture* getArc(float width, float height, float startAngle, float sweepAngle,
- bool useCenter, SkPaint* paint);
-}; // class ArcShapeCache
-
-///////////////////////////////////////////////////////////////////////////////
-// Constructors/destructor
-///////////////////////////////////////////////////////////////////////////////
-
-template<class Entry>
-ShapeCache<Entry>::ShapeCache(const char* name, const char* propertyName, float defaultSize):
- mCache(LruCache<ShapeCacheEntry, PathTexture*>::kUnlimitedCapacity),
- mSize(0), mMaxSize(MB(defaultSize)) {
- char property[PROPERTY_VALUE_MAX];
- if (property_get(propertyName, property, NULL) > 0) {
- INIT_LOGD(" Setting %s cache size to %sMB", name, property);
- setMaxSize(MB(atof(property)));
- } else {
- INIT_LOGD(" Using default %s cache size of %.2fMB", name, defaultSize);
- }
-
- size_t len = strlen(name);
- mName = new char[len + 1];
- strcpy(mName, name);
- mName[len] = '\0';
-
- init();
-}
-
-template<class Entry>
-ShapeCache<Entry>::~ShapeCache() {
- mCache.clear();
- delete[] mName;
-}
-
-template<class Entry>
-void ShapeCache<Entry>::init() {
- mCache.setOnEntryRemovedListener(this);
-
- GLint maxTextureSize;
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
- mMaxTextureSize = maxTextureSize;
-
- mDebugEnabled = readDebugLevel() & kDebugCaches;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Size management
-///////////////////////////////////////////////////////////////////////////////
-
-template<class Entry>
-uint32_t ShapeCache<Entry>::getSize() {
- return mSize;
-}
-
-template<class Entry>
-uint32_t ShapeCache<Entry>::getMaxSize() {
- return mMaxSize;
-}
-
-template<class Entry>
-void ShapeCache<Entry>::setMaxSize(uint32_t maxSize) {
- mMaxSize = maxSize;
- while (mSize > mMaxSize) {
- mCache.removeOldest();
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Callbacks
-///////////////////////////////////////////////////////////////////////////////
-
-template<class Entry>
-void ShapeCache<Entry>::operator()(Entry& path, PathTexture*& texture) {
- removeTexture(texture);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Caching
-///////////////////////////////////////////////////////////////////////////////
-
-template<class Entry>
-void ShapeCache<Entry>::removeTexture(PathTexture* texture) {
- if (texture) {
- const uint32_t size = texture->width * texture->height;
- mSize -= size;
-
- SHAPE_LOGD("ShapeCache::callback: delete %s: name, size, mSize = %d, %d, %d",
- mName, texture->id, size, mSize);
- if (mDebugEnabled) {
- ALOGD("Shape %s deleted, size = %d", mName, size);
- }
-
- if (texture->id) {
- glDeleteTextures(1, &texture->id);
- }
- delete texture;
- }
-}
-
-template<class Entry>
-void ShapeCache<Entry>::purgeCache(uint32_t width, uint32_t height) {
- const uint32_t size = width * height;
- // Don't even try to cache a bitmap that's bigger than the cache
- if (size < mMaxSize) {
- while (mSize + size > mMaxSize) {
- mCache.removeOldest();
- }
- }
-}
-
-template<class Entry>
-void ShapeCache<Entry>::trim() {
- while (mSize > mMaxSize) {
- mCache.removeOldest();
- }
-}
-
-template<class Entry>
-PathTexture* ShapeCache<Entry>::addTexture(const Entry& entry, const SkPath *path,
- const SkPaint* paint) {
- ATRACE_CALL();
-
- float left, top, offset;
- uint32_t width, height;
- computePathBounds(path, paint, left, top, offset, width, height);
-
- if (!checkTextureSize(width, height)) return NULL;
-
- purgeCache(width, height);
-
- SkBitmap bitmap;
- drawPath(path, paint, bitmap, left, top, offset, width, height);
-
- PathTexture* texture = createTexture(left, top, offset, width, height,
- path->getGenerationID());
- addTexture(entry, &bitmap, texture);
-
- return texture;
-}
-
-template<class Entry>
-void ShapeCache<Entry>::addTexture(const Entry& entry, SkBitmap* bitmap, PathTexture* texture) {
- generateTexture(*bitmap, texture);
-
- uint32_t size = texture->width * texture->height;
- if (size < mMaxSize) {
- mSize += size;
- SHAPE_LOGD("ShapeCache::get: create %s: name, size, mSize = %d, %d, %d",
- mName, texture->id, size, mSize);
- if (mDebugEnabled) {
- ALOGD("Shape %s created, size = %d", mName, size);
- }
- mCache.put(entry, texture);
- } else {
- texture->cleanup = true;
- }
-}
-
-template<class Entry>
-void ShapeCache<Entry>::clear() {
- mCache.clear();
-}
-
-template<class Entry>
-void ShapeCache<Entry>::generateTexture(SkBitmap& bitmap, Texture* texture) {
- SkAutoLockPixels alp(bitmap);
- if (!bitmap.readyToDraw()) {
- ALOGE("Cannot generate texture from bitmap");
- return;
- }
-
- glGenTextures(1, &texture->id);
-
- glBindTexture(GL_TEXTURE_2D, texture->id);
- // Textures are Alpha8
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- texture->blend = true;
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texture->width, texture->height, 0,
- GL_ALPHA, GL_UNSIGNED_BYTE, bitmap.getPixels());
-
- texture->setFilter(GL_LINEAR);
- texture->setWrap(GL_CLAMP_TO_EDGE);
-}
-
-}; // namespace uirenderer
-}; // namespace android
-
-#endif // ANDROID_HWUI_SHAPE_CACHE_H
diff --git a/libs/hwui/SkiaShader.cpp b/libs/hwui/SkiaShader.cpp
index 9013fd5..c38eedb 100644
--- a/libs/hwui/SkiaShader.cpp
+++ b/libs/hwui/SkiaShader.cpp
@@ -411,8 +411,14 @@
void SkiaComposeShader::setupProgram(Program* program, const mat4& modelView,
const Snapshot& snapshot, GLuint* textureUnit) {
- mFirst->setupProgram(program, modelView, snapshot, textureUnit);
- mSecond->setupProgram(program, modelView, snapshot, textureUnit);
+ // Apply this compose shader's local transform and pass it down to
+ // the child shaders. They will in turn apply their local transform
+ // to this matrix.
+ mat4 transform;
+ computeScreenSpaceMatrix(transform, modelView);
+
+ mFirst->setupProgram(program, transform, snapshot, textureUnit);
+ mSecond->setupProgram(program, transform, snapshot, textureUnit);
}
}; // namespace uirenderer
diff --git a/libs/hwui/font/CacheTexture.cpp b/libs/hwui/font/CacheTexture.cpp
index 24b0523..1096642 100644
--- a/libs/hwui/font/CacheTexture.cpp
+++ b/libs/hwui/font/CacheTexture.cpp
@@ -106,6 +106,84 @@
// CacheTexture
///////////////////////////////////////////////////////////////////////////////
+CacheTexture::CacheTexture(uint16_t width, uint16_t height, uint32_t maxQuadCount) :
+ mTexture(NULL), mTextureId(0), mWidth(width), mHeight(height),
+ mLinearFiltering(false), mDirty(false), mNumGlyphs(0),
+ mMesh(NULL), mCurrentQuad(0), mMaxQuadCount(maxQuadCount) {
+ mCacheBlocks = new CacheBlock(TEXTURE_BORDER_SIZE, TEXTURE_BORDER_SIZE,
+ mWidth - TEXTURE_BORDER_SIZE, mHeight - TEXTURE_BORDER_SIZE, true);
+}
+
+CacheTexture::~CacheTexture() {
+ releaseMesh();
+ releaseTexture();
+ reset();
+}
+
+void CacheTexture::reset() {
+ // Delete existing cache blocks
+ while (mCacheBlocks != NULL) {
+ CacheBlock* tmpBlock = mCacheBlocks;
+ mCacheBlocks = mCacheBlocks->mNext;
+ delete tmpBlock;
+ }
+ mNumGlyphs = 0;
+ mCurrentQuad = 0;
+}
+
+void CacheTexture::init() {
+ // reset, then create a new remainder space to start again
+ reset();
+ mCacheBlocks = new CacheBlock(TEXTURE_BORDER_SIZE, TEXTURE_BORDER_SIZE,
+ mWidth - TEXTURE_BORDER_SIZE, mHeight - TEXTURE_BORDER_SIZE, true);
+}
+
+void CacheTexture::releaseMesh() {
+ delete[] mMesh;
+}
+
+void CacheTexture::releaseTexture() {
+ if (mTexture) {
+ delete[] mTexture;
+ mTexture = NULL;
+ }
+ if (mTextureId) {
+ glDeleteTextures(1, &mTextureId);
+ mTextureId = 0;
+ }
+ mDirty = false;
+ mCurrentQuad = 0;
+}
+
+void CacheTexture::allocateMesh() {
+ if (!mMesh) {
+ mMesh = new TextureVertex[mMaxQuadCount * 4];
+ }
+}
+
+void CacheTexture::allocateTexture() {
+ if (!mTexture) {
+ mTexture = new uint8_t[mWidth * mHeight];
+ }
+
+ if (!mTextureId) {
+ glGenTextures(1, &mTextureId);
+
+ glBindTexture(GL_TEXTURE_2D, mTextureId);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ // Initialize texture dimensions
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, mWidth, mHeight, 0,
+ GL_ALPHA, GL_UNSIGNED_BYTE, 0);
+
+ const GLenum filtering = getLinearFiltering() ? GL_LINEAR : GL_NEAREST;
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ }
+}
+
bool CacheTexture::fitBitmap(const SkGlyph& glyph, uint32_t* retOriginX, uint32_t* retOriginY) {
if (glyph.fHeight + TEXTURE_BORDER_SIZE * 2 > mHeight) {
return false;
diff --git a/libs/hwui/font/CacheTexture.h b/libs/hwui/font/CacheTexture.h
index fdd1623..5742941 100644
--- a/libs/hwui/font/CacheTexture.h
+++ b/libs/hwui/font/CacheTexture.h
@@ -24,7 +24,8 @@
#include <utils/Log.h>
#include "FontUtil.h"
-#include "Rect.h"
+#include "../Rect.h"
+#include "../Vertex.h"
namespace android {
namespace uirenderer {
@@ -55,14 +56,14 @@
}
static CacheBlock* insertBlock(CacheBlock* head, CacheBlock* newBlock);
-
static CacheBlock* removeBlock(CacheBlock* head, CacheBlock* blockToRemove);
void output() {
CacheBlock* currBlock = this;
while (currBlock) {
ALOGD("Block: this, x, y, w, h = %p, %d, %d, %d, %d",
- currBlock, currBlock->mX, currBlock->mY, currBlock->mWidth, currBlock->mHeight);
+ currBlock, currBlock->mX, currBlock->mY,
+ currBlock->mWidth, currBlock->mHeight);
currBlock = currBlock->mNext;
}
}
@@ -70,72 +71,17 @@
class CacheTexture {
public:
- CacheTexture(uint16_t width, uint16_t height) :
- mTexture(NULL), mTextureId(0), mWidth(width), mHeight(height),
- mLinearFiltering(false), mDirty(false), mNumGlyphs(0) {
- mCacheBlocks = new CacheBlock(TEXTURE_BORDER_SIZE, TEXTURE_BORDER_SIZE,
- mWidth - TEXTURE_BORDER_SIZE, mHeight - TEXTURE_BORDER_SIZE, true);
- }
+ CacheTexture(uint16_t width, uint16_t height, uint32_t maxQuadCount);
+ ~CacheTexture();
- ~CacheTexture() {
- releaseTexture();
- reset();
- }
+ void reset();
+ void init();
- void reset() {
- // Delete existing cache blocks
- while (mCacheBlocks != NULL) {
- CacheBlock* tmpBlock = mCacheBlocks;
- mCacheBlocks = mCacheBlocks->mNext;
- delete tmpBlock;
- }
- mNumGlyphs = 0;
- }
+ void releaseMesh();
+ void releaseTexture();
- void init() {
- // reset, then create a new remainder space to start again
- reset();
- mCacheBlocks = new CacheBlock(TEXTURE_BORDER_SIZE, TEXTURE_BORDER_SIZE,
- mWidth - TEXTURE_BORDER_SIZE, mHeight - TEXTURE_BORDER_SIZE, true);
- }
-
- void releaseTexture() {
- if (mTexture) {
- delete[] mTexture;
- mTexture = NULL;
- }
- if (mTextureId) {
- glDeleteTextures(1, &mTextureId);
- mTextureId = 0;
- }
- mDirty = false;
- }
-
- /**
- * This method assumes that the proper texture unit is active.
- */
- void allocateTexture() {
- if (!mTexture) {
- mTexture = new uint8_t[mWidth * mHeight];
- }
-
- if (!mTextureId) {
- glGenTextures(1, &mTextureId);
-
- glBindTexture(GL_TEXTURE_2D, mTextureId);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- // Initialize texture dimensions
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, mWidth, mHeight, 0,
- GL_ALPHA, GL_UNSIGNED_BYTE, 0);
-
- const GLenum filtering = getLinearFiltering() ? GL_LINEAR : GL_NEAREST;
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }
- }
+ void allocateTexture();
+ void allocateMesh();
bool fitBitmap(const SkGlyph& glyph, uint32_t* retOriginX, uint32_t* retOriginY);
@@ -193,6 +139,42 @@
return mNumGlyphs;
}
+ TextureVertex* mesh() const {
+ return mMesh;
+ }
+
+ uint32_t meshElementCount() const {
+ return mCurrentQuad * 6;
+ }
+
+ uint16_t* indices() const {
+ return (uint16_t*) 0;
+ }
+
+ void resetMesh() {
+ mCurrentQuad = 0;
+ }
+
+ inline void addQuad(float x1, float y1, float u1, float v1,
+ float x2, float y2, float u2, float v2,
+ float x3, float y3, float u3, float v3,
+ float x4, float y4, float u4, float v4) {
+ TextureVertex* mesh = mMesh + mCurrentQuad * 4;
+ TextureVertex::set(mesh++, x1, y1, u1, v1);
+ TextureVertex::set(mesh++, x2, y2, u2, v2);
+ TextureVertex::set(mesh++, x3, y3, u3, v3);
+ TextureVertex::set(mesh++, x4, y4, u4, v4);
+ mCurrentQuad++;
+ }
+
+ bool canDraw() const {
+ return mCurrentQuad > 0;
+ }
+
+ bool endOfMesh() const {
+ return mCurrentQuad == mMaxQuadCount;
+ }
+
private:
uint8_t* mTexture;
GLuint mTextureId;
@@ -201,6 +183,9 @@
bool mLinearFiltering;
bool mDirty;
uint16_t mNumGlyphs;
+ TextureVertex* mMesh;
+ uint32_t mCurrentQuad;
+ uint32_t mMaxQuadCount;
CacheBlock* mCacheBlocks;
Rect mDirtyRect;
};
diff --git a/libs/hwui/font/FontUtil.h b/libs/hwui/font/FontUtil.h
index 4f9c46b..f758666 100644
--- a/libs/hwui/font/FontUtil.h
+++ b/libs/hwui/font/FontUtil.h
@@ -26,7 +26,7 @@
///////////////////////////////////////////////////////////////////////////////
#define DEFAULT_TEXT_SMALL_CACHE_WIDTH 1024
-#define DEFAULT_TEXT_SMALL_CACHE_HEIGHT 256
+#define DEFAULT_TEXT_SMALL_CACHE_HEIGHT 512
#define DEFAULT_TEXT_LARGE_CACHE_WIDTH 2048
#define DEFAULT_TEXT_LARGE_CACHE_HEIGHT 512
diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl
index 312c252..efa8089 100644
--- a/media/java/android/media/IAudioService.aidl
+++ b/media/java/android/media/IAudioService.aidl
@@ -120,14 +120,14 @@
oneway void dispatchMediaKeyEvent(in KeyEvent keyEvent);
void dispatchMediaKeyEventUnderWakelock(in KeyEvent keyEvent);
- oneway void registerMediaButtonIntent(in PendingIntent pi, in ComponentName c);
+ void registerMediaButtonIntent(in PendingIntent pi, in ComponentName c);
oneway void unregisterMediaButtonIntent(in PendingIntent pi, in ComponentName c);
oneway void registerMediaButtonEventReceiverForCalls(in ComponentName c);
oneway void unregisterMediaButtonEventReceiverForCalls();
- int registerRemoteControlClient(in PendingIntent mediaIntent,
- in IRemoteControlClient rcClient, in String callingPackageName);
+ int registerRemoteControlClient(in PendingIntent mediaIntent,
+ in IRemoteControlClient rcClient, in String callingPackageName);
oneway void unregisterRemoteControlClient(in PendingIntent mediaIntent,
in IRemoteControlClient rcClient);
diff --git a/media/java/android/media/MediaMuxer.java b/media/java/android/media/MediaMuxer.java
index dfd0e94..c3cc1e6 100644
--- a/media/java/android/media/MediaMuxer.java
+++ b/media/java/android/media/MediaMuxer.java
@@ -276,7 +276,7 @@
*/
public void release() {
if (mState == MUXER_STATE_STARTED) {
- throw new IllegalStateException("Can't release when muxer is started");
+ stop();
}
if (mNativeObject != 0) {
nativeRelease(mNativeObject);
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java
index 5c74552..fa60ca6 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java
@@ -43,7 +43,7 @@
public static int mBitRate = profile.videoBitRate;
public static boolean mRemoveVideo = true;
public static int mDuration = 60 * 1000; // 60 seconds
- public static int mTimeLapseDuration = 180 * 1000; // 3 minutes
+ public static int mTimeLapseDuration = 15 * 60 * 1000; // 15 minutes
public static double mCaptureRate = 0.5; // 2 sec timelapse interval
@Override
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java
index a80fc13..53eb990 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java
@@ -101,7 +101,9 @@
Log.v(TAG, e.toString());
}
String[] poList = memoryUsage.split("\r|\n|\r\n");
- String memusage = poList[1].concat("\n");
+ // Skip the first two lines since there
+ // is a new media.log introudced recently.
+ String memusage = poList[2].concat("\n");
return memusage;
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java
index 1c60401..be12c7f 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java
@@ -328,7 +328,15 @@
Log.v(TAG, e.toString());
}
String[] poList = memoryUsage.split("\r|\n|\r\n");
- String memusage = poList[1].concat("\n");
+ // A new media.log is enabled with ro.test_harness is set.
+ // The output of "ps mediaserver" will include the
+ // media.log process in the first line. Update the parsing
+ // to only read the thrid line.
+ // Smaple ps mediaserver output:
+ // USER PID PPID VSIZE RSS WCHAN PC NAME
+ // media 131 1 13676 4796 ffffffff 400b1bd0 S media.log
+ // media 219 131 37768 6892 ffffffff 400b236c S /system/bin/mediaserver
+ String memusage = poList[2].concat("\n");
return memusage;
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java
index 6eb9891..199f179 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java
@@ -50,16 +50,10 @@
private Camera mCamera;
private static final int CAMERA_ID = 0;
- private static final int NUMBER_OF_CAMERA_STRESS_LOOPS = 100;
- private static final int NUMBER_OF_RECORDER_STRESS_LOOPS = 100;
- private static final int NUMBER_OF_RECORDERANDPLAY_STRESS_LOOPS = 50;
- private static final int NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER = 200;
- private static final int NUMBER_OF_TIME_LAPSE_LOOPS = 25;
- private static final int TIME_LAPSE_PLAYBACK_WAIT_TIME = 5* 1000; // 5 seconds
+ private static final int NUMBER_OF_TIME_LAPSE_LOOPS = 1;
+ private static final int TIME_LAPSE_PLAYBACK_WAIT_TIME = 30 * 1000; // 30 seconds
private static final int USE_TEST_RUNNER_PROFILE = -1;
private static final long WAIT_TIMEOUT = 10 * 1000; // 10 seconds
- private static final long WAIT_TIME_CAMERA_TEST = 3 * 1000; // 3 seconds
- private static final long WAIT_TIME_RECORDER_TEST = 6 * 1000; // 6 seconds
private static final String OUTPUT_FILE_EXT = ".3gp";
private static final String MEDIA_STRESS_OUTPUT = "mediaStressOutput.txt";
@@ -150,158 +144,6 @@
}
}
- //Test case for stressing the camera preview.
- @LargeTest
- public void testStressCamera() throws Exception {
- SurfaceHolder mSurfaceHolder;
- mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
- Log.v(TAG, "Camera start preview stress test");
- mOutput.write("Total number of loops:" + NUMBER_OF_CAMERA_STRESS_LOOPS + "\n");
- try {
- Log.v(TAG, "Start preview");
- mOutput.write("No of loop: ");
-
- for (int i = 0; i< NUMBER_OF_CAMERA_STRESS_LOOPS; i++) {
- runOnLooper(new Runnable() {
- @Override
- public void run() {
- mCamera = Camera.open(CAMERA_ID);
- }
- });
- mCamera.setErrorCallback(mCameraErrorCallback);
- mCamera.setPreviewDisplay(mSurfaceHolder);
- mCamera.startPreview();
- Thread.sleep(WAIT_TIME_CAMERA_TEST);
- mCamera.stopPreview();
- mCamera.release();
- if (i == 0) {
- mOutput.write(i + 1);
- } else {
- mOutput.write(String.format(", %d", (i + 1)));
- }
- }
- } catch (Exception e) {
- Log.e(TAG, e.toString());
- fail("Camera startup preview stress test");
- }
- }
-
- //Test case for stressing the camera preview.
- @LargeTest
- public void testStressRecorder() throws Exception {
- SurfaceHolder mSurfaceHolder;
- mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
- Log.v(TAG, "H263 video record: reset after prepare Stress test");
- mOutput.write("Total number of loops:" + NUMBER_OF_RECORDER_STRESS_LOOPS + "\n");
- try {
- mOutput.write("No of loop: ");
- Log.v(TAG, "Start preview");
- for (int i = 0; i < NUMBER_OF_RECORDER_STRESS_LOOPS; i++) {
- runOnLooper(new Runnable() {
- @Override
- public void run() {
- mRecorder = new MediaRecorder();
- }
- });
- Log.v(TAG, "counter = " + i);
- String fileName = String.format("%s/temp%d%s",
- Environment.getExternalStorageDirectory(),
- i, OUTPUT_FILE_EXT);
-
- Log.v(TAG, fileName);
- mRecorder.setOnErrorListener(mRecorderErrorCallback);
- mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
- mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
- mRecorder.setOutputFile(fileName);
- mRecorder.setVideoFrameRate(MediaRecorderStressTestRunner.mFrameRate);
- mRecorder.setVideoSize(176,144);
- Log.v(TAG, "setEncoder");
- mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
- mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
- Log.v(TAG, "setPreview");
- mRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
- Log.v(TAG, "prepare");
- mRecorder.prepare();
- Log.v(TAG, "before release");
- Thread.sleep(WAIT_TIME_RECORDER_TEST);
- mRecorder.reset();
- mRecorder.release();
- if (i == 0) {
- mOutput.write(i + 1);
- } else {
- mOutput.write(String.format(", %d", (i + 1)));
- }
- }
- } catch (Exception e) {
- Log.e(TAG, e.toString());
- fail("H263 video recording stress test");
- }
- }
-
- //Stress test case for switching camera and video recorder preview.
- @LargeTest
- public void testStressCameraSwitchRecorder() throws Exception {
- SurfaceHolder mSurfaceHolder;
- mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
- Log.v(TAG, "Camera and video recorder preview switching");
- mOutput.write("Total number of loops: " +
- NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER + "\n");
- try {
- Log.v(TAG, "Start preview");
- mOutput.write("No of loop: ");
- for (int i = 0; i < NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER; i++) {
- runOnLooper(new Runnable() {
- @Override
- public void run() {
- mCamera = Camera.open(CAMERA_ID);
- }
- });
- mCamera.setErrorCallback(mCameraErrorCallback);
- mCamera.setPreviewDisplay(mSurfaceHolder);
- mCamera.startPreview();
- Thread.sleep(WAIT_TIME_CAMERA_TEST);
- mCamera.stopPreview();
- mCamera.release();
- mCamera = null;
- Log.v(TAG, "release camera");
- String fileName = String.format("%s/temp%d%s",
- Environment.getExternalStorageDirectory(),
- i, OUTPUT_FILE_EXT);
- Log.v(TAG, fileName);
- runOnLooper(new Runnable() {
- @Override
- public void run() {
- mRecorder = new MediaRecorder();
- }
- });
- mRecorder.setOnErrorListener(mRecorderErrorCallback);
- mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
- mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
- mRecorder.setOutputFile(fileName);
- mRecorder.setVideoFrameRate(MediaRecorderStressTestRunner.mFrameRate);
- mRecorder.setVideoSize(176,144);
- Log.v(TAG, "Media recorder setEncoder");
- mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
- Log.v(TAG, "mediaRecorder setPreview");
- mRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
- Log.v(TAG, "prepare");
- mRecorder.prepare();
- Log.v(TAG, "before release");
- Thread.sleep(WAIT_TIME_CAMERA_TEST);
- mRecorder.release();
- Log.v(TAG, "release video recorder");
- if (i == 0) {
- mOutput.write(i + 1);
- } else {
- mOutput.write(String.format(", %d", (i + 1)));
- }
- }
- } catch (Exception e) {
- Log.e(TAG, e.toString());
- fail("Camera and recorder switch mode");
- }
- }
-
public void validateRecordedVideo(String recordedFile) {
try {
MediaPlayer mp = new MediaPlayer();
diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java
index 54dcaaa..5a2e261 100644
--- a/opengl/java/android/opengl/GLSurfaceView.java
+++ b/opengl/java/android/opengl/GLSurfaceView.java
@@ -1445,6 +1445,7 @@
Log.i("GLThread", "waiting tid=" + getId()
+ " mHaveEglContext: " + mHaveEglContext
+ " mHaveEglSurface: " + mHaveEglSurface
+ + " mFinishedCreatingEglSurface: " + mFinishedCreatingEglSurface
+ " mPaused: " + mPaused
+ " mHasSurface: " + mHasSurface
+ " mSurfaceIsBad: " + mSurfaceIsBad
@@ -1468,8 +1469,14 @@
if (LOG_SURFACE) {
Log.w("GLThread", "egl createSurface");
}
- if (!mEglHelper.createSurface()) {
+ if (mEglHelper.createSurface()) {
synchronized(sGLThreadManager) {
+ mFinishedCreatingEglSurface = true;
+ sGLThreadManager.notifyAll();
+ }
+ } else {
+ synchronized(sGLThreadManager) {
+ mFinishedCreatingEglSurface = true;
mSurfaceIsBad = true;
sGLThreadManager.notifyAll();
}
@@ -1595,8 +1602,11 @@
Log.i("GLThread", "surfaceCreated tid=" + getId());
}
mHasSurface = true;
+ mFinishedCreatingEglSurface = false;
sGLThreadManager.notifyAll();
- while((mWaitingForSurface) && (!mExited)) {
+ while (mWaitingForSurface
+ && !mFinishedCreatingEglSurface
+ && !mExited) {
try {
sGLThreadManager.wait();
} catch (InterruptedException e) {
@@ -1735,6 +1745,7 @@
private boolean mWaitingForSurface;
private boolean mHaveEglContext;
private boolean mHaveEglSurface;
+ private boolean mFinishedCreatingEglSurface;
private boolean mShouldReleaseEglContext;
private int mWidth;
private int mHeight;
diff --git a/packages/Shell/src/com/android/shell/BugreportReceiver.java b/packages/Shell/src/com/android/shell/BugreportReceiver.java
index 3b1ebf4..de04909 100644
--- a/packages/Shell/src/com/android/shell/BugreportReceiver.java
+++ b/packages/Shell/src/com/android/shell/BugreportReceiver.java
@@ -29,17 +29,16 @@
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
+import android.os.FileUtils;
import android.os.SystemProperties;
import android.support.v4.content.FileProvider;
-import android.util.Log;
+import android.text.format.DateUtils;
import android.util.Patterns;
import com.google.android.collect.Lists;
import java.io.File;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
/**
* Receiver that handles finished bugreports, usually by attaching them to an
@@ -54,10 +53,15 @@
private static final String EXTRA_SCREENSHOT = "android.intent.extra.SCREENSHOT";
/**
- * Number of bugreports to retain before deleting the oldest; 4 reports and
- * 4 screenshots are roughly 17MB of disk space.
+ * Always keep the newest 8 bugreport files; 4 reports and 4 screenshots are
+ * roughly 17MB of disk space.
*/
- private static final int NUM_OLD_FILES = 8;
+ private static final int MIN_KEEP_COUNT = 8;
+
+ /**
+ * Always keep bugreports taken in the last week.
+ */
+ private static final long MIN_KEEP_AGE = DateUtils.WEEK_IN_MILLIS;
@Override
public void onReceive(Context context, Intent intent) {
@@ -94,7 +98,8 @@
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
- deleteOlderFiles(bugreportFile.getParentFile(), NUM_OLD_FILES);
+ FileUtils.deleteOlderFiles(
+ bugreportFile.getParentFile(), MIN_KEEP_COUNT, MIN_KEEP_AGE);
result.finish();
return null;
}
@@ -164,28 +169,6 @@
return foundAccount;
}
- /**
- * Delete the oldest files in given directory until only the requested
- * number remain.
- */
- private static void deleteOlderFiles(File dir, int retainNum) {
- final File[] files = dir.listFiles();
- if (files == null) return;
-
- Arrays.sort(files, new ModifiedComparator());
- for (int i = retainNum; i < files.length; i++) {
- Log.d(TAG, "Deleting old file " + files[i]);
- files[i].delete();
- }
- }
-
- private static class ModifiedComparator implements Comparator<File> {
- @Override
- public int compare(File lhs, File rhs) {
- return (int) (rhs.lastModified() - lhs.lastModified());
- }
- }
-
private static File getFileExtra(Intent intent, String key) {
final String path = intent.getStringExtra(key);
if (path != null) {
@@ -194,5 +177,4 @@
return null;
}
}
-
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
index 78d7caa..46f6430 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -35,6 +35,7 @@
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
+import android.media.RemoteControlClient;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
@@ -55,6 +56,7 @@
import com.android.internal.R;
import com.android.internal.policy.impl.keyguard.KeyguardSecurityModel.SecurityMode;
+import com.android.internal.policy.impl.keyguard.KeyguardUpdateMonitor.DisplayClientState;
import com.android.internal.widget.LockPatternUtils;
import java.io.File;
@@ -62,9 +64,16 @@
public class KeyguardHostView extends KeyguardViewBase {
private static final String TAG = "KeyguardHostView";
+ // transport control states
+ static final int TRANSPORT_GONE = 0;
+ static final int TRANSPORT_INVISIBLE = 1;
+ static final int TRANSPORT_VISIBLE = 2;
+
+ private int mTransportState = TRANSPORT_GONE;
// Use this to debug all of keyguard
public static boolean DEBUG = KeyguardViewMediator.DEBUG;
+ public static boolean DEBUGXPORT = true; // debug music transport control
// Found in KeyguardAppWidgetPickActivity.java
static final int APPWIDGET_HOST_ID = 0x4B455947;
@@ -109,11 +118,8 @@
private KeyguardMultiUserSelectorView mKeyguardMultiUserSelectorView;
- /*package*/ interface TransportCallback {
- void onListenerDetached();
- void onListenerAttached();
- void onPlayStateChanged();
- }
+ protected int mPlaybackState;
+ protected int mClientGeneration;
/*package*/ interface UserSwitcherCallback {
void hideSecurityView(int duration);
@@ -183,6 +189,9 @@
mUserSetupCompleted = Settings.Secure.getIntForUser(mContext.getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0;
+ // Ensure we have the current state *before* we call showAppropriateWidgetPage()
+ getInitialTransportState();
+
if (mSafeModeEnabled) {
Log.v(TAG, "Keyguard widgets disabled by safe mode");
}
@@ -194,6 +203,14 @@
}
}
+ private void getInitialTransportState() {
+ DisplayClientState dcs = KeyguardUpdateMonitor.getInstance(mContext)
+ .getCachedDisplayClientState();
+ mTransportState = (dcs.clearing ? TRANSPORT_GONE :
+ (isMusicPlaying(dcs.playbackState) ? TRANSPORT_VISIBLE : TRANSPORT_INVISIBLE));
+ mPlaybackState = dcs.playbackState;
+ }
+
private void cleanupAppWidgetIds() {
// Since this method may delete a widget (which we can't do until boot completed) we
// may have to defer it until after boot complete.
@@ -249,8 +266,44 @@
mKeyguardMultiUserSelectorView.finalizeActiveUserView(true);
}
}
+ @Override
+ void onMusicClientIdChanged(
+ int clientGeneration, boolean clearing, android.app.PendingIntent intent) {
+ // Set transport state to invisible until we know music is playing (below)
+ if (DEBUGXPORT && (mClientGeneration != clientGeneration || clearing)) {
+ Log.v(TAG, (clearing ? "hide" : "show") + " transport, gen:" + clientGeneration);
+ }
+ mClientGeneration = clientGeneration;
+ mTransportState = (clearing ? TRANSPORT_GONE : TRANSPORT_INVISIBLE);
+ KeyguardHostView.this.post(mSwitchPageRunnable);
+ }
+ @Override
+ public void onMusicPlaybackStateChanged(int playbackState, long eventTime) {
+ mPlaybackState = playbackState;
+ if (DEBUGXPORT) Log.v(TAG, "music state changed: " + playbackState);
+ if (mTransportState != TRANSPORT_GONE) {
+ mTransportState = (isMusicPlaying(mPlaybackState) ?
+ TRANSPORT_VISIBLE : TRANSPORT_INVISIBLE);
+ }
+ KeyguardHostView.this.post(mSwitchPageRunnable);
+ }
};
+ private static final boolean isMusicPlaying(int playbackState) {
+ // This should agree with the list in AudioService.isPlaystateActive()
+ switch (playbackState) {
+ case RemoteControlClient.PLAYSTATE_PLAYING:
+ case RemoteControlClient.PLAYSTATE_BUFFERING:
+ case RemoteControlClient.PLAYSTATE_FAST_FORWARDING:
+ case RemoteControlClient.PLAYSTATE_REWINDING:
+ case RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS:
+ case RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS:
+ return true;
+ default:
+ return false;
+ }
+ }
+
private SlidingChallengeLayout mSlidingChallengeLayout;
@Override
@@ -1125,10 +1178,8 @@
}
private void addDefaultWidgets() {
- LayoutInflater inflater = LayoutInflater.from(mContext);
- inflater.inflate(R.layout.keyguard_transport_control_view, this, true);
-
if (!mSafeModeEnabled && !widgetsDisabledByDpm()) {
+ LayoutInflater inflater = LayoutInflater.from(mContext);
View addWidget = inflater.inflate(R.layout.keyguard_add_widget, this, false);
mAppWidgetContainer.addWidget(addWidget, 0);
View addWidgetButton = addWidget.findViewById(R.id.keyguard_add_widget_view);
@@ -1154,66 +1205,19 @@
}
enableUserSelectorIfNecessary();
- initializeTransportControl();
}
- private boolean removeTransportFromWidgetPager() {
- int page = getWidgetPosition(R.id.keyguard_transport_control);
- if (page != -1) {
- mAppWidgetContainer.removeWidget(mTransportControl);
-
- // XXX keep view attached so we still get show/hide events from AudioManager
- KeyguardHostView.this.addView(mTransportControl);
- mTransportControl.setVisibility(View.GONE);
- mViewStateManager.setTransportState(KeyguardViewStateManager.TRANSPORT_GONE);
- return true;
+ /**
+ * Create KeyguardTransportControlView on demand.
+ * @return
+ */
+ private KeyguardTransportControlView getTransportControlView() {
+ if (mTransportControl == null) {
+ LayoutInflater inflater = LayoutInflater.from(mContext);
+ mTransportControl = (KeyguardTransportControlView)
+ inflater.inflate(R.layout.keyguard_transport_control_view, this, false);
}
- return false;
- }
-
- private void addTransportToWidgetPager() {
- if (getWidgetPosition(R.id.keyguard_transport_control) == -1) {
- KeyguardHostView.this.removeView(mTransportControl);
- // insert to left of camera if it exists, otherwise after right-most widget
- int lastWidget = mAppWidgetContainer.getChildCount() - 1;
- int position = 0; // handle no widget case
- if (lastWidget >= 0) {
- position = mAppWidgetContainer.isCameraPage(lastWidget) ?
- lastWidget : lastWidget + 1;
- }
- mAppWidgetContainer.addWidget(mTransportControl, position);
- mTransportControl.setVisibility(View.VISIBLE);
- }
- }
-
- private void initializeTransportControl() {
- mTransportControl =
- (KeyguardTransportControlView) findViewById(R.id.keyguard_transport_control);
- mTransportControl.setVisibility(View.GONE);
-
- // This code manages showing/hiding the transport control. We keep it around and only
- // add it to the hierarchy if it needs to be present.
- if (mTransportControl != null) {
- mTransportControl.setKeyguardCallback(new TransportCallback() {
- @Override
- public void onListenerDetached() {
- if (removeTransportFromWidgetPager()) {
- mTransportControl.post(mSwitchPageRunnable);
- }
- }
-
- @Override
- public void onListenerAttached() {
- // Transport will be added when playstate changes...
- mTransportControl.post(mSwitchPageRunnable);
- }
-
- @Override
- public void onPlayStateChanged() {
- mTransportControl.post(mSwitchPageRunnable);
- }
- });
- }
+ return mTransportControl;
}
private int getInsertPageIndex() {
@@ -1385,7 +1389,7 @@
if (DEBUG) Log.d(TAG, "onSaveInstanceState");
Parcelable superState = super.onSaveInstanceState();
SavedState ss = new SavedState(superState);
- ss.transportState = mViewStateManager.getTransportState();
+ ss.transportState = mTransportState;
ss.appWidgetToShow = mAppWidgetToShow;
return ss;
}
@@ -1399,7 +1403,7 @@
}
SavedState ss = (SavedState) state;
super.onRestoreInstanceState(ss.getSuperState());
- mViewStateManager.setTransportState(ss.transportState);
+ mTransportState = (ss.transportState);
mAppWidgetToShow = ss.appWidgetToShow;
post(mSwitchPageRunnable);
}
@@ -1420,19 +1424,33 @@
}
private void showAppropriateWidgetPage() {
- int state = mViewStateManager.getTransportState();
- boolean isMusicPlaying = mTransportControl.isMusicPlaying()
- || state == KeyguardViewStateManager.TRANSPORT_VISIBLE;
- if (isMusicPlaying) {
- mViewStateManager.setTransportState(KeyguardViewStateManager.TRANSPORT_VISIBLE);
- addTransportToWidgetPager();
- } else if (state == KeyguardViewStateManager.TRANSPORT_VISIBLE) {
- mViewStateManager.setTransportState(KeyguardViewStateManager.TRANSPORT_INVISIBLE);
- }
- int pageToShow = getAppropriateWidgetPage(isMusicPlaying);
+ int state = mTransportState;
+ ensureTransportPresentOrRemoved(state);
+ int pageToShow = getAppropriateWidgetPage(state);
mAppWidgetContainer.setCurrentPage(pageToShow);
}
+ private void ensureTransportPresentOrRemoved(int state) {
+ int page = getWidgetPosition(R.id.keyguard_transport_control);
+ if (state == TRANSPORT_INVISIBLE || state == TRANSPORT_VISIBLE) {
+ if (page == -1) {
+ if (DEBUGXPORT) Log.v(TAG, "add transport");
+ // insert to left of camera if it exists, otherwise after right-most widget
+ int lastWidget = mAppWidgetContainer.getChildCount() - 1;
+ int position = 0; // handle no widget case
+ if (lastWidget >= 0) {
+ position = mAppWidgetContainer.isCameraPage(lastWidget) ?
+ lastWidget : lastWidget + 1;
+ }
+ mAppWidgetContainer.addWidget(getTransportControlView(), position);
+ }
+ } else if (page != -1) {
+ if (DEBUGXPORT) Log.v(TAG, "remove transport");
+ mAppWidgetContainer.removeWidget(getTransportControlView());
+ mTransportControl = null;
+ }
+ }
+
private CameraWidgetFrame findCameraPage() {
for (int i = mAppWidgetContainer.getChildCount() - 1; i >= 0; i--) {
if (mAppWidgetContainer.isCameraPage(i)) {
@@ -1446,7 +1464,7 @@
return pageIndex >= 0 && pageIndex == getWidgetPosition(R.id.keyguard_transport_control);
}
- private int getAppropriateWidgetPage(boolean isMusicPlaying) {
+ private int getAppropriateWidgetPage(int musicTransportState) {
// assumes at least one widget (besides camera + add)
if (mAppWidgetToShow != AppWidgetManager.INVALID_APPWIDGET_ID) {
final int childCount = mAppWidgetContainer.getChildCount();
@@ -1459,9 +1477,9 @@
mAppWidgetToShow = AppWidgetManager.INVALID_APPWIDGET_ID;
}
// if music playing, show transport
- if (isMusicPlaying) {
+ if (musicTransportState == TRANSPORT_VISIBLE) {
if (DEBUG) Log.d(TAG, "Music playing, show transport");
- return mAppWidgetContainer.getWidgetPageIndex(mTransportControl);
+ return mAppWidgetContainer.getWidgetPageIndex(getTransportControlView());
}
// else show the right-most widget (except for camera)
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java
index fda47d5..9712ea8 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java
@@ -74,7 +74,6 @@
private int mCurrentPlayState;
private AudioManager mAudioManager;
private IRemoteControlDisplayWeak mIRCD;
- private boolean mMusicClientPresent = true;
/**
* The metadata which should be populated into the view once we've been attached
@@ -110,12 +109,6 @@
break;
case MSG_SET_GENERATION_ID:
- if (msg.arg2 != 0) {
- // This means nobody is currently registered. Hide the view.
- onListenerDetached();
- } else {
- onListenerAttached();
- }
if (DEBUG) Log.v(TAG, "New genId = " + msg.arg1 + ", clearing = " + msg.arg2);
mClientGeneration = msg.arg1;
mClientIntent = (PendingIntent) msg.obj;
@@ -124,7 +117,6 @@
}
}
};
- private KeyguardHostView.TransportCallback mTransportCallback;
/**
* This class is required to have weak linkage to the current TransportControlView
@@ -195,26 +187,6 @@
mIRCD = new IRemoteControlDisplayWeak(mHandler);
}
- protected void onListenerDetached() {
- mMusicClientPresent = false;
- if (DEBUG) Log.v(TAG, "onListenerDetached()");
- if (mTransportCallback != null) {
- mTransportCallback.onListenerDetached();
- } else {
- Log.w(TAG, "onListenerDetached: no callback");
- }
- }
-
- private void onListenerAttached() {
- mMusicClientPresent = true;
- if (DEBUG) Log.v(TAG, "onListenerAttached()");
- if (mTransportCallback != null) {
- mTransportCallback.onListenerAttached();
- } else {
- Log.w(TAG, "onListenerAttached(): no callback");
- }
- }
-
private void updateTransportControls(int transportControlFlags) {
mTransportControlFlags = transportControlFlags;
}
@@ -342,11 +314,6 @@
updatePlayPauseState(mCurrentPlayState);
}
- public boolean isMusicPlaying() {
- return mCurrentPlayState == RemoteControlClient.PLAYSTATE_PLAYING
- || mCurrentPlayState == RemoteControlClient.PLAYSTATE_BUFFERING;
- }
-
private static void setVisibilityBasedOnFlag(View view, int flags, int flag) {
if ((flags & flag) != 0) {
view.setVisibility(View.VISIBLE);
@@ -390,7 +357,6 @@
mBtnPlay.setImageResource(imageResId);
mBtnPlay.setContentDescription(getResources().getString(imageDescId));
mCurrentPlayState = state;
- mTransportCallback.onPlayStateChanged();
}
static class SavedState extends BaseSavedState {
@@ -423,28 +389,6 @@
};
}
- @Override
- public Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
- SavedState ss = new SavedState(superState);
- ss.clientPresent = mMusicClientPresent;
- return ss;
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- if (!(state instanceof SavedState)) {
- super.onRestoreInstanceState(state);
- return;
- }
- SavedState ss = (SavedState) state;
- super.onRestoreInstanceState(ss.getSuperState());
- if (ss.clientPresent) {
- if (DEBUG) Log.v(TAG, "Reattaching client because it was attached");
- onListenerAttached();
- }
- }
-
public void onClick(View v) {
int keyCode = -1;
if (v == mBtnPrev) {
@@ -522,8 +466,4 @@
return false;
}
}
-
- public void setKeyguardCallback(KeyguardHostView.TransportCallback transportCallback) {
- mTransportCallback = transportCallback;
- }
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
index c9bffbe..27d816e 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
@@ -18,12 +18,15 @@
import android.app.ActivityManagerNative;
import android.app.IUserSwitchObserver;
+import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
+import android.graphics.Bitmap;
+
import static android.os.BatteryManager.BATTERY_STATUS_FULL;
import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN;
import static android.os.BatteryManager.BATTERY_HEALTH_UNKNOWN;
@@ -32,7 +35,9 @@
import static android.os.BatteryManager.EXTRA_LEVEL;
import static android.os.BatteryManager.EXTRA_HEALTH;
import android.media.AudioManager;
+import android.media.IRemoteControlDisplay;
import android.os.BatteryManager;
+import android.os.Bundle;
import android.os.Handler;
import android.os.IRemoteCallback;
import android.os.Message;
@@ -84,6 +89,8 @@
private static final int MSG_KEYGUARD_VISIBILITY_CHANGED = 312;
protected static final int MSG_BOOT_COMPLETED = 313;
private static final int MSG_USER_SWITCH_COMPLETE = 314;
+ private static final int MSG_SET_CURRENT_CLIENT_ID = 315;
+ protected static final int MSG_SET_PLAYBACK_STATE = 316;
private static KeyguardUpdateMonitor sInstance;
@@ -163,11 +170,66 @@
case MSG_BOOT_COMPLETED:
handleBootCompleted();
break;
-
+ case MSG_SET_CURRENT_CLIENT_ID:
+ handleSetGenerationId(msg.arg1, msg.arg2 != 0, (PendingIntent) msg.obj);
+ break;
+ case MSG_SET_PLAYBACK_STATE:
+ handleSetPlaybackState(msg.arg1, msg.arg2, (Long) msg.obj);
+ break;
}
}
};
+ private AudioManager mAudioManager;
+
+ static class DisplayClientState {
+ public int clientGeneration;
+ public boolean clearing;
+ public PendingIntent intent;
+ public int playbackState;
+ public long playbackEventTime;
+ }
+
+ private DisplayClientState mDisplayClientState = new DisplayClientState();
+
+ /**
+ * This currently implements the bare minimum required to enable showing and hiding
+ * KeyguardTransportControl. There's a lot of client state to maintain which is why
+ * KeyguardTransportControl maintains an independent connection while it's showing.
+ */
+ private final IRemoteControlDisplay.Stub mRemoteControlDisplay =
+ new IRemoteControlDisplay.Stub() {
+
+ public void setPlaybackState(int generationId, int state, long stateChangeTimeMs) {
+ Message msg = mHandler.obtainMessage(MSG_SET_PLAYBACK_STATE,
+ generationId, state, stateChangeTimeMs);
+ mHandler.sendMessage(msg);
+ }
+
+ public void setMetadata(int generationId, Bundle metadata) {
+
+ }
+
+ public void setTransportControlFlags(int generationId, int flags) {
+
+ }
+
+ public void setArtwork(int generationId, Bitmap bitmap) {
+
+ }
+
+ public void setAllMetadata(int generationId, Bundle metadata, Bitmap bitmap) {
+
+ }
+
+ public void setCurrentClientId(int clientGeneration, PendingIntent mediaIntent,
+ boolean clearing) throws RemoteException {
+ Message msg = mHandler.obtainMessage(MSG_SET_CURRENT_CLIENT_ID,
+ clientGeneration, (clearing ? 1 : 0), mediaIntent);
+ mHandler.sendMessage(msg);
+ }
+ };
+
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
@@ -324,6 +386,32 @@
return sInstance;
}
+
+ protected void handleSetGenerationId(int clientGeneration, boolean clearing, PendingIntent p) {
+ mDisplayClientState.clientGeneration = clientGeneration;
+ mDisplayClientState.clearing = clearing;
+ mDisplayClientState.intent = p;
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
+ if (cb != null) {
+ cb.onMusicClientIdChanged(clientGeneration, clearing, p);
+ }
+ }
+ }
+
+ protected void handleSetPlaybackState(int generationId, int playbackState, long eventTime) {
+ if (generationId == mDisplayClientState.clientGeneration) {
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
+ if (cb != null) {
+ cb.onMusicPlaybackStateChanged(playbackState, eventTime);
+ }
+ }
+ } else {
+ Log.w(TAG, "Ignoring generation id " + generationId + " because it's not current");
+ }
+ }
+
private KeyguardUpdateMonitor(Context context) {
mContext = context;
@@ -457,6 +545,8 @@
*/
protected void handleBootCompleted() {
mBootCompleted = true;
+ mAudioManager = new AudioManager(mContext);
+ mAudioManager.registerRemoteControlDisplay(mRemoteControlDisplay);
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
@@ -466,7 +556,7 @@
}
/**
- * We need to store this state in the KeyguardUpdateMonitor since this class will not be
+ * We need to store this state in the KeyguardUpdateMonitor since this class will not be
* destroyed.
*/
public boolean hasBootCompleted() {
@@ -735,6 +825,12 @@
callback.onRefreshCarrierInfo(mTelephonyPlmn, mTelephonySpn);
callback.onClockVisibilityChanged();
callback.onSimStateChanged(mSimState);
+ callback.onMusicClientIdChanged(
+ mDisplayClientState.clientGeneration,
+ mDisplayClientState.clearing,
+ mDisplayClientState.intent);
+ callback.onMusicPlaybackStateChanged(mDisplayClientState.playbackState,
+ mDisplayClientState.playbackEventTime);
}
public void sendKeyguardVisibilityChanged(boolean showing) {
@@ -838,4 +934,8 @@
|| simState == IccCardConstants.State.PUK_REQUIRED
|| simState == IccCardConstants.State.PERM_DISABLED);
}
+
+ public DisplayClientState getCachedDisplayClientState() {
+ return mDisplayClientState;
+ }
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitorCallback.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitorCallback.java
index 2126f06..368ccb3 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitorCallback.java
@@ -15,6 +15,7 @@
*/
package com.android.internal.policy.impl.keyguard;
+import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
import android.media.AudioManager;
@@ -112,4 +113,17 @@
* KeyguardUpdateMonitor.
*/
void onBootCompleted() { }
+
+ /**
+ * Called when audio client attaches or detaches from AudioManager.
+ */
+ void onMusicClientIdChanged(int clientGeneration, boolean clearing, PendingIntent intent) { }
+
+ /**
+ * Called when the audio playback state changes.
+ * @param playbackState
+ * @param eventTime
+ */
+ public void onMusicPlaybackStateChanged(int playbackState, long eventTime) { }
+
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java
index 0a166e1..4410063 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java
@@ -15,7 +15,6 @@
*/
package com.android.internal.policy.impl.keyguard;
-import android.appwidget.AppWidgetManager;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
@@ -35,13 +34,6 @@
private static final int SCREEN_ON_RING_HINT_DELAY = 300;
Handler mMainQueue = new Handler(Looper.myLooper());
- // transport control states
- static final int TRANSPORT_GONE = 0;
- static final int TRANSPORT_INVISIBLE = 1;
- static final int TRANSPORT_VISIBLE = 2;
-
- private int mTransportState = TRANSPORT_GONE;
-
int mLastScrollState = SlidingChallengeLayout.SCROLL_STATE_IDLE;
// Paged view state
@@ -310,14 +302,6 @@
}
}
- public void setTransportState(int state) {
- mTransportState = state;
- }
-
- public int getTransportState() {
- return mTransportState;
- }
-
// ChallengeLayout.OnBouncerStateChangedListener
@Override
public void onBouncerStateChanged(boolean bouncerActive) {
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 328b503..a45c0ff 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -3931,7 +3931,7 @@
b.append(String.format(" %9d ", info.size));
Date stamp = new Date(info.mtime);
- b.append(new SimpleDateFormat("MMM dd kk:mm:ss ").format(stamp));
+ b.append(new SimpleDateFormat("MMM dd HH:mm:ss ").format(stamp));
b.append(info.packageName);
b.append(" :: ");
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index c83a919..72d249a 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -96,6 +96,7 @@
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.am.BatteryStatsService;
+import com.android.server.connectivity.Nat464Xlat;
import com.android.server.connectivity.Tethering;
import com.android.server.connectivity.Vpn;
import com.android.server.net.BaseNetworkObserver;
@@ -154,6 +155,8 @@
private boolean mLockdownEnabled;
private LockdownVpnTracker mLockdownTracker;
+ private Nat464Xlat mClat;
+
/** Lock around {@link #mUidRules} and {@link #mMeteredIfaces}. */
private Object mRulesLock = new Object();
/** Currently active network rules by UID. */
@@ -544,9 +547,12 @@
mVpn = new Vpn(mContext, mVpnCallback, mNetd);
mVpn.startMonitoring(mContext, mTrackerHandler);
+ mClat = new Nat464Xlat(mContext, mNetd, this, mTrackerHandler);
+
try {
mNetd.registerObserver(mTethering);
mNetd.registerObserver(mDataActivityObserver);
+ mNetd.registerObserver(mClat);
} catch (RemoteException e) {
loge("Error registering observer :" + e);
}
@@ -1430,11 +1436,11 @@
private boolean modifyRouteToAddress(LinkProperties lp, InetAddress addr, boolean doAdd,
boolean toDefaultTable) {
- String iface = lp.getInterfaceName();
- RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getRoutes(), addr);
+ RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getAllRoutes(), addr);
if (bestRoute == null) {
- bestRoute = RouteInfo.makeHostRoute(addr, iface);
+ bestRoute = RouteInfo.makeHostRoute(addr, lp.getInterfaceName());
} else {
+ String iface = bestRoute.getInterface();
if (bestRoute.getGateway().equals(addr)) {
// if there is no better route, add the implied hostroute for our gateway
bestRoute = RouteInfo.makeHostRoute(addr, iface);
@@ -1449,9 +1455,8 @@
private boolean modifyRoute(LinkProperties lp, RouteInfo r, int cycleCount, boolean doAdd,
boolean toDefaultTable) {
- String ifaceName = lp.getInterfaceName();
- if ((ifaceName == null) || (lp == null) || (r == null)) {
- if (DBG) log("modifyRoute got unexpected null: " + ifaceName + ", " + lp + ", " + r);
+ if ((lp == null) || (r == null)) {
+ if (DBG) log("modifyRoute got unexpected null: " + lp + ", " + r);
return false;
}
@@ -1460,8 +1465,14 @@
return false;
}
+ String ifaceName = r.getInterface();
+ if(ifaceName == null) {
+ loge("Error modifying route - no interface name");
+ return false;
+ }
+
if (r.isHostRoute() == false) {
- RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getRoutes(), r.getGateway());
+ RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getAllRoutes(), r.getGateway());
if (bestRoute != null) {
if (bestRoute.getGateway().equals(r.getGateway())) {
// if there is no better route, add the implied hostroute for our gateway
@@ -2271,6 +2282,17 @@
}
}
+ // Update 464xlat state.
+ // TODO: Move to handleConnect()
+ NetworkStateTracker tracker = mNetTrackers[netType];
+ if (mClat.requiresClat(netType, tracker)) {
+ if (mNetTrackers[netType].getNetworkInfo().isConnected()) {
+ mClat.startClat(tracker);
+ } else {
+ mClat.stopClat();
+ }
+ }
+
// TODO: Temporary notifying upstread change to Tethering.
// @see bug/4455071
/** Notify TetheringService if interface name has been changed. */
@@ -2300,7 +2322,7 @@
routeDiff = curLp.compareRoutes(newLp);
dnsDiff = curLp.compareDnses(newLp);
} else if (newLp != null) {
- routeDiff.added = newLp.getRoutes();
+ routeDiff.added = newLp.getAllRoutes();
dnsDiff.added = newLp.getDnses();
}
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 14841af..f6c9d82 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -1237,24 +1237,13 @@
public void onServiceConnected(ComponentName name, IBinder service) {
synchronized (mMethodMap) {
if (mCurIntent != null && name.equals(mCurIntent.getComponent())) {
- IInputMethod prevMethod = mCurMethod;
mCurMethod = IInputMethod.Stub.asInterface(service);
if (mCurToken == null) {
Slog.w(TAG, "Service connected without a token!");
unbindCurrentMethodLocked(false, false);
return;
}
- // Remove messages relating to the previous service. Otherwise WindowManagerService
- // will throw a BadTokenException because the old token is being removed.
- if (prevMethod != null) {
- try {
- prevMethod.removeSoftInputMessages();
- } catch (RemoteException e) {
- }
- }
- mCaller.removeMessages(MSG_SHOW_SOFT_INPUT);
- mCaller.removeMessages(MSG_HIDE_SOFT_INPUT);
- if (true || DEBUG) Slog.v(TAG, "Initiating attach with token: " + mCurToken);
+ if (DEBUG) Slog.v(TAG, "Initiating attach with token: " + mCurToken);
executeOrSendMessage(mCurMethod, mCaller.obtainMessageOO(
MSG_ATTACH_TOKEN, mCurMethod, mCurToken));
if (mCurClient != null) {
@@ -1700,7 +1689,7 @@
}
}
- if (true || DEBUG) Slog.v(TAG, "Client requesting input be shown");
+ if (DEBUG) Slog.v(TAG, "Client requesting input be shown");
return showCurrentInputLocked(flags, resultReceiver);
}
} finally {
@@ -1724,8 +1713,7 @@
boolean res = false;
if (mCurMethod != null) {
- if (true ||DEBUG) Slog.d(TAG, "showCurrentInputLocked: mCurToken=" + mCurToken,
- new RuntimeException("here").fillInStackTrace());
+ if (DEBUG) Slog.d(TAG, "showCurrentInputLocked: mCurToken=" + mCurToken);
executeOrSendMessage(mCurMethod, mCaller.obtainMessageIOO(
MSG_SHOW_SOFT_INPUT, getImeShowFlags(), mCurMethod,
resultReceiver));
@@ -1797,13 +1785,11 @@
boolean hideCurrentInputLocked(int flags, ResultReceiver resultReceiver) {
if ((flags&InputMethodManager.HIDE_IMPLICIT_ONLY) != 0
&& (mShowExplicitlyRequested || mShowForced)) {
- if (true ||DEBUG) Slog.v(TAG,
- "Not hiding: explicit show not cancelled by non-explicit hide");
+ if (DEBUG) Slog.v(TAG, "Not hiding: explicit show not cancelled by non-explicit hide");
return false;
}
if (mShowForced && (flags&InputMethodManager.HIDE_NOT_ALWAYS) != 0) {
- if (true ||DEBUG) Slog.v(TAG,
- "Not hiding: forced show not cancelled by not-always hide");
+ if (DEBUG) Slog.v(TAG, "Not hiding: forced show not cancelled by not-always hide");
return false;
}
boolean res;
@@ -2314,7 +2300,7 @@
case MSG_SHOW_SOFT_INPUT:
args = (SomeArgs)msg.obj;
try {
- if (true || DEBUG) Slog.v(TAG, "Calling " + args.arg1 + ".showSoftInput("
+ if (DEBUG) Slog.v(TAG, "Calling " + args.arg1 + ".showSoftInput("
+ msg.arg1 + ", " + args.arg2 + ")");
((IInputMethod)args.arg1).showSoftInput(msg.arg1, (ResultReceiver)args.arg2);
} catch (RemoteException e) {
@@ -2324,7 +2310,7 @@
case MSG_HIDE_SOFT_INPUT:
args = (SomeArgs)msg.obj;
try {
- if (true || DEBUG) Slog.v(TAG, "Calling " + args.arg1 + ".hideSoftInput(0, "
+ if (DEBUG) Slog.v(TAG, "Calling " + args.arg1 + ".hideSoftInput(0, "
+ args.arg2 + ")");
((IInputMethod)args.arg1).hideSoftInput(0, (ResultReceiver)args.arg2);
} catch (RemoteException e) {
@@ -2334,7 +2320,7 @@
case MSG_ATTACH_TOKEN:
args = (SomeArgs)msg.obj;
try {
- if (true || DEBUG) Slog.v(TAG, "Sending attach of token: " + args.arg2);
+ if (DEBUG) Slog.v(TAG, "Sending attach of token: " + args.arg2);
((IInputMethod)args.arg1).attachToken((IBinder)args.arg2);
} catch (RemoteException e) {
}
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 7686705..2210a18 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -233,6 +233,7 @@
try {
mObservers.getBroadcastItem(i).interfaceStatusChanged(iface, up);
} catch (RemoteException e) {
+ } catch (RuntimeException e) {
}
}
mObservers.finishBroadcast();
@@ -248,6 +249,7 @@
try {
mObservers.getBroadcastItem(i).interfaceLinkStateChanged(iface, up);
} catch (RemoteException e) {
+ } catch (RuntimeException e) {
}
}
mObservers.finishBroadcast();
@@ -262,6 +264,7 @@
try {
mObservers.getBroadcastItem(i).interfaceAdded(iface);
} catch (RemoteException e) {
+ } catch (RuntimeException e) {
}
}
mObservers.finishBroadcast();
@@ -281,6 +284,7 @@
try {
mObservers.getBroadcastItem(i).interfaceRemoved(iface);
} catch (RemoteException e) {
+ } catch (RuntimeException e) {
}
}
mObservers.finishBroadcast();
@@ -295,6 +299,7 @@
try {
mObservers.getBroadcastItem(i).limitReached(limitName, iface);
} catch (RemoteException e) {
+ } catch (RuntimeException e) {
}
}
mObservers.finishBroadcast();
@@ -309,6 +314,7 @@
try {
mObservers.getBroadcastItem(i).interfaceClassDataActivityChanged(label, active);
} catch (RemoteException e) {
+ } catch (RuntimeException e) {
}
}
mObservers.finishBroadcast();
diff --git a/services/java/com/android/server/am/ServiceRecord.java b/services/java/com/android/server/am/ServiceRecord.java
index b06c60a..1ac6bdf 100644
--- a/services/java/com/android/server/am/ServiceRecord.java
+++ b/services/java/com/android/server/am/ServiceRecord.java
@@ -368,6 +368,13 @@
return;
}
try {
+ if (foregroundNoti.icon == 0) {
+ // Notifications whose icon is 0 are defined to not show
+ // a notification, silently ignoring it. We don't want to
+ // just ignore it, we want to prevent the service from
+ // being foreground.
+ throw new RuntimeException("icon must be non-zero");
+ }
int[] outId = new int[1];
nm.enqueueNotificationInternal(localPackageName, localPackageName,
appUid, appPid, null, localForegroundId, localForegroundNoti,
diff --git a/services/java/com/android/server/connectivity/Nat464Xlat.java b/services/java/com/android/server/connectivity/Nat464Xlat.java
new file mode 100644
index 0000000..2884eaf
--- /dev/null
+++ b/services/java/com/android/server/connectivity/Nat464Xlat.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2012 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.server.connectivity;
+
+import static android.net.ConnectivityManager.TYPE_MOBILE;
+
+import java.net.Inet4Address;
+
+import android.content.Context;
+import android.net.IConnectivityManager;
+import android.net.InterfaceConfiguration;
+import android.net.LinkAddress;
+import android.net.LinkProperties;
+import android.net.NetworkStateTracker;
+import android.net.NetworkUtils;
+import android.net.RouteInfo;
+import android.os.Handler;
+import android.os.Message;
+import android.os.INetworkManagementService;
+import android.os.RemoteException;
+import android.util.Slog;
+
+import com.android.server.net.BaseNetworkObserver;
+
+/**
+ * @hide
+ *
+ * Class to manage a 464xlat CLAT daemon.
+ */
+public class Nat464Xlat extends BaseNetworkObserver {
+ private Context mContext;
+ private INetworkManagementService mNMService;
+ private IConnectivityManager mConnService;
+ private NetworkStateTracker mTracker;
+ private Handler mHandler;
+
+ // Whether we started clatd and expect it to be running.
+ private boolean mIsStarted;
+ // Whether the clatd interface exists (i.e., clatd is running).
+ private boolean mIsRunning;
+ // The LinkProperties of the clat interface.
+ private LinkProperties mLP;
+
+ // This must match the interface name in clatd.conf.
+ private static final String CLAT_INTERFACE_NAME = "clat4";
+
+ private static final String TAG = "Nat464Xlat";
+
+ public Nat464Xlat(Context context, INetworkManagementService nmService,
+ IConnectivityManager connService, Handler handler) {
+ mContext = context;
+ mNMService = nmService;
+ mConnService = connService;
+ mHandler = handler;
+
+ mIsStarted = false;
+ mIsRunning = false;
+ mLP = new LinkProperties();
+ }
+
+ /**
+ * Determines whether an interface requires clat.
+ * @param netType the network type (one of the
+ * android.net.ConnectivityManager.TYPE_* constants)
+ * @param tracker the NetworkStateTracker corresponding to the network type.
+ * @return true if the interface requires clat, false otherwise.
+ */
+ public boolean requiresClat(int netType, NetworkStateTracker tracker) {
+ LinkProperties lp = tracker.getLinkProperties();
+ // Only support clat on mobile for now.
+ Slog.d(TAG, "requiresClat: netType=" + netType + ", hasIPv4Address=" +
+ lp.hasIPv4Address());
+ return netType == TYPE_MOBILE && !lp.hasIPv4Address();
+ }
+
+ /**
+ * Starts the clat daemon.
+ * @param lp The link properties of the interface to start clatd on.
+ */
+ public void startClat(NetworkStateTracker tracker) {
+ if (mIsStarted) {
+ Slog.e(TAG, "startClat: already started");
+ return;
+ }
+ mTracker = tracker;
+ LinkProperties lp = mTracker.getLinkProperties();
+ String iface = lp.getInterfaceName();
+ Slog.i(TAG, "Starting clatd on " + iface + ", lp=" + lp);
+ try {
+ mNMService.startClatd(iface);
+ } catch(RemoteException e) {
+ Slog.e(TAG, "Error starting clat daemon: " + e);
+ }
+ mIsStarted = true;
+ }
+
+ /**
+ * Stops the clat daemon.
+ */
+ public void stopClat() {
+ if (mIsStarted) {
+ Slog.i(TAG, "Stopping clatd");
+ try {
+ mNMService.stopClatd();
+ } catch(RemoteException e) {
+ Slog.e(TAG, "Error stopping clat daemon: " + e);
+ }
+ mIsStarted = false;
+ mIsRunning = false;
+ mTracker = null;
+ mLP.clear();
+ } else {
+ Slog.e(TAG, "stopClat: already stopped");
+ }
+ }
+
+ public boolean isStarted() {
+ return mIsStarted;
+ }
+
+ public boolean isRunning() {
+ return mIsRunning;
+ }
+
+ @Override
+ public void interfaceAdded(String iface) {
+ if (iface.equals(CLAT_INTERFACE_NAME)) {
+ Slog.i(TAG, "interface " + CLAT_INTERFACE_NAME +
+ " added, mIsRunning = " + mIsRunning + " -> true");
+ mIsRunning = true;
+
+ // Get the network configuration of the clat interface, store it
+ // in our link properties, and stack it on top of the interface
+ // it's running on.
+ try {
+ InterfaceConfiguration config = mNMService.getInterfaceConfig(iface);
+ mLP.clear();
+ mLP.setInterfaceName(iface);
+ RouteInfo ipv4Default = new RouteInfo(new LinkAddress(Inet4Address.ANY, 0), null,
+ iface);
+ mLP.addRoute(ipv4Default);
+ mLP.addLinkAddress(config.getLinkAddress());
+ mTracker.addStackedLink(mLP);
+ Slog.i(TAG, "Adding stacked link. tracker LP: " +
+ mTracker.getLinkProperties());
+ } catch(RemoteException e) {
+ Slog.e(TAG, "Error getting link properties: " + e);
+ }
+
+ // Inform ConnectivityService that things have changed.
+ Message msg = mHandler.obtainMessage(
+ NetworkStateTracker.EVENT_CONFIGURATION_CHANGED,
+ mTracker.getNetworkInfo());
+ Slog.i(TAG, "sending message to ConnectivityService: " + msg);
+ msg.sendToTarget();
+ }
+ }
+
+ @Override
+ public void interfaceRemoved(String iface) {
+ if (iface == CLAT_INTERFACE_NAME) {
+ if (mIsRunning) {
+ NetworkUtils.resetConnections(
+ CLAT_INTERFACE_NAME,
+ NetworkUtils.RESET_IPV4_ADDRESSES);
+ }
+ Slog.i(TAG, "interface " + CLAT_INTERFACE_NAME +
+ " removed, mIsRunning = " + mIsRunning + " -> false");
+ mIsRunning = false;
+ mTracker.removeStackedLink(mLP);
+ mLP.clear();
+ Slog.i(TAG, "mLP = " + mLP);
+ }
+ }
+};
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index e4a7ead..32f39b7 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -35,6 +35,7 @@
import android.net.LinkProperties;
import android.net.NetworkInfo;
import android.net.NetworkUtils;
+import android.net.RouteInfo;
import android.os.Binder;
import android.os.HandlerThread;
import android.os.IBinder;
@@ -1345,7 +1346,21 @@
linkProperties = mConnService.getLinkProperties(upType);
} catch (RemoteException e) { }
if (linkProperties != null) {
- iface = linkProperties.getInterfaceName();
+ // Find the interface with the default IPv4 route. It may be the
+ // interface described by linkProperties, or one of the interfaces
+ // stacked on top of it.
+ Log.i(TAG, "Finding IPv4 upstream interface on: " + linkProperties);
+ RouteInfo ipv4Default = RouteInfo.selectBestRoute(
+ linkProperties.getAllRoutes(), Inet4Address.ANY);
+ if (ipv4Default != null) {
+ iface = ipv4Default.getInterface();
+ Log.i(TAG, "Found interface " + ipv4Default.getInterface());
+ } else {
+ Log.i(TAG, "No IPv4 upstream interface, giving up.");
+ }
+ }
+
+ if (iface != null) {
String[] dnsServers = mDefaultDnsServers;
Collection<InetAddress> dnses = linkProperties.getDnses();
if (dnses != null) {
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 2d12a77..09d1426 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -5077,7 +5077,7 @@
final int N = pkg.requestedPermissions.size();
for (int i=0; i<N; i++) {
final String name = pkg.requestedPermissions.get(i);
- //final boolean required = pkg.requestedPermssionsRequired.get(i);
+ final boolean required = pkg.requestedPermissionsRequired.get(i);
final BasePermission bp = mSettings.mPermissions.get(name);
if (DEBUG_INSTALL) {
if (gp != ps) {
@@ -5091,7 +5091,9 @@
final int level = bp.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
if (level == PermissionInfo.PROTECTION_NORMAL
|| level == PermissionInfo.PROTECTION_DANGEROUS) {
- allowed = true;
+ // If the permission is required, or it's optional and was previously
+ // granted to the application, then allow it. Otherwise deny.
+ allowed = (required || origPermissions.contains(perm));
} else if (bp.packageSetting == null) {
// This permission is invalid; skip it.
allowed = false;
@@ -5141,11 +5143,7 @@
& PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
// For development permissions, a development permission
// is granted only if it was already granted.
- if (origPermissions.contains(perm)) {
- allowed = true;
- } else {
- allowed = false;
- }
+ allowed = origPermissions.contains(perm);
}
if (allowed) {
allowedSig = true;
diff --git a/services/java/com/android/server/wifi/WifiController.java b/services/java/com/android/server/wifi/WifiController.java
index 4d7c434..6e6b8cc 100644
--- a/services/java/com/android/server/wifi/WifiController.java
+++ b/services/java/com/android/server/wifi/WifiController.java
@@ -166,7 +166,7 @@
registerForStayAwakeModeChange(handler);
readWifiIdleTime();
registerForWifiIdleTimeChange(handler);
- readStayAwakeConditions();
+ readWifiSleepPolicy();
registerForWifiSleepPolicyChange(handler);
}
diff --git a/services/java/com/android/server/wm/ScreenRotationAnimation.java b/services/java/com/android/server/wm/ScreenRotationAnimation.java
index 3708df2..b2fbec1 100644
--- a/services/java/com/android/server/wm/ScreenRotationAnimation.java
+++ b/services/java/com/android/server/wm/ScreenRotationAnimation.java
@@ -234,6 +234,7 @@
mSurfaceControl.setLayer(FREEZE_LAYER + 1);
mSurfaceControl.setAlpha(0);
mSurfaceControl.show();
+ sur.destroy();
} catch (SurfaceControl.OutOfResourcesException e) {
Slog.w(TAG, "Unable to allocate freeze surface", e);
}
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index cfefadd..56f4de5 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -1481,7 +1481,11 @@
pos++;
}
if (pos >= N) {
- // All is good!
+ // Z order is good.
+ // The IM target window may be changed, so update the mTargetAppToken.
+ if (imWin != null) {
+ imWin.mTargetAppToken = mInputMethodTarget.mAppToken;
+ }
return false;
}
}
diff --git a/tests/BiDiTests/res/layout/canvas.xml b/tests/BiDiTests/res/layout/canvas.xml
new file mode 100644
index 0000000..0319a83
--- /dev/null
+++ b/tests/BiDiTests/res/layout/canvas.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/canvas"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <LinearLayout android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <SeekBar android:id="@+id/seekbar"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ />
+
+ <view class="com.android.bidi.BiDiTestView"
+ android:id="@+id/testview"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#FF0000"
+ />
+
+ </LinearLayout>
+
+</FrameLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestActivity.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestActivity.java
index b88a885..209597e 100644
--- a/tests/BiDiTests/src/com/android/bidi/BiDiTestActivity.java
+++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestActivity.java
@@ -101,6 +101,7 @@
addItem(result, "Basic", BiDiTestBasic.class, R.id.basic);
+ addItem(result, "Canvas", BiDiTestCanvas.class, R.id.canvas);
addItem(result, "Canvas2", BiDiTestCanvas2.class, R.id.canvas2);
addItem(result, "TextView LTR", BiDiTestTextViewLtr.class, R.id.textview_ltr);
diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestCanvas.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestCanvas.java
new file mode 100644
index 0000000..33ed731
--- /dev/null
+++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestCanvas.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 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.bidi;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.SeekBar;
+
+import static com.android.bidi.BiDiTestConstants.FONT_MAX_SIZE;
+import static com.android.bidi.BiDiTestConstants.FONT_MIN_SIZE;
+
+public class BiDiTestCanvas extends Fragment {
+
+ static final int INIT_TEXT_SIZE = (FONT_MAX_SIZE - FONT_MIN_SIZE) / 2;
+
+ private BiDiTestView testView;
+ private SeekBar textSizeSeekBar;
+ private View currentView;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ currentView = inflater.inflate(R.layout.canvas, container, false);
+ return currentView;
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ testView = (BiDiTestView) currentView.findViewById(R.id.testview);
+ testView.setCurrentTextSize(INIT_TEXT_SIZE);
+
+ textSizeSeekBar = (SeekBar) currentView.findViewById(R.id.seekbar);
+ textSizeSeekBar.setProgress(INIT_TEXT_SIZE);
+ textSizeSeekBar.setMax(FONT_MAX_SIZE - FONT_MIN_SIZE);
+
+ textSizeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ testView.setCurrentTextSize(FONT_MIN_SIZE + progress);
+ }
+
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+ });
+ }
+}
diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestView.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestView.java
new file mode 100644
index 0000000..0b1974a
--- /dev/null
+++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestView.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2011 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.bidi;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.text.TextPaint;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+
+public class BiDiTestView extends View {
+
+ private static final String TAG = "BiDiTestView";
+
+ private static final int BORDER_PADDING = 4;
+ private static final int TEXT_PADDING = 16;
+ private static final int TEXT_SIZE = 16;
+ private static final int ORIGIN = 80;
+
+ private static final float DEFAULT_ITALIC_SKEW_X = -0.25f;
+
+ private Rect rect = new Rect();
+
+ private String NORMAL_TEXT;
+ private String NORMAL_LONG_TEXT;
+ private String NORMAL_LONG_TEXT_2;
+ private String NORMAL_LONG_TEXT_3;
+ private String ITALIC_TEXT;
+ private String BOLD_TEXT;
+ private String BOLD_ITALIC_TEXT;
+ private String ARABIC_TEXT;
+ private String CHINESE_TEXT;
+ private String MIXED_TEXT_1;
+ private String HEBREW_TEXT;
+ private String RTL_TEXT;
+ private String THAI_TEXT;
+
+ private int currentTextSize;
+
+ public BiDiTestView(Context context) {
+ super(context);
+ init(context);
+ }
+
+ public BiDiTestView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init(context);
+ }
+
+ public BiDiTestView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ init(context);
+ }
+
+ private void init(Context context) {
+ NORMAL_TEXT = context.getString(R.string.normal_text);
+ NORMAL_LONG_TEXT = context.getString(R.string.normal_long_text);
+ NORMAL_LONG_TEXT_2 = context.getString(R.string.normal_long_text_2);
+ NORMAL_LONG_TEXT_3 = context.getString(R.string.normal_long_text_3);
+ ITALIC_TEXT = context.getString(R.string.italic_text);
+ BOLD_TEXT = context.getString(R.string.bold_text);
+ BOLD_ITALIC_TEXT = context.getString(R.string.bold_italic_text);
+ ARABIC_TEXT = context.getString(R.string.arabic_text);
+ CHINESE_TEXT = context.getString(R.string.chinese_text);
+ MIXED_TEXT_1 = context.getString(R.string.mixed_text_1);
+ HEBREW_TEXT = context.getString(R.string.hebrew_text);
+ RTL_TEXT = context.getString(R.string.rtl);
+ THAI_TEXT = context.getString(R.string.pointer_location);
+ }
+
+ public void setCurrentTextSize(int size) {
+ currentTextSize = size;
+ invalidate();
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ drawInsideRect(canvas, new Paint(), Color.BLACK);
+
+ int deltaX = 0;
+
+ deltaX = testString(canvas, NORMAL_TEXT, ORIGIN, ORIGIN,
+ false, false, Paint.DIRECTION_LTR, currentTextSize);
+
+ deltaX += testString(canvas, ITALIC_TEXT, ORIGIN + deltaX, ORIGIN,
+ true, false, Paint.DIRECTION_LTR, currentTextSize);
+
+ deltaX += testString(canvas, BOLD_TEXT, ORIGIN + deltaX, ORIGIN,
+ false, true, Paint.DIRECTION_LTR, currentTextSize);
+
+ deltaX += testString(canvas, BOLD_ITALIC_TEXT, ORIGIN + deltaX, ORIGIN,
+ true, true, Paint.DIRECTION_LTR, currentTextSize);
+
+ // Test with a long string
+ deltaX = testString(canvas, NORMAL_LONG_TEXT, ORIGIN, ORIGIN + 2 * currentTextSize,
+ false, false, Paint.DIRECTION_LTR, currentTextSize);
+
+ // Test with a long string
+ deltaX = testString(canvas, NORMAL_LONG_TEXT_2, ORIGIN, ORIGIN + 4 * currentTextSize,
+ false, false, Paint.DIRECTION_LTR, currentTextSize);
+
+ // Test with a long string
+ deltaX = testString(canvas, NORMAL_LONG_TEXT_3, ORIGIN, ORIGIN + 6 * currentTextSize,
+ false, false, Paint.DIRECTION_LTR, currentTextSize);
+
+ // Test Arabic ligature
+ deltaX = testString(canvas, ARABIC_TEXT, ORIGIN, ORIGIN + 8 * currentTextSize,
+ false, false, Paint.DIRECTION_RTL, currentTextSize);
+
+ // Test Chinese
+ deltaX = testString(canvas, CHINESE_TEXT, ORIGIN, ORIGIN + 10 * currentTextSize,
+ false, false, Paint.DIRECTION_LTR, currentTextSize);
+
+ // Test Mixed (English and Arabic)
+ deltaX = testString(canvas, MIXED_TEXT_1, ORIGIN, ORIGIN + 12 * currentTextSize,
+ false, false, Paint.DIRECTION_LTR, currentTextSize);
+
+ // Test Hebrew
+ deltaX = testString(canvas, RTL_TEXT, ORIGIN, ORIGIN + 14 * currentTextSize,
+ false, false, Paint.DIRECTION_RTL, currentTextSize);
+
+ // Test Thai
+ deltaX = testString(canvas, THAI_TEXT, ORIGIN, ORIGIN + 16 * currentTextSize,
+ false, false, Paint.DIRECTION_LTR, currentTextSize);
+ }
+
+ private int testString(Canvas canvas, String text, int x, int y,
+ boolean isItalic, boolean isBold, int dir, int textSize) {
+
+ TextPaint paint = new TextPaint();
+ paint.setAntiAlias(true);
+
+ // Set paint properties
+ boolean oldFakeBold = paint.isFakeBoldText();
+ paint.setFakeBoldText(isBold);
+
+ float oldTextSkewX = paint.getTextSkewX();
+ if (isItalic) {
+ paint.setTextSkewX(DEFAULT_ITALIC_SKEW_X);
+ }
+
+ paint.setTextSize(textSize);
+ paint.setColor(Color.WHITE);
+ canvas.drawText(text, x, y, paint);
+
+ int length = text.length();
+ float[] advances = new float[length];
+ float textWidthHB = paint.getTextRunAdvances(text, 0, length, 0, length, dir, advances, 0);
+ setPaintDir(paint, dir);
+ float textWidthICU = paint.getTextRunAdvances(text, 0, length, 0, length, dir, advances, 0,
+ 1 /* use ICU */);
+
+ logAdvances(text, textWidthHB, textWidthICU, advances);
+ drawMetricsAroundText(canvas, x, y, textWidthHB, textWidthICU, textSize, Color.RED, Color.GREEN);
+
+ // Restore old paint properties
+ paint.setFakeBoldText(oldFakeBold);
+ paint.setTextSkewX(oldTextSkewX);
+
+ return (int) Math.ceil(textWidthHB) + TEXT_PADDING;
+ }
+
+ private void setPaintDir(Paint paint, int dir) {
+ Log.v(TAG, "Setting Paint dir=" + dir);
+ paint.setBidiFlags(dir);
+ }
+
+ private void drawInsideRect(Canvas canvas, Paint paint, int color) {
+ paint.setColor(color);
+ int width = getWidth();
+ int height = getHeight();
+ rect.set(BORDER_PADDING, BORDER_PADDING, width - BORDER_PADDING, height - BORDER_PADDING);
+ canvas.drawRect(rect, paint);
+ }
+
+ private void drawMetricsAroundText(Canvas canvas, int x, int y, float textWidthHB,
+ float textWidthICU, int textSize, int color, int colorICU) {
+ Paint paint = new Paint();
+ paint.setColor(color);
+ canvas.drawLine(x, y - textSize, x, y + 8, paint);
+ canvas.drawLine(x, y + 8, x + textWidthHB, y + 8, paint);
+ canvas.drawLine(x + textWidthHB, y - textSize, x + textWidthHB, y + 8, paint);
+ paint.setColor(colorICU);
+ canvas.drawLine(x + textWidthICU, y - textSize, x + textWidthICU, y + 8, paint);
+ }
+
+ private void logAdvances(String text, float textWidth, float textWidthICU, float[] advances) {
+ Log.v(TAG, "Advances for text: " + text + " total= " + textWidth + " - totalICU= " + textWidthICU);
+// int length = advances.length;
+// for(int n=0; n<length; n++){
+// Log.v(TAG, "adv[" + n + "]=" + advances[n]);
+// }
+ }
+}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/MoreShadersActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/MoreShadersActivity.java
index 02cb4b6..1847f43 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/MoreShadersActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/MoreShadersActivity.java
@@ -57,6 +57,7 @@
private Paint mLargePaint;
private BitmapShader mScaled2Shader;
private ColorFilter mColorFilter;
+ private final Matrix mMtx1;
ShadersView(Context c) {
super(c);
@@ -70,7 +71,7 @@
mScaledShader = new BitmapShader(texture, Shader.TileMode.MIRROR,
Shader.TileMode.MIRROR);
Matrix m2 = new Matrix();
- m2.setScale(0.5f, 0.5f);
+ m2.setScale(0.1f, 0.1f);
mScaledShader.setLocalMatrix(m2);
mScaled2Shader = new BitmapShader(texture, Shader.TileMode.MIRROR,
@@ -81,12 +82,20 @@
mHorGradient = new LinearGradient(0.0f, 0.0f, mDrawWidth, 0.0f,
Color.RED, 0x7f00ff00, Shader.TileMode.CLAMP);
-
+ Matrix m4 = new Matrix();
+ m4.setScale(0.5f, 0.5f);
+ mHorGradient.setLocalMatrix(m4);
+
mVertGradient = new LinearGradient(0.0f, 0.0f, 0.0f, mDrawHeight / 2.0f,
Color.YELLOW, Color.MAGENTA, Shader.TileMode.MIRROR);
mComposeShader = new ComposeShader(mScaledShader, mHorGradient,
PorterDuff.Mode.SRC_OVER);
+ mMtx1 = new Matrix();
+ mMtx1.setTranslate(mTexWidth / 2.0f, mTexHeight / 2.0f);
+ mMtx1.postRotate(45, 0, 0);
+ mComposeShader.setLocalMatrix(mMtx1);
+
mCompose2Shader = new ComposeShader(mHorGradient, mScaledShader,
PorterDuff.Mode.SRC_OUT);
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ShapesActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ShapesActivity.java
index 97e5526..61dca78 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/ShapesActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ShapesActivity.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
+import android.graphics.Path;
import android.graphics.RectF;
import android.os.Bundle;
import android.view.View;
@@ -34,12 +35,13 @@
}
static class ShapesView extends View {
- private Paint mNormalPaint;
- private Paint mStrokePaint;
- private Paint mFillPaint;
- private RectF mRect;
- private RectF mOval;
- private RectF mArc;
+ private final Paint mNormalPaint;
+ private final Paint mStrokePaint;
+ private final Paint mFillPaint;
+ private final RectF mRect;
+ private final RectF mOval;
+ private final RectF mArc;
+ private final Path mTriangle;
ShapesView(Context c) {
super(c);
@@ -65,6 +67,12 @@
mOval = new RectF(0.0f, 0.0f, 80.0f, 45.0f);
mArc = new RectF(0.0f, 0.0f, 100.0f, 120.0f);
+
+ mTriangle = new Path();
+ mTriangle.moveTo(0.0f, 90.0f);
+ mTriangle.lineTo(45.0f, 0.0f);
+ mTriangle.lineTo(90.0f, 90.0f);
+ mTriangle.close();
}
@Override
@@ -136,6 +144,17 @@
canvas.translate(0.0f, 110.0f);
canvas.drawArc(mArc, 30.0f, 100.0f, false, mFillPaint);
canvas.restore();
+
+ canvas.save();
+ canvas.translate(50.0f, 400.0f);
+ canvas.drawPath(mTriangle, mNormalPaint);
+
+ canvas.translate(110.0f, 0.0f);
+ canvas.drawPath(mTriangle, mStrokePaint);
+
+ canvas.translate(110.0f, 0.0f);
+ canvas.drawPath(mTriangle, mFillPaint);
+ canvas.restore();
}
}
}
diff --git a/tests/RenderScriptTests/Balls/Android.mk b/tests/RenderScriptTests/Balls/Android.mk
deleted file mode 100644
index 77281ce..0000000
--- a/tests/RenderScriptTests/Balls/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2008 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := RsBalls
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/Balls/AndroidManifest.xml b/tests/RenderScriptTests/Balls/AndroidManifest.xml
deleted file mode 100644
index 80e6b39..0000000
--- a/tests/RenderScriptTests/Balls/AndroidManifest.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.rs.balls">
- <uses-sdk android:minSdkVersion="14" />
- <application
- android:label="RsBalls"
- android:icon="@drawable/test_pattern">
- <activity android:name="Balls"
- android:screenOrientation="landscape">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/Balls/_index.html b/tests/RenderScriptTests/Balls/_index.html
deleted file mode 100644
index 8760485..0000000
--- a/tests/RenderScriptTests/Balls/_index.html
+++ /dev/null
@@ -1 +0,0 @@
-<p>A brute force physics simulation that renders many balls onto the screen and moves them according to user touch and gravity.</p>
\ No newline at end of file
diff --git a/tests/RenderScriptTests/Balls/res/drawable/flares.png b/tests/RenderScriptTests/Balls/res/drawable/flares.png
deleted file mode 100644
index 3a5c970..0000000
--- a/tests/RenderScriptTests/Balls/res/drawable/flares.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/Balls/res/drawable/test_pattern.png b/tests/RenderScriptTests/Balls/res/drawable/test_pattern.png
deleted file mode 100644
index e7d1455..0000000
--- a/tests/RenderScriptTests/Balls/res/drawable/test_pattern.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/Balls.java b/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/Balls.java
deleted file mode 100644
index 2c6558e..0000000
--- a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/Balls.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2008 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.example.android.rs.balls;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.provider.Settings.System;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.ListView;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.view.View;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-
-public class Balls extends Activity implements SensorEventListener {
- //EventListener mListener = new EventListener();
-
- private static final String LOG_TAG = "libRS_jni";
- private static final boolean DEBUG = false;
- private static final boolean LOG_ENABLED = false;
-
- private BallsView mView;
- private SensorManager mSensorManager;
-
- // get the current looper (from your Activity UI thread for instance
-
-
- public void onSensorChanged(SensorEvent event) {
- //android.util.Log.d("rs", "sensor: " + event.sensor + ", x: " + event.values[0] + ", y: " + event.values[1] + ", z: " + event.values[2]);
- synchronized (this) {
- if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
- if(mView != null) {
- mView.setAccel(event.values[0], event.values[1], event.values[2]);
- }
- }
- }
- }
-
- public void onAccuracyChanged(Sensor sensor, int accuracy) {
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new BallsView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- mSensorManager.registerListener(this,
- mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
- SensorManager.SENSOR_DELAY_FASTEST);
-
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mView.pause();
- onStop();
- }
-
- @Override
- protected void onStop() {
- mSensorManager.unregisterListener(this);
- super.onStop();
- }
-
- static void log(String message) {
- if (LOG_ENABLED) {
- Log.v(LOG_TAG, message);
- }
- }
-
-
-}
-
diff --git a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/BallsRS.java b/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/BallsRS.java
deleted file mode 100644
index d9d182c..0000000
--- a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/BallsRS.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2008 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.example.android.rs.balls;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-
-
-public class BallsRS {
- public static final int PART_COUNT = 4000;
-
- public BallsRS() {
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
- private ScriptC_balls mScript;
- private ScriptC_ball_physics mPhysicsScript;
- private ProgramFragment mPFPoints;
- private ScriptField_Point mPoints;
- private ScriptField_VpConsts mVpConsts;
- private ScriptField_BallGrid mGrid;
- private ScriptField_Ball mBalls;
- private Allocation mGridCache;
-
- void updateProjectionMatrices() {
- mVpConsts = new ScriptField_VpConsts(mRS, 1,
- Allocation.USAGE_SCRIPT |
- Allocation.USAGE_GRAPHICS_CONSTANTS);
- ScriptField_VpConsts.Item i = new ScriptField_VpConsts.Item();
- Matrix4f mvp = new Matrix4f();
- mvp.loadOrtho(0, mRS.getWidth(), mRS.getHeight(), 0, -1, 1);
- i.MVP = mvp;
- mVpConsts.set(i, 0, true);
- }
-
- private void createProgramVertex() {
- updateProjectionMatrices();
-
- ProgramVertex.Builder sb = new ProgramVertex.Builder(mRS);
- String t = "varying vec4 varColor;\n" +
- "void main() {\n" +
- " vec4 pos = vec4(0.0, 0.0, 0.0, 1.0);\n" +
- " pos.xy = ATTRIB_position;\n" +
- " gl_Position = UNI_MVP * pos;\n" +
- " varColor = ATTRIB_color;\n" +
- " gl_PointSize = 12.0;\n" +
- "}\n";
- sb.setShader(t);
- sb.addConstant(mVpConsts.getType());
- sb.addInput(mPoints.getElement());
- ProgramVertex pvs = sb.create();
- pvs.bindConstants(mVpConsts.getAllocation(), 0);
- mRS.bindProgramVertex(pvs);
- }
-
- private Allocation loadTexture(int id) {
- final Allocation allocation =
- Allocation.createFromBitmapResource(mRS, mRes,
- id, Allocation.MipmapControl.MIPMAP_NONE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- return allocation;
- }
-
- ProgramStore BLEND_ADD_DEPTH_NONE(RenderScript rs) {
- ProgramStore.Builder builder = new ProgramStore.Builder(rs);
- builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
- builder.setBlendFunc(ProgramStore.BlendSrcFunc.ONE, ProgramStore.BlendDstFunc.ONE);
- builder.setDitherEnabled(false);
- builder.setDepthMaskEnabled(false);
- return builder.create();
- }
-
- private void createPF(int width, int height) {
- ProgramFragmentFixedFunction.Builder pfb = new ProgramFragmentFixedFunction.Builder(mRS);
- pfb.setPointSpriteTexCoordinateReplacement(true);
- pfb.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.MODULATE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- pfb.setVaryingColor(true);
- mPFPoints = pfb.create();
- }
-
- public void init(RenderScriptGL rs, Resources res, int width, int height) {
- mRS = rs;
- mRes = res;
-
- createPF(width, height);
-
- mPFPoints.bindTexture(loadTexture(R.drawable.flares), 0);
-
- mPoints = new ScriptField_Point(mRS, PART_COUNT, Allocation.USAGE_SCRIPT);
-
- Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS);
- smb.addVertexAllocation(mPoints.getAllocation());
- smb.addIndexSetType(Mesh.Primitive.POINT);
- Mesh smP = smb.create();
-
- mGrid = ScriptField_BallGrid.create2D(mRS, (width + 99) / 100, (height + 99) / 100);
- mGridCache = Allocation.createSized(mRS, Element.F32_2(mRS), PART_COUNT);
- mBalls = new ScriptField_Ball(mRS, PART_COUNT, Allocation.USAGE_SCRIPT);
-
- mPhysicsScript = new ScriptC_ball_physics(mRS);
- mPhysicsScript.set_gGridCache(mGridCache);
- mPhysicsScript.set_gBalls(mBalls.getAllocation());
-
- mScript = new ScriptC_balls(mRS);
- mScript.set_partMesh(smP);
- mScript.set_physics_script(mPhysicsScript);
- mScript.bind_point(mPoints);
- mScript.bind_balls(mBalls);
- mScript.set_gGrid(mGrid.getAllocation());
- mScript.bind_gGridCache(mGridCache);
-
- mScript.set_gPFPoints(mPFPoints);
- createProgramVertex();
-
- mRS.bindProgramStore(BLEND_ADD_DEPTH_NONE(mRS));
-
- mPhysicsScript.set_gMinPos(new Float2(5, 5));
- mPhysicsScript.set_gMaxPos(new Float2(width - 5, height - 5));
- mPhysicsScript.set_gGrid(mGrid.getAllocation());
-
- mScript.invoke_initParts(width, height);
-
- mRS.bindRootScript(mScript);
- }
-
- public void newTouchPosition(float x, float y, float pressure, int id) {
- mPhysicsScript.invoke_touch(x, y, pressure * mRS.getWidth() / 1280, id);
- }
-
- public void setAccel(float x, float y) {
- mPhysicsScript.set_gGravityVector(new Float2(x, y));
- }
-
-}
diff --git a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/BallsView.java b/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/BallsView.java
deleted file mode 100644
index 041782d..0000000
--- a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/BallsView.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2008 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.example.android.rs.balls;
-
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.concurrent.Semaphore;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-
-public class BallsView extends RSSurfaceView {
-
- public BallsView(Context context) {
- super(context);
- //setFocusable(true);
- }
-
- private RenderScriptGL mRS;
- private BallsRS mRender;
-
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- mRS = createRenderScriptGL(sc);
- mRS.setSurface(holder, w, h);
- mRender = new BallsRS();
- mRender.init(mRS, getResources(), w, h);
- }
- mRender.updateProjectionMatrices();
- }
-
- @Override
- protected void onDetachedFromWindow() {
- if(mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
-
- @Override
- public boolean onTouchEvent(MotionEvent ev)
- {
- int act = ev.getActionMasked();
- if (act == ev.ACTION_UP) {
- mRender.newTouchPosition(0, 0, 0, ev.getPointerId(0));
- return false;
- } else if (act == MotionEvent.ACTION_POINTER_UP) {
- // only one pointer going up, we can get the index like this
- int pointerIndex = ev.getActionIndex();
- int pointerId = ev.getPointerId(pointerIndex);
- mRender.newTouchPosition(0, 0, 0, pointerId);
- return false;
- }
- int count = ev.getHistorySize();
- int pcount = ev.getPointerCount();
-
- for (int p=0; p < pcount; p++) {
- int id = ev.getPointerId(p);
- mRender.newTouchPosition(ev.getX(p),
- ev.getY(p),
- ev.getPressure(p),
- id);
-
- for (int i=0; i < count; i++) {
- mRender.newTouchPosition(ev.getHistoricalX(p, i),
- ev.getHistoricalY(p, i),
- ev.getHistoricalPressure(p, i),
- id);
- }
- }
- return true;
- }
-
- void setAccel(float x, float y, float z) {
- if ((mRender == null) || (mRS == null)) {
- return;
- }
- mRender.setAccel(x, -y);
- }
-
-}
-
-
diff --git a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/ball_physics.rs b/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/ball_physics.rs
deleted file mode 100644
index 5b5d2e0..0000000
--- a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/ball_physics.rs
+++ /dev/null
@@ -1,155 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(com.example.android.rs.balls)
-
-#include "balls.rsh"
-
-float2 gGravityVector = {0.f, 9.8f};
-
-float2 gMinPos = {0.f, 0.f};
-float2 gMaxPos = {1280.f, 700.f};
-
-static float2 touchPos[10];
-static float touchPressure[10];
-static const float gDT = 1.f / 30.f;
-
-rs_allocation gGrid;
-rs_allocation gGridCache;
-rs_allocation gBalls;
-
-float gScale = 1.f;
-
-void touch(float x, float y, float pressure, int id) {
- if (id >= 10) {
- return;
- }
-
- touchPos[id].x = x;
- touchPos[id].y = y;
- touchPressure[id] = pressure;
-}
-
-void root(Ball_t *ball, uint32_t x) {
- float2 fv = 0;
- float pressure = 0;
- float2 pos = ball->position;
- int2 gridPos[9];
-
- gridPos[0] = convert_int2((ball->position / 100.f) /*- 0.4999f*/);
- gridPos[1] = (int2){gridPos[0].x - 1, gridPos[0].y - 1};
- gridPos[2] = (int2){gridPos[0].x + 0, gridPos[0].y - 1};
- gridPos[3] = (int2){gridPos[0].x + 1, gridPos[0].y - 1};
- gridPos[4] = (int2){gridPos[0].x - 1, gridPos[0].y};
- gridPos[5] = (int2){gridPos[0].x + 1, gridPos[0].y};
- gridPos[6] = (int2){gridPos[0].x - 1, gridPos[0].y + 1};
- gridPos[7] = (int2){gridPos[0].x + 0, gridPos[0].y + 1};
- gridPos[8] = (int2){gridPos[0].x + 1, gridPos[0].y + 1};
-
- for (int gct=0; gct < 9; gct++) {
- if ((gridPos[gct].x >= rsAllocationGetDimX(gGrid)) ||
- (gridPos[gct].x < 0) ||
- (gridPos[gct].y >= rsAllocationGetDimY(gGrid)) ||
- (gridPos[gct].y < 0)) {
- continue;
- }
- //rsDebug("grid ", gridPos[gct]);
- const BallGrid_t *bg = (const BallGrid_t *)rsGetElementAt(gGrid, gridPos[gct].x, gridPos[gct].y);
-
- for (int cidx = 0; cidx < bg->count; cidx++) {
- float2 bcptr = rsGetElementAt_float2(gGridCache, bg->cacheIdx + cidx);
- float2 vec = bcptr - pos;
- float2 vec2 = vec * vec;
- float len2 = vec2.x + vec2.y;
-
- if ((len2 < 10000.f) && (len2 > 0.f)) {
- float t = native_powr(len2, 1.5f) + 16.0f;
- float2 pfv = (vec / t) * 16000.f;
- pressure += length(pfv);
- fv -= pfv;
- }
- }
- }
-
- //fv /= ball->size * ball->size * ball->size;
- fv -= gGravityVector * 4.f * gScale;
- fv *= gDT;
-
- for (int i=0; i < 10; i++) {
- if (touchPressure[i] > 0.1f) {
- float2 vec = touchPos[i] - ball->position;
- float2 vec2 = vec * vec;
- float len2 = max(2.f, vec2.x + vec2.y);
- float2 pfv = (vec / len2) * touchPressure[i] * 500.f * gScale;
- pressure += length(pfv);
- fv -= pfv;
- }
- }
-
- ball->delta = (ball->delta * (1.f - 0.008f)) + fv;
- ball->position = ball->position + (ball->delta * gDT);
-
- const float wallForce = 400.f * gScale;
- if (ball->position.x > (gMaxPos.x - 20.f)) {
- float d = gMaxPos.x - ball->position.x;
- if (d < 0.f) {
- if (ball->delta.x > 0) {
- ball->delta.x *= -0.7f;
- }
- ball->position.x = gMaxPos.x - 1.f;
- } else {
- ball->delta.x -= min(wallForce / (d * d), 10.f);
- }
- }
-
- if (ball->position.x < (gMinPos.x + 20.f)) {
- float d = ball->position.x - gMinPos.x;
- if (d < 0.f) {
- if (ball->delta.x < 0) {
- ball->delta.x *= -0.7f;
- }
- ball->position.x = gMinPos.x + 1.f;
- } else {
- ball->delta.x += min(wallForce / (d * d), 10.f);
- }
- }
-
- if (ball->position.y > (gMaxPos.y - 20.f)) {
- float d = gMaxPos.y - ball->position.y;
- if (d < 0.f) {
- if (ball->delta.y > 0) {
- ball->delta.y *= -0.7f;
- }
- ball->position.y = gMaxPos.y - 1.f;
- } else {
- ball->delta.y -= min(wallForce / (d * d), 10.f);
- }
- }
-
- if (ball->position.y < (gMinPos.y + 20.f)) {
- float d = ball->position.y - gMinPos.y;
- if (d < 0.f) {
- if (ball->delta.y < 0) {
- ball->delta.y *= -0.7f;
- }
- ball->position.y = gMinPos.y + 1.f;
- } else {
- ball->delta.y += min(wallForce / (d * d * d), 10.f);
- }
- }
-
- // low pressure ~500, high ~2500
- pressure = max(pressure - 400.f, 0.f);
- ball->pressure = pressure;
-
- //rsDebug("p ", pressure);
-
- float4 color = 1.f;
- color.r = pow(pressure, 0.25f) / 12.f;
- color.b = 1.f - color.r;
- color.g = sin(pressure / 1500.f * 3.14f);
- color.rgb = max(color.rgb, (float3)0);
- color.rgb = normalize(color.rgb);
- ball->color = rsPackColorTo8888(color);
-
- //rsDebug("physics pos out", ball->position);
-}
-
diff --git a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/balls.rs b/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/balls.rs
deleted file mode 100644
index 9be9f38..0000000
--- a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/balls.rs
+++ /dev/null
@@ -1,106 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(com.example.android.rs.balls)
-#include "rs_graphics.rsh"
-
-#include "balls.rsh"
-
-#pragma stateVertex(parent)
-#pragma stateStore(parent)
-
-rs_program_fragment gPFPoints;
-rs_mesh partMesh;
-
-rs_allocation gGrid;
-BallGrid_t *unused1;
-float2 *gGridCache;
-
-typedef struct __attribute__((packed, aligned(4))) Point {
- float2 position;
- uchar4 color;
-} Point_t;
-Point_t *point;
-
-typedef struct VpConsts {
- rs_matrix4x4 MVP;
-} VpConsts_t;
-VpConsts_t *vpConstants;
-
-rs_script physics_script;
-
-
-void initParts(int w, int h)
-{
- uint32_t dimX = rsAllocationGetDimX(rsGetAllocation(balls));
-
- for (uint32_t ct=0; ct < dimX; ct++) {
- balls[ct].position.x = rsRand(0.f, (float)w);
- balls[ct].position.y = rsRand(0.f, (float)h);
- balls[ct].delta.x = 0.f;
- balls[ct].delta.y = 0.f;
- }
-}
-
-int root() {
- rsgClearColor(0.f, 0.f, 0.f, 1.f);
-
- int2 gridDims = (int2){ rsAllocationGetDimX(gGrid),
- rsAllocationGetDimY(gGrid) };
-
- rs_allocation ain = rsGetAllocation(balls);
- int32_t dimX = rsAllocationGetDimX(ain);
-
- // Binning
- // Clear the particle list
- for (uint32_t ct=0; ct < dimX; ct++) {
- balls[ct].next = -1;
- }
-
- // Clear the grid
- for (uint32_t y=0; y < gridDims.y; y++) {
- for (uint32_t x=0; x < gridDims.x; x++) {
- BallGrid_t *bg = (BallGrid_t *)rsGetElementAt(gGrid, x, y);
- bg->count = 0;
- bg->idx = -1;
- }
- }
-
- // Create the particle list per grid
- for (uint32_t ct=0; ct < dimX; ct++) {
- int2 p = convert_int2(balls[ct].position / 100.f);
- p.x = rsClamp(p.x, 0, (int)(gridDims.x-1));
- p.y = rsClamp(p.y, 0, (int)(gridDims.y-1));
- BallGrid_t *bg = (BallGrid_t *)rsGetElementAt(gGrid, p.x, p.y);
- bg->count ++;
- balls[ct].next = bg->idx;
- bg->idx = ct;
- }
-
- // Create the sorted grid cache
- uint32_t gridIdx = 0;
- for (uint32_t y=0; y < gridDims.y; y++) {
- for (uint32_t x=0; x < gridDims.x; x++) {
- BallGrid_t *bg = (BallGrid_t *)rsGetElementAt(gGrid, x, y);
- bg->cacheIdx = gridIdx;
-
- int idx = bg->idx;
- while (idx >= 0) {
- const Ball_t * bPtr = &balls[idx];
- gGridCache[gridIdx++] = bPtr->position;
- idx = bPtr->next;
- }
- }
- }
-
-
- rsForEach(physics_script, ain, ain);
-
- for (uint32_t ct=0; ct < dimX; ct++) {
- point[ct].position = balls[ct].position;
- point[ct].color = balls[ct].color;
- }
-
- rsgBindProgramFragment(gPFPoints);
- rsgDrawMesh(partMesh);
- return 1;
-}
-
diff --git a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/balls.rsh b/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/balls.rsh
deleted file mode 100644
index ebe23f8..0000000
--- a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/balls.rsh
+++ /dev/null
@@ -1,19 +0,0 @@
-
-typedef struct __attribute__((packed, aligned(4))) Ball {
- float2 delta;
- float2 position;
- uchar4 color;
- float pressure;
- //float size;
- int32_t next;
- //int arcID;
- //float arcStr;
-} Ball_t;
-Ball_t *balls;
-
-
-typedef struct BallGrid {
- int32_t idx;
- int32_t count;
- int32_t cacheIdx;
-} BallGrid_t;
diff --git a/tests/RenderScriptTests/ComputeBenchmark/Android.mk b/tests/RenderScriptTests/ComputeBenchmark/Android.mk
deleted file mode 100644
index 8d47e89..0000000
--- a/tests/RenderScriptTests/ComputeBenchmark/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2012 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
- $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := RsComputeBenchmark
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/ComputeBenchmark/AndroidManifest.xml b/tests/RenderScriptTests/ComputeBenchmark/AndroidManifest.xml
deleted file mode 100644
index c8fcc17..0000000
--- a/tests/RenderScriptTests/ComputeBenchmark/AndroidManifest.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.rs.computebench">
-
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-sdk android:minSdkVersion="17" />
- <application android:label="_RS_Compute_Bench">
- <activity android:name="ComputeBench">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/ComputeBenchmark/res/layout/main.xml b/tests/RenderScriptTests/ComputeBenchmark/res/layout/main.xml
deleted file mode 100644
index 9e9dab8..0000000
--- a/tests/RenderScriptTests/ComputeBenchmark/res/layout/main.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ImageView
- android:id="@+id/displayin"
- android:layout_width="320dip"
- android:layout_height="266dip" />
-
- <ImageView
- android:id="@+id/displayout"
- android:layout_width="320dip"
- android:layout_height="266dip" />
-
-</LinearLayout>
diff --git a/tests/RenderScriptTests/ComputeBenchmark/src/com/example/android/rs/computebench/Benchmark.java b/tests/RenderScriptTests/ComputeBenchmark/src/com/example/android/rs/computebench/Benchmark.java
deleted file mode 100644
index ec80719..0000000
--- a/tests/RenderScriptTests/ComputeBenchmark/src/com/example/android/rs/computebench/Benchmark.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2012 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.example.android.rs.computebench;
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class Benchmark implements Runnable {
- private final RenderScript mRS;
- private ScriptC_compute_benchmark mScript;
-
- public Benchmark(RenderScript rs, Resources res) {
- mRS = rs;
- mScript = new ScriptC_compute_benchmark(mRS, res, R.raw.compute_benchmark);
- }
-
- public void run() {
- long t = java.lang.System.currentTimeMillis();
- mScript.invoke_bench();
- mRS.finish();
- t = java.lang.System.currentTimeMillis() - t;
- android.util.Log.v("ComputeBench", "Total benchmark took " + t + " ms");
- }
-
-}
diff --git a/tests/RenderScriptTests/ComputeBenchmark/src/com/example/android/rs/computebench/ComputeBench.java b/tests/RenderScriptTests/ComputeBenchmark/src/com/example/android/rs/computebench/ComputeBench.java
deleted file mode 100644
index 2d3e843..0000000
--- a/tests/RenderScriptTests/ComputeBenchmark/src/com/example/android/rs/computebench/ComputeBench.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 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.example.android.rs.computebench;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.renderscript.RenderScript;
-
-public class ComputeBench extends Activity {
- private RenderScript mRS;
- private Benchmark mBenchmark;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- mRS = RenderScript.create(this);
-
- mBenchmark = new Benchmark(mRS, getResources());
- mBenchmark.run();
- }
-}
diff --git a/tests/RenderScriptTests/ComputeBenchmark/src/com/example/android/rs/computebench/compute_benchmark.rs b/tests/RenderScriptTests/ComputeBenchmark/src/com/example/android/rs/computebench/compute_benchmark.rs
deleted file mode 100644
index 2ee56ec..0000000
--- a/tests/RenderScriptTests/ComputeBenchmark/src/com/example/android/rs/computebench/compute_benchmark.rs
+++ /dev/null
@@ -1,407 +0,0 @@
-// Copyright (C) 2012 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.
-
-#pragma version(1)
-#pragma rs java_package_name(com.example.android.rs.computebench)
-
-// Test configuration (accessible from Java)
-uint priming_runs = 1000000;
-uint timing_runs = 5000000;
-
-// Reused variables
-
-static volatile int64_t bench_time;
-static float inv_timing_runs;
-
-#define DECL_VAR_SET(prefix) \
-static volatile float prefix##_f_1 = 1; \
-static volatile float2 prefix##_f_2 = 1; \
-static volatile float3 prefix##_f_3 = 1; \
-static volatile float4 prefix##_f_4 = 1; \
-static volatile char prefix##_c_1 = 1; \
-static volatile char2 prefix##_c_2 = 1; \
-static volatile char3 prefix##_c_3 = 1; \
-static volatile char4 prefix##_c_4 = 1; \
-static volatile uchar prefix##_uc_1 = 1; \
-static volatile uchar2 prefix##_uc_2 = 1; \
-static volatile uchar3 prefix##_uc_3 = 1; \
-static volatile uchar4 prefix##_uc_4 = 1; \
-static volatile short prefix##_s_1 = 1; \
-static volatile short2 prefix##_s_2 = 1; \
-static volatile short3 prefix##_s_3 = 1; \
-static volatile short4 prefix##_s_4 = 1; \
-static volatile ushort prefix##_us_1 = 1; \
-static volatile ushort2 prefix##_us_2 = 1; \
-static volatile ushort3 prefix##_us_3 = 1; \
-static volatile ushort4 prefix##_us_4 = 1; \
-static volatile int prefix##_i_1 = 1; \
-static volatile int2 prefix##_i_2 = 1; \
-static volatile int3 prefix##_i_3 = 1; \
-static volatile int4 prefix##_i_4 = 1; \
-static volatile uint prefix##_ui_1 = 1; \
-static volatile uint2 prefix##_ui_2 = 1; \
-static volatile uint3 prefix##_ui_3 = 1; \
-static volatile uint4 prefix##_ui_4 = 1; \
-static volatile long prefix##_l_1 = 1; \
-static volatile long2 prefix##_l_2 = 1; \
-static volatile long3 prefix##_l_3 = 1; \
-static volatile long4 prefix##_l_4 = 1; \
-static volatile ulong prefix##_ul_1 = 1; \
-static volatile ulong2 prefix##_ul_2 = 1; \
-static volatile ulong3 prefix##_ul_3 = 1; \
-static volatile ulong4 prefix##_ul_4 = 1; \
-
-DECL_VAR_SET(res)
-DECL_VAR_SET(src1)
-DECL_VAR_SET(src2)
-DECL_VAR_SET(src3)
-
-
-// Testing macros
-
-#define RUN_BENCH(line, op) \
- for (int i = priming_runs - 1; i >= 0; --i) { \
- line; \
- } \
- bench_time = rsUptimeMillis(); \
- for (int i = timing_runs - 1; i >= 0; --i) { \
- line; \
- } \
- bench_time = rsUptimeMillis() - bench_time; \
- rsDebug(" " op " took ns", (float)bench_time * inv_timing_runs);
-
-#define BENCH_BASIC_OP_TYPE(op, type) \
- RUN_BENCH(res_##type##_1 = src1_##type##_1 op src2_##type##_1, #type "1 " #op " " #type "1") \
- RUN_BENCH(res_##type##_2 = src1_##type##_2 op src2_##type##_2, #type "2 " #op " " #type "2") \
- RUN_BENCH(res_##type##_3 = src1_##type##_3 op src2_##type##_3, #type "3 " #op " " #type "3") \
- RUN_BENCH(res_##type##_4 = src1_##type##_4 op src2_##type##_4, #type "4 " #op " " #type "4") \
-
-#define BENCH_BASIC_INT_OP(op) \
- rsDebug("Testing basic operation " #op, 0); \
- BENCH_BASIC_OP_TYPE(op, c) \
- BENCH_BASIC_OP_TYPE(op, uc) \
- BENCH_BASIC_OP_TYPE(op, s) \
- BENCH_BASIC_OP_TYPE(op, us) \
- BENCH_BASIC_OP_TYPE(op, i) \
- BENCH_BASIC_OP_TYPE(op, ui) \
- RUN_BENCH(res_l_1 = src1_l_1 op src2_l_1, "l1 " #op " l1") \
- RUN_BENCH(res_ul_1 = src1_ul_1 op src2_ul_1, "ul1 " #op " ul1")
-
-#define BENCH_BASIC_OP(op) \
- BENCH_BASIC_INT_OP(op) \
- BENCH_BASIC_OP_TYPE(op, f)
-
-#define BENCH_CVT(to, from, type) \
- rsDebug("Testing convert from " #from " to " #to, 0); \
- RUN_BENCH(res_##to##_1 = (type)src1_##from##_1, "(" #to ")" #from) \
- RUN_BENCH(res_##to##_2 = convert_##type##2(src1_##from##_2), #to "2 convert_" #type "2(" #from "2)") \
- RUN_BENCH(res_##to##_3 = convert_##type##3(src1_##from##_3), #to "3 convert_" #type "3(" #from "3)") \
- RUN_BENCH(res_##to##_4 = convert_##type##4(src1_##from##_4), #to "4 convert_" #type "4(" #from "4)")
-
-#define BENCH_CVT_MATRIX(to, type) \
- BENCH_CVT(to, c, type); \
- BENCH_CVT(to, uc, type); \
- BENCH_CVT(to, s, type); \
- BENCH_CVT(to, us, type); \
- BENCH_CVT(to, i, type); \
- BENCH_CVT(to, ui, type); \
- BENCH_CVT(to, f, type); \
-
-#define BENCH_XN_FUNC_YN(typeout, fnc, typein) \
- RUN_BENCH(res_##typeout##_1 = fnc(src1_##typein##_1);, #typeout "1 " #fnc "(" #typein "1)") \
- RUN_BENCH(res_##typeout##_2 = fnc(src1_##typein##_2);, #typeout "2 " #fnc "(" #typein "2)") \
- RUN_BENCH(res_##typeout##_3 = fnc(src1_##typein##_3);, #typeout "3 " #fnc "(" #typein "3)") \
- RUN_BENCH(res_##typeout##_4 = fnc(src1_##typein##_4);, #typeout "4 " #fnc "(" #typein "4)")
-
-#define BENCH_XN_FUNC_XN_XN(type, fnc) \
- RUN_BENCH(res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1), #type "1 " #fnc "(" #type "1, " #type "1)") \
- RUN_BENCH(res_##type##_2 = fnc(src1_##type##_2, src2_##type##_2), #type "2 " #fnc "(" #type "2, " #type "2)") \
- RUN_BENCH(res_##type##_3 = fnc(src1_##type##_3, src2_##type##_3), #type "3 " #fnc "(" #type "3, " #type "3)") \
- RUN_BENCH(res_##type##_4 = fnc(src1_##type##_4, src2_##type##_4), #type "4 " #fnc "(" #type "4, " #type "4)") \
-
-#define BENCH_X_FUNC_X_X_X(type, fnc) \
- RUN_BENCH(res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1, src3_##type##_1), #type "1 " #fnc "(" #type "1, " #type "1, " #type "1)")
-
-#define BENCH_IN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- BENCH_XN_FUNC_YN(uc, fnc, uc) \
- BENCH_XN_FUNC_YN(c, fnc, c) \
- BENCH_XN_FUNC_YN(us, fnc, us) \
- BENCH_XN_FUNC_YN(s, fnc, s) \
- BENCH_XN_FUNC_YN(ui, fnc, ui) \
- BENCH_XN_FUNC_YN(i, fnc, i)
-
-#define BENCH_UIN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- BENCH_XN_FUNC_YN(uc, fnc, c) \
- BENCH_XN_FUNC_YN(us, fnc, s) \
- BENCH_XN_FUNC_YN(ui, fnc, i) \
-
-#define BENCH_IN_FUNC_IN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- BENCH_XN_FUNC_XN_XN(uc, fnc) \
- BENCH_XN_FUNC_XN_XN(c, fnc) \
- BENCH_XN_FUNC_XN_XN(us, fnc) \
- BENCH_XN_FUNC_XN_XN(s, fnc) \
- BENCH_XN_FUNC_XN_XN(ui, fnc) \
- BENCH_XN_FUNC_XN_XN(i, fnc)
-
-#define BENCH_I_FUNC_I_I_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- BENCH_X_FUNC_X_X_X(uc, fnc) \
- BENCH_X_FUNC_X_X_X(c, fnc) \
- BENCH_X_FUNC_X_X_X(us, fnc) \
- BENCH_X_FUNC_X_X_X(s, fnc) \
- BENCH_X_FUNC_X_X_X(ui, fnc) \
- BENCH_X_FUNC_X_X_X(i, fnc)
-
-#define BENCH_FN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1), "f1 " #fnc "(f1)") \
- RUN_BENCH(res_f_2 = fnc(src1_f_2), "f2 " #fnc "(f2)") \
- RUN_BENCH(res_f_3 = fnc(src1_f_3), "f3 " #fnc "(f3)") \
- RUN_BENCH(res_f_4 = fnc(src1_f_4), "f4 " #fnc "(f4)")
-
-#define BENCH_FN_FUNC_FN_PFN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1, (float*) &src2_f_1), "f1 " #fnc "(f1, f1*)") \
- RUN_BENCH(res_f_2 = fnc(src1_f_2, (float2*) &src2_f_2), "f2 " #fnc "(f2, f2*)") \
- RUN_BENCH(res_f_3 = fnc(src1_f_3, (float3*) &src2_f_3), "f3 " #fnc "(f3, f3*)") \
- RUN_BENCH(res_f_4 = fnc(src1_f_4, (float4*) &src2_f_4), "f4 " #fnc "(f4, f4*)")
-
-#define BENCH_FN_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1, src2_f_1), "f1 " #fnc "(f1, f1)") \
- RUN_BENCH(res_f_2 = fnc(src1_f_2, src2_f_2), "f2 " #fnc "(f2, f2)") \
- RUN_BENCH(res_f_3 = fnc(src1_f_3, src2_f_3), "f3 " #fnc "(f3, f3)") \
- RUN_BENCH(res_f_4 = fnc(src1_f_4, src2_f_4), "f4 " #fnc "(f4, f4)")
-
-#define BENCH_F34_FUNC_F34_F34(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_3 = fnc(src1_f_3, src2_f_3), "f3 " #fnc "(f3, f3)") \
- RUN_BENCH(res_f_4 = fnc(src1_f_4, src2_f_4), "f4 " #fnc "(f4, f4)")
-
-#define BENCH_FN_FUNC_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1, src2_f_1), "f1 " #fnc "(f1, f1)") \
- RUN_BENCH(res_f_2 = fnc(src1_f_2, src2_f_1), "f2 " #fnc "(f2, f1)") \
- RUN_BENCH(res_f_3 = fnc(src1_f_3, src2_f_1), "f3 " #fnc "(f3, f1)") \
- RUN_BENCH(res_f_4 = fnc(src1_f_4, src2_f_1), "f4 " #fnc "(f4, f1)")
-
-#define BENCH_F_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1), "f1 " #fnc "(f1)") \
- RUN_BENCH(res_f_1 = fnc(src1_f_2), "f1 " #fnc "(f2)") \
- RUN_BENCH(res_f_1 = fnc(src1_f_3), "f1 " #fnc "(f3)") \
- RUN_BENCH(res_f_1 = fnc(src1_f_4), "f1 " #fnc "(f4)")
-
-#define BENCH_F_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1, src2_f_1), "f1 " #fnc "(f1, f1)") \
- RUN_BENCH(res_f_1 = fnc(src1_f_2, src2_f_2), "f1 " #fnc "(f2, f2)") \
- RUN_BENCH(res_f_1 = fnc(src1_f_3, src2_f_3), "f1 " #fnc "(f3, f3)") \
- RUN_BENCH(res_f_1 = fnc(src1_f_4, src2_f_4), "f1 " #fnc "(f4, f4)")
-
-#define BENCH_FN_FUNC_FN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1, src1_i_1), "f1 " #fnc "(f1, i1)") \
- RUN_BENCH(res_f_2 = fnc(src1_f_2, src1_i_2), "f2 " #fnc "(f2, i2)") \
- RUN_BENCH(res_f_3 = fnc(src1_f_3, src1_i_3), "f3 " #fnc "(f3, i3)") \
- RUN_BENCH(res_f_4 = fnc(src1_f_4, src1_i_4), "f4 " #fnc "(f4, i4)")
-
-#define BENCH_FN_FUNC_FN_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1, src1_i_1), "f1 " #fnc "(f1, i1)") \
- RUN_BENCH(res_f_2 = fnc(src1_f_2, src1_i_1), "f2 " #fnc "(f2, i1)") \
- RUN_BENCH(res_f_3 = fnc(src1_f_3, src1_i_1), "f3 " #fnc "(f3, i1)") \
- RUN_BENCH(res_f_4 = fnc(src1_f_4, src1_i_1), "f4 " #fnc "(f4, i1)")
-
-#define BENCH_FN_FUNC_FN_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1, src2_f_1, src3_f_1), "f1 " #fnc "(f1, f1, f1)") \
- RUN_BENCH(res_f_2 = fnc(src1_f_2, src2_f_2, src3_f_2), "f2 " #fnc "(f2, f2, f2)") \
- RUN_BENCH(res_f_3 = fnc(src1_f_3, src2_f_3, src3_f_3), "f3 " #fnc "(f3, f3, f3)") \
- RUN_BENCH(res_f_4 = fnc(src1_f_4, src2_f_4, src3_f_4), "f4 " #fnc "(f4, f4, f4)")
-
-#define BENCH_FN_FUNC_FN_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1, src2_f_1, src3_f_1), "f1 " #fnc "(f1, f1, f1)") \
- RUN_BENCH(res_f_2 = fnc(src1_f_2, src2_f_2, src3_f_1), "f2 " #fnc "(f2, f2, f1)") \
- RUN_BENCH(res_f_3 = fnc(src1_f_3, src2_f_3, src3_f_1), "f3 " #fnc "(f3, f3, f1)") \
- RUN_BENCH(res_f_4 = fnc(src1_f_4, src2_f_4, src3_f_1), "f4 " #fnc "(f4, f4, f1)")
-
-#define BENCH_FN_FUNC_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1, (int*) &src1_i_1), "f1 " #fnc "(f1, i1*)") \
- RUN_BENCH(res_f_2 = fnc(src1_f_2, (int2*) &src1_i_2), "f2 " #fnc "(f2, i2*)") \
- RUN_BENCH(res_f_3 = fnc(src1_f_3, (int3*) &src1_i_3), "f3 " #fnc "(f3, i3*)") \
- RUN_BENCH(res_f_4 = fnc(src1_f_4, (int4*) &src1_i_4), "f4 " #fnc "(f4, i4*)")
-
-#define BENCH_FN_FUNC_FN_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_f_1 = fnc(src1_f_1, src2_f_1, (int*) &src1_i_1), "f1 " #fnc "(f1, f1, i1*)") \
- RUN_BENCH(res_f_2 = fnc(src1_f_2, src2_f_2, (int2*) &src1_i_2), "f2 " #fnc "(f2, f2, i2*)") \
- RUN_BENCH(res_f_3 = fnc(src1_f_3, src2_f_3, (int3*) &src1_i_3), "f3 " #fnc "(f3, f3, i3*)") \
- RUN_BENCH(res_f_4 = fnc(src1_f_4, src2_f_4, (int4*) &src1_i_4), "f4 " #fnc "(f4, f4, i4*)")
-
-#define BENCH_IN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- RUN_BENCH(res_i_1 = fnc(src1_f_1), "i1 " #fnc "(f1)") \
- RUN_BENCH(res_i_2 = fnc(src1_f_2), "i2 " #fnc "(f2)") \
- RUN_BENCH(res_i_3 = fnc(src1_f_3), "i3 " #fnc "(f3)") \
- RUN_BENCH(res_i_4 = fnc(src1_f_4), "i4 " #fnc "(f4)")
-
-
-// Testing functions
-
-static void bench_basic_operators() {
- int i = 0;
- BENCH_BASIC_OP(+);
- BENCH_BASIC_OP(-);
- BENCH_BASIC_OP(*);
- BENCH_BASIC_OP(/);
- BENCH_BASIC_INT_OP(%);
- BENCH_BASIC_INT_OP(<<);
- BENCH_BASIC_INT_OP(>>);
-}
-
-static void bench_convert() {
- BENCH_CVT_MATRIX(c, char);
- BENCH_CVT_MATRIX(uc, uchar);
- BENCH_CVT_MATRIX(s, short);
- BENCH_CVT_MATRIX(us, ushort);
- BENCH_CVT_MATRIX(i, int);
- BENCH_CVT_MATRIX(ui, uint);
- BENCH_CVT_MATRIX(f, float);
-}
-
-static void bench_int_math() {
- BENCH_UIN_FUNC_IN(abs);
- BENCH_IN_FUNC_IN(clz);
- BENCH_IN_FUNC_IN_IN(min);
- BENCH_IN_FUNC_IN_IN(max);
- BENCH_I_FUNC_I_I_I(rsClamp);
-}
-
-static void bench_fp_math() {
- BENCH_FN_FUNC_FN(acos);
- BENCH_FN_FUNC_FN(acosh);
- BENCH_FN_FUNC_FN(acospi);
- BENCH_FN_FUNC_FN(asin);
- BENCH_FN_FUNC_FN(asinh);
- BENCH_FN_FUNC_FN(asinpi);
- BENCH_FN_FUNC_FN(atan);
- BENCH_FN_FUNC_FN_FN(atan2);
- BENCH_FN_FUNC_FN(atanh);
- BENCH_FN_FUNC_FN(atanpi);
- BENCH_FN_FUNC_FN_FN(atan2pi);
- BENCH_FN_FUNC_FN(cbrt);
- BENCH_FN_FUNC_FN(ceil);
- BENCH_FN_FUNC_FN_FN_FN(clamp);
- BENCH_FN_FUNC_FN_FN_F(clamp);
- BENCH_FN_FUNC_FN_FN(copysign);
- BENCH_FN_FUNC_FN(cos);
- BENCH_FN_FUNC_FN(cosh);
- BENCH_FN_FUNC_FN(cospi);
- BENCH_F34_FUNC_F34_F34(cross);
- BENCH_FN_FUNC_FN(degrees);
- BENCH_F_FUNC_FN_FN(distance);
- BENCH_F_FUNC_FN_FN(dot);
- BENCH_FN_FUNC_FN(erfc);
- BENCH_FN_FUNC_FN(erf);
- BENCH_FN_FUNC_FN(exp);
- BENCH_FN_FUNC_FN(exp2);
- BENCH_FN_FUNC_FN(exp10);
- BENCH_FN_FUNC_FN(expm1);
- BENCH_FN_FUNC_FN(fabs);
- BENCH_FN_FUNC_FN_FN(fdim);
- BENCH_FN_FUNC_FN(floor);
- BENCH_FN_FUNC_FN_FN_FN(fma);
- BENCH_FN_FUNC_FN_FN(fmax);
- BENCH_FN_FUNC_FN_F(fmax);
- BENCH_FN_FUNC_FN_FN(fmin);
- BENCH_FN_FUNC_FN_F(fmin);
- BENCH_FN_FUNC_FN_FN(fmod);
- BENCH_FN_FUNC_FN_PFN(fract);
- BENCH_FN_FUNC_FN_PIN(frexp);
- BENCH_FN_FUNC_FN_FN(hypot);
- BENCH_IN_FUNC_FN(ilogb);
- BENCH_FN_FUNC_FN_IN(ldexp);
- BENCH_FN_FUNC_FN_I(ldexp);
- BENCH_F_FUNC_FN(length);
- BENCH_FN_FUNC_FN(lgamma);
- BENCH_FN_FUNC_FN_PIN(lgamma);
- BENCH_FN_FUNC_FN(log);
- BENCH_FN_FUNC_FN(log2);
- BENCH_FN_FUNC_FN(log10);
- BENCH_FN_FUNC_FN(log1p);
- BENCH_FN_FUNC_FN(logb);
- BENCH_FN_FUNC_FN_FN_FN(mad);
- BENCH_FN_FUNC_FN_FN(max);
- BENCH_FN_FUNC_FN_F(max);
- BENCH_FN_FUNC_FN_FN(min);
- BENCH_FN_FUNC_FN_F(min);
- BENCH_FN_FUNC_FN_FN_FN(mix);
- BENCH_FN_FUNC_FN_FN_F(mix);
- BENCH_FN_FUNC_FN_PFN(modf);
- BENCH_FN_FUNC_FN_FN(nextafter);
- BENCH_FN_FUNC_FN(normalize);
- BENCH_FN_FUNC_FN_FN(pow);
- BENCH_FN_FUNC_FN_IN(pown);
- BENCH_FN_FUNC_FN_FN(powr);
- BENCH_FN_FUNC_FN(radians);
- BENCH_FN_FUNC_FN_FN(remainder);
- BENCH_FN_FUNC_FN_FN_PIN(remquo);
- BENCH_FN_FUNC_FN(rint);
- BENCH_FN_FUNC_FN_IN(rootn);
- BENCH_FN_FUNC_FN(round);
- BENCH_FN_FUNC_FN(rsqrt);
- BENCH_FN_FUNC_FN(sign);
- BENCH_FN_FUNC_FN(sin);
- BENCH_FN_FUNC_FN_PFN(sincos);
- BENCH_FN_FUNC_FN(sinh);
- BENCH_FN_FUNC_FN(sinpi);
- BENCH_FN_FUNC_FN(sqrt);
- BENCH_FN_FUNC_FN_FN(step);
- BENCH_FN_FUNC_FN_F(step);
- BENCH_FN_FUNC_FN(tan);
- BENCH_FN_FUNC_FN(tanh);
- BENCH_FN_FUNC_FN(tanpi);
- BENCH_FN_FUNC_FN(tgamma);
- BENCH_FN_FUNC_FN(trunc);
-}
-
-static void bench_approx_math() {
- BENCH_FN_FUNC_FN(half_recip);
- BENCH_FN_FUNC_FN(half_sqrt);
- BENCH_FN_FUNC_FN(half_rsqrt);
- BENCH_FN_FUNC_FN(fast_length);
- BENCH_FN_FUNC_FN_FN(fast_distance);
- BENCH_FN_FUNC_FN(fast_normalize);
-}
-
-void bench() {
- rsDebug("RS Compute Benchmark", 0);
- rsDebug("Current configuration:", 0);
- rsDebug("Priming runs", priming_runs);
- rsDebug("Timing runs", timing_runs);
- rsDebug("Beginning test", 0);
- inv_timing_runs = 1000000.f / (float)timing_runs;
- bench_basic_operators();
- bench_convert();
- bench_int_math();
- bench_fp_math();
- bench_approx_math();
-}
-
diff --git a/tests/RenderScriptTests/ComputePerf/Android.mk b/tests/RenderScriptTests/ComputePerf/Android.mk
deleted file mode 100644
index 6ed5884..0000000
--- a/tests/RenderScriptTests/ComputePerf/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
- $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := RsComputePerf
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/ComputePerf/AndroidManifest.xml b/tests/RenderScriptTests/ComputePerf/AndroidManifest.xml
deleted file mode 100644
index a9193b5..0000000
--- a/tests/RenderScriptTests/ComputePerf/AndroidManifest.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.rs.computeperf">
-
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-sdk android:minSdkVersion="14" />
- <application android:label="Compute Perf">
- <activity android:name="ComputePerf">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/ComputePerf/res/layout/main.xml b/tests/RenderScriptTests/ComputePerf/res/layout/main.xml
deleted file mode 100644
index 61cd24d..0000000
--- a/tests/RenderScriptTests/ComputePerf/res/layout/main.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ImageView
- android:id="@+id/displayin"
- android:layout_width="320dip"
- android:layout_height="266dip" />
-
- <ImageView
- android:id="@+id/displayout"
- android:layout_width="320dip"
- android:layout_height="266dip" />
-
-</LinearLayout>
diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/ComputePerf.java b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/ComputePerf.java
deleted file mode 100644
index 5446f66..0000000
--- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/ComputePerf.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.example.android.rs.computeperf;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.graphics.BitmapFactory;
-import android.graphics.Bitmap;
-import android.renderscript.RenderScript;
-import android.renderscript.Allocation;
-import android.util.Log;
-import android.widget.ImageView;
-
-public class ComputePerf extends Activity {
- private LaunchTest mLT;
- private Mandelbrot mMandel;
- private RenderScript mRS;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- final int numTries = 100;
-
- long timesXLW = 0;
- long timesXYW = 0;
-
- mRS = RenderScript.create(this);
- mLT = new LaunchTest(mRS, getResources());
- mLT.XLW();
- mLT.XYW();
- for (int i = 0; i < numTries; i++) {
- timesXLW += mLT.XLW();
- timesXYW += mLT.XYW();
- }
-
- timesXLW /= numTries;
- timesXYW /= numTries;
-
- // XLW and XYW running times should match pretty closely
- Log.v("ComputePerf", "xlw launch test " + timesXLW + "ms");
- Log.v("ComputePerf", "xyw launch test " + timesXYW + "ms");
-
- mMandel = new Mandelbrot(mRS, getResources());
- mMandel.run();
- }
-}
diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/LaunchTest.java b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/LaunchTest.java
deleted file mode 100644
index e2312ba..0000000
--- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/LaunchTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.example.android.rs.computeperf;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class LaunchTest {
- private RenderScript mRS;
- private Allocation mAllocationX;
- private Allocation mAllocationXY;
- private ScriptC_launchtestxlw mScript_xlw;
- private ScriptC_launchtestxyw mScript_xyw;
-
- LaunchTest(RenderScript rs, Resources res) {
- mRS = rs;
- mScript_xlw = new ScriptC_launchtestxlw(mRS, res, R.raw.launchtestxlw);
- mScript_xyw = new ScriptC_launchtestxyw(mRS, res, R.raw.launchtestxyw);
- final int dim = mScript_xlw.get_dim();
-
- mAllocationX = Allocation.createSized(rs, Element.U8(rs), dim);
- Type.Builder tb = new Type.Builder(rs, Element.U8(rs));
- tb.setX(dim);
- tb.setY(dim);
- mAllocationXY = Allocation.createTyped(rs, tb.create());
- mScript_xlw.bind_buf(mAllocationXY);
- }
-
- public long XLW() {
- long t = java.lang.System.currentTimeMillis();
- mScript_xlw.forEach_root(mAllocationX);
- mRS.finish();
- t = java.lang.System.currentTimeMillis() - t;
- return t;
- }
-
- public long XYW() {
- long t = java.lang.System.currentTimeMillis();
- mScript_xyw.forEach_root(mAllocationXY);
- mRS.finish();
- t = java.lang.System.currentTimeMillis() - t;
- return t;
- }
-}
diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/Mandelbrot.java b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/Mandelbrot.java
deleted file mode 100644
index ea1cd62..0000000
--- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/Mandelbrot.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2011 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.example.android.rs.computeperf;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class Mandelbrot implements Runnable {
- private RenderScript mRS;
- private Allocation mAllocationXY;
- private ScriptC_mandelbrot mScript;
-
- Mandelbrot(RenderScript rs, Resources res) {
- mRS = rs;
- mScript = new ScriptC_mandelbrot(mRS, res, R.raw.mandelbrot);
-
- Type.Builder tb = new Type.Builder(rs, Element.U8_4(rs));
- tb.setX(mScript.get_gDimX());
- tb.setY(mScript.get_gDimY());
- mAllocationXY = Allocation.createTyped(rs, tb.create());
- }
-
- public void run() {
- long t = java.lang.System.currentTimeMillis();
- mScript.forEach_root(mAllocationXY);
- mRS.finish();
- t = java.lang.System.currentTimeMillis() - t;
- android.util.Log.v("ComputePerf", "mandelbrot ms " + t);
- }
-
-}
diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxlw.rs b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxlw.rs
deleted file mode 100644
index 7b81dfe..0000000
--- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxlw.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#pragma version(1)
-#pragma rs java_package_name(com.example.android.rs.computeperf)
-
-const int dim = 2048;
-uint8_t *buf;
-
-void root(uchar *v_out, uint32_t x) {
- uint8_t *p = buf;
- p += x * dim;
- for (int i=0; i<dim; i++) {
- p[i] = 1;
- }
-}
-
diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxyw.rs b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxyw.rs
deleted file mode 100644
index 7f7aa95..0000000
--- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxyw.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#pragma version(1)
-#pragma rs java_package_name(com.example.android.rs.computeperf)
-
-void root(uchar *v_out, uint32_t x, uint32_t y) {
- *v_out = 0;
-}
-
diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/mandelbrot.rs b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/mandelbrot.rs
deleted file mode 100644
index 0ffb0e5..0000000
--- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/mandelbrot.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-#pragma rs java_package_name(com.example.android.rs.computeperf)
-
-const int gMaxIteration = 500;
-const int gDimX = 1024;
-const int gDimY = 1024;
-
-void root(uchar4 *v_out, uint32_t x, uint32_t y) {
- float2 p;
- p.x = -2.5f + ((float)x / gDimX) * 3.5f;
- p.y = -1.f + ((float)y / gDimY) * 2.f;
-
- float2 t = 0;
- float2 t2 = t * t;
- int iteration = 0;
- while((t2.x + t2.y < 4.f) && (iteration < gMaxIteration)) {
- float xtemp = t2.x - t2.y + p.x;
- t.y = 2 * t.x * t.y + p.y;
- t.x = xtemp;
- iteration++;
- t2 = t * t;
- }
-
- if(iteration >= gMaxIteration) {
- *v_out = 0;
- } else {
- *v_out = (uchar4){iteration & 0xff, (iteration >> 6) & 0xff, 0x8f, 0xff};
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/Android.mk b/tests/RenderScriptTests/ImageProcessing/Android.mk
deleted file mode 100644
index d7486e8..0000000
--- a/tests/RenderScriptTests/ImageProcessing/Android.mk
+++ /dev/null
@@ -1,30 +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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
- $(call all-renderscript-files-under, src)
-#LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript
-
-LOCAL_PACKAGE_NAME := ImageProcessing
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/ImageProcessing/AndroidManifest.xml b/tests/RenderScriptTests/ImageProcessing/AndroidManifest.xml
deleted file mode 100644
index d51fa39..0000000
--- a/tests/RenderScriptTests/ImageProcessing/AndroidManifest.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.rs.image">
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-sdk android:minSdkVersion="17" />
- <application android:label="Image Processing"
- android:hardwareAccelerated="true">
- <uses-library android:name="android.test.runner" />
- <activity android:name="ImageProcessingActivity">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
- <instrumentation android:name=".ImageProcessingTestRunner"
- android:targetPackage="com.android.rs.image"
- android:label="Test runner for Image Processing Benchmark Test"
- />
-</manifest>
diff --git a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067.jpg b/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067.jpg
deleted file mode 100644
index 05d3ee2..0000000
--- a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067b.jpg b/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067b.jpg
deleted file mode 100644
index aed0781..0000000
--- a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067b.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml b/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml
deleted file mode 100644
index f0a2b92..0000000
--- a/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml
+++ /dev/null
@@ -1,139 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:id="@+id/toplevel">
- <SurfaceView
- android:id="@+id/surface"
- android:layout_width="1dip"
- android:layout_height="1dip" />
- <ScrollView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <ImageView
- android:id="@+id/display"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/benchmark"
- android:onClick="benchmark"/>
- <TextView
- android:id="@+id/benchmarkText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:text="@string/saturation"/>
- </LinearLayout>
- <Spinner
- android:id="@+id/filterselection"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
- <Spinner
- android:id="@+id/spinner1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider1Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/saturation"/>
- <SeekBar
- android:id="@+id/slider1"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider2Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/gamma"/>
- <SeekBar
- android:id="@+id/slider2"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider3Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:textSize="8pt"
- android:text="@string/out_white"/>
- <SeekBar
- android:id="@+id/slider3"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider4Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/in_white"/>
- <SeekBar
- android:id="@+id/slider4"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider5Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/in_white"/>
- <SeekBar
- android:id="@+id/slider5"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/benchmark_all"
- android:onClick="benchmark_all"/>
- </LinearLayout>
- </ScrollView>
-</LinearLayout>
-
diff --git a/tests/RenderScriptTests/ImageProcessing/res/layout/spinner_layout.xml b/tests/RenderScriptTests/ImageProcessing/res/layout/spinner_layout.xml
deleted file mode 100644
index 8196bbf..0000000
--- a/tests/RenderScriptTests/ImageProcessing/res/layout/spinner_layout.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 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.
--->
-
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:padding="10dp"
- android:textSize="16sp"
-/>
diff --git a/tests/RenderScriptTests/ImageProcessing/res/values/strings.xml b/tests/RenderScriptTests/ImageProcessing/res/values/strings.xml
deleted file mode 100644
index a7dd165..0000000
--- a/tests/RenderScriptTests/ImageProcessing/res/values/strings.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2008 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.
-*/
--->
-
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- General -->
- <skip />
- <!--slider label -->
- <string name="blur_description">Blur Radius</string>
- <string name="in_white">In White</string>
- <string name="out_white">Out White</string>
- <string name="in_black">In Black</string>
- <string name="out_black">Out Black</string>
- <string name="gamma">Gamma</string>
- <string name="saturation">Saturation</string>
- <string name="benchmark">Benchmark</string>
- <string name="benchmark_all">Benchmark All</string>
-
-</resources>
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/BWFilter.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/BWFilter.java
deleted file mode 100644
index 64be4aa..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/BWFilter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-
-public class BWFilter extends TestBase {
- private ScriptC_bwfilter mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_bwfilter(mRS);
- }
-
- public void runTest() {
- mScript.invoke_prepareBwFilter(50, 50, 50);
- mScript.forEach_bwFilterKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java
deleted file mode 100644
index 2303fc3..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-import java.lang.Short;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.ScriptGroup;
-import android.renderscript.ScriptIntrinsicBlend;
-import android.renderscript.Type;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.view.View;
-import android.widget.Spinner;
-
-public class Blend extends TestBase {
- private ScriptIntrinsicBlend mBlend;
- private ScriptC_blend mBlendHelper;
- private short image1Alpha = 128;
- private short image2Alpha = 128;
-
- String mIntrinsicNames[];
-
- private Allocation image1;
- private Allocation image2;
- private int currentIntrinsic = 0;
-
- private AdapterView.OnItemSelectedListener mIntrinsicSpinnerListener =
- new AdapterView.OnItemSelectedListener() {
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
- currentIntrinsic = pos;
- if (mRS != null) {
- runTest();
- act.updateDisplay();
- }
- }
-
- public void onNothingSelected(AdapterView parent) {
-
- }
- };
-
- public void createTest(android.content.res.Resources res) {
- mBlend = ScriptIntrinsicBlend.create(mRS, Element.U8_4(mRS));
- mBlendHelper = new ScriptC_blend(mRS);
- mBlendHelper.set_alpha((short)128);
-
- image1 = Allocation.createTyped(mRS, mInPixelsAllocation.getType());
- image2 = Allocation.createTyped(mRS, mInPixelsAllocation2.getType());
-
- mIntrinsicNames = new String[14];
- mIntrinsicNames[0] = "Source";
- mIntrinsicNames[1] = "Destination";
- mIntrinsicNames[2] = "Source Over";
- mIntrinsicNames[3] = "Destination Over";
- mIntrinsicNames[4] = "Source In";
- mIntrinsicNames[5] = "Destination In";
- mIntrinsicNames[6] = "Source Out";
- mIntrinsicNames[7] = "Destination Out";
- mIntrinsicNames[8] = "Source Atop";
- mIntrinsicNames[9] = "Destination Atop";
- mIntrinsicNames[10] = "XOR";
- mIntrinsicNames[11] = "Add";
- mIntrinsicNames[12] = "Subtract";
- mIntrinsicNames[13] = "Multiply";
- }
-
- public boolean onSpinner1Setup(Spinner s) {
- s.setAdapter(new ArrayAdapter<String>(
- act, R.layout.spinner_layout, mIntrinsicNames));
- s.setOnItemSelectedListener(mIntrinsicSpinnerListener);
- return true;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Image 1 Alpha");
- b.setMax(255);
- b.setProgress(image1Alpha);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- image1Alpha = (short)progress;
- }
-
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Image 2 Alpha");
- b.setMax(255);
- b.setProgress(image2Alpha);
- return true;
- }
-
- public void onBar2Changed(int progress) {
- image2Alpha = (short)progress;
- }
-
- public void runTest() {
- image1.copy2DRangeFrom(0, 0, mInPixelsAllocation.getType().getX(), mInPixelsAllocation.getType().getY(), mInPixelsAllocation, 0, 0);
- image2.copy2DRangeFrom(0, 0, mInPixelsAllocation2.getType().getX(), mInPixelsAllocation2.getType().getY(), mInPixelsAllocation2, 0, 0);
-
- mBlendHelper.set_alpha(image1Alpha);
- mBlendHelper.forEach_setImageAlpha(image1);
-
- mBlendHelper.set_alpha(image2Alpha);
- mBlendHelper.forEach_setImageAlpha(image2);
-
- switch (currentIntrinsic) {
- case 0:
- mBlend.forEachSrc(image1, image2);
- break;
- case 1:
- mBlend.forEachDst(image1, image2);
- break;
- case 2:
- mBlend.forEachSrcOver(image1, image2);
- break;
- case 3:
- mBlend.forEachDstOver(image1, image2);
- break;
- case 4:
- mBlend.forEachSrcIn(image1, image2);
- break;
- case 5:
- mBlend.forEachDstIn(image1, image2);
- break;
- case 6:
- mBlend.forEachSrcOut(image1, image2);
- break;
- case 7:
- mBlend.forEachDstOut(image1, image2);
- break;
- case 8:
- mBlend.forEachSrcAtop(image1, image2);
- break;
- case 9:
- mBlend.forEachDstAtop(image1, image2);
- break;
- case 10:
- mBlend.forEachXor(image1, image2);
- break;
- case 11:
- mBlend.forEachAdd(image1, image2);
- break;
- case 12:
- mBlend.forEachSubtract(image1, image2);
- break;
- case 13:
- mBlend.forEachMultiply(image1, image2);
- break;
- }
-
- mOutPixelsAllocation.copy2DRangeFrom(0, 0, image2.getType().getX(), image2.getType().getY(), image2, 0, 0);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blur25.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blur25.java
deleted file mode 100644
index 0c6d41d..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blur25.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.ScriptIntrinsicBlur;
-import android.renderscript.Type;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Blur25 extends TestBase {
- private boolean mUseIntrinsic = false;
- private ScriptIntrinsicBlur mIntrinsic;
-
- private int MAX_RADIUS = 25;
- private ScriptC_threshold mScript;
- private float mRadius = MAX_RADIUS;
- private float mSaturation = 1.0f;
- private Allocation mScratchPixelsAllocation1;
- private Allocation mScratchPixelsAllocation2;
-
-
- public Blur25(boolean useIntrinsic) {
- mUseIntrinsic = useIntrinsic;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Radius");
- b.setProgress(100);
- return true;
- }
-
-
- public void onBar1Changed(int progress) {
- mRadius = ((float)progress) / 100.0f * MAX_RADIUS;
- if (mRadius <= 0.10f) {
- mRadius = 0.10f;
- }
- if (mUseIntrinsic) {
- mIntrinsic.setRadius(mRadius);
- } else {
- mScript.invoke_setRadius((int)mRadius);
- }
- }
-
-
- public void createTest(android.content.res.Resources res) {
- int width = mInPixelsAllocation.getType().getX();
- int height = mInPixelsAllocation.getType().getY();
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicBlur.create(mRS, Element.U8_4(mRS));
- mIntrinsic.setRadius(MAX_RADIUS);
- mIntrinsic.setInput(mInPixelsAllocation);
- } else {
-
- Type.Builder tb = new Type.Builder(mRS, Element.F32_4(mRS));
- tb.setX(width);
- tb.setY(height);
- mScratchPixelsAllocation1 = Allocation.createTyped(mRS, tb.create());
- mScratchPixelsAllocation2 = Allocation.createTyped(mRS, tb.create());
-
- mScript = new ScriptC_threshold(mRS, res, R.raw.threshold);
- mScript.set_width(width);
- mScript.set_height(height);
- mScript.invoke_setRadius(MAX_RADIUS);
-
- mScript.set_InPixel(mInPixelsAllocation);
- mScript.set_ScratchPixel1(mScratchPixelsAllocation1);
- mScript.set_ScratchPixel2(mScratchPixelsAllocation2);
- }
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mOutPixelsAllocation);
- } else {
- mScript.forEach_copyIn(mInPixelsAllocation, mScratchPixelsAllocation1);
- mScript.forEach_horz(mScratchPixelsAllocation2);
- mScript.forEach_vert(mOutPixelsAllocation);
- }
- }
-
- public void setupBenchmark() {
- if (mUseIntrinsic) {
- mIntrinsic.setRadius(MAX_RADIUS);
- } else {
- mScript.invoke_setRadius(MAX_RADIUS);
- }
- }
-
- public void exitBenchmark() {
- if (mUseIntrinsic) {
- mIntrinsic.setRadius(mRadius);
- } else {
- mScript.invoke_setRadius((int)mRadius);
- }
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blur25G.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blur25G.java
deleted file mode 100644
index ac0dad1..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blur25G.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.graphics.Bitmap;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.ScriptIntrinsicBlur;
-import android.renderscript.Type;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Blur25G extends TestBase {
- private final int MAX_RADIUS = 25;
- private float mRadius = MAX_RADIUS;
-
- private ScriptIntrinsicBlur mIntrinsic;
-
- private ScriptC_greyscale mScript;
- private Allocation mScratchPixelsAllocation1;
- private Allocation mScratchPixelsAllocation2;
-
-
- public Blur25G() {
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Radius");
- b.setProgress(100);
- return true;
- }
-
-
- public void onBar1Changed(int progress) {
- mRadius = ((float)progress) / 100.0f * MAX_RADIUS;
- if (mRadius <= 0.10f) {
- mRadius = 0.10f;
- }
- mIntrinsic.setRadius(mRadius);
- }
-
-
- public void createTest(android.content.res.Resources res) {
- int width = mInPixelsAllocation.getType().getX();
- int height = mInPixelsAllocation.getType().getY();
-
- Type.Builder tb = new Type.Builder(mRS, Element.U8(mRS));
- tb.setX(width);
- tb.setY(height);
- mScratchPixelsAllocation1 = Allocation.createTyped(mRS, tb.create());
- mScratchPixelsAllocation2 = Allocation.createTyped(mRS, tb.create());
-
- mScript = new ScriptC_greyscale(mRS);
- mScript.forEach_toU8(mInPixelsAllocation, mScratchPixelsAllocation1);
-
- mIntrinsic = ScriptIntrinsicBlur.create(mRS, Element.U8(mRS));
- mIntrinsic.setRadius(MAX_RADIUS);
- mIntrinsic.setInput(mScratchPixelsAllocation1);
- }
-
- public void runTest() {
- mIntrinsic.forEach(mScratchPixelsAllocation2);
- }
-
- public void setupBenchmark() {
- mIntrinsic.setRadius(MAX_RADIUS);
- }
-
- public void exitBenchmark() {
- mIntrinsic.setRadius(mRadius);
- }
-
- public void updateBitmap(Bitmap b) {
- mScript.forEach_toU8_4(mScratchPixelsAllocation2, mOutPixelsAllocation);
- mOutPixelsAllocation.copyTo(b);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java
deleted file mode 100644
index f313c46..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.ScriptGroup;
-import android.renderscript.ScriptIntrinsic3DLUT;
-import android.renderscript.ScriptIntrinsicColorMatrix;
-import android.renderscript.Type;
-import android.util.Log;
-
-public class ColorCube extends TestBase {
- private Allocation mCube;
- private ScriptC_colorcube mScript;
- private ScriptIntrinsic3DLUT mIntrinsic;
- private boolean mUseIntrinsic;
-
- public ColorCube(boolean useIntrinsic) {
- mUseIntrinsic = useIntrinsic;
- }
-
- private void initCube() {
- final int sx = 32;
- final int sy = 32;
- final int sz = 16;
-
- Type.Builder tb = new Type.Builder(mRS, Element.U8_4(mRS));
- tb.setX(sx);
- tb.setY(sy);
- tb.setZ(sz);
- Type t = tb.create();
- mCube = Allocation.createTyped(mRS, t);
-
- int dat[] = new int[sx * sy * sz];
- for (int z = 0; z < sz; z++) {
- for (int y = 0; y < sy; y++) {
- for (int x = 0; x < sx; x++ ) {
- int v = 0xff000000;
- v |= (0xff * x / (sx - 1));
- v |= (0xff * y / (sy - 1)) << 8;
- v |= (0xff * z / (sz - 1)) << 16;
- dat[z*sy*sx + y*sx + x] = v;
- }
- }
- }
-
- mCube.copyFromUnchecked(dat);
- }
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_colorcube(mRS, res, R.raw.colorcube);
- mIntrinsic = ScriptIntrinsic3DLUT.create(mRS, Element.U8_4(mRS));
-
- initCube();
- mScript.invoke_setCube(mCube);
- mIntrinsic.setLUT(mCube);
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation);
- } else {
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorMatrix.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorMatrix.java
deleted file mode 100644
index 2ac40a1..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorMatrix.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.ScriptGroup;
-import android.renderscript.ScriptIntrinsicColorMatrix;
-import android.renderscript.Type;
-import android.util.Log;
-
-public class ColorMatrix extends TestBase {
- private ScriptC_colormatrix mScript;
- private ScriptIntrinsicColorMatrix mIntrinsic;
- private boolean mUseIntrinsic;
- private boolean mUseGrey;
-
- public ColorMatrix(boolean useIntrinsic, boolean useGrey) {
- mUseIntrinsic = useIntrinsic;
- mUseGrey = useGrey;
- }
-
- public void createTest(android.content.res.Resources res) {
- Matrix4f m = new Matrix4f();
- m.set(1, 0, 0.2f);
- m.set(1, 1, 0.9f);
- m.set(1, 2, 0.2f);
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
- if (mUseGrey) {
- mIntrinsic.setGreyscale();
- } else {
- mIntrinsic.setColorMatrix(m);
- }
- } else {
- mScript = new ScriptC_colormatrix(mRS, res, R.raw.colormatrix);
- mScript.invoke_setMatrix(m);
- }
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation);
- } else {
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Contrast.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Contrast.java
deleted file mode 100644
index f3cf1b7..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Contrast.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-
-public class Contrast extends TestBase {
- private ScriptC_contrast mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_contrast(mRS);
- }
-
- public void runTest() {
- mScript.invoke_setBright(50.f);
- mScript.forEach_contrast(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Convolve3x3.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Convolve3x3.java
deleted file mode 100644
index 18e9b43..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Convolve3x3.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.ScriptGroup;
-import android.renderscript.ScriptIntrinsicConvolve3x3;
-import android.renderscript.Type;
-import android.util.Log;
-
-public class Convolve3x3 extends TestBase {
- private ScriptC_convolve3x3 mScript;
- private ScriptIntrinsicConvolve3x3 mIntrinsic;
-
- private int mWidth;
- private int mHeight;
- private boolean mUseIntrinsic;
-
- public Convolve3x3(boolean useIntrinsic) {
- mUseIntrinsic = useIntrinsic;
- }
-
- public void createTest(android.content.res.Resources res) {
- mWidth = mInPixelsAllocation.getType().getX();
- mHeight = mInPixelsAllocation.getType().getY();
-
- float f[] = new float[9];
- f[0] = 0.f; f[1] = -1.f; f[2] = 0.f;
- f[3] = -1.f; f[4] = 5.f; f[5] = -1.f;
- f[6] = 0.f; f[7] = -1.f; f[8] = 0.f;
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicConvolve3x3.create(mRS, Element.U8_4(mRS));
- mIntrinsic.setCoefficients(f);
- mIntrinsic.setInput(mInPixelsAllocation);
- } else {
- mScript = new ScriptC_convolve3x3(mRS, res, R.raw.convolve3x3);
- mScript.set_gCoeffs(f);
- mScript.set_gIn(mInPixelsAllocation);
- mScript.set_gWidth(mWidth);
- mScript.set_gHeight(mHeight);
- }
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mOutPixelsAllocation);
- } else {
- mScript.forEach_root(mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Convolve5x5.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Convolve5x5.java
deleted file mode 100644
index 03b3bb8..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Convolve5x5.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.ScriptGroup;
-import android.renderscript.ScriptIntrinsicConvolve5x5;
-import android.renderscript.Type;
-import android.util.Log;
-
-public class Convolve5x5 extends TestBase {
- private ScriptC_convolve5x5 mScript;
- private ScriptIntrinsicConvolve5x5 mIntrinsic;
-
- private int mWidth;
- private int mHeight;
- private boolean mUseIntrinsic;
-
- public Convolve5x5(boolean useIntrinsic) {
- mUseIntrinsic = useIntrinsic;
- }
-
- public void createTest(android.content.res.Resources res) {
- mWidth = mInPixelsAllocation.getType().getX();
- mHeight = mInPixelsAllocation.getType().getY();
-
- float f[] = new float[25];
- //f[0] = 0.012f; f[1] = 0.025f; f[2] = 0.031f; f[3] = 0.025f; f[4] = 0.012f;
- //f[5] = 0.025f; f[6] = 0.057f; f[7] = 0.075f; f[8] = 0.057f; f[9] = 0.025f;
- //f[10]= 0.031f; f[11]= 0.075f; f[12]= 0.095f; f[13]= 0.075f; f[14]= 0.031f;
- //f[15]= 0.025f; f[16]= 0.057f; f[17]= 0.075f; f[18]= 0.057f; f[19]= 0.025f;
- //f[20]= 0.012f; f[21]= 0.025f; f[22]= 0.031f; f[23]= 0.025f; f[24]= 0.012f;
-
- //f[0] = 1.f; f[1] = 2.f; f[2] = 0.f; f[3] = -2.f; f[4] = -1.f;
- //f[5] = 4.f; f[6] = 8.f; f[7] = 0.f; f[8] = -8.f; f[9] = -4.f;
- //f[10]= 6.f; f[11]=12.f; f[12]= 0.f; f[13]=-12.f; f[14]= -6.f;
- //f[15]= 4.f; f[16]= 8.f; f[17]= 0.f; f[18]= -8.f; f[19]= -4.f;
- //f[20]= 1.f; f[21]= 2.f; f[22]= 0.f; f[23]= -2.f; f[24]= -1.f;
-
- f[0] = -1.f; f[1] = -3.f; f[2] = -4.f; f[3] = -3.f; f[4] = -1.f;
- f[5] = -3.f; f[6] = 0.f; f[7] = 6.f; f[8] = 0.f; f[9] = -3.f;
- f[10]= -4.f; f[11]= 6.f; f[12]= 20.f; f[13]= 6.f; f[14]= -4.f;
- f[15]= -3.f; f[16]= 0.f; f[17]= 6.f; f[18]= 0.f; f[19]= -3.f;
- f[20]= -1.f; f[21]= -3.f; f[22]= -4.f; f[23]= -3.f; f[24]= -1.f;
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicConvolve5x5.create(mRS, Element.U8_4(mRS));
- mIntrinsic.setCoefficients(f);
- mIntrinsic.setInput(mInPixelsAllocation);
- } else {
- mScript = new ScriptC_convolve5x5(mRS, res, R.raw.convolve5x5);
- mScript.set_gCoeffs(f);
- mScript.set_gIn(mInPixelsAllocation);
- mScript.set_gWidth(mWidth);
- mScript.set_gHeight(mHeight);
- }
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mOutPixelsAllocation);
- } else {
- mScript.forEach_root(mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Copy.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Copy.java
deleted file mode 100644
index efca0b5..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Copy.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.Type;
-import android.util.Log;
-
-public class Copy extends TestBase {
- private ScriptC_copy mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_copy(mRS, res, R.raw.copy);
- }
-
- public void runTest() {
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/CrossProcess.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/CrossProcess.java
deleted file mode 100644
index b9e3524..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/CrossProcess.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.ScriptIntrinsicLUT;
-import android.util.Log;
-
-public class CrossProcess extends TestBase {
- private ScriptIntrinsicLUT mIntrinsic;
-
- public void createTest(android.content.res.Resources res) {
- mIntrinsic = ScriptIntrinsicLUT.create(mRS, Element.U8_4(mRS));
- for (int ct=0; ct < 256; ct++) {
- float f = ((float)ct) / 255.f;
-
- float r = f;
- if (r < 0.5f) {
- r = 4.0f * r * r * r;
- } else {
- r = 1.0f - r;
- r = 1.0f - (4.0f * r * r * r);
- }
- mIntrinsic.setRed(ct, (int)(r * 255.f + 0.5f));
-
- float g = f;
- if (g < 0.5f) {
- g = 2.0f * g * g;
- } else {
- g = 1.0f - g;
- g = 1.0f - (2.0f * g * g);
- }
- mIntrinsic.setGreen(ct, (int)(g * 255.f + 0.5f));
-
- float b = f * 0.5f + 0.25f;
- mIntrinsic.setBlue(ct, (int)(b * 255.f + 0.5f));
- }
-
- }
-
- public void runTest() {
- mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Exposure.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Exposure.java
deleted file mode 100644
index bec53ab..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Exposure.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-
-public class Exposure extends TestBase {
- private ScriptC_exposure mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_exposure(mRS);
- }
-
- public void runTest() {
- mScript.invoke_setBright(50.f);
- mScript.forEach_exposure(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Fisheye.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Fisheye.java
deleted file mode 100644
index 81868b10..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Fisheye.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Sampler;
-import android.renderscript.Type;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Fisheye extends TestBase {
- private ScriptC_fisheye_full mScript_full = null;
- private ScriptC_fisheye_relaxed mScript_relaxed = null;
- private ScriptC_fisheye_approx_full mScript_approx_full = null;
- private ScriptC_fisheye_approx_relaxed mScript_approx_relaxed = null;
- private final boolean approx;
- private final boolean relaxed;
- private float center_x = 0.5f;
- private float center_y = 0.5f;
- private float scale = 0.5f;
-
- public Fisheye(boolean approx, boolean relaxed) {
- this.approx = approx;
- this.relaxed = relaxed;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Scale");
- b.setMax(100);
- b.setProgress(25);
- return true;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Shift center X");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- t.setText("Shift center Y");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- scale = progress / 50.0f;
- do_init();
- }
- public void onBar2Changed(int progress) {
- center_x = progress / 100.0f;
- do_init();
- }
- public void onBar3Changed(int progress) {
- center_y = progress / 100.0f;
- do_init();
- }
-
- private void do_init() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale);
- else
- mScript_approx_full.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale);
- } else if (relaxed)
- mScript_relaxed.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale);
- else
- mScript_full.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale);
- }
-
- public void createTest(android.content.res.Resources res) {
- if (approx) {
- if (relaxed) {
- mScript_approx_relaxed = new ScriptC_fisheye_approx_relaxed(mRS,
- res, R.raw.fisheye_approx_relaxed);
- mScript_approx_relaxed.set_in_alloc(mInPixelsAllocation);
- mScript_approx_relaxed.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- } else {
- mScript_approx_full = new ScriptC_fisheye_approx_full(mRS, res,
- R.raw.fisheye_approx_full);
- mScript_approx_full.set_in_alloc(mInPixelsAllocation);
- mScript_approx_full.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- }
- } else if (relaxed) {
- mScript_relaxed = new ScriptC_fisheye_relaxed(mRS, res,
- R.raw.fisheye_relaxed);
- mScript_relaxed.set_in_alloc(mInPixelsAllocation);
- mScript_relaxed.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- } else {
- mScript_full = new ScriptC_fisheye_full(mRS, res,
- R.raw.fisheye_full);
- mScript_full.set_in_alloc(mInPixelsAllocation);
- mScript_full.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- }
- do_init();
- }
-
- public void runTest() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.forEach_root(mOutPixelsAllocation);
- else
- mScript_approx_full.forEach_root(mOutPixelsAllocation);
- } else if (relaxed)
- mScript_relaxed.forEach_root(mOutPixelsAllocation);
- else
- mScript_full.forEach_root(mOutPixelsAllocation);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Grain.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Grain.java
deleted file mode 100644
index 8618cc8..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Grain.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.Type;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Grain extends TestBase {
- private ScriptC_grain mScript;
- private Allocation mNoise;
- private Allocation mNoise2;
-
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Strength");
- b.setProgress(50);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- float s = progress / 100.0f;
- mScript.set_gNoiseStrength(s);
- }
-
- private int findHighBit(int v) {
- int bit = 0;
- while (v > 1) {
- bit++;
- v >>= 1;
- }
- return bit;
- }
-
-
- public void createTest(android.content.res.Resources res) {
- int width = mInPixelsAllocation.getType().getX();
- int height = mInPixelsAllocation.getType().getY();
-
- int noiseW = findHighBit(width);
- int noiseH = findHighBit(height);
- if (noiseW > 9) {
- noiseW = 9;
- }
- if (noiseH > 9) {
- noiseH = 9;
- }
- noiseW = 1 << noiseW;
- noiseH = 1 << noiseH;
-
- Type.Builder tb = new Type.Builder(mRS, Element.U8(mRS));
- tb.setX(noiseW);
- tb.setY(noiseH);
- mNoise = Allocation.createTyped(mRS, tb.create());
- mNoise2 = Allocation.createTyped(mRS, tb.create());
-
- mScript = new ScriptC_grain(mRS, res, R.raw.grain);
- mScript.set_gWMask(noiseW - 1);
- mScript.set_gHMask(noiseH - 1);
- mScript.set_gNoiseStrength(0.5f);
- mScript.set_gBlendSource(mNoise);
- mScript.set_gNoise(mNoise2);
- }
-
- public void runTest() {
- mScript.forEach_genRand(mNoise);
- mScript.forEach_blend9(mNoise2);
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Greyscale.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Greyscale.java
deleted file mode 100644
index 3db210a..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Greyscale.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.Type;
-import android.util.Log;
-
-public class Greyscale extends TestBase {
- private ScriptC_greyscale mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_greyscale(mRS, res, R.raw.greyscale);
- }
-
- public void runTest() {
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/GroupTest.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/GroupTest.java
deleted file mode 100644
index 29c204c..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/GroupTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.ScriptIntrinsicConvolve3x3;
-import android.renderscript.ScriptIntrinsicColorMatrix;
-import android.renderscript.Type;
-import android.renderscript.Matrix4f;
-import android.renderscript.ScriptGroup;
-import android.util.Log;
-
-public class GroupTest extends TestBase {
- private ScriptIntrinsicConvolve3x3 mConvolve;
- private ScriptIntrinsicColorMatrix mMatrix;
-
- private Allocation mScratchPixelsAllocation1;
- private ScriptGroup mGroup;
-
- private int mWidth;
- private int mHeight;
- private boolean mUseNative;
-
-
- public GroupTest(boolean useNative) {
- mUseNative = useNative;
- }
-
- public void createTest(android.content.res.Resources res) {
- mWidth = mInPixelsAllocation.getType().getX();
- mHeight = mInPixelsAllocation.getType().getY();
-
- mConvolve = ScriptIntrinsicConvolve3x3.create(mRS, Element.U8_4(mRS));
- mMatrix = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
-
- float f[] = new float[9];
- f[0] = 0.f; f[1] = -1.f; f[2] = 0.f;
- f[3] = -1.f; f[4] = 5.f; f[5] = -1.f;
- f[6] = 0.f; f[7] = -1.f; f[8] = 0.f;
- mConvolve.setCoefficients(f);
-
- Matrix4f m = new Matrix4f();
- m.set(1, 0, 0.2f);
- m.set(1, 1, 0.9f);
- m.set(1, 2, 0.2f);
- mMatrix.setColorMatrix(m);
-
- Type.Builder tb = new Type.Builder(mRS, Element.U8_4(mRS));
- tb.setX(mWidth);
- tb.setY(mHeight);
- Type connect = tb.create();
-
- if (mUseNative) {
- ScriptGroup.Builder b = new ScriptGroup.Builder(mRS);
- b.addKernel(mConvolve.getKernelID());
- b.addKernel(mMatrix.getKernelID());
- b.addConnection(connect, mConvolve.getKernelID(), mMatrix.getKernelID());
- mGroup = b.create();
- } else {
- mScratchPixelsAllocation1 = Allocation.createTyped(mRS, connect);
- }
- }
-
- public void runTest() {
- mConvolve.setInput(mInPixelsAllocation);
- if (mUseNative) {
- mGroup.setOutput(mMatrix.getKernelID(), mOutPixelsAllocation);
- mGroup.execute();
- } else {
- mConvolve.forEach(mScratchPixelsAllocation1);
- mMatrix.forEach(mScratchPixelsAllocation1, mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
deleted file mode 100644
index 8cf46c2..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
+++ /dev/null
@@ -1,557 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.graphics.BitmapFactory;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.view.SurfaceView;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.SeekBar;
-import android.widget.Spinner;
-import android.widget.TextView;
-import android.view.View;
-import android.util.Log;
-import android.renderscript.ScriptC;
-import android.renderscript.RenderScript;
-import android.renderscript.Type;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Script;
-
-import android.os.Environment;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-public class ImageProcessingActivity extends Activity
- implements SeekBar.OnSeekBarChangeListener {
- private final String TAG = "Img";
- public final String RESULT_FILE = "image_processing_result.csv";
-
- RenderScript mRS;
- Allocation mInPixelsAllocation;
- Allocation mInPixelsAllocation2;
- Allocation mOutPixelsAllocation;
-
- /**
- * Define enum type for test names
- */
- public enum TestName {
- // totally there are 38 test cases
- LEVELS_VEC3_RELAXED ("Levels Vec3 Relaxed"),
- LEVELS_VEC4_RELAXED ("Levels Vec4 Relaxed"),
- LEVELS_VEC3_FULL ("Levels Vec3 Full"),
- LEVELS_VEC4_FULL ("Levels Vec4 Full"),
- BLUR_RADIUS_25 ("Blur radius 25"),
- INTRINSIC_BLUE_RADIUS_25 ("Intrinsic Blur radius 25"),
- GREYSCALE ("Greyscale"),
- GRAIN ("Grain"),
- FISHEYE_FULL ("Fisheye Full"),
- FISHEYE_RELAXED ("Fisheye Relaxed"),
- FISHEYE_APPROXIMATE_FULL ("Fisheye Approximate Full"),
- FISHEYE_APPROXIMATE_RELAXED ("Fisheye Approximate Relaxed"),
- VIGNETTE_FULL ("Vignette Full"),
- VIGNETTE_RELAXED ("Vignette Relaxed"),
- VIGNETTE_APPROXIMATE_FULL ("Vignette Approximate Full"),
- VIGNETTE_APPROXIMATE_RELAXED ("Vignette Approximate Relaxed"),
- GROUP_TEST_EMULATED ("Group Test (emulated)"),
- GROUP_TEST_NATIVE ("Group Test (native)"),
- CONVOLVE_3X3 ("Convolve 3x3"),
- INTRINSICS_CONVOLVE_3X3 ("Intrinsics Convolve 3x3"),
- COLOR_MATRIX ("ColorMatrix"),
- INTRINSICS_COLOR_MATRIX ("Intrinsics ColorMatrix"),
- INTRINSICS_COLOR_MATRIX_GREY ("Intrinsics ColorMatrix Grey"),
- COPY ("Copy"),
- CROSS_PROCESS_USING_LUT ("CrossProcess (using LUT)"),
- CONVOLVE_5X5 ("Convolve 5x5"),
- INTRINSICS_CONVOLVE_5X5 ("Intrinsics Convolve 5x5"),
- MANDELBROT ("Mandelbrot"),
- INTRINSICS_BLEND ("Intrinsics Blend"),
- INTRINSICS_BLUR_25G ("Intrinsics Blur 25 uchar"),
- VIBRANCE ("Vibrance"),
- BW_FILTER ("BW Filter"),
- SHADOWS ("Shadows"),
- CONTRAST ("Contrast"),
- EXPOSURE ("Exposure"),
- WHITE_BALANCE ("White Balance"),
- COLOR_CUBE ("Color Cube"),
- COLOR_CUBE_3D_INTRINSIC ("Color Cube (3D LUT intrinsic)"),
- USAGE_IO ("Usage io)");
-
-
- private final String name;
-
- private TestName(String s) {
- name = s;
- }
-
- // return quoted string as displayed test name
- public String toString() {
- return name;
- }
- }
-
- Bitmap mBitmapIn;
- Bitmap mBitmapIn2;
- Bitmap mBitmapOut;
-
- private Spinner mSpinner;
- private SeekBar mBar1;
- private SeekBar mBar2;
- private SeekBar mBar3;
- private SeekBar mBar4;
- private SeekBar mBar5;
- private TextView mText1;
- private TextView mText2;
- private TextView mText3;
- private TextView mText4;
- private TextView mText5;
-
- private float mSaturation = 1.0f;
-
- private TextView mBenchmarkResult;
- private Spinner mTestSpinner;
-
- private SurfaceView mSurfaceView;
- private ImageView mDisplayView;
-
- private boolean mDoingBenchmark;
-
- private TestBase mTest;
- private int mRunCount;
-
- public void updateDisplay() {
- mHandler.sendMessage(Message.obtain());
- }
-
- private Handler mHandler = new Handler() {
- // Allow the filter to complete without blocking the UI
- // thread. When the message arrives that the op is complete
- // we will either mark completion or start a new filter if
- // more work is ready. Either way, display the result.
- @Override
- public void handleMessage(Message msg) {
- boolean doTest = false;
- synchronized(this) {
- if (mRS == null) {
- return;
- }
- mTest.updateBitmap(mBitmapOut);
- mDisplayView.invalidate();
- if (mRunCount > 0) {
- mRunCount--;
- if (mRunCount > 0) {
- doTest = true;
- }
- }
-
- if (doTest) {
- mTest.runTestSendMessage();
- }
- }
- }
-
- };
-
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- if (fromUser) {
-
- if (seekBar == mBar1) {
- mTest.onBar1Changed(progress);
- } else if (seekBar == mBar2) {
- mTest.onBar2Changed(progress);
- } else if (seekBar == mBar3) {
- mTest.onBar3Changed(progress);
- } else if (seekBar == mBar4) {
- mTest.onBar4Changed(progress);
- } else if (seekBar == mBar5) {
- mTest.onBar5Changed(progress);
- }
-
- boolean doTest = false;
- synchronized(this) {
- if (mRunCount == 0) {
- doTest = true;
- mRunCount = 1;
- } else {
- mRunCount = 2;
- }
- }
- if (doTest) {
- mTest.runTestSendMessage();
- }
- }
- }
-
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
-
- public void onStopTrackingTouch(SeekBar seekBar) {
- }
-
- void setupBars() {
- mSpinner.setVisibility(View.VISIBLE);
- mTest.onSpinner1Setup(mSpinner);
-
- mBar1.setVisibility(View.VISIBLE);
- mText1.setVisibility(View.VISIBLE);
- mTest.onBar1Setup(mBar1, mText1);
-
- mBar2.setVisibility(View.VISIBLE);
- mText2.setVisibility(View.VISIBLE);
- mTest.onBar2Setup(mBar2, mText2);
-
- mBar3.setVisibility(View.VISIBLE);
- mText3.setVisibility(View.VISIBLE);
- mTest.onBar3Setup(mBar3, mText3);
-
- mBar4.setVisibility(View.VISIBLE);
- mText4.setVisibility(View.VISIBLE);
- mTest.onBar4Setup(mBar4, mText4);
-
- mBar5.setVisibility(View.VISIBLE);
- mText5.setVisibility(View.VISIBLE);
- mTest.onBar5Setup(mBar5, mText5);
- }
-
-
- void changeTest(TestName testName) {
- if (mTest != null) {
- mTest.destroy();
- }
- switch(testName) {
- case LEVELS_VEC3_RELAXED:
- mTest = new LevelsV4(false, false);
- break;
- case LEVELS_VEC4_RELAXED:
- mTest = new LevelsV4(false, true);
- break;
- case LEVELS_VEC3_FULL:
- mTest = new LevelsV4(true, false);
- break;
- case LEVELS_VEC4_FULL:
- mTest = new LevelsV4(true, true);
- break;
- case BLUR_RADIUS_25:
- mTest = new Blur25(false);
- break;
- case INTRINSIC_BLUE_RADIUS_25:
- mTest = new Blur25(true);
- break;
- case GREYSCALE:
- mTest = new Greyscale();
- break;
- case GRAIN:
- mTest = new Grain();
- break;
- case FISHEYE_FULL:
- mTest = new Fisheye(false, false);
- break;
- case FISHEYE_RELAXED:
- mTest = new Fisheye(false, true);
- break;
- case FISHEYE_APPROXIMATE_FULL:
- mTest = new Fisheye(true, false);
- break;
- case FISHEYE_APPROXIMATE_RELAXED:
- mTest = new Fisheye(true, true);
- break;
- case VIGNETTE_FULL:
- mTest = new Vignette(false, false);
- break;
- case VIGNETTE_RELAXED:
- mTest = new Vignette(false, true);
- break;
- case VIGNETTE_APPROXIMATE_FULL:
- mTest = new Vignette(true, false);
- break;
- case VIGNETTE_APPROXIMATE_RELAXED:
- mTest = new Vignette(true, true);
- break;
- case GROUP_TEST_EMULATED:
- mTest = new GroupTest(false);
- break;
- case GROUP_TEST_NATIVE:
- mTest = new GroupTest(true);
- break;
- case CONVOLVE_3X3:
- mTest = new Convolve3x3(false);
- break;
- case INTRINSICS_CONVOLVE_3X3:
- mTest = new Convolve3x3(true);
- break;
- case COLOR_MATRIX:
- mTest = new ColorMatrix(false, false);
- break;
- case INTRINSICS_COLOR_MATRIX:
- mTest = new ColorMatrix(true, false);
- break;
- case INTRINSICS_COLOR_MATRIX_GREY:
- mTest = new ColorMatrix(true, true);
- break;
- case COPY:
- mTest = new Copy();
- break;
- case CROSS_PROCESS_USING_LUT:
- mTest = new CrossProcess();
- break;
- case CONVOLVE_5X5:
- mTest = new Convolve5x5(false);
- break;
- case INTRINSICS_CONVOLVE_5X5:
- mTest = new Convolve5x5(true);
- break;
- case MANDELBROT:
- mTest = new Mandelbrot();
- break;
- case INTRINSICS_BLEND:
- mTest = new Blend();
- break;
- case INTRINSICS_BLUR_25G:
- mTest = new Blur25G();
- break;
- case VIBRANCE:
- mTest = new Vibrance();
- break;
- case BW_FILTER:
- mTest = new BWFilter();
- break;
- case SHADOWS:
- mTest = new Shadows();
- break;
- case CONTRAST:
- mTest = new Contrast();
- break;
- case EXPOSURE:
- mTest = new Exposure();
- break;
- case WHITE_BALANCE:
- mTest = new WhiteBalance();
- break;
- case COLOR_CUBE:
- mTest = new ColorCube(false);
- break;
- case COLOR_CUBE_3D_INTRINSIC:
- mTest = new ColorCube(true);
- break;
- case USAGE_IO:
- mTest = new UsageIO();
- break;
- }
-
- mTest.createBaseTest(this, mBitmapIn, mBitmapIn2, mBitmapOut);
- setupBars();
-
- mTest.runTest();
- updateDisplay();
- mBenchmarkResult.setText("Result: not run");
- }
-
- void setupTests() {
- mTestSpinner.setAdapter(new ArrayAdapter<TestName>(
- this, R.layout.spinner_layout, TestName.values()));
- }
-
- private AdapterView.OnItemSelectedListener mTestSpinnerListener =
- new AdapterView.OnItemSelectedListener() {
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
- changeTest(TestName.values()[pos]);
- }
-
- public void onNothingSelected(AdapterView parent) {
-
- }
- };
-
- void init() {
- mBitmapIn = loadBitmap(R.drawable.img1600x1067);
- mBitmapIn2 = loadBitmap(R.drawable.img1600x1067b);
- mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(), mBitmapIn.getHeight(),
- mBitmapIn.getConfig());
-
- mSurfaceView = (SurfaceView) findViewById(R.id.surface);
-
- mDisplayView = (ImageView) findViewById(R.id.display);
- mDisplayView.setImageBitmap(mBitmapOut);
-
- mSpinner = (Spinner) findViewById(R.id.spinner1);
-
- mBar1 = (SeekBar) findViewById(R.id.slider1);
- mBar2 = (SeekBar) findViewById(R.id.slider2);
- mBar3 = (SeekBar) findViewById(R.id.slider3);
- mBar4 = (SeekBar) findViewById(R.id.slider4);
- mBar5 = (SeekBar) findViewById(R.id.slider5);
-
- mBar1.setOnSeekBarChangeListener(this);
- mBar2.setOnSeekBarChangeListener(this);
- mBar3.setOnSeekBarChangeListener(this);
- mBar4.setOnSeekBarChangeListener(this);
- mBar5.setOnSeekBarChangeListener(this);
-
- mText1 = (TextView) findViewById(R.id.slider1Text);
- mText2 = (TextView) findViewById(R.id.slider2Text);
- mText3 = (TextView) findViewById(R.id.slider3Text);
- mText4 = (TextView) findViewById(R.id.slider4Text);
- mText5 = (TextView) findViewById(R.id.slider5Text);
-
- mTestSpinner = (Spinner) findViewById(R.id.filterselection);
- mTestSpinner.setOnItemSelectedListener(mTestSpinnerListener);
-
- mBenchmarkResult = (TextView) findViewById(R.id.benchmarkText);
- mBenchmarkResult.setText("Result: not run");
-
-
- mRS = RenderScript.create(this);
- mInPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapIn);
- mInPixelsAllocation2 = Allocation.createFromBitmap(mRS, mBitmapIn2);
- mOutPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapOut);
-
-
- setupTests();
- changeTest(TestName.LEVELS_VEC3_RELAXED);
- }
-
- void cleanup() {
- synchronized(this) {
- RenderScript rs = mRS;
- mRS = null;
- while(mDoingBenchmark) {
- try {
- Thread.sleep(1, 0);
- } catch(InterruptedException e) {
- }
-
- }
- rs.destroy();
- }
-
- mInPixelsAllocation = null;
- mInPixelsAllocation2 = null;
- mOutPixelsAllocation = null;
- mBitmapIn = null;
- mBitmapIn2 = null;
- mBitmapOut = null;
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- init();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
-
- cleanup();
- }
-
-
- @Override
- protected void onResume() {
- super.onResume();
-
- init();
- }
-
- private Bitmap loadBitmap(int resource) {
- final BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- return BitmapFactory.decodeResource(getResources(), resource, options);
- }
-
- // button hook
- public void benchmark(View v) {
- float t = getBenchmark();
- //long javaTime = javaFilter();
- //mBenchmarkResult.setText("RS: " + t + " ms Java: " + javaTime + " ms");
- mBenchmarkResult.setText("Result: " + t + " ms");
- Log.v(TAG, "getBenchmark: Renderscript frame time core ms " + t);
- }
-
- public void benchmark_all(View v) {
- // write result into a file
- File externalStorage = Environment.getExternalStorageDirectory();
- if (!externalStorage.canWrite()) {
- Log.v(TAG, "sdcard is not writable");
- return;
- }
- File resultFile = new File(externalStorage, RESULT_FILE);
- resultFile.setWritable(true, false);
- try {
- BufferedWriter rsWriter = new BufferedWriter(new FileWriter(resultFile));
- Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
- for (TestName tn: TestName.values()) {
- changeTest(tn);
- float t = getBenchmark();
- String s = new String("" + tn.toString() + ", " + t);
- rsWriter.write(s + "\n");
- Log.v(TAG, "Test " + s + "ms\n");
- }
- rsWriter.close();
- } catch (IOException e) {
- Log.v(TAG, "Unable to write result file " + e.getMessage());
- }
- changeTest(TestName.LEVELS_VEC3_RELAXED);
- }
-
-
-
- // For benchmark test
- public float getBenchmark() {
- if (mRS == null) {
- return 0;
- }
- mDoingBenchmark = true;
-
- mTest.setupBenchmark();
- long result = 0;
-
- //Log.v(TAG, "Warming");
- long t = java.lang.System.currentTimeMillis() + 250;
- do {
- mTest.runTest();
- mTest.finish();
- } while (t > java.lang.System.currentTimeMillis());
-
- //Log.v(TAG, "Benchmarking");
- int ct = 0;
- t = java.lang.System.currentTimeMillis();
- do {
- mTest.runTest();
- mTest.finish();
- ct++;
- } while ((t+1000) > java.lang.System.currentTimeMillis());
- t = java.lang.System.currentTimeMillis() - t;
- float ft = (float)t;
- ft /= ct;
-
- mTest.exitBenchmark();
- mDoingBenchmark = false;
- return ft;
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTest.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTest.java
deleted file mode 100644
index 5263c61..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTest.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.image;
-
-import com.android.rs.image.ImageProcessingTestRunner;
-
-import android.os.Bundle;
-import com.android.rs.image.ImageProcessingActivity.TestName;
-
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-
-/**
- * ImageProcessing benchmark test.
- * To run the test, please use command
- *
- * adb shell am instrument -e iteration <n> -w com.android.rs.image/.ImageProcessingTestRunner
- *
- */
-public class ImageProcessingTest extends ActivityInstrumentationTestCase2<ImageProcessingActivity> {
- private final String TAG = "ImageProcessingTest";
- private final String TEST_NAME = "Testname";
- private final String ITERATIONS = "Iterations";
- private final String BENCHMARK = "Benchmark";
- private static int INSTRUMENTATION_IN_PROGRESS = 2;
- private int mIteration;
- private ImageProcessingActivity mActivity;
-
- public ImageProcessingTest() {
- super(ImageProcessingActivity.class);
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- setActivityInitialTouchMode(false);
- mActivity = getActivity();
- ImageProcessingTestRunner mRunner = (ImageProcessingTestRunner) getInstrumentation();
- mIteration = mRunner.mIteration;
- assertTrue("please enter a valid iteration value", mIteration > 0);
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- class TestAction implements Runnable {
- TestName mTestName;
- float mResult;
- public TestAction(TestName testName) {
- mTestName = testName;
- }
- public void run() {
- mActivity.changeTest(mTestName);
- mResult = mActivity.getBenchmark();
- Log.v(TAG, "Benchmark for test \"" + mTestName.toString() + "\" is: " + mResult);
- synchronized(this) {
- this.notify();
- }
- }
- public float getBenchmark() {
- return mResult;
- }
- }
-
- // Set the benchmark thread to run on ui thread
- // Synchronized the thread such that the test will wait for the benchmark thread to finish
- public void runOnUiThread(Runnable action) {
- synchronized(action) {
- mActivity.runOnUiThread(action);
- try {
- action.wait();
- } catch (InterruptedException e) {
- Log.v(TAG, "waiting for action running on UI thread is interrupted: " +
- e.toString());
- }
- }
- }
-
- public void runTest(TestAction ta, String testName) {
- float sum = 0;
- for (int i = 0; i < mIteration; i++) {
- runOnUiThread(ta);
- float bmValue = ta.getBenchmark();
- Log.v(TAG, "results for iteration " + i + " is " + bmValue);
- sum += bmValue;
- }
- float avgResult = sum/mIteration;
-
- // post result to INSTRUMENTATION_STATUS
- Bundle results = new Bundle();
- results.putString(TEST_NAME, testName);
- results.putInt(ITERATIONS, mIteration);
- results.putFloat(BENCHMARK, avgResult);
- getInstrumentation().sendStatus(INSTRUMENTATION_IN_PROGRESS, results);
- }
-
- // Test case 0: Levels Vec3 Relaxed
- @LargeTest
- public void testLevelsVec3Relaxed() {
- TestAction ta = new TestAction(TestName.LEVELS_VEC3_RELAXED);
- runTest(ta, TestName.LEVELS_VEC3_RELAXED.name());
- }
-
- // Test case 1: Levels Vec4 Relaxed
- @LargeTest
- public void testLevelsVec4Relaxed() {
- TestAction ta = new TestAction(TestName.LEVELS_VEC4_RELAXED);
- runTest(ta, TestName.LEVELS_VEC4_RELAXED.name());
- }
-
- // Test case 2: Levels Vec3 Full
- @LargeTest
- public void testLevelsVec3Full() {
- TestAction ta = new TestAction(TestName.LEVELS_VEC3_FULL);
- runTest(ta, TestName.LEVELS_VEC3_FULL.name());
- }
-
- // Test case 3: Levels Vec4 Full
- @LargeTest
- public void testLevelsVec4Full() {
- TestAction ta = new TestAction(TestName.LEVELS_VEC4_FULL);
- runTest(ta, TestName.LEVELS_VEC4_FULL.name());
- }
-
- // Test case 4: Blur Radius 25
- @LargeTest
- public void testBlurRadius25() {
- TestAction ta = new TestAction(TestName.BLUR_RADIUS_25);
- runTest(ta, TestName.BLUR_RADIUS_25.name());
- }
-
- // Test case 5: Intrinsic Blur Radius 25
- @LargeTest
- public void testIntrinsicBlurRadius25() {
- TestAction ta = new TestAction(TestName.INTRINSIC_BLUE_RADIUS_25);
- runTest(ta, TestName.INTRINSIC_BLUE_RADIUS_25.name());
- }
-
- // Test case 6: Greyscale
- @LargeTest
- public void testGreyscale() {
- TestAction ta = new TestAction(TestName.GREYSCALE);
- runTest(ta, TestName.GREYSCALE.name());
- }
-
- // Test case 7: Grain
- @LargeTest
- public void testGrain() {
- TestAction ta = new TestAction(TestName.GRAIN);
- runTest(ta, TestName.GRAIN.name());
- }
-
- // Test case 8: Fisheye Full
- @LargeTest
- public void testFisheyeFull() {
- TestAction ta = new TestAction(TestName.FISHEYE_FULL);
- runTest(ta, TestName.FISHEYE_FULL.name());
- }
-
- // Test case 9: Fisheye Relaxed
- @LargeTest
- public void testFishEyeRelaxed() {
- TestAction ta = new TestAction(TestName.FISHEYE_RELAXED);
- runTest(ta, TestName.FISHEYE_RELAXED.name());
- }
-
- // Test case 10: Fisheye Approximate Full
- @LargeTest
- public void testFisheyeApproximateFull() {
- TestAction ta = new TestAction(TestName.FISHEYE_APPROXIMATE_FULL);
- runTest(ta, TestName.FISHEYE_APPROXIMATE_FULL.name());
- }
-
- // Test case 11: Fisheye Approximate Relaxed
- @LargeTest
- public void testFisheyeApproximateRelaxed() {
- TestAction ta = new TestAction(TestName.FISHEYE_APPROXIMATE_RELAXED);
- runTest(ta, TestName.FISHEYE_APPROXIMATE_RELAXED.name());
- }
-
- // Test case 12: Vignette Full
- @LargeTest
- public void testVignetteFull() {
- TestAction ta = new TestAction(TestName.VIGNETTE_FULL);
- runTest(ta, TestName.VIGNETTE_FULL.name());
- }
-
- // Test case 13: Vignette Relaxed
- @LargeTest
- public void testVignetteRelaxed() {
- TestAction ta = new TestAction(TestName.VIGNETTE_RELAXED);
- runTest(ta, TestName.VIGNETTE_RELAXED.name());
- }
-
- // Test case 14: Vignette Approximate Full
- @LargeTest
- public void testVignetteApproximateFull() {
- TestAction ta = new TestAction(TestName.VIGNETTE_APPROXIMATE_FULL);
- runTest(ta, TestName.VIGNETTE_APPROXIMATE_FULL.name());
- }
-
- // Test case 15: Vignette Approximate Relaxed
- @LargeTest
- public void testVignetteApproximateRelaxed() {
- TestAction ta = new TestAction(TestName.VIGNETTE_APPROXIMATE_RELAXED);
- runTest(ta, TestName.VIGNETTE_APPROXIMATE_RELAXED.name());
- }
-
- // Test case 16: Group Test (emulated)
- @LargeTest
- public void testGroupTestEmulated() {
- TestAction ta = new TestAction(TestName.GROUP_TEST_EMULATED);
- runTest(ta, TestName.GROUP_TEST_EMULATED.name());
- }
-
- // Test case 17: Group Test (native)
- @LargeTest
- public void testGroupTestNative() {
- TestAction ta = new TestAction(TestName.GROUP_TEST_NATIVE);
- runTest(ta, TestName.GROUP_TEST_NATIVE.name());
- }
-
- // Test case 18: Convolve 3x3
- @LargeTest
- public void testConvolve3x3() {
- TestAction ta = new TestAction(TestName.CONVOLVE_3X3);
- runTest(ta, TestName.CONVOLVE_3X3.name());
- }
-
- // Test case 19: Intrinsics Convolve 3x3
- @LargeTest
- public void testIntrinsicsConvolve3x3() {
- TestAction ta = new TestAction(TestName.INTRINSICS_CONVOLVE_3X3);
- runTest(ta, TestName.INTRINSICS_CONVOLVE_3X3.name());
- }
-
- // Test case 20: ColorMatrix
- @LargeTest
- public void testColorMatrix() {
- TestAction ta = new TestAction(TestName.COLOR_MATRIX);
- runTest(ta, TestName.COLOR_MATRIX.name());
- }
-
- // Test case 21: Intrinsics ColorMatrix
- @LargeTest
- public void testIntrinsicsColorMatrix() {
- TestAction ta = new TestAction(TestName.INTRINSICS_COLOR_MATRIX);
- runTest(ta, TestName.INTRINSICS_COLOR_MATRIX.name());
- }
-
- // Test case 22: Intrinsics ColorMatrix Grey
- @LargeTest
- public void testIntrinsicsColorMatrixGrey() {
- TestAction ta = new TestAction(TestName.INTRINSICS_COLOR_MATRIX_GREY);
- runTest(ta, TestName.INTRINSICS_COLOR_MATRIX_GREY.name());
- }
-
- // Test case 23: Copy
- @LargeTest
- public void testCopy() {
- TestAction ta = new TestAction(TestName.COPY);
- runTest(ta, TestName.COPY.name());
- }
-
- // Test case 24: CrossProcess (using LUT)
- @LargeTest
- public void testCrossProcessUsingLUT() {
- TestAction ta = new TestAction(TestName.CROSS_PROCESS_USING_LUT);
- runTest(ta, TestName.CROSS_PROCESS_USING_LUT.name());
- }
-
- // Test case 25: Convolve 5x5
- @LargeTest
- public void testConvolve5x5() {
- TestAction ta = new TestAction(TestName.CONVOLVE_5X5);
- runTest(ta, TestName.CONVOLVE_5X5.name());
- }
-
- // Test case 26: Intrinsics Convolve 5x5
- @LargeTest
- public void testIntrinsicsConvolve5x5() {
- TestAction ta = new TestAction(TestName.INTRINSICS_CONVOLVE_5X5);
- runTest(ta, TestName.INTRINSICS_CONVOLVE_5X5.name());
- }
-
- // Test case 27: Mandelbrot
- @LargeTest
- public void testMandelbrot() {
- TestAction ta = new TestAction(TestName.MANDELBROT);
- runTest(ta, TestName.MANDELBROT.name());
- }
-
- // Test case 28: Intrinsics Blend
- @LargeTest
- public void testIntrinsicsBlend() {
- TestAction ta = new TestAction(TestName.INTRINSICS_BLEND);
- runTest(ta, TestName.INTRINSICS_BLEND.name());
- }
-
- // Test case 29: Intrinsics Blur 25 uchar
- @LargeTest
- public void testIntrinsicsBlur25G() {
- TestAction ta = new TestAction(TestName.INTRINSICS_BLUR_25G);
- runTest(ta, TestName.INTRINSICS_BLUR_25G.name());
- }
-
- // Test case 30: Vibrance
- @LargeTest
- public void testVibrance() {
- TestAction ta = new TestAction(TestName.VIBRANCE);
- runTest(ta, TestName.VIBRANCE.name());
- }
-
- // Test case 31: BWFilter
- @LargeTest
- public void testBWFilter() {
- TestAction ta = new TestAction(TestName.BW_FILTER);
- runTest(ta, TestName.BW_FILTER.name());
- }
-
- // Test case 32: Shadows
- @LargeTest
- public void testShadows() {
- TestAction ta = new TestAction(TestName.SHADOWS);
- runTest(ta, TestName.SHADOWS.name());
- }
-
- // Test case 33: Contrast
- @LargeTest
- public void testContrast() {
- TestAction ta = new TestAction(TestName.CONTRAST);
- runTest(ta, TestName.CONTRAST.name());
- }
-
- // Test case 34: Exposure
- @LargeTest
- public void testExposure(){
- TestAction ta = new TestAction(TestName.EXPOSURE);
- runTest(ta, TestName.EXPOSURE.name());
- }
-
- // Test case 35: White Balance
- @LargeTest
- public void testWhiteBalance() {
- TestAction ta = new TestAction(TestName.WHITE_BALANCE);
- runTest(ta, TestName.WHITE_BALANCE.name());
- }
-
- // Test case 36: Color Cube
- @LargeTest
- public void testColorCube() {
- TestAction ta = new TestAction(TestName.COLOR_CUBE);
- runTest(ta, TestName.COLOR_CUBE.name());
- }
-
- // Test case 37: Color Cube (3D Intrinsic)
- @LargeTest
- public void testColorCube3DIntrinsic() {
- TestAction ta = new TestAction(TestName.COLOR_CUBE_3D_INTRINSIC);
- runTest(ta, TestName.COLOR_CUBE_3D_INTRINSIC.name());
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTestRunner.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTestRunner.java
deleted file mode 100644
index 36fbb3e..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTestRunner.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.image;
-
-import com.android.rs.image.ImageProcessingTest;
-import android.os.Bundle;
-import android.test.InstrumentationTestRunner;
-import android.test.InstrumentationTestSuite;
-import junit.framework.TestSuite;
-
-/**
- * Run the ImageProcessing benchmark test
- * adb shell am instrument -e iteration <n> -w com.android.rs.image/.ImageProcessingTestRunner
- *
- */
-public class ImageProcessingTestRunner extends InstrumentationTestRunner {
- public int mIteration = 5;
-
- @Override
- public TestSuite getAllTests() {
- TestSuite suite = new InstrumentationTestSuite(this);
- suite.addTestSuite(ImageProcessingTest.class);
- return suite;
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- String strIteration = (String) icicle.get("iteration");
- if (strIteration != null) {
- mIteration = Integer.parseInt(strIteration);
- }
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/LevelsV4.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/LevelsV4.java
deleted file mode 100644
index 9eb5647..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/LevelsV4.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Matrix3f;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.Type;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-
-public class LevelsV4 extends TestBase {
- private ScriptC_levels_relaxed mScriptR;
- private ScriptC_levels_full mScriptF;
- private float mInBlack = 0.0f;
- private float mOutBlack = 0.0f;
- private float mInWhite = 255.0f;
- private float mOutWhite = 255.0f;
- private float mSaturation = 1.0f;
-
- Matrix3f satMatrix = new Matrix3f();
- float mInWMinInB;
- float mOutWMinOutB;
- float mOverInWMinInB;
-
- boolean mUseFull;
- boolean mUseV4;
-
- LevelsV4(boolean useFull, boolean useV4) {
- mUseFull = useFull;
- mUseV4 = useV4;
- }
-
-
- private void setLevels() {
- mInWMinInB = mInWhite - mInBlack;
- mOutWMinOutB = mOutWhite - mOutBlack;
- mOverInWMinInB = 1.f / mInWMinInB;
-
- mScriptR.set_inBlack(mInBlack);
- mScriptR.set_outBlack(mOutBlack);
- mScriptR.set_inWMinInB(mInWMinInB);
- mScriptR.set_outWMinOutB(mOutWMinOutB);
- mScriptR.set_overInWMinInB(mOverInWMinInB);
- mScriptF.set_inBlack(mInBlack);
- mScriptF.set_outBlack(mOutBlack);
- mScriptF.set_inWMinInB(mInWMinInB);
- mScriptF.set_outWMinOutB(mOutWMinOutB);
- mScriptF.set_overInWMinInB(mOverInWMinInB);
- }
-
- private void setSaturation() {
- float rWeight = 0.299f;
- float gWeight = 0.587f;
- float bWeight = 0.114f;
- float oneMinusS = 1.0f - mSaturation;
-
- satMatrix.set(0, 0, oneMinusS * rWeight + mSaturation);
- satMatrix.set(0, 1, oneMinusS * rWeight);
- satMatrix.set(0, 2, oneMinusS * rWeight);
- satMatrix.set(1, 0, oneMinusS * gWeight);
- satMatrix.set(1, 1, oneMinusS * gWeight + mSaturation);
- satMatrix.set(1, 2, oneMinusS * gWeight);
- satMatrix.set(2, 0, oneMinusS * bWeight);
- satMatrix.set(2, 1, oneMinusS * bWeight);
- satMatrix.set(2, 2, oneMinusS * bWeight + mSaturation);
- mScriptR.set_colorMat(satMatrix);
- mScriptF.set_colorMat(satMatrix);
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- b.setProgress(50);
- t.setText("Saturation");
- return true;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(0);
- t.setText("In Black");
- return true;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(0);
- t.setText("Out Black");
- return true;
- }
- public boolean onBar4Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(128);
- t.setText("Out White");
- return true;
- }
- public boolean onBar5Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(128);
- t.setText("Out White");
- return true;
- }
-
- public void onBar1Changed(int progress) {
- mSaturation = (float)progress / 50.0f;
- setSaturation();
- }
- public void onBar2Changed(int progress) {
- mInBlack = (float)progress;
- setLevels();
- }
- public void onBar3Changed(int progress) {
- mOutBlack = (float)progress;
- setLevels();
- }
- public void onBar4Changed(int progress) {
- mInWhite = (float)progress + 127.0f;
- setLevels();
- }
- public void onBar5Changed(int progress) {
- mOutWhite = (float)progress + 127.0f;
- setLevels();
- }
-
- public void createTest(android.content.res.Resources res) {
- mScriptR = new ScriptC_levels_relaxed(mRS, res, R.raw.levels_relaxed);
- mScriptF = new ScriptC_levels_full(mRS, res, R.raw.levels_full);
- setSaturation();
- setLevels();
- }
-
- public void runTest() {
- if (mUseFull) {
- if (mUseV4) {
- mScriptF.forEach_root4(mInPixelsAllocation, mOutPixelsAllocation);
- } else {
- mScriptF.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
- } else {
- if (mUseV4) {
- mScriptR.forEach_root4(mInPixelsAllocation, mOutPixelsAllocation);
- } else {
- mScriptR.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
- }
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Mandelbrot.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Mandelbrot.java
deleted file mode 100644
index 20036e6..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Mandelbrot.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.Type;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Mandelbrot extends TestBase {
- private ScriptC_mandelbrot mScript;
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Iterations");
- b.setProgress(0);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- int iters = progress * 3 + 50;
- mScript.set_gMaxIteration(iters);
- }
-
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Lower Bound: X");
- b.setProgress(0);
- return true;
- }
-
- public void onBar2Changed(int progress) {
- float scaleFactor = mScript.get_scaleFactor();
- // allow viewport to be moved by 2x scale factor
- float lowerBoundX = -2.f + ((progress / scaleFactor) / 50.f);
- mScript.set_lowerBoundX(lowerBoundX);
- }
-
- public boolean onBar3Setup(SeekBar b, TextView t) {
- t.setText("Lower Bound: Y");
- b.setProgress(0);
- return true;
- }
-
- public void onBar3Changed(int progress) {
- float scaleFactor = mScript.get_scaleFactor();
- // allow viewport to be moved by 2x scale factor
- float lowerBoundY = -2.f + ((progress / scaleFactor) / 50.f);
- mScript.set_lowerBoundY(lowerBoundY);
- }
-
- public boolean onBar4Setup(SeekBar b, TextView t) {
- t.setText("Scale Factor");
- b.setProgress(0);
- return true;
- }
-
- public void onBar4Changed(int progress) {
- float scaleFactor = 4.f - (3.96f * (progress / 100.f));
- mScript.set_scaleFactor(scaleFactor);
- }
-
- public void createTest(android.content.res.Resources res) {
- int width = mOutPixelsAllocation.getType().getX();
- int height = mOutPixelsAllocation.getType().getY();
-
- mScript = new ScriptC_mandelbrot(mRS, res, R.raw.mandelbrot);
- mScript.set_gDimX(width);
- mScript.set_gDimY(height);
- mScript.set_gMaxIteration(50);
- }
-
- public void runTest() {
- mScript.forEach_root(mOutPixelsAllocation);
- mRS.finish();
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Shadows.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Shadows.java
deleted file mode 100644
index 98ab15f..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Shadows.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-
-public class Shadows extends TestBase {
- private ScriptC_shadows mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_shadows(mRS);
- }
-
- public void runTest() {
- mScript.invoke_prepareShadows(50.f);
- mScript.forEach_shadowsKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java
deleted file mode 100644
index a353d9c..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.graphics.BitmapFactory;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.renderscript.ScriptC;
-import android.renderscript.RenderScript;
-import android.renderscript.Type;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Script;
-import android.view.SurfaceView;
-import android.view.SurfaceHolder;
-import android.widget.ImageView;
-import android.widget.SeekBar;
-import android.widget.TextView;
-import android.view.View;
-import android.util.Log;
-import java.lang.Math;
-import android.widget.Spinner;
-
-public class TestBase {
- protected final String TAG = "Img";
-
- protected RenderScript mRS;
- protected Allocation mInPixelsAllocation;
- protected Allocation mInPixelsAllocation2;
- protected Allocation mOutPixelsAllocation;
- protected ImageProcessingActivity act;
-
- private class MessageProcessor extends RenderScript.RSMessageHandler {
- ImageProcessingActivity mAct;
-
- MessageProcessor(ImageProcessingActivity act) {
- mAct = act;
- }
-
- public void run() {
- mAct.updateDisplay();
- }
- }
-
- // Override to use UI elements
- public void onBar1Changed(int progress) {
- }
- public void onBar2Changed(int progress) {
- }
- public void onBar3Changed(int progress) {
- }
- public void onBar4Changed(int progress) {
- }
- public void onBar5Changed(int progress) {
- }
-
- // Override to use UI elements
- // Unused bars will be hidden.
- public boolean onBar1Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar4Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar5Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
-
- public boolean onSpinner1Setup(Spinner s) {
- s.setVisibility(View.INVISIBLE);
- return false;
- }
-
- public final void createBaseTest(ImageProcessingActivity ipact, Bitmap b, Bitmap b2, Bitmap outb) {
- act = ipact;
- mRS = ipact.mRS;
- mRS.setMessageHandler(new MessageProcessor(act));
-
- mInPixelsAllocation = ipact.mInPixelsAllocation;
- mInPixelsAllocation2 = ipact.mInPixelsAllocation2;
- mOutPixelsAllocation = ipact.mOutPixelsAllocation;
-
- createTest(act.getResources());
- }
-
- // Must override
- public void createTest(android.content.res.Resources res) {
- }
-
- // Must override
- public void runTest() {
- }
-
- final public void runTestSendMessage() {
- runTest();
- mRS.sendMessage(0, null);
- }
-
- public void finish() {
- mRS.finish();
- }
-
- public void destroy() {
- mRS.setMessageHandler(null);
- }
-
- public void updateBitmap(Bitmap b) {
- mOutPixelsAllocation.copyTo(b);
- }
-
- // Override to configure specific benchmark config.
- public void setupBenchmark() {
- }
-
- // Override to reset after benchmark.
- public void exitBenchmark() {
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/UsageIO.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/UsageIO.java
deleted file mode 100644
index 3f86311..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/UsageIO.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.image;
-
-import java.lang.Math;
-
-import android.view.Surface;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.ScriptIntrinsicConvolve3x3;
-import android.renderscript.ScriptIntrinsicColorMatrix;
-import android.renderscript.Type;
-import android.renderscript.Matrix4f;
-import android.renderscript.ScriptGroup;
-import android.util.Log;
-
-public class UsageIO extends TestBase {
- private ScriptIntrinsicColorMatrix mMatrix;
-
- private Allocation mScratchPixelsAllocation1;
- private Allocation mScratchPixelsAllocation2;
-
- public UsageIO() {
- }
-
- public void createTest(android.content.res.Resources res) {
- mMatrix = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
-
- Matrix4f m = new Matrix4f();
- m.set(1, 0, 0.2f);
- m.set(1, 1, 0.9f);
- m.set(1, 2, 0.2f);
- mMatrix.setColorMatrix(m);
-
- Type connect = mInPixelsAllocation.getType();
-
- mScratchPixelsAllocation1 = Allocation.createTyped(mRS, connect, Allocation.USAGE_IO_OUTPUT | Allocation.USAGE_SCRIPT);
- mScratchPixelsAllocation2 = Allocation.createTyped(mRS, connect, Allocation.USAGE_IO_INPUT | Allocation.USAGE_SCRIPT);
-
- Surface s = mScratchPixelsAllocation2.getSurface();
- mScratchPixelsAllocation1.setSurface(s);
- }
-
- public void runTest() {
- mScratchPixelsAllocation1.copyFrom(mInPixelsAllocation);
- mScratchPixelsAllocation1.ioSend();
- mScratchPixelsAllocation2.ioReceive();
- mMatrix.forEach(mScratchPixelsAllocation2, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Vibrance.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Vibrance.java
deleted file mode 100644
index 0bc1ff7..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Vibrance.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-
-public class Vibrance extends TestBase {
- private ScriptC_vibrance mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_vibrance(mRS);
- }
-
- public void runTest() {
- mScript.set_vibrance(50.f);
- mScript.invoke_prepareVibrance();
- mScript.forEach_vibranceKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Vignette.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Vignette.java
deleted file mode 100644
index 18d1103..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Vignette.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Sampler;
-import android.renderscript.Type;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Vignette extends TestBase {
- private ScriptC_vignette_full mScript_full = null;
- private ScriptC_vignette_relaxed mScript_relaxed = null;
- private ScriptC_vignette_approx_full mScript_approx_full = null;
- private ScriptC_vignette_approx_relaxed mScript_approx_relaxed = null;
- private final boolean approx;
- private final boolean relaxed;
- private float center_x = 0.5f;
- private float center_y = 0.5f;
- private float scale = 0.5f;
- private float shade = 0.5f;
- private float slope = 20.0f;
-
- public Vignette(boolean approx, boolean relaxed) {
- this.approx = approx;
- this.relaxed = relaxed;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Scale");
- b.setMax(100);
- b.setProgress(25);
- return true;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Shade");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- t.setText("Slope");
- b.setMax(100);
- b.setProgress(20);
- return true;
- }
- public boolean onBar4Setup(SeekBar b, TextView t) {
- t.setText("Shift center X");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
- public boolean onBar5Setup(SeekBar b, TextView t) {
- t.setText("Shift center Y");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- scale = progress / 50.0f;
- do_init();
- }
- public void onBar2Changed(int progress) {
- shade = progress / 100.0f;
- do_init();
- }
- public void onBar3Changed(int progress) {
- slope = (float)progress;
- do_init();
- }
- public void onBar4Changed(int progress) {
- center_x = progress / 100.0f;
- do_init();
- }
- public void onBar5Changed(int progress) {
- center_y = progress / 100.0f;
- do_init();
- }
-
- private void do_init() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale, shade, slope);
- else
- mScript_approx_full.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale, shade, slope);
- } else if (relaxed)
- mScript_relaxed.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale, shade, slope);
- else
- mScript_full.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale, shade, slope);
- }
-
- public void createTest(android.content.res.Resources res) {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed = new ScriptC_vignette_approx_relaxed(
- mRS, res, R.raw.vignette_approx_relaxed);
- else
- mScript_approx_full = new ScriptC_vignette_approx_full(
- mRS, res, R.raw.vignette_approx_full);
- } else if (relaxed)
- mScript_relaxed = new ScriptC_vignette_relaxed(mRS, res,
- R.raw.vignette_relaxed);
- else
- mScript_full = new ScriptC_vignette_full(mRS, res,
- R.raw.vignette_full);
- do_init();
- }
-
- public void runTest() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- else
- mScript_approx_full.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- } else if (relaxed)
- mScript_relaxed.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- else
- mScript_full.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/WhiteBalance.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/WhiteBalance.java
deleted file mode 100644
index a836067..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/WhiteBalance.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-
-public class WhiteBalance extends TestBase {
- private ScriptC_wbalance mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_wbalance(mRS);
- }
-
- public void runTest() {
- mScript.set_histogramSource(mInPixelsAllocation);
- mScript.set_histogramWidth(mInPixelsAllocation.getType().getX());
- mScript.set_histogramHeight(mInPixelsAllocation.getType().getY());
- mScript.invoke_prepareWhiteBalance();
- mScript.forEach_whiteBalanceKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/blend.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/blend.rs
deleted file mode 100644
index 9ec1246..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/blend.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (C) 2011 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.
-
-#include "ip.rsh"
-
-uchar alpha = 0x0;
-
-void setImageAlpha(uchar4 *v_out, uint32_t x, uint32_t y) {
- v_out->rgba = convert_uchar4((convert_uint4(v_out->rgba) * alpha) >> (uint4)8);
- v_out->a = alpha;
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/bwfilter.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/bwfilter.rs
deleted file mode 100644
index e706d44..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/bwfilter.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-//#pragma rs_fp_relaxed
-
-static float sr = 0.f;
-static float sg = 0.f;
-static float sb = 0.f;
-
-void prepareBwFilter(uint32_t rw, uint32_t gw, uint32_t bw) {
-
- sr = rw;
- sg = gw;
- sb = bw;
-
- float imageMin = min(sg,sb);
- imageMin = fmin(sr,imageMin);
- float imageMax = max(sg,sb);
- imageMax = fmax(sr,imageMax);
- float avg = (imageMin + imageMax)/2;
- sb /= avg;
- sg /= avg;
- sr /= avg;
-
-}
-
-void bwFilterKernel(const uchar4 *in, uchar4 *out) {
- float r = in->r * sr;
- float g = in->g * sg;
- float b = in->b * sb;
- float localMin, localMax, avg;
- localMin = fmin(g,b);
- localMin = fmin(r,localMin);
- localMax = fmax(g,b);
- localMax = fmax(r,localMax);
- avg = (localMin+localMax) * 0.5f;
- out->r = out->g = out->b = rsClamp(avg, 0, 255);
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs
deleted file mode 100644
index 4f1e73e..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-#pragma rs_fp_relaxed
-
-
-static rs_allocation gCube;
-static int4 gDims;
-static int4 gCoordMul;
-
-
-void setCube(rs_allocation c) {
- gCube = c;
- gDims.x = rsAllocationGetDimX(gCube);
- gDims.y = rsAllocationGetDimY(gCube);
- gDims.z = rsAllocationGetDimZ(gCube);
- gDims.w = 0;
-
- float4 m = (float4)(1.f / 255.f) * convert_float4(gDims - 1);
- gCoordMul = convert_int4(m * (float4)0x10000);
-
- rsDebug("dims", gDims);
- rsDebug("gCoordMul", gCoordMul);
-}
-
-void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
- //rsDebug("root", in);
-
- int4 baseCoord = convert_int4(*in) * gCoordMul;
- int4 coord1 = baseCoord >> (int4)16;
- int4 coord2 = min(coord1 + 1, gDims - 1);
-
- int4 weight2 = baseCoord & 0xffff;
- int4 weight1 = (int4)0x10000 - weight2;
-
- uint4 v000 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord1.z));
- uint4 v100 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord1.z));
- uint4 v010 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord1.z));
- uint4 v110 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord1.z));
- uint4 v001 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord2.z));
- uint4 v101 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord2.z));
- uint4 v011 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord2.z));
- uint4 v111 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord2.z));
-
- uint4 yz00 = ((v000 * weight1.x) + (v100 * weight2.x)) >> (int4)8;
- uint4 yz10 = ((v010 * weight1.x) + (v110 * weight2.x)) >> (int4)8;
- uint4 yz01 = ((v001 * weight1.x) + (v101 * weight2.x)) >> (int4)8;
- uint4 yz11 = ((v011 * weight1.x) + (v111 * weight2.x)) >> (int4)8;
-
- uint4 z0 = ((yz00 * weight1.y) + (yz10 * weight2.y)) >> (int4)16;
- uint4 z1 = ((yz01 * weight1.y) + (yz11 * weight2.y)) >> (int4)16;
-
- uint4 v = ((z0 * weight1.z) + (z1 * weight2.z)) >> (int4)16;
- uint4 v2 = (v + 0x7f) >> (int4)8;
-
- *out = convert_uchar4(v2);
- out->a = 0xff;
-
- #if 0
- if (in->r != out->r) {
- rsDebug("dr", in->r - out->r);
- //rsDebug("in", convert_int4(*in));
- //rsDebug("coord1", coord1);
- //rsDebug("coord2", coord2);
- //rsDebug("weight1", weight1);
- //rsDebug("weight2", weight2);
- //rsDebug("yz00", yz00);
- //rsDebug("z0", z0);
- //rsDebug("v", v);
- //rsDebug("v2", v2);
- //rsDebug("out", convert_int4(*out));
- }
- #endif
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.fs
deleted file mode 100644
index 86fb248..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.fs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-static rs_matrix4x4 Mat;
-
-void init() {
- rsMatrixLoadIdentity(&Mat);
-}
-
-void setMatrix(rs_matrix4x4 m) {
- Mat = m;
-}
-
-uchar4 __attribute__((kernel)) root(uchar4 in) {
- float4 f = convert_float4(in);
- f = rsMatrixMultiply(&Mat, f);
- f = clamp(f, 0.f, 255.f);
- return convert_uchar4(f);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/contrast.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/contrast.rs
deleted file mode 100644
index d3743d3..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/contrast.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-static float brightM = 0.f;
-static float brightC = 0.f;
-
-void setBright(float v) {
- brightM = pow(2.f, v / 100.f);
- brightC = 127.f - brightM * 127.f;
-}
-
-void contrast(const uchar4 *in, uchar4 *out)
-{
-#if 0
- out->r = rsClamp((int)(brightM * in->r + brightC), 0, 255);
- out->g = rsClamp((int)(brightM * in->g + brightC), 0, 255);
- out->b = rsClamp((int)(brightM * in->b + brightC), 0, 255);
-#else
- float3 v = convert_float3(in->rgb) * brightM + brightC;
- out->rgb = convert_uchar3(clamp(v, 0.f, 255.f));
-#endif
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.fs
deleted file mode 100644
index 177e86e..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.fs
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-int32_t gWidth;
-int32_t gHeight;
-rs_allocation gIn;
-
-float gCoeffs[9];
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- uint32_t x1 = min((int32_t)x+1, gWidth-1);
- uint32_t x2 = max((int32_t)x-1, 0);
- uint32_t y1 = min((int32_t)y+1, gHeight-1);
- uint32_t y2 = max((int32_t)y-1, 0);
-
- float4 p00 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y1));
- float4 p01 = convert_float4(rsGetElementAt_uchar4(gIn, x, y1));
- float4 p02 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y1));
- float4 p10 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y));
- float4 p11 = convert_float4(rsGetElementAt_uchar4(gIn, x, y));
- float4 p12 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y));
- float4 p20 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y2));
- float4 p21 = convert_float4(rsGetElementAt_uchar4(gIn, x, y2));
- float4 p22 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y2));
- p00 *= gCoeffs[0];
- p01 *= gCoeffs[1];
- p02 *= gCoeffs[2];
- p10 *= gCoeffs[3];
- p11 *= gCoeffs[4];
- p12 *= gCoeffs[5];
- p20 *= gCoeffs[6];
- p21 *= gCoeffs[7];
- p22 *= gCoeffs[8];
-
- p00 += p01;
- p02 += p10;
- p11 += p12;
- p20 += p21;
-
- p22 += p00;
- p02 += p11;
-
- p20 += p22;
- p20 += p02;
-
- p20 = clamp(p20, 0.f, 255.f);
- return convert_uchar4(p20);
-}
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.fs
deleted file mode 100644
index 922a593..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.fs
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-int32_t gWidth;
-int32_t gHeight;
-rs_allocation gIn;
-
-float gCoeffs[25];
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- uint32_t x0 = max((int32_t)x-2, 0);
- uint32_t x1 = max((int32_t)x-1, 0);
- uint32_t x2 = x;
- uint32_t x3 = min((int32_t)x+1, gWidth-1);
- uint32_t x4 = min((int32_t)x+2, gWidth-1);
-
- uint32_t y0 = max((int32_t)y-2, 0);
- uint32_t y1 = max((int32_t)y-1, 0);
- uint32_t y2 = y;
- uint32_t y3 = min((int32_t)y+1, gHeight-1);
- uint32_t y4 = min((int32_t)y+2, gHeight-1);
-
- float4 p0 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y0)) * gCoeffs[0]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y0)) * gCoeffs[1]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y0)) * gCoeffs[2]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y0)) * gCoeffs[3]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y0)) * gCoeffs[4];
-
- float4 p1 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y1)) * gCoeffs[5]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y1)) * gCoeffs[6]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y1)) * gCoeffs[7]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y1)) * gCoeffs[8]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y1)) * gCoeffs[9];
-
- float4 p2 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y2)) * gCoeffs[10]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y2)) * gCoeffs[11]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y2)) * gCoeffs[12]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y2)) * gCoeffs[13]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y2)) * gCoeffs[14];
-
- float4 p3 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y3)) * gCoeffs[15]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y3)) * gCoeffs[16]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y3)) * gCoeffs[17]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y3)) * gCoeffs[18]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y3)) * gCoeffs[19];
-
- float4 p4 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y4)) * gCoeffs[20]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y4)) * gCoeffs[21]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y4)) * gCoeffs[22]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y4)) * gCoeffs[23]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y4)) * gCoeffs[24];
-
- p0 = clamp(p0 + p1 + p2 + p3 + p4, 0.f, 255.f);
- return convert_uchar4(p0);
-}
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.fs
deleted file mode 100644
index 6595874..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.fs
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-uchar4 __attribute__((kernel)) root(uchar4 v_in) {
- return v_in;
-}
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/exposure.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/exposure.rs
deleted file mode 100644
index 0f05cb9..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/exposure.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-static float bright = 0.f;
-
-void setBright(float v) {
- bright = 255.f / (255.f - v);
-}
-
-void exposure(const uchar4 *in, uchar4 *out)
-{
- out->r = rsClamp((int)(bright * in->r), 0, 255);
- out->g = rsClamp((int)(bright * in->g), 0, 255);
- out->b = rsClamp((int)(bright * in->b), 0, 255);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye.rsh
deleted file mode 100644
index 2eacb7d..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye.rsh
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-rs_allocation in_alloc;
-rs_sampler sampler;
-
-static float2 center, neg_center, inv_dimensions, axis_scale;
-static float alpha, radius2, factor;
-
-void init_filter(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y, float k) {
- center.x = center_x;
- center.y = center_y;
- neg_center = -center;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
- alpha = k * 2.0f + 0.75f;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float bound2 = 0.25f * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y);
- const float bound = sqrt(bound2);
- const float radius = 1.15f * bound;
- radius2 = radius*radius;
- const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2));
- factor = bound / max_radian;
-}
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float2 scaledCoord = axis_scale * coord;
- const float dist2 = scaledCoord.x*scaledCoord.x + scaledCoord.y*scaledCoord.y;
- const float inv_dist = rsqrt(dist2);
- const float radian = M_PI_2 - atan((alpha * sqrt(radius2 - dist2)) * inv_dist);
- const float scalar = radian * factor * inv_dist;
- const float2 new_coord = mad(coord, scalar, center);
- const float4 fout = rsSample(in_alloc, sampler, new_coord);
- return rsPackColorTo8888(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx.rsh
deleted file mode 100644
index fcf0a3d..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx.rsh
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-rs_allocation in_alloc;
-rs_sampler sampler;
-
-static float2 center, neg_center, inv_dimensions, axis_scale;
-static float alpha, radius2, factor;
-
-void init_filter(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y, float k) {
- center.x = center_x;
- center.y = center_y;
- neg_center = -center;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
- alpha = k * 2.0f + 0.75f;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float bound2 = 0.25f * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y);
- const float bound = sqrt(bound2);
- const float radius = 1.15f * bound;
- radius2 = radius*radius;
- const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2));
- factor = bound / max_radian;
-}
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float2 scaledCoord = axis_scale * coord;
- const float dist2 = scaledCoord.x*scaledCoord.x + scaledCoord.y*scaledCoord.y;
- const float inv_dist = half_rsqrt(dist2);
- const float radian = M_PI_2 - atan((alpha * half_sqrt(radius2 - dist2)) * inv_dist);
- const float scalar = radian * factor * inv_dist;
- const float2 new_coord = mad(coord, scalar, center);
- const float4 fout = rsSample(in_alloc, sampler, new_coord);
- return rsPackColorTo8888(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_full.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_full.rs
deleted file mode 100644
index ed69ff4..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.fs
deleted file mode 100644
index ed69ff4..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_full.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_full.rs
deleted file mode 100644
index f986b5d..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.fs
deleted file mode 100644
index f986b5d..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.fs
deleted file mode 100644
index 2e62cd7..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.fs
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-uchar __attribute__((kernel)) genRand() {
- return (uchar)rsRand(0xff);
-}
-
-/*
- * Convolution matrix of distance 2 with fixed point of 'kShiftBits' bits
- * shifted. Thus the sum of this matrix should be 'kShiftValue'. Entries of
- * small values are not calculated to gain efficiency.
- * The order ot pixels represented in this matrix is:
- * 1 2 3
- * 4 0 5
- * 6 7 8
- * and the matrix should be: {230, 56, 114, 56, 114, 114, 56, 114, 56}.
- * However, since most of the valus are identical, we only use the first three
- * entries and the entries corresponding to the pixels is:
- * 1 2 1
- * 2 0 2
- * 1 2 1
- */
-
-int32_t gWMask;
-int32_t gHMask;
-
-rs_allocation gBlendSource;
-uchar __attribute__((kernel)) blend9(uint32_t x, uint32_t y) {
- uint32_t x1 = (x-1) & gWMask;
- uint32_t x2 = (x+1) & gWMask;
- uint32_t y1 = (y-1) & gHMask;
- uint32_t y2 = (y+1) & gHMask;
-
- uint p00 = 56 * rsGetElementAt_uchar(gBlendSource, x1, y1);
- uint p01 = 114 * rsGetElementAt_uchar(gBlendSource, x, y1);
- uint p02 = 56 * rsGetElementAt_uchar(gBlendSource, x2, y1);
- uint p10 = 114 * rsGetElementAt_uchar(gBlendSource, x1, y);
- uint p11 = 230 * rsGetElementAt_uchar(gBlendSource, x, y);
- uint p12 = 114 * rsGetElementAt_uchar(gBlendSource, x2, y);
- uint p20 = 56 * rsGetElementAt_uchar(gBlendSource, x1, y2);
- uint p21 = 114 * rsGetElementAt_uchar(gBlendSource, x, y2);
- uint p22 = 56 * rsGetElementAt_uchar(gBlendSource, x2, y2);
-
- p00 += p01;
- p02 += p10;
- p11 += p12;
- p20 += p21;
-
- p22 += p00;
- p02 += p11;
-
- p20 += p22;
- p20 += p02;
-
- p20 = min(p20 >> 10, (uint)255);
- return (uchar)p20;
-}
-
-float gNoiseStrength;
-
-rs_allocation gNoise;
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- float4 ip = convert_float4(in);
- float pnoise = (float) rsGetElementAt_uchar(gNoise, x & gWMask, y & gHMask);
-
- float energy_level = ip.r + ip.g + ip.b;
- float energy_mask = (28.f - sqrt(energy_level)) * 0.03571f;
- pnoise = (pnoise - 128.f) * energy_mask;
-
- ip += pnoise * gNoiseStrength;
- ip = clamp(ip, 0.f, 255.f);
-
- uchar4 p = convert_uchar4(ip);
- p.a = 0xff;
- return p;
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.fs
deleted file mode 100644
index 4e13072..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.fs
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
-
-uchar4 __attribute__((kernel)) root(uchar4 v_in) {
- float4 f4 = rsUnpackColor8888(v_in);
-
- float3 mono = dot(f4.rgb, gMonoMult);
- return rsPackColorTo8888(mono);
-}
-
-uchar __attribute__((kernel)) toU8(uchar4 v_in) {
- float4 f4 = convert_float4(v_in);
- return (uchar)dot(f4.rgb, gMonoMult);
-}
-
-uchar4 __attribute__((kernel)) toU8_4(uchar v_in) {
- return (uchar4)v_in;
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ip.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ip.rsh
deleted file mode 100644
index 01a3346..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ip.rsh
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#pragma version(1)
-#pragma rs java_package_name(com.android.rs.image)
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels.rsh
deleted file mode 100644
index e289906..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels.rsh
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-float inBlack;
-float outBlack;
-float inWMinInB;
-float outWMinOutB;
-float overInWMinInB;
-rs_matrix3x3 colorMat;
-
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- uchar4 out;
- float3 pixel = convert_float4(in).rgb;
- pixel = rsMatrixMultiply(&colorMat, pixel);
- pixel = clamp(pixel, 0.f, 255.f);
- pixel = (pixel - inBlack) * overInWMinInB;
- pixel = pixel * outWMinOutB + outBlack;
- pixel = clamp(pixel, 0.f, 255.f);
- out.xyz = convert_uchar3(pixel);
- out.w = 0xff;
- return out;
-}
-
-uchar4 __attribute__((kernel)) root4(uchar4 in, uint32_t x, uint32_t y) {
- float4 pixel = convert_float4(in);
- pixel.rgb = rsMatrixMultiply(&colorMat, pixel.rgb);
- pixel = clamp(pixel, 0.f, 255.f);
- pixel = (pixel - inBlack) * overInWMinInB;
- pixel = pixel * outWMinOutB + outBlack;
- pixel = clamp(pixel, 0.f, 255.f);
- return convert_uchar4(pixel);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_full.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_full.rs
deleted file mode 100644
index 28596ba..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "levels.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.fs
deleted file mode 100644
index 28596ba..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "levels.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs
deleted file mode 100644
index de0bd00..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (C) 2011 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.
-
-#include "ip.rsh"
-
-uint32_t gMaxIteration = 500;
-uint32_t gDimX = 1024;
-uint32_t gDimY = 1024;
-
-float lowerBoundX = -2.f;
-float lowerBoundY = -2.f;
-float scaleFactor = 4.f;
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- float2 p;
- p.x = lowerBoundX + ((float)x / gDimX) * scaleFactor;
- p.y = lowerBoundY + ((float)y / gDimY) * scaleFactor;
-
- float2 t = 0;
- float2 t2 = t * t;
- int iter = 0;
- while((t2.x + t2.y < 4.f) && (iter < gMaxIteration)) {
- float xtemp = t2.x - t2.y + p.x;
- t.y = 2 * t.x * t.y + p.y;
- t.x = xtemp;
- iter++;
- t2 = t * t;
- }
-
- if(iter >= gMaxIteration) {
- // write a non-transparent black pixel
- return (uchar4){0, 0, 0, 0xff};
- } else {
- float mi3 = gMaxIteration / 3.f;
- if (iter <= (gMaxIteration / 3))
- return (uchar4){0xff * (iter / mi3), 0, 0, 0xff};
- else if (iter <= (((gMaxIteration / 3) * 2)))
- return (uchar4){0xff - (0xff * ((iter - mi3) / mi3)),
- (0xff * ((iter - mi3) / mi3)), 0, 0xff};
- else
- return (uchar4){0, 0xff - (0xff * ((iter - (mi3 * 2)) / mi3)),
- (0xff * ((iter - (mi3 * 2)) / mi3)), 0xff};
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/shadows.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/shadows.rs
deleted file mode 100644
index f6c149d..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/shadows.rs
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-//#pragma rs_fp_relaxed
-
-static double shadowFilterMap[] = {
- -0.00591, 0.0001,
- 1.16488, 0.01668,
- -0.18027, -0.06791,
- -0.12625, 0.09001,
- 0.15065, -0.03897
-};
-
-static double poly[] = {
- 0., 0.,
- 0., 0.,
- 0.
-};
-
-static const int ABITS = 4;
-static const int HSCALE = 256;
-static const int k1=255 << ABITS;
-static const int k2=HSCALE << ABITS;
-
-static double fastevalPoly(double *poly,int n, double x){
-
- double f =x;
- double sum = poly[0]+poly[1]*f;
- int i;
- for (i = 2; i < n; i++) {
- f*=x;
- sum += poly[i]*f;
- }
- return sum;
-}
-
-static ushort3 rgb2hsv( uchar4 rgb)
-{
- int iMin,iMax,chroma;
-
- int ri = rgb.r;
- int gi = rgb.g;
- int bi = rgb.b;
- short rv,rs,rh;
-
- if (ri > gi) {
- iMax = max (ri, bi);
- iMin = min (gi, bi);
- } else {
- iMax = max (gi, bi);
- iMin = min (ri, bi);
- }
-
- chroma = iMax - iMin;
- // set value
- rv = (short)( iMax << ABITS);
-
- // set saturation
- if (rv == 0)
- rs = 0;
- else
- rs = (short)((k1*chroma)/iMax);
-
- // set hue
- if (rs == 0)
- rh = 0;
- else {
- if ( ri == iMax ) {
- rh = (short)( (k2*(6*chroma+gi - bi))/(6*chroma));
- if (rh >= k2) rh -= k2;
- } else if (gi == iMax)
- rh = (short)( (k2*(2*chroma+bi - ri ))/(6*chroma));
- else // (bi == iMax )
- rh = (short)( (k2*(4*chroma+ri - gi ))/(6*chroma));
- }
-
- ushort3 out;
- out.x = rv;
- out.y = rs;
- out.z = rh;
- return out;
-}
-
-static uchar4 hsv2rgb(ushort3 hsv)
-{
- int ABITS = 4;
- int HSCALE = 256;
- int m;
- int H,X,ih,is,iv;
- int k1=255<<ABITS;
- int k2=HSCALE<<ABITS;
- int k3=1<<(ABITS-1);
- int rr=0;
- int rg=0;
- int rb=0;
- short cv = hsv.x;
- short cs = hsv.y;
- short ch = hsv.z;
-
- // set chroma and min component value m
- //chroma = ( cv * cs )/k1;
- //m = cv - chroma;
- m = ((int)cv*(k1 - (int)cs ))/k1;
-
- // chroma == 0 <-> cs == 0 --> m=cv
- if (cs == 0) {
- rb = ( rg = ( rr =( cv >> ABITS) ));
- } else {
- ih=(int)ch;
- is=(int)cs;
- iv=(int)cv;
-
- H = (6*ih)/k2;
- X = ((iv*is)/k2)*(k2- abs(6*ih- 2*(H>>1)*k2 - k2)) ;
-
- // removing additional bits --> unit8
- X=( (X+iv*(k1 - is ))/k1 + k3 ) >> ABITS;
- m=m >> ABITS;
-
- // ( chroma + m ) --> cv ;
- cv=(short) (cv >> ABITS);
- switch (H) {
- case 0:
- rr = cv;
- rg = X;
- rb = m;
- break;
- case 1:
- rr = X;
- rg = cv;
- rb = m;
- break;
- case 2:
- rr = m;
- rg = cv;
- rb = X;
- break;
- case 3:
- rr = m;
- rg = X;
- rb = cv;
- break;
- case 4:
- rr = X;
- rg = m;
- rb = cv;
- break;
- case 5:
- rr = cv;
- rg = m ;
- rb = X;
- break;
- }
- }
-
- uchar4 rgb;
-
- rgb.r = rr;
- rgb.g = rg;
- rgb.b = rb;
-
- return rgb;
-}
-
-void prepareShadows(float scale) {
- double s = (scale>=0)?scale:scale/5;
- for (int i = 0; i < 5; i++) {
- poly[i] = fastevalPoly(shadowFilterMap+i*2,2 , s);
- }
-}
-
-void shadowsKernel(const uchar4 *in, uchar4 *out) {
- ushort3 hsv = rgb2hsv(*in);
- double v = (fastevalPoly(poly,5,hsv.x/4080.)*4080);
- if (v>4080) v = 4080;
- hsv.x = (unsigned short) ((v>0)?v:0);
- *out = hsv2rgb(hsv);
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.fs
deleted file mode 100644
index 0b2c2e8..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.fs
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#include "ip.rsh"
-
-
-int height;
-int width;
-static int radius;
-
-rs_allocation InPixel;
-rs_allocation ScratchPixel1;
-rs_allocation ScratchPixel2;
-
-const int MAX_RADIUS = 25;
-
-// Store our coefficients here
-static float gaussian[MAX_RADIUS * 2 + 1];
-
-void setRadius(int rad) {
- radius = rad;
- // Compute gaussian weights for the blur
- // e is the euler's number
- float e = 2.718281828459045f;
- float pi = 3.1415926535897932f;
- // g(x) = ( 1 / sqrt( 2 * pi ) * sigma) * e ^ ( -x^2 / 2 * sigma^2 )
- // x is of the form [-radius .. 0 .. radius]
- // and sigma varies with radius.
- // Based on some experimental radius values and sigma's
- // we approximately fit sigma = f(radius) as
- // sigma = radius * 0.4 + 0.6
- // The larger the radius gets, the more our gaussian blur
- // will resemble a box blur since with large sigma
- // the gaussian curve begins to lose its shape
- float sigma = 0.4f * (float)radius + 0.6f;
-
- // Now compute the coefficints
- // We will store some redundant values to save some math during
- // the blur calculations
- // precompute some values
- float coeff1 = 1.0f / (sqrt( 2.0f * pi ) * sigma);
- float coeff2 = - 1.0f / (2.0f * sigma * sigma);
-
- float normalizeFactor = 0.0f;
- float floatR = 0.0f;
- for (int r = -radius; r <= radius; r ++) {
- floatR = (float)r;
- gaussian[r + radius] = coeff1 * pow(e, floatR * floatR * coeff2);
- normalizeFactor += gaussian[r + radius];
- }
-
- //Now we need to normalize the weights because all our coefficients need to add up to one
- normalizeFactor = 1.0f / normalizeFactor;
- for (int r = -radius; r <= radius; r ++) {
- floatR = (float)r;
- gaussian[r + radius] *= normalizeFactor;
- }
-}
-
-float4 __attribute__((kernel)) copyIn(uchar4 in) {
- return convert_float4(in);
-}
-
-uchar4 __attribute__((kernel)) vert(uint32_t x, uint32_t y) {
- float3 blurredPixel = 0;
- int gi = 0;
- uchar4 out;
- if ((y > radius) && (y < (height - radius))) {
- for (int r = -radius; r <= radius; r ++) {
- float4 i = rsGetElementAt_float4(ScratchPixel2, x, y + r);
- blurredPixel += i.xyz * gaussian[gi++];
- }
- } else {
- for (int r = -radius; r <= radius; r ++) {
- int validH = rsClamp((int)y + r, (int)0, (int)(height - 1));
- float4 i = rsGetElementAt_float4(ScratchPixel2, x, validH);
- blurredPixel += i.xyz * gaussian[gi++];
- }
- }
-
- out.xyz = convert_uchar3(clamp(blurredPixel, 0.f, 255.f));
- out.w = 0xff;
- return out;
-}
-
-float4 __attribute__((kernel)) horz(uint32_t x, uint32_t y) {
- float4 blurredPixel = 0;
- int gi = 0;
- if ((x > radius) && (x < (width - radius))) {
- for (int r = -radius; r <= radius; r ++) {
- float4 i = rsGetElementAt_float4(ScratchPixel1, x + r, y);
- blurredPixel += i * gaussian[gi++];
- }
- } else {
- for (int r = -radius; r <= radius; r ++) {
- // Stepping left and right away from the pixel
- int validX = rsClamp((int)x + r, (int)0, (int)(width - 1));
- float4 i = rsGetElementAt_float4(ScratchPixel1, validX, y);
- blurredPixel += i * gaussian[gi++];
- }
- }
-
- return blurredPixel;
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vibrance.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vibrance.rs
deleted file mode 100644
index ad4de58..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vibrance.rs
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-float vibrance = 0.f;
-
-static const float Rf = 0.2999f;
-static const float Gf = 0.587f;
-static const float Bf = 0.114f;
-
-static float S = 0.f;
-static float MS = 0.f;
-static float Rt = 0.f;
-static float Gt = 0.f;
-static float Bt = 0.f;
-static float Vib = 0.f;
-
-void vibranceKernel(const uchar4 *in, uchar4 *out) {
-
- float R, G, B;
-
- int r = in->r;
- int g = in->g;
- int b = in->b;
- float red = (r-max(g, b))/256.f;
- float sx = (float)(Vib/(1+native_exp(-red*3)));
- S = sx+1;
- MS = 1.0f - S;
- Rt = Rf * MS;
- Gt = Gf * MS;
- Bt = Bf * MS;
- int t = (r + g) / 2;
- R = r;
- G = g;
- B = b;
-
- float Rc = R * (Rt + S) + G * Gt + B * Bt;
- float Gc = R * Rt + G * (Gt + S) + B * Bt;
- float Bc = R * Rt + G * Gt + B * (Bt + S);
-
- out->r = rsClamp(Rc, 0, 255);
- out->g = rsClamp(Gc, 0, 255);
- out->b = rsClamp(Bc, 0, 255);
-
-}
-
-void prepareVibrance() {
-
- Vib = vibrance/100.f;
- S = Vib + 1;
- MS = 1.0f - S;
- Rt = Rf * MS;
- Gt = Gf * MS;
- Bt = Bf * MS;
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh
deleted file mode 100644
index 04ca1f1..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-static float2 neg_center, axis_scale, inv_dimensions;
-static float sloped_neg_range, sloped_inv_max_dist, shade, opp_shade;
-
-void init_vignette(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y,
- float desired_scale, float desired_shade, float desired_slope) {
-
- neg_center.x = -center_x;
- neg_center.y = -center_y;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float max_dist = 0.5f * length(axis_scale);
- sloped_inv_max_dist = desired_slope * 1.f/max_dist;
-
- // Range needs to be between 1.3 to 0.6. When scale is zero then range is
- // 1.3 which means no vignette at all because the luminousity difference is
- // less than 1/256. Expect input scale to be between 0.0 and 1.0.
- const float neg_range = 0.7f*sqrt(desired_scale) - 1.3f;
- sloped_neg_range = exp(neg_range * desired_slope);
-
- shade = desired_shade;
- opp_shade = 1.f - desired_shade;
-}
-
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float4 fin = convert_float4(in);
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float sloped_dist_ratio = length(axis_scale * coord) * sloped_inv_max_dist;
- const float lumen = opp_shade + shade / ( 1.0f + sloped_neg_range * exp(sloped_dist_ratio) );
- float4 fout;
- fout.rgb = fin.rgb * lumen;
- fout.w = fin.w;
- return convert_uchar4(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh
deleted file mode 100644
index 5668621..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-static float2 neg_center, axis_scale, inv_dimensions;
-static float sloped_neg_range, sloped_inv_max_dist, shade, opp_shade;
-
-void init_vignette(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y,
- float desired_scale, float desired_shade, float desired_slope) {
-
- neg_center.x = -center_x;
- neg_center.y = -center_y;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float max_dist = 0.5f * length(axis_scale);
- sloped_inv_max_dist = desired_slope * 1.f/max_dist;
-
- // Range needs to be between 1.3 to 0.6. When scale is zero then range is
- // 1.3 which means no vignette at all because the luminousity difference is
- // less than 1/256. Expect input scale to be between 0.0 and 1.0.
- const float neg_range = 0.7f*sqrt(desired_scale) - 1.3f;
- sloped_neg_range = exp(neg_range * desired_slope);
-
- shade = desired_shade;
- opp_shade = 1.f - desired_shade;
-}
-
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float4 fin = convert_float4(in);
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float sloped_dist_ratio = fast_length(axis_scale * coord) * sloped_inv_max_dist;
- const float lumen = opp_shade + shade * half_recip(1.f + sloped_neg_range * native_exp(sloped_dist_ratio));
- float4 fout;
- fout.rgb = fin.rgb * lumen;
- fout.w = fin.w;
- return convert_uchar4(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_full.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_full.rs
deleted file mode 100644
index 00cbbc4..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.fs
deleted file mode 100644
index 00cbbc4..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_full.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_full.rs
deleted file mode 100644
index 8202c5c..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.fs
deleted file mode 100644
index 8202c5c..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/wbalance.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/wbalance.rs
deleted file mode 100644
index 6650671..0000000
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/wbalance.rs
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-//#pragma rs_fp_relaxed
-
-static int histR[256] = {0}, histG[256] = {0}, histB[256] = {0};
-
-rs_allocation histogramSource;
-uint32_t histogramHeight;
-uint32_t histogramWidth;
-
-static float scaleR;
-static float scaleG;
-static float scaleB;
-
-static uchar4 estimateWhite() {
-
- for (int i = 0; i < 256; i++) {
- histR[i] = 0; histG[i] = 0; histB[i] = 0;
- }
-
- for (uint32_t i = 0; i < histogramHeight; i++) {
- for (uint32_t j = 0; j < histogramWidth; j++) {
- uchar4 in = rsGetElementAt_uchar4(histogramSource, j, i);
- histR[in.r]++;
- histG[in.g]++;
- histB[in.b]++;
- }
- }
-
- int min_r = -1, min_g = -1, min_b = -1;
- int max_r = 0, max_g = 0, max_b = 0;
- int sum_r = 0, sum_g = 0, sum_b = 0;
-
- for (int i = 1; i < 255; i++) {
- int r = histR[i];
- int g = histG[i];
- int b = histB[i];
- sum_r += r;
- sum_g += g;
- sum_b += b;
-
- if (r>0){
- if (min_r < 0) min_r = i;
- max_r = i;
- }
- if (g>0){
- if (min_g < 0) min_g = i;
- max_g = i;
- }
- if (b>0){
- if (min_b < 0) min_b = i;
- max_b = i;
- }
- }
-
- int sum15r = 0, sum15g = 0, sum15b = 0;
- int count15r = 0, count15g = 0, count15b = 0;
- int tmp_r = 0, tmp_g = 0, tmp_b = 0;
-
- for (int i = 254; i >0; i--) {
- int r = histR[i];
- int g = histG[i];
- int b = histB[i];
- tmp_r += r;
- tmp_g += g;
- tmp_b += b;
-
- if ((tmp_r > sum_r/20) && (tmp_r < sum_r/5)) {
- sum15r += r*i;
- count15r += r;
- }
- if ((tmp_g > sum_g/20) && (tmp_g < sum_g/5)) {
- sum15g += g*i;
- count15g += g;
- }
- if ((tmp_b > sum_b/20) && (tmp_b < sum_b/5)) {
- sum15b += b*i;
- count15b += b;
- }
-
- }
-
- uchar4 out;
-
- if ((count15r>0) && (count15g>0) && (count15b>0) ){
- out.r = sum15r/count15r;
- out.g = sum15g/count15g;
- out.b = sum15b/count15b;
- }else {
- out.r = out.g = out.b = 255;
- }
-
- return out;
-
-}
-
-void prepareWhiteBalance() {
- uchar4 estimation = estimateWhite();
- int minimum = min(estimation.r, min(estimation.g, estimation.b));
- int maximum = max(estimation.r, max(estimation.g, estimation.b));
- float avg = (minimum + maximum) / 2.f;
-
- scaleR = avg/estimation.r;
- scaleG = avg/estimation.g;
- scaleB = avg/estimation.b;
-
-}
-
-static unsigned char contrastClamp(int c)
-{
- int N = 255;
- c &= ~(c >> 31);
- c -= N;
- c &= (c >> 31);
- c += N;
- return (unsigned char) c;
-}
-
-void whiteBalanceKernel(const uchar4 *in, uchar4 *out) {
- float Rc = in->r*scaleR;
- float Gc = in->g*scaleG;
- float Bc = in->b*scaleB;
-
- out->r = contrastClamp(Rc);
- out->g = contrastClamp(Gc);
- out->b = contrastClamp(Bc);
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/Android.mk b/tests/RenderScriptTests/ImageProcessing2/Android.mk
deleted file mode 100644
index 52966a3..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/Android.mk
+++ /dev/null
@@ -1,40 +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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
- $(call all-renderscript-files-under, src)
-
-LOCAL_STATIC_JAVA_LIBRARIES := android.support.v8.renderscript
-
-LOCAL_PACKAGE_NAME := ImageProcessing2
-LOCAL_SDK_VERSION := 8
-LOCAL_RENDERSCRIPT_TARGET_API := 18
-LOCAL_RENDERSCRIPT_COMPATIBILITY := 18
-LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE := $(TOPDIR)external/clang/lib/Headers \
- $(TOPDIR)frameworks/rs/scriptc
-
-LOCAL_RENDERSCRIPT_FLAGS := -rs-package-name=android.support.v8.renderscript
-LOCAL_REQUIRED_MODULES := librsjni
-
-include $(BUILD_PACKAGE)
-
-#include $(call all-makefiles-under, $(LOCAL_PATH))
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/AndroidManifest.xml b/tests/RenderScriptTests/ImageProcessing2/AndroidManifest.xml
deleted file mode 100644
index 20ee053..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/AndroidManifest.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.rs.image2">
- <uses-sdk android:minSdkVersion="8" />
- <application android:label="IP GB">
- <activity android:name="ImageProcessingActivity2">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/city.png b/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/city.png
deleted file mode 100644
index 856eeff..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/city.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067.jpg b/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067.jpg
deleted file mode 100644
index 05d3ee2..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067b.jpg b/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067b.jpg
deleted file mode 100644
index aed0781..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067b.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ImageProcessing2/res/layout/main.xml b/tests/RenderScriptTests/ImageProcessing2/res/layout/main.xml
deleted file mode 100644
index f0a2b92..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/res/layout/main.xml
+++ /dev/null
@@ -1,139 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:id="@+id/toplevel">
- <SurfaceView
- android:id="@+id/surface"
- android:layout_width="1dip"
- android:layout_height="1dip" />
- <ScrollView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <ImageView
- android:id="@+id/display"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/benchmark"
- android:onClick="benchmark"/>
- <TextView
- android:id="@+id/benchmarkText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:text="@string/saturation"/>
- </LinearLayout>
- <Spinner
- android:id="@+id/filterselection"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
- <Spinner
- android:id="@+id/spinner1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider1Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/saturation"/>
- <SeekBar
- android:id="@+id/slider1"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider2Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/gamma"/>
- <SeekBar
- android:id="@+id/slider2"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider3Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:textSize="8pt"
- android:text="@string/out_white"/>
- <SeekBar
- android:id="@+id/slider3"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider4Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/in_white"/>
- <SeekBar
- android:id="@+id/slider4"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider5Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/in_white"/>
- <SeekBar
- android:id="@+id/slider5"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/benchmark_all"
- android:onClick="benchmark_all"/>
- </LinearLayout>
- </ScrollView>
-</LinearLayout>
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/res/layout/spinner_layout.xml b/tests/RenderScriptTests/ImageProcessing2/res/layout/spinner_layout.xml
deleted file mode 100644
index 8196bbf..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/res/layout/spinner_layout.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 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.
--->
-
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:padding="10dp"
- android:textSize="16sp"
-/>
diff --git a/tests/RenderScriptTests/ImageProcessing2/res/values/strings.xml b/tests/RenderScriptTests/ImageProcessing2/res/values/strings.xml
deleted file mode 100644
index a7dd165..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/res/values/strings.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2008 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.
-*/
--->
-
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- General -->
- <skip />
- <!--slider label -->
- <string name="blur_description">Blur Radius</string>
- <string name="in_white">In White</string>
- <string name="out_white">Out White</string>
- <string name="in_black">In Black</string>
- <string name="out_black">Out Black</string>
- <string name="gamma">Gamma</string>
- <string name="saturation">Saturation</string>
- <string name="benchmark">Benchmark</string>
- <string name="benchmark_all">Benchmark All</string>
-
-</resources>
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/BWFilter.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/BWFilter.java
deleted file mode 100644
index 4b19856..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/BWFilter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-
-public class BWFilter extends TestBase {
- private ScriptC_bwfilter mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_bwfilter(mRS);
- }
-
- public void runTest() {
- mScript.invoke_prepareBwFilter(50, 50, 50);
- mScript.forEach_bwFilterKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Blend.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Blend.java
deleted file mode 100644
index d81ba88..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Blend.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-import java.lang.Short;
-
-import android.support.v8.renderscript.*;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.view.View;
-import android.widget.Spinner;
-
-public class Blend extends TestBase {
- private ScriptIntrinsicBlend mBlend;
- private ScriptC_blend mBlendHelper;
- private short image1Alpha = 128;
- private short image2Alpha = 128;
-
- String mIntrinsicNames[];
-
- private Allocation image1;
- private Allocation image2;
- private int currentIntrinsic = 0;
-
- private AdapterView.OnItemSelectedListener mIntrinsicSpinnerListener =
- new AdapterView.OnItemSelectedListener() {
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
- currentIntrinsic = pos;
- if (mRS != null) {
- runTest();
- act.updateDisplay();
- }
- }
-
- public void onNothingSelected(AdapterView parent) {
-
- }
- };
-
- public void createTest(android.content.res.Resources res) {
- mBlend = ScriptIntrinsicBlend.create(mRS, Element.U8_4(mRS));
- mBlendHelper = new ScriptC_blend(mRS);
- mBlendHelper.set_alpha((short)128);
-
- image1 = Allocation.createTyped(mRS, mInPixelsAllocation.getType());
- image2 = Allocation.createTyped(mRS, mInPixelsAllocation2.getType());
-
- mIntrinsicNames = new String[14];
- mIntrinsicNames[0] = "Source";
- mIntrinsicNames[1] = "Destination";
- mIntrinsicNames[2] = "Source Over";
- mIntrinsicNames[3] = "Destination Over";
- mIntrinsicNames[4] = "Source In";
- mIntrinsicNames[5] = "Destination In";
- mIntrinsicNames[6] = "Source Out";
- mIntrinsicNames[7] = "Destination Out";
- mIntrinsicNames[8] = "Source Atop";
- mIntrinsicNames[9] = "Destination Atop";
- mIntrinsicNames[10] = "XOR";
- mIntrinsicNames[11] = "Add";
- mIntrinsicNames[12] = "Subtract";
- mIntrinsicNames[13] = "Multiply";
- }
-
- public boolean onSpinner1Setup(Spinner s) {
- s.setAdapter(new ArrayAdapter<String>(
- act, R.layout.spinner_layout, mIntrinsicNames));
- s.setOnItemSelectedListener(mIntrinsicSpinnerListener);
- return true;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Image 1 Alpha");
- b.setMax(255);
- b.setProgress(image1Alpha);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- image1Alpha = (short)progress;
- }
-
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Image 2 Alpha");
- b.setMax(255);
- b.setProgress(image2Alpha);
- return true;
- }
-
- public void onBar2Changed(int progress) {
- image2Alpha = (short)progress;
- }
-
- public void runTest() {
- image1.copy2DRangeFrom(0, 0, mInPixelsAllocation.getType().getX(), mInPixelsAllocation.getType().getY(), mInPixelsAllocation, 0, 0);
- image2.copy2DRangeFrom(0, 0, mInPixelsAllocation2.getType().getX(), mInPixelsAllocation2.getType().getY(), mInPixelsAllocation2, 0, 0);
-
- mBlendHelper.set_alpha(image1Alpha);
- mBlendHelper.forEach_setImageAlpha(image1);
-
- mBlendHelper.set_alpha(image2Alpha);
- mBlendHelper.forEach_setImageAlpha(image2);
-
- switch (currentIntrinsic) {
- case 0:
- mBlend.forEachSrc(image1, image2);
- break;
- case 1:
- mBlend.forEachDst(image1, image2);
- break;
- case 2:
- mBlend.forEachSrcOver(image1, image2);
- break;
- case 3:
- mBlend.forEachDstOver(image1, image2);
- break;
- case 4:
- mBlend.forEachSrcIn(image1, image2);
- break;
- case 5:
- mBlend.forEachDstIn(image1, image2);
- break;
- case 6:
- mBlend.forEachSrcOut(image1, image2);
- break;
- case 7:
- mBlend.forEachDstOut(image1, image2);
- break;
- case 8:
- mBlend.forEachSrcAtop(image1, image2);
- break;
- case 9:
- mBlend.forEachDstAtop(image1, image2);
- break;
- case 10:
- mBlend.forEachXor(image1, image2);
- break;
- case 11:
- mBlend.forEachAdd(image1, image2);
- break;
- case 12:
- mBlend.forEachSubtract(image1, image2);
- break;
- case 13:
- mBlend.forEachMultiply(image1, image2);
- break;
- }
-
- mOutPixelsAllocation.copy2DRangeFrom(0, 0, image2.getType().getX(), image2.getType().getY(), image2, 0, 0);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Blur25.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Blur25.java
deleted file mode 100644
index b518b02..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Blur25.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Blur25 extends TestBase {
- private boolean mUseIntrinsic = false;
- private ScriptIntrinsicBlur mIntrinsic;
-
- private int MAX_RADIUS = 25;
- private ScriptC_threshold mScript;
- private float mRadius = MAX_RADIUS;
- private float mSaturation = 1.0f;
- private Allocation mScratchPixelsAllocation1;
- private Allocation mScratchPixelsAllocation2;
-
-
- public Blur25(boolean useIntrinsic) {
- mUseIntrinsic = useIntrinsic;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Radius");
- b.setProgress(100);
- return true;
- }
-
-
- public void onBar1Changed(int progress) {
- mRadius = ((float)progress) / 100.0f * MAX_RADIUS;
- if (mRadius <= 0.10f) {
- mRadius = 0.10f;
- }
- if (mUseIntrinsic) {
- mIntrinsic.setRadius(mRadius);
- } else {
- mScript.invoke_setRadius((int)mRadius);
- }
- }
-
-
- public void createTest(android.content.res.Resources res) {
- int width = mInPixelsAllocation.getType().getX();
- int height = mInPixelsAllocation.getType().getY();
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicBlur.create(mRS, Element.U8_4(mRS));
- mIntrinsic.setRadius(MAX_RADIUS);
- mIntrinsic.setInput(mInPixelsAllocation);
- } else {
-
- Type.Builder tb = new Type.Builder(mRS, Element.F32_4(mRS));
- tb.setX(width);
- tb.setY(height);
- mScratchPixelsAllocation1 = Allocation.createTyped(mRS, tb.create());
- mScratchPixelsAllocation2 = Allocation.createTyped(mRS, tb.create());
-
- mScript = new ScriptC_threshold(mRS, res, R.raw.threshold);
- mScript.set_width(width);
- mScript.set_height(height);
- mScript.invoke_setRadius(MAX_RADIUS);
-
- mScript.set_InPixel(mInPixelsAllocation);
- mScript.set_ScratchPixel1(mScratchPixelsAllocation1);
- mScript.set_ScratchPixel2(mScratchPixelsAllocation2);
- }
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mOutPixelsAllocation);
- } else {
- mScript.forEach_copyIn(mInPixelsAllocation, mScratchPixelsAllocation1);
- mScript.forEach_horz(mScratchPixelsAllocation2);
- mScript.forEach_vert(mOutPixelsAllocation);
- }
- }
-
- public void setupBenchmark() {
- if (mUseIntrinsic) {
- mIntrinsic.setRadius(MAX_RADIUS);
- } else {
- mScript.invoke_setRadius(MAX_RADIUS);
- }
- }
-
- public void exitBenchmark() {
- if (mUseIntrinsic) {
- mIntrinsic.setRadius(mRadius);
- } else {
- mScript.invoke_setRadius((int)mRadius);
- }
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Blur25G.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Blur25G.java
deleted file mode 100644
index 19aa9f7..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Blur25G.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.graphics.Bitmap;
-import android.support.v8.renderscript.*;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Blur25G extends TestBase {
- private final int MAX_RADIUS = 25;
- private float mRadius = MAX_RADIUS;
-
- private ScriptIntrinsicBlur mIntrinsic;
-
- private ScriptC_greyscale mScript;
- private Allocation mScratchPixelsAllocation1;
- private Allocation mScratchPixelsAllocation2;
-
-
- public Blur25G() {
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Radius");
- b.setProgress(100);
- return true;
- }
-
-
- public void onBar1Changed(int progress) {
- mRadius = ((float)progress) / 100.0f * MAX_RADIUS;
- if (mRadius <= 0.10f) {
- mRadius = 0.10f;
- }
- mIntrinsic.setRadius(mRadius);
- }
-
-
- public void createTest(android.content.res.Resources res) {
- int width = mInPixelsAllocation.getType().getX();
- int height = mInPixelsAllocation.getType().getY();
-
- Type.Builder tb = new Type.Builder(mRS, Element.U8(mRS));
- tb.setX(width);
- tb.setY(height);
- mScratchPixelsAllocation1 = Allocation.createTyped(mRS, tb.create());
- mScratchPixelsAllocation2 = Allocation.createTyped(mRS, tb.create());
-
- mScript = new ScriptC_greyscale(mRS);
- mScript.forEach_toU8(mInPixelsAllocation, mScratchPixelsAllocation1);
-
- mIntrinsic = ScriptIntrinsicBlur.create(mRS, Element.U8(mRS));
- mIntrinsic.setRadius(MAX_RADIUS);
- mIntrinsic.setInput(mScratchPixelsAllocation1);
- }
-
- public void runTest() {
- mIntrinsic.forEach(mScratchPixelsAllocation2);
- }
-
- public void setupBenchmark() {
- mIntrinsic.setRadius(MAX_RADIUS);
- }
-
- public void exitBenchmark() {
- mIntrinsic.setRadius(mRadius);
- }
-
- public void updateBitmap(Bitmap b) {
- mScript.forEach_toU8_4(mScratchPixelsAllocation2, mOutPixelsAllocation);
- mOutPixelsAllocation.copyTo(b);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ColorCube.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ColorCube.java
deleted file mode 100644
index e960385..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ColorCube.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-import android.util.Log;
-
-public class ColorCube extends TestBase {
- private Allocation mCube;
- private ScriptC_colorcube mScript;
- private ScriptIntrinsic3DLUT mIntrinsic;
- private boolean mUseIntrinsic;
-
- public ColorCube(boolean useIntrinsic) {
- mUseIntrinsic = useIntrinsic;
- }
-
- private void initCube() {
- final int sx = 32;
- final int sy = 32;
- final int sz = 16;
-
- Type.Builder tb = new Type.Builder(mRS, Element.U8_4(mRS));
- tb.setX(sx);
- tb.setY(sy);
- tb.setZ(sz);
- Type t = tb.create();
- mCube = Allocation.createTyped(mRS, t);
-
- int dat[] = new int[sx * sy * sz];
- for (int z = 0; z < sz; z++) {
- for (int y = 0; y < sy; y++) {
- for (int x = 0; x < sx; x++ ) {
- int v = 0xff000000;
- v |= (0xff * x / (sx - 1));
- v |= (0xff * y / (sy - 1)) << 8;
- v |= (0xff * z / (sz - 1)) << 16;
- dat[z*sy*sx + y*sx + x] = v;
- }
- }
- }
-
- mCube.copyFromUnchecked(dat);
- }
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_colorcube(mRS, res, R.raw.colorcube);
- mIntrinsic = ScriptIntrinsic3DLUT.create(mRS, Element.U8_4(mRS));
-
- initCube();
- mScript.invoke_setCube(mCube);
- mIntrinsic.setLUT(mCube);
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation);
- } else {
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ColorMatrix.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ColorMatrix.java
deleted file mode 100644
index 3b0f86a..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ColorMatrix.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-import android.util.Log;
-
-public class ColorMatrix extends TestBase {
- private ScriptC_colormatrix mScript;
- private ScriptIntrinsicColorMatrix mIntrinsic;
- private boolean mUseIntrinsic;
- private boolean mUseGrey;
-
- public ColorMatrix(boolean useIntrinsic, boolean useGrey) {
- mUseIntrinsic = useIntrinsic;
- mUseGrey = useGrey;
- }
-
- public void createTest(android.content.res.Resources res) {
- Matrix4f m = new Matrix4f();
- m.set(1, 0, 0.2f);
- m.set(1, 1, 0.9f);
- m.set(1, 2, 0.2f);
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
- if (mUseGrey) {
- mIntrinsic.setGreyscale();
- } else {
- mIntrinsic.setColorMatrix(m);
- }
- } else {
- mScript = new ScriptC_colormatrix(mRS, res, R.raw.colormatrix);
- mScript.invoke_setMatrix(m);
- }
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation);
- } else {
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Contrast.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Contrast.java
deleted file mode 100644
index 3ae5d2a..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Contrast.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-
-public class Contrast extends TestBase {
- private ScriptC_contrast mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_contrast(mRS);
- }
-
- public void runTest() {
- mScript.invoke_setBright(50.f);
- mScript.forEach_contrast(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Convolve3x3.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Convolve3x3.java
deleted file mode 100644
index d4852f0..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Convolve3x3.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-import android.util.Log;
-
-public class Convolve3x3 extends TestBase {
- private ScriptC_ip2_convolve3x3 mScript;
- private ScriptIntrinsicConvolve3x3 mIntrinsic;
-
- private int mWidth;
- private int mHeight;
- private boolean mUseIntrinsic;
-
- public Convolve3x3(boolean useIntrinsic) {
- mUseIntrinsic = useIntrinsic;
- }
-
- public void createTest(android.content.res.Resources res) {
- mWidth = mInPixelsAllocation.getType().getX();
- mHeight = mInPixelsAllocation.getType().getY();
-
- float f[] = new float[9];
- f[0] = 0.f; f[1] = -1.f; f[2] = 0.f;
- f[3] = -1.f; f[4] = 5.f; f[5] = -1.f;
- f[6] = 0.f; f[7] = -1.f; f[8] = 0.f;
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicConvolve3x3.create(mRS, Element.U8_4(mRS));
- mIntrinsic.setCoefficients(f);
- mIntrinsic.setInput(mInPixelsAllocation);
- } else {
- mScript = new ScriptC_ip2_convolve3x3(mRS, res, R.raw.ip2_convolve3x3);
- mScript.set_gCoeffs(f);
- mScript.set_gIn(mInPixelsAllocation);
- mScript.set_gWidth(mWidth);
- mScript.set_gHeight(mHeight);
- }
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mOutPixelsAllocation);
- } else {
- mScript.forEach_root(mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Convolve5x5.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Convolve5x5.java
deleted file mode 100644
index d2da3c4..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Convolve5x5.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-import android.util.Log;
-
-public class Convolve5x5 extends TestBase {
- private ScriptC_convolve5x5 mScript;
- private ScriptIntrinsicConvolve5x5 mIntrinsic;
-
- private int mWidth;
- private int mHeight;
- private boolean mUseIntrinsic;
-
- public Convolve5x5(boolean useIntrinsic) {
- mUseIntrinsic = useIntrinsic;
- }
-
- public void createTest(android.content.res.Resources res) {
- mWidth = mInPixelsAllocation.getType().getX();
- mHeight = mInPixelsAllocation.getType().getY();
-
- float f[] = new float[25];
- //f[0] = 0.012f; f[1] = 0.025f; f[2] = 0.031f; f[3] = 0.025f; f[4] = 0.012f;
- //f[5] = 0.025f; f[6] = 0.057f; f[7] = 0.075f; f[8] = 0.057f; f[9] = 0.025f;
- //f[10]= 0.031f; f[11]= 0.075f; f[12]= 0.095f; f[13]= 0.075f; f[14]= 0.031f;
- //f[15]= 0.025f; f[16]= 0.057f; f[17]= 0.075f; f[18]= 0.057f; f[19]= 0.025f;
- //f[20]= 0.012f; f[21]= 0.025f; f[22]= 0.031f; f[23]= 0.025f; f[24]= 0.012f;
-
- //f[0] = 1.f; f[1] = 2.f; f[2] = 0.f; f[3] = -2.f; f[4] = -1.f;
- //f[5] = 4.f; f[6] = 8.f; f[7] = 0.f; f[8] = -8.f; f[9] = -4.f;
- //f[10]= 6.f; f[11]=12.f; f[12]= 0.f; f[13]=-12.f; f[14]= -6.f;
- //f[15]= 4.f; f[16]= 8.f; f[17]= 0.f; f[18]= -8.f; f[19]= -4.f;
- //f[20]= 1.f; f[21]= 2.f; f[22]= 0.f; f[23]= -2.f; f[24]= -1.f;
-
- f[0] = -1.f; f[1] = -3.f; f[2] = -4.f; f[3] = -3.f; f[4] = -1.f;
- f[5] = -3.f; f[6] = 0.f; f[7] = 6.f; f[8] = 0.f; f[9] = -3.f;
- f[10]= -4.f; f[11]= 6.f; f[12]= 20.f; f[13]= 6.f; f[14]= -4.f;
- f[15]= -3.f; f[16]= 0.f; f[17]= 6.f; f[18]= 0.f; f[19]= -3.f;
- f[20]= -1.f; f[21]= -3.f; f[22]= -4.f; f[23]= -3.f; f[24]= -1.f;
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicConvolve5x5.create(mRS, Element.U8_4(mRS));
- mIntrinsic.setCoefficients(f);
- mIntrinsic.setInput(mInPixelsAllocation);
- } else {
- mScript = new ScriptC_convolve5x5(mRS, res, R.raw.convolve5x5);
- mScript.set_gCoeffs(f);
- mScript.set_gIn(mInPixelsAllocation);
- mScript.set_gWidth(mWidth);
- mScript.set_gHeight(mHeight);
- }
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mOutPixelsAllocation);
- } else {
- mScript.forEach_root(mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Copy.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Copy.java
deleted file mode 100644
index ef71907..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Copy.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-import android.util.Log;
-
-public class Copy extends TestBase {
- private ScriptC_copy mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_copy(mRS, res, R.raw.copy);
- }
-
- public void runTest() {
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/CrossProcess.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/CrossProcess.java
deleted file mode 100644
index 96787d7..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/CrossProcess.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-import android.util.Log;
-
-public class CrossProcess extends TestBase {
- private ScriptIntrinsicLUT mIntrinsic;
-
- public void createTest(android.content.res.Resources res) {
- mIntrinsic = ScriptIntrinsicLUT.create(mRS, Element.U8_4(mRS));
- for (int ct=0; ct < 256; ct++) {
- float f = ((float)ct) / 255.f;
-
- float r = f;
- if (r < 0.5f) {
- r = 4.0f * r * r * r;
- } else {
- r = 1.0f - r;
- r = 1.0f - (4.0f * r * r * r);
- }
- mIntrinsic.setRed(ct, (int)(r * 255.f + 0.5f));
-
- float g = f;
- if (g < 0.5f) {
- g = 2.0f * g * g;
- } else {
- g = 1.0f - g;
- g = 1.0f - (2.0f * g * g);
- }
- mIntrinsic.setGreen(ct, (int)(g * 255.f + 0.5f));
-
- float b = f * 0.5f + 0.25f;
- mIntrinsic.setBlue(ct, (int)(b * 255.f + 0.5f));
- }
-
- }
-
- public void runTest() {
- mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Exposure.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Exposure.java
deleted file mode 100644
index deb6b46e..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Exposure.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-
-public class Exposure extends TestBase {
- private ScriptC_exposure mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_exposure(mRS);
- }
-
- public void runTest() {
- mScript.invoke_setBright(50.f);
- mScript.forEach_exposure(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Fisheye.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Fisheye.java
deleted file mode 100644
index 97beb88..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Fisheye.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import android.support.v8.renderscript.*;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Fisheye extends TestBase {
- private ScriptC_fisheye_full mScript_full = null;
- private ScriptC_fisheye_relaxed mScript_relaxed = null;
- private ScriptC_fisheye_approx_full mScript_approx_full = null;
- private ScriptC_fisheye_approx_relaxed mScript_approx_relaxed = null;
- private final boolean approx;
- private final boolean relaxed;
- private float center_x = 0.5f;
- private float center_y = 0.5f;
- private float scale = 0.5f;
-
- public Fisheye(boolean approx, boolean relaxed) {
- this.approx = approx;
- this.relaxed = relaxed;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Scale");
- b.setMax(100);
- b.setProgress(25);
- return true;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Shift center X");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- t.setText("Shift center Y");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- scale = progress / 50.0f;
- do_init();
- }
- public void onBar2Changed(int progress) {
- center_x = progress / 100.0f;
- do_init();
- }
- public void onBar3Changed(int progress) {
- center_y = progress / 100.0f;
- do_init();
- }
-
- private void do_init() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale);
- else
- mScript_approx_full.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale);
- } else if (relaxed)
- mScript_relaxed.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale);
- else
- mScript_full.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale);
- }
-
- public void createTest(android.content.res.Resources res) {
- if (approx) {
- if (relaxed) {
- mScript_approx_relaxed = new ScriptC_fisheye_approx_relaxed(mRS,
- res, R.raw.fisheye_approx_relaxed);
- mScript_approx_relaxed.set_in_alloc(mInPixelsAllocation);
- mScript_approx_relaxed.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- } else {
- mScript_approx_full = new ScriptC_fisheye_approx_full(mRS, res,
- R.raw.fisheye_approx_full);
- mScript_approx_full.set_in_alloc(mInPixelsAllocation);
- mScript_approx_full.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- }
- } else if (relaxed) {
- mScript_relaxed = new ScriptC_fisheye_relaxed(mRS, res,
- R.raw.fisheye_relaxed);
- mScript_relaxed.set_in_alloc(mInPixelsAllocation);
- mScript_relaxed.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- } else {
- mScript_full = new ScriptC_fisheye_full(mRS, res,
- R.raw.fisheye_full);
- mScript_full.set_in_alloc(mInPixelsAllocation);
- mScript_full.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- }
- do_init();
- }
-
- public void runTest() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.forEach_root(mOutPixelsAllocation);
- else
- mScript_approx_full.forEach_root(mOutPixelsAllocation);
- } else if (relaxed)
- mScript_relaxed.forEach_root(mOutPixelsAllocation);
- else
- mScript_full.forEach_root(mOutPixelsAllocation);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Grain.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Grain.java
deleted file mode 100644
index dfd3c32..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Grain.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Grain extends TestBase {
- private ScriptC_grain mScript;
- private Allocation mNoise;
- private Allocation mNoise2;
-
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Strength");
- b.setProgress(50);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- float s = progress / 100.0f;
- mScript.set_gNoiseStrength(s);
- }
-
- private int findHighBit(int v) {
- int bit = 0;
- while (v > 1) {
- bit++;
- v >>= 1;
- }
- return bit;
- }
-
-
- public void createTest(android.content.res.Resources res) {
- int width = mInPixelsAllocation.getType().getX();
- int height = mInPixelsAllocation.getType().getY();
-
- int noiseW = findHighBit(width);
- int noiseH = findHighBit(height);
- if (noiseW > 9) {
- noiseW = 9;
- }
- if (noiseH > 9) {
- noiseH = 9;
- }
- noiseW = 1 << noiseW;
- noiseH = 1 << noiseH;
-
- Type.Builder tb = new Type.Builder(mRS, Element.U8(mRS));
- tb.setX(noiseW);
- tb.setY(noiseH);
- mNoise = Allocation.createTyped(mRS, tb.create());
- mNoise2 = Allocation.createTyped(mRS, tb.create());
-
- mScript = new ScriptC_grain(mRS, res, R.raw.grain);
- mScript.set_gWMask(noiseW - 1);
- mScript.set_gHMask(noiseH - 1);
- mScript.set_gNoiseStrength(0.5f);
- mScript.set_gBlendSource(mNoise);
- mScript.set_gNoise(mNoise2);
- }
-
- public void runTest() {
- mScript.forEach_genRand(mNoise);
- mScript.forEach_blend9(mNoise2);
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Greyscale.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Greyscale.java
deleted file mode 100644
index 5b16e24..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Greyscale.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import android.util.Log;
-
-public class Greyscale extends TestBase {
- private ScriptC_greyscale mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_greyscale(mRS, res, R.raw.greyscale);
- }
-
- public void runTest() {
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/GroupTest.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/GroupTest.java
deleted file mode 100644
index a7ceebe..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/GroupTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-import android.util.Log;
-
-public class GroupTest extends TestBase {
- private ScriptIntrinsicConvolve3x3 mConvolve;
- private ScriptIntrinsicColorMatrix mMatrix;
-
- private Allocation mScratchPixelsAllocation1;
- private ScriptGroup mGroup;
-
- private int mWidth;
- private int mHeight;
- private boolean mUseNative;
-
-
- public GroupTest(boolean useNative) {
- mUseNative = useNative;
- }
-
- public void createTest(android.content.res.Resources res) {
- mWidth = mInPixelsAllocation.getType().getX();
- mHeight = mInPixelsAllocation.getType().getY();
-
- mConvolve = ScriptIntrinsicConvolve3x3.create(mRS, Element.U8_4(mRS));
- mMatrix = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
-
- float f[] = new float[9];
- f[0] = 0.f; f[1] = -1.f; f[2] = 0.f;
- f[3] = -1.f; f[4] = 5.f; f[5] = -1.f;
- f[6] = 0.f; f[7] = -1.f; f[8] = 0.f;
- mConvolve.setCoefficients(f);
-
- Matrix4f m = new Matrix4f();
- m.set(1, 0, 0.2f);
- m.set(1, 1, 0.9f);
- m.set(1, 2, 0.2f);
- mMatrix.setColorMatrix(m);
-
- Type.Builder tb = new Type.Builder(mRS, Element.U8_4(mRS));
- tb.setX(mWidth);
- tb.setY(mHeight);
- Type connect = tb.create();
-
- if (mUseNative) {
- ScriptGroup.Builder b = new ScriptGroup.Builder(mRS);
- b.addKernel(mConvolve.getKernelID());
- b.addKernel(mMatrix.getKernelID());
- b.addConnection(connect, mConvolve.getKernelID(), mMatrix.getKernelID());
- mGroup = b.create();
- } else {
- mScratchPixelsAllocation1 = Allocation.createTyped(mRS, connect);
- }
- }
-
- public void runTest() {
- mConvolve.setInput(mInPixelsAllocation);
- if (mUseNative) {
- mGroup.setOutput(mMatrix.getKernelID(), mOutPixelsAllocation);
- mGroup.execute();
- } else {
- mConvolve.forEach(mScratchPixelsAllocation1);
- mMatrix.forEach(mScratchPixelsAllocation1, mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ImageProcessingActivity2.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ImageProcessingActivity2.java
deleted file mode 100644
index 4b0e2dd..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ImageProcessingActivity2.java
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.graphics.BitmapFactory;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.support.v8.renderscript.*;
-import android.view.SurfaceView;
-import android.view.SurfaceHolder;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.SeekBar;
-import android.widget.Spinner;
-import android.widget.TextView;
-import android.view.View;
-import android.util.Log;
-import java.lang.Math;
-
-import android.os.Environment;
-import android.app.Instrumentation;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-public class ImageProcessingActivity2 extends Activity
- implements SeekBar.OnSeekBarChangeListener {
- private final String TAG = "Img";
- public final String RESULT_FILE = "image_processing_result.csv";
-
- RenderScript mRS;
- Allocation mInPixelsAllocation;
- Allocation mInPixelsAllocation2;
- Allocation mOutPixelsAllocation;
-
- /**
- * Define enum type for test names
- */
- public enum TestName {
- // totally there are 38 test cases
- LEVELS_VEC3_RELAXED ("Levels Vec3 Relaxed"),
- LEVELS_VEC4_RELAXED ("Levels Vec4 Relaxed"),
- LEVELS_VEC3_FULL ("Levels Vec3 Full"),
- LEVELS_VEC4_FULL ("Levels Vec4 Full"),
- BLUR_RADIUS_25 ("Blur radius 25"),
- INTRINSIC_BLUE_RADIUS_25 ("Intrinsic Blur radius 25"),
- GREYSCALE ("Greyscale"),
- GRAIN ("Grain"),
- FISHEYE_FULL ("Fisheye Full"),
- FISHEYE_RELAXED ("Fisheye Relaxed"),
- FISHEYE_APPROXIMATE_FULL ("Fisheye Approximate Full"),
- FISHEYE_APPROXIMATE_RELAXED ("Fisheye Approximate Relaxed"),
- VIGNETTE_FULL ("Vignette Full"),
- VIGNETTE_RELAXED ("Vignette Relaxed"),
- VIGNETTE_APPROXIMATE_FULL ("Vignette Approximate Full"),
- VIGNETTE_APPROXIMATE_RELAXED ("Vignette Approximate Relaxed"),
- GROUP_TEST_EMULATED ("Group Test (emulated)"),
- GROUP_TEST_NATIVE ("Group Test (native)"),
- CONVOLVE_3X3 ("Convolve 3x3"),
- INTRINSICS_CONVOLVE_3X3 ("Intrinsics Convolve 3x3"),
- COLOR_MATRIX ("ColorMatrix"),
- INTRINSICS_COLOR_MATRIX ("Intrinsics ColorMatrix"),
- INTRINSICS_COLOR_MATRIX_GREY ("Intrinsics ColorMatrix Grey"),
- COPY ("Copy"),
- CROSS_PROCESS_USING_LUT ("CrossProcess (using LUT)"),
- CONVOLVE_5X5 ("Convolve 5x5"),
- INTRINSICS_CONVOLVE_5X5 ("Intrinsics Convolve 5x5"),
- MANDELBROT ("Mandelbrot"),
- INTRINSICS_BLEND ("Intrinsics Blend"),
- INTRINSICS_BLUR_25G ("Intrinsics Blur 25 uchar"),
- VIBRANCE ("Vibrance"),
- BW_FILTER ("BW Filter"),
- SHADOWS ("Shadows"),
- CONTRAST ("Contrast"),
- EXPOSURE ("Exposure"),
- WHITE_BALANCE ("White Balance"),
- COLOR_CUBE ("Color Cube"),
- COLOR_CUBE_3D_INTRINSIC ("Color Cube (3D LUT intrinsic)");
-
-
- private final String name;
-
- private TestName(String s) {
- name = s;
- }
-
- // return quoted string as displayed test name
- public String toString() {
- return name;
- }
- }
-
- Bitmap mBitmapIn;
- Bitmap mBitmapIn2;
- Bitmap mBitmapOut;
-
- private Spinner mSpinner;
- private SeekBar mBar1;
- private SeekBar mBar2;
- private SeekBar mBar3;
- private SeekBar mBar4;
- private SeekBar mBar5;
- private TextView mText1;
- private TextView mText2;
- private TextView mText3;
- private TextView mText4;
- private TextView mText5;
-
- private float mSaturation = 1.0f;
-
- private TextView mBenchmarkResult;
- private Spinner mTestSpinner;
-
- private SurfaceView mSurfaceView;
- private ImageView mDisplayView;
-
- private boolean mDoingBenchmark;
-
- private TestBase mTest;
- private int mRunCount;
-
- public void updateDisplay() {
- mTest.updateBitmap(mBitmapOut);
- mDisplayView.invalidate();
- }
-
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- if (fromUser) {
-
- if (seekBar == mBar1) {
- mTest.onBar1Changed(progress);
- } else if (seekBar == mBar2) {
- mTest.onBar2Changed(progress);
- } else if (seekBar == mBar3) {
- mTest.onBar3Changed(progress);
- } else if (seekBar == mBar4) {
- mTest.onBar4Changed(progress);
- } else if (seekBar == mBar5) {
- mTest.onBar5Changed(progress);
- }
-
- mTest.runTest();
- updateDisplay();
- }
- }
-
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
-
- public void onStopTrackingTouch(SeekBar seekBar) {
- }
-
- void setupBars() {
- mSpinner.setVisibility(View.VISIBLE);
- mTest.onSpinner1Setup(mSpinner);
-
- mBar1.setVisibility(View.VISIBLE);
- mText1.setVisibility(View.VISIBLE);
- mTest.onBar1Setup(mBar1, mText1);
-
- mBar2.setVisibility(View.VISIBLE);
- mText2.setVisibility(View.VISIBLE);
- mTest.onBar2Setup(mBar2, mText2);
-
- mBar3.setVisibility(View.VISIBLE);
- mText3.setVisibility(View.VISIBLE);
- mTest.onBar3Setup(mBar3, mText3);
-
- mBar4.setVisibility(View.VISIBLE);
- mText4.setVisibility(View.VISIBLE);
- mTest.onBar4Setup(mBar4, mText4);
-
- mBar5.setVisibility(View.VISIBLE);
- mText5.setVisibility(View.VISIBLE);
- mTest.onBar5Setup(mBar5, mText5);
- }
-
-
- void changeTest(TestName testName) {
- if (mTest != null) {
- mTest.destroy();
- }
- switch(testName) {
- case LEVELS_VEC3_RELAXED:
- mTest = new LevelsV4(false, false);
- break;
- case LEVELS_VEC4_RELAXED:
- mTest = new LevelsV4(false, true);
- break;
- case LEVELS_VEC3_FULL:
- mTest = new LevelsV4(true, false);
- break;
- case LEVELS_VEC4_FULL:
- mTest = new LevelsV4(true, true);
- break;
- case BLUR_RADIUS_25:
- mTest = new Blur25(false);
- break;
- case INTRINSIC_BLUE_RADIUS_25:
- mTest = new Blur25(true);
- break;
- case GREYSCALE:
- mTest = new Greyscale();
- break;
- case GRAIN:
- mTest = new Grain();
- break;
- case FISHEYE_FULL:
- mTest = new Fisheye(false, false);
- break;
- case FISHEYE_RELAXED:
- mTest = new Fisheye(false, true);
- break;
- case FISHEYE_APPROXIMATE_FULL:
- mTest = new Fisheye(true, false);
- break;
- case FISHEYE_APPROXIMATE_RELAXED:
- mTest = new Fisheye(true, true);
- break;
- case VIGNETTE_FULL:
- mTest = new Vignette(false, false);
- break;
- case VIGNETTE_RELAXED:
- mTest = new Vignette(false, true);
- break;
- case VIGNETTE_APPROXIMATE_FULL:
- mTest = new Vignette(true, false);
- break;
- case VIGNETTE_APPROXIMATE_RELAXED:
- mTest = new Vignette(true, true);
- break;
- case GROUP_TEST_EMULATED:
- mTest = new GroupTest(false);
- break;
- case GROUP_TEST_NATIVE:
- mTest = new GroupTest(true);
- break;
- case CONVOLVE_3X3:
- mTest = new Convolve3x3(false);
- break;
- case INTRINSICS_CONVOLVE_3X3:
- mTest = new Convolve3x3(true);
- break;
- case COLOR_MATRIX:
- mTest = new ColorMatrix(false, false);
- break;
- case INTRINSICS_COLOR_MATRIX:
- mTest = new ColorMatrix(true, false);
- break;
- case INTRINSICS_COLOR_MATRIX_GREY:
- mTest = new ColorMatrix(true, true);
- break;
- case COPY:
- mTest = new Copy();
- break;
- case CROSS_PROCESS_USING_LUT:
- mTest = new CrossProcess();
- break;
- case CONVOLVE_5X5:
- mTest = new Convolve5x5(false);
- break;
- case INTRINSICS_CONVOLVE_5X5:
- mTest = new Convolve5x5(true);
- break;
- case MANDELBROT:
- mTest = new Mandelbrot();
- break;
- case INTRINSICS_BLEND:
- mTest = new Blend();
- break;
- case INTRINSICS_BLUR_25G:
- mTest = new Blur25G();
- break;
- case VIBRANCE:
- mTest = new Vibrance();
- break;
- case BW_FILTER:
- mTest = new BWFilter();
- break;
- case SHADOWS:
- mTest = new Shadows();
- break;
- case CONTRAST:
- mTest = new Contrast();
- break;
- case EXPOSURE:
- mTest = new Exposure();
- break;
- case WHITE_BALANCE:
- mTest = new WhiteBalance();
- break;
- case COLOR_CUBE:
- mTest = new ColorCube(false);
- break;
- case COLOR_CUBE_3D_INTRINSIC:
- mTest = new ColorCube(true);
- break;
- }
-
- mTest.createBaseTest(this, mBitmapIn, mBitmapIn2, mBitmapOut);
- setupBars();
-
- mTest.runTest();
- updateDisplay();
- mBenchmarkResult.setText("Result: not run");
- }
-
- void setupTests() {
- mTestSpinner.setAdapter(new ArrayAdapter<TestName>(
- this, R.layout.spinner_layout, TestName.values()));
- }
-
- private AdapterView.OnItemSelectedListener mTestSpinnerListener =
- new AdapterView.OnItemSelectedListener() {
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
- changeTest(TestName.values()[pos]);
- }
-
- public void onNothingSelected(AdapterView parent) {
-
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- mBitmapIn = loadBitmap(R.drawable.img1600x1067);
- mBitmapIn2 = loadBitmap(R.drawable.img1600x1067b);
- mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(), mBitmapIn.getHeight(),
- mBitmapIn.getConfig());
-
- mSurfaceView = (SurfaceView) findViewById(R.id.surface);
-
- mDisplayView = (ImageView) findViewById(R.id.display);
- mDisplayView.setImageBitmap(mBitmapOut);
-
- mSpinner = (Spinner) findViewById(R.id.spinner1);
-
- mBar1 = (SeekBar) findViewById(R.id.slider1);
- mBar2 = (SeekBar) findViewById(R.id.slider2);
- mBar3 = (SeekBar) findViewById(R.id.slider3);
- mBar4 = (SeekBar) findViewById(R.id.slider4);
- mBar5 = (SeekBar) findViewById(R.id.slider5);
-
- mBar1.setOnSeekBarChangeListener(this);
- mBar2.setOnSeekBarChangeListener(this);
- mBar3.setOnSeekBarChangeListener(this);
- mBar4.setOnSeekBarChangeListener(this);
- mBar5.setOnSeekBarChangeListener(this);
-
- mText1 = (TextView) findViewById(R.id.slider1Text);
- mText2 = (TextView) findViewById(R.id.slider2Text);
- mText3 = (TextView) findViewById(R.id.slider3Text);
- mText4 = (TextView) findViewById(R.id.slider4Text);
- mText5 = (TextView) findViewById(R.id.slider5Text);
-
- mTestSpinner = (Spinner) findViewById(R.id.filterselection);
- mTestSpinner.setOnItemSelectedListener(mTestSpinnerListener);
-
- mBenchmarkResult = (TextView) findViewById(R.id.benchmarkText);
- mBenchmarkResult.setText("Result: not run");
-
-
- mRS = RenderScript.create(this);
- mInPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapIn);
- mInPixelsAllocation2 = Allocation.createFromBitmap(mRS, mBitmapIn2);
- mOutPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapOut);
-
-
- setupTests();
- changeTest(TestName.LEVELS_VEC3_RELAXED);
- }
-
-
- private Bitmap loadBitmap(int resource) {
- final BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- return BitmapFactory.decodeResource(getResources(), resource, options);
- }
-
- // button hook
- public void benchmark(View v) {
- float t = getBenchmark();
- //long javaTime = javaFilter();
- //mBenchmarkResult.setText("RS: " + t + " ms Java: " + javaTime + " ms");
- mBenchmarkResult.setText("Result: " + t + " ms");
- Log.v(TAG, "getBenchmark: Renderscript frame time core ms " + t);
- }
-
- public void benchmark_all(View v) {
- // write result into a file
- File externalStorage = Environment.getExternalStorageDirectory();
- if (!externalStorage.canWrite()) {
- Log.v(TAG, "sdcard is not writable");
- return;
- }
- File resultFile = new File(externalStorage, RESULT_FILE);
- //resultFile.setWritable(true, false);
- try {
- BufferedWriter rsWriter = new BufferedWriter(new FileWriter(resultFile));
- Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
- for (TestName tn: TestName.values()) {
- changeTest(tn);
- float t = getBenchmark();
- String s = new String("" + tn.toString() + ", " + t);
- rsWriter.write(s + "\n");
- Log.v(TAG, "Test " + s + "ms\n");
- }
- rsWriter.close();
- } catch (IOException e) {
- Log.v(TAG, "Unable to write result file " + e.getMessage());
- }
- changeTest(TestName.LEVELS_VEC3_RELAXED);
- }
-
- // For benchmark test
- public float getBenchmark() {
- mDoingBenchmark = true;
-
- mTest.setupBenchmark();
- long result = 0;
-
- //Log.v(TAG, "Warming");
- long t = java.lang.System.currentTimeMillis() + 250;
- do {
- mTest.runTest();
- mTest.finish();
- } while (t > java.lang.System.currentTimeMillis());
-
- //Log.v(TAG, "Benchmarking");
- int ct = 0;
- t = java.lang.System.currentTimeMillis();
- do {
- mTest.runTest();
- mTest.finish();
- ct++;
- } while ((t+1000) > java.lang.System.currentTimeMillis());
- t = java.lang.System.currentTimeMillis() - t;
- float ft = (float)t;
- ft /= ct;
-
- mTest.exitBenchmark();
- mDoingBenchmark = false;
-
- return ft;
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/LevelsV4.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/LevelsV4.java
deleted file mode 100644
index fbe3727..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/LevelsV4.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-
-public class LevelsV4 extends TestBase {
- private ScriptC_levels_relaxed mScriptR;
- private ScriptC_levels_full mScriptF;
- private float mInBlack = 0.0f;
- private float mOutBlack = 0.0f;
- private float mInWhite = 255.0f;
- private float mOutWhite = 255.0f;
- private float mSaturation = 1.0f;
-
- Matrix3f satMatrix = new Matrix3f();
- float mInWMinInB;
- float mOutWMinOutB;
- float mOverInWMinInB;
-
- boolean mUseFull;
- boolean mUseV4;
-
- LevelsV4(boolean useFull, boolean useV4) {
- mUseFull = useFull;
- mUseV4 = useV4;
- }
-
-
- private void setLevels() {
- mInWMinInB = mInWhite - mInBlack;
- mOutWMinOutB = mOutWhite - mOutBlack;
- mOverInWMinInB = 1.f / mInWMinInB;
-
- mScriptR.set_inBlack(mInBlack);
- mScriptR.set_outBlack(mOutBlack);
- mScriptR.set_inWMinInB(mInWMinInB);
- mScriptR.set_outWMinOutB(mOutWMinOutB);
- mScriptR.set_overInWMinInB(mOverInWMinInB);
- mScriptF.set_inBlack(mInBlack);
- mScriptF.set_outBlack(mOutBlack);
- mScriptF.set_inWMinInB(mInWMinInB);
- mScriptF.set_outWMinOutB(mOutWMinOutB);
- mScriptF.set_overInWMinInB(mOverInWMinInB);
- }
-
- private void setSaturation() {
- float rWeight = 0.299f;
- float gWeight = 0.587f;
- float bWeight = 0.114f;
- float oneMinusS = 1.0f - mSaturation;
-
- satMatrix.set(0, 0, oneMinusS * rWeight + mSaturation);
- satMatrix.set(0, 1, oneMinusS * rWeight);
- satMatrix.set(0, 2, oneMinusS * rWeight);
- satMatrix.set(1, 0, oneMinusS * gWeight);
- satMatrix.set(1, 1, oneMinusS * gWeight + mSaturation);
- satMatrix.set(1, 2, oneMinusS * gWeight);
- satMatrix.set(2, 0, oneMinusS * bWeight);
- satMatrix.set(2, 1, oneMinusS * bWeight);
- satMatrix.set(2, 2, oneMinusS * bWeight + mSaturation);
- mScriptR.set_colorMat(satMatrix);
- mScriptF.set_colorMat(satMatrix);
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- b.setProgress(50);
- t.setText("Saturation");
- return true;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(0);
- t.setText("In Black");
- return true;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(0);
- t.setText("Out Black");
- return true;
- }
- public boolean onBar4Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(128);
- t.setText("Out White");
- return true;
- }
- public boolean onBar5Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(128);
- t.setText("Out White");
- return true;
- }
-
- public void onBar1Changed(int progress) {
- mSaturation = (float)progress / 50.0f;
- setSaturation();
- }
- public void onBar2Changed(int progress) {
- mInBlack = (float)progress;
- setLevels();
- }
- public void onBar3Changed(int progress) {
- mOutBlack = (float)progress;
- setLevels();
- }
- public void onBar4Changed(int progress) {
- mInWhite = (float)progress + 127.0f;
- setLevels();
- }
- public void onBar5Changed(int progress) {
- mOutWhite = (float)progress + 127.0f;
- setLevels();
- }
-
- public void createTest(android.content.res.Resources res) {
- mScriptR = new ScriptC_levels_relaxed(mRS, res, R.raw.levels_relaxed);
- mScriptF = new ScriptC_levels_full(mRS, res, R.raw.levels_full);
- setSaturation();
- setLevels();
- }
-
- public void runTest() {
- if (mUseFull) {
- if (mUseV4) {
- mScriptF.forEach_root4(mInPixelsAllocation, mOutPixelsAllocation);
- } else {
- mScriptF.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
- } else {
- if (mUseV4) {
- mScriptR.forEach_root4(mInPixelsAllocation, mOutPixelsAllocation);
- } else {
- mScriptR.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
- }
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Mandelbrot.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Mandelbrot.java
deleted file mode 100644
index 1780587..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Mandelbrot.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Mandelbrot extends TestBase {
- private ScriptC_mandelbrot mScript;
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Iterations");
- b.setProgress(0);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- int iters = progress * 3 + 50;
- mScript.set_gMaxIteration(iters);
- }
-
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Lower Bound: X");
- b.setProgress(0);
- return true;
- }
-
- public void onBar2Changed(int progress) {
- float scaleFactor = mScript.get_scaleFactor();
- // allow viewport to be moved by 2x scale factor
- float lowerBoundX = -2.f + ((progress / scaleFactor) / 50.f);
- mScript.set_lowerBoundX(lowerBoundX);
- }
-
- public boolean onBar3Setup(SeekBar b, TextView t) {
- t.setText("Lower Bound: Y");
- b.setProgress(0);
- return true;
- }
-
- public void onBar3Changed(int progress) {
- float scaleFactor = mScript.get_scaleFactor();
- // allow viewport to be moved by 2x scale factor
- float lowerBoundY = -2.f + ((progress / scaleFactor) / 50.f);
- mScript.set_lowerBoundY(lowerBoundY);
- }
-
- public boolean onBar4Setup(SeekBar b, TextView t) {
- t.setText("Scale Factor");
- b.setProgress(0);
- return true;
- }
-
- public void onBar4Changed(int progress) {
- float scaleFactor = 4.f - (3.96f * (progress / 100.f));
- mScript.set_scaleFactor(scaleFactor);
- }
-
- public void createTest(android.content.res.Resources res) {
- int width = mOutPixelsAllocation.getType().getX();
- int height = mOutPixelsAllocation.getType().getY();
-
- mScript = new ScriptC_mandelbrot(mRS, res, R.raw.mandelbrot);
- mScript.set_gDimX(width);
- mScript.set_gDimY(height);
- mScript.set_gMaxIteration(50);
- }
-
- public void runTest() {
- mScript.forEach_root(mOutPixelsAllocation);
- mRS.finish();
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Shadows.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Shadows.java
deleted file mode 100644
index 353c56d..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Shadows.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-
-public class Shadows extends TestBase {
- private ScriptC_shadows mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_shadows(mRS);
- }
-
- public void runTest() {
- mScript.invoke_prepareShadows(50.f);
- mScript.forEach_shadowsKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/TestBase.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/TestBase.java
deleted file mode 100644
index eeabc73..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/TestBase.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.graphics.BitmapFactory;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.support.v8.renderscript.*;
-import android.view.SurfaceView;
-import android.view.SurfaceHolder;
-import android.widget.ImageView;
-import android.widget.SeekBar;
-import android.widget.TextView;
-import android.view.View;
-import android.util.Log;
-import java.lang.Math;
-import android.widget.Spinner;
-
-public class TestBase {
- protected final String TAG = "Img";
-
- protected RenderScript mRS;
- protected Allocation mInPixelsAllocation;
- protected Allocation mInPixelsAllocation2;
- protected Allocation mOutPixelsAllocation;
-
- protected ImageProcessingActivity2 act;
-
- // Override to use UI elements
- public void onBar1Changed(int progress) {
- }
- public void onBar2Changed(int progress) {
- }
- public void onBar3Changed(int progress) {
- }
- public void onBar4Changed(int progress) {
- }
- public void onBar5Changed(int progress) {
- }
-
- // Override to use UI elements
- // Unused bars will be hidden.
- public boolean onBar1Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar4Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar5Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
-
- public boolean onSpinner1Setup(Spinner s) {
- s.setVisibility(View.INVISIBLE);
- return false;
- }
-
- public final void createBaseTest(ImageProcessingActivity2 ipact, Bitmap b, Bitmap b2, Bitmap outb) {
- act = ipact;
- mRS = ipact.mRS;
-
- mInPixelsAllocation = ipact.mInPixelsAllocation;
- mInPixelsAllocation2 = ipact.mInPixelsAllocation2;
- mOutPixelsAllocation = ipact.mOutPixelsAllocation;
-
- createTest(act.getResources());
- }
-
- // Must override
- public void createTest(android.content.res.Resources res) {
- }
-
- // Must override
- public void runTest() {
- }
-
- public void finish() {
- mRS.finish();
- }
-
- public void destroy() {
- }
-
- public void updateBitmap(Bitmap b) {
- mOutPixelsAllocation.copyTo(b);
- }
-
- // Override to configure specific benchmark config.
- public void setupBenchmark() {
- }
-
- // Override to reset after benchmark.
- public void exitBenchmark() {
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Vibrance.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Vibrance.java
deleted file mode 100644
index 37c0aa7..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Vibrance.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-public class Vibrance extends TestBase {
- private ScriptC_vibrance mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_vibrance(mRS);
- }
-
- public void runTest() {
- mScript.set_vibrance(50.f);
- mScript.invoke_prepareVibrance();
- mScript.forEach_vibranceKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Vignette.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Vignette.java
deleted file mode 100644
index 9f6d34d..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Vignette.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Vignette extends TestBase {
- private ScriptC_vignette_full mScript_full = null;
- private ScriptC_vignette_relaxed mScript_relaxed = null;
- private ScriptC_vignette_approx_full mScript_approx_full = null;
- private ScriptC_vignette_approx_relaxed mScript_approx_relaxed = null;
- private final boolean approx;
- private final boolean relaxed;
- private float center_x = 0.5f;
- private float center_y = 0.5f;
- private float scale = 0.5f;
- private float shade = 0.5f;
- private float slope = 20.0f;
-
- public Vignette(boolean approx, boolean relaxed) {
- this.approx = approx;
- this.relaxed = relaxed;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Scale");
- b.setMax(100);
- b.setProgress(25);
- return true;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Shade");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- t.setText("Slope");
- b.setMax(100);
- b.setProgress(20);
- return true;
- }
- public boolean onBar4Setup(SeekBar b, TextView t) {
- t.setText("Shift center X");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
- public boolean onBar5Setup(SeekBar b, TextView t) {
- t.setText("Shift center Y");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- scale = progress / 50.0f;
- do_init();
- }
- public void onBar2Changed(int progress) {
- shade = progress / 100.0f;
- do_init();
- }
- public void onBar3Changed(int progress) {
- slope = (float)progress;
- do_init();
- }
- public void onBar4Changed(int progress) {
- center_x = progress / 100.0f;
- do_init();
- }
- public void onBar5Changed(int progress) {
- center_y = progress / 100.0f;
- do_init();
- }
-
- private void do_init() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale, shade, slope);
- else
- mScript_approx_full.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale, shade, slope);
- } else if (relaxed)
- mScript_relaxed.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale, shade, slope);
- else
- mScript_full.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale, shade, slope);
- }
-
- public void createTest(android.content.res.Resources res) {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed = new ScriptC_vignette_approx_relaxed(
- mRS, res, R.raw.vignette_approx_relaxed);
- else
- mScript_approx_full = new ScriptC_vignette_approx_full(
- mRS, res, R.raw.vignette_approx_full);
- } else if (relaxed)
- mScript_relaxed = new ScriptC_vignette_relaxed(mRS, res,
- R.raw.vignette_relaxed);
- else
- mScript_full = new ScriptC_vignette_full(mRS, res,
- R.raw.vignette_full);
- do_init();
- }
-
- public void runTest() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- else
- mScript_approx_full.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- } else if (relaxed)
- mScript_relaxed.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- else
- mScript_full.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/WhiteBalance.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/WhiteBalance.java
deleted file mode 100644
index 658e3b1..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/WhiteBalance.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.image2;
-
-import java.lang.Math;
-
-import android.support.v8.renderscript.*;
-
-public class WhiteBalance extends TestBase {
- private ScriptC_wbalance mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_wbalance(mRS);
- }
-
- public void runTest() {
- mScript.set_histogramSource(mInPixelsAllocation);
- mScript.set_histogramWidth(mInPixelsAllocation.getType().getX());
- mScript.set_histogramHeight(mInPixelsAllocation.getType().getY());
- mScript.invoke_prepareWhiteBalance();
- mScript.forEach_whiteBalanceKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/blend.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/blend.rs
deleted file mode 100644
index 9ec1246..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/blend.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (C) 2011 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.
-
-#include "ip.rsh"
-
-uchar alpha = 0x0;
-
-void setImageAlpha(uchar4 *v_out, uint32_t x, uint32_t y) {
- v_out->rgba = convert_uchar4((convert_uint4(v_out->rgba) * alpha) >> (uint4)8);
- v_out->a = alpha;
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/bwfilter.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/bwfilter.rs
deleted file mode 100644
index e706d44..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/bwfilter.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-//#pragma rs_fp_relaxed
-
-static float sr = 0.f;
-static float sg = 0.f;
-static float sb = 0.f;
-
-void prepareBwFilter(uint32_t rw, uint32_t gw, uint32_t bw) {
-
- sr = rw;
- sg = gw;
- sb = bw;
-
- float imageMin = min(sg,sb);
- imageMin = fmin(sr,imageMin);
- float imageMax = max(sg,sb);
- imageMax = fmax(sr,imageMax);
- float avg = (imageMin + imageMax)/2;
- sb /= avg;
- sg /= avg;
- sr /= avg;
-
-}
-
-void bwFilterKernel(const uchar4 *in, uchar4 *out) {
- float r = in->r * sr;
- float g = in->g * sg;
- float b = in->b * sb;
- float localMin, localMax, avg;
- localMin = fmin(g,b);
- localMin = fmin(r,localMin);
- localMax = fmax(g,b);
- localMax = fmax(r,localMax);
- avg = (localMin+localMax) * 0.5f;
- out->r = out->g = out->b = rsClamp(avg, 0, 255);
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/colorcube.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/colorcube.rs
deleted file mode 100644
index 4f1e73e..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/colorcube.rs
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-#pragma rs_fp_relaxed
-
-
-static rs_allocation gCube;
-static int4 gDims;
-static int4 gCoordMul;
-
-
-void setCube(rs_allocation c) {
- gCube = c;
- gDims.x = rsAllocationGetDimX(gCube);
- gDims.y = rsAllocationGetDimY(gCube);
- gDims.z = rsAllocationGetDimZ(gCube);
- gDims.w = 0;
-
- float4 m = (float4)(1.f / 255.f) * convert_float4(gDims - 1);
- gCoordMul = convert_int4(m * (float4)0x10000);
-
- rsDebug("dims", gDims);
- rsDebug("gCoordMul", gCoordMul);
-}
-
-void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
- //rsDebug("root", in);
-
- int4 baseCoord = convert_int4(*in) * gCoordMul;
- int4 coord1 = baseCoord >> (int4)16;
- int4 coord2 = min(coord1 + 1, gDims - 1);
-
- int4 weight2 = baseCoord & 0xffff;
- int4 weight1 = (int4)0x10000 - weight2;
-
- uint4 v000 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord1.z));
- uint4 v100 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord1.z));
- uint4 v010 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord1.z));
- uint4 v110 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord1.z));
- uint4 v001 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord2.z));
- uint4 v101 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord2.z));
- uint4 v011 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord2.z));
- uint4 v111 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord2.z));
-
- uint4 yz00 = ((v000 * weight1.x) + (v100 * weight2.x)) >> (int4)8;
- uint4 yz10 = ((v010 * weight1.x) + (v110 * weight2.x)) >> (int4)8;
- uint4 yz01 = ((v001 * weight1.x) + (v101 * weight2.x)) >> (int4)8;
- uint4 yz11 = ((v011 * weight1.x) + (v111 * weight2.x)) >> (int4)8;
-
- uint4 z0 = ((yz00 * weight1.y) + (yz10 * weight2.y)) >> (int4)16;
- uint4 z1 = ((yz01 * weight1.y) + (yz11 * weight2.y)) >> (int4)16;
-
- uint4 v = ((z0 * weight1.z) + (z1 * weight2.z)) >> (int4)16;
- uint4 v2 = (v + 0x7f) >> (int4)8;
-
- *out = convert_uchar4(v2);
- out->a = 0xff;
-
- #if 0
- if (in->r != out->r) {
- rsDebug("dr", in->r - out->r);
- //rsDebug("in", convert_int4(*in));
- //rsDebug("coord1", coord1);
- //rsDebug("coord2", coord2);
- //rsDebug("weight1", weight1);
- //rsDebug("weight2", weight2);
- //rsDebug("yz00", yz00);
- //rsDebug("z0", z0);
- //rsDebug("v", v);
- //rsDebug("v2", v2);
- //rsDebug("out", convert_int4(*out));
- }
- #endif
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/colormatrix.fs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/colormatrix.fs
deleted file mode 100644
index 86fb248..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/colormatrix.fs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-static rs_matrix4x4 Mat;
-
-void init() {
- rsMatrixLoadIdentity(&Mat);
-}
-
-void setMatrix(rs_matrix4x4 m) {
- Mat = m;
-}
-
-uchar4 __attribute__((kernel)) root(uchar4 in) {
- float4 f = convert_float4(in);
- f = rsMatrixMultiply(&Mat, f);
- f = clamp(f, 0.f, 255.f);
- return convert_uchar4(f);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/contrast.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/contrast.rs
deleted file mode 100644
index d3743d3..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/contrast.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-static float brightM = 0.f;
-static float brightC = 0.f;
-
-void setBright(float v) {
- brightM = pow(2.f, v / 100.f);
- brightC = 127.f - brightM * 127.f;
-}
-
-void contrast(const uchar4 *in, uchar4 *out)
-{
-#if 0
- out->r = rsClamp((int)(brightM * in->r + brightC), 0, 255);
- out->g = rsClamp((int)(brightM * in->g + brightC), 0, 255);
- out->b = rsClamp((int)(brightM * in->b + brightC), 0, 255);
-#else
- float3 v = convert_float3(in->rgb) * brightM + brightC;
- out->rgb = convert_uchar3(clamp(v, 0.f, 255.f));
-#endif
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/convolve5x5.fs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/convolve5x5.fs
deleted file mode 100644
index 922a593..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/convolve5x5.fs
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-int32_t gWidth;
-int32_t gHeight;
-rs_allocation gIn;
-
-float gCoeffs[25];
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- uint32_t x0 = max((int32_t)x-2, 0);
- uint32_t x1 = max((int32_t)x-1, 0);
- uint32_t x2 = x;
- uint32_t x3 = min((int32_t)x+1, gWidth-1);
- uint32_t x4 = min((int32_t)x+2, gWidth-1);
-
- uint32_t y0 = max((int32_t)y-2, 0);
- uint32_t y1 = max((int32_t)y-1, 0);
- uint32_t y2 = y;
- uint32_t y3 = min((int32_t)y+1, gHeight-1);
- uint32_t y4 = min((int32_t)y+2, gHeight-1);
-
- float4 p0 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y0)) * gCoeffs[0]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y0)) * gCoeffs[1]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y0)) * gCoeffs[2]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y0)) * gCoeffs[3]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y0)) * gCoeffs[4];
-
- float4 p1 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y1)) * gCoeffs[5]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y1)) * gCoeffs[6]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y1)) * gCoeffs[7]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y1)) * gCoeffs[8]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y1)) * gCoeffs[9];
-
- float4 p2 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y2)) * gCoeffs[10]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y2)) * gCoeffs[11]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y2)) * gCoeffs[12]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y2)) * gCoeffs[13]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y2)) * gCoeffs[14];
-
- float4 p3 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y3)) * gCoeffs[15]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y3)) * gCoeffs[16]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y3)) * gCoeffs[17]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y3)) * gCoeffs[18]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y3)) * gCoeffs[19];
-
- float4 p4 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y4)) * gCoeffs[20]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y4)) * gCoeffs[21]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y4)) * gCoeffs[22]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y4)) * gCoeffs[23]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y4)) * gCoeffs[24];
-
- p0 = clamp(p0 + p1 + p2 + p3 + p4, 0.f, 255.f);
- return convert_uchar4(p0);
-}
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/copy.fs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/copy.fs
deleted file mode 100644
index 6595874..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/copy.fs
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-uchar4 __attribute__((kernel)) root(uchar4 v_in) {
- return v_in;
-}
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/exposure.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/exposure.rs
deleted file mode 100644
index 0f05cb9..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/exposure.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-static float bright = 0.f;
-
-void setBright(float v) {
- bright = 255.f / (255.f - v);
-}
-
-void exposure(const uchar4 *in, uchar4 *out)
-{
- out->r = rsClamp((int)(bright * in->r), 0, 255);
- out->g = rsClamp((int)(bright * in->g), 0, 255);
- out->b = rsClamp((int)(bright * in->b), 0, 255);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye.rsh b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye.rsh
deleted file mode 100644
index 2eacb7d..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye.rsh
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-rs_allocation in_alloc;
-rs_sampler sampler;
-
-static float2 center, neg_center, inv_dimensions, axis_scale;
-static float alpha, radius2, factor;
-
-void init_filter(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y, float k) {
- center.x = center_x;
- center.y = center_y;
- neg_center = -center;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
- alpha = k * 2.0f + 0.75f;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float bound2 = 0.25f * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y);
- const float bound = sqrt(bound2);
- const float radius = 1.15f * bound;
- radius2 = radius*radius;
- const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2));
- factor = bound / max_radian;
-}
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float2 scaledCoord = axis_scale * coord;
- const float dist2 = scaledCoord.x*scaledCoord.x + scaledCoord.y*scaledCoord.y;
- const float inv_dist = rsqrt(dist2);
- const float radian = M_PI_2 - atan((alpha * sqrt(radius2 - dist2)) * inv_dist);
- const float scalar = radian * factor * inv_dist;
- const float2 new_coord = mad(coord, scalar, center);
- const float4 fout = rsSample(in_alloc, sampler, new_coord);
- return rsPackColorTo8888(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx.rsh b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx.rsh
deleted file mode 100644
index fcf0a3d..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx.rsh
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-rs_allocation in_alloc;
-rs_sampler sampler;
-
-static float2 center, neg_center, inv_dimensions, axis_scale;
-static float alpha, radius2, factor;
-
-void init_filter(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y, float k) {
- center.x = center_x;
- center.y = center_y;
- neg_center = -center;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
- alpha = k * 2.0f + 0.75f;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float bound2 = 0.25f * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y);
- const float bound = sqrt(bound2);
- const float radius = 1.15f * bound;
- radius2 = radius*radius;
- const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2));
- factor = bound / max_radian;
-}
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float2 scaledCoord = axis_scale * coord;
- const float dist2 = scaledCoord.x*scaledCoord.x + scaledCoord.y*scaledCoord.y;
- const float inv_dist = half_rsqrt(dist2);
- const float radian = M_PI_2 - atan((alpha * half_sqrt(radius2 - dist2)) * inv_dist);
- const float scalar = radian * factor * inv_dist;
- const float2 new_coord = mad(coord, scalar, center);
- const float4 fout = rsSample(in_alloc, sampler, new_coord);
- return rsPackColorTo8888(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx_full.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx_full.rs
deleted file mode 100644
index ed69ff4..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx_relaxed.fs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx_relaxed.fs
deleted file mode 100644
index ed69ff4..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_full.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_full.rs
deleted file mode 100644
index f986b5d..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_relaxed.fs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_relaxed.fs
deleted file mode 100644
index f986b5d..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/grain.fs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/grain.fs
deleted file mode 100644
index 2e62cd7..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/grain.fs
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-uchar __attribute__((kernel)) genRand() {
- return (uchar)rsRand(0xff);
-}
-
-/*
- * Convolution matrix of distance 2 with fixed point of 'kShiftBits' bits
- * shifted. Thus the sum of this matrix should be 'kShiftValue'. Entries of
- * small values are not calculated to gain efficiency.
- * The order ot pixels represented in this matrix is:
- * 1 2 3
- * 4 0 5
- * 6 7 8
- * and the matrix should be: {230, 56, 114, 56, 114, 114, 56, 114, 56}.
- * However, since most of the valus are identical, we only use the first three
- * entries and the entries corresponding to the pixels is:
- * 1 2 1
- * 2 0 2
- * 1 2 1
- */
-
-int32_t gWMask;
-int32_t gHMask;
-
-rs_allocation gBlendSource;
-uchar __attribute__((kernel)) blend9(uint32_t x, uint32_t y) {
- uint32_t x1 = (x-1) & gWMask;
- uint32_t x2 = (x+1) & gWMask;
- uint32_t y1 = (y-1) & gHMask;
- uint32_t y2 = (y+1) & gHMask;
-
- uint p00 = 56 * rsGetElementAt_uchar(gBlendSource, x1, y1);
- uint p01 = 114 * rsGetElementAt_uchar(gBlendSource, x, y1);
- uint p02 = 56 * rsGetElementAt_uchar(gBlendSource, x2, y1);
- uint p10 = 114 * rsGetElementAt_uchar(gBlendSource, x1, y);
- uint p11 = 230 * rsGetElementAt_uchar(gBlendSource, x, y);
- uint p12 = 114 * rsGetElementAt_uchar(gBlendSource, x2, y);
- uint p20 = 56 * rsGetElementAt_uchar(gBlendSource, x1, y2);
- uint p21 = 114 * rsGetElementAt_uchar(gBlendSource, x, y2);
- uint p22 = 56 * rsGetElementAt_uchar(gBlendSource, x2, y2);
-
- p00 += p01;
- p02 += p10;
- p11 += p12;
- p20 += p21;
-
- p22 += p00;
- p02 += p11;
-
- p20 += p22;
- p20 += p02;
-
- p20 = min(p20 >> 10, (uint)255);
- return (uchar)p20;
-}
-
-float gNoiseStrength;
-
-rs_allocation gNoise;
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- float4 ip = convert_float4(in);
- float pnoise = (float) rsGetElementAt_uchar(gNoise, x & gWMask, y & gHMask);
-
- float energy_level = ip.r + ip.g + ip.b;
- float energy_mask = (28.f - sqrt(energy_level)) * 0.03571f;
- pnoise = (pnoise - 128.f) * energy_mask;
-
- ip += pnoise * gNoiseStrength;
- ip = clamp(ip, 0.f, 255.f);
-
- uchar4 p = convert_uchar4(ip);
- p.a = 0xff;
- return p;
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/greyscale.fs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/greyscale.fs
deleted file mode 100644
index 4e13072..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/greyscale.fs
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
-
-uchar4 __attribute__((kernel)) root(uchar4 v_in) {
- float4 f4 = rsUnpackColor8888(v_in);
-
- float3 mono = dot(f4.rgb, gMonoMult);
- return rsPackColorTo8888(mono);
-}
-
-uchar __attribute__((kernel)) toU8(uchar4 v_in) {
- float4 f4 = convert_float4(v_in);
- return (uchar)dot(f4.rgb, gMonoMult);
-}
-
-uchar4 __attribute__((kernel)) toU8_4(uchar v_in) {
- return (uchar4)v_in;
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ip.rsh b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ip.rsh
deleted file mode 100644
index 34e213c..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ip.rsh
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#pragma version(1)
-#pragma rs java_package_name(com.android.rs.image2)
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ip2_convolve3x3.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ip2_convolve3x3.rs
deleted file mode 100644
index 177e86e..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ip2_convolve3x3.rs
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-int32_t gWidth;
-int32_t gHeight;
-rs_allocation gIn;
-
-float gCoeffs[9];
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- uint32_t x1 = min((int32_t)x+1, gWidth-1);
- uint32_t x2 = max((int32_t)x-1, 0);
- uint32_t y1 = min((int32_t)y+1, gHeight-1);
- uint32_t y2 = max((int32_t)y-1, 0);
-
- float4 p00 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y1));
- float4 p01 = convert_float4(rsGetElementAt_uchar4(gIn, x, y1));
- float4 p02 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y1));
- float4 p10 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y));
- float4 p11 = convert_float4(rsGetElementAt_uchar4(gIn, x, y));
- float4 p12 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y));
- float4 p20 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y2));
- float4 p21 = convert_float4(rsGetElementAt_uchar4(gIn, x, y2));
- float4 p22 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y2));
- p00 *= gCoeffs[0];
- p01 *= gCoeffs[1];
- p02 *= gCoeffs[2];
- p10 *= gCoeffs[3];
- p11 *= gCoeffs[4];
- p12 *= gCoeffs[5];
- p20 *= gCoeffs[6];
- p21 *= gCoeffs[7];
- p22 *= gCoeffs[8];
-
- p00 += p01;
- p02 += p10;
- p11 += p12;
- p20 += p21;
-
- p22 += p00;
- p02 += p11;
-
- p20 += p22;
- p20 += p02;
-
- p20 = clamp(p20, 0.f, 255.f);
- return convert_uchar4(p20);
-}
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels.rsh b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels.rsh
deleted file mode 100644
index e289906..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels.rsh
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-float inBlack;
-float outBlack;
-float inWMinInB;
-float outWMinOutB;
-float overInWMinInB;
-rs_matrix3x3 colorMat;
-
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- uchar4 out;
- float3 pixel = convert_float4(in).rgb;
- pixel = rsMatrixMultiply(&colorMat, pixel);
- pixel = clamp(pixel, 0.f, 255.f);
- pixel = (pixel - inBlack) * overInWMinInB;
- pixel = pixel * outWMinOutB + outBlack;
- pixel = clamp(pixel, 0.f, 255.f);
- out.xyz = convert_uchar3(pixel);
- out.w = 0xff;
- return out;
-}
-
-uchar4 __attribute__((kernel)) root4(uchar4 in, uint32_t x, uint32_t y) {
- float4 pixel = convert_float4(in);
- pixel.rgb = rsMatrixMultiply(&colorMat, pixel.rgb);
- pixel = clamp(pixel, 0.f, 255.f);
- pixel = (pixel - inBlack) * overInWMinInB;
- pixel = pixel * outWMinOutB + outBlack;
- pixel = clamp(pixel, 0.f, 255.f);
- return convert_uchar4(pixel);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels_full.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels_full.rs
deleted file mode 100644
index 28596ba..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "levels.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels_relaxed.fs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels_relaxed.fs
deleted file mode 100644
index 28596ba..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "levels.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/mandelbrot.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/mandelbrot.rs
deleted file mode 100644
index de0bd00..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/mandelbrot.rs
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (C) 2011 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.
-
-#include "ip.rsh"
-
-uint32_t gMaxIteration = 500;
-uint32_t gDimX = 1024;
-uint32_t gDimY = 1024;
-
-float lowerBoundX = -2.f;
-float lowerBoundY = -2.f;
-float scaleFactor = 4.f;
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- float2 p;
- p.x = lowerBoundX + ((float)x / gDimX) * scaleFactor;
- p.y = lowerBoundY + ((float)y / gDimY) * scaleFactor;
-
- float2 t = 0;
- float2 t2 = t * t;
- int iter = 0;
- while((t2.x + t2.y < 4.f) && (iter < gMaxIteration)) {
- float xtemp = t2.x - t2.y + p.x;
- t.y = 2 * t.x * t.y + p.y;
- t.x = xtemp;
- iter++;
- t2 = t * t;
- }
-
- if(iter >= gMaxIteration) {
- // write a non-transparent black pixel
- return (uchar4){0, 0, 0, 0xff};
- } else {
- float mi3 = gMaxIteration / 3.f;
- if (iter <= (gMaxIteration / 3))
- return (uchar4){0xff * (iter / mi3), 0, 0, 0xff};
- else if (iter <= (((gMaxIteration / 3) * 2)))
- return (uchar4){0xff - (0xff * ((iter - mi3) / mi3)),
- (0xff * ((iter - mi3) / mi3)), 0, 0xff};
- else
- return (uchar4){0, 0xff - (0xff * ((iter - (mi3 * 2)) / mi3)),
- (0xff * ((iter - (mi3 * 2)) / mi3)), 0xff};
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/shadows.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/shadows.rs
deleted file mode 100644
index f6c149d..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/shadows.rs
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-//#pragma rs_fp_relaxed
-
-static double shadowFilterMap[] = {
- -0.00591, 0.0001,
- 1.16488, 0.01668,
- -0.18027, -0.06791,
- -0.12625, 0.09001,
- 0.15065, -0.03897
-};
-
-static double poly[] = {
- 0., 0.,
- 0., 0.,
- 0.
-};
-
-static const int ABITS = 4;
-static const int HSCALE = 256;
-static const int k1=255 << ABITS;
-static const int k2=HSCALE << ABITS;
-
-static double fastevalPoly(double *poly,int n, double x){
-
- double f =x;
- double sum = poly[0]+poly[1]*f;
- int i;
- for (i = 2; i < n; i++) {
- f*=x;
- sum += poly[i]*f;
- }
- return sum;
-}
-
-static ushort3 rgb2hsv( uchar4 rgb)
-{
- int iMin,iMax,chroma;
-
- int ri = rgb.r;
- int gi = rgb.g;
- int bi = rgb.b;
- short rv,rs,rh;
-
- if (ri > gi) {
- iMax = max (ri, bi);
- iMin = min (gi, bi);
- } else {
- iMax = max (gi, bi);
- iMin = min (ri, bi);
- }
-
- chroma = iMax - iMin;
- // set value
- rv = (short)( iMax << ABITS);
-
- // set saturation
- if (rv == 0)
- rs = 0;
- else
- rs = (short)((k1*chroma)/iMax);
-
- // set hue
- if (rs == 0)
- rh = 0;
- else {
- if ( ri == iMax ) {
- rh = (short)( (k2*(6*chroma+gi - bi))/(6*chroma));
- if (rh >= k2) rh -= k2;
- } else if (gi == iMax)
- rh = (short)( (k2*(2*chroma+bi - ri ))/(6*chroma));
- else // (bi == iMax )
- rh = (short)( (k2*(4*chroma+ri - gi ))/(6*chroma));
- }
-
- ushort3 out;
- out.x = rv;
- out.y = rs;
- out.z = rh;
- return out;
-}
-
-static uchar4 hsv2rgb(ushort3 hsv)
-{
- int ABITS = 4;
- int HSCALE = 256;
- int m;
- int H,X,ih,is,iv;
- int k1=255<<ABITS;
- int k2=HSCALE<<ABITS;
- int k3=1<<(ABITS-1);
- int rr=0;
- int rg=0;
- int rb=0;
- short cv = hsv.x;
- short cs = hsv.y;
- short ch = hsv.z;
-
- // set chroma and min component value m
- //chroma = ( cv * cs )/k1;
- //m = cv - chroma;
- m = ((int)cv*(k1 - (int)cs ))/k1;
-
- // chroma == 0 <-> cs == 0 --> m=cv
- if (cs == 0) {
- rb = ( rg = ( rr =( cv >> ABITS) ));
- } else {
- ih=(int)ch;
- is=(int)cs;
- iv=(int)cv;
-
- H = (6*ih)/k2;
- X = ((iv*is)/k2)*(k2- abs(6*ih- 2*(H>>1)*k2 - k2)) ;
-
- // removing additional bits --> unit8
- X=( (X+iv*(k1 - is ))/k1 + k3 ) >> ABITS;
- m=m >> ABITS;
-
- // ( chroma + m ) --> cv ;
- cv=(short) (cv >> ABITS);
- switch (H) {
- case 0:
- rr = cv;
- rg = X;
- rb = m;
- break;
- case 1:
- rr = X;
- rg = cv;
- rb = m;
- break;
- case 2:
- rr = m;
- rg = cv;
- rb = X;
- break;
- case 3:
- rr = m;
- rg = X;
- rb = cv;
- break;
- case 4:
- rr = X;
- rg = m;
- rb = cv;
- break;
- case 5:
- rr = cv;
- rg = m ;
- rb = X;
- break;
- }
- }
-
- uchar4 rgb;
-
- rgb.r = rr;
- rgb.g = rg;
- rgb.b = rb;
-
- return rgb;
-}
-
-void prepareShadows(float scale) {
- double s = (scale>=0)?scale:scale/5;
- for (int i = 0; i < 5; i++) {
- poly[i] = fastevalPoly(shadowFilterMap+i*2,2 , s);
- }
-}
-
-void shadowsKernel(const uchar4 *in, uchar4 *out) {
- ushort3 hsv = rgb2hsv(*in);
- double v = (fastevalPoly(poly,5,hsv.x/4080.)*4080);
- if (v>4080) v = 4080;
- hsv.x = (unsigned short) ((v>0)?v:0);
- *out = hsv2rgb(hsv);
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/threshold.fs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/threshold.fs
deleted file mode 100644
index 0b2c2e8..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/threshold.fs
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#include "ip.rsh"
-
-
-int height;
-int width;
-static int radius;
-
-rs_allocation InPixel;
-rs_allocation ScratchPixel1;
-rs_allocation ScratchPixel2;
-
-const int MAX_RADIUS = 25;
-
-// Store our coefficients here
-static float gaussian[MAX_RADIUS * 2 + 1];
-
-void setRadius(int rad) {
- radius = rad;
- // Compute gaussian weights for the blur
- // e is the euler's number
- float e = 2.718281828459045f;
- float pi = 3.1415926535897932f;
- // g(x) = ( 1 / sqrt( 2 * pi ) * sigma) * e ^ ( -x^2 / 2 * sigma^2 )
- // x is of the form [-radius .. 0 .. radius]
- // and sigma varies with radius.
- // Based on some experimental radius values and sigma's
- // we approximately fit sigma = f(radius) as
- // sigma = radius * 0.4 + 0.6
- // The larger the radius gets, the more our gaussian blur
- // will resemble a box blur since with large sigma
- // the gaussian curve begins to lose its shape
- float sigma = 0.4f * (float)radius + 0.6f;
-
- // Now compute the coefficints
- // We will store some redundant values to save some math during
- // the blur calculations
- // precompute some values
- float coeff1 = 1.0f / (sqrt( 2.0f * pi ) * sigma);
- float coeff2 = - 1.0f / (2.0f * sigma * sigma);
-
- float normalizeFactor = 0.0f;
- float floatR = 0.0f;
- for (int r = -radius; r <= radius; r ++) {
- floatR = (float)r;
- gaussian[r + radius] = coeff1 * pow(e, floatR * floatR * coeff2);
- normalizeFactor += gaussian[r + radius];
- }
-
- //Now we need to normalize the weights because all our coefficients need to add up to one
- normalizeFactor = 1.0f / normalizeFactor;
- for (int r = -radius; r <= radius; r ++) {
- floatR = (float)r;
- gaussian[r + radius] *= normalizeFactor;
- }
-}
-
-float4 __attribute__((kernel)) copyIn(uchar4 in) {
- return convert_float4(in);
-}
-
-uchar4 __attribute__((kernel)) vert(uint32_t x, uint32_t y) {
- float3 blurredPixel = 0;
- int gi = 0;
- uchar4 out;
- if ((y > radius) && (y < (height - radius))) {
- for (int r = -radius; r <= radius; r ++) {
- float4 i = rsGetElementAt_float4(ScratchPixel2, x, y + r);
- blurredPixel += i.xyz * gaussian[gi++];
- }
- } else {
- for (int r = -radius; r <= radius; r ++) {
- int validH = rsClamp((int)y + r, (int)0, (int)(height - 1));
- float4 i = rsGetElementAt_float4(ScratchPixel2, x, validH);
- blurredPixel += i.xyz * gaussian[gi++];
- }
- }
-
- out.xyz = convert_uchar3(clamp(blurredPixel, 0.f, 255.f));
- out.w = 0xff;
- return out;
-}
-
-float4 __attribute__((kernel)) horz(uint32_t x, uint32_t y) {
- float4 blurredPixel = 0;
- int gi = 0;
- if ((x > radius) && (x < (width - radius))) {
- for (int r = -radius; r <= radius; r ++) {
- float4 i = rsGetElementAt_float4(ScratchPixel1, x + r, y);
- blurredPixel += i * gaussian[gi++];
- }
- } else {
- for (int r = -radius; r <= radius; r ++) {
- // Stepping left and right away from the pixel
- int validX = rsClamp((int)x + r, (int)0, (int)(width - 1));
- float4 i = rsGetElementAt_float4(ScratchPixel1, validX, y);
- blurredPixel += i * gaussian[gi++];
- }
- }
-
- return blurredPixel;
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vibrance.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vibrance.rs
deleted file mode 100644
index ad4de58..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vibrance.rs
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-float vibrance = 0.f;
-
-static const float Rf = 0.2999f;
-static const float Gf = 0.587f;
-static const float Bf = 0.114f;
-
-static float S = 0.f;
-static float MS = 0.f;
-static float Rt = 0.f;
-static float Gt = 0.f;
-static float Bt = 0.f;
-static float Vib = 0.f;
-
-void vibranceKernel(const uchar4 *in, uchar4 *out) {
-
- float R, G, B;
-
- int r = in->r;
- int g = in->g;
- int b = in->b;
- float red = (r-max(g, b))/256.f;
- float sx = (float)(Vib/(1+native_exp(-red*3)));
- S = sx+1;
- MS = 1.0f - S;
- Rt = Rf * MS;
- Gt = Gf * MS;
- Bt = Bf * MS;
- int t = (r + g) / 2;
- R = r;
- G = g;
- B = b;
-
- float Rc = R * (Rt + S) + G * Gt + B * Bt;
- float Gc = R * Rt + G * (Gt + S) + B * Bt;
- float Bc = R * Rt + G * Gt + B * (Bt + S);
-
- out->r = rsClamp(Rc, 0, 255);
- out->g = rsClamp(Gc, 0, 255);
- out->b = rsClamp(Bc, 0, 255);
-
-}
-
-void prepareVibrance() {
-
- Vib = vibrance/100.f;
- S = Vib + 1;
- MS = 1.0f - S;
- Rt = Rf * MS;
- Gt = Gf * MS;
- Bt = Bf * MS;
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette.rsh b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette.rsh
deleted file mode 100644
index 04ca1f1..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette.rsh
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-static float2 neg_center, axis_scale, inv_dimensions;
-static float sloped_neg_range, sloped_inv_max_dist, shade, opp_shade;
-
-void init_vignette(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y,
- float desired_scale, float desired_shade, float desired_slope) {
-
- neg_center.x = -center_x;
- neg_center.y = -center_y;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float max_dist = 0.5f * length(axis_scale);
- sloped_inv_max_dist = desired_slope * 1.f/max_dist;
-
- // Range needs to be between 1.3 to 0.6. When scale is zero then range is
- // 1.3 which means no vignette at all because the luminousity difference is
- // less than 1/256. Expect input scale to be between 0.0 and 1.0.
- const float neg_range = 0.7f*sqrt(desired_scale) - 1.3f;
- sloped_neg_range = exp(neg_range * desired_slope);
-
- shade = desired_shade;
- opp_shade = 1.f - desired_shade;
-}
-
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float4 fin = convert_float4(in);
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float sloped_dist_ratio = length(axis_scale * coord) * sloped_inv_max_dist;
- const float lumen = opp_shade + shade / ( 1.0f + sloped_neg_range * exp(sloped_dist_ratio) );
- float4 fout;
- fout.rgb = fin.rgb * lumen;
- fout.w = fin.w;
- return convert_uchar4(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx.rsh b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx.rsh
deleted file mode 100644
index 5668621..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx.rsh
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-static float2 neg_center, axis_scale, inv_dimensions;
-static float sloped_neg_range, sloped_inv_max_dist, shade, opp_shade;
-
-void init_vignette(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y,
- float desired_scale, float desired_shade, float desired_slope) {
-
- neg_center.x = -center_x;
- neg_center.y = -center_y;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float max_dist = 0.5f * length(axis_scale);
- sloped_inv_max_dist = desired_slope * 1.f/max_dist;
-
- // Range needs to be between 1.3 to 0.6. When scale is zero then range is
- // 1.3 which means no vignette at all because the luminousity difference is
- // less than 1/256. Expect input scale to be between 0.0 and 1.0.
- const float neg_range = 0.7f*sqrt(desired_scale) - 1.3f;
- sloped_neg_range = exp(neg_range * desired_slope);
-
- shade = desired_shade;
- opp_shade = 1.f - desired_shade;
-}
-
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float4 fin = convert_float4(in);
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float sloped_dist_ratio = fast_length(axis_scale * coord) * sloped_inv_max_dist;
- const float lumen = opp_shade + shade * half_recip(1.f + sloped_neg_range * native_exp(sloped_dist_ratio));
- float4 fout;
- fout.rgb = fin.rgb * lumen;
- fout.w = fin.w;
- return convert_uchar4(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx_full.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx_full.rs
deleted file mode 100644
index 00cbbc4..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx_relaxed.fs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx_relaxed.fs
deleted file mode 100644
index 00cbbc4..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_full.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_full.rs
deleted file mode 100644
index 8202c5c..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_relaxed.fs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_relaxed.fs
deleted file mode 100644
index 8202c5c..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/wbalance.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/wbalance.rs
deleted file mode 100644
index 6650671..0000000
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/wbalance.rs
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-//#pragma rs_fp_relaxed
-
-static int histR[256] = {0}, histG[256] = {0}, histB[256] = {0};
-
-rs_allocation histogramSource;
-uint32_t histogramHeight;
-uint32_t histogramWidth;
-
-static float scaleR;
-static float scaleG;
-static float scaleB;
-
-static uchar4 estimateWhite() {
-
- for (int i = 0; i < 256; i++) {
- histR[i] = 0; histG[i] = 0; histB[i] = 0;
- }
-
- for (uint32_t i = 0; i < histogramHeight; i++) {
- for (uint32_t j = 0; j < histogramWidth; j++) {
- uchar4 in = rsGetElementAt_uchar4(histogramSource, j, i);
- histR[in.r]++;
- histG[in.g]++;
- histB[in.b]++;
- }
- }
-
- int min_r = -1, min_g = -1, min_b = -1;
- int max_r = 0, max_g = 0, max_b = 0;
- int sum_r = 0, sum_g = 0, sum_b = 0;
-
- for (int i = 1; i < 255; i++) {
- int r = histR[i];
- int g = histG[i];
- int b = histB[i];
- sum_r += r;
- sum_g += g;
- sum_b += b;
-
- if (r>0){
- if (min_r < 0) min_r = i;
- max_r = i;
- }
- if (g>0){
- if (min_g < 0) min_g = i;
- max_g = i;
- }
- if (b>0){
- if (min_b < 0) min_b = i;
- max_b = i;
- }
- }
-
- int sum15r = 0, sum15g = 0, sum15b = 0;
- int count15r = 0, count15g = 0, count15b = 0;
- int tmp_r = 0, tmp_g = 0, tmp_b = 0;
-
- for (int i = 254; i >0; i--) {
- int r = histR[i];
- int g = histG[i];
- int b = histB[i];
- tmp_r += r;
- tmp_g += g;
- tmp_b += b;
-
- if ((tmp_r > sum_r/20) && (tmp_r < sum_r/5)) {
- sum15r += r*i;
- count15r += r;
- }
- if ((tmp_g > sum_g/20) && (tmp_g < sum_g/5)) {
- sum15g += g*i;
- count15g += g;
- }
- if ((tmp_b > sum_b/20) && (tmp_b < sum_b/5)) {
- sum15b += b*i;
- count15b += b;
- }
-
- }
-
- uchar4 out;
-
- if ((count15r>0) && (count15g>0) && (count15b>0) ){
- out.r = sum15r/count15r;
- out.g = sum15g/count15g;
- out.b = sum15b/count15b;
- }else {
- out.r = out.g = out.b = 255;
- }
-
- return out;
-
-}
-
-void prepareWhiteBalance() {
- uchar4 estimation = estimateWhite();
- int minimum = min(estimation.r, min(estimation.g, estimation.b));
- int maximum = max(estimation.r, max(estimation.g, estimation.b));
- float avg = (minimum + maximum) / 2.f;
-
- scaleR = avg/estimation.r;
- scaleG = avg/estimation.g;
- scaleB = avg/estimation.b;
-
-}
-
-static unsigned char contrastClamp(int c)
-{
- int N = 255;
- c &= ~(c >> 31);
- c -= N;
- c &= (c >> 31);
- c += N;
- return (unsigned char) c;
-}
-
-void whiteBalanceKernel(const uchar4 *in, uchar4 *out) {
- float Rc = in->r*scaleR;
- float Gc = in->g*scaleG;
- float Bc = in->b*scaleB;
-
- out->r = contrastClamp(Rc);
- out->g = contrastClamp(Gc);
- out->b = contrastClamp(Bc);
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/Android.mk b/tests/RenderScriptTests/ImageProcessing_jb/Android.mk
deleted file mode 100644
index 20d6be7..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/Android.mk
+++ /dev/null
@@ -1,29 +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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
- $(call all-renderscript-files-under, src)
-#LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript
-
-LOCAL_PACKAGE_NAME := ImageProcessingJB
-LOCAL_SDK_VERSION := 17
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/AndroidManifest.xml b/tests/RenderScriptTests/ImageProcessing_jb/AndroidManifest.xml
deleted file mode 100644
index b3fcfc4..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/AndroidManifest.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.rs.imagejb">
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-sdk android:minSdkVersion="11" />
- <application android:label="Image Processing JB"
- android:hardwareAccelerated="true">
- <activity android:name="ImageProcessingActivityJB">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/res/drawable-nodpi/img1600x1067.jpg b/tests/RenderScriptTests/ImageProcessing_jb/res/drawable-nodpi/img1600x1067.jpg
deleted file mode 100644
index 05d3ee2..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/res/drawable-nodpi/img1600x1067.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/res/drawable-nodpi/img1600x1067b.jpg b/tests/RenderScriptTests/ImageProcessing_jb/res/drawable-nodpi/img1600x1067b.jpg
deleted file mode 100644
index aed0781..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/res/drawable-nodpi/img1600x1067b.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/res/layout/main.xml b/tests/RenderScriptTests/ImageProcessing_jb/res/layout/main.xml
deleted file mode 100644
index f0a2b92..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/res/layout/main.xml
+++ /dev/null
@@ -1,139 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:id="@+id/toplevel">
- <SurfaceView
- android:id="@+id/surface"
- android:layout_width="1dip"
- android:layout_height="1dip" />
- <ScrollView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <ImageView
- android:id="@+id/display"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/benchmark"
- android:onClick="benchmark"/>
- <TextView
- android:id="@+id/benchmarkText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:text="@string/saturation"/>
- </LinearLayout>
- <Spinner
- android:id="@+id/filterselection"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
- <Spinner
- android:id="@+id/spinner1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider1Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/saturation"/>
- <SeekBar
- android:id="@+id/slider1"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider2Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/gamma"/>
- <SeekBar
- android:id="@+id/slider2"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider3Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:textSize="8pt"
- android:text="@string/out_white"/>
- <SeekBar
- android:id="@+id/slider3"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider4Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/in_white"/>
- <SeekBar
- android:id="@+id/slider4"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/slider5Text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/in_white"/>
- <SeekBar
- android:id="@+id/slider5"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/benchmark_all"
- android:onClick="benchmark_all"/>
- </LinearLayout>
- </ScrollView>
-</LinearLayout>
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/res/layout/spinner_layout.xml b/tests/RenderScriptTests/ImageProcessing_jb/res/layout/spinner_layout.xml
deleted file mode 100644
index 8196bbf..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/res/layout/spinner_layout.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 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.
--->
-
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:padding="10dp"
- android:textSize="16sp"
-/>
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/res/values/strings.xml b/tests/RenderScriptTests/ImageProcessing_jb/res/values/strings.xml
deleted file mode 100644
index a7dd165..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/res/values/strings.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2008 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.
-*/
--->
-
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- General -->
- <skip />
- <!--slider label -->
- <string name="blur_description">Blur Radius</string>
- <string name="in_white">In White</string>
- <string name="out_white">Out White</string>
- <string name="in_black">In Black</string>
- <string name="out_black">Out Black</string>
- <string name="gamma">Gamma</string>
- <string name="saturation">Saturation</string>
- <string name="benchmark">Benchmark</string>
- <string name="benchmark_all">Benchmark All</string>
-
-</resources>
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/BWFilter.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/BWFilter.java
deleted file mode 100644
index 4870ac4..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/BWFilter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-
-public class BWFilter extends TestBase {
- private ScriptC_bwfilter mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_bwfilter(mRS);
- }
-
- public void runTest() {
- mScript.invoke_prepareBwFilter(50, 50, 50);
- mScript.forEach_bwFilterKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Blend.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Blend.java
deleted file mode 100644
index 302dc31..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Blend.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-import java.lang.Short;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.ScriptGroup;
-import android.renderscript.ScriptIntrinsicBlend;
-import android.renderscript.Type;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.view.View;
-import android.widget.Spinner;
-
-public class Blend extends TestBase {
- private ScriptIntrinsicBlend mBlend;
- private ScriptC_blend mBlendHelper;
- private short image1Alpha = 128;
- private short image2Alpha = 128;
-
- String mIntrinsicNames[];
-
- private Allocation image1;
- private Allocation image2;
- private int currentIntrinsic = 0;
-
- private AdapterView.OnItemSelectedListener mIntrinsicSpinnerListener =
- new AdapterView.OnItemSelectedListener() {
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
- currentIntrinsic = pos;
- if (mRS != null) {
- runTest();
- act.updateDisplay();
- }
- }
-
- public void onNothingSelected(AdapterView parent) {
-
- }
- };
-
- public void createTest(android.content.res.Resources res) {
- mBlend = ScriptIntrinsicBlend.create(mRS, Element.U8_4(mRS));
- mBlendHelper = new ScriptC_blend(mRS);
- mBlendHelper.set_alpha((short)128);
-
- image1 = Allocation.createTyped(mRS, mInPixelsAllocation.getType());
- image2 = Allocation.createTyped(mRS, mInPixelsAllocation2.getType());
-
- mIntrinsicNames = new String[14];
- mIntrinsicNames[0] = "Source";
- mIntrinsicNames[1] = "Destination";
- mIntrinsicNames[2] = "Source Over";
- mIntrinsicNames[3] = "Destination Over";
- mIntrinsicNames[4] = "Source In";
- mIntrinsicNames[5] = "Destination In";
- mIntrinsicNames[6] = "Source Out";
- mIntrinsicNames[7] = "Destination Out";
- mIntrinsicNames[8] = "Source Atop";
- mIntrinsicNames[9] = "Destination Atop";
- mIntrinsicNames[10] = "XOR";
- mIntrinsicNames[11] = "Add";
- mIntrinsicNames[12] = "Subtract";
- mIntrinsicNames[13] = "Multiply";
- }
-
- public boolean onSpinner1Setup(Spinner s) {
- s.setAdapter(new ArrayAdapter<String>(
- act, R.layout.spinner_layout, mIntrinsicNames));
- s.setOnItemSelectedListener(mIntrinsicSpinnerListener);
- return true;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Image 1 Alpha");
- b.setMax(255);
- b.setProgress(image1Alpha);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- image1Alpha = (short)progress;
- }
-
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Image 2 Alpha");
- b.setMax(255);
- b.setProgress(image2Alpha);
- return true;
- }
-
- public void onBar2Changed(int progress) {
- image2Alpha = (short)progress;
- }
-
- public void runTest() {
- image1.copy2DRangeFrom(0, 0, mInPixelsAllocation.getType().getX(), mInPixelsAllocation.getType().getY(), mInPixelsAllocation, 0, 0);
- image2.copy2DRangeFrom(0, 0, mInPixelsAllocation2.getType().getX(), mInPixelsAllocation2.getType().getY(), mInPixelsAllocation2, 0, 0);
-
- mBlendHelper.set_alpha(image1Alpha);
- mBlendHelper.forEach_setImageAlpha(image1);
-
- mBlendHelper.set_alpha(image2Alpha);
- mBlendHelper.forEach_setImageAlpha(image2);
-
- switch (currentIntrinsic) {
- case 0:
- mBlend.forEachSrc(image1, image2);
- break;
- case 1:
- mBlend.forEachDst(image1, image2);
- break;
- case 2:
- mBlend.forEachSrcOver(image1, image2);
- break;
- case 3:
- mBlend.forEachDstOver(image1, image2);
- break;
- case 4:
- mBlend.forEachSrcIn(image1, image2);
- break;
- case 5:
- mBlend.forEachDstIn(image1, image2);
- break;
- case 6:
- mBlend.forEachSrcOut(image1, image2);
- break;
- case 7:
- mBlend.forEachDstOut(image1, image2);
- break;
- case 8:
- mBlend.forEachSrcAtop(image1, image2);
- break;
- case 9:
- mBlend.forEachDstAtop(image1, image2);
- break;
- case 10:
- mBlend.forEachXor(image1, image2);
- break;
- case 11:
- mBlend.forEachAdd(image1, image2);
- break;
- case 12:
- mBlend.forEachSubtract(image1, image2);
- break;
- case 13:
- mBlend.forEachMultiply(image1, image2);
- break;
- }
-
- mOutPixelsAllocation.copy2DRangeFrom(0, 0, image2.getType().getX(), image2.getType().getY(), image2, 0, 0);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Blur25.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Blur25.java
deleted file mode 100644
index 90acd00..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Blur25.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.ScriptIntrinsicBlur;
-import android.renderscript.Type;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Blur25 extends TestBase {
- private boolean mUseIntrinsic = false;
- private ScriptIntrinsicBlur mIntrinsic;
-
- private int MAX_RADIUS = 25;
- private ScriptC_threshold mScript;
- private float mRadius = MAX_RADIUS;
- private float mSaturation = 1.0f;
- private Allocation mScratchPixelsAllocation1;
- private Allocation mScratchPixelsAllocation2;
-
-
- public Blur25(boolean useIntrinsic) {
- mUseIntrinsic = useIntrinsic;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Radius");
- b.setProgress(100);
- return true;
- }
-
-
- public void onBar1Changed(int progress) {
- mRadius = ((float)progress) / 100.0f * MAX_RADIUS;
- if (mRadius <= 0.10f) {
- mRadius = 0.10f;
- }
- if (mUseIntrinsic) {
- mIntrinsic.setRadius(mRadius);
- } else {
- mScript.invoke_setRadius((int)mRadius);
- }
- }
-
-
- public void createTest(android.content.res.Resources res) {
- int width = mInPixelsAllocation.getType().getX();
- int height = mInPixelsAllocation.getType().getY();
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicBlur.create(mRS, Element.U8_4(mRS));
- mIntrinsic.setRadius(MAX_RADIUS);
- mIntrinsic.setInput(mInPixelsAllocation);
- } else {
-
- Type.Builder tb = new Type.Builder(mRS, Element.F32_4(mRS));
- tb.setX(width);
- tb.setY(height);
- mScratchPixelsAllocation1 = Allocation.createTyped(mRS, tb.create());
- mScratchPixelsAllocation2 = Allocation.createTyped(mRS, tb.create());
-
- mScript = new ScriptC_threshold(mRS, res, R.raw.threshold);
- mScript.set_width(width);
- mScript.set_height(height);
- mScript.invoke_setRadius(MAX_RADIUS);
-
- mScript.set_InPixel(mInPixelsAllocation);
- mScript.set_ScratchPixel1(mScratchPixelsAllocation1);
- mScript.set_ScratchPixel2(mScratchPixelsAllocation2);
- }
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mOutPixelsAllocation);
- } else {
- mScript.forEach_copyIn(mInPixelsAllocation, mScratchPixelsAllocation1);
- mScript.forEach_horz(mScratchPixelsAllocation2);
- mScript.forEach_vert(mOutPixelsAllocation);
- }
- }
-
- public void setupBenchmark() {
- if (mUseIntrinsic) {
- mIntrinsic.setRadius(MAX_RADIUS);
- } else {
- mScript.invoke_setRadius(MAX_RADIUS);
- }
- }
-
- public void exitBenchmark() {
- if (mUseIntrinsic) {
- mIntrinsic.setRadius(mRadius);
- } else {
- mScript.invoke_setRadius((int)mRadius);
- }
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/ColorMatrix.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/ColorMatrix.java
deleted file mode 100644
index 5053d4d..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/ColorMatrix.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.ScriptGroup;
-import android.renderscript.ScriptIntrinsicColorMatrix;
-import android.renderscript.Type;
-import android.util.Log;
-
-public class ColorMatrix extends TestBase {
- private ScriptC_colormatrix mScript;
- private ScriptIntrinsicColorMatrix mIntrinsic;
- private boolean mUseIntrinsic;
- private boolean mUseGrey;
-
- public ColorMatrix(boolean useIntrinsic, boolean useGrey) {
- mUseIntrinsic = useIntrinsic;
- mUseGrey = useGrey;
- }
-
- public void createTest(android.content.res.Resources res) {
- Matrix4f m = new Matrix4f();
- m.set(1, 0, 0.2f);
- m.set(1, 1, 0.9f);
- m.set(1, 2, 0.2f);
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
- if (mUseGrey) {
- mIntrinsic.setGreyscale();
- } else {
- mIntrinsic.setColorMatrix(m);
- }
- } else {
- mScript = new ScriptC_colormatrix(mRS, res, R.raw.colormatrix);
- mScript.invoke_setMatrix(m);
- }
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation);
- } else {
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Contrast.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Contrast.java
deleted file mode 100644
index 20b28ff..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Contrast.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-
-public class Contrast extends TestBase {
- private ScriptC_contrast mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_contrast(mRS);
- }
-
- public void runTest() {
- mScript.invoke_setBright(50.f);
- mScript.forEach_contrast(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Convolve3x3.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Convolve3x3.java
deleted file mode 100644
index d7acf4a..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Convolve3x3.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.ScriptGroup;
-import android.renderscript.ScriptIntrinsicConvolve3x3;
-import android.renderscript.Type;
-import android.util.Log;
-
-public class Convolve3x3 extends TestBase {
- private ScriptC_convolve3x3 mScript;
- private ScriptIntrinsicConvolve3x3 mIntrinsic;
-
- private int mWidth;
- private int mHeight;
- private boolean mUseIntrinsic;
-
- public Convolve3x3(boolean useIntrinsic) {
- mUseIntrinsic = useIntrinsic;
- }
-
- public void createTest(android.content.res.Resources res) {
- mWidth = mInPixelsAllocation.getType().getX();
- mHeight = mInPixelsAllocation.getType().getY();
-
- float f[] = new float[9];
- f[0] = 0.f; f[1] = -1.f; f[2] = 0.f;
- f[3] = -1.f; f[4] = 5.f; f[5] = -1.f;
- f[6] = 0.f; f[7] = -1.f; f[8] = 0.f;
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicConvolve3x3.create(mRS, Element.U8_4(mRS));
- mIntrinsic.setCoefficients(f);
- mIntrinsic.setInput(mInPixelsAllocation);
- } else {
- mScript = new ScriptC_convolve3x3(mRS, res, R.raw.convolve3x3);
- mScript.set_gCoeffs(f);
- mScript.set_gIn(mInPixelsAllocation);
- mScript.set_gWidth(mWidth);
- mScript.set_gHeight(mHeight);
- }
- }
-
- public void runTest() {
- mScript.forEach_root(mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Convolve5x5.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Convolve5x5.java
deleted file mode 100644
index d1dbb1f..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Convolve5x5.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.ScriptGroup;
-import android.renderscript.ScriptIntrinsicConvolve5x5;
-import android.renderscript.Type;
-import android.util.Log;
-
-public class Convolve5x5 extends TestBase {
- private ScriptC_convolve5x5 mScript;
- private ScriptIntrinsicConvolve5x5 mIntrinsic;
-
- private int mWidth;
- private int mHeight;
- private boolean mUseIntrinsic;
-
- public Convolve5x5(boolean useIntrinsic) {
- mUseIntrinsic = useIntrinsic;
- }
-
- public void createTest(android.content.res.Resources res) {
- mWidth = mInPixelsAllocation.getType().getX();
- mHeight = mInPixelsAllocation.getType().getY();
-
- float f[] = new float[25];
- //f[0] = 0.012f; f[1] = 0.025f; f[2] = 0.031f; f[3] = 0.025f; f[4] = 0.012f;
- //f[5] = 0.025f; f[6] = 0.057f; f[7] = 0.075f; f[8] = 0.057f; f[9] = 0.025f;
- //f[10]= 0.031f; f[11]= 0.075f; f[12]= 0.095f; f[13]= 0.075f; f[14]= 0.031f;
- //f[15]= 0.025f; f[16]= 0.057f; f[17]= 0.075f; f[18]= 0.057f; f[19]= 0.025f;
- //f[20]= 0.012f; f[21]= 0.025f; f[22]= 0.031f; f[23]= 0.025f; f[24]= 0.012f;
-
- //f[0] = 1.f; f[1] = 2.f; f[2] = 0.f; f[3] = -2.f; f[4] = -1.f;
- //f[5] = 4.f; f[6] = 8.f; f[7] = 0.f; f[8] = -8.f; f[9] = -4.f;
- //f[10]= 6.f; f[11]=12.f; f[12]= 0.f; f[13]=-12.f; f[14]= -6.f;
- //f[15]= 4.f; f[16]= 8.f; f[17]= 0.f; f[18]= -8.f; f[19]= -4.f;
- //f[20]= 1.f; f[21]= 2.f; f[22]= 0.f; f[23]= -2.f; f[24]= -1.f;
-
- f[0] = -1.f; f[1] = -3.f; f[2] = -4.f; f[3] = -3.f; f[4] = -1.f;
- f[5] = -3.f; f[6] = 0.f; f[7] = 6.f; f[8] = 0.f; f[9] = -3.f;
- f[10]= -4.f; f[11]= 6.f; f[12]= 20.f; f[13]= 6.f; f[14]= -4.f;
- f[15]= -3.f; f[16]= 0.f; f[17]= 6.f; f[18]= 0.f; f[19]= -3.f;
- f[20]= -1.f; f[21]= -3.f; f[22]= -4.f; f[23]= -3.f; f[24]= -1.f;
-
- if (mUseIntrinsic) {
- mIntrinsic = ScriptIntrinsicConvolve5x5.create(mRS, Element.U8_4(mRS));
- mIntrinsic.setCoefficients(f);
- mIntrinsic.setInput(mInPixelsAllocation);
- } else {
- mScript = new ScriptC_convolve5x5(mRS, res, R.raw.convolve5x5);
- mScript.set_gCoeffs(f);
- mScript.set_gIn(mInPixelsAllocation);
- mScript.set_gWidth(mWidth);
- mScript.set_gHeight(mHeight);
- }
- }
-
- public void runTest() {
- if (mUseIntrinsic) {
- mIntrinsic.forEach(mOutPixelsAllocation);
- } else {
- mScript.forEach_root(mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Copy.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Copy.java
deleted file mode 100644
index 1bdee4b..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Copy.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.Type;
-import android.util.Log;
-
-public class Copy extends TestBase {
- private ScriptC_copy mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_copy(mRS, res, R.raw.copy);
- }
-
- public void runTest() {
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/CrossProcess.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/CrossProcess.java
deleted file mode 100644
index 75ee39b..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/CrossProcess.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.ScriptIntrinsicLUT;
-import android.util.Log;
-
-public class CrossProcess extends TestBase {
- private ScriptIntrinsicLUT mIntrinsic;
-
- public void createTest(android.content.res.Resources res) {
- mIntrinsic = ScriptIntrinsicLUT.create(mRS, Element.U8_4(mRS));
- for (int ct=0; ct < 256; ct++) {
- float f = ((float)ct) / 255.f;
-
- float r = f;
- if (r < 0.5f) {
- r = 4.0f * r * r * r;
- } else {
- r = 1.0f - r;
- r = 1.0f - (4.0f * r * r * r);
- }
- mIntrinsic.setRed(ct, (int)(r * 255.f + 0.5f));
-
- float g = f;
- if (g < 0.5f) {
- g = 2.0f * g * g;
- } else {
- g = 1.0f - g;
- g = 1.0f - (2.0f * g * g);
- }
- mIntrinsic.setGreen(ct, (int)(g * 255.f + 0.5f));
-
- float b = f * 0.5f + 0.25f;
- mIntrinsic.setBlue(ct, (int)(b * 255.f + 0.5f));
- }
-
- }
-
- public void runTest() {
- mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Exposure.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Exposure.java
deleted file mode 100644
index ddde96f..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Exposure.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-
-public class Exposure extends TestBase {
- private ScriptC_exposure mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_exposure(mRS);
- }
-
- public void runTest() {
- mScript.invoke_setBright(50.f);
- mScript.forEach_exposure(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Fisheye.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Fisheye.java
deleted file mode 100644
index 114839c..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Fisheye.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Sampler;
-import android.renderscript.Type;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Fisheye extends TestBase {
- private ScriptC_fisheye_full mScript_full = null;
- private ScriptC_fisheye_relaxed mScript_relaxed = null;
- private ScriptC_fisheye_approx_full mScript_approx_full = null;
- private ScriptC_fisheye_approx_relaxed mScript_approx_relaxed = null;
- private final boolean approx;
- private final boolean relaxed;
- private float center_x = 0.5f;
- private float center_y = 0.5f;
- private float scale = 0.5f;
-
- public Fisheye(boolean approx, boolean relaxed) {
- this.approx = approx;
- this.relaxed = relaxed;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Scale");
- b.setMax(100);
- b.setProgress(25);
- return true;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Shift center X");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- t.setText("Shift center Y");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- scale = progress / 50.0f;
- do_init();
- }
- public void onBar2Changed(int progress) {
- center_x = progress / 100.0f;
- do_init();
- }
- public void onBar3Changed(int progress) {
- center_y = progress / 100.0f;
- do_init();
- }
-
- private void do_init() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale);
- else
- mScript_approx_full.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale);
- } else if (relaxed)
- mScript_relaxed.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale);
- else
- mScript_full.invoke_init_filter(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale);
- }
-
- public void createTest(android.content.res.Resources res) {
- if (approx) {
- if (relaxed) {
- mScript_approx_relaxed = new ScriptC_fisheye_approx_relaxed(mRS,
- res, R.raw.fisheye_approx_relaxed);
- mScript_approx_relaxed.set_in_alloc(mInPixelsAllocation);
- mScript_approx_relaxed.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- } else {
- mScript_approx_full = new ScriptC_fisheye_approx_full(mRS, res,
- R.raw.fisheye_approx_full);
- mScript_approx_full.set_in_alloc(mInPixelsAllocation);
- mScript_approx_full.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- }
- } else if (relaxed) {
- mScript_relaxed = new ScriptC_fisheye_relaxed(mRS, res,
- R.raw.fisheye_relaxed);
- mScript_relaxed.set_in_alloc(mInPixelsAllocation);
- mScript_relaxed.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- } else {
- mScript_full = new ScriptC_fisheye_full(mRS, res,
- R.raw.fisheye_full);
- mScript_full.set_in_alloc(mInPixelsAllocation);
- mScript_full.set_sampler(Sampler.CLAMP_LINEAR(mRS));
- }
- do_init();
- }
-
- public void runTest() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.forEach_root(mOutPixelsAllocation);
- else
- mScript_approx_full.forEach_root(mOutPixelsAllocation);
- } else if (relaxed)
- mScript_relaxed.forEach_root(mOutPixelsAllocation);
- else
- mScript_full.forEach_root(mOutPixelsAllocation);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Grain.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Grain.java
deleted file mode 100644
index 5cd19a2..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Grain.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.Type;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Grain extends TestBase {
- private ScriptC_grain mScript;
- private Allocation mNoise;
- private Allocation mNoise2;
-
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Strength");
- b.setProgress(50);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- float s = progress / 100.0f;
- mScript.set_gNoiseStrength(s);
- }
-
- private int findHighBit(int v) {
- int bit = 0;
- while (v > 1) {
- bit++;
- v >>= 1;
- }
- return bit;
- }
-
-
- public void createTest(android.content.res.Resources res) {
- int width = mInPixelsAllocation.getType().getX();
- int height = mInPixelsAllocation.getType().getY();
-
- int noiseW = findHighBit(width);
- int noiseH = findHighBit(height);
- if (noiseW > 9) {
- noiseW = 9;
- }
- if (noiseH > 9) {
- noiseH = 9;
- }
- noiseW = 1 << noiseW;
- noiseH = 1 << noiseH;
-
- Type.Builder tb = new Type.Builder(mRS, Element.U8(mRS));
- tb.setX(noiseW);
- tb.setY(noiseH);
- mNoise = Allocation.createTyped(mRS, tb.create());
- mNoise2 = Allocation.createTyped(mRS, tb.create());
-
- mScript = new ScriptC_grain(mRS, res, R.raw.grain);
- mScript.set_gWMask(noiseW - 1);
- mScript.set_gHMask(noiseH - 1);
- mScript.set_gNoiseStrength(0.5f);
- mScript.set_gBlendSource(mNoise);
- mScript.set_gNoise(mNoise2);
- }
-
- public void runTest() {
- mScript.forEach_genRand(mNoise);
- mScript.forEach_blend9(mNoise2);
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Greyscale.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Greyscale.java
deleted file mode 100644
index f1952e7..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Greyscale.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.Type;
-import android.util.Log;
-
-public class Greyscale extends TestBase {
- private ScriptC_greyscale mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_greyscale(mRS, res, R.raw.greyscale);
- }
-
- public void runTest() {
- mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/GroupTest.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/GroupTest.java
deleted file mode 100644
index 3e5175a..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/GroupTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.ScriptIntrinsicConvolve3x3;
-import android.renderscript.ScriptIntrinsicColorMatrix;
-import android.renderscript.Type;
-import android.renderscript.Matrix4f;
-import android.renderscript.ScriptGroup;
-import android.util.Log;
-
-public class GroupTest extends TestBase {
- private ScriptIntrinsicConvolve3x3 mConvolve;
- private ScriptIntrinsicColorMatrix mMatrix;
-
- private Allocation mScratchPixelsAllocation1;
- private ScriptGroup mGroup;
-
- private int mWidth;
- private int mHeight;
- private boolean mUseNative;
-
-
- public GroupTest(boolean useNative) {
- mUseNative = useNative;
- }
-
- public void createTest(android.content.res.Resources res) {
- mWidth = mInPixelsAllocation.getType().getX();
- mHeight = mInPixelsAllocation.getType().getY();
-
- mConvolve = ScriptIntrinsicConvolve3x3.create(mRS, Element.U8_4(mRS));
- mMatrix = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
-
- float f[] = new float[9];
- f[0] = 0.f; f[1] = -1.f; f[2] = 0.f;
- f[3] = -1.f; f[4] = 5.f; f[5] = -1.f;
- f[6] = 0.f; f[7] = -1.f; f[8] = 0.f;
- mConvolve.setCoefficients(f);
-
- Matrix4f m = new Matrix4f();
- m.set(1, 0, 0.2f);
- m.set(1, 1, 0.9f);
- m.set(1, 2, 0.2f);
- mMatrix.setColorMatrix(m);
-
- Type.Builder tb = new Type.Builder(mRS, Element.U8_4(mRS));
- tb.setX(mWidth);
- tb.setY(mHeight);
- Type connect = tb.create();
-
- if (mUseNative) {
- ScriptGroup.Builder b = new ScriptGroup.Builder(mRS);
- b.addKernel(mConvolve.getKernelID());
- b.addKernel(mMatrix.getKernelID());
- b.addConnection(connect, mConvolve.getKernelID(), mMatrix.getKernelID());
- mGroup = b.create();
- } else {
- mScratchPixelsAllocation1 = Allocation.createTyped(mRS, connect);
- }
- }
-
- public void runTest() {
- mConvolve.setInput(mInPixelsAllocation);
- if (mUseNative) {
- mGroup.setOutput(mMatrix.getKernelID(), mOutPixelsAllocation);
- mGroup.execute();
- } else {
- mConvolve.forEach(mScratchPixelsAllocation1);
- mMatrix.forEach(mScratchPixelsAllocation1, mOutPixelsAllocation);
- }
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/ImageProcessingActivityJB.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/ImageProcessingActivityJB.java
deleted file mode 100644
index 93937ef..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/ImageProcessingActivityJB.java
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.graphics.BitmapFactory;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.view.SurfaceView;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.SeekBar;
-import android.widget.Spinner;
-import android.widget.TextView;
-import android.view.View;
-import android.util.Log;
-import android.renderscript.ScriptC;
-import android.renderscript.RenderScript;
-import android.renderscript.Type;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Script;
-
-import android.os.Environment;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-public class ImageProcessingActivityJB extends Activity
- implements SeekBar.OnSeekBarChangeListener {
- private final String TAG = "Img";
- public final String RESULT_FILE = "image_processing_result.csv";
-
- RenderScript mRS;
- Allocation mInPixelsAllocation;
- Allocation mInPixelsAllocation2;
- Allocation mOutPixelsAllocation;
-
- /**
- * Define enum type for test names
- */
- public enum TestName {
- // totally there are 38 test cases
- LEVELS_VEC3_RELAXED ("Levels Vec3 Relaxed"),
- LEVELS_VEC4_RELAXED ("Levels Vec4 Relaxed"),
- LEVELS_VEC3_FULL ("Levels Vec3 Full"),
- LEVELS_VEC4_FULL ("Levels Vec4 Full"),
- BLUR_RADIUS_25 ("Blur radius 25"),
- INTRINSIC_BLUE_RADIUS_25 ("Intrinsic Blur radius 25"),
- GREYSCALE ("Greyscale"),
- GRAIN ("Grain"),
- FISHEYE_FULL ("Fisheye Full"),
- FISHEYE_RELAXED ("Fisheye Relaxed"),
- FISHEYE_APPROXIMATE_FULL ("Fisheye Approximate Full"),
- FISHEYE_APPROXIMATE_RELAXED ("Fisheye Approximate Relaxed"),
- VIGNETTE_FULL ("Vignette Full"),
- VIGNETTE_RELAXED ("Vignette Relaxed"),
- VIGNETTE_APPROXIMATE_FULL ("Vignette Approximate Full"),
- VIGNETTE_APPROXIMATE_RELAXED ("Vignette Approximate Relaxed"),
- GROUP_TEST_EMULATED ("Group Test (emulated)"),
- GROUP_TEST_NATIVE ("Group Test (native)"),
- CONVOLVE_3X3 ("Convolve 3x3"),
- INTRINSICS_CONVOLVE_3X3 ("Intrinsics Convolve 3x3"),
- COLOR_MATRIX ("ColorMatrix"),
- INTRINSICS_COLOR_MATRIX ("Intrinsics ColorMatrix"),
- INTRINSICS_COLOR_MATRIX_GREY ("Intrinsics ColorMatrix Grey"),
- COPY ("Copy"),
- CROSS_PROCESS_USING_LUT ("CrossProcess (using LUT)"),
- CONVOLVE_5X5 ("Convolve 5x5"),
- INTRINSICS_CONVOLVE_5X5 ("Intrinsics Convolve 5x5"),
- MANDELBROT ("Mandelbrot"),
- INTRINSICS_BLEND ("Intrinsics Blend"),
- VIBRANCE ("Vibrance"),
- BW_FILTER ("BW Filter"),
- SHADOWS ("Shadows"),
- CONTRAST ("Contrast"),
- EXPOSURE ("Exposure"),
- WHITE_BALANCE ("White Balance");
-
-
- private final String name;
-
- private TestName(String s) {
- name = s;
- }
-
- // return quoted string as displayed test name
- public String toString() {
- return name;
- }
- }
-
- Bitmap mBitmapIn;
- Bitmap mBitmapIn2;
- Bitmap mBitmapOut;
-
- private Spinner mSpinner;
- private SeekBar mBar1;
- private SeekBar mBar2;
- private SeekBar mBar3;
- private SeekBar mBar4;
- private SeekBar mBar5;
- private TextView mText1;
- private TextView mText2;
- private TextView mText3;
- private TextView mText4;
- private TextView mText5;
-
- private float mSaturation = 1.0f;
-
- private TextView mBenchmarkResult;
- private Spinner mTestSpinner;
-
- private SurfaceView mSurfaceView;
- private ImageView mDisplayView;
-
- private boolean mDoingBenchmark;
-
- private TestBase mTest;
- private int mRunCount;
-
- public void updateDisplay() {
- mHandler.sendMessage(Message.obtain());
- }
-
- private Handler mHandler = new Handler() {
- // Allow the filter to complete without blocking the UI
- // thread. When the message arrives that the op is complete
- // we will either mark completion or start a new filter if
- // more work is ready. Either way, display the result.
- @Override
- public void handleMessage(Message msg) {
- mTest.updateBitmap(mBitmapOut);
- mDisplayView.invalidate();
-
- boolean doTest = false;
- synchronized(this) {
- if (mRunCount > 0) {
- mRunCount--;
- if (mRunCount > 0) {
- doTest = true;
- }
- }
- }
- if (doTest) {
- mTest.runTestSendMessage();
- }
- }
-
- };
-
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- if (fromUser) {
-
- if (seekBar == mBar1) {
- mTest.onBar1Changed(progress);
- } else if (seekBar == mBar2) {
- mTest.onBar2Changed(progress);
- } else if (seekBar == mBar3) {
- mTest.onBar3Changed(progress);
- } else if (seekBar == mBar4) {
- mTest.onBar4Changed(progress);
- } else if (seekBar == mBar5) {
- mTest.onBar5Changed(progress);
- }
-
- boolean doTest = false;
- synchronized(this) {
- if (mRunCount == 0) {
- doTest = true;
- mRunCount = 1;
- } else {
- mRunCount = 2;
- }
- }
- if (doTest) {
- mTest.runTestSendMessage();
- }
- }
- }
-
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
-
- public void onStopTrackingTouch(SeekBar seekBar) {
- }
-
- void setupBars() {
- mSpinner.setVisibility(View.VISIBLE);
- mTest.onSpinner1Setup(mSpinner);
-
- mBar1.setVisibility(View.VISIBLE);
- mText1.setVisibility(View.VISIBLE);
- mTest.onBar1Setup(mBar1, mText1);
-
- mBar2.setVisibility(View.VISIBLE);
- mText2.setVisibility(View.VISIBLE);
- mTest.onBar2Setup(mBar2, mText2);
-
- mBar3.setVisibility(View.VISIBLE);
- mText3.setVisibility(View.VISIBLE);
- mTest.onBar3Setup(mBar3, mText3);
-
- mBar4.setVisibility(View.VISIBLE);
- mText4.setVisibility(View.VISIBLE);
- mTest.onBar4Setup(mBar4, mText4);
-
- mBar5.setVisibility(View.VISIBLE);
- mText5.setVisibility(View.VISIBLE);
- mTest.onBar5Setup(mBar5, mText5);
- }
-
-
- void changeTest(TestName testName) {
- if (mTest != null) {
- mTest.destroy();
- }
- switch(testName) {
- case LEVELS_VEC3_RELAXED:
- mTest = new LevelsV4(false, false);
- break;
- case LEVELS_VEC4_RELAXED:
- mTest = new LevelsV4(false, true);
- break;
- case LEVELS_VEC3_FULL:
- mTest = new LevelsV4(true, false);
- break;
- case LEVELS_VEC4_FULL:
- mTest = new LevelsV4(true, true);
- break;
- case BLUR_RADIUS_25:
- mTest = new Blur25(false);
- break;
- case INTRINSIC_BLUE_RADIUS_25:
- mTest = new Blur25(true);
- break;
- case GREYSCALE:
- mTest = new Greyscale();
- break;
- case GRAIN:
- mTest = new Grain();
- break;
- case FISHEYE_FULL:
- mTest = new Fisheye(false, false);
- break;
- case FISHEYE_RELAXED:
- mTest = new Fisheye(false, true);
- break;
- case FISHEYE_APPROXIMATE_FULL:
- mTest = new Fisheye(true, false);
- break;
- case FISHEYE_APPROXIMATE_RELAXED:
- mTest = new Fisheye(true, true);
- break;
- case VIGNETTE_FULL:
- mTest = new Vignette(false, false);
- break;
- case VIGNETTE_RELAXED:
- mTest = new Vignette(false, true);
- break;
- case VIGNETTE_APPROXIMATE_FULL:
- mTest = new Vignette(true, false);
- break;
- case VIGNETTE_APPROXIMATE_RELAXED:
- mTest = new Vignette(true, true);
- break;
- case GROUP_TEST_EMULATED:
- mTest = new GroupTest(false);
- break;
- case GROUP_TEST_NATIVE:
- mTest = new GroupTest(true);
- break;
- case CONVOLVE_3X3:
- mTest = new Convolve3x3(false);
- break;
- case INTRINSICS_CONVOLVE_3X3:
- mTest = new Convolve3x3(true);
- break;
- case COLOR_MATRIX:
- mTest = new ColorMatrix(false, false);
- break;
- case INTRINSICS_COLOR_MATRIX:
- mTest = new ColorMatrix(true, false);
- break;
- case INTRINSICS_COLOR_MATRIX_GREY:
- mTest = new ColorMatrix(true, true);
- break;
- case COPY:
- mTest = new Copy();
- break;
- case CROSS_PROCESS_USING_LUT:
- mTest = new CrossProcess();
- break;
- case CONVOLVE_5X5:
- mTest = new Convolve5x5(false);
- break;
- case INTRINSICS_CONVOLVE_5X5:
- mTest = new Convolve5x5(true);
- break;
- case MANDELBROT:
- mTest = new Mandelbrot();
- break;
- case INTRINSICS_BLEND:
- mTest = new Blend();
- break;
- case VIBRANCE:
- mTest = new Vibrance();
- break;
- case BW_FILTER:
- mTest = new BWFilter();
- break;
- case SHADOWS:
- mTest = new Shadows();
- break;
- case CONTRAST:
- mTest = new Contrast();
- break;
- case EXPOSURE:
- mTest = new Exposure();
- break;
- case WHITE_BALANCE:
- mTest = new WhiteBalance();
- break;
- }
-
- mTest.createBaseTest(this, mBitmapIn, mBitmapIn2, mBitmapOut);
- setupBars();
-
- mTest.runTest();
- updateDisplay();
- mBenchmarkResult.setText("Result: not run");
- }
-
- void setupTests() {
- mTestSpinner.setAdapter(new ArrayAdapter<TestName>(
- this, R.layout.spinner_layout, TestName.values()));
- }
-
- private AdapterView.OnItemSelectedListener mTestSpinnerListener =
- new AdapterView.OnItemSelectedListener() {
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
- changeTest(TestName.values()[pos]);
- }
-
- public void onNothingSelected(AdapterView parent) {
-
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- mBitmapIn = loadBitmap(R.drawable.img1600x1067);
- mBitmapIn2 = loadBitmap(R.drawable.img1600x1067b);
- mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(), mBitmapIn.getHeight(),
- mBitmapIn.getConfig());
-
- mSurfaceView = (SurfaceView) findViewById(R.id.surface);
-
- mDisplayView = (ImageView) findViewById(R.id.display);
- mDisplayView.setImageBitmap(mBitmapOut);
-
- mSpinner = (Spinner) findViewById(R.id.spinner1);
-
- mBar1 = (SeekBar) findViewById(R.id.slider1);
- mBar2 = (SeekBar) findViewById(R.id.slider2);
- mBar3 = (SeekBar) findViewById(R.id.slider3);
- mBar4 = (SeekBar) findViewById(R.id.slider4);
- mBar5 = (SeekBar) findViewById(R.id.slider5);
-
- mBar1.setOnSeekBarChangeListener(this);
- mBar2.setOnSeekBarChangeListener(this);
- mBar3.setOnSeekBarChangeListener(this);
- mBar4.setOnSeekBarChangeListener(this);
- mBar5.setOnSeekBarChangeListener(this);
-
- mText1 = (TextView) findViewById(R.id.slider1Text);
- mText2 = (TextView) findViewById(R.id.slider2Text);
- mText3 = (TextView) findViewById(R.id.slider3Text);
- mText4 = (TextView) findViewById(R.id.slider4Text);
- mText5 = (TextView) findViewById(R.id.slider5Text);
-
- mTestSpinner = (Spinner) findViewById(R.id.filterselection);
- mTestSpinner.setOnItemSelectedListener(mTestSpinnerListener);
-
- mBenchmarkResult = (TextView) findViewById(R.id.benchmarkText);
- mBenchmarkResult.setText("Result: not run");
-
-
- mRS = RenderScript.create(this);
- mInPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapIn);
- mInPixelsAllocation2 = Allocation.createFromBitmap(mRS, mBitmapIn2);
- mOutPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapOut);
-
-
- setupTests();
- changeTest(TestName.LEVELS_VEC3_RELAXED);
- }
-
-
- private Bitmap loadBitmap(int resource) {
- final BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- return BitmapFactory.decodeResource(getResources(), resource, options);
- }
-
- // button hook
- public void benchmark(View v) {
- float t = getBenchmark();
- //long javaTime = javaFilter();
- //mBenchmarkResult.setText("RS: " + t + " ms Java: " + javaTime + " ms");
- mBenchmarkResult.setText("Result: " + t + " ms");
- Log.v(TAG, "getBenchmark: Renderscript frame time core ms " + t);
- }
-
- public void benchmark_all(View v) {
- // write result into a file
- File externalStorage = Environment.getExternalStorageDirectory();
- if (!externalStorage.canWrite()) {
- Log.v(TAG, "sdcard is not writable");
- return;
- }
- File resultFile = new File(externalStorage, RESULT_FILE);
- resultFile.setWritable(true, false);
- try {
- BufferedWriter rsWriter = new BufferedWriter(new FileWriter(resultFile));
- Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
- for (TestName tn: TestName.values()) {
- changeTest(tn);
- float t = getBenchmark();
- String s = new String("" + tn.toString() + ", " + t);
- rsWriter.write(s + "\n");
- Log.v(TAG, "Test " + s + "ms\n");
- }
- rsWriter.close();
- } catch (IOException e) {
- Log.v(TAG, "Unable to write result file " + e.getMessage());
- }
- changeTest(TestName.LEVELS_VEC3_RELAXED);
- }
-
- // For benchmark test
- public float getBenchmark() {
- mDoingBenchmark = true;
-
- mTest.setupBenchmark();
- long result = 0;
-
- //Log.v(TAG, "Warming");
- long t = java.lang.System.currentTimeMillis() + 250;
- do {
- mTest.runTest();
- mTest.finish();
- } while (t > java.lang.System.currentTimeMillis());
-
- //Log.v(TAG, "Benchmarking");
- int ct = 0;
- t = java.lang.System.currentTimeMillis();
- do {
- mTest.runTest();
- mTest.finish();
- ct++;
- } while ((t+1000) > java.lang.System.currentTimeMillis());
- t = java.lang.System.currentTimeMillis() - t;
- float ft = (float)t;
- ft /= ct;
-
- mTest.exitBenchmark();
- mDoingBenchmark = false;
-
- return ft;
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/LevelsV4.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/LevelsV4.java
deleted file mode 100644
index 741e480..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/LevelsV4.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Matrix3f;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.Type;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-
-public class LevelsV4 extends TestBase {
- private ScriptC_levels_relaxed mScriptR;
- private ScriptC_levels_full mScriptF;
- private float mInBlack = 0.0f;
- private float mOutBlack = 0.0f;
- private float mInWhite = 255.0f;
- private float mOutWhite = 255.0f;
- private float mSaturation = 1.0f;
-
- Matrix3f satMatrix = new Matrix3f();
- float mInWMinInB;
- float mOutWMinOutB;
- float mOverInWMinInB;
-
- boolean mUseFull;
- boolean mUseV4;
-
- LevelsV4(boolean useFull, boolean useV4) {
- mUseFull = useFull;
- mUseV4 = useV4;
- }
-
-
- private void setLevels() {
- mInWMinInB = mInWhite - mInBlack;
- mOutWMinOutB = mOutWhite - mOutBlack;
- mOverInWMinInB = 1.f / mInWMinInB;
-
- mScriptR.set_inBlack(mInBlack);
- mScriptR.set_outBlack(mOutBlack);
- mScriptR.set_inWMinInB(mInWMinInB);
- mScriptR.set_outWMinOutB(mOutWMinOutB);
- mScriptR.set_overInWMinInB(mOverInWMinInB);
- mScriptF.set_inBlack(mInBlack);
- mScriptF.set_outBlack(mOutBlack);
- mScriptF.set_inWMinInB(mInWMinInB);
- mScriptF.set_outWMinOutB(mOutWMinOutB);
- mScriptF.set_overInWMinInB(mOverInWMinInB);
- }
-
- private void setSaturation() {
- float rWeight = 0.299f;
- float gWeight = 0.587f;
- float bWeight = 0.114f;
- float oneMinusS = 1.0f - mSaturation;
-
- satMatrix.set(0, 0, oneMinusS * rWeight + mSaturation);
- satMatrix.set(0, 1, oneMinusS * rWeight);
- satMatrix.set(0, 2, oneMinusS * rWeight);
- satMatrix.set(1, 0, oneMinusS * gWeight);
- satMatrix.set(1, 1, oneMinusS * gWeight + mSaturation);
- satMatrix.set(1, 2, oneMinusS * gWeight);
- satMatrix.set(2, 0, oneMinusS * bWeight);
- satMatrix.set(2, 1, oneMinusS * bWeight);
- satMatrix.set(2, 2, oneMinusS * bWeight + mSaturation);
- mScriptR.set_colorMat(satMatrix);
- mScriptF.set_colorMat(satMatrix);
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- b.setProgress(50);
- t.setText("Saturation");
- return true;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(0);
- t.setText("In Black");
- return true;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(0);
- t.setText("Out Black");
- return true;
- }
- public boolean onBar4Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(128);
- t.setText("Out White");
- return true;
- }
- public boolean onBar5Setup(SeekBar b, TextView t) {
- b.setMax(128);
- b.setProgress(128);
- t.setText("Out White");
- return true;
- }
-
- public void onBar1Changed(int progress) {
- mSaturation = (float)progress / 50.0f;
- setSaturation();
- }
- public void onBar2Changed(int progress) {
- mInBlack = (float)progress;
- setLevels();
- }
- public void onBar3Changed(int progress) {
- mOutBlack = (float)progress;
- setLevels();
- }
- public void onBar4Changed(int progress) {
- mInWhite = (float)progress + 127.0f;
- setLevels();
- }
- public void onBar5Changed(int progress) {
- mOutWhite = (float)progress + 127.0f;
- setLevels();
- }
-
- public void createTest(android.content.res.Resources res) {
- mScriptR = new ScriptC_levels_relaxed(mRS, res, R.raw.levels_relaxed);
- mScriptF = new ScriptC_levels_full(mRS, res, R.raw.levels_full);
- setSaturation();
- setLevels();
- }
-
- public void runTest() {
- if (mUseFull) {
- if (mUseV4) {
- mScriptF.forEach_root4(mInPixelsAllocation, mOutPixelsAllocation);
- } else {
- mScriptF.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
- } else {
- if (mUseV4) {
- mScriptR.forEach_root4(mInPixelsAllocation, mOutPixelsAllocation);
- } else {
- mScriptR.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
- }
- }
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Mandelbrot.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Mandelbrot.java
deleted file mode 100644
index ca34848..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Mandelbrot.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Script;
-import android.renderscript.ScriptC;
-import android.renderscript.Type;
-import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Mandelbrot extends TestBase {
- private ScriptC_mandelbrot mScript;
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Iterations");
- b.setProgress(0);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- int iters = progress * 3 + 50;
- mScript.set_gMaxIteration(iters);
- }
-
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Lower Bound: X");
- b.setProgress(0);
- return true;
- }
-
- public void onBar2Changed(int progress) {
- float scaleFactor = mScript.get_scaleFactor();
- // allow viewport to be moved by 2x scale factor
- float lowerBoundX = -2.f + ((progress / scaleFactor) / 50.f);
- mScript.set_lowerBoundX(lowerBoundX);
- }
-
- public boolean onBar3Setup(SeekBar b, TextView t) {
- t.setText("Lower Bound: Y");
- b.setProgress(0);
- return true;
- }
-
- public void onBar3Changed(int progress) {
- float scaleFactor = mScript.get_scaleFactor();
- // allow viewport to be moved by 2x scale factor
- float lowerBoundY = -2.f + ((progress / scaleFactor) / 50.f);
- mScript.set_lowerBoundY(lowerBoundY);
- }
-
- public boolean onBar4Setup(SeekBar b, TextView t) {
- t.setText("Scale Factor");
- b.setProgress(0);
- return true;
- }
-
- public void onBar4Changed(int progress) {
- float scaleFactor = 4.f - (3.96f * (progress / 100.f));
- mScript.set_scaleFactor(scaleFactor);
- }
-
- public void createTest(android.content.res.Resources res) {
- int width = mOutPixelsAllocation.getType().getX();
- int height = mOutPixelsAllocation.getType().getY();
-
- mScript = new ScriptC_mandelbrot(mRS, res, R.raw.mandelbrot);
- mScript.set_gDimX(width);
- mScript.set_gDimY(height);
- mScript.set_gMaxIteration(50);
- }
-
- public void runTest() {
- mScript.forEach_root(mOutPixelsAllocation);
- mRS.finish();
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Shadows.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Shadows.java
deleted file mode 100644
index d246d59..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Shadows.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-
-public class Shadows extends TestBase {
- private ScriptC_shadows mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_shadows(mRS);
- }
-
- public void runTest() {
- mScript.invoke_prepareShadows(50.f);
- mScript.forEach_shadowsKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/TestBase.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/TestBase.java
deleted file mode 100644
index 9ae366a..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/TestBase.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.graphics.BitmapFactory;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.renderscript.ScriptC;
-import android.renderscript.RenderScript;
-import android.renderscript.Type;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Script;
-import android.view.SurfaceView;
-import android.view.SurfaceHolder;
-import android.widget.ImageView;
-import android.widget.SeekBar;
-import android.widget.TextView;
-import android.view.View;
-import android.util.Log;
-import java.lang.Math;
-import android.widget.Spinner;
-
-public class TestBase {
- protected final String TAG = "Img";
-
- protected RenderScript mRS;
- protected Allocation mInPixelsAllocation;
- protected Allocation mInPixelsAllocation2;
- protected Allocation mOutPixelsAllocation;
- protected ScriptC_msg mMessageScript;
-
- protected ImageProcessingActivityJB act;
-
- private class MessageProcessor extends RenderScript.RSMessageHandler {
- ImageProcessingActivityJB mAct;
-
- MessageProcessor(ImageProcessingActivityJB act) {
- mAct = act;
- }
-
- public void run() {
- mAct.updateDisplay();
- }
- }
-
- // Override to use UI elements
- public void onBar1Changed(int progress) {
- }
- public void onBar2Changed(int progress) {
- }
- public void onBar3Changed(int progress) {
- }
- public void onBar4Changed(int progress) {
- }
- public void onBar5Changed(int progress) {
- }
-
- // Override to use UI elements
- // Unused bars will be hidden.
- public boolean onBar1Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar4Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
- public boolean onBar5Setup(SeekBar b, TextView t) {
- b.setVisibility(View.INVISIBLE);
- t.setVisibility(View.INVISIBLE);
- return false;
- }
-
- public boolean onSpinner1Setup(Spinner s) {
- s.setVisibility(View.INVISIBLE);
- return false;
- }
-
- public final void createBaseTest(ImageProcessingActivityJB ipact, Bitmap b, Bitmap b2, Bitmap outb) {
- act = ipact;
- mRS = ipact.mRS;
- mRS.setMessageHandler(new MessageProcessor(act));
-
- mInPixelsAllocation = ipact.mInPixelsAllocation;
- mInPixelsAllocation2 = ipact.mInPixelsAllocation2;
- mOutPixelsAllocation = ipact.mOutPixelsAllocation;
-
- createTest(act.getResources());
- }
-
- // Must override
- public void createTest(android.content.res.Resources res) {
- }
-
- // Must override
- public void runTest() {
- }
-
- final public void runTestSendMessage() {
- runTest();
- mMessageScript.invoke_sendMsg();
- }
-
- public void finish() {
- mRS.finish();
- }
-
- public void destroy() {
- mRS.setMessageHandler(null);
- }
-
- public void updateBitmap(Bitmap b) {
- mOutPixelsAllocation.copyTo(b);
- }
-
- // Override to configure specific benchmark config.
- public void setupBenchmark() {
- }
-
- // Override to reset after benchmark.
- public void exitBenchmark() {
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Vibrance.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Vibrance.java
deleted file mode 100644
index 09822a9..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Vibrance.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-
-public class Vibrance extends TestBase {
- private ScriptC_vibrance mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_vibrance(mRS);
- }
-
- public void runTest() {
- mScript.set_vibrance(50.f);
- mScript.invoke_prepareVibrance();
- mScript.forEach_vibranceKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Vignette.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Vignette.java
deleted file mode 100644
index 9451757..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Vignette.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Sampler;
-import android.renderscript.Type;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Vignette extends TestBase {
- private ScriptC_vignette_full mScript_full = null;
- private ScriptC_vignette_relaxed mScript_relaxed = null;
- private ScriptC_vignette_approx_full mScript_approx_full = null;
- private ScriptC_vignette_approx_relaxed mScript_approx_relaxed = null;
- private final boolean approx;
- private final boolean relaxed;
- private float center_x = 0.5f;
- private float center_y = 0.5f;
- private float scale = 0.5f;
- private float shade = 0.5f;
- private float slope = 20.0f;
-
- public Vignette(boolean approx, boolean relaxed) {
- this.approx = approx;
- this.relaxed = relaxed;
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Scale");
- b.setMax(100);
- b.setProgress(25);
- return true;
- }
- public boolean onBar2Setup(SeekBar b, TextView t) {
- t.setText("Shade");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
- public boolean onBar3Setup(SeekBar b, TextView t) {
- t.setText("Slope");
- b.setMax(100);
- b.setProgress(20);
- return true;
- }
- public boolean onBar4Setup(SeekBar b, TextView t) {
- t.setText("Shift center X");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
- public boolean onBar5Setup(SeekBar b, TextView t) {
- t.setText("Shift center Y");
- b.setMax(100);
- b.setProgress(50);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- scale = progress / 50.0f;
- do_init();
- }
- public void onBar2Changed(int progress) {
- shade = progress / 100.0f;
- do_init();
- }
- public void onBar3Changed(int progress) {
- slope = (float)progress;
- do_init();
- }
- public void onBar4Changed(int progress) {
- center_x = progress / 100.0f;
- do_init();
- }
- public void onBar5Changed(int progress) {
- center_y = progress / 100.0f;
- do_init();
- }
-
- private void do_init() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale, shade, slope);
- else
- mScript_approx_full.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x,
- center_y, scale, shade, slope);
- } else if (relaxed)
- mScript_relaxed.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale, shade, slope);
- else
- mScript_full.invoke_init_vignette(
- mInPixelsAllocation.getType().getX(),
- mInPixelsAllocation.getType().getY(), center_x, center_y,
- scale, shade, slope);
- }
-
- public void createTest(android.content.res.Resources res) {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed = new ScriptC_vignette_approx_relaxed(
- mRS, res, R.raw.vignette_approx_relaxed);
- else
- mScript_approx_full = new ScriptC_vignette_approx_full(
- mRS, res, R.raw.vignette_approx_full);
- } else if (relaxed)
- mScript_relaxed = new ScriptC_vignette_relaxed(mRS, res,
- R.raw.vignette_relaxed);
- else
- mScript_full = new ScriptC_vignette_full(mRS, res,
- R.raw.vignette_full);
- do_init();
- }
-
- public void runTest() {
- if (approx) {
- if (relaxed)
- mScript_approx_relaxed.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- else
- mScript_approx_full.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- } else if (relaxed)
- mScript_relaxed.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- else
- mScript_full.forEach_root(mInPixelsAllocation,
- mOutPixelsAllocation);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/WhiteBalance.java b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/WhiteBalance.java
deleted file mode 100644
index f15aaf5b..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/WhiteBalance.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.imagejb;
-
-import java.lang.Math;
-
-import android.renderscript.Allocation;
-
-public class WhiteBalance extends TestBase {
- private ScriptC_wbalance mScript;
-
- public void createTest(android.content.res.Resources res) {
- mScript = new ScriptC_wbalance(mRS);
- }
-
- public void runTest() {
- mScript.set_histogramSource(mInPixelsAllocation);
- mScript.set_histogramWidth(mInPixelsAllocation.getType().getX());
- mScript.set_histogramHeight(mInPixelsAllocation.getType().getY());
- mScript.invoke_prepareWhiteBalance();
- mScript.forEach_whiteBalanceKernel(mInPixelsAllocation, mOutPixelsAllocation);
- }
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/blend.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/blend.rs
deleted file mode 100644
index 9ec1246..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/blend.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (C) 2011 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.
-
-#include "ip.rsh"
-
-uchar alpha = 0x0;
-
-void setImageAlpha(uchar4 *v_out, uint32_t x, uint32_t y) {
- v_out->rgba = convert_uchar4((convert_uint4(v_out->rgba) * alpha) >> (uint4)8);
- v_out->a = alpha;
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/bwfilter.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/bwfilter.rs
deleted file mode 100644
index e706d44..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/bwfilter.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-//#pragma rs_fp_relaxed
-
-static float sr = 0.f;
-static float sg = 0.f;
-static float sb = 0.f;
-
-void prepareBwFilter(uint32_t rw, uint32_t gw, uint32_t bw) {
-
- sr = rw;
- sg = gw;
- sb = bw;
-
- float imageMin = min(sg,sb);
- imageMin = fmin(sr,imageMin);
- float imageMax = max(sg,sb);
- imageMax = fmax(sr,imageMax);
- float avg = (imageMin + imageMax)/2;
- sb /= avg;
- sg /= avg;
- sr /= avg;
-
-}
-
-void bwFilterKernel(const uchar4 *in, uchar4 *out) {
- float r = in->r * sr;
- float g = in->g * sg;
- float b = in->b * sb;
- float localMin, localMax, avg;
- localMin = fmin(g,b);
- localMin = fmin(r,localMin);
- localMax = fmax(g,b);
- localMax = fmax(r,localMax);
- avg = (localMin+localMax) * 0.5f;
- out->r = out->g = out->b = rsClamp(avg, 0, 255);
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/colormatrix.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/colormatrix.fs
deleted file mode 100644
index 86fb248..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/colormatrix.fs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-static rs_matrix4x4 Mat;
-
-void init() {
- rsMatrixLoadIdentity(&Mat);
-}
-
-void setMatrix(rs_matrix4x4 m) {
- Mat = m;
-}
-
-uchar4 __attribute__((kernel)) root(uchar4 in) {
- float4 f = convert_float4(in);
- f = rsMatrixMultiply(&Mat, f);
- f = clamp(f, 0.f, 255.f);
- return convert_uchar4(f);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/contrast.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/contrast.rs
deleted file mode 100644
index d3743d3..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/contrast.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-static float brightM = 0.f;
-static float brightC = 0.f;
-
-void setBright(float v) {
- brightM = pow(2.f, v / 100.f);
- brightC = 127.f - brightM * 127.f;
-}
-
-void contrast(const uchar4 *in, uchar4 *out)
-{
-#if 0
- out->r = rsClamp((int)(brightM * in->r + brightC), 0, 255);
- out->g = rsClamp((int)(brightM * in->g + brightC), 0, 255);
- out->b = rsClamp((int)(brightM * in->b + brightC), 0, 255);
-#else
- float3 v = convert_float3(in->rgb) * brightM + brightC;
- out->rgb = convert_uchar3(clamp(v, 0.f, 255.f));
-#endif
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/convolve3x3.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/convolve3x3.fs
deleted file mode 100644
index 177e86e..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/convolve3x3.fs
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-int32_t gWidth;
-int32_t gHeight;
-rs_allocation gIn;
-
-float gCoeffs[9];
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- uint32_t x1 = min((int32_t)x+1, gWidth-1);
- uint32_t x2 = max((int32_t)x-1, 0);
- uint32_t y1 = min((int32_t)y+1, gHeight-1);
- uint32_t y2 = max((int32_t)y-1, 0);
-
- float4 p00 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y1));
- float4 p01 = convert_float4(rsGetElementAt_uchar4(gIn, x, y1));
- float4 p02 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y1));
- float4 p10 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y));
- float4 p11 = convert_float4(rsGetElementAt_uchar4(gIn, x, y));
- float4 p12 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y));
- float4 p20 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y2));
- float4 p21 = convert_float4(rsGetElementAt_uchar4(gIn, x, y2));
- float4 p22 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y2));
- p00 *= gCoeffs[0];
- p01 *= gCoeffs[1];
- p02 *= gCoeffs[2];
- p10 *= gCoeffs[3];
- p11 *= gCoeffs[4];
- p12 *= gCoeffs[5];
- p20 *= gCoeffs[6];
- p21 *= gCoeffs[7];
- p22 *= gCoeffs[8];
-
- p00 += p01;
- p02 += p10;
- p11 += p12;
- p20 += p21;
-
- p22 += p00;
- p02 += p11;
-
- p20 += p22;
- p20 += p02;
-
- p20 = clamp(p20, 0.f, 255.f);
- return convert_uchar4(p20);
-}
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/convolve5x5.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/convolve5x5.fs
deleted file mode 100644
index 922a593..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/convolve5x5.fs
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-int32_t gWidth;
-int32_t gHeight;
-rs_allocation gIn;
-
-float gCoeffs[25];
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- uint32_t x0 = max((int32_t)x-2, 0);
- uint32_t x1 = max((int32_t)x-1, 0);
- uint32_t x2 = x;
- uint32_t x3 = min((int32_t)x+1, gWidth-1);
- uint32_t x4 = min((int32_t)x+2, gWidth-1);
-
- uint32_t y0 = max((int32_t)y-2, 0);
- uint32_t y1 = max((int32_t)y-1, 0);
- uint32_t y2 = y;
- uint32_t y3 = min((int32_t)y+1, gHeight-1);
- uint32_t y4 = min((int32_t)y+2, gHeight-1);
-
- float4 p0 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y0)) * gCoeffs[0]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y0)) * gCoeffs[1]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y0)) * gCoeffs[2]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y0)) * gCoeffs[3]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y0)) * gCoeffs[4];
-
- float4 p1 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y1)) * gCoeffs[5]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y1)) * gCoeffs[6]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y1)) * gCoeffs[7]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y1)) * gCoeffs[8]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y1)) * gCoeffs[9];
-
- float4 p2 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y2)) * gCoeffs[10]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y2)) * gCoeffs[11]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y2)) * gCoeffs[12]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y2)) * gCoeffs[13]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y2)) * gCoeffs[14];
-
- float4 p3 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y3)) * gCoeffs[15]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y3)) * gCoeffs[16]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y3)) * gCoeffs[17]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y3)) * gCoeffs[18]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y3)) * gCoeffs[19];
-
- float4 p4 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y4)) * gCoeffs[20]
- + convert_float4(rsGetElementAt_uchar4(gIn, x1, y4)) * gCoeffs[21]
- + convert_float4(rsGetElementAt_uchar4(gIn, x2, y4)) * gCoeffs[22]
- + convert_float4(rsGetElementAt_uchar4(gIn, x3, y4)) * gCoeffs[23]
- + convert_float4(rsGetElementAt_uchar4(gIn, x4, y4)) * gCoeffs[24];
-
- p0 = clamp(p0 + p1 + p2 + p3 + p4, 0.f, 255.f);
- return convert_uchar4(p0);
-}
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/copy.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/copy.fs
deleted file mode 100644
index 6595874..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/copy.fs
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-uchar4 __attribute__((kernel)) root(uchar4 v_in) {
- return v_in;
-}
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/exposure.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/exposure.rs
deleted file mode 100644
index 0f05cb9..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/exposure.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-static float bright = 0.f;
-
-void setBright(float v) {
- bright = 255.f / (255.f - v);
-}
-
-void exposure(const uchar4 *in, uchar4 *out)
-{
- out->r = rsClamp((int)(bright * in->r), 0, 255);
- out->g = rsClamp((int)(bright * in->g), 0, 255);
- out->b = rsClamp((int)(bright * in->b), 0, 255);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye.rsh b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye.rsh
deleted file mode 100644
index 2eacb7d..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye.rsh
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-rs_allocation in_alloc;
-rs_sampler sampler;
-
-static float2 center, neg_center, inv_dimensions, axis_scale;
-static float alpha, radius2, factor;
-
-void init_filter(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y, float k) {
- center.x = center_x;
- center.y = center_y;
- neg_center = -center;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
- alpha = k * 2.0f + 0.75f;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float bound2 = 0.25f * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y);
- const float bound = sqrt(bound2);
- const float radius = 1.15f * bound;
- radius2 = radius*radius;
- const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2));
- factor = bound / max_radian;
-}
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float2 scaledCoord = axis_scale * coord;
- const float dist2 = scaledCoord.x*scaledCoord.x + scaledCoord.y*scaledCoord.y;
- const float inv_dist = rsqrt(dist2);
- const float radian = M_PI_2 - atan((alpha * sqrt(radius2 - dist2)) * inv_dist);
- const float scalar = radian * factor * inv_dist;
- const float2 new_coord = mad(coord, scalar, center);
- const float4 fout = rsSample(in_alloc, sampler, new_coord);
- return rsPackColorTo8888(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx.rsh b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx.rsh
deleted file mode 100644
index fcf0a3d..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx.rsh
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-rs_allocation in_alloc;
-rs_sampler sampler;
-
-static float2 center, neg_center, inv_dimensions, axis_scale;
-static float alpha, radius2, factor;
-
-void init_filter(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y, float k) {
- center.x = center_x;
- center.y = center_y;
- neg_center = -center;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
- alpha = k * 2.0f + 0.75f;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float bound2 = 0.25f * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y);
- const float bound = sqrt(bound2);
- const float radius = 1.15f * bound;
- radius2 = radius*radius;
- const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2));
- factor = bound / max_radian;
-}
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float2 scaledCoord = axis_scale * coord;
- const float dist2 = scaledCoord.x*scaledCoord.x + scaledCoord.y*scaledCoord.y;
- const float inv_dist = half_rsqrt(dist2);
- const float radian = M_PI_2 - atan((alpha * half_sqrt(radius2 - dist2)) * inv_dist);
- const float scalar = radian * factor * inv_dist;
- const float2 new_coord = mad(coord, scalar, center);
- const float4 fout = rsSample(in_alloc, sampler, new_coord);
- return rsPackColorTo8888(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx_full.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx_full.rs
deleted file mode 100644
index ed69ff4..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx_relaxed.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx_relaxed.fs
deleted file mode 100644
index ed69ff4..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_full.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_full.rs
deleted file mode 100644
index f986b5d..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_relaxed.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_relaxed.fs
deleted file mode 100644
index f986b5d..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/fisheye_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "fisheye.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/grain.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/grain.fs
deleted file mode 100644
index 2e62cd7..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/grain.fs
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-uchar __attribute__((kernel)) genRand() {
- return (uchar)rsRand(0xff);
-}
-
-/*
- * Convolution matrix of distance 2 with fixed point of 'kShiftBits' bits
- * shifted. Thus the sum of this matrix should be 'kShiftValue'. Entries of
- * small values are not calculated to gain efficiency.
- * The order ot pixels represented in this matrix is:
- * 1 2 3
- * 4 0 5
- * 6 7 8
- * and the matrix should be: {230, 56, 114, 56, 114, 114, 56, 114, 56}.
- * However, since most of the valus are identical, we only use the first three
- * entries and the entries corresponding to the pixels is:
- * 1 2 1
- * 2 0 2
- * 1 2 1
- */
-
-int32_t gWMask;
-int32_t gHMask;
-
-rs_allocation gBlendSource;
-uchar __attribute__((kernel)) blend9(uint32_t x, uint32_t y) {
- uint32_t x1 = (x-1) & gWMask;
- uint32_t x2 = (x+1) & gWMask;
- uint32_t y1 = (y-1) & gHMask;
- uint32_t y2 = (y+1) & gHMask;
-
- uint p00 = 56 * rsGetElementAt_uchar(gBlendSource, x1, y1);
- uint p01 = 114 * rsGetElementAt_uchar(gBlendSource, x, y1);
- uint p02 = 56 * rsGetElementAt_uchar(gBlendSource, x2, y1);
- uint p10 = 114 * rsGetElementAt_uchar(gBlendSource, x1, y);
- uint p11 = 230 * rsGetElementAt_uchar(gBlendSource, x, y);
- uint p12 = 114 * rsGetElementAt_uchar(gBlendSource, x2, y);
- uint p20 = 56 * rsGetElementAt_uchar(gBlendSource, x1, y2);
- uint p21 = 114 * rsGetElementAt_uchar(gBlendSource, x, y2);
- uint p22 = 56 * rsGetElementAt_uchar(gBlendSource, x2, y2);
-
- p00 += p01;
- p02 += p10;
- p11 += p12;
- p20 += p21;
-
- p22 += p00;
- p02 += p11;
-
- p20 += p22;
- p20 += p02;
-
- p20 = min(p20 >> 10, (uint)255);
- return (uchar)p20;
-}
-
-float gNoiseStrength;
-
-rs_allocation gNoise;
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- float4 ip = convert_float4(in);
- float pnoise = (float) rsGetElementAt_uchar(gNoise, x & gWMask, y & gHMask);
-
- float energy_level = ip.r + ip.g + ip.b;
- float energy_mask = (28.f - sqrt(energy_level)) * 0.03571f;
- pnoise = (pnoise - 128.f) * energy_mask;
-
- ip += pnoise * gNoiseStrength;
- ip = clamp(ip, 0.f, 255.f);
-
- uchar4 p = convert_uchar4(ip);
- p.a = 0xff;
- return p;
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/greyscale.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/greyscale.fs
deleted file mode 100644
index 4e13072..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/greyscale.fs
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
-
-uchar4 __attribute__((kernel)) root(uchar4 v_in) {
- float4 f4 = rsUnpackColor8888(v_in);
-
- float3 mono = dot(f4.rgb, gMonoMult);
- return rsPackColorTo8888(mono);
-}
-
-uchar __attribute__((kernel)) toU8(uchar4 v_in) {
- float4 f4 = convert_float4(v_in);
- return (uchar)dot(f4.rgb, gMonoMult);
-}
-
-uchar4 __attribute__((kernel)) toU8_4(uchar v_in) {
- return (uchar4)v_in;
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/ip.rsh b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/ip.rsh
deleted file mode 100644
index 8124211..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/ip.rsh
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#pragma version(1)
-#pragma rs java_package_name(com.android.rs.imagejb)
-
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/levels.rsh b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/levels.rsh
deleted file mode 100644
index e289906..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/levels.rsh
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-float inBlack;
-float outBlack;
-float inWMinInB;
-float outWMinOutB;
-float overInWMinInB;
-rs_matrix3x3 colorMat;
-
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- uchar4 out;
- float3 pixel = convert_float4(in).rgb;
- pixel = rsMatrixMultiply(&colorMat, pixel);
- pixel = clamp(pixel, 0.f, 255.f);
- pixel = (pixel - inBlack) * overInWMinInB;
- pixel = pixel * outWMinOutB + outBlack;
- pixel = clamp(pixel, 0.f, 255.f);
- out.xyz = convert_uchar3(pixel);
- out.w = 0xff;
- return out;
-}
-
-uchar4 __attribute__((kernel)) root4(uchar4 in, uint32_t x, uint32_t y) {
- float4 pixel = convert_float4(in);
- pixel.rgb = rsMatrixMultiply(&colorMat, pixel.rgb);
- pixel = clamp(pixel, 0.f, 255.f);
- pixel = (pixel - inBlack) * overInWMinInB;
- pixel = pixel * outWMinOutB + outBlack;
- pixel = clamp(pixel, 0.f, 255.f);
- return convert_uchar4(pixel);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/levels_full.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/levels_full.rs
deleted file mode 100644
index 28596ba..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/levels_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "levels.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/levels_relaxed.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/levels_relaxed.fs
deleted file mode 100644
index 28596ba..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/levels_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "levels.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/mandelbrot.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/mandelbrot.rs
deleted file mode 100644
index de0bd00..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/mandelbrot.rs
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (C) 2011 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.
-
-#include "ip.rsh"
-
-uint32_t gMaxIteration = 500;
-uint32_t gDimX = 1024;
-uint32_t gDimY = 1024;
-
-float lowerBoundX = -2.f;
-float lowerBoundY = -2.f;
-float scaleFactor = 4.f;
-
-uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
- float2 p;
- p.x = lowerBoundX + ((float)x / gDimX) * scaleFactor;
- p.y = lowerBoundY + ((float)y / gDimY) * scaleFactor;
-
- float2 t = 0;
- float2 t2 = t * t;
- int iter = 0;
- while((t2.x + t2.y < 4.f) && (iter < gMaxIteration)) {
- float xtemp = t2.x - t2.y + p.x;
- t.y = 2 * t.x * t.y + p.y;
- t.x = xtemp;
- iter++;
- t2 = t * t;
- }
-
- if(iter >= gMaxIteration) {
- // write a non-transparent black pixel
- return (uchar4){0, 0, 0, 0xff};
- } else {
- float mi3 = gMaxIteration / 3.f;
- if (iter <= (gMaxIteration / 3))
- return (uchar4){0xff * (iter / mi3), 0, 0, 0xff};
- else if (iter <= (((gMaxIteration / 3) * 2)))
- return (uchar4){0xff - (0xff * ((iter - mi3) / mi3)),
- (0xff * ((iter - mi3) / mi3)), 0, 0xff};
- else
- return (uchar4){0, 0xff - (0xff * ((iter - (mi3 * 2)) / mi3)),
- (0xff * ((iter - (mi3 * 2)) / mi3)), 0xff};
- }
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/msg.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/msg.rs
deleted file mode 100644
index 645eb98..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/msg.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#pragma version(1)
-#pragma rs java_package_name(com.android.rs.imagejb)
-
-void sendMsg() {
- rsSendToClientBlocking(0);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs
deleted file mode 100644
index f6c149d..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-//#pragma rs_fp_relaxed
-
-static double shadowFilterMap[] = {
- -0.00591, 0.0001,
- 1.16488, 0.01668,
- -0.18027, -0.06791,
- -0.12625, 0.09001,
- 0.15065, -0.03897
-};
-
-static double poly[] = {
- 0., 0.,
- 0., 0.,
- 0.
-};
-
-static const int ABITS = 4;
-static const int HSCALE = 256;
-static const int k1=255 << ABITS;
-static const int k2=HSCALE << ABITS;
-
-static double fastevalPoly(double *poly,int n, double x){
-
- double f =x;
- double sum = poly[0]+poly[1]*f;
- int i;
- for (i = 2; i < n; i++) {
- f*=x;
- sum += poly[i]*f;
- }
- return sum;
-}
-
-static ushort3 rgb2hsv( uchar4 rgb)
-{
- int iMin,iMax,chroma;
-
- int ri = rgb.r;
- int gi = rgb.g;
- int bi = rgb.b;
- short rv,rs,rh;
-
- if (ri > gi) {
- iMax = max (ri, bi);
- iMin = min (gi, bi);
- } else {
- iMax = max (gi, bi);
- iMin = min (ri, bi);
- }
-
- chroma = iMax - iMin;
- // set value
- rv = (short)( iMax << ABITS);
-
- // set saturation
- if (rv == 0)
- rs = 0;
- else
- rs = (short)((k1*chroma)/iMax);
-
- // set hue
- if (rs == 0)
- rh = 0;
- else {
- if ( ri == iMax ) {
- rh = (short)( (k2*(6*chroma+gi - bi))/(6*chroma));
- if (rh >= k2) rh -= k2;
- } else if (gi == iMax)
- rh = (short)( (k2*(2*chroma+bi - ri ))/(6*chroma));
- else // (bi == iMax )
- rh = (short)( (k2*(4*chroma+ri - gi ))/(6*chroma));
- }
-
- ushort3 out;
- out.x = rv;
- out.y = rs;
- out.z = rh;
- return out;
-}
-
-static uchar4 hsv2rgb(ushort3 hsv)
-{
- int ABITS = 4;
- int HSCALE = 256;
- int m;
- int H,X,ih,is,iv;
- int k1=255<<ABITS;
- int k2=HSCALE<<ABITS;
- int k3=1<<(ABITS-1);
- int rr=0;
- int rg=0;
- int rb=0;
- short cv = hsv.x;
- short cs = hsv.y;
- short ch = hsv.z;
-
- // set chroma and min component value m
- //chroma = ( cv * cs )/k1;
- //m = cv - chroma;
- m = ((int)cv*(k1 - (int)cs ))/k1;
-
- // chroma == 0 <-> cs == 0 --> m=cv
- if (cs == 0) {
- rb = ( rg = ( rr =( cv >> ABITS) ));
- } else {
- ih=(int)ch;
- is=(int)cs;
- iv=(int)cv;
-
- H = (6*ih)/k2;
- X = ((iv*is)/k2)*(k2- abs(6*ih- 2*(H>>1)*k2 - k2)) ;
-
- // removing additional bits --> unit8
- X=( (X+iv*(k1 - is ))/k1 + k3 ) >> ABITS;
- m=m >> ABITS;
-
- // ( chroma + m ) --> cv ;
- cv=(short) (cv >> ABITS);
- switch (H) {
- case 0:
- rr = cv;
- rg = X;
- rb = m;
- break;
- case 1:
- rr = X;
- rg = cv;
- rb = m;
- break;
- case 2:
- rr = m;
- rg = cv;
- rb = X;
- break;
- case 3:
- rr = m;
- rg = X;
- rb = cv;
- break;
- case 4:
- rr = X;
- rg = m;
- rb = cv;
- break;
- case 5:
- rr = cv;
- rg = m ;
- rb = X;
- break;
- }
- }
-
- uchar4 rgb;
-
- rgb.r = rr;
- rgb.g = rg;
- rgb.b = rb;
-
- return rgb;
-}
-
-void prepareShadows(float scale) {
- double s = (scale>=0)?scale:scale/5;
- for (int i = 0; i < 5; i++) {
- poly[i] = fastevalPoly(shadowFilterMap+i*2,2 , s);
- }
-}
-
-void shadowsKernel(const uchar4 *in, uchar4 *out) {
- ushort3 hsv = rgb2hsv(*in);
- double v = (fastevalPoly(poly,5,hsv.x/4080.)*4080);
- if (v>4080) v = 4080;
- hsv.x = (unsigned short) ((v>0)?v:0);
- *out = hsv2rgb(hsv);
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/threshold.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/threshold.fs
deleted file mode 100644
index 0b2c2e8..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/threshold.fs
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#include "ip.rsh"
-
-
-int height;
-int width;
-static int radius;
-
-rs_allocation InPixel;
-rs_allocation ScratchPixel1;
-rs_allocation ScratchPixel2;
-
-const int MAX_RADIUS = 25;
-
-// Store our coefficients here
-static float gaussian[MAX_RADIUS * 2 + 1];
-
-void setRadius(int rad) {
- radius = rad;
- // Compute gaussian weights for the blur
- // e is the euler's number
- float e = 2.718281828459045f;
- float pi = 3.1415926535897932f;
- // g(x) = ( 1 / sqrt( 2 * pi ) * sigma) * e ^ ( -x^2 / 2 * sigma^2 )
- // x is of the form [-radius .. 0 .. radius]
- // and sigma varies with radius.
- // Based on some experimental radius values and sigma's
- // we approximately fit sigma = f(radius) as
- // sigma = radius * 0.4 + 0.6
- // The larger the radius gets, the more our gaussian blur
- // will resemble a box blur since with large sigma
- // the gaussian curve begins to lose its shape
- float sigma = 0.4f * (float)radius + 0.6f;
-
- // Now compute the coefficints
- // We will store some redundant values to save some math during
- // the blur calculations
- // precompute some values
- float coeff1 = 1.0f / (sqrt( 2.0f * pi ) * sigma);
- float coeff2 = - 1.0f / (2.0f * sigma * sigma);
-
- float normalizeFactor = 0.0f;
- float floatR = 0.0f;
- for (int r = -radius; r <= radius; r ++) {
- floatR = (float)r;
- gaussian[r + radius] = coeff1 * pow(e, floatR * floatR * coeff2);
- normalizeFactor += gaussian[r + radius];
- }
-
- //Now we need to normalize the weights because all our coefficients need to add up to one
- normalizeFactor = 1.0f / normalizeFactor;
- for (int r = -radius; r <= radius; r ++) {
- floatR = (float)r;
- gaussian[r + radius] *= normalizeFactor;
- }
-}
-
-float4 __attribute__((kernel)) copyIn(uchar4 in) {
- return convert_float4(in);
-}
-
-uchar4 __attribute__((kernel)) vert(uint32_t x, uint32_t y) {
- float3 blurredPixel = 0;
- int gi = 0;
- uchar4 out;
- if ((y > radius) && (y < (height - radius))) {
- for (int r = -radius; r <= radius; r ++) {
- float4 i = rsGetElementAt_float4(ScratchPixel2, x, y + r);
- blurredPixel += i.xyz * gaussian[gi++];
- }
- } else {
- for (int r = -radius; r <= radius; r ++) {
- int validH = rsClamp((int)y + r, (int)0, (int)(height - 1));
- float4 i = rsGetElementAt_float4(ScratchPixel2, x, validH);
- blurredPixel += i.xyz * gaussian[gi++];
- }
- }
-
- out.xyz = convert_uchar3(clamp(blurredPixel, 0.f, 255.f));
- out.w = 0xff;
- return out;
-}
-
-float4 __attribute__((kernel)) horz(uint32_t x, uint32_t y) {
- float4 blurredPixel = 0;
- int gi = 0;
- if ((x > radius) && (x < (width - radius))) {
- for (int r = -radius; r <= radius; r ++) {
- float4 i = rsGetElementAt_float4(ScratchPixel1, x + r, y);
- blurredPixel += i * gaussian[gi++];
- }
- } else {
- for (int r = -radius; r <= radius; r ++) {
- // Stepping left and right away from the pixel
- int validX = rsClamp((int)x + r, (int)0, (int)(width - 1));
- float4 i = rsGetElementAt_float4(ScratchPixel1, validX, y);
- blurredPixel += i * gaussian[gi++];
- }
- }
-
- return blurredPixel;
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vibrance.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vibrance.rs
deleted file mode 100644
index 8db113c..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vibrance.rs
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-float vibrance = 0.f;
-
-static const float Rf = 0.2999f;
-static const float Gf = 0.587f;
-static const float Bf = 0.114f;
-
-static float S = 0.f;
-static float MS = 0.f;
-static float Rt = 0.f;
-static float Gt = 0.f;
-static float Bt = 0.f;
-static float Vib = 0.f;
-
-void vibranceKernel(const uchar4 *in, uchar4 *out) {
-
- float R, G, B;
-
- int r = in->r;
- int g = in->g;
- int b = in->b;
- float red = (r-max(g, b))/256.f;
- float sx = (float)(Vib/(1+exp(-red*3)));
- S = sx+1;
- MS = 1.0f - S;
- Rt = Rf * MS;
- Gt = Gf * MS;
- Bt = Bf * MS;
- int t = (r + g) / 2;
- R = r;
- G = g;
- B = b;
-
- float Rc = R * (Rt + S) + G * Gt + B * Bt;
- float Gc = R * Rt + G * (Gt + S) + B * Bt;
- float Bc = R * Rt + G * Gt + B * (Bt + S);
-
- out->r = rsClamp(Rc, 0, 255);
- out->g = rsClamp(Gc, 0, 255);
- out->b = rsClamp(Bc, 0, 255);
-
-}
-
-void prepareVibrance() {
-
- Vib = vibrance/100.f;
- S = Vib + 1;
- MS = 1.0f - S;
- Rt = Rf * MS;
- Gt = Gf * MS;
- Bt = Bf * MS;
-
-}
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette.rsh b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette.rsh
deleted file mode 100644
index 04ca1f1..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette.rsh
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-static float2 neg_center, axis_scale, inv_dimensions;
-static float sloped_neg_range, sloped_inv_max_dist, shade, opp_shade;
-
-void init_vignette(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y,
- float desired_scale, float desired_shade, float desired_slope) {
-
- neg_center.x = -center_x;
- neg_center.y = -center_y;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float max_dist = 0.5f * length(axis_scale);
- sloped_inv_max_dist = desired_slope * 1.f/max_dist;
-
- // Range needs to be between 1.3 to 0.6. When scale is zero then range is
- // 1.3 which means no vignette at all because the luminousity difference is
- // less than 1/256. Expect input scale to be between 0.0 and 1.0.
- const float neg_range = 0.7f*sqrt(desired_scale) - 1.3f;
- sloped_neg_range = exp(neg_range * desired_slope);
-
- shade = desired_shade;
- opp_shade = 1.f - desired_shade;
-}
-
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float4 fin = convert_float4(in);
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float sloped_dist_ratio = length(axis_scale * coord) * sloped_inv_max_dist;
- const float lumen = opp_shade + shade / ( 1.0f + sloped_neg_range * exp(sloped_dist_ratio) );
- float4 fout;
- fout.rgb = fin.rgb * lumen;
- fout.w = fin.w;
- return convert_uchar4(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx.rsh b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx.rsh
deleted file mode 100644
index 0eacdc8..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx.rsh
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-static float2 neg_center, axis_scale, inv_dimensions;
-static float sloped_neg_range, sloped_inv_max_dist, shade, opp_shade;
-
-void init_vignette(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y,
- float desired_scale, float desired_shade, float desired_slope) {
-
- neg_center.x = -center_x;
- neg_center.y = -center_y;
- inv_dimensions.x = 1.f / (float)dim_x;
- inv_dimensions.y = 1.f / (float)dim_y;
-
- axis_scale = (float2)1.f;
- if (dim_x > dim_y)
- axis_scale.y = (float)dim_y / (float)dim_x;
- else
- axis_scale.x = (float)dim_x / (float)dim_y;
-
- const float max_dist = 0.5f * length(axis_scale);
- sloped_inv_max_dist = desired_slope * 1.f/max_dist;
-
- // Range needs to be between 1.3 to 0.6. When scale is zero then range is
- // 1.3 which means no vignette at all because the luminousity difference is
- // less than 1/256. Expect input scale to be between 0.0 and 1.0.
- const float neg_range = 0.7f*sqrt(desired_scale) - 1.3f;
- sloped_neg_range = exp(neg_range * desired_slope);
-
- shade = desired_shade;
- opp_shade = 1.f - desired_shade;
-}
-
-uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
- // Convert x and y to floating point coordinates with center as origin
- const float4 fin = convert_float4(in);
- const float2 inCoord = {(float)x, (float)y};
- const float2 coord = mad(inCoord, inv_dimensions, neg_center);
- const float sloped_dist_ratio = fast_length(axis_scale * coord) * sloped_inv_max_dist;
- const float lumen = opp_shade + shade * half_recip(1.f + sloped_neg_range * exp(sloped_dist_ratio));
- float4 fout;
- fout.rgb = fin.rgb * lumen;
- fout.w = fin.w;
- return convert_uchar4(fout);
-}
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx_full.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx_full.rs
deleted file mode 100644
index 00cbbc4..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx_relaxed.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx_relaxed.fs
deleted file mode 100644
index 00cbbc4..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette_approx.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_full.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_full.rs
deleted file mode 100644
index 8202c5c..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_relaxed.fs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_relaxed.fs
deleted file mode 100644
index 8202c5c..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/vignette_relaxed.fs
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-
-#include "vignette.rsh"
-
diff --git a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/wbalance.rs b/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/wbalance.rs
deleted file mode 100644
index 6650671..0000000
--- a/tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/wbalance.rs
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "ip.rsh"
-//#pragma rs_fp_relaxed
-
-static int histR[256] = {0}, histG[256] = {0}, histB[256] = {0};
-
-rs_allocation histogramSource;
-uint32_t histogramHeight;
-uint32_t histogramWidth;
-
-static float scaleR;
-static float scaleG;
-static float scaleB;
-
-static uchar4 estimateWhite() {
-
- for (int i = 0; i < 256; i++) {
- histR[i] = 0; histG[i] = 0; histB[i] = 0;
- }
-
- for (uint32_t i = 0; i < histogramHeight; i++) {
- for (uint32_t j = 0; j < histogramWidth; j++) {
- uchar4 in = rsGetElementAt_uchar4(histogramSource, j, i);
- histR[in.r]++;
- histG[in.g]++;
- histB[in.b]++;
- }
- }
-
- int min_r = -1, min_g = -1, min_b = -1;
- int max_r = 0, max_g = 0, max_b = 0;
- int sum_r = 0, sum_g = 0, sum_b = 0;
-
- for (int i = 1; i < 255; i++) {
- int r = histR[i];
- int g = histG[i];
- int b = histB[i];
- sum_r += r;
- sum_g += g;
- sum_b += b;
-
- if (r>0){
- if (min_r < 0) min_r = i;
- max_r = i;
- }
- if (g>0){
- if (min_g < 0) min_g = i;
- max_g = i;
- }
- if (b>0){
- if (min_b < 0) min_b = i;
- max_b = i;
- }
- }
-
- int sum15r = 0, sum15g = 0, sum15b = 0;
- int count15r = 0, count15g = 0, count15b = 0;
- int tmp_r = 0, tmp_g = 0, tmp_b = 0;
-
- for (int i = 254; i >0; i--) {
- int r = histR[i];
- int g = histG[i];
- int b = histB[i];
- tmp_r += r;
- tmp_g += g;
- tmp_b += b;
-
- if ((tmp_r > sum_r/20) && (tmp_r < sum_r/5)) {
- sum15r += r*i;
- count15r += r;
- }
- if ((tmp_g > sum_g/20) && (tmp_g < sum_g/5)) {
- sum15g += g*i;
- count15g += g;
- }
- if ((tmp_b > sum_b/20) && (tmp_b < sum_b/5)) {
- sum15b += b*i;
- count15b += b;
- }
-
- }
-
- uchar4 out;
-
- if ((count15r>0) && (count15g>0) && (count15b>0) ){
- out.r = sum15r/count15r;
- out.g = sum15g/count15g;
- out.b = sum15b/count15b;
- }else {
- out.r = out.g = out.b = 255;
- }
-
- return out;
-
-}
-
-void prepareWhiteBalance() {
- uchar4 estimation = estimateWhite();
- int minimum = min(estimation.r, min(estimation.g, estimation.b));
- int maximum = max(estimation.r, max(estimation.g, estimation.b));
- float avg = (minimum + maximum) / 2.f;
-
- scaleR = avg/estimation.r;
- scaleG = avg/estimation.g;
- scaleB = avg/estimation.b;
-
-}
-
-static unsigned char contrastClamp(int c)
-{
- int N = 255;
- c &= ~(c >> 31);
- c -= N;
- c &= (c >> 31);
- c += N;
- return (unsigned char) c;
-}
-
-void whiteBalanceKernel(const uchar4 *in, uchar4 *out) {
- float Rc = in->r*scaleR;
- float Gc = in->g*scaleG;
- float Bc = in->b*scaleB;
-
- out->r = contrastClamp(Rc);
- out->g = contrastClamp(Gc);
- out->b = contrastClamp(Bc);
-}
diff --git a/tests/RenderScriptTests/LatencyBenchmark/Android.mk b/tests/RenderScriptTests/LatencyBenchmark/Android.mk
deleted file mode 100644
index ef2164d..0000000
--- a/tests/RenderScriptTests/LatencyBenchmark/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2012 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
- $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := RsLatencyBenchmark
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/LatencyBenchmark/AndroidManifest.xml b/tests/RenderScriptTests/LatencyBenchmark/AndroidManifest.xml
deleted file mode 100644
index 923bb88..0000000
--- a/tests/RenderScriptTests/LatencyBenchmark/AndroidManifest.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.rs.latencybench">
-
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-sdk android:minSdkVersion="17" />
- <application android:label="_RS_Latency_Bench">
- <activity android:name="LatencyBench">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/LatencyBenchmark/res/layout/main.xml b/tests/RenderScriptTests/LatencyBenchmark/res/layout/main.xml
deleted file mode 100644
index 9e9dab8..0000000
--- a/tests/RenderScriptTests/LatencyBenchmark/res/layout/main.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ImageView
- android:id="@+id/displayin"
- android:layout_width="320dip"
- android:layout_height="266dip" />
-
- <ImageView
- android:id="@+id/displayout"
- android:layout_width="320dip"
- android:layout_height="266dip" />
-
-</LinearLayout>
diff --git a/tests/RenderScriptTests/LatencyBenchmark/src/com/example/android/rs/computebench/Benchmark.java b/tests/RenderScriptTests/LatencyBenchmark/src/com/example/android/rs/computebench/Benchmark.java
deleted file mode 100644
index ee14fb9..0000000
--- a/tests/RenderScriptTests/LatencyBenchmark/src/com/example/android/rs/computebench/Benchmark.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2012 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.example.android.rs.latencybench;
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class Benchmark implements Runnable {
- private final RenderScript mRS;
- private ScriptC_compute_benchmark mScript;
- private Allocation ain;
- private Allocation aout;
-
- public Benchmark(RenderScript rs, Resources res) {
- mRS = rs;
- mScript = new ScriptC_compute_benchmark(mRS, res, R.raw.compute_benchmark);
- ain = Allocation.createSized(rs, Element.U32(mRS), 10000);
- aout = Allocation.createSized(rs, Element.U32(mRS), 10000);
- }
-
- public void run() {
- int[] temp;
- temp = new int[1];
-
- long t = java.lang.System.currentTimeMillis();
-
- for (int i = 0; i < 1000000; i++)
- mScript.forEach_root(ain, aout);
- aout.copy1DRangeFrom(0, 1, temp);
-
- t = java.lang.System.currentTimeMillis() - t;
- android.util.Log.v("LatencyBench", "Iterated Java forEach took " + t + " ms");
-
- mScript.set_empty_kern(mScript);
- mScript.set_in(ain);
- mScript.set_out(aout);
-
- t = java.lang.System.currentTimeMillis();
- mScript.invoke_emptyKernelLauncher();
- aout.copy1DRangeFrom(0, 1, temp);
-
- t = java.lang.System.currentTimeMillis() - t;
- android.util.Log.v("LatencyBench", "Invoked forEach took " + t + " ms");
-
-
-
- }
-
-}
diff --git a/tests/RenderScriptTests/LatencyBenchmark/src/com/example/android/rs/computebench/LatencyBench.java b/tests/RenderScriptTests/LatencyBenchmark/src/com/example/android/rs/computebench/LatencyBench.java
deleted file mode 100644
index fdce9a7..0000000
--- a/tests/RenderScriptTests/LatencyBenchmark/src/com/example/android/rs/computebench/LatencyBench.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 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.example.android.rs.latencybench;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.renderscript.RenderScript;
-
-public class LatencyBench extends Activity {
- private RenderScript mRS;
- private Benchmark mBenchmark;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- mRS = RenderScript.create(this);
-
- mBenchmark = new Benchmark(mRS, getResources());
- mBenchmark.run();
- }
-}
diff --git a/tests/RenderScriptTests/LatencyBenchmark/src/com/example/android/rs/computebench/compute_benchmark.rs b/tests/RenderScriptTests/LatencyBenchmark/src/com/example/android/rs/computebench/compute_benchmark.rs
deleted file mode 100644
index c6d1ea9..0000000
--- a/tests/RenderScriptTests/LatencyBenchmark/src/com/example/android/rs/computebench/compute_benchmark.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2012 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.
-
-#pragma version(1)
-#pragma rs java_package_name(com.example.android.rs.latencybench)
-
-rs_script empty_kern;
-rs_allocation in, out;
-int iters = 1000000;
-
-void root(const uint32_t *ain, uint32_t *aout) {
-
-}
-
-void emptyKernelLauncher() {
- for (int i = 0; i < iters; i++)
- rsForEach(empty_kern, in, out);
-}
diff --git a/tests/RenderScriptTests/LivePreview/Android.mk b/tests/RenderScriptTests/LivePreview/Android.mk
deleted file mode 100644
index 1b45573..0000000
--- a/tests/RenderScriptTests/LivePreview/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2012 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := PreviewRS
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/LivePreview/AndroidManifest.xml b/tests/RenderScriptTests/LivePreview/AndroidManifest.xml
deleted file mode 100644
index 1b91464..0000000
--- a/tests/RenderScriptTests/LivePreview/AndroidManifest.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2012 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.
-*/
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.rs.livepreview">
- <uses-sdk android:minSdkVersion="14" />
- <uses-permission android:name="android.permission.CAMERA" />
- <application android:label="Preview FS"
- android:hardwareAccelerated="true">
-
- <activity android:name="CameraPreviewActivity"
- android:label="Preview FS"
- android:screenOrientation="landscape">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/LivePreview/res/drawable-nodpi/city.png b/tests/RenderScriptTests/LivePreview/res/drawable-nodpi/city.png
deleted file mode 100644
index 856eeff..0000000
--- a/tests/RenderScriptTests/LivePreview/res/drawable-nodpi/city.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/LivePreview/res/layout/cf_format_list_item.xml b/tests/RenderScriptTests/LivePreview/res/layout/cf_format_list_item.xml
deleted file mode 100644
index 8196bbf..0000000
--- a/tests/RenderScriptTests/LivePreview/res/layout/cf_format_list_item.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 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.
--->
-
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:padding="10dp"
- android:textSize="16sp"
-/>
diff --git a/tests/RenderScriptTests/LivePreview/res/layout/cf_main.xml b/tests/RenderScriptTests/LivePreview/res/layout/cf_main.xml
deleted file mode 100644
index ecb736b..0000000
--- a/tests/RenderScriptTests/LivePreview/res/layout/cf_main.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2012 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="0dp"
- android:layout_height="fill_parent"
- android:layout_weight="3" >
-
- <TextureView
- android:id="@+id/preview_view"
- android:layout_height="0dp"
- android:layout_width="fill_parent"
- android:layout_weight="3" />
- <TextView
- android:id="@+id/preview_label"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:text="@string/cf_preview_label"
- android:padding="2dp"
- android:textSize="16sp"
- android:gravity="center" />
-
- </LinearLayout>
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="0dp"
- android:layout_height="fill_parent"
- android:layout_weight="3" >
-
- <TextureView
- android:id="@+id/format_view"
- android:layout_height="0dp"
- android:layout_width="fill_parent"
- android:layout_weight="3" />
- <TextView
- android:id="@+id/format_label"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:text="@string/cf_format_label"
- android:padding="2dp"
- android:textSize="16sp"
- android:gravity="center" />
-
- </LinearLayout>
-
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="0dp"
- android:layout_height="fill_parent"
- android:layout_weight="2" >
-
- <Spinner
- android:id="@+id/cameras_selection"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
- <Spinner
- android:id="@+id/resolution_selection"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
- <Spinner
- android:id="@+id/format_selection"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
-
- </LinearLayout>
-
- </LinearLayout>
-
-
-</LinearLayout>
diff --git a/tests/RenderScriptTests/LivePreview/res/layout/main.xml b/tests/RenderScriptTests/LivePreview/res/layout/main.xml
deleted file mode 100644
index a6a075c..0000000
--- a/tests/RenderScriptTests/LivePreview/res/layout/main.xml
+++ /dev/null
@@ -1,140 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:id="@+id/toplevel">
- <SurfaceView
- android:id="@+id/surface"
- android:layout_width="1dip"
- android:layout_height="1dip" />
- <ScrollView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <ImageView
- android:id="@+id/display"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/benchmark"
- android:onClick="benchmark"/>
- <TextView
- android:id="@+id/benchmarkText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:text="@string/saturation"/>
- </LinearLayout>
- <TextView
- android:id="@+id/inSaturationText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/saturation"/>
- <SeekBar
- android:id="@+id/inSaturation"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/outWhiteText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:textSize="8pt"
- android:text="@string/out_white"/>
- <SeekBar
- android:id="@+id/outWhite"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/inWhiteText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/in_white"/>
- <SeekBar
- android:id="@+id/inWhite"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/outBlackText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/out_black"/>
- <SeekBar
- android:id="@+id/outBlack"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/inBlackText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/in_black"/>
- <SeekBar
- android:id="@+id/inBlack"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/inGammaText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/gamma"/>
- <SeekBar
- android:id="@+id/inGamma"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- </LinearLayout>
- </ScrollView>
-</LinearLayout>
-
diff --git a/tests/RenderScriptTests/LivePreview/res/layout/rs.xml b/tests/RenderScriptTests/LivePreview/res/layout/rs.xml
deleted file mode 100644
index 6fde1b9..0000000
--- a/tests/RenderScriptTests/LivePreview/res/layout/rs.xml
+++ /dev/null
@@ -1,140 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:id="@+id/toplevel">
- <SurfaceView
- android:id="@+id/surface"
- android:layout_width="1dip"
- android:layout_height="1dip" />
- <ScrollView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <TextureView
- android:id="@+id/display"
- android:layout_width="800sp"
- android:layout_height="423sp" />
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/benchmark"
- android:onClick="benchmark"/>
- <TextView
- android:id="@+id/benchmarkText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:text="@string/saturation"/>
- </LinearLayout>
- <TextView
- android:id="@+id/inSaturationText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/saturation"/>
- <SeekBar
- android:id="@+id/inSaturation"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/outWhiteText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:textSize="8pt"
- android:text="@string/out_white"/>
- <SeekBar
- android:id="@+id/outWhite"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/inWhiteText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/in_white"/>
- <SeekBar
- android:id="@+id/inWhite"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/outBlackText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/out_black"/>
- <SeekBar
- android:id="@+id/outBlack"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/inBlackText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/in_black"/>
- <SeekBar
- android:id="@+id/inBlack"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/inGammaText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:layout_marginLeft="10sp"
- android:layout_marginTop="15sp"
- android:text="@string/gamma"/>
- <SeekBar
- android:id="@+id/inGamma"
- android:layout_marginLeft="10sp"
- android:layout_marginRight="10sp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- </LinearLayout>
- </ScrollView>
-</LinearLayout>
-
diff --git a/tests/RenderScriptTests/LivePreview/res/values/strings.xml b/tests/RenderScriptTests/LivePreview/res/values/strings.xml
deleted file mode 100644
index d651bfb..0000000
--- a/tests/RenderScriptTests/LivePreview/res/values/strings.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-<resources>
- <string name="in_white">In White</string>
- <string name="out_white">Out White</string>
- <string name="in_black">In Black</string>
- <string name="out_black">Out Black</string>
- <string name="gamma">Gamma</string>
- <string name="saturation">Saturation</string>
- <string name="benchmark">Benchmark</string>
-
- <string name="app_name">CTS Verifier</string>
- <string name="welcome_text">Welcome to the CTS Verifier!</string>
- <string name="version_text">%1$s</string>
- <string name="continue_button_text">Continue</string>
-
- <string name="cf_preview_label">Normal preview</string>
- <string name="cf_format_label">Processed callback data</string>
- <string name="camera_format">Camera Formats</string>
-
-
-</resources>
diff --git a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/CameraPreviewActivity.java b/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/CameraPreviewActivity.java
deleted file mode 100644
index 62dcaa8..0000000
--- a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/CameraPreviewActivity.java
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.livepreview;
-
-//import com.android.cts.verifier.PassFailButtons;
-//import com.android.cts.verifier.R;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.graphics.Bitmap;
-import android.graphics.Color;
-import android.graphics.ColorMatrix;
-import android.graphics.ColorMatrixColorFilter;
-import android.graphics.ImageFormat;
-import android.graphics.Matrix;
-import android.graphics.SurfaceTexture;
-import android.hardware.Camera;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.os.Handler;
-import android.util.Log;
-import android.util.SparseArray;
-import android.view.View;
-import android.view.TextureView;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.Spinner;
-
-import java.io.IOException;
-import java.lang.InterruptedException;
-import java.lang.Math;
-import java.lang.Thread;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.TreeSet;
-
-import android.renderscript.*;
-
-/**
- * Tests for manual verification of the CDD-required camera output formats
- * for preview callbacks
- */
-public class CameraPreviewActivity extends Activity
- implements TextureView.SurfaceTextureListener, Camera.PreviewCallback {
-
- private static final String TAG = "CameraFormats";
-
- private TextureView mPreviewView;
- private SurfaceTexture mPreviewTexture;
- private int mPreviewTexWidth;
- private int mPreviewTexHeight;
-
- //private TextureView mFormatView;
-
- private Spinner mCameraSpinner;
- private Spinner mResolutionSpinner;
-
- private int mCurrentCameraId = -1;
- private Camera mCamera;
-
- private List<Camera.Size> mPreviewSizes;
- private Camera.Size mNextPreviewSize;
- private Camera.Size mPreviewSize;
-
- private TextureView mOutputView;
- //private Bitmap mCallbackBitmap;
-
- private static final int STATE_OFF = 0;
- private static final int STATE_PREVIEW = 1;
- private static final int STATE_NO_CALLBACKS = 2;
- private int mState = STATE_OFF;
- private boolean mProcessInProgress = false;
- private boolean mProcessingFirstFrame = false;
-
-
- private RenderScript mRS;
- private RsYuv mFilterYuv;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.cf_main);
-
- mPreviewView = (TextureView) findViewById(R.id.preview_view);
- mOutputView = (TextureView) findViewById(R.id.format_view);
-
- mPreviewView.setSurfaceTextureListener(this);
-
- int numCameras = Camera.getNumberOfCameras();
- String[] cameraNames = new String[numCameras];
- for (int i = 0; i < numCameras; i++) {
- cameraNames[i] = "Camera " + i;
- }
- mCameraSpinner = (Spinner) findViewById(R.id.cameras_selection);
- mCameraSpinner.setAdapter(
- new ArrayAdapter<String>(
- this, R.layout.cf_format_list_item, cameraNames));
- mCameraSpinner.setOnItemSelectedListener(mCameraSpinnerListener);
-
- mResolutionSpinner = (Spinner) findViewById(R.id.resolution_selection);
- mResolutionSpinner.setOnItemSelectedListener(mResolutionSelectedListener);
-
- mRS = RenderScript.create(this);
- mFilterYuv = new RsYuv(mRS);
- mOutputView.setSurfaceTextureListener(mFilterYuv);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- setUpCamera(mCameraSpinner.getSelectedItemPosition());
- }
-
- @Override
- public void onPause() {
- super.onPause();
-
- shutdownCamera();
- }
-
- public void onSurfaceTextureAvailable(SurfaceTexture surface,
- int width, int height) {
- mPreviewTexture = surface;
- mPreviewTexWidth = width;
- mPreviewTexHeight = height;
- if (mCamera != null) {
- startPreview();
- }
- }
-
- public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
- // Ignored, Camera does all the work for us
- }
-
- public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
- return true;
- }
-
- public void onSurfaceTextureUpdated(SurfaceTexture surface) {
- // Invoked every time there's a new Camera preview frame
- }
-
- private AdapterView.OnItemSelectedListener mCameraSpinnerListener =
- new AdapterView.OnItemSelectedListener() {
- public void onItemSelected(AdapterView<?> parent,
- View view, int pos, long id) {
- if (mCurrentCameraId != pos) {
- setUpCamera(pos);
- }
- }
-
- public void onNothingSelected(AdapterView parent) {
-
- }
-
- };
-
- private AdapterView.OnItemSelectedListener mResolutionSelectedListener =
- new AdapterView.OnItemSelectedListener() {
- public void onItemSelected(AdapterView<?> parent,
- View view, int position, long id) {
- if (mPreviewSizes.get(position) != mPreviewSize) {
- mNextPreviewSize = mPreviewSizes.get(position);
- startPreview();
- }
- }
-
- public void onNothingSelected(AdapterView parent) {
-
- }
-
- };
-
-
- private void setUpCamera(int id) {
- shutdownCamera();
-
- mCurrentCameraId = id;
- mCamera = Camera.open(id);
- Camera.Parameters p = mCamera.getParameters();
-
- // Get preview resolutions
-
- List<Camera.Size> unsortedSizes = p.getSupportedPreviewSizes();
-
- class SizeCompare implements Comparator<Camera.Size> {
- public int compare(Camera.Size lhs, Camera.Size rhs) {
- if (lhs.width < rhs.width) return -1;
- if (lhs.width > rhs.width) return 1;
- if (lhs.height < rhs.height) return -1;
- if (lhs.height > rhs.height) return 1;
- return 0;
- }
- };
-
- SizeCompare s = new SizeCompare();
- TreeSet<Camera.Size> sortedResolutions = new TreeSet<Camera.Size>(s);
- sortedResolutions.addAll(unsortedSizes);
-
- mPreviewSizes = new ArrayList<Camera.Size>(sortedResolutions);
-
- String[] availableSizeNames = new String[mPreviewSizes.size()];
- for (int i = 0; i < mPreviewSizes.size(); i++) {
- availableSizeNames[i] =
- Integer.toString(mPreviewSizes.get(i).width) + " x " +
- Integer.toString(mPreviewSizes.get(i).height);
- }
- mResolutionSpinner.setAdapter(
- new ArrayAdapter<String>(
- this, R.layout.cf_format_list_item, availableSizeNames));
-
-
- // Set initial values
-
- mNextPreviewSize = mPreviewSizes.get(15);
- mResolutionSpinner.setSelection(15);
-
- if (mPreviewTexture != null) {
- startPreview();
- }
- }
-
- private void shutdownCamera() {
- if (mCamera != null) {
- mCamera.setPreviewCallbackWithBuffer(null);
- mCamera.stopPreview();
- mCamera.release();
- mCamera = null;
- mState = STATE_OFF;
- }
- }
-
- private void startPreview() {
- if (mState != STATE_OFF) {
- // Stop for a while to drain callbacks
- mCamera.setPreviewCallbackWithBuffer(null);
- mCamera.stopPreview();
- mState = STATE_OFF;
- Handler h = new Handler();
- Runnable mDelayedPreview = new Runnable() {
- public void run() {
- startPreview();
- }
- };
- h.postDelayed(mDelayedPreview, 300);
- return;
- }
- mState = STATE_PREVIEW;
-
- Matrix transform = new Matrix();
- float widthRatio = mNextPreviewSize.width / (float)mPreviewTexWidth;
- float heightRatio = mNextPreviewSize.height / (float)mPreviewTexHeight;
-
- transform.setScale(1, heightRatio/widthRatio);
- transform.postTranslate(0,
- mPreviewTexHeight * (1 - heightRatio/widthRatio)/2);
-
- mPreviewView.setTransform(transform);
- mOutputView.setTransform(transform);
-
- mPreviewSize = mNextPreviewSize;
-
- Camera.Parameters p = mCamera.getParameters();
- p.setPreviewFormat(ImageFormat.NV21);
- p.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
- mCamera.setParameters(p);
-
- mCamera.setPreviewCallbackWithBuffer(this);
- int expectedBytes = mPreviewSize.width * mPreviewSize.height *
- ImageFormat.getBitsPerPixel(ImageFormat.NV21) / 8;
- for (int i=0; i < 4; i++) {
- mCamera.addCallbackBuffer(new byte[expectedBytes]);
- }
- //mFormatView.setColorFilter(mYuv2RgbFilter);
-
- mProcessingFirstFrame = true;
- try {
- mCamera.setPreviewTexture(mPreviewTexture);
- mCamera.startPreview();
- } catch (IOException ioe) {
- // Something bad happened
- Log.e(TAG, "Unable to start up preview");
- }
-
- }
-
-
- private class ProcessPreviewDataTask extends AsyncTask<byte[], Void, Boolean> {
- protected Boolean doInBackground(byte[]... datas) {
- byte[] data = datas[0];
-
- long t1 = java.lang.System.currentTimeMillis();
-
- mFilterYuv.execute(data);
-
- long t2 = java.lang.System.currentTimeMillis();
- mTiming[mTimingSlot++] = t2 - t1;
- if (mTimingSlot >= mTiming.length) {
- float total = 0;
- for (int i=0; i<mTiming.length; i++) {
- total += (float)mTiming[i];
- }
- total /= mTiming.length;
- Log.e(TAG, "time + " + total);
- mTimingSlot = 0;
- }
-
- mCamera.addCallbackBuffer(data);
- mProcessInProgress = false;
- return true;
- }
-
- protected void onPostExecute(Boolean result) {
- mOutputView.invalidate();
- }
-
- }
-
- private long mTiming[] = new long[50];
- private int mTimingSlot = 0;
-
- public void onPreviewFrame(byte[] data, Camera camera) {
- if (mProcessInProgress || mState != STATE_PREVIEW) {
- mCamera.addCallbackBuffer(data);
- return;
- }
- if (data == null) {
- return;
- }
-
- int expectedBytes = mPreviewSize.width * mPreviewSize.height *
- ImageFormat.getBitsPerPixel(ImageFormat.NV21) / 8;
-
- if (expectedBytes != data.length) {
- Log.e(TAG, "Mismatched size of buffer! Expected ");
-
- mState = STATE_NO_CALLBACKS;
- mCamera.setPreviewCallbackWithBuffer(null);
- return;
- }
-
- mProcessInProgress = true;
-
- if ((mFilterYuv == null) ||
- (mPreviewSize.width != mFilterYuv.getWidth()) ||
- (mPreviewSize.height != mFilterYuv.getHeight()) ) {
-
- mFilterYuv.reset(mPreviewSize.width, mPreviewSize.height);
- }
-
- mProcessInProgress = true;
- new ProcessPreviewDataTask().execute(data);
- }
-
-
-
-}
\ No newline at end of file
diff --git a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/RsYuv.java b/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/RsYuv.java
deleted file mode 100644
index 12d3185..0000000
--- a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/RsYuv.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.livepreview;
-
-import android.app.Activity;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.os.Bundle;
-import android.graphics.SurfaceTexture;
-import android.renderscript.Allocation;
-import android.renderscript.Matrix3f;
-import android.renderscript.RenderScript;
-import android.util.Log;
-import android.view.TextureView;
-import android.view.View;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-
-import android.graphics.Bitmap;
-
-public class RsYuv implements TextureView.SurfaceTextureListener
-{
- private int mHeight;
- private int mWidth;
- private RenderScript mRS;
- private Allocation mAllocationOut;
- private Allocation mAllocationIn;
- private ScriptC_yuv mScript;
- private ScriptIntrinsicYuvToRGB mYuv;
- private boolean mHaveSurface;
- private SurfaceTexture mSurface;
- private ScriptGroup mGroup;
-
- RsYuv(RenderScript rs) {
- mRS = rs;
- mScript = new ScriptC_yuv(mRS);
- mYuv = ScriptIntrinsicYuvToRGB.create(rs, Element.RGBA_8888(mRS));
- }
-
- void setupSurface() {
- if (mAllocationOut != null) {
- mAllocationOut.setSurfaceTexture(mSurface);
- }
- if (mSurface != null) {
- mHaveSurface = true;
- } else {
- mHaveSurface = false;
- }
- }
-
- void reset(int width, int height) {
- if (mAllocationOut != null) {
- mAllocationOut.destroy();
- }
-
- android.util.Log.v("cpa", "reset " + width + ", " + height);
- mHeight = height;
- mWidth = width;
- mScript.invoke_setSize(mWidth, mHeight);
-
- Type.Builder tb = new Type.Builder(mRS, Element.RGBA_8888(mRS));
- tb.setX(mWidth);
- tb.setY(mHeight);
- Type t = tb.create();
- mAllocationOut = Allocation.createTyped(mRS, t, Allocation.USAGE_SCRIPT |
- Allocation.USAGE_IO_OUTPUT);
-
-
- tb = new Type.Builder(mRS, Element.createPixel(mRS, Element.DataType.UNSIGNED_8, Element.DataKind.PIXEL_YUV));
- tb.setX(mWidth);
- tb.setY(mHeight);
- tb.setYuvFormat(android.graphics.ImageFormat.NV21);
- mAllocationIn = Allocation.createTyped(mRS, tb.create(), Allocation.USAGE_SCRIPT);
- mYuv.setInput(mAllocationIn);
- setupSurface();
-
-
- ScriptGroup.Builder b = new ScriptGroup.Builder(mRS);
- b.addKernel(mScript.getKernelID_root());
- b.addKernel(mYuv.getKernelID());
- b.addConnection(t, mYuv.getKernelID(), mScript.getKernelID_root());
- mGroup = b.create();
- }
-
- public int getWidth() {
- return mWidth;
- }
- public int getHeight() {
- return mHeight;
- }
-
- private long mTiming[] = new long[50];
- private int mTimingSlot = 0;
-
- void execute(byte[] yuv) {
- mAllocationIn.copyFrom(yuv);
- if (mHaveSurface) {
- mGroup.setOutput(mScript.getKernelID_root(), mAllocationOut);
- mGroup.execute();
-
- //mYuv.forEach(mAllocationOut);
- //mScript.forEach_root(mAllocationOut, mAllocationOut);
- mAllocationOut.ioSendOutput();
- }
- }
-
-
-
- @Override
- public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
- android.util.Log.v("cpa", "onSurfaceTextureAvailable " + surface);
- mSurface = surface;
- setupSurface();
- }
-
- @Override
- public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
- android.util.Log.v("cpa", "onSurfaceTextureSizeChanged " + surface);
- mSurface = surface;
- setupSurface();
- }
-
- @Override
- public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
- android.util.Log.v("cpa", "onSurfaceTextureDestroyed " + surface);
- mSurface = surface;
- setupSurface();
- return true;
- }
-
- @Override
- public void onSurfaceTextureUpdated(SurfaceTexture surface) {
- }
-}
-
diff --git a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/yuv.rs b/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/yuv.rs
deleted file mode 100644
index c4f698f..0000000
--- a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/yuv.rs
+++ /dev/null
@@ -1,126 +0,0 @@
-
-#pragma version(1)
-#pragma rs java_package_name(com.android.rs.livepreview)
-//#pragma rs_fp_relaxed
-
-static int gWidth;
-static int gHeight;
-static uchar crossProcess_tableR[256];
-static uchar crossProcess_tableG[256];
-static uchar crossProcess_tableB[256];
-static uchar vignette_table[512];
-
-
-static float4 crossProcess(float4 color) {
- float4 ncolor = 0.f;
- float v;
-
- if (color.r < 0.5f) {
- v = color.r;
- ncolor.r = 4.0f * v * v * v;
- } else {
- v = 1.0f - color.r;
- ncolor.r = 1.0f - (4.0f * v * v * v);
- }
-
- if (color.g < 0.5f) {
- v = color.g;
- ncolor.g = 2.0f * v * v;
- } else {
- v = 1.0f - color.g;
- ncolor.g = 1.0f - (2.0f * v * v);
- }
-
- ncolor.b = color.b * 0.5f + 0.25f;
- ncolor.a = color.a;
- return ncolor;
-}
-
-static uchar4 crossProcess_i(uchar4 color) {
- uchar4 ncolor = color;
- ncolor.r = crossProcess_tableR[color.r];
- ncolor.g = crossProcess_tableG[color.g];
- ncolor.b = crossProcess_tableB[color.b];
- return ncolor;
-}
-
-
-float temp = 0.2f;
-static float4 colortemp(float4 color) {
- float4 new_color = color;
- float4 t = color * ((float4)1.0f - color) * temp;
-
- new_color.r = color.r + t.r;
- new_color.b = color.b - t.b;
- if (temp > 0.0f) {
- color.g = color.g + t.g * 0.25f;
- }
- float max_value = max(new_color.r, max(new_color.g, new_color.b));
- if (max_value > 1.0f) {
- new_color /= max_value;
- }
-
- return new_color;
-}
-
-
-static float vignette_dist_mod;
-int2 vignette_half_dims;
-static uchar4 vignette(uchar4 color, uint32_t x, uint32_t y) {
- int2 xy = {x, y};
- xy -= vignette_half_dims;
- xy *= xy;
-
- float d = vignette_dist_mod * (xy.x + xy.y);
- ushort4 c = convert_ushort4(color);
- c *= vignette_table[(int)d];
- c >>= (ushort4)8;
- return convert_uchar4(c);
-}
-
-void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
- uchar4 p;
- p = crossProcess_i(*in);
- p = vignette(p, x, y);
-
- out->rgba = p;
- out->a = 0xff;
-}
-
-float vignetteScale = 0.5f;
-float vignetteShade = 0.85f;
-
-static void precompute() {
- for(int i=0; i <256; i++) {
- float4 f = ((float)i) / 255.f;
- float4 res = crossProcess(f);
- res = colortemp(res);
- crossProcess_tableR[i] = (uchar)(res.r * 255.f);
- crossProcess_tableG[i] = (uchar)(res.g * 255.f);
- crossProcess_tableB[i] = (uchar)(res.b * 255.f);
- }
-
- for(int i=0; i <512; i++) {
- const float slope = 20.0f;
- float f = ((float)i) / 511.f;
-
- float range = 1.30f - sqrt(vignetteScale) * 0.7f;
- float lumen = vignetteShade / (1.0f + exp((sqrt(f) - range) * slope)) + (1.0f - vignetteShade);
- lumen = clamp(lumen, 0.f, 1.f);
-
- vignette_table[i] = (uchar)(lumen * 255.f + 0.5f);
- }
-}
-
-void init() {
- precompute();
-}
-
-void setSize(int w, int h) {
- gWidth = w;
- gHeight = h;
- vignette_half_dims = (int2){w / 2, h / 2};
- vignette_dist_mod = 512.f;
- vignette_dist_mod /= (float)(w*w + h*h) / 4.f;
-
-}
diff --git a/tests/RenderScriptTests/MathErr/Android.mk b/tests/RenderScriptTests/MathErr/Android.mk
deleted file mode 100644
index b3edd02..0000000
--- a/tests/RenderScriptTests/MathErr/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
- $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := RsMathErr
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/MathErr/AndroidManifest.xml b/tests/RenderScriptTests/MathErr/AndroidManifest.xml
deleted file mode 100644
index 6a3db2c..0000000
--- a/tests/RenderScriptTests/MathErr/AndroidManifest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.rs.matherr">
-
- <uses-sdk android:minSdkVersion="17" />
- <application android:label="RS Math Err">
- <activity android:name="MathErrActivity">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/MathErr/res/layout/main.xml b/tests/RenderScriptTests/MathErr/res/layout/main.xml
deleted file mode 100644
index 7b2c76a..0000000
--- a/tests/RenderScriptTests/MathErr/res/layout/main.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ImageView
- android:id="@+id/displayin"
- android:layout_width="320dip"
- android:layout_height="266dip" />
-
- <ImageView
- android:id="@+id/displayout"
- android:layout_width="320dip"
- android:layout_height="266dip" />
-
-</LinearLayout>
diff --git a/tests/RenderScriptTests/MathErr/src/com/example/android/rs/matherr/MathErr.java b/tests/RenderScriptTests/MathErr/src/com/example/android/rs/matherr/MathErr.java
deleted file mode 100644
index 4561267..0000000
--- a/tests/RenderScriptTests/MathErr/src/com/example/android/rs/matherr/MathErr.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2013 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.example.android.rs.matherr;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import java.lang.Float;
-import java.lang.Math;
-
-public class MathErr {
- private RenderScript mRS;
- private Allocation mAllocationSrc;
- private Allocation mAllocationRes;
- private ScriptC_math_err mScript;
- private java.util.Random mRand = new java.util.Random();
-
- private final int BUF_SIZE = 4096;
- float mSrc[] = new float[BUF_SIZE];
- float mRef[] = new float[BUF_SIZE];
- float mRes[] = new float[BUF_SIZE];
-
- MathErr(RenderScript rs) {
- mRS = rs;
- mScript = new ScriptC_math_err(mRS);
-
- mAllocationSrc = Allocation.createSized(rs, Element.F32(rs), BUF_SIZE);
- mAllocationRes = Allocation.createSized(rs, Element.F32(rs), BUF_SIZE);
-
- testExp2();
- testLog2();
- }
-
- void buildRand() {
- for (int i=0; i < BUF_SIZE; i++) {
- mSrc[i] = (((float)i) / 9) - 200;
- //mSrc[i] = Float.intBitsToFloat(mRand.nextInt());
- }
- mAllocationSrc.copyFrom(mSrc);
- }
-
- void logErr() {
- mAllocationRes.copyTo(mRes);
- for (int i=0; i < BUF_SIZE; i++) {
- int err = Float.floatToRawIntBits(mRef[i]) - Float.floatToRawIntBits(mRes[i]);
- err = Math.abs(err);
- if (err > 8096) {
- android.util.Log.v("err", "error " + err + " src " + mSrc[i] + " ref " + mRef[i] + " res " + mRes[i]);
- }
- }
- }
-
- void testExp2() {
- android.util.Log.v("err", "testing exp2");
- buildRand();
- mScript.forEach_testExp2(mAllocationSrc, mAllocationRes);
- for (int i=0; i < BUF_SIZE; i++) {
- mRef[i] = (float)Math.pow(2.f, mSrc[i]);
- }
- logErr();
- }
-
- void testLog2() {
- android.util.Log.v("err", "testing log2");
- buildRand();
- mScript.forEach_testLog2(mAllocationSrc, mAllocationRes);
- for (int i=0; i < BUF_SIZE; i++) {
- mRef[i] = (float)Math.log(mSrc[i]) * 1.442695041f;
- }
- logErr();
- }
-
-}
diff --git a/tests/RenderScriptTests/MathErr/src/com/example/android/rs/matherr/MathErrActivity.java b/tests/RenderScriptTests/MathErr/src/com/example/android/rs/matherr/MathErrActivity.java
deleted file mode 100644
index 74d7b71..0000000
--- a/tests/RenderScriptTests/MathErr/src/com/example/android/rs/matherr/MathErrActivity.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2013 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.example.android.rs.matherr;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.renderscript.RenderScript;
-import android.renderscript.Allocation;
-import android.util.Log;
-
-public class MathErrActivity extends Activity {
- private MathErr mME;
- private RenderScript mRS;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- mRS = RenderScript.create(this);
- mME = new MathErr(mRS);
- }
-}
diff --git a/tests/RenderScriptTests/MathErr/src/com/example/android/rs/matherr/math_err.rs b/tests/RenderScriptTests/MathErr/src/com/example/android/rs/matherr/math_err.rs
deleted file mode 100644
index a26770b..0000000
--- a/tests/RenderScriptTests/MathErr/src/com/example/android/rs/matherr/math_err.rs
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#pragma version(1)
-#pragma rs java_package_name(com.example.android.rs.matherr)
-
-typedef union
-{
- float fv;
- int32_t iv;
-} ieee_float_shape_type;
-
-/* Get a 32 bit int from a float. */
-
-#define GET_FLOAT_WORD(i,d) \
-do { \
- ieee_float_shape_type gf_u; \
- gf_u.fv = (d); \
- (i) = gf_u.iv; \
-} while (0)
-
-/* Set a float from a 32 bit int. */
-
-#define SET_FLOAT_WORD(d,i) \
-do { \
- ieee_float_shape_type sf_u; \
- sf_u.iv = (i); \
- (d) = sf_u.fv; \
-} while (0)
-
-
-static float fast_log2(float v) {
- int32_t ibits;
- GET_FLOAT_WORD(ibits, v);
-
- int32_t e = (ibits >> 23) & 0xff;
-
- ibits &= 0x7fffff;
- ibits |= 127 << 23;
-
- float ir;
- SET_FLOAT_WORD(ir, ibits);
-
- ir -= 1.5f;
- float ir2 = ir*ir;
- float adj2 = 0.405465108f + // -0.00009f +
- (0.666666667f * ir) -
- (0.222222222f * ir2) +
- (0.098765432f * ir*ir2) -
- (0.049382716f * ir2*ir2) +
- (0.026337449f * ir*ir2*ir2) -
- (0.014631916f * ir2*ir2*ir2);
- adj2 *= (1.f / 0.693147181f);
-
- return (float)(e - 127) + adj2;
-}
-
-void testExp2(const float *in, float *out) {
- float i = *in;
- if (i > (-125.f) && i < 125.f) {
- *out = native_exp2(i);
- } else {
- *out = exp2(i);
- }
- *out = native_exp2(i);
-}
-
-void testLog2(const float *in, float *out) {
- *out = fast_log2(*in);
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/Android.mk b/tests/RenderScriptTests/RSTest_CompatLib/Android.mk
deleted file mode 100644
index 0fd0d96..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := RSTest_Compat
-
-LOCAL_STATIC_JAVA_LIBRARIES := android.support.v8.renderscript
-
-LOCAL_SDK_VERSION := 8
-LOCAL_RENDERSCRIPT_TARGET_API := 18
-LOCAL_RENDERSCRIPT_COMPATIBILITY := 18
-
-LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
-LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE := \
- $(TOPDIR)external/clang/lib/Headers \
- $(TOPDIR)frameworks/rs/scriptc
-
-LOCAL_RENDERSCRIPT_FLAGS := -rs-package-name=android.support.v8.renderscript
-LOCAL_REQUIRED_MODULES := librsjni
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/AndroidManifest.xml b/tests/RenderScriptTests/RSTest_CompatLib/AndroidManifest.xml
deleted file mode 100644
index 53219e7..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/AndroidManifest.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.rs.test_compat">
- <uses-sdk android:minSdkVersion="8" />
- <uses-sdk android:targetSdkVersion="8" />
- <application
- android:label="_RS_Test_Compat"
- android:icon="@drawable/test_pattern">
- <activity android:name="RSTest"
- android:screenOrientation="portrait">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/res/drawable-nodpi/test_pattern.png b/tests/RenderScriptTests/RSTest_CompatLib/res/drawable-nodpi/test_pattern.png
deleted file mode 100644
index e7d1455..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/res/drawable-nodpi/test_pattern.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/RSTest.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/RSTest.java
deleted file mode 100644
index b76f21e..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/RSTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.support.v8.renderscript.RenderScript;
-
-import android.app.ListActivity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.provider.Settings.System;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.ListView;
-import android.widget.ArrayAdapter;
-
-import java.lang.Runtime;
-
-public class RSTest extends ListActivity {
-
- private static final String LOG_TAG = "RSTest_Compat";
- private static final boolean DEBUG = false;
- private static final boolean LOG_ENABLED = false;
-
- private RenderScript mRS;
- private RSTestCore RSTC;
-
- String mTestNames[];
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- mRS = RenderScript.create(this);
-
- RSTC = new RSTestCore(this);
- RSTC.init(mRS, getResources());
-
-
-
-
- }
-
- static void log(String message) {
- if (LOG_ENABLED) {
- Log.v(LOG_TAG, message);
- }
- }
-
-
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/RSTestCore.java
deleted file mode 100644
index 51f8a4d..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/RSTestCore.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2008-2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-import android.util.Log;
-import java.util.ArrayList;
-import java.util.ListIterator;
-import java.util.Timer;
-import java.util.TimerTask;
-import android.app.ListActivity;
-import android.widget.ArrayAdapter;
-
-public class RSTestCore {
- ListActivity mCtx;
-
- public RSTestCore(ListActivity ctx) {
- mCtx = ctx;
- }
-
- private Resources mRes;
- private RenderScript mRS;
-
- private ArrayList<UnitTest> unitTests;
- private ListIterator<UnitTest> test_iter;
- private UnitTest activeTest;
- private boolean stopTesting;
-
- private ScriptField_ListAllocs_s mListAllocs;
-
- private ArrayAdapter<UnitTest> testAdapter;
-
- /* Periodic timer for ensuring future tests get scheduled */
- private Timer mTimer;
- public static final int RS_TIMER_PERIOD = 100;
-
- public void init(RenderScript rs, Resources res) {
- mRS = rs;
- mRes = res;
- stopTesting = false;
-
- unitTests = new ArrayList<UnitTest>();
-
- unitTests.add(new UT_primitives(this, mRes, mCtx));
- unitTests.add(new UT_constant(this, mRes, mCtx));
- unitTests.add(new UT_vector(this, mRes, mCtx));
- unitTests.add(new UT_unsigned(this, mRes, mCtx));
- unitTests.add(new UT_array_init(this, mRes, mCtx));
- unitTests.add(new UT_array_alloc(this, mRes, mCtx));
- unitTests.add(new UT_kernel(this, mRes, mCtx));
- unitTests.add(new UT_kernel_struct(this, mRes, mCtx));
- unitTests.add(new UT_bug_char(this, mRes, mCtx));
- unitTests.add(new UT_clamp(this, mRes, mCtx));
- unitTests.add(new UT_clamp_relaxed(this, mRes, mCtx));
- unitTests.add(new UT_convert(this, mRes, mCtx));
- unitTests.add(new UT_convert_relaxed(this, mRes, mCtx));
- unitTests.add(new UT_copy_test(this, mRes, mCtx));
- unitTests.add(new UT_rsdebug(this, mRes, mCtx));
- unitTests.add(new UT_rstime(this, mRes, mCtx));
- unitTests.add(new UT_rstypes(this, mRes, mCtx));
- unitTests.add(new UT_alloc(this, mRes, mCtx));
- unitTests.add(new UT_refcount(this, mRes, mCtx));
- unitTests.add(new UT_foreach(this, mRes, mCtx));
- unitTests.add(new UT_foreach_bounds(this, mRes, mCtx));
- unitTests.add(new UT_noroot(this, mRes, mCtx));
- unitTests.add(new UT_atomic(this, mRes, mCtx));
- unitTests.add(new UT_struct(this, mRes, mCtx));
- unitTests.add(new UT_math(this, mRes, mCtx));
- unitTests.add(new UT_math_conformance(this, mRes, mCtx));
- unitTests.add(new UT_math_agree(this, mRes, mCtx));
- unitTests.add(new UT_min(this, mRes, mCtx));
- unitTests.add(new UT_int4(this, mRes, mCtx));
- unitTests.add(new UT_element(this, mRes, mCtx));
- unitTests.add(new UT_sampler(this, mRes, mCtx));
- unitTests.add(new UT_fp_mad(this, mRes, mCtx));
-
- /*
- unitTests.add(new UnitTest(null, "<Pass>", 1));
- unitTests.add(new UnitTest());
- unitTests.add(new UnitTest(null, "<Fail>", -1));
-
- for (int i = 0; i < 20; i++) {
- unitTests.add(new UnitTest(null, "<Pass>", 1));
- }
- */
-
- UnitTest [] uta = new UnitTest[unitTests.size()];
- uta = unitTests.toArray(uta);
-
- mListAllocs = new ScriptField_ListAllocs_s(mRS, uta.length);
- for (int i = 0; i < uta.length; i++) {
-
- ScriptField_ListAllocs_s.Item listElem = new ScriptField_ListAllocs_s.Item();
- listElem.text = Allocation.createFromString(mRS, uta[i].name, Allocation.USAGE_SCRIPT);
- listElem.result = uta[i].getResult();
- mListAllocs.set(listElem, i, false);
- uta[i].setItem(listElem);
- }
-
- mListAllocs.copyAll();
-
- testAdapter = new ArrayAdapter<UnitTest>(mCtx, android.R.layout.simple_list_item_1, unitTests);
- mCtx.setListAdapter(testAdapter);
-
- test_iter = unitTests.listIterator();
- refreshTestResults(); /* Kick off the first test */
-
- TimerTask pTask = new TimerTask() {
- public void run() {
- refreshTestResults();
- }
- };
-
- mTimer = new Timer();
- mTimer.schedule(pTask, RS_TIMER_PERIOD, RS_TIMER_PERIOD);
- }
-
- public void checkAndRunNextTest() {
- mCtx.runOnUiThread(new Runnable() {
- public void run() {
- if (testAdapter != null)
- testAdapter.notifyDataSetChanged();
- }
- });
-
- if (activeTest != null) {
- if (!activeTest.isAlive()) {
- /* Properly clean up on our last test */
- try {
- activeTest.join();
- }
- catch (InterruptedException e) {
- }
- activeTest = null;
- }
- }
-
- if (!stopTesting && activeTest == null) {
- if (test_iter.hasNext()) {
- activeTest = test_iter.next();
- activeTest.start();
- /* This routine will only get called once when a new test
- * should start running. The message handler in UnitTest.java
- * ensures this. */
- }
- else {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer.purge();
- mTimer = null;
- }
- }
- }
- }
-
- public void refreshTestResults() {
- checkAndRunNextTest();
- }
-
- public void cleanup() {
- stopTesting = true;
- UnitTest t = activeTest;
-
- /* Stop periodic refresh of testing */
- if (mTimer != null) {
- mTimer.cancel();
- mTimer.purge();
- mTimer = null;
- }
-
- /* Wait to exit until we finish the current test */
- if (t != null) {
- try {
- t.join();
- }
- catch (InterruptedException e) {
- }
- t = null;
- }
-
- }
-
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_alloc.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_alloc.java
deleted file mode 100644
index 3af3745..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_alloc.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_alloc extends UnitTest {
- private Resources mRes;
-
- protected UT_alloc(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Alloc", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_alloc s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- int Y = 7;
- int Z = 0;
- s.set_dimX(X);
- s.set_dimY(Y);
- s.set_dimZ(Z);
- typeBuilder.setX(X).setY(Y);
- Allocation A = Allocation.createTyped(RS, typeBuilder.create());
- s.bind_a(A);
- s.set_aRaw(A);
-
- typeBuilder = new Type.Builder(RS, Element.I32(RS));
- typeBuilder.setX(X).setY(Y).setFaces(true);
- Allocation AFaces = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aFaces(AFaces);
- typeBuilder.setFaces(false).setMipmaps(true);
- Allocation ALOD = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aLOD(ALOD);
- typeBuilder.setFaces(true).setMipmaps(true);
- Allocation AFacesLOD = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aFacesLOD(AFacesLOD);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_alloc s = new ScriptC_alloc(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_root(s.get_aRaw());
- s.invoke_alloc_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_array_alloc.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_array_alloc.java
deleted file mode 100644
index 751187b..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_array_alloc.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_array_alloc extends UnitTest {
- private Resources mRes;
-
- protected UT_array_alloc(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Array Allocation", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_array_alloc s = new ScriptC_array_alloc(pRS);
- pRS.setMessageHandler(mRsMessage);
-
- int dimX = s.get_dimX();
- Allocation[] Arr = new Allocation[dimX];
- Type.Builder typeBuilder = new Type.Builder(pRS, Element.I32(pRS));
- Type T = typeBuilder.setX(1).create();
- for (int i = 0; i < dimX; i++) {
- Allocation A = Allocation.createTyped(pRS, T);
- Arr[i] = A;
- }
- s.set_a(Arr);
-
- s.invoke_array_alloc_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- passTest();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_array_init.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_array_init.java
deleted file mode 100644
index f8b2fd3..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_array_init.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_array_init extends UnitTest {
- private Resources mRes;
-
- protected UT_array_init(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Array Init", ctx);
- mRes = res;
- }
-
- private void checkInit(ScriptC_array_init s) {
- float[] fa = s.get_fa();
- _RS_ASSERT("fa[0] == 1.0", fa[0] == 1.0);
- _RS_ASSERT("fa[1] == 9.9999f", fa[1] == 9.9999f);
- _RS_ASSERT("fa[2] == 0", fa[2] == 0);
- _RS_ASSERT("fa[3] == 0", fa[3] == 0);
- _RS_ASSERT("fa.length == 4", fa.length == 4);
-
- double[] da = s.get_da();
- _RS_ASSERT("da[0] == 7.0", da[0] == 7.0);
- _RS_ASSERT("da[1] == 8.88888", da[1] == 8.88888);
- _RS_ASSERT("da.length == 2", da.length == 2);
-
- byte[] ca = s.get_ca();
- _RS_ASSERT("ca[0] == 'a'", ca[0] == 'a');
- _RS_ASSERT("ca[1] == 7", ca[1] == 7);
- _RS_ASSERT("ca[2] == 'b'", ca[2] == 'b');
- _RS_ASSERT("ca[3] == 'c'", ca[3] == 'c');
- _RS_ASSERT("ca.length == 4", ca.length == 4);
-
- short[] sa = s.get_sa();
- _RS_ASSERT("sa[0] == 1", sa[0] == 1);
- _RS_ASSERT("sa[1] == 1", sa[1] == 1);
- _RS_ASSERT("sa[2] == 2", sa[2] == 2);
- _RS_ASSERT("sa[3] == 3", sa[3] == 3);
- _RS_ASSERT("sa.length == 4", sa.length == 4);
-
- int[] ia = s.get_ia();
- _RS_ASSERT("ia[0] == 5", ia[0] == 5);
- _RS_ASSERT("ia[1] == 8", ia[1] == 8);
- _RS_ASSERT("ia[2] == 0", ia[2] == 0);
- _RS_ASSERT("ia[3] == 0", ia[3] == 0);
- _RS_ASSERT("ia.length == 4", ia.length == 4);
-
- long[] la = s.get_la();
- _RS_ASSERT("la[0] == 13", la[0] == 13);
- _RS_ASSERT("la[1] == 21", la[1] == 21);
- _RS_ASSERT("la.length == 4", la.length == 2);
-
- long[] lla = s.get_lla();
- _RS_ASSERT("lla[0] == 34", lla[0] == 34);
- _RS_ASSERT("lla[1] == 0", lla[1] == 0);
- _RS_ASSERT("lla[2] == 0", lla[2] == 0);
- _RS_ASSERT("lla[3] == 0", lla[3] == 0);
- _RS_ASSERT("lla.length == 4", lla.length == 4);
-
- boolean[] ba = s.get_ba();
- _RS_ASSERT("ba[0] == true", ba[0] == true);
- _RS_ASSERT("ba[1] == false", ba[1] == false);
- _RS_ASSERT("ba[2] == false", ba[2] == false);
- _RS_ASSERT("ba.length == 3", ba.length == 3);
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_array_init s = new ScriptC_array_init(pRS);
- pRS.setMessageHandler(mRsMessage);
- checkInit(s);
- s.invoke_array_init_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- passTest();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_atomic.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_atomic.java
deleted file mode 100644
index 7fe4b36..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_atomic.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_atomic extends UnitTest {
- private Resources mRes;
-
- protected UT_atomic(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Atomics", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_atomic s = new ScriptC_atomic(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_atomic_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_bug_char.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_bug_char.java
deleted file mode 100644
index 5da5288..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_bug_char.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-import android.util.Log;
-import java.util.Arrays;
-
-public class UT_bug_char extends UnitTest {
- private Resources mRes;
-
- protected UT_bug_char(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Bug Char", ctx);
- mRes = res;
- }
-
- // packing functions
- private Byte2 pack_b2(byte[] val) {
- assert val.length == 2;
- Log.i("bug_char", "pack_b2 " + val[0] + " " + val[1]);
- return new Byte2(val[0], val[1]);
- }
-
- private byte min(byte v1, byte v2) {
- return v1 < v2 ? v1 : v2;
- }
- private byte[] min(byte[] v1, byte[] v2) {
- assert v1.length == v2.length;
- byte[] rv = new byte[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
-
- private void initializeValues(ScriptC_bug_char s) {
- byte rand_sc1_0 = (byte)7;
- byte[] rand_sc2_0 = new byte[2];
- rand_sc2_0[0] = 11;
- rand_sc2_0[1] = 21;
- Log.i("bug_char", "Generated sc2_0 to " + Arrays.toString(rand_sc2_0));
- byte rand_sc1_1 = (byte)10;
- byte[] rand_sc2_1 = new byte[2];
- rand_sc2_1[0] = 13;
- rand_sc2_1[1] = 15;
- Log.i("bug_char", "Generated sc2_1 to " + Arrays.toString(rand_sc2_1));
-
- s.set_rand_sc1_0(rand_sc1_0);
- s.set_rand_sc2_0(pack_b2(rand_sc2_0));
- s.set_rand_sc1_1(rand_sc1_1);
- s.set_rand_sc2_1(pack_b2(rand_sc2_1));
- // Set results for min
- s.set_min_rand_sc1_sc1(min(rand_sc1_0, rand_sc1_1));
- byte[] min_rand_sc2_raw = min(rand_sc2_0, rand_sc2_1);
- Log.i("bug_char", "Generating min_rand_sc2_sc2 to " +
- Arrays.toString(min_rand_sc2_raw));
- Byte2 min_rand_sc2 = pack_b2(min_rand_sc2_raw);
- Log.i("bug_char", "Setting min_rand_sc2_sc2 to [" + min_rand_sc2.x +
- ", " + min_rand_sc2.y + "]");
- s.set_min_rand_sc2_sc2(min_rand_sc2);
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_bug_char s = new ScriptC_bug_char(pRS, mRes,
- R.raw.bug_char);
- pRS.setMessageHandler(mRsMessage);
- initializeValues(s);
- s.invoke_bug_char_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_clamp.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_clamp.java
deleted file mode 100644
index 1f28abc..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_clamp.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_clamp extends UnitTest {
- private Resources mRes;
-
- protected UT_clamp(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Clamp (Full)", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_clamp s = new ScriptC_clamp(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_clamp_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_clamp_relaxed.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_clamp_relaxed.java
deleted file mode 100644
index d880e68..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_clamp_relaxed.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_clamp_relaxed extends UnitTest {
- private Resources mRes;
-
- protected UT_clamp_relaxed(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Clamp (Relaxed)", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_clamp_relaxed s =
- new ScriptC_clamp_relaxed(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_clamp_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_constant.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_constant.java
deleted file mode 100644
index 3085032..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_constant.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_constant extends UnitTest {
- private Resources mRes;
-
- protected UT_constant(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Const", ctx);
- mRes = res;
- }
-
- private void Assert(boolean b) {
- if (!b) {
- failTest();
- }
- }
-
- public void run() {
- Assert(ScriptC_constant.const_floatTest == 1.99f);
- Assert(ScriptC_constant.const_doubleTest == 2.05);
- Assert(ScriptC_constant.const_charTest == -8);
- Assert(ScriptC_constant.const_shortTest == -16);
- Assert(ScriptC_constant.const_intTest == -32);
- Assert(ScriptC_constant.const_longTest == 17179869184l);
- Assert(ScriptC_constant.const_longlongTest == 68719476736l);
-
- Assert(ScriptC_constant.const_ucharTest == 8);
- Assert(ScriptC_constant.const_ushortTest == 16);
- Assert(ScriptC_constant.const_uintTest == 32);
- Assert(ScriptC_constant.const_ulongTest == 4611686018427387904L);
- Assert(ScriptC_constant.const_int64_tTest == -17179869184l);
- Assert(ScriptC_constant.const_uint64_tTest == 117179869184l);
-
- Assert(ScriptC_constant.const_boolTest == true);
-
- passTest();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_convert.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_convert.java
deleted file mode 100644
index a7cb226..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_convert.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_convert extends UnitTest {
- private Resources mRes;
-
- protected UT_convert(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Convert", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_convert s = new ScriptC_convert(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_convert_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_convert_relaxed.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_convert_relaxed.java
deleted file mode 100644
index 269bcef..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_convert_relaxed.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_convert_relaxed extends UnitTest {
- private Resources mRes;
-
- protected UT_convert_relaxed(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Convert (Relaxed)", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_convert_relaxed s =
- new ScriptC_convert_relaxed(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_convert_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_copy_test.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_copy_test.java
deleted file mode 100644
index f435dde..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_copy_test.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-import android.util.Log;
-
-public class UT_copy_test extends UnitTest {
- private Resources mRes;
- boolean pass = true;
-
- protected UT_copy_test(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Copy", ctx);
- mRes = res;
- }
-
- void testFloat2(RenderScript rs, ScriptC_copy_test s) {
- Allocation a1 = Allocation.createSized(rs, Element.F32_2(rs), 1024);
- Allocation a2 = Allocation.createSized(rs, Element.F32_2(rs), 1024);
-
- float[] f1 = new float[1024 * 2];
- float[] f2 = new float[1024 * 2];
- for (int ct=0; ct < f1.length; ct++) {
- f1[ct] = (float)ct;
- }
- a1.copyFrom(f1);
-
- s.forEach_copyFloat2(a1, a2);
-
- a2.copyTo(f2);
- for (int ct=0; ct < f1.length; ct++) {
- if (f1[ct] != f2[ct]) {
- failTest();
- Log.v("RS Test", "Compare failed at " + ct + ", " + f1[ct] + ", " + f2[ct]);
- }
- }
- a1.destroy();
- a2.destroy();
- }
-
- void testFloat3(RenderScript rs, ScriptC_copy_test s) {
- Allocation a1 = Allocation.createSized(rs, Element.F32_3(rs), 1024);
- Allocation a2 = Allocation.createSized(rs, Element.F32_3(rs), 1024);
-
- float[] f1 = new float[1024 * 4];
- float[] f2 = new float[1024 * 4];
- for (int ct=0; ct < f1.length; ct++) {
- f1[ct] = (float)ct;
- }
- a1.copyFrom(f1);
-
- s.forEach_copyFloat3(a1, a2);
-
- a2.copyTo(f2);
- for (int ct=0; ct < f1.length; ct++) {
- if ((f1[ct] != f2[ct]) && ((ct&3) != 3)) {
- failTest();
- Log.v("RS Test", "Compare failed at " + ct + ", " + f1[ct] + ", " + f2[ct]);
- }
- }
- a1.destroy();
- a2.destroy();
- }
-
- void testFloat4(RenderScript rs, ScriptC_copy_test s) {
- Allocation a1 = Allocation.createSized(rs, Element.F32_4(rs), 1024);
- Allocation a2 = Allocation.createSized(rs, Element.F32_4(rs), 1024);
-
- float[] f1 = new float[1024 * 4];
- float[] f2 = new float[1024 * 4];
- for (int ct=0; ct < f1.length; ct++) {
- f1[ct] = (float)ct;
- }
- a1.copyFrom(f1);
-
- s.forEach_copyFloat4(a1, a2);
-
- a2.copyTo(f2);
- for (int ct=0; ct < f1.length; ct++) {
- if (f1[ct] != f2[ct]) {
- failTest();
- Log.v("RS Test", "Compare failed at " + ct + ", " + f1[ct] + ", " + f2[ct]);
- }
- }
- a1.destroy();
- a2.destroy();
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_copy_test s = new ScriptC_copy_test(pRS);
- pRS.setMessageHandler(mRsMessage);
-
- testFloat2(pRS, s);
- testFloat3(pRS, s);
- testFloat4(pRS, s);
- s.invoke_sendResult(true);
-
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_element.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_element.java
deleted file mode 100644
index abfa44c..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_element.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_element extends UnitTest {
- private Resources mRes;
-
- Element simpleElem;
- Element complexElem;
-
- final String subElemNames[] = {
- "subElem0",
- "subElem1",
- "subElem2",
- "arrayElem0",
- "arrayElem1",
- "subElem3",
- "subElem4",
- "subElem5",
- "subElem6",
- "subElem_7",
- };
-
- final int subElemArraySizes[] = {
- 1,
- 1,
- 1,
- 2,
- 5,
- 1,
- 1,
- 1,
- 1,
- 1,
- };
-
- final int subElemOffsets[] = {
- 0,
- 4,
- 8,
- 12,
- 20,
- 40,
- 44,
- 48,
- 64,
- 80,
- };
-
- protected UT_element(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Element", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_element s) {
- simpleElem = Element.F32_3(RS);
- complexElem = ScriptField_ComplexStruct.createElement(RS);
- s.set_simpleElem(simpleElem);
- s.set_complexElem(complexElem);
-
- ScriptField_ComplexStruct data = new ScriptField_ComplexStruct(RS, 1);
- s.bind_complexStruct(data);
- }
-
- private void testScriptSide(RenderScript pRS) {
- ScriptC_element s = new ScriptC_element(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.invoke_element_test();
- pRS.finish();
- waitForMessage();
- }
-
- private void testJavaSide(RenderScript RS) {
-
- int subElemCount = simpleElem.getSubElementCount();
- _RS_ASSERT("subElemCount == 0", subElemCount == 0);
-
- subElemCount = complexElem.getSubElementCount();
- _RS_ASSERT("subElemCount == 10", subElemCount == 10);
- _RS_ASSERT("complexElem.getSizeBytes() == ScriptField_ComplexStruct.Item.sizeof",
- complexElem.getBytesSize() == ScriptField_ComplexStruct.Item.sizeof);
-
- for (int i = 0; i < subElemCount; i ++) {
- _RS_ASSERT("complexElem.getSubElement(i) != null",
- complexElem.getSubElement(i) != null);
- _RS_ASSERT("complexElem.getSubElementName(i).equals(subElemNames[i])",
- complexElem.getSubElementName(i).equals(subElemNames[i]));
- _RS_ASSERT("complexElem.getSubElementArraySize(i) == subElemArraySizes[i]",
- complexElem.getSubElementArraySize(i) == subElemArraySizes[i]);
- _RS_ASSERT("complexElem.getSubElementOffsetBytes(i) == subElemOffsets[i]",
- complexElem.getSubElementOffsetBytes(i) == subElemOffsets[i]);
- }
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- testScriptSide(pRS);
- testJavaSide(pRS);
- passTest();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_foreach.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_foreach.java
deleted file mode 100644
index fd18f93..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_foreach.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011-2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_foreach extends UnitTest {
- private Resources mRes;
- private Allocation A;
-
- protected UT_foreach(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "ForEach", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_foreach s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- int Y = 7;
- s.set_dimX(X);
- s.set_dimY(Y);
- typeBuilder.setX(X).setY(Y);
- A = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aRaw(A);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_foreach s = new ScriptC_foreach(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_root(A);
- s.invoke_verify_root();
- s.forEach_foo(A, A);
- s.invoke_verify_foo();
- s.invoke_foreach_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_foreach_bounds.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_foreach_bounds.java
deleted file mode 100644
index 13fefe7..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_foreach_bounds.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_foreach_bounds extends UnitTest {
- private Resources mRes;
- private Allocation A;
-
- protected UT_foreach_bounds(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "ForEach (bounds)", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_foreach_bounds s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- int Y = 7;
- s.set_dimX(X);
- s.set_dimY(Y);
- typeBuilder.setX(X).setY(Y);
- A = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aRaw(A);
- s.set_s(s);
- s.set_ain(A);
- s.set_aout(A);
- s.set_xStart(2);
- s.set_xEnd(5);
- s.set_yStart(3);
- s.set_yEnd(6);
- s.forEach_zero(A);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_foreach_bounds s = new ScriptC_foreach_bounds(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.invoke_foreach_bounds_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_fp_mad.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_fp_mad.java
deleted file mode 100644
index 960df24..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_fp_mad.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_fp_mad extends UnitTest {
- private Resources mRes;
-
- protected UT_fp_mad(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Fp_Mad", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_fp_mad s = new ScriptC_fp_mad(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_fp_mad_test(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_int4.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_int4.java
deleted file mode 100644
index 9592798..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_int4.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_int4 extends UnitTest {
- private Resources mRes;
-
- protected UT_int4(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "int4", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_int4 s = new ScriptC_int4(pRS, mRes, R.raw.int4);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_int4_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_kernel.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_kernel.java
deleted file mode 100644
index ec67665..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_kernel.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-import android.util.Log;
-
-public class UT_kernel extends UnitTest {
- private Resources mRes;
- private Allocation A;
- private Allocation B;
-
- protected UT_kernel(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Kernels (pass-by-value)", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_kernel s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- s.set_dimX(X);
- typeBuilder.setX(X);
- A = Allocation.createTyped(RS, typeBuilder.create());
- s.bind_ain(A);
- B = Allocation.createTyped(RS, typeBuilder.create());
- s.bind_aout(B);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_kernel s = new ScriptC_kernel(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_init_vars(A);
- s.forEach_root(A, B);
- s.invoke_verify_root();
- s.invoke_kernel_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_kernel_struct.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_kernel_struct.java
deleted file mode 100644
index 07538ec..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_kernel_struct.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-import android.util.Log;
-
-public class UT_kernel_struct extends UnitTest {
- private Resources mRes;
- private Allocation A;
- private Allocation B;
-
- protected UT_kernel_struct(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Kernels (struct pass-by-value)", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_kernel_struct s) {
- int X = 5;
- s.set_dimX(X);
- ScriptField_simpleStruct t;
- t = new ScriptField_simpleStruct(RS, X);
- s.bind_ain(t);
- A = t.getAllocation();
- t = new ScriptField_simpleStruct(RS, X);
- s.bind_aout(t);
- B = t.getAllocation();
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_kernel_struct s = new ScriptC_kernel_struct(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_init_vars(A);
- s.forEach_root(A, B);
- s.invoke_verify_root();
- s.invoke_kernel_struct_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_math.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_math.java
deleted file mode 100644
index 055c454..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_math.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_math extends UnitTest {
- private Resources mRes;
-
- protected UT_math(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Math", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_math s = new ScriptC_math(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_math_test(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_math_agree.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_math_agree.java
deleted file mode 100644
index a7e7429..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_math_agree.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-import android.util.Log;
-import java.util.Arrays;
-import java.util.Random;
-
-public class UT_math_agree extends UnitTest {
- private Resources mRes;
- private Random rand;
-
- protected UT_math_agree(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Math Agreement", ctx);
- mRes = res;
- rand = new Random();
- }
-
- // packing functions
- private Float2 pack_f2(float[] val) {
- assert val.length == 2;
- return new Float2(val[0], val[1]);
- }
- private Float3 pack_f3(float[] val) {
- assert val.length == 3;
- return new Float3(val[0], val[1], val[2]);
- }
- private Float4 pack_f4(float[] val) {
- assert val.length == 4;
- return new Float4(val[0], val[1], val[2], val[3]);
- }
- private Byte2 pack_b2(byte[] val) {
- assert val.length == 2;
- return new Byte2(val[0], val[1]);
- }
- private Byte3 pack_b3(byte[] val) {
- assert val.length == 3;
- return new Byte3(val[0], val[1], val[2]);
- }
- private Byte4 pack_b4(byte[] val) {
- assert val.length == 4;
- return new Byte4(val[0], val[1], val[2], val[3]);
- }
- private Short2 pack_s2(short[] val) {
- assert val.length == 2;
- return new Short2(val[0], val[1]);
- }
- private Short3 pack_s3(short[] val) {
- assert val.length == 3;
- return new Short3(val[0], val[1], val[2]);
- }
- private Short4 pack_s4(short[] val) {
- assert val.length == 4;
- return new Short4(val[0], val[1], val[2], val[3]);
- }
- private Int2 pack_i2(int[] val) {
- assert val.length == 2;
- return new Int2(val[0], val[1]);
- }
- private Int3 pack_i3(int[] val) {
- assert val.length == 3;
- return new Int3(val[0], val[1], val[2]);
- }
- private Int4 pack_i4(int[] val) {
- assert val.length == 4;
- return new Int4(val[0], val[1], val[2], val[3]);
- }
- private Long2 pack_l2(long[] val) {
- assert val.length == 2;
- return new Long2(val[0], val[1]);
- }
- private Long3 pack_l3(long[] val) {
- assert val.length == 3;
- return new Long3(val[0], val[1], val[2]);
- }
- private Long4 pack_l4(long[] val) {
- assert val.length == 4;
- return new Long4(val[0], val[1], val[2], val[3]);
- }
-
- // random vector generation functions
- private float[] randvec_float(int dim) {
- float[] fv = new float[dim];
- for (int i = 0; i < dim; ++i)
- fv[i] = rand.nextFloat();
- return fv;
- }
- private byte[] randvec_char(int dim) {
- byte[] cv = new byte[dim];
- rand.nextBytes(cv);
- return cv;
- }
- private short[] randvec_uchar(int dim) {
- short[] ucv = new short[dim];
- for (int i = 0; i < dim; ++i)
- ucv[i] = (short)rand.nextInt(0x1 << 8);
- return ucv;
- }
- private short[] randvec_short(int dim) {
- short[] sv = new short[dim];
- for (int i = 0; i < dim; ++i)
- sv[i] = (short)rand.nextInt(0x1 << 16);
- return sv;
- }
- private int[] randvec_ushort(int dim) {
- int[] usv = new int[dim];
- for (int i = 0; i < dim; ++i)
- usv[i] = rand.nextInt(0x1 << 16);
- return usv;
- }
- private int[] randvec_int(int dim) {
- int[] iv = new int[dim];
- for (int i = 0; i < dim; ++i)
- iv[i] = rand.nextInt();
- return iv;
- }
- private long[] randvec_uint(int dim) {
- long[] uiv = new long[dim];
- for (int i = 0; i < dim; ++i)
- uiv[i] = (long)rand.nextInt() - (long)Integer.MIN_VALUE;
- return uiv;
- }
- private long[] randvec_long(int dim) {
- long[] lv = new long[dim];
- for (int i = 0; i < dim; ++i)
- lv[i] = rand.nextLong();
- return lv;
- }
- // TODO: unsigned long generator
-
- // min reference functions
- private float min(float v1, float v2) {
- return v1 < v2 ? v1 : v2;
- }
- private float[] min(float[] v1, float[] v2) {
- assert v1.length == v2.length;
- float[] rv = new float[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
- private byte min(byte v1, byte v2) {
- return v1 < v2 ? v1 : v2;
- }
- private byte[] min(byte[] v1, byte[] v2) {
- assert v1.length == v2.length;
- byte[] rv = new byte[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
- private short min(short v1, short v2) {
- return v1 < v2 ? v1 : v2;
- }
- private short[] min(short[] v1, short[] v2) {
- assert v1.length == v2.length;
- short[] rv = new short[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
- private int min(int v1, int v2) {
- return v1 < v2 ? v1 : v2;
- }
- private int[] min(int[] v1, int[] v2) {
- assert v1.length == v2.length;
- int[] rv = new int[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
- private long min(long v1, long v2) {
- return v1 < v2 ? v1 : v2;
- }
- private long[] min(long[] v1, long[] v2) {
- assert v1.length == v2.length;
- long[] rv = new long[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
- // TODO: unsigned long version of min
-
- // max reference functions
- private float max(float v1, float v2) {
- return v1 > v2 ? v1 : v2;
- }
- private float[] max(float[] v1, float[] v2) {
- assert v1.length == v2.length;
- float[] rv = new float[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2[i]);
- return rv;
- }
- private byte max(byte v1, byte v2) {
- return v1 > v2 ? v1 : v2;
- }
- private byte[] max(byte[] v1, byte[] v2) {
- assert v1.length == v2.length;
- byte[] rv = new byte[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2[i]);
- return rv;
- }
- private short max(short v1, short v2) {
- return v1 > v2 ? v1 : v2;
- }
- private short[] max(short[] v1, short[] v2) {
- assert v1.length == v2.length;
- short[] rv = new short[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2[i]);
- return rv;
- }
- private int max(int v1, int v2) {
- return v1 > v2 ? v1 : v2;
- }
- private int[] max(int[] v1, int[] v2) {
- assert v1.length == v2.length;
- int[] rv = new int[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2[i]);
- return rv;
- }
- private long max(long v1, long v2) {
- return v1 > v2 ? v1 : v2;
- }
- private long[] max(long[] v1, long[] v2) {
- assert v1.length == v2.length;
- long[] rv = new long[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2[i]);
- return rv;
- }
- // TODO: unsigned long version of max
-
- // fmin reference functions
- private float fmin(float v1, float v2) {
- return min(v1, v2);
- }
- private float[] fmin(float[] v1, float[] v2) {
- return min(v1, v2);
- }
- private float[] fmin(float[] v1, float v2) {
- float[] rv = new float[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2);
- return rv;
- }
-
- // fmax reference functions
- private float fmax(float v1, float v2) {
- return max(v1, v2);
- }
- private float[] fmax(float[] v1, float[] v2) {
- return max(v1, v2);
- }
- private float[] fmax(float[] v1, float v2) {
- float[] rv = new float[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2);
- return rv;
- }
-
- private void initializeValues(ScriptC_math_agree s) {
- float x = rand.nextFloat();
- float y = rand.nextFloat();
-
- s.set_x(x);
- s.set_y(y);
- s.set_result_add(x + y);
- s.set_result_sub(x - y);
- s.set_result_mul(x * y);
- s.set_result_div(x / y);
-
- // Generate random vectors of all types
- float rand_f1_0 = rand.nextFloat();
- float[] rand_f2_0 = randvec_float(2);
- float[] rand_f3_0 = randvec_float(3);
- float[] rand_f4_0 = randvec_float(4);
- float rand_f1_1 = rand.nextFloat();
- float[] rand_f2_1 = randvec_float(2);
- float[] rand_f3_1 = randvec_float(3);
- float[] rand_f4_1 = randvec_float(4);
- short rand_uc1_0 = (short)rand.nextInt(0x1 << 8);
- short[] rand_uc2_0 = randvec_uchar(2);
- short[] rand_uc3_0 = randvec_uchar(3);
- short[] rand_uc4_0 = randvec_uchar(4);
- short rand_uc1_1 = (short)rand.nextInt(0x1 << 8);
- short[] rand_uc2_1 = randvec_uchar(2);
- short[] rand_uc3_1 = randvec_uchar(3);
- short[] rand_uc4_1 = randvec_uchar(4);
- short rand_ss1_0 = (short)rand.nextInt(0x1 << 16);
- short[] rand_ss2_0 = randvec_short(2);
- short[] rand_ss3_0 = randvec_short(3);
- short[] rand_ss4_0 = randvec_short(4);
- short rand_ss1_1 = (short)rand.nextInt(0x1 << 16);
- short[] rand_ss2_1 = randvec_short(2);
- short[] rand_ss3_1 = randvec_short(3);
- short[] rand_ss4_1 = randvec_short(4);
- int rand_us1_0 = rand.nextInt(0x1 << 16);
- int[] rand_us2_0 = randvec_ushort(2);
- int[] rand_us3_0 = randvec_ushort(3);
- int[] rand_us4_0 = randvec_ushort(4);
- int rand_us1_1 = rand.nextInt(0x1 << 16);
- int[] rand_us2_1 = randvec_ushort(2);
- int[] rand_us3_1 = randvec_ushort(3);
- int[] rand_us4_1 = randvec_ushort(4);
- int rand_si1_0 = rand.nextInt();
- int[] rand_si2_0 = randvec_int(2);
- int[] rand_si3_0 = randvec_int(3);
- int[] rand_si4_0 = randvec_int(4);
- int rand_si1_1 = rand.nextInt();
- int[] rand_si2_1 = randvec_int(2);
- int[] rand_si3_1 = randvec_int(3);
- int[] rand_si4_1 = randvec_int(4);
- long rand_ui1_0 = (long)rand.nextInt() - (long)Integer.MIN_VALUE;
- long[] rand_ui2_0 = randvec_uint(2);
- long[] rand_ui3_0 = randvec_uint(3);
- long[] rand_ui4_0 = randvec_uint(4);
- long rand_ui1_1 = (long)rand.nextInt() - (long)Integer.MIN_VALUE;
- long[] rand_ui2_1 = randvec_uint(2);
- long[] rand_ui3_1 = randvec_uint(3);
- long[] rand_ui4_1 = randvec_uint(4);
- long rand_sl1_0 = rand.nextLong();
- long[] rand_sl2_0 = randvec_long(2);
- long[] rand_sl3_0 = randvec_long(3);
- long[] rand_sl4_0 = randvec_long(4);
- long rand_sl1_1 = rand.nextLong();
- long[] rand_sl2_1 = randvec_long(2);
- long[] rand_sl3_1 = randvec_long(3);
- long[] rand_sl4_1 = randvec_long(4);
- byte rand_sc1_0 = (byte)rand.nextInt(0x1 << 8);
- byte[] rand_sc2_0 = randvec_char(2);
- byte[] rand_sc3_0 = randvec_char(3);
- byte[] rand_sc4_0 = randvec_char(4);
- byte rand_sc1_1 = (byte)rand.nextInt(0x1 << 8);
- byte[] rand_sc2_1 = randvec_char(2);
- byte[] rand_sc3_1 = randvec_char(3);
- byte[] rand_sc4_1 = randvec_char(4);
- // TODO: generate unsigned long vectors
-
- // Set random vectors in renderscript code
- s.set_rand_f1_0(rand_f1_0);
- s.set_rand_f2_0(pack_f2(rand_f2_0));
- s.set_rand_f3_0(pack_f3(rand_f3_0));
- s.set_rand_f4_0(pack_f4(rand_f4_0));
- s.set_rand_f1_1(rand_f1_1);
- s.set_rand_f2_1(pack_f2(rand_f2_1));
- s.set_rand_f3_1(pack_f3(rand_f3_1));
- s.set_rand_f4_1(pack_f4(rand_f4_1));
- s.set_rand_uc1_1(rand_uc1_1);
- s.set_rand_uc2_1(pack_s2(rand_uc2_1));
- s.set_rand_uc3_1(pack_s3(rand_uc3_1));
- s.set_rand_uc4_1(pack_s4(rand_uc4_1));
- s.set_rand_ss1_0(rand_ss1_0);
- s.set_rand_ss2_0(pack_s2(rand_ss2_0));
- s.set_rand_ss3_0(pack_s3(rand_ss3_0));
- s.set_rand_ss4_0(pack_s4(rand_ss4_0));
- s.set_rand_ss1_1(rand_ss1_1);
- s.set_rand_ss2_1(pack_s2(rand_ss2_1));
- s.set_rand_ss3_1(pack_s3(rand_ss3_1));
- s.set_rand_ss4_1(pack_s4(rand_ss4_1));
- s.set_rand_us1_0(rand_us1_0);
- s.set_rand_us2_0(pack_i2(rand_us2_0));
- s.set_rand_us3_0(pack_i3(rand_us3_0));
- s.set_rand_us4_0(pack_i4(rand_us4_0));
- s.set_rand_us1_1(rand_us1_1);
- s.set_rand_us2_1(pack_i2(rand_us2_1));
- s.set_rand_us3_1(pack_i3(rand_us3_1));
- s.set_rand_us4_1(pack_i4(rand_us4_1));
- s.set_rand_si1_0(rand_si1_0);
- s.set_rand_si2_0(pack_i2(rand_si2_0));
- s.set_rand_si3_0(pack_i3(rand_si3_0));
- s.set_rand_si4_0(pack_i4(rand_si4_0));
- s.set_rand_si1_1(rand_si1_1);
- s.set_rand_si2_1(pack_i2(rand_si2_1));
- s.set_rand_si3_1(pack_i3(rand_si3_1));
- s.set_rand_si4_1(pack_i4(rand_si4_1));
- s.set_rand_ui1_0(rand_ui1_0);
- s.set_rand_ui2_0(pack_l2(rand_ui2_0));
- s.set_rand_ui3_0(pack_l3(rand_ui3_0));
- s.set_rand_ui4_0(pack_l4(rand_ui4_0));
- s.set_rand_ui1_1(rand_ui1_1);
- s.set_rand_ui2_1(pack_l2(rand_ui2_1));
- s.set_rand_ui3_1(pack_l3(rand_ui3_1));
- s.set_rand_ui4_1(pack_l4(rand_ui4_1));
- s.set_rand_sl1_0(rand_sl1_0);
- s.set_rand_sl2_0(pack_l2(rand_sl2_0));
- s.set_rand_sl3_0(pack_l3(rand_sl3_0));
- s.set_rand_sl4_0(pack_l4(rand_sl4_0));
- s.set_rand_sl1_1(rand_sl1_1);
- s.set_rand_sl2_1(pack_l2(rand_sl2_1));
- s.set_rand_sl3_1(pack_l3(rand_sl3_1));
- s.set_rand_sl4_1(pack_l4(rand_sl4_1));
- s.set_rand_uc1_0(rand_uc1_0);
- s.set_rand_uc2_0(pack_s2(rand_uc2_0));
- s.set_rand_uc3_0(pack_s3(rand_uc3_0));
- s.set_rand_uc4_0(pack_s4(rand_uc4_0));
- s.set_rand_sc1_0(rand_sc1_0);
- s.set_rand_sc2_0(pack_b2(rand_sc2_0));
- s.set_rand_sc3_0(pack_b3(rand_sc3_0));
- s.set_rand_sc4_0(pack_b4(rand_sc4_0));
- s.set_rand_sc1_1(rand_sc1_1);
- s.set_rand_sc2_1(pack_b2(rand_sc2_1));
- s.set_rand_sc3_1(pack_b3(rand_sc3_1));
- s.set_rand_sc4_1(pack_b4(rand_sc4_1));
- // TODO: set unsigned long vectors
-
- // Set results for min
- s.set_min_rand_f1_f1(min(rand_f1_0, rand_f1_1));
- s.set_min_rand_f2_f2(pack_f2(min(rand_f2_0, rand_f2_1)));
- s.set_min_rand_f3_f3(pack_f3(min(rand_f3_0, rand_f3_1)));
- s.set_min_rand_f4_f4(pack_f4(min(rand_f4_0, rand_f4_1)));
- s.set_min_rand_uc1_uc1(min(rand_uc1_0, rand_uc1_1));
- s.set_min_rand_uc2_uc2(pack_s2(min(rand_uc2_0, rand_uc2_1)));
- s.set_min_rand_uc3_uc3(pack_s3(min(rand_uc3_0, rand_uc3_1)));
- s.set_min_rand_uc4_uc4(pack_s4(min(rand_uc4_0, rand_uc4_1)));
- s.set_min_rand_ss1_ss1(min(rand_ss1_0, rand_ss1_1));
- s.set_min_rand_ss2_ss2(pack_s2(min(rand_ss2_0, rand_ss2_1)));
- s.set_min_rand_ss3_ss3(pack_s3(min(rand_ss3_0, rand_ss3_1)));
- s.set_min_rand_ss4_ss4(pack_s4(min(rand_ss4_0, rand_ss4_1)));
- s.set_min_rand_us1_us1(min(rand_us1_0, rand_us1_1));
- s.set_min_rand_us2_us2(pack_i2(min(rand_us2_0, rand_us2_1)));
- s.set_min_rand_us3_us3(pack_i3(min(rand_us3_0, rand_us3_1)));
- s.set_min_rand_us4_us4(pack_i4(min(rand_us4_0, rand_us4_1)));
- s.set_min_rand_si1_si1(min(rand_si1_0, rand_si1_1));
- s.set_min_rand_si2_si2(pack_i2(min(rand_si2_0, rand_si2_1)));
- s.set_min_rand_si3_si3(pack_i3(min(rand_si3_0, rand_si3_1)));
- s.set_min_rand_si4_si4(pack_i4(min(rand_si4_0, rand_si4_1)));
- s.set_min_rand_ui1_ui1(min(rand_ui1_0, rand_ui1_1));
- s.set_min_rand_ui2_ui2(pack_l2(min(rand_ui2_0, rand_ui2_1)));
- s.set_min_rand_ui3_ui3(pack_l3(min(rand_ui3_0, rand_ui3_1)));
- s.set_min_rand_ui4_ui4(pack_l4(min(rand_ui4_0, rand_ui4_1)));
- s.set_min_rand_sl1_sl1(min(rand_sl1_0, rand_sl1_1));
- s.set_min_rand_sl2_sl2(pack_l2(min(rand_sl2_0, rand_sl2_1)));
- s.set_min_rand_sl3_sl3(pack_l3(min(rand_sl3_0, rand_sl3_1)));
- s.set_min_rand_sl4_sl4(pack_l4(min(rand_sl4_0, rand_sl4_1)));
- s.set_min_rand_sc1_sc1(min(rand_sc1_0, rand_sc1_1));
- s.set_min_rand_sc2_sc2(pack_b2(min(rand_sc2_0, rand_sc2_1)));
- s.set_min_rand_sc3_sc3(pack_b3(min(rand_sc3_0, rand_sc3_1)));
- s.set_min_rand_sc4_sc4(pack_b4(min(rand_sc4_0, rand_sc4_1)));
- // TODO: set results for unsigned long min
-
- // Set results for max
- s.set_max_rand_f1_f1(max(rand_f1_0, rand_f1_1));
- s.set_max_rand_f2_f2(pack_f2(max(rand_f2_0, rand_f2_1)));
- s.set_max_rand_f3_f3(pack_f3(max(rand_f3_0, rand_f3_1)));
- s.set_max_rand_f4_f4(pack_f4(max(rand_f4_0, rand_f4_1)));
- s.set_max_rand_uc1_uc1(max(rand_uc1_0, rand_uc1_1));
- s.set_max_rand_uc2_uc2(pack_s2(max(rand_uc2_0, rand_uc2_1)));
- s.set_max_rand_uc3_uc3(pack_s3(max(rand_uc3_0, rand_uc3_1)));
- s.set_max_rand_uc4_uc4(pack_s4(max(rand_uc4_0, rand_uc4_1)));
- s.set_max_rand_ss1_ss1(max(rand_ss1_0, rand_ss1_1));
- s.set_max_rand_ss2_ss2(pack_s2(max(rand_ss2_0, rand_ss2_1)));
- s.set_max_rand_ss3_ss3(pack_s3(max(rand_ss3_0, rand_ss3_1)));
- s.set_max_rand_ss4_ss4(pack_s4(max(rand_ss4_0, rand_ss4_1)));
- s.set_max_rand_us1_us1(max(rand_us1_0, rand_us1_1));
- s.set_max_rand_us2_us2(pack_i2(max(rand_us2_0, rand_us2_1)));
- s.set_max_rand_us3_us3(pack_i3(max(rand_us3_0, rand_us3_1)));
- s.set_max_rand_us4_us4(pack_i4(max(rand_us4_0, rand_us4_1)));
- s.set_max_rand_si1_si1(max(rand_si1_0, rand_si1_1));
- s.set_max_rand_si2_si2(pack_i2(max(rand_si2_0, rand_si2_1)));
- s.set_max_rand_si3_si3(pack_i3(max(rand_si3_0, rand_si3_1)));
- s.set_max_rand_si4_si4(pack_i4(max(rand_si4_0, rand_si4_1)));
- s.set_max_rand_ui1_ui1(max(rand_ui1_0, rand_ui1_1));
- s.set_max_rand_ui2_ui2(pack_l2(max(rand_ui2_0, rand_ui2_1)));
- s.set_max_rand_ui3_ui3(pack_l3(max(rand_ui3_0, rand_ui3_1)));
- s.set_max_rand_ui4_ui4(pack_l4(max(rand_ui4_0, rand_ui4_1)));
- s.set_max_rand_sl1_sl1(max(rand_sl1_0, rand_sl1_1));
- s.set_max_rand_sl2_sl2(pack_l2(max(rand_sl2_0, rand_sl2_1)));
- s.set_max_rand_sl3_sl3(pack_l3(max(rand_sl3_0, rand_sl3_1)));
- s.set_max_rand_sl4_sl4(pack_l4(max(rand_sl4_0, rand_sl4_1)));
- s.set_max_rand_sc1_sc1(max(rand_sc1_0, rand_sc1_1));
- s.set_max_rand_sc2_sc2(pack_b2(max(rand_sc2_0, rand_sc2_1)));
- s.set_max_rand_sc3_sc3(pack_b3(max(rand_sc3_0, rand_sc3_1)));
- s.set_max_rand_sc4_sc4(pack_b4(max(rand_sc4_0, rand_sc4_1)));
-
- // TODO: set results for unsigned long max
-
- // Set results for fmin
- s.set_fmin_rand_f1_f1(fmin(rand_f1_0, rand_f1_1));
- s.set_fmin_rand_f2_f2(pack_f2(fmin(rand_f2_0, rand_f2_1)));
- s.set_fmin_rand_f3_f3(pack_f3(fmin(rand_f3_0, rand_f3_1)));
- s.set_fmin_rand_f4_f4(pack_f4(fmin(rand_f4_0, rand_f4_1)));
- s.set_fmin_rand_f2_f1(pack_f2(fmin(rand_f2_0, rand_f1_1)));
- s.set_fmin_rand_f3_f1(pack_f3(fmin(rand_f3_0, rand_f1_1)));
- s.set_fmin_rand_f4_f1(pack_f4(fmin(rand_f4_0, rand_f1_1)));
-
- // Set results for fmax
- s.set_fmax_rand_f1_f1(fmax(rand_f1_0, rand_f1_1));
- s.set_fmax_rand_f2_f2(pack_f2(fmax(rand_f2_0, rand_f2_1)));
- s.set_fmax_rand_f3_f3(pack_f3(fmax(rand_f3_0, rand_f3_1)));
- s.set_fmax_rand_f4_f4(pack_f4(fmax(rand_f4_0, rand_f4_1)));
- s.set_fmax_rand_f2_f1(pack_f2(fmax(rand_f2_0, rand_f1_1)));
- s.set_fmax_rand_f3_f1(pack_f3(fmax(rand_f3_0, rand_f1_1)));
- s.set_fmax_rand_f4_f1(pack_f4(fmax(rand_f4_0, rand_f1_1)));
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_math_agree s = new ScriptC_math_agree(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeValues(s);
- s.invoke_math_agree_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_math_conformance.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_math_conformance.java
deleted file mode 100644
index 384cd13..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_math_conformance.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_math_conformance extends UnitTest {
- private Resources mRes;
-
- protected UT_math_conformance(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Math Conformance", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_math_conformance s =
- new ScriptC_math_conformance(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_math_conformance_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- passTest();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_min.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_min.java
deleted file mode 100644
index cea9fe5..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_min.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_min extends UnitTest {
- private Resources mRes;
-
- protected UT_min(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Min (relaxed)", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_min s = new ScriptC_min(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_min_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_noroot.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_noroot.java
deleted file mode 100644
index 606af4d..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_noroot.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011-2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_noroot extends UnitTest {
- private Resources mRes;
- private Allocation A;
-
- protected UT_noroot(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "ForEach (no root)", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_noroot s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- int Y = 7;
- s.set_dimX(X);
- s.set_dimY(Y);
- typeBuilder.setX(X).setY(Y);
- A = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aRaw(A);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_noroot s = new ScriptC_noroot(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_foo(A, A);
- s.invoke_verify_foo();
- s.invoke_noroot_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_primitives.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_primitives.java
deleted file mode 100644
index 3c663a8..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_primitives.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_primitives extends UnitTest {
- private Resources mRes;
-
- protected UT_primitives(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Primitives", ctx);
- mRes = res;
- }
-
- private boolean initializeGlobals(ScriptC_primitives s) {
- float pF = s.get_floatTest();
- if (pF != 1.99f) {
- return false;
- }
- s.set_floatTest(2.99f);
-
- double pD = s.get_doubleTest();
- if (pD != 2.05) {
- return false;
- }
- s.set_doubleTest(3.05);
-
- byte pC = s.get_charTest();
- if (pC != -8) {
- return false;
- }
- s.set_charTest((byte)-16);
-
- short pS = s.get_shortTest();
- if (pS != -16) {
- return false;
- }
- s.set_shortTest((short)-32);
-
- int pI = s.get_intTest();
- if (pI != -32) {
- return false;
- }
- s.set_intTest(-64);
-
- long pL = s.get_longTest();
- if (pL != 17179869184l) {
- return false;
- }
- s.set_longTest(17179869185l);
-
- long puL = s.get_ulongTest();
- if (puL != 4611686018427387904L) {
- return false;
- }
- s.set_ulongTest(4611686018427387903L);
-
-
- long pLL = s.get_longlongTest();
- if (pLL != 68719476736L) {
- return false;
- }
- s.set_longlongTest(68719476735L);
-
- long pu64 = s.get_uint64_tTest();
- if (pu64 != 117179869184l) {
- return false;
- }
- s.set_uint64_tTest(117179869185l);
-
- return true;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_primitives s = new ScriptC_primitives(pRS);
- pRS.setMessageHandler(mRsMessage);
- if (!initializeGlobals(s)) {
- failTest();
- } else {
- s.invoke_primitives_test(0, 0);
- pRS.finish();
- waitForMessage();
- }
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_refcount.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_refcount.java
deleted file mode 100644
index e6317d5..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_refcount.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_refcount extends UnitTest {
- private Resources mRes;
-
- protected UT_refcount(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Refcount", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_refcount s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 500;
- int Y = 700;
- typeBuilder.setX(X).setY(Y);
- Allocation A = Allocation.createTyped(RS, typeBuilder.create());
- s.set_globalA(A);
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- pRS.setMessageHandler(mRsMessage);
- ScriptC_refcount s = new ScriptC_refcount(pRS);
- initializeGlobals(pRS, s);
- s.invoke_refcount_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_rsdebug.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_rsdebug.java
deleted file mode 100644
index 740180e..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_rsdebug.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_rsdebug extends UnitTest {
- private Resources mRes;
-
- protected UT_rsdebug(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsDebug", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rsdebug s = new ScriptC_rsdebug(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_test_rsdebug(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_rstime.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_rstime.java
deleted file mode 100644
index 86e35a8..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_rstime.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_rstime extends UnitTest {
- private Resources mRes;
-
- protected UT_rstime(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsTime", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rstime s = new ScriptC_rstime(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.setTimeZone("America/Los_Angeles");
- s.invoke_test_rstime(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_rstypes.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_rstypes.java
deleted file mode 100644
index 3245eca..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_rstypes.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_rstypes extends UnitTest {
- private Resources mRes;
-
- protected UT_rstypes(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsTypes", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rstypes s = new ScriptC_rstypes(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_test_rstypes(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_sampler.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_sampler.java
deleted file mode 100644
index d8d5a78..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_sampler.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_sampler extends UnitTest {
- private Resources mRes;
-
- Sampler minification;
- Sampler magnification;
- Sampler wrapS;
- Sampler wrapT;
- Sampler anisotropy;
-
- protected UT_sampler(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Sampler", ctx);
- mRes = res;
- }
-
- private Sampler.Builder getDefaultBuilder(RenderScript RS) {
- Sampler.Builder b = new Sampler.Builder(RS);
- b.setMinification(Sampler.Value.NEAREST);
- b.setMagnification(Sampler.Value.NEAREST);
- b.setWrapS(Sampler.Value.CLAMP);
- b.setWrapT(Sampler.Value.CLAMP);
- b.setAnisotropy(1.0f);
- return b;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_sampler s) {
- Sampler.Builder b = getDefaultBuilder(RS);
- b.setMinification(Sampler.Value.LINEAR_MIP_LINEAR);
- minification = b.create();
-
- b = getDefaultBuilder(RS);
- b.setMagnification(Sampler.Value.LINEAR);
- magnification = b.create();
-
- b = getDefaultBuilder(RS);
- b.setWrapS(Sampler.Value.WRAP);
- wrapS = b.create();
-
- b = getDefaultBuilder(RS);
- b.setWrapT(Sampler.Value.WRAP);
- wrapT = b.create();
-
- b = getDefaultBuilder(RS);
- b.setAnisotropy(8.0f);
- anisotropy = b.create();
-
- s.set_minification(minification);
- s.set_magnification(magnification);
- s.set_wrapS(wrapS);
- s.set_wrapT(wrapT);
- s.set_anisotropy(anisotropy);
- }
-
- private void testScriptSide(RenderScript pRS) {
- ScriptC_sampler s = new ScriptC_sampler(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.invoke_sampler_test();
- pRS.finish();
- waitForMessage();
- }
-
- private void testJavaSide(RenderScript RS) {
- _RS_ASSERT("minification.getMagnification() == Sampler.Value.NEAREST",
- minification.getMagnification() == Sampler.Value.NEAREST);
- _RS_ASSERT("minification.getMinification() == Sampler.Value.LINEAR_MIP_LINEAR",
- minification.getMinification() == Sampler.Value.LINEAR_MIP_LINEAR);
- _RS_ASSERT("minification.getWrapS() == Sampler.Value.CLAMP",
- minification.getWrapS() == Sampler.Value.CLAMP);
- _RS_ASSERT("minification.getWrapT() == Sampler.Value.CLAMP",
- minification.getWrapT() == Sampler.Value.CLAMP);
- _RS_ASSERT("minification.getAnisotropy() == 1.0f",
- minification.getAnisotropy() == 1.0f);
-
- _RS_ASSERT("magnification.getMagnification() == Sampler.Value.LINEAR",
- magnification.getMagnification() == Sampler.Value.LINEAR);
- _RS_ASSERT("magnification.getMinification() == Sampler.Value.NEAREST",
- magnification.getMinification() == Sampler.Value.NEAREST);
- _RS_ASSERT("magnification.getWrapS() == Sampler.Value.CLAMP",
- magnification.getWrapS() == Sampler.Value.CLAMP);
- _RS_ASSERT("magnification.getWrapT() == Sampler.Value.CLAMP",
- magnification.getWrapT() == Sampler.Value.CLAMP);
- _RS_ASSERT("magnification.getAnisotropy() == 1.0f",
- magnification.getAnisotropy() == 1.0f);
-
- _RS_ASSERT("wrapS.getMagnification() == Sampler.Value.NEAREST",
- wrapS.getMagnification() == Sampler.Value.NEAREST);
- _RS_ASSERT("wrapS.getMinification() == Sampler.Value.NEAREST",
- wrapS.getMinification() == Sampler.Value.NEAREST);
- _RS_ASSERT("wrapS.getWrapS() == Sampler.Value.WRAP",
- wrapS.getWrapS() == Sampler.Value.WRAP);
- _RS_ASSERT("wrapS.getWrapT() == Sampler.Value.CLAMP",
- wrapS.getWrapT() == Sampler.Value.CLAMP);
- _RS_ASSERT("wrapS.getAnisotropy() == 1.0f",
- wrapS.getAnisotropy() == 1.0f);
-
- _RS_ASSERT("wrapT.getMagnification() == Sampler.Value.NEAREST",
- wrapT.getMagnification() == Sampler.Value.NEAREST);
- _RS_ASSERT("wrapT.getMinification() == Sampler.Value.NEAREST",
- wrapT.getMinification() == Sampler.Value.NEAREST);
- _RS_ASSERT("wrapT.getWrapS() == Sampler.Value.CLAMP",
- wrapT.getWrapS() == Sampler.Value.CLAMP);
- _RS_ASSERT("wrapT.getWrapT() == Sampler.Value.WRAP",
- wrapT.getWrapT() == Sampler.Value.WRAP);
- _RS_ASSERT("wrapT.getAnisotropy() == 1.0f",
- wrapT.getAnisotropy() == 1.0f);
-
- _RS_ASSERT("anisotropy.getMagnification() == Sampler.Value.NEAREST",
- anisotropy.getMagnification() == Sampler.Value.NEAREST);
- _RS_ASSERT("anisotropy.getMinification() == Sampler.Value.NEAREST",
- anisotropy.getMinification() == Sampler.Value.NEAREST);
- _RS_ASSERT("anisotropy.getWrapS() == Sampler.Value.CLAMP",
- anisotropy.getWrapS() == Sampler.Value.CLAMP);
- _RS_ASSERT("anisotropy.getWrapT() == Sampler.Value.CLAMP",
- anisotropy.getWrapT() == Sampler.Value.CLAMP);
- _RS_ASSERT("anisotropy.getAnisotropy() == 1.0f",
- anisotropy.getAnisotropy() == 8.0f);
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- testScriptSide(pRS);
- testJavaSide(pRS);
- passTest();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_struct.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_struct.java
deleted file mode 100644
index 43bbaf7..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_struct.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_struct extends UnitTest {
- private Resources mRes;
-
- protected UT_struct(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Struct", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_struct s = new ScriptC_struct(pRS);
- pRS.setMessageHandler(mRsMessage);
-
- ScriptField_Point2 p = new ScriptField_Point2(pRS, 1);
- ScriptField_Point2.Item i = new ScriptField_Point2.Item();
- int val = 100;
- i.x = val;
- i.y = val;
- p.set(i, 0, true);
- s.bind_point2(p);
- s.invoke_struct_test(val);
- pRS.finish();
- waitForMessage();
-
- val = 200;
- p.set_x(0, val, true);
- p.set_y(0, val, true);
- s.invoke_struct_test(val);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_unsigned.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_unsigned.java
deleted file mode 100644
index 0e16240..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_unsigned.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_unsigned extends UnitTest {
- private Resources mRes;
-
- protected UT_unsigned(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Unsigned", ctx);
- mRes = res;
- }
-
- private boolean initializeGlobals(ScriptC_unsigned s) {
- short pUC = s.get_uc();
- if (pUC != 5) {
- return false;
- }
- s.set_uc((short)129);
-
- long pUI = s.get_ui();
- if (pUI != 37) {
- return false;
- }
- s.set_ui(0x7fffffff);
-
- return true;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_unsigned s = new ScriptC_unsigned(pRS);
- pRS.setMessageHandler(mRsMessage);
- if (!initializeGlobals(s)) {
- failTest();
- } else {
- s.invoke_unsigned_test();
- pRS.finish();
- waitForMessage();
- }
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_vector.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_vector.java
deleted file mode 100644
index 6ba822e..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UT_vector.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.*;
-
-public class UT_vector extends UnitTest {
- private Resources mRes;
-
- protected UT_vector(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Vector", ctx);
- mRes = res;
- }
-
- private boolean initializeGlobals(ScriptC_vector s) {
- Float2 F2 = s.get_f2();
- if (F2.x != 1.0f || F2.y != 2.0f) {
- return false;
- }
- F2.x = 2.99f;
- F2.y = 3.99f;
- s.set_f2(F2);
-
- Float3 F3 = s.get_f3();
- if (F3.x != 1.0f || F3.y != 2.0f || F3.z != 3.0f) {
- return false;
- }
- F3.x = 2.99f;
- F3.y = 3.99f;
- F3.z = 4.99f;
- s.set_f3(F3);
-
- Float4 F4 = s.get_f4();
- if (F4.x != 1.0f || F4.y != 2.0f || F4.z != 3.0f || F4.w != 4.0f) {
- return false;
- }
- F4.x = 2.99f;
- F4.y = 3.99f;
- F4.z = 4.99f;
- F4.w = 5.99f;
- s.set_f4(F4);
-
- Double2 D2 = s.get_d2();
- if (D2.x != 1.0 || D2.y != 2.0) {
- return false;
- }
- D2.x = 2.99;
- D2.y = 3.99;
- s.set_d2(D2);
-
- Double3 D3 = s.get_d3();
- if (D3.x != 1.0 || D3.y != 2.0 || D3.z != 3.0) {
- return false;
- }
- D3.x = 2.99;
- D3.y = 3.99;
- D3.z = 4.99;
- s.set_d3(D3);
-
- Double4 D4 = s.get_d4();
- if (D4.x != 1.0 || D4.y != 2.0 || D4.z != 3.0 || D4.w != 4.0) {
- return false;
- }
- D4.x = 2.99;
- D4.y = 3.99;
- D4.z = 4.99;
- D4.w = 5.99;
- s.set_d4(D4);
-
- Byte2 B2 = s.get_i8_2();
- if (B2.x != 1 || B2.y != 2) {
- return false;
- }
- B2.x = 2;
- B2.y = 3;
- s.set_i8_2(B2);
-
- Byte3 B3 = s.get_i8_3();
- if (B3.x != 1 || B3.y != 2 || B3.z != 3) {
- return false;
- }
- B3.x = 2;
- B3.y = 3;
- B3.z = 4;
- s.set_i8_3(B3);
-
- Byte4 B4 = s.get_i8_4();
- if (B4.x != 1 || B4.y != 2 || B4.z != 3 || B4.w != 4) {
- return false;
- }
- B4.x = 2;
- B4.y = 3;
- B4.z = 4;
- B4.w = 5;
- s.set_i8_4(B4);
-
- Short2 S2 = s.get_u8_2();
- if (S2.x != 1 || S2.y != 2) {
- return false;
- }
- S2.x = 2;
- S2.y = 3;
- s.set_u8_2(S2);
-
- Short3 S3 = s.get_u8_3();
- if (S3.x != 1 || S3.y != 2 || S3.z != 3) {
- return false;
- }
- S3.x = 2;
- S3.y = 3;
- S3.z = 4;
- s.set_u8_3(S3);
-
- Short4 S4 = s.get_u8_4();
- if (S4.x != 1 || S4.y != 2 || S4.z != 3 || S4.w != 4) {
- return false;
- }
- S4.x = 2;
- S4.y = 3;
- S4.z = 4;
- S4.w = 5;
- s.set_u8_4(S4);
-
- S2 = s.get_i16_2();
- if (S2.x != 1 || S2.y != 2) {
- return false;
- }
- S2.x = 2;
- S2.y = 3;
- s.set_i16_2(S2);
-
- S3 = s.get_i16_3();
- if (S3.x != 1 || S3.y != 2 || S3.z != 3) {
- return false;
- }
- S3.x = 2;
- S3.y = 3;
- S3.z = 4;
- s.set_i16_3(S3);
-
- S4 = s.get_i16_4();
- if (S4.x != 1 || S4.y != 2 || S4.z != 3 || S4.w != 4) {
- return false;
- }
- S4.x = 2;
- S4.y = 3;
- S4.z = 4;
- S4.w = 5;
- s.set_i16_4(S4);
-
- Int2 I2 = s.get_u16_2();
- if (I2.x != 1 || I2.y != 2) {
- return false;
- }
- I2.x = 2;
- I2.y = 3;
- s.set_u16_2(I2);
-
- Int3 I3 = s.get_u16_3();
- if (I3.x != 1 || I3.y != 2 || I3.z != 3) {
- return false;
- }
- I3.x = 2;
- I3.y = 3;
- I3.z = 4;
- s.set_u16_3(I3);
-
- Int4 I4 = s.get_u16_4();
- if (I4.x != 1 || I4.y != 2 || I4.z != 3 || I4.w != 4) {
- return false;
- }
- I4.x = 2;
- I4.y = 3;
- I4.z = 4;
- I4.w = 5;
- s.set_u16_4(I4);
-
- I2 = s.get_i32_2();
- if (I2.x != 1 || I2.y != 2) {
- return false;
- }
- I2.x = 2;
- I2.y = 3;
- s.set_i32_2(I2);
-
- I3 = s.get_i32_3();
- if (I3.x != 1 || I3.y != 2 || I3.z != 3) {
- return false;
- }
- I3.x = 2;
- I3.y = 3;
- I3.z = 4;
- s.set_i32_3(I3);
-
- I4 = s.get_i32_4();
- if (I4.x != 1 || I4.y != 2 || I4.z != 3 || I4.w != 4) {
- return false;
- }
- I4.x = 2;
- I4.y = 3;
- I4.z = 4;
- I4.w = 5;
- s.set_i32_4(I4);
-
- Long2 L2 = s.get_u32_2();
- if (L2.x != 1 || L2.y != 2) {
- return false;
- }
- L2.x = 2;
- L2.y = 3;
- s.set_u32_2(L2);
-
- Long3 L3 = s.get_u32_3();
- if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
- return false;
- }
- L3.x = 2;
- L3.y = 3;
- L3.z = 4;
- s.set_u32_3(L3);
-
- Long4 L4 = s.get_u32_4();
- if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
- return false;
- }
- L4.x = 2;
- L4.y = 3;
- L4.z = 4;
- L4.w = 5;
- s.set_u32_4(L4);
-
- L2 = s.get_i64_2();
- if (L2.x != 1 || L2.y != 2) {
- return false;
- }
- L2.x = 2;
- L2.y = 3;
- s.set_i64_2(L2);
-
- L3 = s.get_i64_3();
- if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
- return false;
- }
- L3.x = 2;
- L3.y = 3;
- L3.z = 4;
- s.set_i64_3(L3);
-
- L4 = s.get_i64_4();
- if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
- return false;
- }
- L4.x = 2;
- L4.y = 3;
- L4.z = 4;
- L4.w = 5;
- s.set_i64_4(L4);
-
- L2 = s.get_u64_2();
- if (L2.x != 1 || L2.y != 2) {
- return false;
- }
- L2.x = 2;
- L2.y = 3;
- s.set_u64_2(L2);
-
- L3 = s.get_u64_3();
- if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
- return false;
- }
- L3.x = 2;
- L3.y = 3;
- L3.z = 4;
- s.set_u64_3(L3);
-
- L4 = s.get_u64_4();
- if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
- return false;
- }
- L4.x = 2;
- L4.y = 3;
- L4.z = 4;
- L4.w = 5;
- s.set_u64_4(L4);
-
- return true;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_vector s = new ScriptC_vector(pRS);
- pRS.setMessageHandler(mRsMessage);
- if (!initializeGlobals(s)) {
- failTest();
- } else {
- s.invoke_vector_test();
- pRS.finish();
- waitForMessage();
- }
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UnitTest.java b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UnitTest.java
deleted file mode 100644
index 01abf2f..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/UnitTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2013 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.rs.test_compat;
-import android.content.Context;
-import android.util.Log;
-import android.support.v8.renderscript.RenderScript.RSMessageHandler;
-
-public class UnitTest extends Thread {
- public String name;
- private int result;
- private ScriptField_ListAllocs_s.Item mItem;
- private RSTestCore mRSTC;
- private boolean msgHandled;
- protected Context mCtx;
-
- /* These constants must match those in shared.rsh */
- public static final int RS_MSG_TEST_PASSED = 100;
- public static final int RS_MSG_TEST_FAILED = 101;
-
- private static int numTests = 0;
- public int testID;
-
- protected UnitTest(RSTestCore rstc, String n, int initResult, Context ctx) {
- super();
- mRSTC = rstc;
- name = n;
- msgHandled = false;
- mCtx = ctx;
- result = initResult;
- testID = numTests++;
- }
-
- protected UnitTest(RSTestCore rstc, String n, Context ctx) {
- this(rstc, n, 0, ctx);
- }
-
- protected UnitTest(RSTestCore rstc, Context ctx) {
- this (rstc, "<Unknown>", ctx);
- }
-
- protected UnitTest(Context ctx) {
- this (null, ctx);
- }
-
- protected void _RS_ASSERT(String message, boolean b) {
- if(b == false) {
- Log.e(name, message + " FAILED");
- failTest();
- }
- }
-
- private void updateUI() {
- if (mItem != null) {
- mItem.result = result;
- msgHandled = true;
- try {
- mRSTC.refreshTestResults();
- }
- catch (IllegalStateException e) {
- /* Ignore the case where our message receiver has been
- disconnected. This happens when we leave the application
- before it finishes running all of the unit tests. */
- }
- }
- }
-
- protected RSMessageHandler mRsMessage = new RSMessageHandler() {
- public void run() {
- if (result == 0) {
- switch (mID) {
- case RS_MSG_TEST_PASSED:
- result = 1;
- break;
- case RS_MSG_TEST_FAILED:
- result = -1;
- break;
- default:
- RSTest.log("Unit test got unexpected message");
- return;
- }
- }
-
- updateUI();
- }
- };
-
- public void waitForMessage() {
- while (!msgHandled) {
- yield();
- }
- }
-
- public int getResult() {
- return result;
- }
-
- public void failTest() {
- result = -1;
- updateUI();
- }
-
- public void passTest() {
- if (result != -1) {
- result = 1;
- }
- updateUI();
- }
-
- public String toString() {
- String out = name;
- if (result == 1) {
- out += " - PASSED";
- }
- else if (result == -1) {
- out += " - FAILED";
- }
- return out;
- }
-
- public void setItem(ScriptField_ListAllocs_s.Item item) {
- mItem = item;
- }
-
- public void run() {
- /* This method needs to be implemented for each subclass */
- if (mRSTC != null) {
- mRSTC.refreshTestResults();
- }
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/alloc.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/alloc.rs
deleted file mode 100644
index 1b5e2ac..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/alloc.rs
+++ /dev/null
@@ -1,92 +0,0 @@
-#include "shared.rsh"
-
-int *a;
-int dimX;
-int dimY;
-int dimZ;
-
-rs_allocation aRaw;
-rs_allocation aFaces;
-rs_allocation aLOD;
-rs_allocation aFacesLOD;
-
-void root(int *o, uint32_t x, uint32_t y) {
- *o = x + y * dimX;
-}
-
-static bool test_alloc_dims() {
- bool failed = false;
- int i, j;
-
- _RS_ASSERT(rsAllocationGetDimX(aRaw) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aRaw) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aRaw) == dimZ);
-
- // Test 2D addressing
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- rsDebug("Verifying ", i + j * dimX);
- const void *p = rsGetElementAt(aRaw, i, j);
- int val = *(const int *)p;
- _RS_ASSERT(val == (i + j * dimX));
- }
- }
-
- // Test 1D addressing
- for (i = 0; i < dimX; i++) {
- rsDebug("Verifying ", i);
- const void *p = rsGetElementAt(aRaw, i);
- int val = *(const int *)p;
- _RS_ASSERT(val == i);
- }
-
- // Test 3D addressing
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- rsDebug("Verifying ", i + j * dimX);
- const void *p = rsGetElementAt(aRaw, i, j, 0);
- int val = *(const int *)p;
- _RS_ASSERT(val == (i + j * dimX));
- }
- }
-
- _RS_ASSERT(rsAllocationGetDimX(aFaces) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aFaces) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aFaces) == dimZ);
- _RS_ASSERT(rsAllocationGetDimFaces(aFaces) != 0);
- _RS_ASSERT(rsAllocationGetDimLOD(aFaces) == 0);
-
- _RS_ASSERT(rsAllocationGetDimX(aLOD) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aLOD) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aLOD) == dimZ);
- _RS_ASSERT(rsAllocationGetDimFaces(aLOD) == 0);
- _RS_ASSERT(rsAllocationGetDimLOD(aLOD) != 0);
-
- _RS_ASSERT(rsAllocationGetDimX(aFacesLOD) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aFacesLOD) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aFacesLOD) == dimZ);
- _RS_ASSERT(rsAllocationGetDimFaces(aFacesLOD) != 0);
- _RS_ASSERT(rsAllocationGetDimLOD(aFacesLOD) != 0);
-
- if (failed) {
- rsDebug("test_alloc_dims FAILED", 0);
- }
- else {
- rsDebug("test_alloc_dims PASSED", 0);
- }
-
- return failed;
-}
-
-void alloc_test() {
- bool failed = false;
- failed |= test_alloc_dims();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/array_alloc.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/array_alloc.rs
deleted file mode 100644
index 74ffdb1..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/array_alloc.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "shared.rsh"
-
-const int dimX = 20;
-rs_allocation a[dimX];
-
-void array_alloc_test() {
- bool failed = false;
-
- for (int i = 0; i < dimX; i++) {
- rsDebug("i: ", i);
- _RS_ASSERT(rsAllocationGetDimX(a[i]) == 1);
- }
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/array_init.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/array_init.rs
deleted file mode 100644
index 842249a..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/array_init.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-#include "shared.rsh"
-
-// Testing constant array initialization
-float fa[4] = {1.0, 9.9999f};
-double da[2] = {7.0, 8.88888};
-char ca[4] = {'a', 7, 'b', 'c'};
-short sa[4] = {1, 1, 2, 3};
-int ia[4] = {5, 8};
-long la[2] = {13, 21};
-long long lla[4] = {34};
-bool ba[3] = {true, false};
-
-void array_init_test() {
- bool failed = false;
-
- _RS_ASSERT(fa[0] == 1.0);
- _RS_ASSERT(fa[1] == 9.9999f);
- _RS_ASSERT(fa[2] == 0);
- _RS_ASSERT(fa[3] == 0);
-
- _RS_ASSERT(da[0] == 7.0);
- _RS_ASSERT(da[1] == 8.88888);
-
- _RS_ASSERT(ca[0] == 'a');
- _RS_ASSERT(ca[1] == 7);
- _RS_ASSERT(ca[2] == 'b');
- _RS_ASSERT(ca[3] == 'c');
-
- _RS_ASSERT(sa[0] == 1);
- _RS_ASSERT(sa[1] == 1);
- _RS_ASSERT(sa[2] == 2);
- _RS_ASSERT(sa[3] == 3);
-
- _RS_ASSERT(ia[0] == 5);
- _RS_ASSERT(ia[1] == 8);
- _RS_ASSERT(ia[2] == 0);
- _RS_ASSERT(ia[3] == 0);
-
- _RS_ASSERT(la[0] == 13);
- _RS_ASSERT(la[1] == 21);
-
- _RS_ASSERT(lla[0] == 34);
- _RS_ASSERT(lla[1] == 0);
- _RS_ASSERT(lla[2] == 0);
- _RS_ASSERT(lla[3] == 0);
-
- _RS_ASSERT(ba[0] == true);
- _RS_ASSERT(ba[1] == false);
- _RS_ASSERT(ba[2] == false);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/atomic.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/atomic.rs
deleted file mode 100644
index f0a5041..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/atomic.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-#include "shared.rsh"
-
-// Testing atomic operations
-static bool testUMax(uint32_t dst, uint32_t src) {
- bool failed = false;
- uint32_t old = dst;
- uint32_t expect = (dst > src ? dst : src);
- uint32_t ret = rsAtomicMax(&dst, src);
- _RS_ASSERT(old == ret);
- _RS_ASSERT(dst == expect);
- return failed;
-}
-
-static bool testUMin(uint32_t dst, uint32_t src) {
- bool failed = false;
- uint32_t old = dst;
- uint32_t expect = (dst < src ? dst : src);
- uint32_t ret = rsAtomicMin(&dst, src);
- _RS_ASSERT(old == ret);
- _RS_ASSERT(dst == expect);
- return failed;
-}
-
-static bool testUCas(uint32_t dst, uint32_t cmp, uint32_t swp) {
- bool failed = false;
- uint32_t old = dst;
- uint32_t expect = (dst == cmp ? swp : dst);
- uint32_t ret = rsAtomicCas(&dst, cmp, swp);
- _RS_ASSERT(old == ret);
- _RS_ASSERT(dst == expect);
- return failed;
-}
-
-static bool test_atomics() {
- bool failed = false;
-
- failed |= testUMax(5, 6);
- failed |= testUMax(6, 5);
- failed |= testUMax(5, 0xf0000006);
- failed |= testUMax(0xf0000006, 5);
-
- failed |= testUMin(5, 6);
- failed |= testUMin(6, 5);
- failed |= testUMin(5, 0xf0000006);
- failed |= testUMin(0xf0000006, 5);
-
- failed |= testUCas(4, 4, 5);
- failed |= testUCas(4, 5, 5);
- failed |= testUCas(5, 5, 4);
- failed |= testUCas(5, 4, 4);
- failed |= testUCas(0xf0000004, 0xf0000004, 0xf0000005);
- failed |= testUCas(0xf0000004, 0xf0000005, 0xf0000005);
- failed |= testUCas(0xf0000005, 0xf0000005, 0xf0000004);
- failed |= testUCas(0xf0000005, 0xf0000004, 0xf0000004);
-
- if (failed) {
- rsDebug("test_atomics FAILED", 0);
- }
- else {
- rsDebug("test_atomics PASSED", 0);
- }
-
- return failed;
-}
-
-void atomic_test() {
- bool failed = false;
- failed |= test_atomics();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/bug_char.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/bug_char.rs
deleted file mode 100644
index dcd7b72..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/bug_char.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "shared.rsh"
-
-char rand_sc1_0, rand_sc1_1;
-char2 rand_sc2_0, rand_sc2_1;
-
-char min_rand_sc1_sc1;
-char2 min_rand_sc2_sc2;
-
-static bool test_bug_char() {
- bool failed = false;
-
- rsDebug("rand_sc2_0.x: ", rand_sc2_0.x);
- rsDebug("rand_sc2_0.y: ", rand_sc2_0.y);
- rsDebug("rand_sc2_1.x: ", rand_sc2_1.x);
- rsDebug("rand_sc2_1.y: ", rand_sc2_1.y);
- char temp_sc1;
- char2 temp_sc2;
-
- temp_sc1 = min( rand_sc1_0, rand_sc1_1 );
- if (temp_sc1 != min_rand_sc1_sc1) {
- rsDebug("temp_sc1", temp_sc1);
- failed = true;
- }
- rsDebug("broken", 'y');
-
- temp_sc2 = min( rand_sc2_0, rand_sc2_1 );
- if (temp_sc2.x != min_rand_sc2_sc2.x
- || temp_sc2.y != min_rand_sc2_sc2.y) {
- failed = true;
- }
-
-
- return failed;
-}
-
-void bug_char_test() {
- bool failed = false;
- failed |= test_bug_char();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/clamp.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/clamp.rs
deleted file mode 100644
index 28b00bd..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/clamp.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "shared.rsh"
-
-static bool test_clamp_vector() {
- bool failed = false;
-
- float2 src2 = { 2.0f, 2.0f};
- float2 min2 = { 0.5f, -3.0f};
- float2 max2 = { 1.0f, 9.0f};
-
- float2 res2 = clamp(src2, min2, max2);
- _RS_ASSERT(res2.x == 1.0f);
- _RS_ASSERT(res2.y == 2.0f);
-
-
- float3 src3 = { 2.0f, 2.0f, 1.0f};
- float3 min3 = { 0.5f, -3.0f, 3.0f};
- float3 max3 = { 1.0f, 9.0f, 4.0f};
-
- float3 res3 = clamp(src3, min3, max3);
- _RS_ASSERT(res3.x == 1.0f);
- _RS_ASSERT(res3.y == 2.0f);
- _RS_ASSERT(res3.z == 3.0f);
-
-
- float4 src4 = { 2.0f, 2.0f, 1.0f, 4.0f };
- float4 min4 = { 0.5f, -3.0f, 3.0f, 4.0f };
- float4 max4 = { 1.0f, 9.0f, 4.0f, 4.0f };
-
- float4 res4 = clamp(src4, min4, max4);
- _RS_ASSERT(res4.x == 1.0f);
- _RS_ASSERT(res4.y == 2.0f);
- _RS_ASSERT(res4.z == 3.0f);
- _RS_ASSERT(res4.w == 4.0f);
-
- if (failed) {
- rsDebug("test_clamp_vector FAILED", 0);
- }
- else {
- rsDebug("test_clamp_vector PASSED", 0);
- }
-
- return failed;
-}
-
-void clamp_test() {
- bool failed = false;
- failed |= test_clamp_vector();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/clamp_relaxed.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/clamp_relaxed.rs
deleted file mode 100644
index 71c65ae..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/clamp_relaxed.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "clamp.rs"
-#pragma rs_fp_relaxed
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/constant.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/constant.rs
deleted file mode 100644
index 732eaef..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/constant.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "shared.rsh"
-
-const float floatTest = 1.99f;
-const double doubleTest = 2.05;
-const char charTest = -8;
-const short shortTest = -16;
-const int intTest = -32;
-const long longTest = 17179869184l; // 1 << 34
-const long long longlongTest = 68719476736l; // 1 << 36
-
-const uchar ucharTest = 8;
-const ushort ushortTest = 16;
-const uint uintTest = 32;
-const ulong ulongTest = 4611686018427387904L;
-const int64_t int64_tTest = -17179869184l; // - 1 << 34
-const uint64_t uint64_tTest = 117179869184l;
-
-const bool boolTest = true;
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/convert.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/convert.rs
deleted file mode 100644
index e314f2b..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/convert.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "shared.rsh"
-
-float4 f4 = { 2.0f, 4.0f, 6.0f, 8.0f };
-
-char4 i8_4 = { -1, -2, -3, 4 };
-
-static bool test_convert() {
- bool failed = false;
-
- f4 = convert_float4(i8_4);
- _RS_ASSERT(f4.x == -1.0f);
- _RS_ASSERT(f4.y == -2.0f);
- _RS_ASSERT(f4.z == -3.0f);
- _RS_ASSERT(f4.w == 4.0f);
-
- if (failed) {
- rsDebug("test_convert FAILED", 0);
- }
- else {
- rsDebug("test_convert PASSED", 0);
- }
-
- return failed;
-}
-
-void convert_test() {
- bool failed = false;
- failed |= test_convert();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/convert_relaxed.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/convert_relaxed.rs
deleted file mode 100644
index 81abb9b..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/convert_relaxed.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "convert.rs"
-#pragma rs_fp_relaxed
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/copy_test.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/copy_test.rs
deleted file mode 100644
index f4243eb..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/copy_test.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "shared.rsh"
-
-void sendResult(bool pass) {
- if (pass) {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
-}
-
-
-float2 __attribute((kernel)) copyFloat2(float2 i) {
- return i;
-}
-
-float3 __attribute((kernel)) copyFloat3(float3 i) {
- return i;
-}
-
-float4 __attribute((kernel)) copyFloat4(float4 i) {
- return i;
-}
-
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/element.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/element.rs
deleted file mode 100644
index 1f24775..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/element.rs
+++ /dev/null
@@ -1,156 +0,0 @@
-#include "shared.rsh"
-#include "rs_graphics.rsh"
-
-rs_element simpleElem;
-rs_element complexElem;
-typedef struct ComplexStruct {
- float subElem0;
- float subElem1;
- int subElem2;
- float arrayElem0[2];
- int arrayElem1[5];
- char subElem3;
- float subElem4;
- float2 subElem5;
- float3 subElem6;
- float4 subElem_7;
-} ComplexStruct_t;
-
-ComplexStruct_t *complexStruct;
-
-static const char *subElemNames[] = {
- "subElem0",
- "subElem1",
- "subElem2",
- "arrayElem0",
- "arrayElem1",
- "subElem3",
- "subElem4",
- "subElem5",
- "subElem6",
- "subElem_7",
-};
-
-static uint32_t subElemNamesSizes[] = {
- 8,
- 8,
- 8,
- 10,
- 10,
- 8,
- 8,
- 8,
- 8,
- 9,
-};
-
-static uint32_t subElemArraySizes[] = {
- 1,
- 1,
- 1,
- 2,
- 5,
- 1,
- 1,
- 1,
- 1,
- 1,
-};
-
-static void resetStruct() {
- uint8_t *bytePtr = (uint8_t*)complexStruct;
- uint32_t sizeOfStruct = sizeof(*complexStruct);
- for(uint32_t i = 0; i < sizeOfStruct; i ++) {
- bytePtr[i] = 0;
- }
-}
-
-static bool equals(const char *name0, const char * name1, uint32_t len) {
- for (uint32_t i = 0; i < len; i ++) {
- if (name0[i] != name1[i]) {
- return false;
- }
- }
- return true;
-}
-
-static bool test_element_getters() {
- bool failed = false;
-
- uint32_t subElemOffsets[10];
- uint32_t index = 0;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem0 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem1 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem2 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->arrayElem0 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->arrayElem1 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem3 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem4 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem5 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem6 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem_7 - (uint32_t)complexStruct;
-
- uint32_t subElemCount = rsElementGetSubElementCount(simpleElem);
- _RS_ASSERT(subElemCount == 0);
- _RS_ASSERT(rsElementGetDataType(simpleElem) == RS_TYPE_FLOAT_32);
- _RS_ASSERT(rsElementGetVectorSize(simpleElem) == 3);
-
- subElemCount = rsElementGetSubElementCount(complexElem);
- _RS_ASSERT(subElemCount == 10);
- _RS_ASSERT(rsElementGetDataType(complexElem) == RS_TYPE_NONE);
- _RS_ASSERT(rsElementGetVectorSize(complexElem) == 1);
- _RS_ASSERT(rsElementGetBytesSize(complexElem) == sizeof(*complexStruct));
-
- char buffer[64];
- for (uint32_t i = 0; i < subElemCount; i ++) {
- rs_element subElem = rsElementGetSubElement(complexElem, i);
- _RS_ASSERT(rsIsObject(subElem));
-
- _RS_ASSERT(rsElementGetSubElementNameLength(complexElem, i) == subElemNamesSizes[i] + 1);
-
- uint32_t written = rsElementGetSubElementName(complexElem, i, buffer, 64);
- _RS_ASSERT(written == subElemNamesSizes[i]);
- _RS_ASSERT(equals(buffer, subElemNames[i], written));
-
- _RS_ASSERT(rsElementGetSubElementArraySize(complexElem, i) == subElemArraySizes[i]);
- _RS_ASSERT(rsElementGetSubElementOffsetBytes(complexElem, i) == subElemOffsets[i]);
- }
-
- // Tests error checking
- rs_element subElem = rsElementGetSubElement(complexElem, subElemCount);
- _RS_ASSERT(!rsIsObject(subElem));
-
- _RS_ASSERT(rsElementGetSubElementNameLength(complexElem, subElemCount) == 0);
-
- _RS_ASSERT(rsElementGetSubElementName(complexElem, subElemCount, buffer, 64) == 0);
- _RS_ASSERT(rsElementGetSubElementName(complexElem, 0, NULL, 64) == 0);
- _RS_ASSERT(rsElementGetSubElementName(complexElem, 0, buffer, 0) == 0);
- uint32_t written = rsElementGetSubElementName(complexElem, 0, buffer, 5);
- _RS_ASSERT(written == 4);
- _RS_ASSERT(buffer[4] == '\0');
-
- _RS_ASSERT(rsElementGetSubElementArraySize(complexElem, subElemCount) == 0);
- _RS_ASSERT(rsElementGetSubElementOffsetBytes(complexElem, subElemCount) == 0);
-
- if (failed) {
- rsDebug("test_element_getters FAILED", 0);
- }
- else {
- rsDebug("test_element_getters PASSED", 0);
- }
-
- return failed;
-}
-
-void element_test() {
- bool failed = false;
- failed |= test_element_getters();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/foreach.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/foreach.rs
deleted file mode 100644
index 08e6bed..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/foreach.rs
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "shared.rsh"
-
-rs_allocation aRaw;
-int dimX;
-int dimY;
-static bool failed = false;
-
-void root(int *out, uint32_t x, uint32_t y) {
- *out = x + y * dimX;
-}
-
-void foo(const int *in, int *out, uint32_t x, uint32_t y) {
- _RS_ASSERT(*in == (x + y * dimX));
- *out = 99 + x + y * dimX;
- _RS_ASSERT(*out == (99 + x + y * dimX));
-}
-
-static bool test_root_output() {
- bool failed = false;
- int i, j;
-
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- int v = rsGetElementAt_int(aRaw, i, j);
- _RS_ASSERT(v == (i + j * dimX));
- }
- }
-
- if (failed) {
- rsDebug("test_root_output FAILED", 0);
- }
- else {
- rsDebug("test_root_output PASSED", 0);
- }
-
- return failed;
-}
-
-static bool test_foo_output() {
- bool failed = false;
- int i, j;
-
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- int v = rsGetElementAt_int(aRaw, i, j);
- _RS_ASSERT(v == (99 + i + j * dimX));
- }
- }
-
- if (failed) {
- rsDebug("test_foo_output FAILED", 0);
- }
- else {
- rsDebug("test_foo_output PASSED", 0);
- }
-
- return failed;
-}
-
-void verify_root() {
- failed |= test_root_output();
-}
-
-void verify_foo() {
- failed |= test_foo_output();
-}
-
-void foreach_test() {
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/foreach_bounds.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/foreach_bounds.rs
deleted file mode 100644
index 89df090..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/foreach_bounds.rs
+++ /dev/null
@@ -1,72 +0,0 @@
-#include "shared.rsh"
-
-int dimX;
-int dimY;
-int xStart = 0;
-int xEnd = 0;
-int yStart = 0;
-int yEnd = 0;
-
-rs_script s;
-rs_allocation aRaw;
-rs_allocation ain;
-rs_allocation aout;
-
-void root(int *out, uint32_t x, uint32_t y) {
- *out = x + y * dimX;
-}
-
-int __attribute__((kernel)) zero() {
- return 0;
-}
-
-static bool test_root_output() {
- bool failed = false;
- int i, j;
-
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- int v = rsGetElementAt_int(aRaw, i, j);
- rsDebug("i: ", i);
- rsDebug("j: ", j);
- rsDebug("a[j][i]: ", v);
- if (i < xStart || i >= xEnd || j < yStart || j >= yEnd) {
- _RS_ASSERT(v == 0);
- } else {
- _RS_ASSERT(v == (i + j * dimX));
- }
- }
- }
-
- if (failed) {
- rsDebug("test_root_output FAILED", 0);
- }
- else {
- rsDebug("test_root_output PASSED", 0);
- }
-
- return failed;
-}
-
-void foreach_bounds_test() {
- static bool failed = false;
-
- rs_script_call_t rssc = {0};
- rssc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
- rssc.xStart = xStart;
- rssc.xEnd = xEnd;
- rssc.yStart = yStart;
- rssc.yEnd = yEnd;
-
- rsForEach(s, ain, aout, NULL, 0, &rssc);
-
- failed |= test_root_output();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/fp_mad.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/fp_mad.rs
deleted file mode 100644
index b6f2b2a6..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/fp_mad.rs
+++ /dev/null
@@ -1,174 +0,0 @@
-#include "shared.rsh"
-
-const int TEST_COUNT = 1;
-
-static float data_f1[1025];
-static float4 data_f4[1025];
-
-static void test_mad4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~1 billion ops
- for (int ct=0; ct < 1000 * (1000 / 80); ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = (data_f4[i] * 0.02f +
- data_f4[i+1] * 0.04f +
- data_f4[i+2] * 0.05f +
- data_f4[i+3] * 0.1f +
- data_f4[i+4] * 0.2f +
- data_f4[i+5] * 0.2f +
- data_f4[i+6] * 0.1f +
- data_f4[i+7] * 0.05f +
- data_f4[i+8] * 0.04f +
- data_f4[i+9] * 0.02f + 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_mad4 M ops", 1000.f / time);
-}
-
-static void test_mad(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~1 billion ops
- for (int ct=0; ct < 1000 * (1000 / 20); ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = (data_f1[i] * 0.02f +
- data_f1[i+1] * 0.04f +
- data_f1[i+2] * 0.05f +
- data_f1[i+3] * 0.1f +
- data_f1[i+4] * 0.2f +
- data_f1[i+5] * 0.2f +
- data_f1[i+6] * 0.1f +
- data_f1[i+7] * 0.05f +
- data_f1[i+8] * 0.04f +
- data_f1[i+9] * 0.02f + 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_mad M ops", 1000.f / time);
-}
-
-static void test_norm(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = normalize(data_f4[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_norm M ops", 10.f / time);
-}
-
-static void test_sincos4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10 / 4; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = sin(data_f4[i]) * cos(data_f4[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_sincos4 M ops", 10.f / time);
-}
-
-static void test_sincos(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = sin(data_f1[i]) * cos(data_f1[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_sincos M ops", 10.f / time);
-}
-
-static void test_clamp(uint32_t index) {
- start();
-
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = clamp(data_f1[i], -1.f, 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_clamp M ops", 100.f / time);
-
- start();
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100; ct++) {
- for (int i=0; i < (1000); i++) {
- if (data_f1[i] < -1.f) data_f1[i] = -1.f;
- if (data_f1[i] > -1.f) data_f1[i] = 1.f;
- }
- }
-
- time = end(index);
- rsDebug("fp_clamp ref M ops", 100.f / time);
-}
-
-static void test_clamp4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100 /4; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = clamp(data_f4[i], -1.f, 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_clamp4 M ops", 100.f / time);
-}
-
-void fp_mad_test(uint32_t index, int test_num) {
- int x;
- for (x=0; x < 1025; x++) {
- data_f1[x] = (x & 0xf) * 0.1f;
- data_f4[x].x = (x & 0xf) * 0.1f;
- data_f4[x].y = (x & 0xf0) * 0.1f;
- data_f4[x].z = (x & 0x33) * 0.1f;
- data_f4[x].w = (x & 0x77) * 0.1f;
- }
-
- test_mad4(index);
- test_mad(index);
-
- for (x=0; x < 1025; x++) {
- data_f1[x] = (x & 0xf) * 0.1f + 1.f;
- data_f4[x].x = (x & 0xf) * 0.1f + 1.f;
- data_f4[x].y = (x & 0xf0) * 0.1f + 1.f;
- data_f4[x].z = (x & 0x33) * 0.1f + 1.f;
- data_f4[x].w = (x & 0x77) * 0.1f + 1.f;
- }
-
- test_norm(index);
- test_sincos4(index);
- test_sincos(index);
- test_clamp4(index);
- test_clamp(index);
-
- // TODO Actually verify test result accuracy
- rsDebug("fp_mad_test PASSED", 0);
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
-}
-
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/int4.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/int4.rs
deleted file mode 100644
index c791cab..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/int4.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "shared.rsh"
-#pragma rs_fp_relaxed
-
-uchar4 u4 = 4;
-int4 gi4 = {2, 2, 2, 2};
-
-void int4_test() {
- bool failed = false;
- int4 i4 = {u4.x, u4.y, u4.z, u4.w};
- i4 *= gi4;
-
- rsDebug("i4.x", i4.x);
- rsDebug("i4.y", i4.y);
- rsDebug("i4.z", i4.z);
- rsDebug("i4.w", i4.w);
-
- _RS_ASSERT(i4.x == 8);
- _RS_ASSERT(i4.y == 8);
- _RS_ASSERT(i4.z == 8);
- _RS_ASSERT(i4.w == 8);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/kernel.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/kernel.rs
deleted file mode 100644
index d6c9df3..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/kernel.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "shared.rsh"
-
-int *ain;
-int *aout;
-int dimX;
-static bool failed = false;
-
-void init_vars(int *out) {
- *out = 7;
-}
-
-
-int __attribute__((kernel)) root(int ain, uint32_t x) {
- _RS_ASSERT(ain == 7);
- return ain + x;
-}
-
-static bool test_root_output() {
- bool failed = false;
- int i;
-
- for (i = 0; i < dimX; i++) {
- _RS_ASSERT(aout[i] == (i + ain[i]));
- }
-
- if (failed) {
- rsDebug("test_root_output FAILED", 0);
- }
- else {
- rsDebug("test_root_output PASSED", 0);
- }
-
- return failed;
-}
-
-void verify_root() {
- failed |= test_root_output();
-}
-
-void kernel_test() {
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/kernel_struct.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/kernel_struct.rs
deleted file mode 100644
index 62c30ae..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/kernel_struct.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "shared.rsh"
-
-struct simpleStruct {
- int i1;
- char ignored1;
- float f1;
- int i2;
- char ignored2;
- float f2;
-};
-
-struct simpleStruct *ain;
-struct simpleStruct *aout;
-int dimX;
-static bool failed = false;
-
-void init_vars(struct simpleStruct *out, uint32_t x) {
- out->i1 = 0;
- out->f1 = 0.f;
- out->i2 = 1;
- out->f2 = 1.0f;
-}
-
-struct simpleStruct __attribute__((kernel))
- root(struct simpleStruct in, uint32_t x) {
- struct simpleStruct s;
- s.i1 = in.i1 + x;
- s.f1 = in.f1 + x;
- s.i2 = in.i2 + x;
- s.f2 = in.f2 + x;
- return s;
-}
-
-static bool test_root_output() {
- bool failed = false;
- int i;
-
- for (i = 0; i < dimX; i++) {
- _RS_ASSERT(aout[i].i1 == (i + ain[i].i1));
- _RS_ASSERT(aout[i].f1 == (i + ain[i].f1));
- _RS_ASSERT(aout[i].i2 == (i + ain[i].i2));
- _RS_ASSERT(aout[i].f2 == (i + ain[i].f2));
- }
-
- if (failed) {
- rsDebug("test_root_output FAILED", 0);
- }
- else {
- rsDebug("test_root_output PASSED", 0);
- }
-
- return failed;
-}
-
-void verify_root() {
- failed |= test_root_output();
-}
-
-void kernel_struct_test() {
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/math.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/math.rs
deleted file mode 100644
index aae29a4..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/math.rs
+++ /dev/null
@@ -1,436 +0,0 @@
-#include "shared.rsh"
-
-// Testing math library
-
-volatile float f1;
-volatile float2 f2;
-volatile float3 f3;
-volatile float4 f4;
-
-volatile int i1;
-volatile int2 i2;
-volatile int3 i3;
-volatile int4 i4;
-
-volatile uint ui1;
-volatile uint2 ui2;
-volatile uint3 ui3;
-volatile uint4 ui4;
-
-volatile short s1;
-volatile short2 s2;
-volatile short3 s3;
-volatile short4 s4;
-
-volatile ushort us1;
-volatile ushort2 us2;
-volatile ushort3 us3;
-volatile ushort4 us4;
-
-volatile char c1;
-volatile char2 c2;
-volatile char3 c3;
-volatile char4 c4;
-
-volatile uchar uc1;
-volatile uchar2 uc2;
-volatile uchar3 uc3;
-volatile uchar4 uc4;
-
-#define DECL_INT(prefix) \
-volatile char prefix##_c_1 = 1; \
-volatile char2 prefix##_c_2 = 1; \
-volatile char3 prefix##_c_3 = 1; \
-volatile char4 prefix##_c_4 = 1; \
-volatile uchar prefix##_uc_1 = 1; \
-volatile uchar2 prefix##_uc_2 = 1; \
-volatile uchar3 prefix##_uc_3 = 1; \
-volatile uchar4 prefix##_uc_4 = 1; \
-volatile short prefix##_s_1 = 1; \
-volatile short2 prefix##_s_2 = 1; \
-volatile short3 prefix##_s_3 = 1; \
-volatile short4 prefix##_s_4 = 1; \
-volatile ushort prefix##_us_1 = 1; \
-volatile ushort2 prefix##_us_2 = 1; \
-volatile ushort3 prefix##_us_3 = 1; \
-volatile ushort4 prefix##_us_4 = 1; \
-volatile int prefix##_i_1 = 1; \
-volatile int2 prefix##_i_2 = 1; \
-volatile int3 prefix##_i_3 = 1; \
-volatile int4 prefix##_i_4 = 1; \
-volatile uint prefix##_ui_1 = 1; \
-volatile uint2 prefix##_ui_2 = 1; \
-volatile uint3 prefix##_ui_3 = 1; \
-volatile uint4 prefix##_ui_4 = 1; \
-volatile long prefix##_l_1 = 1; \
-volatile ulong prefix##_ul_1 = 1;
-
-DECL_INT(res)
-DECL_INT(src1)
-DECL_INT(src2)
-
-#define TEST_INT_OP_TYPE(op, type) \
-rsDebug("Testing " #op " for " #type "1", i++); \
-res_##type##_1 = src1_##type##_1 op src2_##type##_1; \
-rsDebug("Testing " #op " for " #type "2", i++); \
-res_##type##_2 = src1_##type##_2 op src2_##type##_2; \
-rsDebug("Testing " #op " for " #type "3", i++); \
-res_##type##_3 = src1_##type##_3 op src2_##type##_3; \
-rsDebug("Testing " #op " for " #type "4", i++); \
-res_##type##_4 = src1_##type##_4 op src2_##type##_4;
-
-#define TEST_INT_OP(op) \
-TEST_INT_OP_TYPE(op, c) \
-TEST_INT_OP_TYPE(op, uc) \
-TEST_INT_OP_TYPE(op, s) \
-TEST_INT_OP_TYPE(op, us) \
-TEST_INT_OP_TYPE(op, i) \
-TEST_INT_OP_TYPE(op, ui) \
-rsDebug("Testing " #op " for l1", i++); \
-res_l_1 = src1_l_1 op src2_l_1; \
-rsDebug("Testing " #op " for ul1", i++); \
-res_ul_1 = src1_ul_1 op src2_ul_1;
-
-#define TEST_XN_FUNC_YN(typeout, fnc, typein) \
- res_##typeout##_1 = fnc(src1_##typein##_1); \
- res_##typeout##_2 = fnc(src1_##typein##_2); \
- res_##typeout##_3 = fnc(src1_##typein##_3); \
- res_##typeout##_4 = fnc(src1_##typein##_4);
-
-#define TEST_XN_FUNC_XN_XN(type, fnc) \
- res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1); \
- res_##type##_2 = fnc(src1_##type##_2, src2_##type##_2); \
- res_##type##_3 = fnc(src1_##type##_3, src2_##type##_3); \
- res_##type##_4 = fnc(src1_##type##_4, src2_##type##_4);
-
-#define TEST_X_FUNC_X_X_X(type, fnc) \
- res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1, src2_##type##_1);
-
-#define TEST_IN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_YN(uc, fnc, uc) \
- TEST_XN_FUNC_YN(c, fnc, c) \
- TEST_XN_FUNC_YN(us, fnc, us) \
- TEST_XN_FUNC_YN(s, fnc, s) \
- TEST_XN_FUNC_YN(ui, fnc, ui) \
- TEST_XN_FUNC_YN(i, fnc, i)
-
-#define TEST_UIN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_YN(uc, fnc, c) \
- TEST_XN_FUNC_YN(us, fnc, s) \
- TEST_XN_FUNC_YN(ui, fnc, i) \
-
-#define TEST_IN_FUNC_IN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_XN_XN(uc, fnc) \
- TEST_XN_FUNC_XN_XN(c, fnc) \
- TEST_XN_FUNC_XN_XN(us, fnc) \
- TEST_XN_FUNC_XN_XN(s, fnc) \
- TEST_XN_FUNC_XN_XN(ui, fnc) \
- TEST_XN_FUNC_XN_XN(i, fnc)
-
-#define TEST_I_FUNC_I_I_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_X_FUNC_X_X_X(uc, fnc) \
- TEST_X_FUNC_X_X_X(c, fnc) \
- TEST_X_FUNC_X_X_X(us, fnc) \
- TEST_X_FUNC_X_X_X(s, fnc) \
- TEST_X_FUNC_X_X_X(ui, fnc) \
- TEST_X_FUNC_X_X_X(i, fnc)
-
-#define TEST_FN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1); \
- f2 = fnc(f2); \
- f3 = fnc(f3); \
- f4 = fnc(f4);
-
-#define TEST_FN_FUNC_FN_PFN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (float*) &f1); \
- f2 = fnc(f2, (float2*) &f2); \
- f3 = fnc(f3, (float3*) &f3); \
- f4 = fnc(f4, (float4*) &f4);
-
-#define TEST_FN_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f2); \
- f3 = fnc(f3, f3); \
- f4 = fnc(f4, f4);
-
-#define TEST_F34_FUNC_F34_F34(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f3 = fnc(f3, f3); \
- f4 = fnc(f4, f4);
-
-#define TEST_FN_FUNC_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f1); \
- f3 = fnc(f3, f1); \
- f4 = fnc(f4, f1);
-
-#define TEST_F_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1); \
- f1 = fnc(f2); \
- f1 = fnc(f3); \
- f1 = fnc(f4);
-
-#define TEST_F_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f1 = fnc(f2, f2); \
- f1 = fnc(f3, f3); \
- f1 = fnc(f4, f4);
-
-#define TEST_FN_FUNC_FN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i2); \
- f3 = fnc(f3, i3); \
- f4 = fnc(f4, i4);
-
-#define TEST_FN_FUNC_FN_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i1); \
- f3 = fnc(f3, i1); \
- f4 = fnc(f4, i1);
-
-#define TEST_FN_FUNC_FN_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, f1); \
- f2 = fnc(f2, f2, f2); \
- f3 = fnc(f3, f3, f3); \
- f4 = fnc(f4, f4, f4);
-
-#define TEST_FN_FUNC_FN_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, f1); \
- f2 = fnc(f2, f1, f1); \
- f3 = fnc(f3, f1, f1); \
- f4 = fnc(f4, f1, f1);
-
-#define TEST_FN_FUNC_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (int*) &i1); \
- f2 = fnc(f2, (int2*) &i2); \
- f3 = fnc(f3, (int3*) &i3); \
- f4 = fnc(f4, (int4*) &i4);
-
-#define TEST_FN_FUNC_FN_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, (int*) &i1); \
- f2 = fnc(f2, f2, (int2*) &i2); \
- f3 = fnc(f3, f3, (int3*) &i3); \
- f4 = fnc(f4, f4, (int4*) &i4);
-
-#define TEST_IN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- i1 = fnc(f1); \
- i2 = fnc(f2); \
- i3 = fnc(f3); \
- i4 = fnc(f4);
-
-static bool test_fp_math(uint32_t index) {
- bool failed = false;
- start();
-
- TEST_FN_FUNC_FN(acos);
- TEST_FN_FUNC_FN(acosh);
- TEST_FN_FUNC_FN(acospi);
- TEST_FN_FUNC_FN(asin);
- TEST_FN_FUNC_FN(asinh);
- TEST_FN_FUNC_FN(asinpi);
- TEST_FN_FUNC_FN(atan);
- TEST_FN_FUNC_FN_FN(atan2);
- TEST_FN_FUNC_FN(atanh);
- TEST_FN_FUNC_FN(atanpi);
- TEST_FN_FUNC_FN_FN(atan2pi);
- TEST_FN_FUNC_FN(cbrt);
- TEST_FN_FUNC_FN(ceil);
- TEST_FN_FUNC_FN_FN_FN(clamp);
- TEST_FN_FUNC_FN_FN_F(clamp);
- TEST_FN_FUNC_FN_FN(copysign);
- TEST_FN_FUNC_FN(cos);
- TEST_FN_FUNC_FN(cosh);
- TEST_FN_FUNC_FN(cospi);
- TEST_F34_FUNC_F34_F34(cross);
- TEST_FN_FUNC_FN(degrees);
- TEST_F_FUNC_FN_FN(distance);
- TEST_F_FUNC_FN_FN(dot);
- TEST_FN_FUNC_FN(erfc);
- TEST_FN_FUNC_FN(erf);
- TEST_FN_FUNC_FN(exp);
- TEST_FN_FUNC_FN(exp2);
- TEST_FN_FUNC_FN(exp10);
- TEST_FN_FUNC_FN(expm1);
- TEST_FN_FUNC_FN(fabs);
- TEST_FN_FUNC_FN_FN(fdim);
- TEST_FN_FUNC_FN(floor);
- TEST_FN_FUNC_FN_FN_FN(fma);
- TEST_FN_FUNC_FN_FN(fmax);
- TEST_FN_FUNC_FN_F(fmax);
- TEST_FN_FUNC_FN_FN(fmin);
- TEST_FN_FUNC_FN_F(fmin);
- TEST_FN_FUNC_FN_FN(fmod);
- TEST_FN_FUNC_FN_PFN(fract);
- TEST_FN_FUNC_FN_PIN(frexp);
- TEST_FN_FUNC_FN_FN(hypot);
- TEST_IN_FUNC_FN(ilogb);
- TEST_FN_FUNC_FN_IN(ldexp);
- TEST_FN_FUNC_FN_I(ldexp);
- TEST_F_FUNC_FN(length);
- TEST_FN_FUNC_FN(lgamma);
- TEST_FN_FUNC_FN_PIN(lgamma);
- TEST_FN_FUNC_FN(log);
- TEST_FN_FUNC_FN(log2);
- TEST_FN_FUNC_FN(log10);
- TEST_FN_FUNC_FN(log1p);
- TEST_FN_FUNC_FN(logb);
- TEST_FN_FUNC_FN_FN_FN(mad);
- TEST_FN_FUNC_FN_FN(max);
- TEST_FN_FUNC_FN_F(max);
- TEST_FN_FUNC_FN_FN(min);
- TEST_FN_FUNC_FN_F(min);
- TEST_FN_FUNC_FN_FN_FN(mix);
- TEST_FN_FUNC_FN_FN_F(mix);
- TEST_FN_FUNC_FN_PFN(modf);
- // nan
- TEST_FN_FUNC_FN_FN(nextafter);
- TEST_FN_FUNC_FN(normalize);
- TEST_FN_FUNC_FN_FN(pow);
- TEST_FN_FUNC_FN_IN(pown);
- TEST_FN_FUNC_FN_FN(powr);
- TEST_FN_FUNC_FN(radians);
- TEST_FN_FUNC_FN_FN(remainder);
- TEST_FN_FUNC_FN_FN_PIN(remquo);
- TEST_FN_FUNC_FN(rint);
- TEST_FN_FUNC_FN_IN(rootn);
- TEST_FN_FUNC_FN(round);
- TEST_FN_FUNC_FN(rsqrt);
- TEST_FN_FUNC_FN(sign);
- TEST_FN_FUNC_FN(sin);
- TEST_FN_FUNC_FN_PFN(sincos);
- TEST_FN_FUNC_FN(sinh);
- TEST_FN_FUNC_FN(sinpi);
- TEST_FN_FUNC_FN(sqrt);
- TEST_FN_FUNC_FN_FN(step);
- TEST_FN_FUNC_FN_F(step);
- TEST_FN_FUNC_FN(tan);
- TEST_FN_FUNC_FN(tanh);
- TEST_FN_FUNC_FN(tanpi);
- TEST_FN_FUNC_FN(tgamma);
- TEST_FN_FUNC_FN(trunc);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_fp_math FAILED", time);
- }
- else {
- rsDebug("test_fp_math PASSED", time);
- }
-
- return failed;
-}
-
-static bool test_int_math(uint32_t index) {
- bool failed = false;
- start();
-
- TEST_UIN_FUNC_IN(abs);
- TEST_IN_FUNC_IN(clz);
- TEST_IN_FUNC_IN_IN(min);
- TEST_IN_FUNC_IN_IN(max);
- TEST_I_FUNC_I_I_I(rsClamp);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_int_math FAILED", time);
- }
- else {
- rsDebug("test_int_math PASSED", time);
- }
-
- return failed;
-}
-
-static bool test_basic_operators() {
- bool failed = false;
- int i = 0;
-
- TEST_INT_OP(+);
- TEST_INT_OP(-);
- TEST_INT_OP(*);
- TEST_INT_OP(/);
- TEST_INT_OP(%);
- TEST_INT_OP(<<);
- TEST_INT_OP(>>);
-
- if (failed) {
- rsDebug("test_basic_operators FAILED", 0);
- }
- else {
- rsDebug("test_basic_operators PASSED", 0);
- }
-
- return failed;
-}
-
-#define TEST_CVT(to, from, type) \
-rsDebug("Testing convert from " #from " to " #to, 0); \
-to##1 = from##1; \
-to##2 = convert_##type##2(from##2); \
-to##3 = convert_##type##3(from##3); \
-to##4 = convert_##type##4(from##4);
-
-#define TEST_CVT_MATRIX(to, type) \
-TEST_CVT(to, c, type); \
-TEST_CVT(to, uc, type); \
-TEST_CVT(to, s, type); \
-TEST_CVT(to, us, type); \
-TEST_CVT(to, i, type); \
-TEST_CVT(to, ui, type); \
-TEST_CVT(to, f, type); \
-
-static bool test_convert() {
- bool failed = false;
-
- TEST_CVT_MATRIX(c, char);
- TEST_CVT_MATRIX(uc, uchar);
- TEST_CVT_MATRIX(s, short);
- TEST_CVT_MATRIX(us, ushort);
- TEST_CVT_MATRIX(i, int);
- TEST_CVT_MATRIX(ui, uint);
- TEST_CVT_MATRIX(f, float);
-
- if (failed) {
- rsDebug("test_convert FAILED", 0);
- }
- else {
- rsDebug("test_convert PASSED", 0);
- }
-
- return failed;
-}
-
-void math_test(uint32_t index, int test_num) {
- bool failed = false;
- failed |= test_convert();
- failed |= test_fp_math(index);
- failed |= test_int_math(index);
- failed |= test_basic_operators();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/math_agree.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/math_agree.rs
deleted file mode 100644
index 5bfbb2b..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/math_agree.rs
+++ /dev/null
@@ -1,409 +0,0 @@
-#include "shared.rsh"
-//#pragma rs_fp_relaxed
-
-volatile float x = 0.0f;
-volatile float y = 0.0f;
-volatile float result_add = 0.0f;
-volatile float result_sub = 0.0f;
-volatile float result_mul = 0.0f;
-volatile float result_div = 0.0f;
-
-#define DECLARE_INPUT_SET(type, abbrev) \
-volatile type rand_##abbrev##1_0, rand_##abbrev##1_1; \
-volatile type##2 rand_##abbrev##2_0, rand_##abbrev##2_1; \
-volatile type##3 rand_##abbrev##3_0, rand_##abbrev##3_1; \
-volatile type##4 rand_##abbrev##4_0, rand_##abbrev##4_1;
-
-#define DECLARE_ALL_INPUT_SETS() \
-DECLARE_INPUT_SET(float, f); \
-DECLARE_INPUT_SET(char, sc); \
-DECLARE_INPUT_SET(uchar, uc); \
-DECLARE_INPUT_SET(short, ss); \
-DECLARE_INPUT_SET(ushort, us); \
-DECLARE_INPUT_SET(int, si); \
-DECLARE_INPUT_SET(uint, ui); \
-DECLARE_INPUT_SET(long, sl); \
-DECLARE_INPUT_SET(ulong, ul);
-
-DECLARE_ALL_INPUT_SETS();
-
-#define DECLARE_REFERENCE_SET_VEC_VEC(type, abbrev, func) \
-volatile type func##_rand_##abbrev##1_##abbrev##1; \
-volatile type##2 func##_rand_##abbrev##2_##abbrev##2; \
-volatile type##3 func##_rand_##abbrev##3_##abbrev##3; \
-volatile type##4 func##_rand_##abbrev##4_##abbrev##4;
-#define DECLARE_REFERENCE_SET_VEC_SCL(type, abbrev, func) \
-volatile type##2 func##_rand_##abbrev##2_##abbrev##1; \
-volatile type##3 func##_rand_##abbrev##3_##abbrev##1; \
-volatile type##4 func##_rand_##abbrev##4_##abbrev##1;
-
-#define DECLARE_ALL_REFERENCE_SETS_VEC_VEC(func) \
-DECLARE_REFERENCE_SET_VEC_VEC(float, f, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(char, sc, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(uchar, uc, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(short, ss, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(ushort, us, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(int, si, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(uint, ui, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(long, sl, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(ulong, ul, func);
-
-DECLARE_ALL_REFERENCE_SETS_VEC_VEC(min);
-DECLARE_ALL_REFERENCE_SETS_VEC_VEC(max);
-DECLARE_REFERENCE_SET_VEC_VEC(float, f, fmin);
-DECLARE_REFERENCE_SET_VEC_SCL(float, f, fmin);
-DECLARE_REFERENCE_SET_VEC_VEC(float, f, fmax);
-DECLARE_REFERENCE_SET_VEC_SCL(float, f, fmax);
-
-static void fail_f1(float v1, float v2, float actual, float expected, char *op_name) {
- int dist = float_dist(actual, expected);
- rsDebug("float operation did not match!", op_name);
- rsDebug("v1", v1);
- rsDebug("v2", v2);
- rsDebug("Dalvik result", expected);
- rsDebug("Renderscript result", actual);
- rsDebug("ULP difference", dist);
-}
-
-static void fail_f2(float2 v1, float2 v2, float2 actual, float2 expected, char *op_name) {
- int2 dist;
- dist.x = float_dist(actual.x, expected.x);
- dist.y = float_dist(actual.y, expected.y);
- rsDebug("float2 operation did not match!", op_name);
- rsDebug("v1.x", v1.x);
- rsDebug("v1.y", v1.y);
- rsDebug("v2.x", v2.x);
- rsDebug("v2.y", v2.y);
- rsDebug("Dalvik result .x", expected.x);
- rsDebug("Dalvik result .y", expected.y);
- rsDebug("Renderscript result .x", actual.x);
- rsDebug("Renderscript result .y", actual.y);
- rsDebug("ULP difference .x", dist.x);
- rsDebug("ULP difference .y", dist.y);
-}
-
-static void fail_f3(float3 v1, float3 v2, float3 actual, float3 expected, char *op_name) {
- int3 dist;
- dist.x = float_dist(actual.x, expected.x);
- dist.y = float_dist(actual.y, expected.y);
- dist.z = float_dist(actual.z, expected.z);
- rsDebug("float3 operation did not match!", op_name);
- rsDebug("v1.x", v1.x);
- rsDebug("v1.y", v1.y);
- rsDebug("v1.z", v1.z);
- rsDebug("v2.x", v2.x);
- rsDebug("v2.y", v2.y);
- rsDebug("v2.z", v2.z);
- rsDebug("Dalvik result .x", expected.x);
- rsDebug("Dalvik result .y", expected.y);
- rsDebug("Dalvik result .z", expected.z);
- rsDebug("Renderscript result .x", actual.x);
- rsDebug("Renderscript result .y", actual.y);
- rsDebug("Renderscript result .z", actual.z);
- rsDebug("ULP difference .x", dist.x);
- rsDebug("ULP difference .y", dist.y);
- rsDebug("ULP difference .z", dist.z);
-}
-
-static void fail_f4(float4 v1, float4 v2, float4 actual, float4 expected, char *op_name) {
- int4 dist;
- dist.x = float_dist(actual.x, expected.x);
- dist.y = float_dist(actual.y, expected.y);
- dist.z = float_dist(actual.z, expected.z);
- dist.w = float_dist(actual.w, expected.w);
- rsDebug("float4 operation did not match!", op_name);
- rsDebug("v1.x", v1.x);
- rsDebug("v1.y", v1.y);
- rsDebug("v1.z", v1.z);
- rsDebug("v1.w", v1.w);
- rsDebug("v2.x", v2.x);
- rsDebug("v2.y", v2.y);
- rsDebug("v2.z", v2.z);
- rsDebug("v2.w", v2.w);
- rsDebug("Dalvik result .x", expected.x);
- rsDebug("Dalvik result .y", expected.y);
- rsDebug("Dalvik result .z", expected.z);
- rsDebug("Dalvik result .w", expected.w);
- rsDebug("Renderscript result .x", actual.x);
- rsDebug("Renderscript result .y", actual.y);
- rsDebug("Renderscript result .z", actual.z);
- rsDebug("Renderscript result .w", actual.w);
- rsDebug("ULP difference .x", dist.x);
- rsDebug("ULP difference .y", dist.y);
- rsDebug("ULP difference .z", dist.z);
- rsDebug("ULP difference .w", dist.w);
-}
-
-static bool f1_almost_equal(float a, float b) {
- return float_almost_equal(a, b);
-}
-
-static bool f2_almost_equal(float2 a, float2 b) {
- return float_almost_equal(a.x, b.x) && float_almost_equal(a.y, b.y);
-}
-
-
-static bool f3_almost_equal(float3 a, float3 b) {
- return float_almost_equal(a.x, b.x) && float_almost_equal(a.y, b.y)
- && float_almost_equal(a.z, b.z);
-}
-
-static bool f4_almost_equal(float4 a, float4 b) {
- return float_almost_equal(a.x, b.x) && float_almost_equal(a.y, b.y)
- && float_almost_equal(a.z, b.z) && float_almost_equal(a.w, b.w);
-}
-
-#define TEST_BASIC_FLOAT_OP(op, opName) \
-temp_f1 = x op y; \
-if (! float_almost_equal(temp_f1, result_##opName)) { \
- fail_f1(x, y , temp_f1, result_##opName, #opName); \
- failed = true; \
-}
-
-#define TEST_FN_FN(func, size) \
-temp_f##size = func(rand_f##size##_0, rand_f##size##_1); \
-if (! f##size##_almost_equal(temp_f##size , func##_rand_f##size##_f##size)) { \
- fail_f##size (x, y , temp_f##size, func##_rand_f##size##_f##size, #func); \
- failed = true; \
-}
-#define TEST_FN_F(func, size) \
-temp_f##size = func(rand_f##size##_0, rand_f1_1); \
-if (! f##size##_almost_equal(temp_f##size , func##_rand_f##size##_f1)) { \
- fail_f##size (x, y , temp_f##size, func##_rand_f##size##_f1 , #func); \
- failed = true; \
-}
-
-#define TEST_FN_FN_ALL(func) \
-TEST_FN_FN(func, 1) \
-TEST_FN_FN(func, 2) \
-TEST_FN_FN(func, 3) \
-TEST_FN_FN(func, 4)
-#define TEST_FN_F_ALL(func) \
-TEST_FN_F(func, 2) \
-TEST_FN_F(func, 3) \
-TEST_FN_F(func, 4)
-
-#define TEST_VEC1_VEC1(func, type) \
-temp_##type##1 = func( rand_##type##1_0, rand_##type##1_1 ); \
-if (temp_##type##1 != func##_rand_##type##1_##type##1) { \
- rsDebug(#func " " #type "1 operation did not match!", 0); \
- rsDebug("v1", rand_##type##1_0); \
- rsDebug("v2", rand_##type##1_1); \
- rsDebug("Dalvik result", func##_rand_##type##1_##type##1); \
- rsDebug("Renderscript result", temp_##type##1); \
- failed = true; \
-}
-#define TEST_VEC2_VEC2(func, type) \
-temp_##type##2 = func( rand_##type##2_0, rand_##type##2_1 ); \
-if (temp_##type##2 .x != func##_rand_##type##2_##type##2 .x \
- || temp_##type##2 .y != func##_rand_##type##2_##type##2 .y) { \
- rsDebug(#func " " #type "2 operation did not match!", 0); \
- rsDebug("v1.x", rand_##type##2_0 .x); \
- rsDebug("v1.y", rand_##type##2_0 .y); \
- rsDebug("v2.x", rand_##type##2_1 .x); \
- rsDebug("v2.y", rand_##type##2_1 .y); \
- rsDebug("Dalvik result .x", func##_rand_##type##2_##type##2 .x); \
- rsDebug("Dalvik result .y", func##_rand_##type##2_##type##2 .y); \
- rsDebug("Renderscript result .x", temp_##type##2 .x); \
- rsDebug("Renderscript result .y", temp_##type##2 .y); \
- failed = true; \
-}
-#define TEST_VEC3_VEC3(func, type) \
-temp_##type##3 = func( rand_##type##3_0, rand_##type##3_1 ); \
-if (temp_##type##3 .x != func##_rand_##type##3_##type##3 .x \
- || temp_##type##3 .y != func##_rand_##type##3_##type##3 .y \
- || temp_##type##3 .z != func##_rand_##type##3_##type##3 .z) { \
- rsDebug(#func " " #type "3 operation did not match!", 0); \
- rsDebug("v1.x", rand_##type##3_0 .x); \
- rsDebug("v1.y", rand_##type##3_0 .y); \
- rsDebug("v1.z", rand_##type##3_0 .z); \
- rsDebug("v2.x", rand_##type##3_1 .x); \
- rsDebug("v2.y", rand_##type##3_1 .y); \
- rsDebug("v2.z", rand_##type##3_1 .z); \
- rsDebug("Dalvik result .x", func##_rand_##type##3_##type##3 .x); \
- rsDebug("Dalvik result .y", func##_rand_##type##3_##type##3 .y); \
- rsDebug("Dalvik result .z", func##_rand_##type##3_##type##3 .z); \
- rsDebug("Renderscript result .x", temp_##type##3 .x); \
- rsDebug("Renderscript result .y", temp_##type##3 .y); \
- rsDebug("Renderscript result .z", temp_##type##3 .z); \
- failed = true; \
-}
-#define TEST_VEC4_VEC4(func, type) \
-temp_##type##4 = func( rand_##type##4_0, rand_##type##4_1 ); \
-if (temp_##type##4 .x != func##_rand_##type##4_##type##4 .x \
- || temp_##type##4 .y != func##_rand_##type##4_##type##4 .y \
- || temp_##type##4 .z != func##_rand_##type##4_##type##4 .z \
- || temp_##type##4 .w != func##_rand_##type##4_##type##4 .w) { \
- rsDebug(#func " " #type "4 operation did not match!", 0); \
- rsDebug("v1.x", rand_##type##4_0 .x); \
- rsDebug("v1.y", rand_##type##4_0 .y); \
- rsDebug("v1.z", rand_##type##4_0 .z); \
- rsDebug("v1.w", rand_##type##4_0 .w); \
- rsDebug("v2.x", rand_##type##4_1 .x); \
- rsDebug("v2.y", rand_##type##4_1 .y); \
- rsDebug("v2.z", rand_##type##4_1 .z); \
- rsDebug("v2.w", rand_##type##4_1 .w); \
- rsDebug("Dalvik result .x", func##_rand_##type##4_##type##4 .x); \
- rsDebug("Dalvik result .y", func##_rand_##type##4_##type##4 .y); \
- rsDebug("Dalvik result .z", func##_rand_##type##4_##type##4 .z); \
- rsDebug("Dalvik result .w", func##_rand_##type##4_##type##4 .w); \
- rsDebug("Renderscript result .x", temp_##type##4 .x); \
- rsDebug("Renderscript result .y", temp_##type##4 .y); \
- rsDebug("Renderscript result .z", temp_##type##4 .z); \
- rsDebug("Renderscript result .w", temp_##type##4 .w); \
- failed = true; \
-}
-
-#define TEST_SC1_SC1(func) TEST_VEC1_VEC1(func, sc)
-#define TEST_SC2_SC2(func) TEST_VEC2_VEC2(func, sc)
-#define TEST_SC3_SC3(func) TEST_VEC3_VEC3(func, sc)
-#define TEST_SC4_SC4(func) TEST_VEC4_VEC4(func, sc)
-
-#define TEST_UC1_UC1(func) TEST_VEC1_VEC1(func, uc)
-#define TEST_UC2_UC2(func) TEST_VEC2_VEC2(func, uc)
-#define TEST_UC3_UC3(func) TEST_VEC3_VEC3(func, uc)
-#define TEST_UC4_UC4(func) TEST_VEC4_VEC4(func, uc)
-
-#define TEST_SS1_SS1(func) TEST_VEC1_VEC1(func, ss)
-#define TEST_SS2_SS2(func) TEST_VEC2_VEC2(func, ss)
-#define TEST_SS3_SS3(func) TEST_VEC3_VEC3(func, ss)
-#define TEST_SS4_SS4(func) TEST_VEC4_VEC4(func, ss)
-
-#define TEST_US1_US1(func) TEST_VEC1_VEC1(func, us)
-#define TEST_US2_US2(func) TEST_VEC2_VEC2(func, us)
-#define TEST_US3_US3(func) TEST_VEC3_VEC3(func, us)
-#define TEST_US4_US4(func) TEST_VEC4_VEC4(func, us)
-
-#define TEST_SI1_SI1(func) TEST_VEC1_VEC1(func, si)
-#define TEST_SI2_SI2(func) TEST_VEC2_VEC2(func, si)
-#define TEST_SI3_SI3(func) TEST_VEC3_VEC3(func, si)
-#define TEST_SI4_SI4(func) TEST_VEC4_VEC4(func, si)
-
-#define TEST_UI1_UI1(func) TEST_VEC1_VEC1(func, ui)
-#define TEST_UI2_UI2(func) TEST_VEC2_VEC2(func, ui)
-#define TEST_UI3_UI3(func) TEST_VEC3_VEC3(func, ui)
-#define TEST_UI4_UI4(func) TEST_VEC4_VEC4(func, ui)
-
-#define TEST_SL1_SL1(func) TEST_VEC1_VEC1(func, sl)
-#define TEST_SL2_SL2(func) TEST_VEC2_VEC2(func, sl)
-#define TEST_SL3_SL3(func) TEST_VEC3_VEC3(func, sl)
-#define TEST_SL4_SL4(func) TEST_VEC4_VEC4(func, sl)
-
-#define TEST_UL1_UL1(func) TEST_VEC1_VEC1(func, ul)
-#define TEST_UL2_UL2(func) TEST_VEC2_VEC2(func, ul)
-#define TEST_UL3_UL3(func) TEST_VEC3_VEC3(func, ul)
-#define TEST_UL4_UL4(func) TEST_VEC4_VEC4(func, ul)
-
-#define TEST_SC_SC_ALL(func) \
-TEST_SC1_SC1(func) \
-TEST_SC2_SC2(func) \
-TEST_SC3_SC3(func) \
-TEST_SC4_SC4(func)
-#define TEST_UC_UC_ALL(func) \
-TEST_UC1_UC1(func) \
-TEST_UC2_UC2(func) \
-TEST_UC3_UC3(func) \
-TEST_UC4_UC4(func)
-
-#define TEST_SS_SS_ALL(func) \
-TEST_SS1_SS1(func) \
-TEST_SS2_SS2(func) \
-TEST_SS3_SS3(func) \
-TEST_SS4_SS4(func)
-#define TEST_US_US_ALL(func) \
-TEST_US1_US1(func) \
-TEST_US2_US2(func) \
-TEST_US3_US3(func) \
-TEST_US4_US4(func)
-#define TEST_SI_SI_ALL(func) \
-TEST_SI1_SI1(func) \
-TEST_SI2_SI2(func) \
-TEST_SI3_SI3(func) \
-TEST_SI4_SI4(func)
-#define TEST_UI_UI_ALL(func) \
-TEST_UI1_UI1(func) \
-TEST_UI2_UI2(func) \
-TEST_UI3_UI3(func) \
-TEST_UI4_UI4(func)
-#define TEST_SL_SL_ALL(func) \
-TEST_SL1_SL1(func) \
-TEST_SL2_SL2(func) \
-TEST_SL3_SL3(func) \
-TEST_SL4_SL4(func)
-#define TEST_UL_UL_ALL(func) \
-TEST_UL1_UL1(func) \
-TEST_UL2_UL2(func) \
-TEST_UL3_UL3(func) \
-TEST_UL4_UL4(func)
-
-#define TEST_VEC_VEC_ALL(func) \
-TEST_FN_FN_ALL(func) \
-TEST_SC_SC_ALL(func) \
-TEST_UC_UC_ALL(func) \
-TEST_SS_SS_ALL(func) \
-TEST_US_US_ALL(func) \
-TEST_SI_SI_ALL(func) \
-TEST_UI_UI_ALL(func)
-
-// TODO: add long types to ALL macro
-#if 0
-TEST_SL_SL_ALL(func) \
-TEST_UL_UL_ALL(func)
-#endif
-
-#define DECLARE_TEMP_SET(type, abbrev) \
-volatile type temp_##abbrev##1; \
-volatile type##2 temp_##abbrev##2; \
-volatile type##3 temp_##abbrev##3; \
-volatile type##4 temp_##abbrev##4;
-
-#define DECLARE_ALL_TEMP_SETS() \
-DECLARE_TEMP_SET(float, f); \
-DECLARE_TEMP_SET(char, sc); \
-DECLARE_TEMP_SET(uchar, uc); \
-DECLARE_TEMP_SET(short, ss); \
-DECLARE_TEMP_SET(ushort, us); \
-DECLARE_TEMP_SET(int, si); \
-DECLARE_TEMP_SET(uint, ui); \
-DECLARE_TEMP_SET(long, sl); \
-DECLARE_TEMP_SET(ulong, ul);
-
-static bool test_math_agree() {
- bool failed = false;
-
- DECLARE_ALL_TEMP_SETS();
-
- TEST_BASIC_FLOAT_OP(+, add);
- TEST_BASIC_FLOAT_OP(-, sub);
- TEST_BASIC_FLOAT_OP(*, mul);
- TEST_BASIC_FLOAT_OP(/, div);
-
- TEST_VEC_VEC_ALL(min);
- TEST_VEC_VEC_ALL(max);
- TEST_FN_FN_ALL(fmin);
- TEST_FN_F_ALL(fmin);
- TEST_FN_FN_ALL(fmax);
- TEST_FN_F_ALL(fmax);
-
- if (failed) {
- rsDebug("test_math_agree FAILED", 0);
- }
- else {
- rsDebug("test_math_agree PASSED", 0);
- }
-
- return failed;
-}
-
-void math_agree_test() {
- bool failed = false;
- failed |= test_math_agree();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/math_conformance.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/math_conformance.rs
deleted file mode 100644
index 2d62f34..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/math_conformance.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "shared.rsh"
-
-// Testing math conformance
-
-static bool test_rootn() {
- bool failed = false;
-
- // rootn(x, 0) -> NaN
- _RS_ASSERT(isnan(rootn(1.0f, 0)));
-
- // rootn(+/-0, n) -> +/-inf for odd n < 0
- _RS_ASSERT(isposinf(rootn(0.f, -3)));
- _RS_ASSERT(isneginf(rootn(-0.f, -3)));
-
- // rootn(+/-0, n) -> +inf for even n < 0
- _RS_ASSERT(isposinf(rootn(0.f, -8)));
- _RS_ASSERT(isposinf(rootn(-0.f, -8)));
-
- // rootn(+/-0, n) -> +/-0 for odd n > 0
- _RS_ASSERT(isposzero(rootn(0.f, 3)));
- _RS_ASSERT(isnegzero(rootn(-0.f, 3)));
-
- // rootn(+/-0, n) -> +0 for even n > 0
- _RS_ASSERT(isposzero(rootn(0.f, 8)));
- _RS_ASSERT(isposzero(rootn(-0.f, 8)));
-
- // rootn(x, n) -> NaN for x < 0 and even n
- _RS_ASSERT(isnan(rootn(-10000.f, -4)));
- _RS_ASSERT(isnan(rootn(-10000.f, 4)));
-
- // rootn(x, n) -> value for x < 0 and odd n
- _RS_ASSERT(!isnan(rootn(-10000.f, -3)));
- _RS_ASSERT(!isnan(rootn(-10000.f, 3)));
-
- if (failed) {
- rsDebug("test_rootn FAILED", -1);
- }
- else {
- rsDebug("test_rootn PASSED", 0);
- }
-
- return failed;
-}
-
-void math_conformance_test() {
- bool failed = false;
- failed |= test_rootn();
-
- if (failed) {
- rsDebug("math_conformance_test FAILED", -1);
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsDebug("math_conformance_test PASSED", 0);
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/min.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/min.rs
deleted file mode 100644
index 4b92763..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/min.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "shared.rsh"
-#pragma rs_fp_relaxed
-
-volatile uchar2 res_uc_2 = 1;
-volatile uchar2 src1_uc_2 = 1;
-volatile uchar2 src2_uc_2 = 1;
-
-void min_test() {
- bool failed = false;
-
- res_uc_2 = min(src1_uc_2, src2_uc_2);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/noroot.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/noroot.rs
deleted file mode 100644
index 2c807bd..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/noroot.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "shared.rsh"
-
-rs_allocation aRaw;
-int dimX;
-int dimY;
-static bool failed = false;
-
-void foo(const int *in, int *out, uint32_t x, uint32_t y) {
- *out = 99 + x + y * dimX;
-}
-
-static bool test_foo_output() {
- bool failed = false;
- int i, j;
-
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- int v = rsGetElementAt_int(aRaw, i, j);
- _RS_ASSERT(v == (99 + i + j * dimX));
- }
- }
-
- if (failed) {
- rsDebug("test_foo_output FAILED", 0);
- }
- else {
- rsDebug("test_foo_output PASSED", 0);
- }
-
- return failed;
-}
-
-void verify_foo() {
- failed |= test_foo_output();
-}
-
-void noroot_test() {
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/primitives.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/primitives.rs
deleted file mode 100644
index ce451da..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/primitives.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "shared.rsh"
-
-// Testing primitive types
-float floatTest = 1.99f;
-double doubleTest = 2.05;
-char charTest = -8;
-short shortTest = -16;
-int intTest = -32;
-long longTest = 17179869184l; // 1 << 34
-long long longlongTest = 68719476736l; // 1 << 36
-
-uchar ucharTest = 8;
-ushort ushortTest = 16;
-uint uintTest = 32;
-ulong ulongTest = 4611686018427387904L;
-int64_t int64_tTest = -17179869184l; // - 1 << 34
-uint64_t uint64_tTest = 117179869184l;
-
-static bool test_primitive_types(uint32_t index) {
- bool failed = false;
- start();
-
- _RS_ASSERT(floatTest == 2.99f);
- _RS_ASSERT(doubleTest == 3.05);
- _RS_ASSERT(charTest == -16);
- _RS_ASSERT(shortTest == -32);
- _RS_ASSERT(intTest == -64);
- _RS_ASSERT(longTest == 17179869185l);
- _RS_ASSERT(longlongTest == 68719476735l);
-
- _RS_ASSERT(ucharTest == 8);
- _RS_ASSERT(ushortTest == 16);
- _RS_ASSERT(uintTest == 32);
- _RS_ASSERT(ulongTest == 4611686018427387903L);
- _RS_ASSERT(int64_tTest == -17179869184l);
- _RS_ASSERT(uint64_tTest == 117179869185l);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_primitives FAILED", time);
- }
- else {
- rsDebug("test_primitives PASSED", time);
- }
-
- return failed;
-}
-
-void primitives_test(uint32_t index, int test_num) {
- bool failed = false;
- failed |= test_primitive_types(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/refcount.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/refcount.rs
deleted file mode 100644
index 4ea70e2..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/refcount.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "shared.rsh"
-
-// Testing reference counting of RS object types
-
-rs_allocation globalA;
-static rs_allocation staticGlobalA;
-
-void refcount_test() {
- staticGlobalA = globalA;
- rsClearObject(&globalA);
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rsdebug.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rsdebug.rs
deleted file mode 100644
index 68ac168..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rsdebug.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "shared.rsh"
-
-// Testing primitive types
-float floatTest = 1.99f;
-float2 float2Test = {2.99f, 12.99f};
-float3 float3Test = {3.99f, 13.99f, 23.99f};
-float4 float4Test = {4.99f, 14.99f, 24.99f, 34.99f};
-double doubleTest = 2.05;
-char charTest = -8;
-short shortTest = -16;
-int intTest = -32;
-long longTest = 17179869184l; // 1 << 34
-long long longlongTest = 68719476736l; // 1 << 36
-
-uchar ucharTest = 8;
-ushort ushortTest = 16;
-uint uintTest = 32;
-ulong ulongTest = 4611686018427387904L;
-int64_t int64_tTest = -17179869184l; // - 1 << 34
-uint64_t uint64_tTest = 117179869184l;
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- // This test focuses primarily on compilation-time, not run-time.
- // For this reason, none of the outputs are actually checked.
-
- rsDebug("floatTest", floatTest);
- rsDebug("float2Test", float2Test);
- rsDebug("float3Test", float3Test);
- rsDebug("float4Test", float4Test);
- rsDebug("doubleTest", doubleTest);
- rsDebug("charTest", charTest);
- rsDebug("shortTest", shortTest);
- rsDebug("intTest", intTest);
- rsDebug("longTest", longTest);
- rsDebug("longlongTest", longlongTest);
-
- rsDebug("ucharTest", ucharTest);
- rsDebug("ushortTest", ushortTest);
- rsDebug("uintTest", uintTest);
- rsDebug("ulongTest", ulongTest);
- rsDebug("int64_tTest", int64_tTest);
- rsDebug("uint64_tTest", uint64_tTest);
-
- return failed;
-}
-
-void test_rsdebug(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rsdebug_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rsdebug_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rslist.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rslist.rs
deleted file mode 100644
index 650243e..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rslist.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2013 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test_compat)
-
-typedef struct ListAllocs_s {
- rs_allocation text;
- int result;
-} ListAllocs;
-
-ListAllocs *gList;
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rstime.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rstime.rs
deleted file mode 100644
index 7be955d..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rstime.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "shared.rsh"
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- rs_time_t curTime = rsTime(0);
- rs_tm tm;
- rsDebug("curTime", curTime);
-
- rsLocaltime(&tm, &curTime);
-
- rsDebug("tm.tm_sec", tm.tm_sec);
- rsDebug("tm.tm_min", tm.tm_min);
- rsDebug("tm.tm_hour", tm.tm_hour);
- rsDebug("tm.tm_mday", tm.tm_mday);
- rsDebug("tm.tm_mon", tm.tm_mon);
- rsDebug("tm.tm_year", tm.tm_year);
- rsDebug("tm.tm_wday", tm.tm_wday);
- rsDebug("tm.tm_yday", tm.tm_yday);
- rsDebug("tm.tm_isdst", tm.tm_isdst);
-
- // Test a specific time (since we set America/Los_Angeles localtime)
- curTime = 1294438893;
- rsLocaltime(&tm, &curTime);
-
- _RS_ASSERT(tm.tm_sec == 33);
- _RS_ASSERT(tm.tm_min == 21);
- _RS_ASSERT(tm.tm_hour == 14);
- _RS_ASSERT(tm.tm_mday == 7);
- _RS_ASSERT(tm.tm_mon == 0);
- _RS_ASSERT(tm.tm_year == 111);
- _RS_ASSERT(tm.tm_wday == 5);
- _RS_ASSERT(tm.tm_yday == 6);
- _RS_ASSERT(tm.tm_isdst == 0);
-
- return failed;
-}
-
-void test_rstime(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rstime_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rstime_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rstypes.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rstypes.rs
deleted file mode 100644
index bec124d..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/rstypes.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "shared.rsh"
-#include "rs_graphics.rsh"
-
-rs_element elementTest;
-rs_type typeTest;
-rs_allocation allocationTest;
-rs_sampler samplerTest;
-rs_script scriptTest;
-
-rs_matrix4x4 matrix4x4Test;
-rs_matrix3x3 matrix3x3Test;
-rs_matrix2x2 matrix2x2Test;
-
-struct my_struct {
- int i;
- rs_allocation banana;
-};
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- rs_matrix4x4 matrix4x4TestLocal;
- rs_matrix3x3 matrix3x3TestLocal;
- rs_matrix2x2 matrix2x2TestLocal;
-
- // This test focuses primarily on compilation-time, not run-time.
- rs_element elementTestLocal;
- rs_type typeTestLocal;
- rs_allocation allocationTestLocal;
- rs_sampler samplerTestLocal;
- rs_script scriptTestLocal;
-
- struct my_struct structTest;
-
- //allocationTestLocal = allocationTest;
-
- //allocationTest = allocationTestLocal;
-
- /*for (int i = 0; i < 4; i++) {
- fontTestLocalArray[i] = fontTestLocal;
- }*/
-
- /*fontTest = fontTestLocalArray[3];*/
-
- return failed;
-}
-
-void test_rstypes(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rstypes_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rstypes_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/sampler.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/sampler.rs
deleted file mode 100644
index ff1c0a7..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/sampler.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-#include "shared.rsh"
-#include "rs_graphics.rsh"
-rs_sampler minification;
-rs_sampler magnification;
-rs_sampler wrapS;
-rs_sampler wrapT;
-rs_sampler anisotropy;
-
-static bool test_sampler_getters() {
- bool failed = false;
-
- _RS_ASSERT(rsSamplerGetMagnification(minification) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetMinification(minification) == RS_SAMPLER_LINEAR_MIP_LINEAR);
- _RS_ASSERT(rsSamplerGetWrapS(minification) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetWrapT(minification) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetAnisotropy(minification) == 1.0f);
-
- _RS_ASSERT(rsSamplerGetMagnification(magnification) == RS_SAMPLER_LINEAR);
- _RS_ASSERT(rsSamplerGetMinification(magnification) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetWrapS(magnification) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetWrapT(magnification) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetAnisotropy(magnification) == 1.0f);
-
- _RS_ASSERT(rsSamplerGetMagnification(wrapS) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetMinification(wrapS) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetWrapS(wrapS) == RS_SAMPLER_WRAP);
- _RS_ASSERT(rsSamplerGetWrapT(wrapS) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetAnisotropy(wrapS) == 1.0f);
-
- _RS_ASSERT(rsSamplerGetMagnification(wrapT) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetMinification(wrapT) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetWrapS(wrapT) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetWrapT(wrapT) == RS_SAMPLER_WRAP);
- _RS_ASSERT(rsSamplerGetAnisotropy(wrapT) == 1.0f);
-
- _RS_ASSERT(rsSamplerGetMagnification(anisotropy) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetMinification(anisotropy) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetWrapS(anisotropy) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetWrapT(anisotropy) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetAnisotropy(anisotropy) == 8.0f);
-
- if (failed) {
- rsDebug("test_sampler_getters FAILED", 0);
- }
- else {
- rsDebug("test_sampler_getters PASSED", 0);
- }
-
- return failed;
-}
-
-void sampler_test() {
- bool failed = false;
- failed |= test_sampler_getters();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/shared.rsh b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/shared.rsh
deleted file mode 100644
index b05a354..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/shared.rsh
+++ /dev/null
@@ -1,114 +0,0 @@
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test_compat)
-
-typedef struct TestResult_s {
- rs_allocation name;
- bool pass;
- float score;
- int64_t time;
-} TestResult;
-//TestResult *g_results;
-
-static int64_t g_time;
-
-static void start(void) {
- g_time = rsUptimeMillis();
-}
-
-static float end(uint32_t idx) {
- int64_t t = rsUptimeMillis() - g_time;
- //g_results[idx].time = t;
- //rsDebug("test time", (int)t);
- return ((float)t) / 1000.f;
-}
-
-#define _RS_ASSERT(b) \
-do { \
- if (!(b)) { \
- failed = true; \
- rsDebug(#b " FAILED", 0); \
- } \
-\
-} while (0)
-
-static const int iposinf = 0x7f800000;
-static const int ineginf = 0xff800000;
-
-static const float posinf() {
- float f = *((float*)&iposinf);
- return f;
-}
-
-static const float neginf() {
- float f = *((float*)&ineginf);
- return f;
-}
-
-static bool isposinf(float f) {
- int i = *((int*)(void*)&f);
- return (i == iposinf);
-}
-
-static bool isneginf(float f) {
- int i = *((int*)(void*)&f);
- return (i == ineginf);
-}
-
-static bool isnan(float f) {
- int i = *((int*)(void*)&f);
- return (((i & 0x7f800000) == 0x7f800000) && (i & 0x007fffff));
-}
-
-static bool isposzero(float f) {
- int i = *((int*)(void*)&f);
- return (i == 0x00000000);
-}
-
-static bool isnegzero(float f) {
- int i = *((int*)(void*)&f);
- return (i == 0x80000000);
-}
-
-static bool iszero(float f) {
- return isposzero(f) || isnegzero(f);
-}
-
-/* Absolute epsilon used for floats. Value is similar to float.h. */
-#ifndef FLT_EPSILON
-#define FLT_EPSILON 1.19e7f
-#endif
-/* Max ULPs while still being considered "equal". Only used when this number
- of ULPs is of a greater size than FLT_EPSILON. */
-#define FLT_MAX_ULP 1
-
-/* Calculate the difference in ULPs between the two values. (Return zero on
- perfect equality.) */
-static int float_dist(float f1, float f2) {
- return *((int *)(&f1)) - *((int *)(&f2));
-}
-
-/* Check if two floats are essentially equal. Will fail with some values
- due to design. (Validate using FLT_EPSILON or similar if necessary.) */
-static bool float_almost_equal(float f1, float f2) {
- int *i1 = (int*)(&f1);
- int *i2 = (int*)(&f2);
-
- // Check for sign equality
- if ( ((*i1 >> 31) == 0) != ((*i2 >> 31) == 0) ) {
- // Handle signed zeroes
- if (f1 == f2)
- return true;
- return false;
- }
-
- // Check with ULP distance
- if (float_dist(f1, f2) > FLT_MAX_ULP)
- return false;
- return true;
-}
-
-/* These constants must match those in UnitTest.java */
-static const int RS_MSG_TEST_PASSED = 100;
-static const int RS_MSG_TEST_FAILED = 101;
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/struct.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/struct.rs
deleted file mode 100644
index 1cd728e..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/struct.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "shared.rsh"
-
-typedef struct Point2 {
- int x;
- int y;
-} Point_2;
-Point_2 *point2;
-
-static bool test_Point_2(int expected) {
- bool failed = false;
-
- rsDebug("Point: ", point2[0].x, point2[0].y);
- _RS_ASSERT(point2[0].x == expected);
- _RS_ASSERT(point2[0].y == expected);
-
- if (failed) {
- rsDebug("test_Point_2 FAILED", 0);
- }
- else {
- rsDebug("test_Point_2 PASSED", 0);
- }
-
- return failed;
-}
-
-void struct_test(int expected) {
- bool failed = false;
- failed |= test_Point_2(expected);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/test_root.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/test_root.rs
deleted file mode 100644
index 89e7de7..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/test_root.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Fountain test script
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test_compat)
-
-#pragma stateFragment(parent)
-
-#include "rs_graphics.rsh"
-
-
-typedef struct TestResult {
- rs_allocation name;
- bool pass;
- float score;
-} TestResult_t;
-TestResult_t *results;
-
-int root() {
-
- return 0;
-}
-
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/unsigned.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/unsigned.rs
deleted file mode 100644
index 2c056f4..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/unsigned.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "shared.rsh"
-
-// Testing unsigned types for Bug 6764163
-unsigned int ui = 37;
-unsigned char uc = 5;
-
-static bool test_unsigned() {
- bool failed = false;
-
- rsDebug("ui", ui);
- rsDebug("uc", uc);
- _RS_ASSERT(ui == 0x7fffffff);
- _RS_ASSERT(uc == 129);
-
- if (failed) {
- rsDebug("test_unsigned FAILED", -1);
- }
- else {
- rsDebug("test_unsigned PASSED", 0);
- }
-
- return failed;
-}
-
-void unsigned_test() {
- bool failed = false;
- failed |= test_unsigned();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/vector.rs b/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/vector.rs
deleted file mode 100644
index 0430a2f..0000000
--- a/tests/RenderScriptTests/RSTest_CompatLib/src/com/android/rs/test/vector.rs
+++ /dev/null
@@ -1,198 +0,0 @@
-#include "shared.rsh"
-
-// Testing vector types
-float2 f2 = { 1.0f, 2.0f };
-float3 f3 = { 1.0f, 2.0f, 3.0f };
-float4 f4 = { 1.0f, 2.0f, 3.0f, 4.0f };
-
-double2 d2 = { 1.0, 2.0 };
-double3 d3 = { 1.0, 2.0, 3.0 };
-double4 d4 = { 1.0, 2.0, 3.0, 4.0 };
-
-char2 i8_2 = { 1, 2 };
-char3 i8_3 = { 1, 2, 3 };
-char4 i8_4 = { 1, 2, 3, 4 };
-
-uchar2 u8_2 = { 1, 2 };
-uchar3 u8_3 = { 1, 2, 3 };
-uchar4 u8_4 = { 1, 2, 3, 4 };
-
-short2 i16_2 = { 1, 2 };
-short3 i16_3 = { 1, 2, 3 };
-short4 i16_4 = { 1, 2, 3, 4 };
-
-ushort2 u16_2 = { 1, 2 };
-ushort3 u16_3 = { 1, 2, 3 };
-ushort4 u16_4 = { 1, 2, 3, 4 };
-
-int2 i32_2 = { 1, 2 };
-int3 i32_3 = { 1, 2, 3 };
-int4 i32_4 = { 1, 2, 3, 4 };
-
-uint2 u32_2 = { 1, 2 };
-uint3 u32_3 = { 1, 2, 3 };
-uint4 u32_4 = { 1, 2, 3, 4 };
-
-long2 i64_2 = { 1, 2 };
-long3 i64_3 = { 1, 2, 3 };
-long4 i64_4 = { 1, 2, 3, 4 };
-
-ulong2 u64_2 = { 1, 2 };
-ulong3 u64_3 = { 1, 2, 3 };
-ulong4 u64_4 = { 1, 2, 3, 4 };
-
-static bool test_vector_types() {
- bool failed = false;
-
- rsDebug("Testing F32", 0);
- _RS_ASSERT(f2.x == 2.99f);
- _RS_ASSERT(f2.y == 3.99f);
-
- _RS_ASSERT(f3.x == 2.99f);
- _RS_ASSERT(f3.y == 3.99f);
- _RS_ASSERT(f3.z == 4.99f);
-
- _RS_ASSERT(f4.x == 2.99f);
- _RS_ASSERT(f4.y == 3.99f);
- _RS_ASSERT(f4.z == 4.99f);
- _RS_ASSERT(f4.w == 5.99f);
-
- rsDebug("Testing F64", 0);
- _RS_ASSERT(d2.x == 2.99);
- _RS_ASSERT(d2.y == 3.99);
-
- _RS_ASSERT(d3.x == 2.99);
- _RS_ASSERT(d3.y == 3.99);
- _RS_ASSERT(d3.z == 4.99);
-
- _RS_ASSERT(d4.x == 2.99);
- _RS_ASSERT(d4.y == 3.99);
- _RS_ASSERT(d4.z == 4.99);
- _RS_ASSERT(d4.w == 5.99);
-
- rsDebug("Testing I8", 0);
- _RS_ASSERT(i8_2.x == 2);
- _RS_ASSERT(i8_2.y == 3);
-
- _RS_ASSERT(i8_3.x == 2);
- _RS_ASSERT(i8_3.y == 3);
- _RS_ASSERT(i8_3.z == 4);
-
- _RS_ASSERT(i8_4.x == 2);
- _RS_ASSERT(i8_4.y == 3);
- _RS_ASSERT(i8_4.z == 4);
- _RS_ASSERT(i8_4.w == 5);
-
- rsDebug("Testing U8", 0);
- _RS_ASSERT(u8_2.x == 2);
- _RS_ASSERT(u8_2.y == 3);
-
- _RS_ASSERT(u8_3.x == 2);
- _RS_ASSERT(u8_3.y == 3);
- _RS_ASSERT(u8_3.z == 4);
-
- _RS_ASSERT(u8_4.x == 2);
- _RS_ASSERT(u8_4.y == 3);
- _RS_ASSERT(u8_4.z == 4);
- _RS_ASSERT(u8_4.w == 5);
-
- rsDebug("Testing I16", 0);
- _RS_ASSERT(i16_2.x == 2);
- _RS_ASSERT(i16_2.y == 3);
-
- _RS_ASSERT(i16_3.x == 2);
- _RS_ASSERT(i16_3.y == 3);
- _RS_ASSERT(i16_3.z == 4);
-
- _RS_ASSERT(i16_4.x == 2);
- _RS_ASSERT(i16_4.y == 3);
- _RS_ASSERT(i16_4.z == 4);
- _RS_ASSERT(i16_4.w == 5);
-
- rsDebug("Testing U16", 0);
- _RS_ASSERT(u16_2.x == 2);
- _RS_ASSERT(u16_2.y == 3);
-
- _RS_ASSERT(u16_3.x == 2);
- _RS_ASSERT(u16_3.y == 3);
- _RS_ASSERT(u16_3.z == 4);
-
- _RS_ASSERT(u16_4.x == 2);
- _RS_ASSERT(u16_4.y == 3);
- _RS_ASSERT(u16_4.z == 4);
- _RS_ASSERT(u16_4.w == 5);
-
- rsDebug("Testing I32", 0);
- _RS_ASSERT(i32_2.x == 2);
- _RS_ASSERT(i32_2.y == 3);
-
- _RS_ASSERT(i32_3.x == 2);
- _RS_ASSERT(i32_3.y == 3);
- _RS_ASSERT(i32_3.z == 4);
-
- _RS_ASSERT(i32_4.x == 2);
- _RS_ASSERT(i32_4.y == 3);
- _RS_ASSERT(i32_4.z == 4);
- _RS_ASSERT(i32_4.w == 5);
-
- rsDebug("Testing U32", 0);
- _RS_ASSERT(u32_2.x == 2);
- _RS_ASSERT(u32_2.y == 3);
-
- _RS_ASSERT(u32_3.x == 2);
- _RS_ASSERT(u32_3.y == 3);
- _RS_ASSERT(u32_3.z == 4);
-
- _RS_ASSERT(u32_4.x == 2);
- _RS_ASSERT(u32_4.y == 3);
- _RS_ASSERT(u32_4.z == 4);
- _RS_ASSERT(u32_4.w == 5);
-
- rsDebug("Testing I64", 0);
- _RS_ASSERT(i64_2.x == 2);
- _RS_ASSERT(i64_2.y == 3);
-
- _RS_ASSERT(i64_3.x == 2);
- _RS_ASSERT(i64_3.y == 3);
- _RS_ASSERT(i64_3.z == 4);
-
- _RS_ASSERT(i64_4.x == 2);
- _RS_ASSERT(i64_4.y == 3);
- _RS_ASSERT(i64_4.z == 4);
- _RS_ASSERT(i64_4.w == 5);
-
- rsDebug("Testing U64", 0);
- _RS_ASSERT(u64_2.x == 2);
- _RS_ASSERT(u64_2.y == 3);
-
- _RS_ASSERT(u64_3.x == 2);
- _RS_ASSERT(u64_3.y == 3);
- _RS_ASSERT(u64_3.z == 4);
-
- _RS_ASSERT(u64_4.x == 2);
- _RS_ASSERT(u64_4.y == 3);
- _RS_ASSERT(u64_4.z == 4);
- _RS_ASSERT(u64_4.w == 5);
-
- if (failed) {
- rsDebug("test_vector FAILED", 0);
- }
- else {
- rsDebug("test_vector PASSED", 0);
- }
-
- return failed;
-}
-
-void vector_test() {
- bool failed = false;
- failed |= test_vector_types();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/SampleTest/Android.mk b/tests/RenderScriptTests/SampleTest/Android.mk
deleted file mode 100644
index f3439b0..0000000
--- a/tests/RenderScriptTests/SampleTest/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2012 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := SampleRS
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/SampleTest/AndroidManifest.xml b/tests/RenderScriptTests/SampleTest/AndroidManifest.xml
deleted file mode 100644
index ec115f7..0000000
--- a/tests/RenderScriptTests/SampleTest/AndroidManifest.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2012 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.
-*/
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.rs.sample">
- <uses-sdk android:minSdkVersion="14" />
- <application android:label="Sample Test"
- android:hardwareAccelerated="true">
-
- <activity android:name="SampleRSActivity"
- android:label="Sample Test">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/SampleTest/res/drawable-nodpi/city.png b/tests/RenderScriptTests/SampleTest/res/drawable-nodpi/city.png
deleted file mode 100644
index 27c4618..0000000
--- a/tests/RenderScriptTests/SampleTest/res/drawable-nodpi/city.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SampleTest/res/drawable-nodpi/twobytwo.png b/tests/RenderScriptTests/SampleTest/res/drawable-nodpi/twobytwo.png
deleted file mode 100644
index 98cf963..0000000
--- a/tests/RenderScriptTests/SampleTest/res/drawable-nodpi/twobytwo.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SampleTest/res/layout/rs.xml b/tests/RenderScriptTests/SampleTest/res/layout/rs.xml
deleted file mode 100644
index f2a356f..0000000
--- a/tests/RenderScriptTests/SampleTest/res/layout/rs.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:id="@+id/toplevel">
- <ScrollView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:text="@string/wraplinear"/>
- <TextureView
- android:id="@+id/display"
- android:layout_width="256sp"
- android:layout_height="256sp" />
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:text="@string/clamplinear"/>
- <TextureView
- android:id="@+id/display2"
- android:layout_width="256sp"
- android:layout_height="256sp" />
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:text="@string/wrapnearest"/>
- <TextureView
- android:id="@+id/display3"
- android:layout_width="256sp"
- android:layout_height="256sp" />
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:text="@string/clampnearest"/>
- <TextureView
- android:id="@+id/display4"
- android:layout_width="256sp"
- android:layout_height="256sp" />
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/benchmark"
- android:onClick="benchmark"/>
- <TextView
- android:id="@+id/benchmarkText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="8pt"
- android:text="@string/benchmark"/>
- </LinearLayout>
- </LinearLayout>
- </ScrollView>
-</LinearLayout>
-
diff --git a/tests/RenderScriptTests/SampleTest/res/values/strings.xml b/tests/RenderScriptTests/SampleTest/res/values/strings.xml
deleted file mode 100644
index a0a2499..0000000
--- a/tests/RenderScriptTests/SampleTest/res/values/strings.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2012 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.
-*/
--->
-
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- General -->
- <skip />
- <string name="benchmark">Benchmark</string>
- <string name="wraplinear">Wrap Linear</string>
- <string name="clamplinear">Clamp Linear</string>
- <string name="wrapnearest">Wrap Nearest</string>
- <string name="clampnearest">Clamp Nearest</string>
-</resources>
diff --git a/tests/RenderScriptTests/SampleTest/src/com/android/rs/sample/SampleRSActivity.java b/tests/RenderScriptTests/SampleTest/src/com/android/rs/sample/SampleRSActivity.java
deleted file mode 100644
index 77cbf84..0000000
--- a/tests/RenderScriptTests/SampleTest/src/com/android/rs/sample/SampleRSActivity.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.sample;
-
-import android.app.Activity;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.SurfaceTexture;
-import android.os.Bundle;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix3f;
-import android.renderscript.RenderScript;
-import android.renderscript.Sampler;
-import android.renderscript.Type;
-import android.renderscript.Type.Builder;
-import android.util.Log;
-import android.view.TextureView;
-import android.view.TextureView.SurfaceTextureListener;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class SampleRSActivity extends Activity {
- class TextureViewUpdater implements TextureView.SurfaceTextureListener {
- private Allocation mOutPixelsAllocation;
- private Sampler mSampler;
-
- TextureViewUpdater(Allocation outAlloc, Sampler sampler) {
- mOutPixelsAllocation = outAlloc;
- mSampler = sampler;
- }
-
- public void onSurfaceTextureUpdated(SurfaceTexture surface) {
- }
-
- public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
- mOutPixelsAllocation.setSurfaceTexture(surface);
- }
-
- public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
- mOutPixelsAllocation.setSurfaceTexture(surface);
- filterAlloc(mOutPixelsAllocation, mSampler);
- }
-
- public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
- mOutPixelsAllocation.setSurfaceTexture(null);
- return true;
- }
- }
-
- private final String TAG = "Img";
- private Bitmap mBitmapTwoByTwo;
- private Bitmap mBitmapCity;
-
- private TextView mBenchmarkResult;
-
- private RenderScript mRS;
- private Allocation mTwoByTwoAlloc;
- private Allocation mCityAlloc;
- private ScriptC_sample mScript;
-
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
-
- public void onStopTrackingTouch(SeekBar seekBar) {
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.rs);
-
- mBitmapTwoByTwo = loadBitmap(R.drawable.twobytwo);
- mBitmapCity = loadBitmap(R.drawable.city);
-
- mBenchmarkResult = (TextView) findViewById(R.id.benchmarkText);
- mBenchmarkResult.setText("Result: not run");
-
- mRS = RenderScript.create(this);
- mTwoByTwoAlloc = Allocation.createFromBitmap(mRS, mBitmapTwoByTwo,
- Allocation.MipmapControl.MIPMAP_NONE,
- Allocation.USAGE_SCRIPT);
-
- mCityAlloc = Allocation.createFromBitmap(mRS, mBitmapCity,
- Allocation.MipmapControl.MIPMAP_NONE,
- Allocation.USAGE_SCRIPT);
-
- Type.Builder b = new Type.Builder(mRS, Element.RGBA_8888(mRS));
-
- int usage = Allocation.USAGE_SCRIPT | Allocation.USAGE_IO_OUTPUT;
-
- int outX = 256;
- int outY = 256;
-
- // Wrap Linear
- Allocation outAlloc = Allocation.createTyped(mRS, b.setX(outX).setY(outY).create(), usage);
- TextureViewUpdater updater = new TextureViewUpdater(outAlloc, Sampler.WRAP_LINEAR(mRS));
- TextureView displayView = (TextureView) findViewById(R.id.display);
- displayView.setSurfaceTextureListener(updater);
-
- // Clamp Linear
- outAlloc = Allocation.createTyped(mRS, b.setX(outX).setY(outY).create(), usage);
- updater = new TextureViewUpdater(outAlloc, Sampler.CLAMP_LINEAR(mRS));
- displayView = (TextureView) findViewById(R.id.display2);
- displayView.setSurfaceTextureListener(updater);
-
- // Wrap Nearest
- outAlloc = Allocation.createTyped(mRS, b.setX(outX).setY(outY).create(), usage);
- updater = new TextureViewUpdater(outAlloc, Sampler.WRAP_NEAREST(mRS));
- displayView = (TextureView) findViewById(R.id.display3);
- displayView.setSurfaceTextureListener(updater);
-
- // Clamp Nearest
- outAlloc = Allocation.createTyped(mRS, b.setX(outX).setY(outY).create(), usage);
- updater = new TextureViewUpdater(outAlloc, Sampler.CLAMP_NEAREST(mRS));
- displayView = (TextureView) findViewById(R.id.display4);
- displayView.setSurfaceTextureListener(updater);
-
- mScript = new ScriptC_sample(mRS, getResources(), R.raw.sample);
- }
-
- private Bitmap loadBitmap(int resource) {
- final BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- Bitmap b = BitmapFactory.decodeResource(getResources(), resource, options);
- Bitmap b2 = Bitmap.createBitmap(b.getWidth(), b.getHeight(), b.getConfig());
- Canvas c = new Canvas(b2);
- c.drawBitmap(b, 0, 0, null);
- b.recycle();
- return b2;
- }
-
- private synchronized void filterAlloc(Allocation alloc, Sampler sampler) {
- long t = java.lang.System.currentTimeMillis();
- mScript.invoke_setSampleData(alloc, mTwoByTwoAlloc, sampler);
- mScript.forEach_root(alloc);
- alloc.ioSendOutput();
- mRS.finish();
- t = java.lang.System.currentTimeMillis() - t;
- Log.i(TAG, "Filter time is: " + t + " ms");
- }
-
- public void benchmark(View v) {
- /*filterAlloc();
- long t = java.lang.System.currentTimeMillis();
- filterAlloc();
- t = java.lang.System.currentTimeMillis() - t;
- mDisplayView.invalidate();
- mBenchmarkResult.setText("Result: " + t + " ms");*/
- }
-}
diff --git a/tests/RenderScriptTests/SampleTest/src/com/android/rs/sample/sample.rs b/tests/RenderScriptTests/SampleTest/src/com/android/rs/sample/sample.rs
deleted file mode 100644
index e2bf43d..0000000
--- a/tests/RenderScriptTests/SampleTest/src/com/android/rs/sample/sample.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#pragma version(1)
-#pragma rs java_package_name(com.android.rs.sample)
-#include "rs_graphics.rsh"
-
-static rs_allocation sourceAlloc;
-static rs_allocation destAlloc;
-static rs_sampler allocSampler;
-
-void setSampleData(rs_allocation dest, rs_allocation source, rs_sampler sampler) {
- destAlloc = dest;
- sourceAlloc = source;
- allocSampler = sampler;
-}
-
-void root(uchar4 *out, uint32_t x, uint32_t y) {
-
- float destX = (float)rsAllocationGetDimX(destAlloc) - 1.0f;
- float destY = (float)rsAllocationGetDimY(destAlloc) - 1.0f;
-
- float2 uv;
- uv.x = (float)x / destX;
- uv.y = (float)y / destY;
-
- out->xyz = convert_uchar3(rsSample(sourceAlloc, allocSampler, uv*2.0f).xyz);
- out->w = 0xff;
-}
-
diff --git a/tests/RenderScriptTests/tests/Android.mk b/tests/RenderScriptTests/tests/Android.mk
deleted file mode 100644
index 198693c..0000000
--- a/tests/RenderScriptTests/tests/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2008 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := RSTest
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/tests/AndroidManifest.xml b/tests/RenderScriptTests/tests/AndroidManifest.xml
deleted file mode 100644
index b660398..0000000
--- a/tests/RenderScriptTests/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.rs.test">
- <application
- android:label="_RS_Test"
- android:icon="@drawable/test_pattern">
- <activity android:name="RSTest"
- android:screenOrientation="portrait">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/tests/res/drawable-nodpi/test_pattern.png b/tests/RenderScriptTests/tests/res/drawable-nodpi/test_pattern.png
deleted file mode 100644
index e7d1455..0000000
--- a/tests/RenderScriptTests/tests/res/drawable-nodpi/test_pattern.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTest.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTest.java
deleted file mode 100644
index d1b23fa..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2008 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.rs.test;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.provider.Settings.System;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.ListView;
-
-import java.lang.Runtime;
-
-public class RSTest extends Activity {
- //EventListener mListener = new EventListener();
-
- private static final String LOG_TAG = "RSTest";
- private static final boolean DEBUG = false;
- private static final boolean LOG_ENABLED = false;
-
- private RSTestView mView;
-
- // get the current looper (from your Activity UI thread for instance
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new RSTestView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onPause();
- mView.pause();
- }
-
- @Override
- protected void onStop() {
- // Actually kill the app if we are stopping. We don't want to
- // continue/resume this test ever. It should always start fresh.
- finish();
- super.onStop();
- }
-
- static void log(String message) {
- if (LOG_ENABLED) {
- Log.v(LOG_TAG, message);
- }
- }
-
-
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
deleted file mode 100644
index 8645ae5..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-import java.util.ArrayList;
-import java.util.ListIterator;
-import java.util.Timer;
-import java.util.TimerTask;
-
-
-public class RSTestCore {
- int mWidth;
- int mHeight;
- Context mCtx;
-
- public RSTestCore(Context ctx) {
- mCtx = ctx;
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
-
- private Font mFont;
- ScriptField_ListAllocs_s mListAllocs;
- int mLastX;
- int mLastY;
- private ScriptC_rslist mScript;
-
- private ArrayList<UnitTest> unitTests;
- private ListIterator<UnitTest> test_iter;
- private UnitTest activeTest;
- private boolean stopTesting;
-
- /* Periodic timer for ensuring future tests get scheduled */
- private Timer mTimer;
- public static final int RS_TIMER_PERIOD = 100;
-
- public void init(RenderScriptGL rs, Resources res, int width, int height) {
- mRS = rs;
- mRes = res;
- mWidth = width;
- mHeight = height;
- stopTesting = false;
-
- mScript = new ScriptC_rslist(mRS, mRes, R.raw.rslist);
-
- unitTests = new ArrayList<UnitTest>();
-
- unitTests.add(new UT_primitives(this, mRes, mCtx));
- unitTests.add(new UT_constant(this, mRes, mCtx));
- unitTests.add(new UT_vector(this, mRes, mCtx));
- unitTests.add(new UT_unsigned(this, mRes, mCtx));
- unitTests.add(new UT_array_init(this, mRes, mCtx));
- unitTests.add(new UT_array_alloc(this, mRes, mCtx));
- unitTests.add(new UT_kernel(this, mRes, mCtx));
- unitTests.add(new UT_kernel_struct(this, mRes, mCtx));
- unitTests.add(new UT_bug_char(this, mRes, mCtx));
- unitTests.add(new UT_clamp(this, mRes, mCtx));
- unitTests.add(new UT_clamp_relaxed(this, mRes, mCtx));
- unitTests.add(new UT_convert(this, mRes, mCtx));
- unitTests.add(new UT_convert_relaxed(this, mRes, mCtx));
- unitTests.add(new UT_copy_test(this, mRes, mCtx));
- unitTests.add(new UT_rsdebug(this, mRes, mCtx));
- unitTests.add(new UT_rstime(this, mRes, mCtx));
- unitTests.add(new UT_rstypes(this, mRes, mCtx));
- unitTests.add(new UT_alloc(this, mRes, mCtx));
- unitTests.add(new UT_refcount(this, mRes, mCtx));
- unitTests.add(new UT_foreach(this, mRes, mCtx));
- unitTests.add(new UT_foreach_bounds(this, mRes, mCtx));
- unitTests.add(new UT_noroot(this, mRes, mCtx));
- unitTests.add(new UT_atomic(this, mRes, mCtx));
- unitTests.add(new UT_struct(this, mRes, mCtx));
- unitTests.add(new UT_math(this, mRes, mCtx));
- unitTests.add(new UT_math_conformance(this, mRes, mCtx));
- unitTests.add(new UT_math_agree(this, mRes, mCtx));
- unitTests.add(new UT_min(this, mRes, mCtx));
- unitTests.add(new UT_int4(this, mRes, mCtx));
- unitTests.add(new UT_element(this, mRes, mCtx));
- unitTests.add(new UT_sampler(this, mRes, mCtx));
- unitTests.add(new UT_program_store(this, mRes, mCtx));
- unitTests.add(new UT_program_raster(this, mRes, mCtx));
- unitTests.add(new UT_mesh(this, mRes, mCtx));
- unitTests.add(new UT_fp_mad(this, mRes, mCtx));
-
- /*
- unitTests.add(new UnitTest(null, "<Pass>", 1));
- unitTests.add(new UnitTest());
- unitTests.add(new UnitTest(null, "<Fail>", -1));
-
- for (int i = 0; i < 20; i++) {
- unitTests.add(new UnitTest(null, "<Pass>", 1));
- }
- */
-
- UnitTest [] uta = new UnitTest[unitTests.size()];
- uta = unitTests.toArray(uta);
-
- mListAllocs = new ScriptField_ListAllocs_s(mRS, uta.length);
- for (int i = 0; i < uta.length; i++) {
- ScriptField_ListAllocs_s.Item listElem = new ScriptField_ListAllocs_s.Item();
- listElem.text = Allocation.createFromString(mRS, uta[i].name, Allocation.USAGE_SCRIPT);
- listElem.result = uta[i].getResult();
- mListAllocs.set(listElem, i, false);
- uta[i].setItem(listElem);
- }
-
- mListAllocs.copyAll();
-
- mScript.bind_gList(mListAllocs);
-
- mFont = Font.create(mRS, mRes, "serif", Font.Style.BOLD, 8);
- mScript.set_gFont(mFont);
-
- mRS.bindRootScript(mScript);
-
- test_iter = unitTests.listIterator();
- refreshTestResults(); /* Kick off the first test */
-
- TimerTask pTask = new TimerTask() {
- public void run() {
- refreshTestResults();
- }
- };
-
- mTimer = new Timer();
- mTimer.schedule(pTask, RS_TIMER_PERIOD, RS_TIMER_PERIOD);
- }
-
- public void checkAndRunNextTest() {
- if (activeTest != null) {
- if (!activeTest.isAlive()) {
- /* Properly clean up on our last test */
- try {
- activeTest.join();
- }
- catch (InterruptedException e) {
- }
- activeTest = null;
- }
- }
-
- if (!stopTesting && activeTest == null) {
- if (test_iter.hasNext()) {
- activeTest = test_iter.next();
- activeTest.start();
- /* This routine will only get called once when a new test
- * should start running. The message handler in UnitTest.java
- * ensures this. */
- }
- else {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer.purge();
- mTimer = null;
- }
- }
- }
- }
-
- public void refreshTestResults() {
- checkAndRunNextTest();
-
- if (mListAllocs != null && mScript != null && mRS != null) {
- mListAllocs.copyAll();
-
- mScript.bind_gList(mListAllocs);
- mRS.bindRootScript(mScript);
- }
- }
-
- public void cleanup() {
- stopTesting = true;
- UnitTest t = activeTest;
-
- /* Stop periodic refresh of testing */
- if (mTimer != null) {
- mTimer.cancel();
- mTimer.purge();
- mTimer = null;
- }
-
- /* Wait to exit until we finish the current test */
- if (t != null) {
- try {
- t.join();
- }
- catch (InterruptedException e) {
- }
- t = null;
- }
-
- }
-
- public void newTouchPosition(float x, float y, float pressure, int id) {
- }
-
- public void onActionDown(int x, int y) {
- mScript.set_gDY(0.0f);
- mLastX = x;
- mLastY = y;
- refreshTestResults();
- }
-
- public void onActionMove(int x, int y) {
- int dx = mLastX - x;
- int dy = mLastY - y;
-
- if (Math.abs(dy) <= 2) {
- dy = 0;
- }
-
- mScript.set_gDY(dy);
-
- mLastX = x;
- mLastY = y;
- refreshTestResults();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestView.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestView.java
deleted file mode 100644
index 368f286..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestView.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2008 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.rs.test;
-
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.concurrent.Semaphore;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-
-public class RSTestView extends RSSurfaceView {
-
- private Context mCtx;
-
- public RSTestView(Context context) {
- super(context);
- mCtx = context;
- //setFocusable(true);
- }
-
- private RenderScriptGL mRS;
- private RSTestCore mRender;
-
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- mRS = createRenderScriptGL(sc);
- mRS.setSurface(holder, w, h);
- mRender = new RSTestCore(mCtx);
- mRender.init(mRS, getResources(), w, h);
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- if(mRS != null) {
- mRender.cleanup();
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- return super.onKeyDown(keyCode, event);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev)
- {
- boolean ret = false;
- int act = ev.getAction();
- if (act == ev.ACTION_DOWN) {
- mRender.onActionDown((int)ev.getX(), (int)ev.getY());
- ret = true;
- }
- else if (act == ev.ACTION_MOVE) {
- mRender.onActionMove((int)ev.getX(), (int)ev.getY());
- ret = true;
- }
-
- return ret;
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_alloc.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_alloc.java
deleted file mode 100644
index 3ea942c..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_alloc.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_alloc extends UnitTest {
- private Resources mRes;
-
- protected UT_alloc(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Alloc", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_alloc s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- int Y = 7;
- int Z = 0;
- s.set_dimX(X);
- s.set_dimY(Y);
- s.set_dimZ(Z);
- typeBuilder.setX(X).setY(Y);
- Allocation A = Allocation.createTyped(RS, typeBuilder.create());
- s.bind_a(A);
- s.set_aRaw(A);
-
- typeBuilder = new Type.Builder(RS, Element.I32(RS));
- typeBuilder.setX(X).setY(Y).setFaces(true);
- Allocation AFaces = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aFaces(AFaces);
- typeBuilder.setFaces(false).setMipmaps(true);
- Allocation ALOD = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aLOD(ALOD);
- typeBuilder.setFaces(true).setMipmaps(true);
- Allocation AFacesLOD = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aFacesLOD(AFacesLOD);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_alloc s = new ScriptC_alloc(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_root(s.get_aRaw());
- s.invoke_alloc_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_alloc.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_alloc.java
deleted file mode 100644
index ac01a93..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_alloc.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_array_alloc extends UnitTest {
- private Resources mRes;
-
- protected UT_array_alloc(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Array Allocation", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_array_alloc s = new ScriptC_array_alloc(pRS);
- pRS.setMessageHandler(mRsMessage);
-
- int dimX = s.get_dimX();
- Allocation[] Arr = new Allocation[dimX];
- Type.Builder typeBuilder = new Type.Builder(pRS, Element.I32(pRS));
- Type T = typeBuilder.setX(1).create();
- for (int i = 0; i < dimX; i++) {
- Allocation A = Allocation.createTyped(pRS, T);
- Arr[i] = A;
- }
- s.set_a(Arr);
-
- s.invoke_array_alloc_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- passTest();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_init.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_init.java
deleted file mode 100644
index c74e4b3..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_init.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_array_init extends UnitTest {
- private Resources mRes;
-
- protected UT_array_init(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Array Init", ctx);
- mRes = res;
- }
-
- private void checkInit(ScriptC_array_init s) {
- float[] fa = s.get_fa();
- _RS_ASSERT("fa[0] == 1.0", fa[0] == 1.0);
- _RS_ASSERT("fa[1] == 9.9999f", fa[1] == 9.9999f);
- _RS_ASSERT("fa[2] == 0", fa[2] == 0);
- _RS_ASSERT("fa[3] == 0", fa[3] == 0);
- _RS_ASSERT("fa.length == 4", fa.length == 4);
-
- double[] da = s.get_da();
- _RS_ASSERT("da[0] == 7.0", da[0] == 7.0);
- _RS_ASSERT("da[1] == 8.88888", da[1] == 8.88888);
- _RS_ASSERT("da.length == 2", da.length == 2);
-
- byte[] ca = s.get_ca();
- _RS_ASSERT("ca[0] == 'a'", ca[0] == 'a');
- _RS_ASSERT("ca[1] == 7", ca[1] == 7);
- _RS_ASSERT("ca[2] == 'b'", ca[2] == 'b');
- _RS_ASSERT("ca[3] == 'c'", ca[3] == 'c');
- _RS_ASSERT("ca.length == 4", ca.length == 4);
-
- short[] sa = s.get_sa();
- _RS_ASSERT("sa[0] == 1", sa[0] == 1);
- _RS_ASSERT("sa[1] == 1", sa[1] == 1);
- _RS_ASSERT("sa[2] == 2", sa[2] == 2);
- _RS_ASSERT("sa[3] == 3", sa[3] == 3);
- _RS_ASSERT("sa.length == 4", sa.length == 4);
-
- int[] ia = s.get_ia();
- _RS_ASSERT("ia[0] == 5", ia[0] == 5);
- _RS_ASSERT("ia[1] == 8", ia[1] == 8);
- _RS_ASSERT("ia[2] == 0", ia[2] == 0);
- _RS_ASSERT("ia[3] == 0", ia[3] == 0);
- _RS_ASSERT("ia.length == 4", ia.length == 4);
-
- long[] la = s.get_la();
- _RS_ASSERT("la[0] == 13", la[0] == 13);
- _RS_ASSERT("la[1] == 21", la[1] == 21);
- _RS_ASSERT("la.length == 4", la.length == 2);
-
- long[] lla = s.get_lla();
- _RS_ASSERT("lla[0] == 34", lla[0] == 34);
- _RS_ASSERT("lla[1] == 0", lla[1] == 0);
- _RS_ASSERT("lla[2] == 0", lla[2] == 0);
- _RS_ASSERT("lla[3] == 0", lla[3] == 0);
- _RS_ASSERT("lla.length == 4", lla.length == 4);
-
- boolean[] ba = s.get_ba();
- _RS_ASSERT("ba[0] == true", ba[0] == true);
- _RS_ASSERT("ba[1] == false", ba[1] == false);
- _RS_ASSERT("ba[2] == false", ba[2] == false);
- _RS_ASSERT("ba.length == 3", ba.length == 3);
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_array_init s = new ScriptC_array_init(pRS);
- pRS.setMessageHandler(mRsMessage);
- checkInit(s);
- s.invoke_array_init_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- passTest();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_atomic.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_atomic.java
deleted file mode 100644
index 0b8e072..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_atomic.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_atomic extends UnitTest {
- private Resources mRes;
-
- protected UT_atomic(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Atomics", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_atomic s = new ScriptC_atomic(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_atomic_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_bug_char.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_bug_char.java
deleted file mode 100644
index faf3a31..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_bug_char.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-import java.util.Arrays;
-
-public class UT_bug_char extends UnitTest {
- private Resources mRes;
-
- protected UT_bug_char(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Bug Char", ctx);
- mRes = res;
- }
-
- // packing functions
- private Byte2 pack_b2(byte[] val) {
- assert val.length == 2;
- Log.i("bug_char", "pack_b2 " + val[0] + " " + val[1]);
- return new Byte2(val[0], val[1]);
- }
-
- private byte min(byte v1, byte v2) {
- return v1 < v2 ? v1 : v2;
- }
- private byte[] min(byte[] v1, byte[] v2) {
- assert v1.length == v2.length;
- byte[] rv = new byte[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
-
- private void initializeValues(ScriptC_bug_char s) {
- byte rand_sc1_0 = (byte)7;
- byte[] rand_sc2_0 = new byte[2];
- rand_sc2_0[0] = 11;
- rand_sc2_0[1] = 21;
- Log.i("bug_char", "Generated sc2_0 to " + Arrays.toString(rand_sc2_0));
- byte rand_sc1_1 = (byte)10;
- byte[] rand_sc2_1 = new byte[2];
- rand_sc2_1[0] = 13;
- rand_sc2_1[1] = 15;
- Log.i("bug_char", "Generated sc2_1 to " + Arrays.toString(rand_sc2_1));
-
- s.set_rand_sc1_0(rand_sc1_0);
- s.set_rand_sc2_0(pack_b2(rand_sc2_0));
- s.set_rand_sc1_1(rand_sc1_1);
- s.set_rand_sc2_1(pack_b2(rand_sc2_1));
- // Set results for min
- s.set_min_rand_sc1_sc1(min(rand_sc1_0, rand_sc1_1));
- byte[] min_rand_sc2_raw = min(rand_sc2_0, rand_sc2_1);
- Log.i("bug_char", "Generating min_rand_sc2_sc2 to " +
- Arrays.toString(min_rand_sc2_raw));
- Byte2 min_rand_sc2 = pack_b2(min_rand_sc2_raw);
- Log.i("bug_char", "Setting min_rand_sc2_sc2 to [" + min_rand_sc2.x +
- ", " + min_rand_sc2.y + "]");
- s.set_min_rand_sc2_sc2(min_rand_sc2);
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_bug_char s = new ScriptC_bug_char(pRS, mRes,
- R.raw.bug_char);
- pRS.setMessageHandler(mRsMessage);
- initializeValues(s);
- s.invoke_bug_char_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_clamp.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_clamp.java
deleted file mode 100644
index de98d0c..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_clamp.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_clamp extends UnitTest {
- private Resources mRes;
-
- protected UT_clamp(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Clamp (Full)", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_clamp s = new ScriptC_clamp(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_clamp_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_clamp_relaxed.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_clamp_relaxed.java
deleted file mode 100644
index 91e7140..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_clamp_relaxed.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_clamp_relaxed extends UnitTest {
- private Resources mRes;
-
- protected UT_clamp_relaxed(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Clamp (Relaxed)", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_clamp_relaxed s =
- new ScriptC_clamp_relaxed(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_clamp_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_constant.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_constant.java
deleted file mode 100644
index adda5a3..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_constant.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_constant extends UnitTest {
- private Resources mRes;
-
- protected UT_constant(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Const", ctx);
- mRes = res;
- }
-
- private void Assert(boolean b) {
- if (!b) {
- failTest();
- }
- }
-
- public void run() {
- Assert(ScriptC_constant.const_floatTest == 1.99f);
- Assert(ScriptC_constant.const_doubleTest == 2.05);
- Assert(ScriptC_constant.const_charTest == -8);
- Assert(ScriptC_constant.const_shortTest == -16);
- Assert(ScriptC_constant.const_intTest == -32);
- Assert(ScriptC_constant.const_longTest == 17179869184l);
- Assert(ScriptC_constant.const_longlongTest == 68719476736l);
-
- Assert(ScriptC_constant.const_ucharTest == 8);
- Assert(ScriptC_constant.const_ushortTest == 16);
- Assert(ScriptC_constant.const_uintTest == 32);
- Assert(ScriptC_constant.const_ulongTest == 4611686018427387904L);
- Assert(ScriptC_constant.const_int64_tTest == -17179869184l);
- Assert(ScriptC_constant.const_uint64_tTest == 117179869184l);
-
- Assert(ScriptC_constant.const_boolTest == true);
-
- passTest();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_convert.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_convert.java
deleted file mode 100644
index adf79bc..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_convert.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_convert extends UnitTest {
- private Resources mRes;
-
- protected UT_convert(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Convert", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_convert s = new ScriptC_convert(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_convert_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_convert_relaxed.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_convert_relaxed.java
deleted file mode 100644
index a0757f3..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_convert_relaxed.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_convert_relaxed extends UnitTest {
- private Resources mRes;
-
- protected UT_convert_relaxed(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Convert (Relaxed)", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_convert_relaxed s =
- new ScriptC_convert_relaxed(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_convert_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_copy_test.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_copy_test.java
deleted file mode 100644
index 380f6ec..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_copy_test.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-
-public class UT_copy_test extends UnitTest {
- private Resources mRes;
- boolean pass = true;
-
- protected UT_copy_test(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Copy", ctx);
- mRes = res;
- }
-
- void testFloat2(RenderScript rs, ScriptC_copy_test s) {
- Allocation a1 = Allocation.createSized(rs, Element.F32_2(rs), 1024);
- Allocation a2 = Allocation.createSized(rs, Element.F32_2(rs), 1024);
-
- float[] f1 = new float[1024 * 2];
- float[] f2 = new float[1024 * 2];
- for (int ct=0; ct < f1.length; ct++) {
- f1[ct] = (float)ct;
- }
- a1.copyFrom(f1);
-
- s.forEach_copyFloat2(a1, a2);
-
- a2.copyTo(f2);
- for (int ct=0; ct < f1.length; ct++) {
- if (f1[ct] != f2[ct]) {
- failTest();
- Log.v("RS Test", "Compare failed at " + ct + ", " + f1[ct] + ", " + f2[ct]);
- }
- }
- a1.destroy();
- a2.destroy();
- }
-
- void testFloat3(RenderScript rs, ScriptC_copy_test s) {
- Allocation a1 = Allocation.createSized(rs, Element.F32_3(rs), 1024);
- Allocation a2 = Allocation.createSized(rs, Element.F32_3(rs), 1024);
-
- float[] f1 = new float[1024 * 4];
- float[] f2 = new float[1024 * 4];
- for (int ct=0; ct < f1.length; ct++) {
- f1[ct] = (float)ct;
- }
- a1.copyFrom(f1);
-
- s.forEach_copyFloat3(a1, a2);
-
- a2.copyTo(f2);
- for (int ct=0; ct < f1.length; ct++) {
- if ((f1[ct] != f2[ct]) && ((ct&3) != 3)) {
- failTest();
- Log.v("RS Test", "Compare failed at " + ct + ", " + f1[ct] + ", " + f2[ct]);
- }
- }
- a1.destroy();
- a2.destroy();
- }
-
- void testFloat4(RenderScript rs, ScriptC_copy_test s) {
- Allocation a1 = Allocation.createSized(rs, Element.F32_4(rs), 1024);
- Allocation a2 = Allocation.createSized(rs, Element.F32_4(rs), 1024);
-
- float[] f1 = new float[1024 * 4];
- float[] f2 = new float[1024 * 4];
- for (int ct=0; ct < f1.length; ct++) {
- f1[ct] = (float)ct;
- }
- a1.copyFrom(f1);
-
- s.forEach_copyFloat4(a1, a2);
-
- a2.copyTo(f2);
- for (int ct=0; ct < f1.length; ct++) {
- if (f1[ct] != f2[ct]) {
- failTest();
- Log.v("RS Test", "Compare failed at " + ct + ", " + f1[ct] + ", " + f2[ct]);
- }
- }
- a1.destroy();
- a2.destroy();
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_copy_test s = new ScriptC_copy_test(pRS);
- pRS.setMessageHandler(mRsMessage);
-
- testFloat2(pRS, s);
- testFloat3(pRS, s);
- testFloat4(pRS, s);
- s.invoke_sendResult(true);
-
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_element.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_element.java
deleted file mode 100644
index 07bcc74..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_element.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.Element.*;
-import android.renderscript.Element.DataKind.*;
-import android.renderscript.Element.DataType.*;
-
-public class UT_element extends UnitTest {
- private Resources mRes;
-
- Element simpleElem;
- Element complexElem;
-
- final String subElemNames[] = {
- "subElem0",
- "subElem1",
- "subElem2",
- "arrayElem0",
- "arrayElem1",
- "subElem3",
- "subElem4",
- "subElem5",
- "subElem6",
- "subElem_7",
- };
-
- final int subElemArraySizes[] = {
- 1,
- 1,
- 1,
- 2,
- 5,
- 1,
- 1,
- 1,
- 1,
- 1,
- };
-
- final int subElemOffsets[] = {
- 0,
- 4,
- 8,
- 12,
- 20,
- 40,
- 44,
- 48,
- 64,
- 80,
- };
-
- protected UT_element(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Element", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_element s) {
- simpleElem = Element.F32_3(RS);
- complexElem = ScriptField_ComplexStruct.createElement(RS);
- s.set_simpleElem(simpleElem);
- s.set_complexElem(complexElem);
-
- ScriptField_ComplexStruct data = new ScriptField_ComplexStruct(RS, 1);
- s.bind_complexStruct(data);
- }
-
- private void testScriptSide(RenderScript pRS) {
- ScriptC_element s = new ScriptC_element(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.invoke_element_test();
- pRS.finish();
- waitForMessage();
- }
-
- private void testJavaSide(RenderScript RS) {
-
- int subElemCount = simpleElem.getSubElementCount();
- _RS_ASSERT("subElemCount == 0", subElemCount == 0);
- _RS_ASSERT("simpleElem.getDataKind() == USER",
- simpleElem.getDataKind() == DataKind.USER);
- _RS_ASSERT("simpleElem.getDataType() == FLOAT_32",
- simpleElem.getDataType() == DataType.FLOAT_32);
-
- subElemCount = complexElem.getSubElementCount();
- _RS_ASSERT("subElemCount == 10", subElemCount == 10);
- _RS_ASSERT("complexElem.getDataKind() == USER",
- complexElem.getDataKind() == DataKind.USER);
- _RS_ASSERT("complexElemsimpleElem.getDataType() == NONE",
- complexElem.getDataType() == DataType.NONE);
- _RS_ASSERT("complexElem.getSizeBytes() == ScriptField_ComplexStruct.Item.sizeof",
- complexElem.getBytesSize() == ScriptField_ComplexStruct.Item.sizeof);
-
- for (int i = 0; i < subElemCount; i ++) {
- _RS_ASSERT("complexElem.getSubElement(i) != null",
- complexElem.getSubElement(i) != null);
- _RS_ASSERT("complexElem.getSubElementName(i).equals(subElemNames[i])",
- complexElem.getSubElementName(i).equals(subElemNames[i]));
- _RS_ASSERT("complexElem.getSubElementArraySize(i) == subElemArraySizes[i]",
- complexElem.getSubElementArraySize(i) == subElemArraySizes[i]);
- _RS_ASSERT("complexElem.getSubElementOffsetBytes(i) == subElemOffsets[i]",
- complexElem.getSubElementOffsetBytes(i) == subElemOffsets[i]);
- }
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- testScriptSide(pRS);
- testJavaSide(pRS);
- passTest();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach.java
deleted file mode 100644
index 6c95109..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_foreach extends UnitTest {
- private Resources mRes;
- private Allocation A;
-
- protected UT_foreach(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "ForEach", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_foreach s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- int Y = 7;
- s.set_dimX(X);
- s.set_dimY(Y);
- typeBuilder.setX(X).setY(Y);
- A = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aRaw(A);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_foreach s = new ScriptC_foreach(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_root(A);
- s.invoke_verify_root();
- s.forEach_foo(A, A);
- s.invoke_verify_foo();
- s.invoke_foreach_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach_bounds.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach_bounds.java
deleted file mode 100644
index 97f3a32..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach_bounds.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_foreach_bounds extends UnitTest {
- private Resources mRes;
- private Allocation A;
-
- protected UT_foreach_bounds(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "ForEach (bounds)", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_foreach_bounds s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- int Y = 7;
- final int xStart = 2;
- final int xEnd = 5;
- final int yStart = 3;
- final int yEnd = 6;
- s.set_dimX(X);
- s.set_dimY(Y);
- typeBuilder.setX(X).setY(Y);
- A = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aRaw(A);
- s.set_s(s);
- s.set_ain(A);
- s.set_aout(A);
- s.set_xStart(xStart);
- s.set_xEnd(xEnd);
- s.set_yStart(yStart);
- s.set_yEnd(yEnd);
- s.forEach_zero(A);
-
- Script.LaunchOptions sc = new Script.LaunchOptions();
- sc.setX(xStart, xEnd).setY(yStart, yEnd);
- s.forEach_root(A, sc);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_foreach_bounds s = new ScriptC_foreach_bounds(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.invoke_verify_root();
- s.invoke_foreach_bounds_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_fp_mad.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_fp_mad.java
deleted file mode 100644
index 5b7344d..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_fp_mad.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_fp_mad extends UnitTest {
- private Resources mRes;
-
- protected UT_fp_mad(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Fp_Mad", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_fp_mad s = new ScriptC_fp_mad(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_fp_mad_test(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_int4.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_int4.java
deleted file mode 100644
index 89a2a71..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_int4.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_int4 extends UnitTest {
- private Resources mRes;
-
- protected UT_int4(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "int4", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_int4 s = new ScriptC_int4(pRS, mRes, R.raw.int4);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_int4_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_kernel.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_kernel.java
deleted file mode 100644
index e0bd33e..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_kernel.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-
-public class UT_kernel extends UnitTest {
- private Resources mRes;
- private Allocation A;
- private Allocation B;
-
- protected UT_kernel(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Kernels (pass-by-value)", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_kernel s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- s.set_dimX(X);
- typeBuilder.setX(X);
- A = Allocation.createTyped(RS, typeBuilder.create());
- s.bind_ain(A);
- B = Allocation.createTyped(RS, typeBuilder.create());
- s.bind_aout(B);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_kernel s = new ScriptC_kernel(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_init_vars(A);
- s.forEach_root(A, B);
- s.invoke_verify_root();
- s.invoke_kernel_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_kernel_struct.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_kernel_struct.java
deleted file mode 100644
index 8e22810..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_kernel_struct.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-
-public class UT_kernel_struct extends UnitTest {
- private Resources mRes;
- private Allocation A;
- private Allocation B;
-
- protected UT_kernel_struct(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Kernels (struct pass-by-value)", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_kernel_struct s) {
- int X = 5;
- s.set_dimX(X);
- ScriptField_simpleStruct t;
- t = new ScriptField_simpleStruct(RS, X);
- s.bind_ain(t);
- A = t.getAllocation();
- t = new ScriptField_simpleStruct(RS, X);
- s.bind_aout(t);
- B = t.getAllocation();
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_kernel_struct s = new ScriptC_kernel_struct(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_init_vars(A);
- s.forEach_root(A, B);
- s.invoke_verify_root();
- s.invoke_kernel_struct_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math.java
deleted file mode 100644
index 8ad462b..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_math extends UnitTest {
- private Resources mRes;
-
- protected UT_math(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Math", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_math s = new ScriptC_math(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_math_test(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java
deleted file mode 100644
index 220509c..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-import java.util.Arrays;
-import java.util.Random;
-
-public class UT_math_agree extends UnitTest {
- private Resources mRes;
- private Random rand;
-
- protected UT_math_agree(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Math Agreement", ctx);
- mRes = res;
- rand = new Random();
- }
-
- // packing functions
- private Float2 pack_f2(float[] val) {
- assert val.length == 2;
- return new Float2(val[0], val[1]);
- }
- private Float3 pack_f3(float[] val) {
- assert val.length == 3;
- return new Float3(val[0], val[1], val[2]);
- }
- private Float4 pack_f4(float[] val) {
- assert val.length == 4;
- return new Float4(val[0], val[1], val[2], val[3]);
- }
- private Byte2 pack_b2(byte[] val) {
- assert val.length == 2;
- return new Byte2(val[0], val[1]);
- }
- private Byte3 pack_b3(byte[] val) {
- assert val.length == 3;
- return new Byte3(val[0], val[1], val[2]);
- }
- private Byte4 pack_b4(byte[] val) {
- assert val.length == 4;
- return new Byte4(val[0], val[1], val[2], val[3]);
- }
- private Short2 pack_s2(short[] val) {
- assert val.length == 2;
- return new Short2(val[0], val[1]);
- }
- private Short3 pack_s3(short[] val) {
- assert val.length == 3;
- return new Short3(val[0], val[1], val[2]);
- }
- private Short4 pack_s4(short[] val) {
- assert val.length == 4;
- return new Short4(val[0], val[1], val[2], val[3]);
- }
- private Int2 pack_i2(int[] val) {
- assert val.length == 2;
- return new Int2(val[0], val[1]);
- }
- private Int3 pack_i3(int[] val) {
- assert val.length == 3;
- return new Int3(val[0], val[1], val[2]);
- }
- private Int4 pack_i4(int[] val) {
- assert val.length == 4;
- return new Int4(val[0], val[1], val[2], val[3]);
- }
- private Long2 pack_l2(long[] val) {
- assert val.length == 2;
- return new Long2(val[0], val[1]);
- }
- private Long3 pack_l3(long[] val) {
- assert val.length == 3;
- return new Long3(val[0], val[1], val[2]);
- }
- private Long4 pack_l4(long[] val) {
- assert val.length == 4;
- return new Long4(val[0], val[1], val[2], val[3]);
- }
-
- // random vector generation functions
- private float[] randvec_float(int dim) {
- float[] fv = new float[dim];
- for (int i = 0; i < dim; ++i)
- fv[i] = rand.nextFloat();
- return fv;
- }
- private byte[] randvec_char(int dim) {
- byte[] cv = new byte[dim];
- rand.nextBytes(cv);
- return cv;
- }
- private short[] randvec_uchar(int dim) {
- short[] ucv = new short[dim];
- for (int i = 0; i < dim; ++i)
- ucv[i] = (short)rand.nextInt(0x1 << 8);
- return ucv;
- }
- private short[] randvec_short(int dim) {
- short[] sv = new short[dim];
- for (int i = 0; i < dim; ++i)
- sv[i] = (short)rand.nextInt(0x1 << 16);
- return sv;
- }
- private int[] randvec_ushort(int dim) {
- int[] usv = new int[dim];
- for (int i = 0; i < dim; ++i)
- usv[i] = rand.nextInt(0x1 << 16);
- return usv;
- }
- private int[] randvec_int(int dim) {
- int[] iv = new int[dim];
- for (int i = 0; i < dim; ++i)
- iv[i] = rand.nextInt();
- return iv;
- }
- private long[] randvec_uint(int dim) {
- long[] uiv = new long[dim];
- for (int i = 0; i < dim; ++i)
- uiv[i] = (long)rand.nextInt() - (long)Integer.MIN_VALUE;
- return uiv;
- }
- private long[] randvec_long(int dim) {
- long[] lv = new long[dim];
- for (int i = 0; i < dim; ++i)
- lv[i] = rand.nextLong();
- return lv;
- }
- // TODO: unsigned long generator
-
- // min reference functions
- private float min(float v1, float v2) {
- return v1 < v2 ? v1 : v2;
- }
- private float[] min(float[] v1, float[] v2) {
- assert v1.length == v2.length;
- float[] rv = new float[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
- private byte min(byte v1, byte v2) {
- return v1 < v2 ? v1 : v2;
- }
- private byte[] min(byte[] v1, byte[] v2) {
- assert v1.length == v2.length;
- byte[] rv = new byte[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
- private short min(short v1, short v2) {
- return v1 < v2 ? v1 : v2;
- }
- private short[] min(short[] v1, short[] v2) {
- assert v1.length == v2.length;
- short[] rv = new short[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
- private int min(int v1, int v2) {
- return v1 < v2 ? v1 : v2;
- }
- private int[] min(int[] v1, int[] v2) {
- assert v1.length == v2.length;
- int[] rv = new int[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
- private long min(long v1, long v2) {
- return v1 < v2 ? v1 : v2;
- }
- private long[] min(long[] v1, long[] v2) {
- assert v1.length == v2.length;
- long[] rv = new long[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2[i]);
- return rv;
- }
- // TODO: unsigned long version of min
-
- // max reference functions
- private float max(float v1, float v2) {
- return v1 > v2 ? v1 : v2;
- }
- private float[] max(float[] v1, float[] v2) {
- assert v1.length == v2.length;
- float[] rv = new float[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2[i]);
- return rv;
- }
- private byte max(byte v1, byte v2) {
- return v1 > v2 ? v1 : v2;
- }
- private byte[] max(byte[] v1, byte[] v2) {
- assert v1.length == v2.length;
- byte[] rv = new byte[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2[i]);
- return rv;
- }
- private short max(short v1, short v2) {
- return v1 > v2 ? v1 : v2;
- }
- private short[] max(short[] v1, short[] v2) {
- assert v1.length == v2.length;
- short[] rv = new short[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2[i]);
- return rv;
- }
- private int max(int v1, int v2) {
- return v1 > v2 ? v1 : v2;
- }
- private int[] max(int[] v1, int[] v2) {
- assert v1.length == v2.length;
- int[] rv = new int[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2[i]);
- return rv;
- }
- private long max(long v1, long v2) {
- return v1 > v2 ? v1 : v2;
- }
- private long[] max(long[] v1, long[] v2) {
- assert v1.length == v2.length;
- long[] rv = new long[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2[i]);
- return rv;
- }
- // TODO: unsigned long version of max
-
- // fmin reference functions
- private float fmin(float v1, float v2) {
- return min(v1, v2);
- }
- private float[] fmin(float[] v1, float[] v2) {
- return min(v1, v2);
- }
- private float[] fmin(float[] v1, float v2) {
- float[] rv = new float[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = min(v1[i], v2);
- return rv;
- }
-
- // fmax reference functions
- private float fmax(float v1, float v2) {
- return max(v1, v2);
- }
- private float[] fmax(float[] v1, float[] v2) {
- return max(v1, v2);
- }
- private float[] fmax(float[] v1, float v2) {
- float[] rv = new float[v1.length];
- for (int i = 0; i < v1.length; ++i)
- rv[i] = max(v1[i], v2);
- return rv;
- }
-
- private void initializeValues(ScriptC_math_agree s) {
- float x = rand.nextFloat();
- float y = rand.nextFloat();
-
- s.set_x(x);
- s.set_y(y);
- s.set_result_add(x + y);
- s.set_result_sub(x - y);
- s.set_result_mul(x * y);
- s.set_result_div(x / y);
-
- // Generate random vectors of all types
- float rand_f1_0 = rand.nextFloat();
- float[] rand_f2_0 = randvec_float(2);
- float[] rand_f3_0 = randvec_float(3);
- float[] rand_f4_0 = randvec_float(4);
- float rand_f1_1 = rand.nextFloat();
- float[] rand_f2_1 = randvec_float(2);
- float[] rand_f3_1 = randvec_float(3);
- float[] rand_f4_1 = randvec_float(4);
- short rand_uc1_0 = (short)rand.nextInt(0x1 << 8);
- short[] rand_uc2_0 = randvec_uchar(2);
- short[] rand_uc3_0 = randvec_uchar(3);
- short[] rand_uc4_0 = randvec_uchar(4);
- short rand_uc1_1 = (short)rand.nextInt(0x1 << 8);
- short[] rand_uc2_1 = randvec_uchar(2);
- short[] rand_uc3_1 = randvec_uchar(3);
- short[] rand_uc4_1 = randvec_uchar(4);
- short rand_ss1_0 = (short)rand.nextInt(0x1 << 16);
- short[] rand_ss2_0 = randvec_short(2);
- short[] rand_ss3_0 = randvec_short(3);
- short[] rand_ss4_0 = randvec_short(4);
- short rand_ss1_1 = (short)rand.nextInt(0x1 << 16);
- short[] rand_ss2_1 = randvec_short(2);
- short[] rand_ss3_1 = randvec_short(3);
- short[] rand_ss4_1 = randvec_short(4);
- int rand_us1_0 = rand.nextInt(0x1 << 16);
- int[] rand_us2_0 = randvec_ushort(2);
- int[] rand_us3_0 = randvec_ushort(3);
- int[] rand_us4_0 = randvec_ushort(4);
- int rand_us1_1 = rand.nextInt(0x1 << 16);
- int[] rand_us2_1 = randvec_ushort(2);
- int[] rand_us3_1 = randvec_ushort(3);
- int[] rand_us4_1 = randvec_ushort(4);
- int rand_si1_0 = rand.nextInt();
- int[] rand_si2_0 = randvec_int(2);
- int[] rand_si3_0 = randvec_int(3);
- int[] rand_si4_0 = randvec_int(4);
- int rand_si1_1 = rand.nextInt();
- int[] rand_si2_1 = randvec_int(2);
- int[] rand_si3_1 = randvec_int(3);
- int[] rand_si4_1 = randvec_int(4);
- long rand_ui1_0 = (long)rand.nextInt() - (long)Integer.MIN_VALUE;
- long[] rand_ui2_0 = randvec_uint(2);
- long[] rand_ui3_0 = randvec_uint(3);
- long[] rand_ui4_0 = randvec_uint(4);
- long rand_ui1_1 = (long)rand.nextInt() - (long)Integer.MIN_VALUE;
- long[] rand_ui2_1 = randvec_uint(2);
- long[] rand_ui3_1 = randvec_uint(3);
- long[] rand_ui4_1 = randvec_uint(4);
- long rand_sl1_0 = rand.nextLong();
- long[] rand_sl2_0 = randvec_long(2);
- long[] rand_sl3_0 = randvec_long(3);
- long[] rand_sl4_0 = randvec_long(4);
- long rand_sl1_1 = rand.nextLong();
- long[] rand_sl2_1 = randvec_long(2);
- long[] rand_sl3_1 = randvec_long(3);
- long[] rand_sl4_1 = randvec_long(4);
- byte rand_sc1_0 = (byte)rand.nextInt(0x1 << 8);
- byte[] rand_sc2_0 = randvec_char(2);
- byte[] rand_sc3_0 = randvec_char(3);
- byte[] rand_sc4_0 = randvec_char(4);
- byte rand_sc1_1 = (byte)rand.nextInt(0x1 << 8);
- byte[] rand_sc2_1 = randvec_char(2);
- byte[] rand_sc3_1 = randvec_char(3);
- byte[] rand_sc4_1 = randvec_char(4);
- // TODO: generate unsigned long vectors
-
- // Set random vectors in renderscript code
- s.set_rand_f1_0(rand_f1_0);
- s.set_rand_f2_0(pack_f2(rand_f2_0));
- s.set_rand_f3_0(pack_f3(rand_f3_0));
- s.set_rand_f4_0(pack_f4(rand_f4_0));
- s.set_rand_f1_1(rand_f1_1);
- s.set_rand_f2_1(pack_f2(rand_f2_1));
- s.set_rand_f3_1(pack_f3(rand_f3_1));
- s.set_rand_f4_1(pack_f4(rand_f4_1));
- s.set_rand_uc1_1(rand_uc1_1);
- s.set_rand_uc2_1(pack_s2(rand_uc2_1));
- s.set_rand_uc3_1(pack_s3(rand_uc3_1));
- s.set_rand_uc4_1(pack_s4(rand_uc4_1));
- s.set_rand_ss1_0(rand_ss1_0);
- s.set_rand_ss2_0(pack_s2(rand_ss2_0));
- s.set_rand_ss3_0(pack_s3(rand_ss3_0));
- s.set_rand_ss4_0(pack_s4(rand_ss4_0));
- s.set_rand_ss1_1(rand_ss1_1);
- s.set_rand_ss2_1(pack_s2(rand_ss2_1));
- s.set_rand_ss3_1(pack_s3(rand_ss3_1));
- s.set_rand_ss4_1(pack_s4(rand_ss4_1));
- s.set_rand_us1_0(rand_us1_0);
- s.set_rand_us2_0(pack_i2(rand_us2_0));
- s.set_rand_us3_0(pack_i3(rand_us3_0));
- s.set_rand_us4_0(pack_i4(rand_us4_0));
- s.set_rand_us1_1(rand_us1_1);
- s.set_rand_us2_1(pack_i2(rand_us2_1));
- s.set_rand_us3_1(pack_i3(rand_us3_1));
- s.set_rand_us4_1(pack_i4(rand_us4_1));
- s.set_rand_si1_0(rand_si1_0);
- s.set_rand_si2_0(pack_i2(rand_si2_0));
- s.set_rand_si3_0(pack_i3(rand_si3_0));
- s.set_rand_si4_0(pack_i4(rand_si4_0));
- s.set_rand_si1_1(rand_si1_1);
- s.set_rand_si2_1(pack_i2(rand_si2_1));
- s.set_rand_si3_1(pack_i3(rand_si3_1));
- s.set_rand_si4_1(pack_i4(rand_si4_1));
- s.set_rand_ui1_0(rand_ui1_0);
- s.set_rand_ui2_0(pack_l2(rand_ui2_0));
- s.set_rand_ui3_0(pack_l3(rand_ui3_0));
- s.set_rand_ui4_0(pack_l4(rand_ui4_0));
- s.set_rand_ui1_1(rand_ui1_1);
- s.set_rand_ui2_1(pack_l2(rand_ui2_1));
- s.set_rand_ui3_1(pack_l3(rand_ui3_1));
- s.set_rand_ui4_1(pack_l4(rand_ui4_1));
- s.set_rand_sl1_0(rand_sl1_0);
- s.set_rand_sl2_0(pack_l2(rand_sl2_0));
- s.set_rand_sl3_0(pack_l3(rand_sl3_0));
- s.set_rand_sl4_0(pack_l4(rand_sl4_0));
- s.set_rand_sl1_1(rand_sl1_1);
- s.set_rand_sl2_1(pack_l2(rand_sl2_1));
- s.set_rand_sl3_1(pack_l3(rand_sl3_1));
- s.set_rand_sl4_1(pack_l4(rand_sl4_1));
- s.set_rand_uc1_0(rand_uc1_0);
- s.set_rand_uc2_0(pack_s2(rand_uc2_0));
- s.set_rand_uc3_0(pack_s3(rand_uc3_0));
- s.set_rand_uc4_0(pack_s4(rand_uc4_0));
- s.set_rand_sc1_0(rand_sc1_0);
- s.set_rand_sc2_0(pack_b2(rand_sc2_0));
- s.set_rand_sc3_0(pack_b3(rand_sc3_0));
- s.set_rand_sc4_0(pack_b4(rand_sc4_0));
- s.set_rand_sc1_1(rand_sc1_1);
- s.set_rand_sc2_1(pack_b2(rand_sc2_1));
- s.set_rand_sc3_1(pack_b3(rand_sc3_1));
- s.set_rand_sc4_1(pack_b4(rand_sc4_1));
- // TODO: set unsigned long vectors
-
- // Set results for min
- s.set_min_rand_f1_f1(min(rand_f1_0, rand_f1_1));
- s.set_min_rand_f2_f2(pack_f2(min(rand_f2_0, rand_f2_1)));
- s.set_min_rand_f3_f3(pack_f3(min(rand_f3_0, rand_f3_1)));
- s.set_min_rand_f4_f4(pack_f4(min(rand_f4_0, rand_f4_1)));
- s.set_min_rand_uc1_uc1(min(rand_uc1_0, rand_uc1_1));
- s.set_min_rand_uc2_uc2(pack_s2(min(rand_uc2_0, rand_uc2_1)));
- s.set_min_rand_uc3_uc3(pack_s3(min(rand_uc3_0, rand_uc3_1)));
- s.set_min_rand_uc4_uc4(pack_s4(min(rand_uc4_0, rand_uc4_1)));
- s.set_min_rand_ss1_ss1(min(rand_ss1_0, rand_ss1_1));
- s.set_min_rand_ss2_ss2(pack_s2(min(rand_ss2_0, rand_ss2_1)));
- s.set_min_rand_ss3_ss3(pack_s3(min(rand_ss3_0, rand_ss3_1)));
- s.set_min_rand_ss4_ss4(pack_s4(min(rand_ss4_0, rand_ss4_1)));
- s.set_min_rand_us1_us1(min(rand_us1_0, rand_us1_1));
- s.set_min_rand_us2_us2(pack_i2(min(rand_us2_0, rand_us2_1)));
- s.set_min_rand_us3_us3(pack_i3(min(rand_us3_0, rand_us3_1)));
- s.set_min_rand_us4_us4(pack_i4(min(rand_us4_0, rand_us4_1)));
- s.set_min_rand_si1_si1(min(rand_si1_0, rand_si1_1));
- s.set_min_rand_si2_si2(pack_i2(min(rand_si2_0, rand_si2_1)));
- s.set_min_rand_si3_si3(pack_i3(min(rand_si3_0, rand_si3_1)));
- s.set_min_rand_si4_si4(pack_i4(min(rand_si4_0, rand_si4_1)));
- s.set_min_rand_ui1_ui1(min(rand_ui1_0, rand_ui1_1));
- s.set_min_rand_ui2_ui2(pack_l2(min(rand_ui2_0, rand_ui2_1)));
- s.set_min_rand_ui3_ui3(pack_l3(min(rand_ui3_0, rand_ui3_1)));
- s.set_min_rand_ui4_ui4(pack_l4(min(rand_ui4_0, rand_ui4_1)));
- s.set_min_rand_sl1_sl1(min(rand_sl1_0, rand_sl1_1));
- s.set_min_rand_sl2_sl2(pack_l2(min(rand_sl2_0, rand_sl2_1)));
- s.set_min_rand_sl3_sl3(pack_l3(min(rand_sl3_0, rand_sl3_1)));
- s.set_min_rand_sl4_sl4(pack_l4(min(rand_sl4_0, rand_sl4_1)));
- s.set_min_rand_sc1_sc1(min(rand_sc1_0, rand_sc1_1));
- s.set_min_rand_sc2_sc2(pack_b2(min(rand_sc2_0, rand_sc2_1)));
- s.set_min_rand_sc3_sc3(pack_b3(min(rand_sc3_0, rand_sc3_1)));
- s.set_min_rand_sc4_sc4(pack_b4(min(rand_sc4_0, rand_sc4_1)));
- // TODO: set results for unsigned long min
-
- // Set results for max
- s.set_max_rand_f1_f1(max(rand_f1_0, rand_f1_1));
- s.set_max_rand_f2_f2(pack_f2(max(rand_f2_0, rand_f2_1)));
- s.set_max_rand_f3_f3(pack_f3(max(rand_f3_0, rand_f3_1)));
- s.set_max_rand_f4_f4(pack_f4(max(rand_f4_0, rand_f4_1)));
- s.set_max_rand_uc1_uc1(max(rand_uc1_0, rand_uc1_1));
- s.set_max_rand_uc2_uc2(pack_s2(max(rand_uc2_0, rand_uc2_1)));
- s.set_max_rand_uc3_uc3(pack_s3(max(rand_uc3_0, rand_uc3_1)));
- s.set_max_rand_uc4_uc4(pack_s4(max(rand_uc4_0, rand_uc4_1)));
- s.set_max_rand_ss1_ss1(max(rand_ss1_0, rand_ss1_1));
- s.set_max_rand_ss2_ss2(pack_s2(max(rand_ss2_0, rand_ss2_1)));
- s.set_max_rand_ss3_ss3(pack_s3(max(rand_ss3_0, rand_ss3_1)));
- s.set_max_rand_ss4_ss4(pack_s4(max(rand_ss4_0, rand_ss4_1)));
- s.set_max_rand_us1_us1(max(rand_us1_0, rand_us1_1));
- s.set_max_rand_us2_us2(pack_i2(max(rand_us2_0, rand_us2_1)));
- s.set_max_rand_us3_us3(pack_i3(max(rand_us3_0, rand_us3_1)));
- s.set_max_rand_us4_us4(pack_i4(max(rand_us4_0, rand_us4_1)));
- s.set_max_rand_si1_si1(max(rand_si1_0, rand_si1_1));
- s.set_max_rand_si2_si2(pack_i2(max(rand_si2_0, rand_si2_1)));
- s.set_max_rand_si3_si3(pack_i3(max(rand_si3_0, rand_si3_1)));
- s.set_max_rand_si4_si4(pack_i4(max(rand_si4_0, rand_si4_1)));
- s.set_max_rand_ui1_ui1(max(rand_ui1_0, rand_ui1_1));
- s.set_max_rand_ui2_ui2(pack_l2(max(rand_ui2_0, rand_ui2_1)));
- s.set_max_rand_ui3_ui3(pack_l3(max(rand_ui3_0, rand_ui3_1)));
- s.set_max_rand_ui4_ui4(pack_l4(max(rand_ui4_0, rand_ui4_1)));
- s.set_max_rand_sl1_sl1(max(rand_sl1_0, rand_sl1_1));
- s.set_max_rand_sl2_sl2(pack_l2(max(rand_sl2_0, rand_sl2_1)));
- s.set_max_rand_sl3_sl3(pack_l3(max(rand_sl3_0, rand_sl3_1)));
- s.set_max_rand_sl4_sl4(pack_l4(max(rand_sl4_0, rand_sl4_1)));
- s.set_max_rand_sc1_sc1(max(rand_sc1_0, rand_sc1_1));
- s.set_max_rand_sc2_sc2(pack_b2(max(rand_sc2_0, rand_sc2_1)));
- s.set_max_rand_sc3_sc3(pack_b3(max(rand_sc3_0, rand_sc3_1)));
- s.set_max_rand_sc4_sc4(pack_b4(max(rand_sc4_0, rand_sc4_1)));
-
- // TODO: set results for unsigned long max
-
- // Set results for fmin
- s.set_fmin_rand_f1_f1(fmin(rand_f1_0, rand_f1_1));
- s.set_fmin_rand_f2_f2(pack_f2(fmin(rand_f2_0, rand_f2_1)));
- s.set_fmin_rand_f3_f3(pack_f3(fmin(rand_f3_0, rand_f3_1)));
- s.set_fmin_rand_f4_f4(pack_f4(fmin(rand_f4_0, rand_f4_1)));
- s.set_fmin_rand_f2_f1(pack_f2(fmin(rand_f2_0, rand_f1_1)));
- s.set_fmin_rand_f3_f1(pack_f3(fmin(rand_f3_0, rand_f1_1)));
- s.set_fmin_rand_f4_f1(pack_f4(fmin(rand_f4_0, rand_f1_1)));
-
- // Set results for fmax
- s.set_fmax_rand_f1_f1(fmax(rand_f1_0, rand_f1_1));
- s.set_fmax_rand_f2_f2(pack_f2(fmax(rand_f2_0, rand_f2_1)));
- s.set_fmax_rand_f3_f3(pack_f3(fmax(rand_f3_0, rand_f3_1)));
- s.set_fmax_rand_f4_f4(pack_f4(fmax(rand_f4_0, rand_f4_1)));
- s.set_fmax_rand_f2_f1(pack_f2(fmax(rand_f2_0, rand_f1_1)));
- s.set_fmax_rand_f3_f1(pack_f3(fmax(rand_f3_0, rand_f1_1)));
- s.set_fmax_rand_f4_f1(pack_f4(fmax(rand_f4_0, rand_f1_1)));
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_math_agree s = new ScriptC_math_agree(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeValues(s);
- s.invoke_math_agree_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_conformance.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_conformance.java
deleted file mode 100644
index 620eeb5..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_conformance.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_math_conformance extends UnitTest {
- private Resources mRes;
-
- protected UT_math_conformance(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Math Conformance", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_math_conformance s =
- new ScriptC_math_conformance(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_math_conformance_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- passTest();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_mesh.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_mesh.java
deleted file mode 100644
index 29e5025..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_mesh.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.Mesh.*;
-
-public class UT_mesh extends UnitTest {
- private Resources mRes;
-
- Mesh mesh;
-
- protected UT_mesh(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Mesh", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_mesh s) {
- Allocation vAlloc0 = Allocation.createSized(RS, Element.F32(RS), 10);
- Allocation vAlloc1 = Allocation.createSized(RS, Element.F32_2(RS), 10);
-
- Allocation iAlloc0 = Allocation.createSized(RS, Element.I16(RS), 10);
- Allocation iAlloc2 = Allocation.createSized(RS, Element.I16(RS), 10);
-
- Mesh.AllocationBuilder mBuilder = new Mesh.AllocationBuilder(RS);
- mBuilder.addVertexAllocation(vAlloc0);
- mBuilder.addVertexAllocation(vAlloc1);
-
- mBuilder.addIndexSetAllocation(iAlloc0, Primitive.POINT);
- mBuilder.addIndexSetType(Primitive.LINE);
- mBuilder.addIndexSetAllocation(iAlloc2, Primitive.TRIANGLE);
-
- s.set_mesh(mBuilder.create());
- s.set_vertexAlloc0(vAlloc0);
- s.set_vertexAlloc1(vAlloc1);
- s.set_indexAlloc0(iAlloc0);
- s.set_indexAlloc2(iAlloc2);
- }
-
- private void testScriptSide(RenderScript pRS) {
- ScriptC_mesh s = new ScriptC_mesh(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.invoke_mesh_test();
- pRS.finish();
- waitForMessage();
- }
-
- private void testJavaSide(RenderScript RS) {
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- testScriptSide(pRS);
- testJavaSide(pRS);
- passTest();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_min.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_min.java
deleted file mode 100644
index 137cae9..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_min.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_min extends UnitTest {
- private Resources mRes;
-
- protected UT_min(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Min (relaxed)", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_min s = new ScriptC_min(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_min_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_noroot.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_noroot.java
deleted file mode 100644
index 69526a8..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_noroot.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_noroot extends UnitTest {
- private Resources mRes;
- private Allocation A;
-
- protected UT_noroot(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "ForEach (no root)", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_noroot s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- int Y = 7;
- s.set_dimX(X);
- s.set_dimY(Y);
- typeBuilder.setX(X).setY(Y);
- A = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aRaw(A);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_noroot s = new ScriptC_noroot(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_foo(A, A);
- s.invoke_verify_foo();
- s.invoke_noroot_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_primitives.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_primitives.java
deleted file mode 100644
index c1234f0..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_primitives.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_primitives extends UnitTest {
- private Resources mRes;
-
- protected UT_primitives(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Primitives", ctx);
- mRes = res;
- }
-
- private boolean initializeGlobals(ScriptC_primitives s) {
- float pF = s.get_floatTest();
- if (pF != 1.99f) {
- return false;
- }
- s.set_floatTest(2.99f);
-
- double pD = s.get_doubleTest();
- if (pD != 2.05) {
- return false;
- }
- s.set_doubleTest(3.05);
-
- byte pC = s.get_charTest();
- if (pC != -8) {
- return false;
- }
- s.set_charTest((byte)-16);
-
- short pS = s.get_shortTest();
- if (pS != -16) {
- return false;
- }
- s.set_shortTest((short)-32);
-
- int pI = s.get_intTest();
- if (pI != -32) {
- return false;
- }
- s.set_intTest(-64);
-
- long pL = s.get_longTest();
- if (pL != 17179869184l) {
- return false;
- }
- s.set_longTest(17179869185l);
-
- long puL = s.get_ulongTest();
- if (puL != 4611686018427387904L) {
- return false;
- }
- s.set_ulongTest(4611686018427387903L);
-
-
- long pLL = s.get_longlongTest();
- if (pLL != 68719476736L) {
- return false;
- }
- s.set_longlongTest(68719476735L);
-
- long pu64 = s.get_uint64_tTest();
- if (pu64 != 117179869184l) {
- return false;
- }
- s.set_uint64_tTest(117179869185l);
-
- return true;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_primitives s = new ScriptC_primitives(pRS);
- pRS.setMessageHandler(mRsMessage);
- if (!initializeGlobals(s)) {
- failTest();
- } else {
- s.invoke_primitives_test(0, 0);
- pRS.finish();
- waitForMessage();
- }
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_raster.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_raster.java
deleted file mode 100644
index 046a215..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_raster.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.ProgramRaster;
-import android.renderscript.ProgramRaster.CullMode;
-
-public class UT_program_raster extends UnitTest {
- private Resources mRes;
-
- ProgramRaster pointSpriteEnabled;
- ProgramRaster cullMode;
-
- protected UT_program_raster(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "ProgramRaster", ctx);
- mRes = res;
- }
-
- private ProgramRaster.Builder getDefaultBuilder(RenderScript RS) {
- ProgramRaster.Builder b = new ProgramRaster.Builder(RS);
- b.setCullMode(CullMode.BACK);
- b.setPointSpriteEnabled(false);
- return b;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_program_raster s) {
- ProgramRaster.Builder b = getDefaultBuilder(RS);
- pointSpriteEnabled = b.setPointSpriteEnabled(true).create();
- b = getDefaultBuilder(RS);
- cullMode = b.setCullMode(CullMode.FRONT).create();
-
- s.set_pointSpriteEnabled(pointSpriteEnabled);
- s.set_cullMode(cullMode);
- }
-
- private void testScriptSide(RenderScript pRS) {
- ScriptC_program_raster s = new ScriptC_program_raster(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.invoke_program_raster_test();
- pRS.finish();
- waitForMessage();
- }
-
- private void testJavaSide(RenderScript RS) {
- _RS_ASSERT("pointSpriteEnabled.isPointSpriteEnabled() == true",
- pointSpriteEnabled.isPointSpriteEnabled() == true);
- _RS_ASSERT("pointSpriteEnabled.getCullMode() == ProgramRaster.CullMode.BACK",
- pointSpriteEnabled.getCullMode() == ProgramRaster.CullMode.BACK);
-
- _RS_ASSERT("cullMode.isPointSpriteEnabled() == false",
- cullMode.isPointSpriteEnabled() == false);
- _RS_ASSERT("cullMode.getCullMode() == ProgramRaster.CullMode.FRONT",
- cullMode.getCullMode() == ProgramRaster.CullMode.FRONT);
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- testScriptSide(pRS);
- testJavaSide(pRS);
- passTest();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_store.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_store.java
deleted file mode 100644
index 6510b6b..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_program_store.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.ProgramStore.BlendDstFunc;
-import android.renderscript.ProgramStore.BlendSrcFunc;
-import android.renderscript.ProgramStore.Builder;
-import android.renderscript.ProgramStore.DepthFunc;
-
-public class UT_program_store extends UnitTest {
- private Resources mRes;
-
- ProgramStore ditherEnable;
- ProgramStore colorRWriteEnable;
- ProgramStore colorGWriteEnable;
- ProgramStore colorBWriteEnable;
- ProgramStore colorAWriteEnable;
- ProgramStore blendSrc;
- ProgramStore blendDst;
- ProgramStore depthWriteEnable;
- ProgramStore depthFunc;
-
- protected UT_program_store(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "ProgramStore", ctx);
- mRes = res;
- }
-
- private ProgramStore.Builder getDefaultBuilder(RenderScript RS) {
- ProgramStore.Builder b = new ProgramStore.Builder(RS);
- b.setBlendFunc(ProgramStore.BlendSrcFunc.ZERO, ProgramStore.BlendDstFunc.ZERO);
- b.setColorMaskEnabled(false, false, false, false);
- b.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
- b.setDepthMaskEnabled(false);
- b.setDitherEnabled(false);
- return b;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_program_store s) {
- ProgramStore.Builder b = getDefaultBuilder(RS);
- ditherEnable = b.setDitherEnabled(true).create();
-
- b = getDefaultBuilder(RS);
- colorRWriteEnable = b.setColorMaskEnabled(true, false, false, false).create();
-
- b = getDefaultBuilder(RS);
- colorGWriteEnable = b.setColorMaskEnabled(false, true, false, false).create();
-
- b = getDefaultBuilder(RS);
- colorBWriteEnable = b.setColorMaskEnabled(false, false, true, false).create();
-
- b = getDefaultBuilder(RS);
- colorAWriteEnable = b.setColorMaskEnabled(false, false, false, true).create();
-
- b = getDefaultBuilder(RS);
- blendSrc = b.setBlendFunc(ProgramStore.BlendSrcFunc.DST_COLOR,
- ProgramStore.BlendDstFunc.ZERO).create();
-
- b = getDefaultBuilder(RS);
- blendDst = b.setBlendFunc(ProgramStore.BlendSrcFunc.ZERO,
- ProgramStore.BlendDstFunc.DST_ALPHA).create();
-
- b = getDefaultBuilder(RS);
- depthWriteEnable = b.setDepthMaskEnabled(true).create();
-
- b = getDefaultBuilder(RS);
- depthFunc = b.setDepthFunc(ProgramStore.DepthFunc.GREATER).create();
-
- s.set_ditherEnable(ditherEnable);
- s.set_colorRWriteEnable(colorRWriteEnable);
- s.set_colorGWriteEnable(colorGWriteEnable);
- s.set_colorBWriteEnable(colorBWriteEnable);
- s.set_colorAWriteEnable(colorAWriteEnable);
- s.set_blendSrc(blendSrc);
- s.set_blendDst(blendDst);
- s.set_depthWriteEnable(depthWriteEnable);
- s.set_depthFunc(depthFunc);
- }
-
- private void testScriptSide(RenderScript pRS) {
- ScriptC_program_store s = new ScriptC_program_store(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.invoke_program_store_test();
- pRS.finish();
- waitForMessage();
- }
-
- void checkObject(ProgramStore ps,
- boolean depthMask,
- DepthFunc df,
- BlendSrcFunc bsf,
- BlendDstFunc bdf,
- boolean R,
- boolean G,
- boolean B,
- boolean A,
- boolean dither) {
- _RS_ASSERT("ps.isDepthMaskEnabled() == depthMask", ps.isDepthMaskEnabled() == depthMask);
- _RS_ASSERT("ps.getDepthFunc() == df", ps.getDepthFunc() == df);
- _RS_ASSERT("ps.getBlendSrcFunc() == bsf", ps.getBlendSrcFunc() == bsf);
- _RS_ASSERT("ps.getBlendDstFunc() == bdf", ps.getBlendDstFunc() == bdf);
- _RS_ASSERT("ps.isColorMaskRedEnabled() == R", ps.isColorMaskRedEnabled() == R);
- _RS_ASSERT("ps.isColorMaskGreenEnabled() == G", ps.isColorMaskGreenEnabled() == G);
- _RS_ASSERT("ps.isColorMaskBlueEnabled () == B", ps.isColorMaskBlueEnabled () == B);
- _RS_ASSERT("ps.isColorMaskAlphaEnabled() == A", ps.isColorMaskAlphaEnabled() == A);
- _RS_ASSERT("ps.isDitherEnabled() == dither", ps.isDitherEnabled() == dither);
- }
-
- void varyBuilderColorAndDither(ProgramStore.Builder pb,
- boolean depthMask,
- DepthFunc df,
- BlendSrcFunc bsf,
- BlendDstFunc bdf) {
- for (int r = 0; r <= 1; r++) {
- boolean isR = (r == 1);
- for (int g = 0; g <= 1; g++) {
- boolean isG = (g == 1);
- for (int b = 0; b <= 1; b++) {
- boolean isB = (b == 1);
- for (int a = 0; a <= 1; a++) {
- boolean isA = (a == 1);
- for (int dither = 0; dither <= 1; dither++) {
- boolean isDither = (dither == 1);
- pb.setDitherEnabled(isDither);
- pb.setColorMaskEnabled(isR, isG, isB, isA);
- ProgramStore ps = pb.create();
- checkObject(ps, depthMask, df, bsf, bdf, isR, isG, isB, isA, isDither);
- }
- }
- }
- }
- }
- }
-
- public void testJavaSide(RenderScript RS) {
- for (int depth = 0; depth <= 1; depth++) {
- boolean depthMask = (depth == 1);
- for (DepthFunc df : DepthFunc.values()) {
- for (BlendSrcFunc bsf : BlendSrcFunc.values()) {
- for (BlendDstFunc bdf : BlendDstFunc.values()) {
- ProgramStore.Builder b = new ProgramStore.Builder(RS);
- b.setDepthFunc(df);
- b.setDepthMaskEnabled(depthMask);
- b.setBlendFunc(bsf, bdf);
- varyBuilderColorAndDither(b, depthMask, df, bsf, bdf);
- }
- }
- }
- }
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- testJavaSide(pRS);
- testScriptSide(pRS);
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_refcount.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_refcount.java
deleted file mode 100644
index 22bbd2f..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_refcount.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_refcount extends UnitTest {
- private Resources mRes;
-
- protected UT_refcount(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Refcount", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_refcount s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 500;
- int Y = 700;
- typeBuilder.setX(X).setY(Y);
- Allocation A = Allocation.createTyped(RS, typeBuilder.create());
- s.set_globalA(A);
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- pRS.setMessageHandler(mRsMessage);
- ScriptC_refcount s = new ScriptC_refcount(pRS);
- initializeGlobals(pRS, s);
- s.invoke_refcount_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_rsdebug.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_rsdebug.java
deleted file mode 100644
index 548288b..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_rsdebug.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_rsdebug extends UnitTest {
- private Resources mRes;
-
- protected UT_rsdebug(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsDebug", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rsdebug s = new ScriptC_rsdebug(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_test_rsdebug(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_rstime.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_rstime.java
deleted file mode 100644
index f000412..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_rstime.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_rstime extends UnitTest {
- private Resources mRes;
-
- protected UT_rstime(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsTime", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rstime s = new ScriptC_rstime(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.setTimeZone("America/Los_Angeles");
- s.invoke_test_rstime(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_rstypes.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_rstypes.java
deleted file mode 100644
index f677f10..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_rstypes.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_rstypes extends UnitTest {
- private Resources mRes;
-
- protected UT_rstypes(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsTypes", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rstypes s = new ScriptC_rstypes(pRS);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_test_rstypes(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_sampler.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_sampler.java
deleted file mode 100644
index 00c850c..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_sampler.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.Sampler;
-import android.renderscript.Sampler.Value;
-
-public class UT_sampler extends UnitTest {
- private Resources mRes;
-
- Sampler minification;
- Sampler magnification;
- Sampler wrapS;
- Sampler wrapT;
- Sampler anisotropy;
-
- protected UT_sampler(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Sampler", ctx);
- mRes = res;
- }
-
- private Sampler.Builder getDefaultBuilder(RenderScript RS) {
- Sampler.Builder b = new Sampler.Builder(RS);
- b.setMinification(Value.NEAREST);
- b.setMagnification(Value.NEAREST);
- b.setWrapS(Value.CLAMP);
- b.setWrapT(Value.CLAMP);
- b.setAnisotropy(1.0f);
- return b;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_sampler s) {
- Sampler.Builder b = getDefaultBuilder(RS);
- b.setMinification(Value.LINEAR_MIP_LINEAR);
- minification = b.create();
-
- b = getDefaultBuilder(RS);
- b.setMagnification(Value.LINEAR);
- magnification = b.create();
-
- b = getDefaultBuilder(RS);
- b.setWrapS(Value.WRAP);
- wrapS = b.create();
-
- b = getDefaultBuilder(RS);
- b.setWrapT(Value.WRAP);
- wrapT = b.create();
-
- b = getDefaultBuilder(RS);
- b.setAnisotropy(8.0f);
- anisotropy = b.create();
-
- s.set_minification(minification);
- s.set_magnification(magnification);
- s.set_wrapS(wrapS);
- s.set_wrapT(wrapT);
- s.set_anisotropy(anisotropy);
- }
-
- private void testScriptSide(RenderScript pRS) {
- ScriptC_sampler s = new ScriptC_sampler(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.invoke_sampler_test();
- pRS.finish();
- waitForMessage();
- }
-
- private void testJavaSide(RenderScript RS) {
- _RS_ASSERT("minification.getMagnification() == Sampler.Value.NEAREST",
- minification.getMagnification() == Sampler.Value.NEAREST);
- _RS_ASSERT("minification.getMinification() == Sampler.Value.LINEAR_MIP_LINEAR",
- minification.getMinification() == Sampler.Value.LINEAR_MIP_LINEAR);
- _RS_ASSERT("minification.getWrapS() == Sampler.Value.CLAMP",
- minification.getWrapS() == Sampler.Value.CLAMP);
- _RS_ASSERT("minification.getWrapT() == Sampler.Value.CLAMP",
- minification.getWrapT() == Sampler.Value.CLAMP);
- _RS_ASSERT("minification.getAnisotropy() == 1.0f",
- minification.getAnisotropy() == 1.0f);
-
- _RS_ASSERT("magnification.getMagnification() == Sampler.Value.LINEAR",
- magnification.getMagnification() == Sampler.Value.LINEAR);
- _RS_ASSERT("magnification.getMinification() == Sampler.Value.NEAREST",
- magnification.getMinification() == Sampler.Value.NEAREST);
- _RS_ASSERT("magnification.getWrapS() == Sampler.Value.CLAMP",
- magnification.getWrapS() == Sampler.Value.CLAMP);
- _RS_ASSERT("magnification.getWrapT() == Sampler.Value.CLAMP",
- magnification.getWrapT() == Sampler.Value.CLAMP);
- _RS_ASSERT("magnification.getAnisotropy() == 1.0f",
- magnification.getAnisotropy() == 1.0f);
-
- _RS_ASSERT("wrapS.getMagnification() == Sampler.Value.NEAREST",
- wrapS.getMagnification() == Sampler.Value.NEAREST);
- _RS_ASSERT("wrapS.getMinification() == Sampler.Value.NEAREST",
- wrapS.getMinification() == Sampler.Value.NEAREST);
- _RS_ASSERT("wrapS.getWrapS() == Sampler.Value.WRAP",
- wrapS.getWrapS() == Sampler.Value.WRAP);
- _RS_ASSERT("wrapS.getWrapT() == Sampler.Value.CLAMP",
- wrapS.getWrapT() == Sampler.Value.CLAMP);
- _RS_ASSERT("wrapS.getAnisotropy() == 1.0f",
- wrapS.getAnisotropy() == 1.0f);
-
- _RS_ASSERT("wrapT.getMagnification() == Sampler.Value.NEAREST",
- wrapT.getMagnification() == Sampler.Value.NEAREST);
- _RS_ASSERT("wrapT.getMinification() == Sampler.Value.NEAREST",
- wrapT.getMinification() == Sampler.Value.NEAREST);
- _RS_ASSERT("wrapT.getWrapS() == Sampler.Value.CLAMP",
- wrapT.getWrapS() == Sampler.Value.CLAMP);
- _RS_ASSERT("wrapT.getWrapT() == Sampler.Value.WRAP",
- wrapT.getWrapT() == Sampler.Value.WRAP);
- _RS_ASSERT("wrapT.getAnisotropy() == 1.0f",
- wrapT.getAnisotropy() == 1.0f);
-
- _RS_ASSERT("anisotropy.getMagnification() == Sampler.Value.NEAREST",
- anisotropy.getMagnification() == Sampler.Value.NEAREST);
- _RS_ASSERT("anisotropy.getMinification() == Sampler.Value.NEAREST",
- anisotropy.getMinification() == Sampler.Value.NEAREST);
- _RS_ASSERT("anisotropy.getWrapS() == Sampler.Value.CLAMP",
- anisotropy.getWrapS() == Sampler.Value.CLAMP);
- _RS_ASSERT("anisotropy.getWrapT() == Sampler.Value.CLAMP",
- anisotropy.getWrapT() == Sampler.Value.CLAMP);
- _RS_ASSERT("anisotropy.getAnisotropy() == 1.0f",
- anisotropy.getAnisotropy() == 8.0f);
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- testScriptSide(pRS);
- testJavaSide(pRS);
- passTest();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_struct.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_struct.java
deleted file mode 100644
index 6f47b72..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_struct.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_struct extends UnitTest {
- private Resources mRes;
-
- protected UT_struct(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Struct", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_struct s = new ScriptC_struct(pRS);
- pRS.setMessageHandler(mRsMessage);
-
- ScriptField_Point2 p = new ScriptField_Point2(pRS, 1);
- ScriptField_Point2.Item i = new ScriptField_Point2.Item();
- int val = 100;
- i.x = val;
- i.y = val;
- p.set(i, 0, true);
- s.bind_point2(p);
- s.invoke_struct_test(val);
- pRS.finish();
- waitForMessage();
-
- val = 200;
- p.set_x(0, val, true);
- p.set_y(0, val, true);
- s.invoke_struct_test(val);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_unsigned.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_unsigned.java
deleted file mode 100644
index 9ea0f8a..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_unsigned.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2012 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_unsigned extends UnitTest {
- private Resources mRes;
-
- protected UT_unsigned(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Unsigned", ctx);
- mRes = res;
- }
-
- private boolean initializeGlobals(ScriptC_unsigned s) {
- short pUC = s.get_uc();
- if (pUC != 5) {
- return false;
- }
- s.set_uc((short)129);
-
- long pUI = s.get_ui();
- if (pUI != 37) {
- return false;
- }
- s.set_ui(0x7fffffff);
-
- return true;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_unsigned s = new ScriptC_unsigned(pRS);
- pRS.setMessageHandler(mRsMessage);
- if (!initializeGlobals(s)) {
- failTest();
- } else {
- s.invoke_unsigned_test();
- pRS.finish();
- waitForMessage();
- }
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_vector.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_vector.java
deleted file mode 100644
index 91cc0af..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_vector.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_vector extends UnitTest {
- private Resources mRes;
-
- protected UT_vector(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Vector", ctx);
- mRes = res;
- }
-
- private boolean initializeGlobals(ScriptC_vector s) {
- Float2 F2 = s.get_f2();
- if (F2.x != 1.0f || F2.y != 2.0f) {
- return false;
- }
- F2.x = 2.99f;
- F2.y = 3.99f;
- s.set_f2(F2);
-
- Float3 F3 = s.get_f3();
- if (F3.x != 1.0f || F3.y != 2.0f || F3.z != 3.0f) {
- return false;
- }
- F3.x = 2.99f;
- F3.y = 3.99f;
- F3.z = 4.99f;
- s.set_f3(F3);
-
- Float4 F4 = s.get_f4();
- if (F4.x != 1.0f || F4.y != 2.0f || F4.z != 3.0f || F4.w != 4.0f) {
- return false;
- }
- F4.x = 2.99f;
- F4.y = 3.99f;
- F4.z = 4.99f;
- F4.w = 5.99f;
- s.set_f4(F4);
-
- Double2 D2 = s.get_d2();
- if (D2.x != 1.0 || D2.y != 2.0) {
- return false;
- }
- D2.x = 2.99;
- D2.y = 3.99;
- s.set_d2(D2);
-
- Double3 D3 = s.get_d3();
- if (D3.x != 1.0 || D3.y != 2.0 || D3.z != 3.0) {
- return false;
- }
- D3.x = 2.99;
- D3.y = 3.99;
- D3.z = 4.99;
- s.set_d3(D3);
-
- Double4 D4 = s.get_d4();
- if (D4.x != 1.0 || D4.y != 2.0 || D4.z != 3.0 || D4.w != 4.0) {
- return false;
- }
- D4.x = 2.99;
- D4.y = 3.99;
- D4.z = 4.99;
- D4.w = 5.99;
- s.set_d4(D4);
-
- Byte2 B2 = s.get_i8_2();
- if (B2.x != 1 || B2.y != 2) {
- return false;
- }
- B2.x = 2;
- B2.y = 3;
- s.set_i8_2(B2);
-
- Byte3 B3 = s.get_i8_3();
- if (B3.x != 1 || B3.y != 2 || B3.z != 3) {
- return false;
- }
- B3.x = 2;
- B3.y = 3;
- B3.z = 4;
- s.set_i8_3(B3);
-
- Byte4 B4 = s.get_i8_4();
- if (B4.x != 1 || B4.y != 2 || B4.z != 3 || B4.w != 4) {
- return false;
- }
- B4.x = 2;
- B4.y = 3;
- B4.z = 4;
- B4.w = 5;
- s.set_i8_4(B4);
-
- Short2 S2 = s.get_u8_2();
- if (S2.x != 1 || S2.y != 2) {
- return false;
- }
- S2.x = 2;
- S2.y = 3;
- s.set_u8_2(S2);
-
- Short3 S3 = s.get_u8_3();
- if (S3.x != 1 || S3.y != 2 || S3.z != 3) {
- return false;
- }
- S3.x = 2;
- S3.y = 3;
- S3.z = 4;
- s.set_u8_3(S3);
-
- Short4 S4 = s.get_u8_4();
- if (S4.x != 1 || S4.y != 2 || S4.z != 3 || S4.w != 4) {
- return false;
- }
- S4.x = 2;
- S4.y = 3;
- S4.z = 4;
- S4.w = 5;
- s.set_u8_4(S4);
-
- S2 = s.get_i16_2();
- if (S2.x != 1 || S2.y != 2) {
- return false;
- }
- S2.x = 2;
- S2.y = 3;
- s.set_i16_2(S2);
-
- S3 = s.get_i16_3();
- if (S3.x != 1 || S3.y != 2 || S3.z != 3) {
- return false;
- }
- S3.x = 2;
- S3.y = 3;
- S3.z = 4;
- s.set_i16_3(S3);
-
- S4 = s.get_i16_4();
- if (S4.x != 1 || S4.y != 2 || S4.z != 3 || S4.w != 4) {
- return false;
- }
- S4.x = 2;
- S4.y = 3;
- S4.z = 4;
- S4.w = 5;
- s.set_i16_4(S4);
-
- Int2 I2 = s.get_u16_2();
- if (I2.x != 1 || I2.y != 2) {
- return false;
- }
- I2.x = 2;
- I2.y = 3;
- s.set_u16_2(I2);
-
- Int3 I3 = s.get_u16_3();
- if (I3.x != 1 || I3.y != 2 || I3.z != 3) {
- return false;
- }
- I3.x = 2;
- I3.y = 3;
- I3.z = 4;
- s.set_u16_3(I3);
-
- Int4 I4 = s.get_u16_4();
- if (I4.x != 1 || I4.y != 2 || I4.z != 3 || I4.w != 4) {
- return false;
- }
- I4.x = 2;
- I4.y = 3;
- I4.z = 4;
- I4.w = 5;
- s.set_u16_4(I4);
-
- I2 = s.get_i32_2();
- if (I2.x != 1 || I2.y != 2) {
- return false;
- }
- I2.x = 2;
- I2.y = 3;
- s.set_i32_2(I2);
-
- I3 = s.get_i32_3();
- if (I3.x != 1 || I3.y != 2 || I3.z != 3) {
- return false;
- }
- I3.x = 2;
- I3.y = 3;
- I3.z = 4;
- s.set_i32_3(I3);
-
- I4 = s.get_i32_4();
- if (I4.x != 1 || I4.y != 2 || I4.z != 3 || I4.w != 4) {
- return false;
- }
- I4.x = 2;
- I4.y = 3;
- I4.z = 4;
- I4.w = 5;
- s.set_i32_4(I4);
-
- Long2 L2 = s.get_u32_2();
- if (L2.x != 1 || L2.y != 2) {
- return false;
- }
- L2.x = 2;
- L2.y = 3;
- s.set_u32_2(L2);
-
- Long3 L3 = s.get_u32_3();
- if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
- return false;
- }
- L3.x = 2;
- L3.y = 3;
- L3.z = 4;
- s.set_u32_3(L3);
-
- Long4 L4 = s.get_u32_4();
- if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
- return false;
- }
- L4.x = 2;
- L4.y = 3;
- L4.z = 4;
- L4.w = 5;
- s.set_u32_4(L4);
-
- L2 = s.get_i64_2();
- if (L2.x != 1 || L2.y != 2) {
- return false;
- }
- L2.x = 2;
- L2.y = 3;
- s.set_i64_2(L2);
-
- L3 = s.get_i64_3();
- if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
- return false;
- }
- L3.x = 2;
- L3.y = 3;
- L3.z = 4;
- s.set_i64_3(L3);
-
- L4 = s.get_i64_4();
- if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
- return false;
- }
- L4.x = 2;
- L4.y = 3;
- L4.z = 4;
- L4.w = 5;
- s.set_i64_4(L4);
-
- L2 = s.get_u64_2();
- if (L2.x != 1 || L2.y != 2) {
- return false;
- }
- L2.x = 2;
- L2.y = 3;
- s.set_u64_2(L2);
-
- L3 = s.get_u64_3();
- if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
- return false;
- }
- L3.x = 2;
- L3.y = 3;
- L3.z = 4;
- s.set_u64_3(L3);
-
- L4 = s.get_u64_4();
- if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
- return false;
- }
- L4.x = 2;
- L4.y = 3;
- L4.z = 4;
- L4.w = 5;
- s.set_u64_4(L4);
-
- return true;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_vector s = new ScriptC_vector(pRS);
- pRS.setMessageHandler(mRsMessage);
- if (!initializeGlobals(s)) {
- failTest();
- } else {
- s.invoke_vector_test();
- pRS.finish();
- waitForMessage();
- }
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java
deleted file mode 100644
index fbac124..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test;
-import android.content.Context;
-import android.util.Log;
-import android.renderscript.RenderScript.RSMessageHandler;
-
-public class UnitTest extends Thread {
- public String name;
- private int result;
- private ScriptField_ListAllocs_s.Item mItem;
- private RSTestCore mRSTC;
- private boolean msgHandled;
- protected Context mCtx;
-
- /* These constants must match those in shared.rsh */
- public static final int RS_MSG_TEST_PASSED = 100;
- public static final int RS_MSG_TEST_FAILED = 101;
-
- private static int numTests = 0;
- public int testID;
-
- protected UnitTest(RSTestCore rstc, String n, int initResult, Context ctx) {
- super();
- mRSTC = rstc;
- name = n;
- msgHandled = false;
- mCtx = ctx;
- result = initResult;
- testID = numTests++;
- }
-
- protected UnitTest(RSTestCore rstc, String n, Context ctx) {
- this(rstc, n, 0, ctx);
- }
-
- protected UnitTest(RSTestCore rstc, Context ctx) {
- this (rstc, "<Unknown>", ctx);
- }
-
- protected UnitTest(Context ctx) {
- this (null, ctx);
- }
-
- protected void _RS_ASSERT(String message, boolean b) {
- if(b == false) {
- Log.e(name, message + " FAILED");
- failTest();
- }
- }
-
- private void updateUI() {
- if (mItem != null) {
- mItem.result = result;
- msgHandled = true;
- try {
- mRSTC.refreshTestResults();
- }
- catch (IllegalStateException e) {
- /* Ignore the case where our message receiver has been
- disconnected. This happens when we leave the application
- before it finishes running all of the unit tests. */
- }
- }
- }
-
- protected RSMessageHandler mRsMessage = new RSMessageHandler() {
- public void run() {
- if (result == 0) {
- switch (mID) {
- case RS_MSG_TEST_PASSED:
- result = 1;
- break;
- case RS_MSG_TEST_FAILED:
- result = -1;
- break;
- default:
- RSTest.log("Unit test got unexpected message");
- return;
- }
- }
-
- updateUI();
- }
- };
-
- public void waitForMessage() {
- while (!msgHandled) {
- yield();
- }
- }
-
- public int getResult() {
- return result;
- }
-
- public void failTest() {
- result = -1;
- updateUI();
- }
-
- public void passTest() {
- if (result != -1) {
- result = 1;
- }
- updateUI();
- }
-
- public void setItem(ScriptField_ListAllocs_s.Item item) {
- mItem = item;
- }
-
- public void run() {
- /* This method needs to be implemented for each subclass */
- if (mRSTC != null) {
- mRSTC.refreshTestResults();
- }
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/alloc.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/alloc.rs
deleted file mode 100644
index 1b5e2ac..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/alloc.rs
+++ /dev/null
@@ -1,92 +0,0 @@
-#include "shared.rsh"
-
-int *a;
-int dimX;
-int dimY;
-int dimZ;
-
-rs_allocation aRaw;
-rs_allocation aFaces;
-rs_allocation aLOD;
-rs_allocation aFacesLOD;
-
-void root(int *o, uint32_t x, uint32_t y) {
- *o = x + y * dimX;
-}
-
-static bool test_alloc_dims() {
- bool failed = false;
- int i, j;
-
- _RS_ASSERT(rsAllocationGetDimX(aRaw) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aRaw) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aRaw) == dimZ);
-
- // Test 2D addressing
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- rsDebug("Verifying ", i + j * dimX);
- const void *p = rsGetElementAt(aRaw, i, j);
- int val = *(const int *)p;
- _RS_ASSERT(val == (i + j * dimX));
- }
- }
-
- // Test 1D addressing
- for (i = 0; i < dimX; i++) {
- rsDebug("Verifying ", i);
- const void *p = rsGetElementAt(aRaw, i);
- int val = *(const int *)p;
- _RS_ASSERT(val == i);
- }
-
- // Test 3D addressing
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- rsDebug("Verifying ", i + j * dimX);
- const void *p = rsGetElementAt(aRaw, i, j, 0);
- int val = *(const int *)p;
- _RS_ASSERT(val == (i + j * dimX));
- }
- }
-
- _RS_ASSERT(rsAllocationGetDimX(aFaces) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aFaces) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aFaces) == dimZ);
- _RS_ASSERT(rsAllocationGetDimFaces(aFaces) != 0);
- _RS_ASSERT(rsAllocationGetDimLOD(aFaces) == 0);
-
- _RS_ASSERT(rsAllocationGetDimX(aLOD) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aLOD) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aLOD) == dimZ);
- _RS_ASSERT(rsAllocationGetDimFaces(aLOD) == 0);
- _RS_ASSERT(rsAllocationGetDimLOD(aLOD) != 0);
-
- _RS_ASSERT(rsAllocationGetDimX(aFacesLOD) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aFacesLOD) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aFacesLOD) == dimZ);
- _RS_ASSERT(rsAllocationGetDimFaces(aFacesLOD) != 0);
- _RS_ASSERT(rsAllocationGetDimLOD(aFacesLOD) != 0);
-
- if (failed) {
- rsDebug("test_alloc_dims FAILED", 0);
- }
- else {
- rsDebug("test_alloc_dims PASSED", 0);
- }
-
- return failed;
-}
-
-void alloc_test() {
- bool failed = false;
- failed |= test_alloc_dims();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/array_alloc.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/array_alloc.rs
deleted file mode 100644
index 74ffdb1..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/array_alloc.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "shared.rsh"
-
-const int dimX = 20;
-rs_allocation a[dimX];
-
-void array_alloc_test() {
- bool failed = false;
-
- for (int i = 0; i < dimX; i++) {
- rsDebug("i: ", i);
- _RS_ASSERT(rsAllocationGetDimX(a[i]) == 1);
- }
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/array_init.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/array_init.rs
deleted file mode 100644
index 842249a..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/array_init.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-#include "shared.rsh"
-
-// Testing constant array initialization
-float fa[4] = {1.0, 9.9999f};
-double da[2] = {7.0, 8.88888};
-char ca[4] = {'a', 7, 'b', 'c'};
-short sa[4] = {1, 1, 2, 3};
-int ia[4] = {5, 8};
-long la[2] = {13, 21};
-long long lla[4] = {34};
-bool ba[3] = {true, false};
-
-void array_init_test() {
- bool failed = false;
-
- _RS_ASSERT(fa[0] == 1.0);
- _RS_ASSERT(fa[1] == 9.9999f);
- _RS_ASSERT(fa[2] == 0);
- _RS_ASSERT(fa[3] == 0);
-
- _RS_ASSERT(da[0] == 7.0);
- _RS_ASSERT(da[1] == 8.88888);
-
- _RS_ASSERT(ca[0] == 'a');
- _RS_ASSERT(ca[1] == 7);
- _RS_ASSERT(ca[2] == 'b');
- _RS_ASSERT(ca[3] == 'c');
-
- _RS_ASSERT(sa[0] == 1);
- _RS_ASSERT(sa[1] == 1);
- _RS_ASSERT(sa[2] == 2);
- _RS_ASSERT(sa[3] == 3);
-
- _RS_ASSERT(ia[0] == 5);
- _RS_ASSERT(ia[1] == 8);
- _RS_ASSERT(ia[2] == 0);
- _RS_ASSERT(ia[3] == 0);
-
- _RS_ASSERT(la[0] == 13);
- _RS_ASSERT(la[1] == 21);
-
- _RS_ASSERT(lla[0] == 34);
- _RS_ASSERT(lla[1] == 0);
- _RS_ASSERT(lla[2] == 0);
- _RS_ASSERT(lla[3] == 0);
-
- _RS_ASSERT(ba[0] == true);
- _RS_ASSERT(ba[1] == false);
- _RS_ASSERT(ba[2] == false);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/atomic.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/atomic.rs
deleted file mode 100644
index f0a5041..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/atomic.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-#include "shared.rsh"
-
-// Testing atomic operations
-static bool testUMax(uint32_t dst, uint32_t src) {
- bool failed = false;
- uint32_t old = dst;
- uint32_t expect = (dst > src ? dst : src);
- uint32_t ret = rsAtomicMax(&dst, src);
- _RS_ASSERT(old == ret);
- _RS_ASSERT(dst == expect);
- return failed;
-}
-
-static bool testUMin(uint32_t dst, uint32_t src) {
- bool failed = false;
- uint32_t old = dst;
- uint32_t expect = (dst < src ? dst : src);
- uint32_t ret = rsAtomicMin(&dst, src);
- _RS_ASSERT(old == ret);
- _RS_ASSERT(dst == expect);
- return failed;
-}
-
-static bool testUCas(uint32_t dst, uint32_t cmp, uint32_t swp) {
- bool failed = false;
- uint32_t old = dst;
- uint32_t expect = (dst == cmp ? swp : dst);
- uint32_t ret = rsAtomicCas(&dst, cmp, swp);
- _RS_ASSERT(old == ret);
- _RS_ASSERT(dst == expect);
- return failed;
-}
-
-static bool test_atomics() {
- bool failed = false;
-
- failed |= testUMax(5, 6);
- failed |= testUMax(6, 5);
- failed |= testUMax(5, 0xf0000006);
- failed |= testUMax(0xf0000006, 5);
-
- failed |= testUMin(5, 6);
- failed |= testUMin(6, 5);
- failed |= testUMin(5, 0xf0000006);
- failed |= testUMin(0xf0000006, 5);
-
- failed |= testUCas(4, 4, 5);
- failed |= testUCas(4, 5, 5);
- failed |= testUCas(5, 5, 4);
- failed |= testUCas(5, 4, 4);
- failed |= testUCas(0xf0000004, 0xf0000004, 0xf0000005);
- failed |= testUCas(0xf0000004, 0xf0000005, 0xf0000005);
- failed |= testUCas(0xf0000005, 0xf0000005, 0xf0000004);
- failed |= testUCas(0xf0000005, 0xf0000004, 0xf0000004);
-
- if (failed) {
- rsDebug("test_atomics FAILED", 0);
- }
- else {
- rsDebug("test_atomics PASSED", 0);
- }
-
- return failed;
-}
-
-void atomic_test() {
- bool failed = false;
- failed |= test_atomics();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/bug_char.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/bug_char.rs
deleted file mode 100644
index dcd7b72..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/bug_char.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "shared.rsh"
-
-char rand_sc1_0, rand_sc1_1;
-char2 rand_sc2_0, rand_sc2_1;
-
-char min_rand_sc1_sc1;
-char2 min_rand_sc2_sc2;
-
-static bool test_bug_char() {
- bool failed = false;
-
- rsDebug("rand_sc2_0.x: ", rand_sc2_0.x);
- rsDebug("rand_sc2_0.y: ", rand_sc2_0.y);
- rsDebug("rand_sc2_1.x: ", rand_sc2_1.x);
- rsDebug("rand_sc2_1.y: ", rand_sc2_1.y);
- char temp_sc1;
- char2 temp_sc2;
-
- temp_sc1 = min( rand_sc1_0, rand_sc1_1 );
- if (temp_sc1 != min_rand_sc1_sc1) {
- rsDebug("temp_sc1", temp_sc1);
- failed = true;
- }
- rsDebug("broken", 'y');
-
- temp_sc2 = min( rand_sc2_0, rand_sc2_1 );
- if (temp_sc2.x != min_rand_sc2_sc2.x
- || temp_sc2.y != min_rand_sc2_sc2.y) {
- failed = true;
- }
-
-
- return failed;
-}
-
-void bug_char_test() {
- bool failed = false;
- failed |= test_bug_char();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/clamp.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/clamp.rs
deleted file mode 100644
index 28b00bd..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/clamp.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "shared.rsh"
-
-static bool test_clamp_vector() {
- bool failed = false;
-
- float2 src2 = { 2.0f, 2.0f};
- float2 min2 = { 0.5f, -3.0f};
- float2 max2 = { 1.0f, 9.0f};
-
- float2 res2 = clamp(src2, min2, max2);
- _RS_ASSERT(res2.x == 1.0f);
- _RS_ASSERT(res2.y == 2.0f);
-
-
- float3 src3 = { 2.0f, 2.0f, 1.0f};
- float3 min3 = { 0.5f, -3.0f, 3.0f};
- float3 max3 = { 1.0f, 9.0f, 4.0f};
-
- float3 res3 = clamp(src3, min3, max3);
- _RS_ASSERT(res3.x == 1.0f);
- _RS_ASSERT(res3.y == 2.0f);
- _RS_ASSERT(res3.z == 3.0f);
-
-
- float4 src4 = { 2.0f, 2.0f, 1.0f, 4.0f };
- float4 min4 = { 0.5f, -3.0f, 3.0f, 4.0f };
- float4 max4 = { 1.0f, 9.0f, 4.0f, 4.0f };
-
- float4 res4 = clamp(src4, min4, max4);
- _RS_ASSERT(res4.x == 1.0f);
- _RS_ASSERT(res4.y == 2.0f);
- _RS_ASSERT(res4.z == 3.0f);
- _RS_ASSERT(res4.w == 4.0f);
-
- if (failed) {
- rsDebug("test_clamp_vector FAILED", 0);
- }
- else {
- rsDebug("test_clamp_vector PASSED", 0);
- }
-
- return failed;
-}
-
-void clamp_test() {
- bool failed = false;
- failed |= test_clamp_vector();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/clamp_relaxed.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/clamp_relaxed.rs
deleted file mode 100644
index 71c65ae..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/clamp_relaxed.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "clamp.rs"
-#pragma rs_fp_relaxed
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/constant.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/constant.rs
deleted file mode 100644
index 732eaef..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/constant.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "shared.rsh"
-
-const float floatTest = 1.99f;
-const double doubleTest = 2.05;
-const char charTest = -8;
-const short shortTest = -16;
-const int intTest = -32;
-const long longTest = 17179869184l; // 1 << 34
-const long long longlongTest = 68719476736l; // 1 << 36
-
-const uchar ucharTest = 8;
-const ushort ushortTest = 16;
-const uint uintTest = 32;
-const ulong ulongTest = 4611686018427387904L;
-const int64_t int64_tTest = -17179869184l; // - 1 << 34
-const uint64_t uint64_tTest = 117179869184l;
-
-const bool boolTest = true;
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/convert.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/convert.rs
deleted file mode 100644
index e314f2b..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/convert.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "shared.rsh"
-
-float4 f4 = { 2.0f, 4.0f, 6.0f, 8.0f };
-
-char4 i8_4 = { -1, -2, -3, 4 };
-
-static bool test_convert() {
- bool failed = false;
-
- f4 = convert_float4(i8_4);
- _RS_ASSERT(f4.x == -1.0f);
- _RS_ASSERT(f4.y == -2.0f);
- _RS_ASSERT(f4.z == -3.0f);
- _RS_ASSERT(f4.w == 4.0f);
-
- if (failed) {
- rsDebug("test_convert FAILED", 0);
- }
- else {
- rsDebug("test_convert PASSED", 0);
- }
-
- return failed;
-}
-
-void convert_test() {
- bool failed = false;
- failed |= test_convert();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/convert_relaxed.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/convert_relaxed.rs
deleted file mode 100644
index 81abb9b..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/convert_relaxed.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "convert.rs"
-#pragma rs_fp_relaxed
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/copy_test.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/copy_test.rs
deleted file mode 100644
index f4243eb..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/copy_test.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "shared.rsh"
-
-void sendResult(bool pass) {
- if (pass) {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
-}
-
-
-float2 __attribute((kernel)) copyFloat2(float2 i) {
- return i;
-}
-
-float3 __attribute((kernel)) copyFloat3(float3 i) {
- return i;
-}
-
-float4 __attribute((kernel)) copyFloat4(float4 i) {
- return i;
-}
-
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/element.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/element.rs
deleted file mode 100644
index 419ce07..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/element.rs
+++ /dev/null
@@ -1,158 +0,0 @@
-#include "shared.rsh"
-#include "rs_graphics.rsh"
-
-rs_element simpleElem;
-rs_element complexElem;
-typedef struct ComplexStruct {
- float subElem0;
- float subElem1;
- int subElem2;
- float arrayElem0[2];
- int arrayElem1[5];
- char subElem3;
- float subElem4;
- float2 subElem5;
- float3 subElem6;
- float4 subElem_7;
-} ComplexStruct_t;
-
-ComplexStruct_t *complexStruct;
-
-static const char *subElemNames[] = {
- "subElem0",
- "subElem1",
- "subElem2",
- "arrayElem0",
- "arrayElem1",
- "subElem3",
- "subElem4",
- "subElem5",
- "subElem6",
- "subElem_7",
-};
-
-static uint32_t subElemNamesSizes[] = {
- 8,
- 8,
- 8,
- 10,
- 10,
- 8,
- 8,
- 8,
- 8,
- 9,
-};
-
-static uint32_t subElemArraySizes[] = {
- 1,
- 1,
- 1,
- 2,
- 5,
- 1,
- 1,
- 1,
- 1,
- 1,
-};
-
-static void resetStruct() {
- uint8_t *bytePtr = (uint8_t*)complexStruct;
- uint32_t sizeOfStruct = sizeof(*complexStruct);
- for(uint32_t i = 0; i < sizeOfStruct; i ++) {
- bytePtr[i] = 0;
- }
-}
-
-static bool equals(const char *name0, const char * name1, uint32_t len) {
- for (uint32_t i = 0; i < len; i ++) {
- if (name0[i] != name1[i]) {
- return false;
- }
- }
- return true;
-}
-
-static bool test_element_getters() {
- bool failed = false;
-
- uint32_t subElemOffsets[10];
- uint32_t index = 0;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem0 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem1 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem2 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->arrayElem0 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->arrayElem1 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem3 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem4 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem5 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem6 - (uint32_t)complexStruct;
- subElemOffsets[index++] = (uint32_t)&complexStruct->subElem_7 - (uint32_t)complexStruct;
-
- uint32_t subElemCount = rsElementGetSubElementCount(simpleElem);
- _RS_ASSERT(subElemCount == 0);
- _RS_ASSERT(rsElementGetDataKind(simpleElem) == RS_KIND_USER);
- _RS_ASSERT(rsElementGetDataType(simpleElem) == RS_TYPE_FLOAT_32);
- _RS_ASSERT(rsElementGetVectorSize(simpleElem) == 3);
-
- subElemCount = rsElementGetSubElementCount(complexElem);
- _RS_ASSERT(subElemCount == 10);
- _RS_ASSERT(rsElementGetDataKind(complexElem) == RS_KIND_USER);
- _RS_ASSERT(rsElementGetDataType(complexElem) == RS_TYPE_NONE);
- _RS_ASSERT(rsElementGetVectorSize(complexElem) == 1);
- _RS_ASSERT(rsElementGetBytesSize(complexElem) == sizeof(*complexStruct));
-
- char buffer[64];
- for (uint32_t i = 0; i < subElemCount; i ++) {
- rs_element subElem = rsElementGetSubElement(complexElem, i);
- _RS_ASSERT(rsIsObject(subElem));
-
- _RS_ASSERT(rsElementGetSubElementNameLength(complexElem, i) == subElemNamesSizes[i] + 1);
-
- uint32_t written = rsElementGetSubElementName(complexElem, i, buffer, 64);
- _RS_ASSERT(written == subElemNamesSizes[i]);
- _RS_ASSERT(equals(buffer, subElemNames[i], written));
-
- _RS_ASSERT(rsElementGetSubElementArraySize(complexElem, i) == subElemArraySizes[i]);
- _RS_ASSERT(rsElementGetSubElementOffsetBytes(complexElem, i) == subElemOffsets[i]);
- }
-
- // Tests error checking
- rs_element subElem = rsElementGetSubElement(complexElem, subElemCount);
- _RS_ASSERT(!rsIsObject(subElem));
-
- _RS_ASSERT(rsElementGetSubElementNameLength(complexElem, subElemCount) == 0);
-
- _RS_ASSERT(rsElementGetSubElementName(complexElem, subElemCount, buffer, 64) == 0);
- _RS_ASSERT(rsElementGetSubElementName(complexElem, 0, NULL, 64) == 0);
- _RS_ASSERT(rsElementGetSubElementName(complexElem, 0, buffer, 0) == 0);
- uint32_t written = rsElementGetSubElementName(complexElem, 0, buffer, 5);
- _RS_ASSERT(written == 4);
- _RS_ASSERT(buffer[4] == '\0');
-
- _RS_ASSERT(rsElementGetSubElementArraySize(complexElem, subElemCount) == 0);
- _RS_ASSERT(rsElementGetSubElementOffsetBytes(complexElem, subElemCount) == 0);
-
- if (failed) {
- rsDebug("test_element_getters FAILED", 0);
- }
- else {
- rsDebug("test_element_getters PASSED", 0);
- }
-
- return failed;
-}
-
-void element_test() {
- bool failed = false;
- failed |= test_element_getters();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach.rs
deleted file mode 100644
index 08e6bed..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach.rs
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "shared.rsh"
-
-rs_allocation aRaw;
-int dimX;
-int dimY;
-static bool failed = false;
-
-void root(int *out, uint32_t x, uint32_t y) {
- *out = x + y * dimX;
-}
-
-void foo(const int *in, int *out, uint32_t x, uint32_t y) {
- _RS_ASSERT(*in == (x + y * dimX));
- *out = 99 + x + y * dimX;
- _RS_ASSERT(*out == (99 + x + y * dimX));
-}
-
-static bool test_root_output() {
- bool failed = false;
- int i, j;
-
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- int v = rsGetElementAt_int(aRaw, i, j);
- _RS_ASSERT(v == (i + j * dimX));
- }
- }
-
- if (failed) {
- rsDebug("test_root_output FAILED", 0);
- }
- else {
- rsDebug("test_root_output PASSED", 0);
- }
-
- return failed;
-}
-
-static bool test_foo_output() {
- bool failed = false;
- int i, j;
-
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- int v = rsGetElementAt_int(aRaw, i, j);
- _RS_ASSERT(v == (99 + i + j * dimX));
- }
- }
-
- if (failed) {
- rsDebug("test_foo_output FAILED", 0);
- }
- else {
- rsDebug("test_foo_output PASSED", 0);
- }
-
- return failed;
-}
-
-void verify_root() {
- failed |= test_root_output();
-}
-
-void verify_foo() {
- failed |= test_foo_output();
-}
-
-void foreach_test() {
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach_bounds.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach_bounds.rs
deleted file mode 100644
index fa76390..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach_bounds.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "shared.rsh"
-
-int dimX;
-int dimY;
-int xStart = 0;
-int xEnd = 0;
-int yStart = 0;
-int yEnd = 0;
-
-static bool failed = false;
-
-rs_script s;
-rs_allocation aRaw;
-rs_allocation ain;
-rs_allocation aout;
-
-void root(int *out, uint32_t x, uint32_t y) {
- *out = x + y * dimX;
-}
-
-int __attribute__((kernel)) zero() {
- return 0;
-}
-
-static bool test_root_output() {
- bool failed = false;
- int i, j;
-
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- int v = rsGetElementAt_int(aRaw, i, j);
- if (i < xStart || i >= xEnd || j < yStart || j >= yEnd) {
- _RS_ASSERT(v == 0);
- } else {
- _RS_ASSERT(v == (i + j * dimX));
- }
- }
- }
-
- if (failed) {
- rsDebug("test_root_output FAILED", 0);
- }
- else {
- rsDebug("test_root_output PASSED", 0);
- }
-
- return failed;
-}
-
-void verify_root() {
- failed |= test_root_output();
-}
-
-void foreach_bounds_test() {
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/fp_mad.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/fp_mad.rs
deleted file mode 100644
index b6f2b2a6..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/fp_mad.rs
+++ /dev/null
@@ -1,174 +0,0 @@
-#include "shared.rsh"
-
-const int TEST_COUNT = 1;
-
-static float data_f1[1025];
-static float4 data_f4[1025];
-
-static void test_mad4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~1 billion ops
- for (int ct=0; ct < 1000 * (1000 / 80); ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = (data_f4[i] * 0.02f +
- data_f4[i+1] * 0.04f +
- data_f4[i+2] * 0.05f +
- data_f4[i+3] * 0.1f +
- data_f4[i+4] * 0.2f +
- data_f4[i+5] * 0.2f +
- data_f4[i+6] * 0.1f +
- data_f4[i+7] * 0.05f +
- data_f4[i+8] * 0.04f +
- data_f4[i+9] * 0.02f + 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_mad4 M ops", 1000.f / time);
-}
-
-static void test_mad(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~1 billion ops
- for (int ct=0; ct < 1000 * (1000 / 20); ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = (data_f1[i] * 0.02f +
- data_f1[i+1] * 0.04f +
- data_f1[i+2] * 0.05f +
- data_f1[i+3] * 0.1f +
- data_f1[i+4] * 0.2f +
- data_f1[i+5] * 0.2f +
- data_f1[i+6] * 0.1f +
- data_f1[i+7] * 0.05f +
- data_f1[i+8] * 0.04f +
- data_f1[i+9] * 0.02f + 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_mad M ops", 1000.f / time);
-}
-
-static void test_norm(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = normalize(data_f4[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_norm M ops", 10.f / time);
-}
-
-static void test_sincos4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10 / 4; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = sin(data_f4[i]) * cos(data_f4[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_sincos4 M ops", 10.f / time);
-}
-
-static void test_sincos(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = sin(data_f1[i]) * cos(data_f1[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_sincos M ops", 10.f / time);
-}
-
-static void test_clamp(uint32_t index) {
- start();
-
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = clamp(data_f1[i], -1.f, 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_clamp M ops", 100.f / time);
-
- start();
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100; ct++) {
- for (int i=0; i < (1000); i++) {
- if (data_f1[i] < -1.f) data_f1[i] = -1.f;
- if (data_f1[i] > -1.f) data_f1[i] = 1.f;
- }
- }
-
- time = end(index);
- rsDebug("fp_clamp ref M ops", 100.f / time);
-}
-
-static void test_clamp4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100 /4; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = clamp(data_f4[i], -1.f, 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_clamp4 M ops", 100.f / time);
-}
-
-void fp_mad_test(uint32_t index, int test_num) {
- int x;
- for (x=0; x < 1025; x++) {
- data_f1[x] = (x & 0xf) * 0.1f;
- data_f4[x].x = (x & 0xf) * 0.1f;
- data_f4[x].y = (x & 0xf0) * 0.1f;
- data_f4[x].z = (x & 0x33) * 0.1f;
- data_f4[x].w = (x & 0x77) * 0.1f;
- }
-
- test_mad4(index);
- test_mad(index);
-
- for (x=0; x < 1025; x++) {
- data_f1[x] = (x & 0xf) * 0.1f + 1.f;
- data_f4[x].x = (x & 0xf) * 0.1f + 1.f;
- data_f4[x].y = (x & 0xf0) * 0.1f + 1.f;
- data_f4[x].z = (x & 0x33) * 0.1f + 1.f;
- data_f4[x].w = (x & 0x77) * 0.1f + 1.f;
- }
-
- test_norm(index);
- test_sincos4(index);
- test_sincos(index);
- test_clamp4(index);
- test_clamp(index);
-
- // TODO Actually verify test result accuracy
- rsDebug("fp_mad_test PASSED", 0);
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
-}
-
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/int4.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/int4.rs
deleted file mode 100644
index c791cab..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/int4.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "shared.rsh"
-#pragma rs_fp_relaxed
-
-uchar4 u4 = 4;
-int4 gi4 = {2, 2, 2, 2};
-
-void int4_test() {
- bool failed = false;
- int4 i4 = {u4.x, u4.y, u4.z, u4.w};
- i4 *= gi4;
-
- rsDebug("i4.x", i4.x);
- rsDebug("i4.y", i4.y);
- rsDebug("i4.z", i4.z);
- rsDebug("i4.w", i4.w);
-
- _RS_ASSERT(i4.x == 8);
- _RS_ASSERT(i4.y == 8);
- _RS_ASSERT(i4.z == 8);
- _RS_ASSERT(i4.w == 8);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/kernel.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/kernel.rs
deleted file mode 100644
index d6c9df3..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/kernel.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "shared.rsh"
-
-int *ain;
-int *aout;
-int dimX;
-static bool failed = false;
-
-void init_vars(int *out) {
- *out = 7;
-}
-
-
-int __attribute__((kernel)) root(int ain, uint32_t x) {
- _RS_ASSERT(ain == 7);
- return ain + x;
-}
-
-static bool test_root_output() {
- bool failed = false;
- int i;
-
- for (i = 0; i < dimX; i++) {
- _RS_ASSERT(aout[i] == (i + ain[i]));
- }
-
- if (failed) {
- rsDebug("test_root_output FAILED", 0);
- }
- else {
- rsDebug("test_root_output PASSED", 0);
- }
-
- return failed;
-}
-
-void verify_root() {
- failed |= test_root_output();
-}
-
-void kernel_test() {
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/kernel_struct.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/kernel_struct.rs
deleted file mode 100644
index 62c30ae..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/kernel_struct.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "shared.rsh"
-
-struct simpleStruct {
- int i1;
- char ignored1;
- float f1;
- int i2;
- char ignored2;
- float f2;
-};
-
-struct simpleStruct *ain;
-struct simpleStruct *aout;
-int dimX;
-static bool failed = false;
-
-void init_vars(struct simpleStruct *out, uint32_t x) {
- out->i1 = 0;
- out->f1 = 0.f;
- out->i2 = 1;
- out->f2 = 1.0f;
-}
-
-struct simpleStruct __attribute__((kernel))
- root(struct simpleStruct in, uint32_t x) {
- struct simpleStruct s;
- s.i1 = in.i1 + x;
- s.f1 = in.f1 + x;
- s.i2 = in.i2 + x;
- s.f2 = in.f2 + x;
- return s;
-}
-
-static bool test_root_output() {
- bool failed = false;
- int i;
-
- for (i = 0; i < dimX; i++) {
- _RS_ASSERT(aout[i].i1 == (i + ain[i].i1));
- _RS_ASSERT(aout[i].f1 == (i + ain[i].f1));
- _RS_ASSERT(aout[i].i2 == (i + ain[i].i2));
- _RS_ASSERT(aout[i].f2 == (i + ain[i].f2));
- }
-
- if (failed) {
- rsDebug("test_root_output FAILED", 0);
- }
- else {
- rsDebug("test_root_output PASSED", 0);
- }
-
- return failed;
-}
-
-void verify_root() {
- failed |= test_root_output();
-}
-
-void kernel_struct_test() {
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/math.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/math.rs
deleted file mode 100644
index edde9d8..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/math.rs
+++ /dev/null
@@ -1,437 +0,0 @@
-#include "shared.rsh"
-
-// Testing math library
-
-volatile float f1;
-volatile float2 f2;
-volatile float3 f3;
-volatile float4 f4;
-
-volatile int i1;
-volatile int2 i2;
-volatile int3 i3;
-volatile int4 i4;
-
-volatile uint ui1;
-volatile uint2 ui2;
-volatile uint3 ui3;
-volatile uint4 ui4;
-
-volatile short s1;
-volatile short2 s2;
-volatile short3 s3;
-volatile short4 s4;
-
-volatile ushort us1;
-volatile ushort2 us2;
-volatile ushort3 us3;
-volatile ushort4 us4;
-
-volatile char c1;
-volatile char2 c2;
-volatile char3 c3;
-volatile char4 c4;
-
-volatile uchar uc1;
-volatile uchar2 uc2;
-volatile uchar3 uc3;
-volatile uchar4 uc4;
-
-#define DECL_INT(prefix) \
-volatile char prefix##_c_1 = 1; \
-volatile char2 prefix##_c_2 = 1; \
-volatile char3 prefix##_c_3 = 1; \
-volatile char4 prefix##_c_4 = 1; \
-volatile uchar prefix##_uc_1 = 1; \
-volatile uchar2 prefix##_uc_2 = 1; \
-volatile uchar3 prefix##_uc_3 = 1; \
-volatile uchar4 prefix##_uc_4 = 1; \
-volatile short prefix##_s_1 = 1; \
-volatile short2 prefix##_s_2 = 1; \
-volatile short3 prefix##_s_3 = 1; \
-volatile short4 prefix##_s_4 = 1; \
-volatile ushort prefix##_us_1 = 1; \
-volatile ushort2 prefix##_us_2 = 1; \
-volatile ushort3 prefix##_us_3 = 1; \
-volatile ushort4 prefix##_us_4 = 1; \
-volatile int prefix##_i_1 = 1; \
-volatile int2 prefix##_i_2 = 1; \
-volatile int3 prefix##_i_3 = 1; \
-volatile int4 prefix##_i_4 = 1; \
-volatile uint prefix##_ui_1 = 1; \
-volatile uint2 prefix##_ui_2 = 1; \
-volatile uint3 prefix##_ui_3 = 1; \
-volatile uint4 prefix##_ui_4 = 1; \
-volatile long prefix##_l_1 = 1; \
-volatile ulong prefix##_ul_1 = 1;
-
-DECL_INT(res)
-DECL_INT(src1)
-DECL_INT(src2)
-
-#define TEST_INT_OP_TYPE(op, type) \
-rsDebug("Testing " #op " for " #type "1", i++); \
-res_##type##_1 = src1_##type##_1 op src2_##type##_1; \
-rsDebug("Testing " #op " for " #type "2", i++); \
-res_##type##_2 = src1_##type##_2 op src2_##type##_2; \
-rsDebug("Testing " #op " for " #type "3", i++); \
-res_##type##_3 = src1_##type##_3 op src2_##type##_3; \
-rsDebug("Testing " #op " for " #type "4", i++); \
-res_##type##_4 = src1_##type##_4 op src2_##type##_4;
-
-#define TEST_INT_OP(op) \
-TEST_INT_OP_TYPE(op, c) \
-TEST_INT_OP_TYPE(op, uc) \
-TEST_INT_OP_TYPE(op, s) \
-TEST_INT_OP_TYPE(op, us) \
-TEST_INT_OP_TYPE(op, i) \
-TEST_INT_OP_TYPE(op, ui) \
-rsDebug("Testing " #op " for l1", i++); \
-res_l_1 = src1_l_1 op src2_l_1; \
-rsDebug("Testing " #op " for ul1", i++); \
-res_ul_1 = src1_ul_1 op src2_ul_1;
-
-#define TEST_XN_FUNC_YN(typeout, fnc, typein) \
- res_##typeout##_1 = fnc(src1_##typein##_1); \
- res_##typeout##_2 = fnc(src1_##typein##_2); \
- res_##typeout##_3 = fnc(src1_##typein##_3); \
- res_##typeout##_4 = fnc(src1_##typein##_4);
-
-#define TEST_XN_FUNC_XN_XN(type, fnc) \
- res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1); \
- res_##type##_2 = fnc(src1_##type##_2, src2_##type##_2); \
- res_##type##_3 = fnc(src1_##type##_3, src2_##type##_3); \
- res_##type##_4 = fnc(src1_##type##_4, src2_##type##_4);
-
-#define TEST_X_FUNC_X_X_X(type, fnc) \
- res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1, src2_##type##_1);
-
-#define TEST_IN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_YN(uc, fnc, uc) \
- TEST_XN_FUNC_YN(c, fnc, c) \
- TEST_XN_FUNC_YN(us, fnc, us) \
- TEST_XN_FUNC_YN(s, fnc, s) \
- TEST_XN_FUNC_YN(ui, fnc, ui) \
- TEST_XN_FUNC_YN(i, fnc, i)
-
-#define TEST_UIN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_YN(uc, fnc, c) \
- TEST_XN_FUNC_YN(us, fnc, s) \
- TEST_XN_FUNC_YN(ui, fnc, i) \
-
-#define TEST_IN_FUNC_IN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_XN_XN(uc, fnc) \
- TEST_XN_FUNC_XN_XN(c, fnc) \
- TEST_XN_FUNC_XN_XN(us, fnc) \
- TEST_XN_FUNC_XN_XN(s, fnc) \
- TEST_XN_FUNC_XN_XN(ui, fnc) \
- TEST_XN_FUNC_XN_XN(i, fnc)
-
-#define TEST_I_FUNC_I_I_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_X_FUNC_X_X_X(uc, fnc) \
- TEST_X_FUNC_X_X_X(c, fnc) \
- TEST_X_FUNC_X_X_X(us, fnc) \
- TEST_X_FUNC_X_X_X(s, fnc) \
- TEST_X_FUNC_X_X_X(ui, fnc) \
- TEST_X_FUNC_X_X_X(i, fnc)
-
-#define TEST_FN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1); \
- f2 = fnc(f2); \
- f3 = fnc(f3); \
- f4 = fnc(f4);
-
-#define TEST_FN_FUNC_FN_PFN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (float*) &f1); \
- f2 = fnc(f2, (float2*) &f2); \
- f3 = fnc(f3, (float3*) &f3); \
- f4 = fnc(f4, (float4*) &f4);
-
-#define TEST_FN_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f2); \
- f3 = fnc(f3, f3); \
- f4 = fnc(f4, f4);
-
-#define TEST_F34_FUNC_F34_F34(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f3 = fnc(f3, f3); \
- f4 = fnc(f4, f4);
-
-#define TEST_FN_FUNC_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f1); \
- f3 = fnc(f3, f1); \
- f4 = fnc(f4, f1);
-
-#define TEST_F_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1); \
- f1 = fnc(f2); \
- f1 = fnc(f3); \
- f1 = fnc(f4);
-
-#define TEST_F_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f1 = fnc(f2, f2); \
- f1 = fnc(f3, f3); \
- f1 = fnc(f4, f4);
-
-#define TEST_FN_FUNC_FN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i2); \
- f3 = fnc(f3, i3); \
- f4 = fnc(f4, i4);
-
-#define TEST_FN_FUNC_FN_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i1); \
- f3 = fnc(f3, i1); \
- f4 = fnc(f4, i1);
-
-#define TEST_FN_FUNC_FN_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, f1); \
- f2 = fnc(f2, f2, f2); \
- f3 = fnc(f3, f3, f3); \
- f4 = fnc(f4, f4, f4);
-
-#define TEST_FN_FUNC_FN_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, f1); \
- f2 = fnc(f2, f1, f1); \
- f3 = fnc(f3, f1, f1); \
- f4 = fnc(f4, f1, f1);
-
-#define TEST_FN_FUNC_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (int*) &i1); \
- f2 = fnc(f2, (int2*) &i2); \
- f3 = fnc(f3, (int3*) &i3); \
- f4 = fnc(f4, (int4*) &i4);
-
-#define TEST_FN_FUNC_FN_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, (int*) &i1); \
- f2 = fnc(f2, f2, (int2*) &i2); \
- f3 = fnc(f3, f3, (int3*) &i3); \
- f4 = fnc(f4, f4, (int4*) &i4);
-
-#define TEST_IN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- i1 = fnc(f1); \
- i2 = fnc(f2); \
- i3 = fnc(f3); \
- i4 = fnc(f4);
-
-static bool test_fp_math(uint32_t index) {
- bool failed = false;
- start();
-
- TEST_FN_FUNC_FN(acos);
- TEST_FN_FUNC_FN(acosh);
- TEST_FN_FUNC_FN(acospi);
- TEST_FN_FUNC_FN(asin);
- TEST_FN_FUNC_FN(asinh);
- TEST_FN_FUNC_FN(asinpi);
- TEST_FN_FUNC_FN(atan);
- TEST_FN_FUNC_FN_FN(atan2);
- TEST_FN_FUNC_FN(atanh);
- TEST_FN_FUNC_FN(atanpi);
- TEST_FN_FUNC_FN_FN(atan2pi);
- TEST_FN_FUNC_FN(cbrt);
- TEST_FN_FUNC_FN(ceil);
- TEST_FN_FUNC_FN_FN_FN(clamp);
- TEST_FN_FUNC_FN_FN_F(clamp);
- TEST_FN_FUNC_FN_FN(copysign);
- TEST_FN_FUNC_FN(cos);
- TEST_FN_FUNC_FN(cosh);
- TEST_FN_FUNC_FN(cospi);
- TEST_F34_FUNC_F34_F34(cross);
- TEST_FN_FUNC_FN(degrees);
- TEST_F_FUNC_FN_FN(distance);
- TEST_F_FUNC_FN_FN(dot);
- TEST_FN_FUNC_FN(erfc);
- TEST_FN_FUNC_FN(erf);
- TEST_FN_FUNC_FN(exp);
- TEST_FN_FUNC_FN(exp2);
- TEST_FN_FUNC_FN(exp10);
- TEST_FN_FUNC_FN(expm1);
- TEST_FN_FUNC_FN(fabs);
- TEST_FN_FUNC_FN_FN(fdim);
- TEST_FN_FUNC_FN(floor);
- TEST_FN_FUNC_FN_FN_FN(fma);
- TEST_FN_FUNC_FN_FN(fmax);
- TEST_FN_FUNC_FN_F(fmax);
- TEST_FN_FUNC_FN_FN(fmin);
- TEST_FN_FUNC_FN_F(fmin);
- TEST_FN_FUNC_FN_FN(fmod);
- TEST_FN_FUNC_FN_PFN(fract);
- TEST_FN_FUNC_FN(fract);
- TEST_FN_FUNC_FN_PIN(frexp);
- TEST_FN_FUNC_FN_FN(hypot);
- TEST_IN_FUNC_FN(ilogb);
- TEST_FN_FUNC_FN_IN(ldexp);
- TEST_FN_FUNC_FN_I(ldexp);
- TEST_F_FUNC_FN(length);
- TEST_FN_FUNC_FN(lgamma);
- TEST_FN_FUNC_FN_PIN(lgamma);
- TEST_FN_FUNC_FN(log);
- TEST_FN_FUNC_FN(log2);
- TEST_FN_FUNC_FN(log10);
- TEST_FN_FUNC_FN(log1p);
- TEST_FN_FUNC_FN(logb);
- TEST_FN_FUNC_FN_FN_FN(mad);
- TEST_FN_FUNC_FN_FN(max);
- TEST_FN_FUNC_FN_F(max);
- TEST_FN_FUNC_FN_FN(min);
- TEST_FN_FUNC_FN_F(min);
- TEST_FN_FUNC_FN_FN_FN(mix);
- TEST_FN_FUNC_FN_FN_F(mix);
- TEST_FN_FUNC_FN_PFN(modf);
- // nan
- TEST_FN_FUNC_FN_FN(nextafter);
- TEST_FN_FUNC_FN(normalize);
- TEST_FN_FUNC_FN_FN(pow);
- TEST_FN_FUNC_FN_IN(pown);
- TEST_FN_FUNC_FN_FN(powr);
- TEST_FN_FUNC_FN(radians);
- TEST_FN_FUNC_FN_FN(remainder);
- TEST_FN_FUNC_FN_FN_PIN(remquo);
- TEST_FN_FUNC_FN(rint);
- TEST_FN_FUNC_FN_IN(rootn);
- TEST_FN_FUNC_FN(round);
- TEST_FN_FUNC_FN(rsqrt);
- TEST_FN_FUNC_FN(sign);
- TEST_FN_FUNC_FN(sin);
- TEST_FN_FUNC_FN_PFN(sincos);
- TEST_FN_FUNC_FN(sinh);
- TEST_FN_FUNC_FN(sinpi);
- TEST_FN_FUNC_FN(sqrt);
- TEST_FN_FUNC_FN_FN(step);
- TEST_FN_FUNC_FN_F(step);
- TEST_FN_FUNC_FN(tan);
- TEST_FN_FUNC_FN(tanh);
- TEST_FN_FUNC_FN(tanpi);
- TEST_FN_FUNC_FN(tgamma);
- TEST_FN_FUNC_FN(trunc);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_fp_math FAILED", time);
- }
- else {
- rsDebug("test_fp_math PASSED", time);
- }
-
- return failed;
-}
-
-static bool test_int_math(uint32_t index) {
- bool failed = false;
- start();
-
- TEST_UIN_FUNC_IN(abs);
- TEST_IN_FUNC_IN(clz);
- TEST_IN_FUNC_IN_IN(min);
- TEST_IN_FUNC_IN_IN(max);
- TEST_I_FUNC_I_I_I(rsClamp);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_int_math FAILED", time);
- }
- else {
- rsDebug("test_int_math PASSED", time);
- }
-
- return failed;
-}
-
-static bool test_basic_operators() {
- bool failed = false;
- int i = 0;
-
- TEST_INT_OP(+);
- TEST_INT_OP(-);
- TEST_INT_OP(*);
- TEST_INT_OP(/);
- TEST_INT_OP(%);
- TEST_INT_OP(<<);
- TEST_INT_OP(>>);
-
- if (failed) {
- rsDebug("test_basic_operators FAILED", 0);
- }
- else {
- rsDebug("test_basic_operators PASSED", 0);
- }
-
- return failed;
-}
-
-#define TEST_CVT(to, from, type) \
-rsDebug("Testing convert from " #from " to " #to, 0); \
-to##1 = from##1; \
-to##2 = convert_##type##2(from##2); \
-to##3 = convert_##type##3(from##3); \
-to##4 = convert_##type##4(from##4);
-
-#define TEST_CVT_MATRIX(to, type) \
-TEST_CVT(to, c, type); \
-TEST_CVT(to, uc, type); \
-TEST_CVT(to, s, type); \
-TEST_CVT(to, us, type); \
-TEST_CVT(to, i, type); \
-TEST_CVT(to, ui, type); \
-TEST_CVT(to, f, type); \
-
-static bool test_convert() {
- bool failed = false;
-
- TEST_CVT_MATRIX(c, char);
- TEST_CVT_MATRIX(uc, uchar);
- TEST_CVT_MATRIX(s, short);
- TEST_CVT_MATRIX(us, ushort);
- TEST_CVT_MATRIX(i, int);
- TEST_CVT_MATRIX(ui, uint);
- TEST_CVT_MATRIX(f, float);
-
- if (failed) {
- rsDebug("test_convert FAILED", 0);
- }
- else {
- rsDebug("test_convert PASSED", 0);
- }
-
- return failed;
-}
-
-void math_test(uint32_t index, int test_num) {
- bool failed = false;
- failed |= test_convert();
- failed |= test_fp_math(index);
- failed |= test_int_math(index);
- failed |= test_basic_operators();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs
deleted file mode 100644
index 5bfbb2b..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs
+++ /dev/null
@@ -1,409 +0,0 @@
-#include "shared.rsh"
-//#pragma rs_fp_relaxed
-
-volatile float x = 0.0f;
-volatile float y = 0.0f;
-volatile float result_add = 0.0f;
-volatile float result_sub = 0.0f;
-volatile float result_mul = 0.0f;
-volatile float result_div = 0.0f;
-
-#define DECLARE_INPUT_SET(type, abbrev) \
-volatile type rand_##abbrev##1_0, rand_##abbrev##1_1; \
-volatile type##2 rand_##abbrev##2_0, rand_##abbrev##2_1; \
-volatile type##3 rand_##abbrev##3_0, rand_##abbrev##3_1; \
-volatile type##4 rand_##abbrev##4_0, rand_##abbrev##4_1;
-
-#define DECLARE_ALL_INPUT_SETS() \
-DECLARE_INPUT_SET(float, f); \
-DECLARE_INPUT_SET(char, sc); \
-DECLARE_INPUT_SET(uchar, uc); \
-DECLARE_INPUT_SET(short, ss); \
-DECLARE_INPUT_SET(ushort, us); \
-DECLARE_INPUT_SET(int, si); \
-DECLARE_INPUT_SET(uint, ui); \
-DECLARE_INPUT_SET(long, sl); \
-DECLARE_INPUT_SET(ulong, ul);
-
-DECLARE_ALL_INPUT_SETS();
-
-#define DECLARE_REFERENCE_SET_VEC_VEC(type, abbrev, func) \
-volatile type func##_rand_##abbrev##1_##abbrev##1; \
-volatile type##2 func##_rand_##abbrev##2_##abbrev##2; \
-volatile type##3 func##_rand_##abbrev##3_##abbrev##3; \
-volatile type##4 func##_rand_##abbrev##4_##abbrev##4;
-#define DECLARE_REFERENCE_SET_VEC_SCL(type, abbrev, func) \
-volatile type##2 func##_rand_##abbrev##2_##abbrev##1; \
-volatile type##3 func##_rand_##abbrev##3_##abbrev##1; \
-volatile type##4 func##_rand_##abbrev##4_##abbrev##1;
-
-#define DECLARE_ALL_REFERENCE_SETS_VEC_VEC(func) \
-DECLARE_REFERENCE_SET_VEC_VEC(float, f, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(char, sc, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(uchar, uc, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(short, ss, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(ushort, us, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(int, si, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(uint, ui, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(long, sl, func); \
-DECLARE_REFERENCE_SET_VEC_VEC(ulong, ul, func);
-
-DECLARE_ALL_REFERENCE_SETS_VEC_VEC(min);
-DECLARE_ALL_REFERENCE_SETS_VEC_VEC(max);
-DECLARE_REFERENCE_SET_VEC_VEC(float, f, fmin);
-DECLARE_REFERENCE_SET_VEC_SCL(float, f, fmin);
-DECLARE_REFERENCE_SET_VEC_VEC(float, f, fmax);
-DECLARE_REFERENCE_SET_VEC_SCL(float, f, fmax);
-
-static void fail_f1(float v1, float v2, float actual, float expected, char *op_name) {
- int dist = float_dist(actual, expected);
- rsDebug("float operation did not match!", op_name);
- rsDebug("v1", v1);
- rsDebug("v2", v2);
- rsDebug("Dalvik result", expected);
- rsDebug("Renderscript result", actual);
- rsDebug("ULP difference", dist);
-}
-
-static void fail_f2(float2 v1, float2 v2, float2 actual, float2 expected, char *op_name) {
- int2 dist;
- dist.x = float_dist(actual.x, expected.x);
- dist.y = float_dist(actual.y, expected.y);
- rsDebug("float2 operation did not match!", op_name);
- rsDebug("v1.x", v1.x);
- rsDebug("v1.y", v1.y);
- rsDebug("v2.x", v2.x);
- rsDebug("v2.y", v2.y);
- rsDebug("Dalvik result .x", expected.x);
- rsDebug("Dalvik result .y", expected.y);
- rsDebug("Renderscript result .x", actual.x);
- rsDebug("Renderscript result .y", actual.y);
- rsDebug("ULP difference .x", dist.x);
- rsDebug("ULP difference .y", dist.y);
-}
-
-static void fail_f3(float3 v1, float3 v2, float3 actual, float3 expected, char *op_name) {
- int3 dist;
- dist.x = float_dist(actual.x, expected.x);
- dist.y = float_dist(actual.y, expected.y);
- dist.z = float_dist(actual.z, expected.z);
- rsDebug("float3 operation did not match!", op_name);
- rsDebug("v1.x", v1.x);
- rsDebug("v1.y", v1.y);
- rsDebug("v1.z", v1.z);
- rsDebug("v2.x", v2.x);
- rsDebug("v2.y", v2.y);
- rsDebug("v2.z", v2.z);
- rsDebug("Dalvik result .x", expected.x);
- rsDebug("Dalvik result .y", expected.y);
- rsDebug("Dalvik result .z", expected.z);
- rsDebug("Renderscript result .x", actual.x);
- rsDebug("Renderscript result .y", actual.y);
- rsDebug("Renderscript result .z", actual.z);
- rsDebug("ULP difference .x", dist.x);
- rsDebug("ULP difference .y", dist.y);
- rsDebug("ULP difference .z", dist.z);
-}
-
-static void fail_f4(float4 v1, float4 v2, float4 actual, float4 expected, char *op_name) {
- int4 dist;
- dist.x = float_dist(actual.x, expected.x);
- dist.y = float_dist(actual.y, expected.y);
- dist.z = float_dist(actual.z, expected.z);
- dist.w = float_dist(actual.w, expected.w);
- rsDebug("float4 operation did not match!", op_name);
- rsDebug("v1.x", v1.x);
- rsDebug("v1.y", v1.y);
- rsDebug("v1.z", v1.z);
- rsDebug("v1.w", v1.w);
- rsDebug("v2.x", v2.x);
- rsDebug("v2.y", v2.y);
- rsDebug("v2.z", v2.z);
- rsDebug("v2.w", v2.w);
- rsDebug("Dalvik result .x", expected.x);
- rsDebug("Dalvik result .y", expected.y);
- rsDebug("Dalvik result .z", expected.z);
- rsDebug("Dalvik result .w", expected.w);
- rsDebug("Renderscript result .x", actual.x);
- rsDebug("Renderscript result .y", actual.y);
- rsDebug("Renderscript result .z", actual.z);
- rsDebug("Renderscript result .w", actual.w);
- rsDebug("ULP difference .x", dist.x);
- rsDebug("ULP difference .y", dist.y);
- rsDebug("ULP difference .z", dist.z);
- rsDebug("ULP difference .w", dist.w);
-}
-
-static bool f1_almost_equal(float a, float b) {
- return float_almost_equal(a, b);
-}
-
-static bool f2_almost_equal(float2 a, float2 b) {
- return float_almost_equal(a.x, b.x) && float_almost_equal(a.y, b.y);
-}
-
-
-static bool f3_almost_equal(float3 a, float3 b) {
- return float_almost_equal(a.x, b.x) && float_almost_equal(a.y, b.y)
- && float_almost_equal(a.z, b.z);
-}
-
-static bool f4_almost_equal(float4 a, float4 b) {
- return float_almost_equal(a.x, b.x) && float_almost_equal(a.y, b.y)
- && float_almost_equal(a.z, b.z) && float_almost_equal(a.w, b.w);
-}
-
-#define TEST_BASIC_FLOAT_OP(op, opName) \
-temp_f1 = x op y; \
-if (! float_almost_equal(temp_f1, result_##opName)) { \
- fail_f1(x, y , temp_f1, result_##opName, #opName); \
- failed = true; \
-}
-
-#define TEST_FN_FN(func, size) \
-temp_f##size = func(rand_f##size##_0, rand_f##size##_1); \
-if (! f##size##_almost_equal(temp_f##size , func##_rand_f##size##_f##size)) { \
- fail_f##size (x, y , temp_f##size, func##_rand_f##size##_f##size, #func); \
- failed = true; \
-}
-#define TEST_FN_F(func, size) \
-temp_f##size = func(rand_f##size##_0, rand_f1_1); \
-if (! f##size##_almost_equal(temp_f##size , func##_rand_f##size##_f1)) { \
- fail_f##size (x, y , temp_f##size, func##_rand_f##size##_f1 , #func); \
- failed = true; \
-}
-
-#define TEST_FN_FN_ALL(func) \
-TEST_FN_FN(func, 1) \
-TEST_FN_FN(func, 2) \
-TEST_FN_FN(func, 3) \
-TEST_FN_FN(func, 4)
-#define TEST_FN_F_ALL(func) \
-TEST_FN_F(func, 2) \
-TEST_FN_F(func, 3) \
-TEST_FN_F(func, 4)
-
-#define TEST_VEC1_VEC1(func, type) \
-temp_##type##1 = func( rand_##type##1_0, rand_##type##1_1 ); \
-if (temp_##type##1 != func##_rand_##type##1_##type##1) { \
- rsDebug(#func " " #type "1 operation did not match!", 0); \
- rsDebug("v1", rand_##type##1_0); \
- rsDebug("v2", rand_##type##1_1); \
- rsDebug("Dalvik result", func##_rand_##type##1_##type##1); \
- rsDebug("Renderscript result", temp_##type##1); \
- failed = true; \
-}
-#define TEST_VEC2_VEC2(func, type) \
-temp_##type##2 = func( rand_##type##2_0, rand_##type##2_1 ); \
-if (temp_##type##2 .x != func##_rand_##type##2_##type##2 .x \
- || temp_##type##2 .y != func##_rand_##type##2_##type##2 .y) { \
- rsDebug(#func " " #type "2 operation did not match!", 0); \
- rsDebug("v1.x", rand_##type##2_0 .x); \
- rsDebug("v1.y", rand_##type##2_0 .y); \
- rsDebug("v2.x", rand_##type##2_1 .x); \
- rsDebug("v2.y", rand_##type##2_1 .y); \
- rsDebug("Dalvik result .x", func##_rand_##type##2_##type##2 .x); \
- rsDebug("Dalvik result .y", func##_rand_##type##2_##type##2 .y); \
- rsDebug("Renderscript result .x", temp_##type##2 .x); \
- rsDebug("Renderscript result .y", temp_##type##2 .y); \
- failed = true; \
-}
-#define TEST_VEC3_VEC3(func, type) \
-temp_##type##3 = func( rand_##type##3_0, rand_##type##3_1 ); \
-if (temp_##type##3 .x != func##_rand_##type##3_##type##3 .x \
- || temp_##type##3 .y != func##_rand_##type##3_##type##3 .y \
- || temp_##type##3 .z != func##_rand_##type##3_##type##3 .z) { \
- rsDebug(#func " " #type "3 operation did not match!", 0); \
- rsDebug("v1.x", rand_##type##3_0 .x); \
- rsDebug("v1.y", rand_##type##3_0 .y); \
- rsDebug("v1.z", rand_##type##3_0 .z); \
- rsDebug("v2.x", rand_##type##3_1 .x); \
- rsDebug("v2.y", rand_##type##3_1 .y); \
- rsDebug("v2.z", rand_##type##3_1 .z); \
- rsDebug("Dalvik result .x", func##_rand_##type##3_##type##3 .x); \
- rsDebug("Dalvik result .y", func##_rand_##type##3_##type##3 .y); \
- rsDebug("Dalvik result .z", func##_rand_##type##3_##type##3 .z); \
- rsDebug("Renderscript result .x", temp_##type##3 .x); \
- rsDebug("Renderscript result .y", temp_##type##3 .y); \
- rsDebug("Renderscript result .z", temp_##type##3 .z); \
- failed = true; \
-}
-#define TEST_VEC4_VEC4(func, type) \
-temp_##type##4 = func( rand_##type##4_0, rand_##type##4_1 ); \
-if (temp_##type##4 .x != func##_rand_##type##4_##type##4 .x \
- || temp_##type##4 .y != func##_rand_##type##4_##type##4 .y \
- || temp_##type##4 .z != func##_rand_##type##4_##type##4 .z \
- || temp_##type##4 .w != func##_rand_##type##4_##type##4 .w) { \
- rsDebug(#func " " #type "4 operation did not match!", 0); \
- rsDebug("v1.x", rand_##type##4_0 .x); \
- rsDebug("v1.y", rand_##type##4_0 .y); \
- rsDebug("v1.z", rand_##type##4_0 .z); \
- rsDebug("v1.w", rand_##type##4_0 .w); \
- rsDebug("v2.x", rand_##type##4_1 .x); \
- rsDebug("v2.y", rand_##type##4_1 .y); \
- rsDebug("v2.z", rand_##type##4_1 .z); \
- rsDebug("v2.w", rand_##type##4_1 .w); \
- rsDebug("Dalvik result .x", func##_rand_##type##4_##type##4 .x); \
- rsDebug("Dalvik result .y", func##_rand_##type##4_##type##4 .y); \
- rsDebug("Dalvik result .z", func##_rand_##type##4_##type##4 .z); \
- rsDebug("Dalvik result .w", func##_rand_##type##4_##type##4 .w); \
- rsDebug("Renderscript result .x", temp_##type##4 .x); \
- rsDebug("Renderscript result .y", temp_##type##4 .y); \
- rsDebug("Renderscript result .z", temp_##type##4 .z); \
- rsDebug("Renderscript result .w", temp_##type##4 .w); \
- failed = true; \
-}
-
-#define TEST_SC1_SC1(func) TEST_VEC1_VEC1(func, sc)
-#define TEST_SC2_SC2(func) TEST_VEC2_VEC2(func, sc)
-#define TEST_SC3_SC3(func) TEST_VEC3_VEC3(func, sc)
-#define TEST_SC4_SC4(func) TEST_VEC4_VEC4(func, sc)
-
-#define TEST_UC1_UC1(func) TEST_VEC1_VEC1(func, uc)
-#define TEST_UC2_UC2(func) TEST_VEC2_VEC2(func, uc)
-#define TEST_UC3_UC3(func) TEST_VEC3_VEC3(func, uc)
-#define TEST_UC4_UC4(func) TEST_VEC4_VEC4(func, uc)
-
-#define TEST_SS1_SS1(func) TEST_VEC1_VEC1(func, ss)
-#define TEST_SS2_SS2(func) TEST_VEC2_VEC2(func, ss)
-#define TEST_SS3_SS3(func) TEST_VEC3_VEC3(func, ss)
-#define TEST_SS4_SS4(func) TEST_VEC4_VEC4(func, ss)
-
-#define TEST_US1_US1(func) TEST_VEC1_VEC1(func, us)
-#define TEST_US2_US2(func) TEST_VEC2_VEC2(func, us)
-#define TEST_US3_US3(func) TEST_VEC3_VEC3(func, us)
-#define TEST_US4_US4(func) TEST_VEC4_VEC4(func, us)
-
-#define TEST_SI1_SI1(func) TEST_VEC1_VEC1(func, si)
-#define TEST_SI2_SI2(func) TEST_VEC2_VEC2(func, si)
-#define TEST_SI3_SI3(func) TEST_VEC3_VEC3(func, si)
-#define TEST_SI4_SI4(func) TEST_VEC4_VEC4(func, si)
-
-#define TEST_UI1_UI1(func) TEST_VEC1_VEC1(func, ui)
-#define TEST_UI2_UI2(func) TEST_VEC2_VEC2(func, ui)
-#define TEST_UI3_UI3(func) TEST_VEC3_VEC3(func, ui)
-#define TEST_UI4_UI4(func) TEST_VEC4_VEC4(func, ui)
-
-#define TEST_SL1_SL1(func) TEST_VEC1_VEC1(func, sl)
-#define TEST_SL2_SL2(func) TEST_VEC2_VEC2(func, sl)
-#define TEST_SL3_SL3(func) TEST_VEC3_VEC3(func, sl)
-#define TEST_SL4_SL4(func) TEST_VEC4_VEC4(func, sl)
-
-#define TEST_UL1_UL1(func) TEST_VEC1_VEC1(func, ul)
-#define TEST_UL2_UL2(func) TEST_VEC2_VEC2(func, ul)
-#define TEST_UL3_UL3(func) TEST_VEC3_VEC3(func, ul)
-#define TEST_UL4_UL4(func) TEST_VEC4_VEC4(func, ul)
-
-#define TEST_SC_SC_ALL(func) \
-TEST_SC1_SC1(func) \
-TEST_SC2_SC2(func) \
-TEST_SC3_SC3(func) \
-TEST_SC4_SC4(func)
-#define TEST_UC_UC_ALL(func) \
-TEST_UC1_UC1(func) \
-TEST_UC2_UC2(func) \
-TEST_UC3_UC3(func) \
-TEST_UC4_UC4(func)
-
-#define TEST_SS_SS_ALL(func) \
-TEST_SS1_SS1(func) \
-TEST_SS2_SS2(func) \
-TEST_SS3_SS3(func) \
-TEST_SS4_SS4(func)
-#define TEST_US_US_ALL(func) \
-TEST_US1_US1(func) \
-TEST_US2_US2(func) \
-TEST_US3_US3(func) \
-TEST_US4_US4(func)
-#define TEST_SI_SI_ALL(func) \
-TEST_SI1_SI1(func) \
-TEST_SI2_SI2(func) \
-TEST_SI3_SI3(func) \
-TEST_SI4_SI4(func)
-#define TEST_UI_UI_ALL(func) \
-TEST_UI1_UI1(func) \
-TEST_UI2_UI2(func) \
-TEST_UI3_UI3(func) \
-TEST_UI4_UI4(func)
-#define TEST_SL_SL_ALL(func) \
-TEST_SL1_SL1(func) \
-TEST_SL2_SL2(func) \
-TEST_SL3_SL3(func) \
-TEST_SL4_SL4(func)
-#define TEST_UL_UL_ALL(func) \
-TEST_UL1_UL1(func) \
-TEST_UL2_UL2(func) \
-TEST_UL3_UL3(func) \
-TEST_UL4_UL4(func)
-
-#define TEST_VEC_VEC_ALL(func) \
-TEST_FN_FN_ALL(func) \
-TEST_SC_SC_ALL(func) \
-TEST_UC_UC_ALL(func) \
-TEST_SS_SS_ALL(func) \
-TEST_US_US_ALL(func) \
-TEST_SI_SI_ALL(func) \
-TEST_UI_UI_ALL(func)
-
-// TODO: add long types to ALL macro
-#if 0
-TEST_SL_SL_ALL(func) \
-TEST_UL_UL_ALL(func)
-#endif
-
-#define DECLARE_TEMP_SET(type, abbrev) \
-volatile type temp_##abbrev##1; \
-volatile type##2 temp_##abbrev##2; \
-volatile type##3 temp_##abbrev##3; \
-volatile type##4 temp_##abbrev##4;
-
-#define DECLARE_ALL_TEMP_SETS() \
-DECLARE_TEMP_SET(float, f); \
-DECLARE_TEMP_SET(char, sc); \
-DECLARE_TEMP_SET(uchar, uc); \
-DECLARE_TEMP_SET(short, ss); \
-DECLARE_TEMP_SET(ushort, us); \
-DECLARE_TEMP_SET(int, si); \
-DECLARE_TEMP_SET(uint, ui); \
-DECLARE_TEMP_SET(long, sl); \
-DECLARE_TEMP_SET(ulong, ul);
-
-static bool test_math_agree() {
- bool failed = false;
-
- DECLARE_ALL_TEMP_SETS();
-
- TEST_BASIC_FLOAT_OP(+, add);
- TEST_BASIC_FLOAT_OP(-, sub);
- TEST_BASIC_FLOAT_OP(*, mul);
- TEST_BASIC_FLOAT_OP(/, div);
-
- TEST_VEC_VEC_ALL(min);
- TEST_VEC_VEC_ALL(max);
- TEST_FN_FN_ALL(fmin);
- TEST_FN_F_ALL(fmin);
- TEST_FN_FN_ALL(fmax);
- TEST_FN_F_ALL(fmax);
-
- if (failed) {
- rsDebug("test_math_agree FAILED", 0);
- }
- else {
- rsDebug("test_math_agree PASSED", 0);
- }
-
- return failed;
-}
-
-void math_agree_test() {
- bool failed = false;
- failed |= test_math_agree();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/math_conformance.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/math_conformance.rs
deleted file mode 100644
index 2d62f34..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/math_conformance.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "shared.rsh"
-
-// Testing math conformance
-
-static bool test_rootn() {
- bool failed = false;
-
- // rootn(x, 0) -> NaN
- _RS_ASSERT(isnan(rootn(1.0f, 0)));
-
- // rootn(+/-0, n) -> +/-inf for odd n < 0
- _RS_ASSERT(isposinf(rootn(0.f, -3)));
- _RS_ASSERT(isneginf(rootn(-0.f, -3)));
-
- // rootn(+/-0, n) -> +inf for even n < 0
- _RS_ASSERT(isposinf(rootn(0.f, -8)));
- _RS_ASSERT(isposinf(rootn(-0.f, -8)));
-
- // rootn(+/-0, n) -> +/-0 for odd n > 0
- _RS_ASSERT(isposzero(rootn(0.f, 3)));
- _RS_ASSERT(isnegzero(rootn(-0.f, 3)));
-
- // rootn(+/-0, n) -> +0 for even n > 0
- _RS_ASSERT(isposzero(rootn(0.f, 8)));
- _RS_ASSERT(isposzero(rootn(-0.f, 8)));
-
- // rootn(x, n) -> NaN for x < 0 and even n
- _RS_ASSERT(isnan(rootn(-10000.f, -4)));
- _RS_ASSERT(isnan(rootn(-10000.f, 4)));
-
- // rootn(x, n) -> value for x < 0 and odd n
- _RS_ASSERT(!isnan(rootn(-10000.f, -3)));
- _RS_ASSERT(!isnan(rootn(-10000.f, 3)));
-
- if (failed) {
- rsDebug("test_rootn FAILED", -1);
- }
- else {
- rsDebug("test_rootn PASSED", 0);
- }
-
- return failed;
-}
-
-void math_conformance_test() {
- bool failed = false;
- failed |= test_rootn();
-
- if (failed) {
- rsDebug("math_conformance_test FAILED", -1);
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsDebug("math_conformance_test PASSED", 0);
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/mesh.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/mesh.rs
deleted file mode 100644
index 1354897..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/mesh.rs
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "shared.rsh"
-#include "rs_graphics.rsh"
-
-rs_mesh mesh;
-rs_allocation vertexAlloc0;
-rs_allocation vertexAlloc1;
-
-rs_allocation indexAlloc0;
-rs_allocation indexAlloc2;
-
-static bool test_mesh_getters() {
- bool failed = false;
-
- _RS_ASSERT(rsgMeshGetVertexAllocationCount(mesh) == 2);
- _RS_ASSERT(rsgMeshGetPrimitiveCount(mesh) == 3);
-
- rs_allocation meshV0 = rsgMeshGetVertexAllocation(mesh, 0);
- rs_allocation meshV1 = rsgMeshGetVertexAllocation(mesh, 1);
- rs_allocation meshV2 = rsgMeshGetVertexAllocation(mesh, 2);
- _RS_ASSERT(meshV0.p == vertexAlloc0.p);
- _RS_ASSERT(meshV1.p == vertexAlloc1.p);
- _RS_ASSERT(!rsIsObject(meshV2));
-
- rs_allocation meshI0 = rsgMeshGetIndexAllocation(mesh, 0);
- rs_allocation meshI1 = rsgMeshGetIndexAllocation(mesh, 1);
- rs_allocation meshI2 = rsgMeshGetIndexAllocation(mesh, 2);
- rs_allocation meshI3 = rsgMeshGetIndexAllocation(mesh, 3);
- _RS_ASSERT(meshI0.p == indexAlloc0.p);
- _RS_ASSERT(!rsIsObject(meshI1));
- _RS_ASSERT(meshI2.p == indexAlloc2.p);
- _RS_ASSERT(!rsIsObject(meshI3));
-
- rs_primitive p0 = rsgMeshGetPrimitive(mesh, 0);
- rs_primitive p1 = rsgMeshGetPrimitive(mesh, 1);
- rs_primitive p2 = rsgMeshGetPrimitive(mesh, 2);
- rs_primitive p3 = rsgMeshGetPrimitive(mesh, 3);
-
- _RS_ASSERT(p0 == RS_PRIMITIVE_POINT);
- _RS_ASSERT(p1 == RS_PRIMITIVE_LINE);
- _RS_ASSERT(p2 == RS_PRIMITIVE_TRIANGLE);
- _RS_ASSERT(p3 == RS_PRIMITIVE_INVALID);
-
- if (failed) {
- rsDebug("test_mesh_getters FAILED", 0);
- }
- else {
- rsDebug("test_mesh_getters PASSED", 0);
- }
-
- return failed;
-}
-
-void mesh_test() {
- bool failed = false;
- failed |= test_mesh_getters();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/min.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/min.rs
deleted file mode 100644
index 4b92763..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/min.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "shared.rsh"
-#pragma rs_fp_relaxed
-
-volatile uchar2 res_uc_2 = 1;
-volatile uchar2 src1_uc_2 = 1;
-volatile uchar2 src2_uc_2 = 1;
-
-void min_test() {
- bool failed = false;
-
- res_uc_2 = min(src1_uc_2, src2_uc_2);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/noroot.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/noroot.rs
deleted file mode 100644
index 2c807bd..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/noroot.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "shared.rsh"
-
-rs_allocation aRaw;
-int dimX;
-int dimY;
-static bool failed = false;
-
-void foo(const int *in, int *out, uint32_t x, uint32_t y) {
- *out = 99 + x + y * dimX;
-}
-
-static bool test_foo_output() {
- bool failed = false;
- int i, j;
-
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- int v = rsGetElementAt_int(aRaw, i, j);
- _RS_ASSERT(v == (99 + i + j * dimX));
- }
- }
-
- if (failed) {
- rsDebug("test_foo_output FAILED", 0);
- }
- else {
- rsDebug("test_foo_output PASSED", 0);
- }
-
- return failed;
-}
-
-void verify_foo() {
- failed |= test_foo_output();
-}
-
-void noroot_test() {
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/primitives.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/primitives.rs
deleted file mode 100644
index ce451da..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/primitives.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "shared.rsh"
-
-// Testing primitive types
-float floatTest = 1.99f;
-double doubleTest = 2.05;
-char charTest = -8;
-short shortTest = -16;
-int intTest = -32;
-long longTest = 17179869184l; // 1 << 34
-long long longlongTest = 68719476736l; // 1 << 36
-
-uchar ucharTest = 8;
-ushort ushortTest = 16;
-uint uintTest = 32;
-ulong ulongTest = 4611686018427387904L;
-int64_t int64_tTest = -17179869184l; // - 1 << 34
-uint64_t uint64_tTest = 117179869184l;
-
-static bool test_primitive_types(uint32_t index) {
- bool failed = false;
- start();
-
- _RS_ASSERT(floatTest == 2.99f);
- _RS_ASSERT(doubleTest == 3.05);
- _RS_ASSERT(charTest == -16);
- _RS_ASSERT(shortTest == -32);
- _RS_ASSERT(intTest == -64);
- _RS_ASSERT(longTest == 17179869185l);
- _RS_ASSERT(longlongTest == 68719476735l);
-
- _RS_ASSERT(ucharTest == 8);
- _RS_ASSERT(ushortTest == 16);
- _RS_ASSERT(uintTest == 32);
- _RS_ASSERT(ulongTest == 4611686018427387903L);
- _RS_ASSERT(int64_tTest == -17179869184l);
- _RS_ASSERT(uint64_tTest == 117179869185l);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_primitives FAILED", time);
- }
- else {
- rsDebug("test_primitives PASSED", time);
- }
-
- return failed;
-}
-
-void primitives_test(uint32_t index, int test_num) {
- bool failed = false;
- failed |= test_primitive_types(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/program_raster.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/program_raster.rs
deleted file mode 100644
index 3d6b502..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/program_raster.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "shared.rsh"
-#include "rs_graphics.rsh"
-
-rs_program_raster pointSpriteEnabled;
-rs_program_raster cullMode;
-
-static bool test_program_raster_getters() {
- bool failed = false;
-
- _RS_ASSERT(rsgProgramRasterIsPointSpriteEnabled(pointSpriteEnabled) == true);
- _RS_ASSERT(rsgProgramRasterGetCullMode(pointSpriteEnabled) == RS_CULL_BACK);
-
- _RS_ASSERT(rsgProgramRasterIsPointSpriteEnabled(cullMode) == false);
- _RS_ASSERT(rsgProgramRasterGetCullMode(cullMode) == RS_CULL_FRONT);
-
- if (failed) {
- rsDebug("test_program_raster_getters FAILED", 0);
- }
- else {
- rsDebug("test_program_raster_getters PASSED", 0);
- }
-
- return failed;
-}
-
-void program_raster_test() {
- bool failed = false;
- failed |= test_program_raster_getters();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/program_store.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/program_store.rs
deleted file mode 100644
index 2ae5636..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/program_store.rs
+++ /dev/null
@@ -1,128 +0,0 @@
-#include "shared.rsh"
-#include "rs_graphics.rsh"
-
-rs_program_store ditherEnable;
-rs_program_store colorRWriteEnable;
-rs_program_store colorGWriteEnable;
-rs_program_store colorBWriteEnable;
-rs_program_store colorAWriteEnable;
-rs_program_store blendSrc;
-rs_program_store blendDst;
-rs_program_store depthWriteEnable;
-rs_program_store depthFunc;
-
-static bool test_program_store_getters() {
- bool failed = false;
-
- _RS_ASSERT(rsgProgramStoreGetDepthFunc(depthFunc) == RS_DEPTH_FUNC_GREATER);
- _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(depthFunc) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(depthFunc) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(depthFunc) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(depthFunc) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( depthFunc) == false);
- _RS_ASSERT(rsgProgramStoreIsDitherEnabled(depthFunc) == false);
- _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(depthFunc) == RS_BLEND_SRC_ZERO);
- _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(depthFunc) == RS_BLEND_DST_ZERO);
-
- _RS_ASSERT(rsgProgramStoreGetDepthFunc(depthWriteEnable) == RS_DEPTH_FUNC_ALWAYS);
- _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(depthWriteEnable) == true);
- _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(depthWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(depthWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(depthWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( depthWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsDitherEnabled(depthWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(depthWriteEnable) == RS_BLEND_SRC_ZERO);
- _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(depthWriteEnable) == RS_BLEND_DST_ZERO);
-
- _RS_ASSERT(rsgProgramStoreGetDepthFunc(colorRWriteEnable) == RS_DEPTH_FUNC_ALWAYS);
- _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(colorRWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(colorRWriteEnable) == true);
- _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(colorRWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(colorRWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( colorRWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsDitherEnabled(colorRWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorRWriteEnable) == RS_BLEND_SRC_ZERO);
- _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorRWriteEnable) == RS_BLEND_DST_ZERO);
-
- _RS_ASSERT(rsgProgramStoreGetDepthFunc(colorGWriteEnable) == RS_DEPTH_FUNC_ALWAYS);
- _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(colorGWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(colorGWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(colorGWriteEnable) == true);
- _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(colorGWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( colorGWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsDitherEnabled(colorGWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorGWriteEnable) == RS_BLEND_SRC_ZERO);
- _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorGWriteEnable) == RS_BLEND_DST_ZERO);
-
- _RS_ASSERT(rsgProgramStoreGetDepthFunc(colorBWriteEnable) == RS_DEPTH_FUNC_ALWAYS);
- _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(colorBWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(colorBWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(colorBWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(colorBWriteEnable) == true);
- _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( colorBWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsDitherEnabled(colorBWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorBWriteEnable) == RS_BLEND_SRC_ZERO);
- _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorBWriteEnable) == RS_BLEND_DST_ZERO);
-
- _RS_ASSERT(rsgProgramStoreGetDepthFunc(colorAWriteEnable) == RS_DEPTH_FUNC_ALWAYS);
- _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(colorAWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(colorAWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(colorAWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(colorAWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( colorAWriteEnable) == true);
- _RS_ASSERT(rsgProgramStoreIsDitherEnabled(colorAWriteEnable) == false);
- _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorAWriteEnable) == RS_BLEND_SRC_ZERO);
- _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorAWriteEnable) == RS_BLEND_DST_ZERO);
-
- _RS_ASSERT(rsgProgramStoreGetDepthFunc(ditherEnable) == RS_DEPTH_FUNC_ALWAYS);
- _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(ditherEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(ditherEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(ditherEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(ditherEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( ditherEnable) == false);
- _RS_ASSERT(rsgProgramStoreIsDitherEnabled(ditherEnable) == true);
- _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(ditherEnable) == RS_BLEND_SRC_ZERO);
- _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(ditherEnable) == RS_BLEND_DST_ZERO);
-
- _RS_ASSERT(rsgProgramStoreGetDepthFunc(blendSrc) == RS_DEPTH_FUNC_ALWAYS);
- _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(blendSrc) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(blendSrc) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(blendSrc) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(blendSrc) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( blendSrc) == false);
- _RS_ASSERT(rsgProgramStoreIsDitherEnabled(blendSrc) == false);
- _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(blendSrc) == RS_BLEND_SRC_DST_COLOR);
- _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(blendSrc) == RS_BLEND_DST_ZERO);
-
- _RS_ASSERT(rsgProgramStoreGetDepthFunc(blendDst) == RS_DEPTH_FUNC_ALWAYS);
- _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(blendDst) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(blendDst) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(blendDst) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(blendDst) == false);
- _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( blendDst) == false);
- _RS_ASSERT(rsgProgramStoreIsDitherEnabled(blendDst) == false);
- _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(blendDst) == RS_BLEND_SRC_ZERO);
- _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(blendDst) == RS_BLEND_DST_DST_ALPHA);
-
- if (failed) {
- rsDebug("test_program_store_getters FAILED", 0);
- }
- else {
- rsDebug("test_program_store_getters PASSED", 0);
- }
-
- return failed;
-}
-
-void program_store_test() {
- bool failed = false;
- failed |= test_program_store_getters();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/refcount.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/refcount.rs
deleted file mode 100644
index 4ea70e2..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/refcount.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "shared.rsh"
-
-// Testing reference counting of RS object types
-
-rs_allocation globalA;
-static rs_allocation staticGlobalA;
-
-void refcount_test() {
- staticGlobalA = globalA;
- rsClearObject(&globalA);
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/rsdebug.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/rsdebug.rs
deleted file mode 100644
index 68ac168..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/rsdebug.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "shared.rsh"
-
-// Testing primitive types
-float floatTest = 1.99f;
-float2 float2Test = {2.99f, 12.99f};
-float3 float3Test = {3.99f, 13.99f, 23.99f};
-float4 float4Test = {4.99f, 14.99f, 24.99f, 34.99f};
-double doubleTest = 2.05;
-char charTest = -8;
-short shortTest = -16;
-int intTest = -32;
-long longTest = 17179869184l; // 1 << 34
-long long longlongTest = 68719476736l; // 1 << 36
-
-uchar ucharTest = 8;
-ushort ushortTest = 16;
-uint uintTest = 32;
-ulong ulongTest = 4611686018427387904L;
-int64_t int64_tTest = -17179869184l; // - 1 << 34
-uint64_t uint64_tTest = 117179869184l;
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- // This test focuses primarily on compilation-time, not run-time.
- // For this reason, none of the outputs are actually checked.
-
- rsDebug("floatTest", floatTest);
- rsDebug("float2Test", float2Test);
- rsDebug("float3Test", float3Test);
- rsDebug("float4Test", float4Test);
- rsDebug("doubleTest", doubleTest);
- rsDebug("charTest", charTest);
- rsDebug("shortTest", shortTest);
- rsDebug("intTest", intTest);
- rsDebug("longTest", longTest);
- rsDebug("longlongTest", longlongTest);
-
- rsDebug("ucharTest", ucharTest);
- rsDebug("ushortTest", ushortTest);
- rsDebug("uintTest", uintTest);
- rsDebug("ulongTest", ulongTest);
- rsDebug("int64_tTest", int64_tTest);
- rsDebug("uint64_tTest", uint64_tTest);
-
- return failed;
-}
-
-void test_rsdebug(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rsdebug_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rsdebug_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/rslist.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/rslist.rs
deleted file mode 100644
index d8663fb..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/rslist.rs
+++ /dev/null
@@ -1,107 +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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test)
-
-#include "rs_graphics.rsh"
-
-float gDY;
-
-rs_font gFont;
-
-typedef struct ListAllocs_s {
- rs_allocation text;
- int result;
-} ListAllocs;
-
-ListAllocs *gList;
-
-void init() {
- gDY = 0.0f;
-}
-
-int textPos = 0;
-
-int root(void) {
-
- rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- rsgClearDepth(1.0f);
-
- textPos -= (int)gDY*2;
- gDY *= 0.95;
-
- rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f);
- rsgBindFont(gFont);
-
- rs_allocation listAlloc;
- listAlloc = rsGetAllocation(gList);
- int allocSize = rsAllocationGetDimX(listAlloc);
-
- int width = rsgGetWidth();
- int height = rsgGetHeight();
-
- int itemHeight = 80;
- int totalItemHeight = itemHeight * allocSize;
-
- /* Prevent scrolling above the top of the list */
- int firstItem = height - totalItemHeight;
- if (firstItem < 0) {
- firstItem = 0;
- }
-
- /* Prevent scrolling past the last line of the list */
- int lastItem = -1 * (totalItemHeight - height);
- if (lastItem > 0) {
- lastItem = 0;
- }
-
- if (textPos > firstItem) {
- textPos = firstItem;
- }
- else if (textPos < lastItem) {
- textPos = lastItem;
- }
-
- int currentYPos = itemHeight + textPos;
-
- for(int i = 0; i < allocSize; i ++) {
- if(currentYPos - itemHeight > height) {
- break;
- }
-
- if(currentYPos > 0) {
- switch(gList[i].result) {
- case 1: /* Passed */
- rsgFontColor(0.5f, 0.9f, 0.5f, 1.0f);
- break;
- case -1: /* Failed */
- rsgFontColor(0.9f, 0.5f, 0.5f, 1.0f);
- break;
- case 0: /* Still Testing */
- rsgFontColor(0.9f, 0.9f, 0.5f, 1.0f);
- break;
- default: /* Unknown */
- rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f);
- break;
- }
- rsgDrawRect(0, currentYPos - 1, width, currentYPos, 0);
- rsgDrawText(gList[i].text, 30, currentYPos - 32);
- }
- currentYPos += itemHeight;
- }
-
- return 10;
-}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/rstime.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/rstime.rs
deleted file mode 100644
index 7be955d..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/rstime.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "shared.rsh"
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- rs_time_t curTime = rsTime(0);
- rs_tm tm;
- rsDebug("curTime", curTime);
-
- rsLocaltime(&tm, &curTime);
-
- rsDebug("tm.tm_sec", tm.tm_sec);
- rsDebug("tm.tm_min", tm.tm_min);
- rsDebug("tm.tm_hour", tm.tm_hour);
- rsDebug("tm.tm_mday", tm.tm_mday);
- rsDebug("tm.tm_mon", tm.tm_mon);
- rsDebug("tm.tm_year", tm.tm_year);
- rsDebug("tm.tm_wday", tm.tm_wday);
- rsDebug("tm.tm_yday", tm.tm_yday);
- rsDebug("tm.tm_isdst", tm.tm_isdst);
-
- // Test a specific time (since we set America/Los_Angeles localtime)
- curTime = 1294438893;
- rsLocaltime(&tm, &curTime);
-
- _RS_ASSERT(tm.tm_sec == 33);
- _RS_ASSERT(tm.tm_min == 21);
- _RS_ASSERT(tm.tm_hour == 14);
- _RS_ASSERT(tm.tm_mday == 7);
- _RS_ASSERT(tm.tm_mon == 0);
- _RS_ASSERT(tm.tm_year == 111);
- _RS_ASSERT(tm.tm_wday == 5);
- _RS_ASSERT(tm.tm_yday == 6);
- _RS_ASSERT(tm.tm_isdst == 0);
-
- return failed;
-}
-
-void test_rstime(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rstime_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rstime_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/rstypes.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/rstypes.rs
deleted file mode 100644
index 22d9c13..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/rstypes.rs
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "shared.rsh"
-#include "rs_graphics.rsh"
-
-rs_element elementTest;
-rs_type typeTest;
-rs_allocation allocationTest;
-rs_sampler samplerTest;
-rs_script scriptTest;
-rs_mesh meshTest;
-rs_program_fragment program_fragmentTest;
-rs_program_vertex program_vertexTest;
-rs_program_raster program_rasterTest;
-rs_program_store program_storeTest;
-rs_font fontTest;
-
-rs_matrix4x4 matrix4x4Test;
-rs_matrix3x3 matrix3x3Test;
-rs_matrix2x2 matrix2x2Test;
-
-struct my_struct {
- int i;
- rs_font fontTestStruct;
-};
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- rs_matrix4x4 matrix4x4TestLocal;
- rs_matrix3x3 matrix3x3TestLocal;
- rs_matrix2x2 matrix2x2TestLocal;
-
- // This test focuses primarily on compilation-time, not run-time.
- rs_element elementTestLocal;
- rs_type typeTestLocal;
- rs_allocation allocationTestLocal;
- rs_sampler samplerTestLocal;
- rs_script scriptTestLocal;
- rs_mesh meshTestLocal;
- rs_program_fragment program_fragmentTestLocal;
- rs_program_vertex program_vertexTestLocal;
- rs_program_raster program_rasterTestLocal;
- rs_program_store program_storeTestLocal;
- rs_font fontTestLocal;
-
- rs_font fontTestLocalArray[4];
-
- rs_font fontTestLocalPreInit = fontTest;
-
- struct my_struct structTest;
-
- fontTestLocal = fontTest;
- //allocationTestLocal = allocationTest;
-
- fontTest = fontTestLocal;
- //allocationTest = allocationTestLocal;
-
- /*for (int i = 0; i < 4; i++) {
- fontTestLocalArray[i] = fontTestLocal;
- }*/
-
- /*fontTest = fontTestLocalArray[3];*/
-
- return failed;
-}
-
-void test_rstypes(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rstypes_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rstypes_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/sampler.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/sampler.rs
deleted file mode 100644
index ff1c0a7..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/sampler.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-#include "shared.rsh"
-#include "rs_graphics.rsh"
-rs_sampler minification;
-rs_sampler magnification;
-rs_sampler wrapS;
-rs_sampler wrapT;
-rs_sampler anisotropy;
-
-static bool test_sampler_getters() {
- bool failed = false;
-
- _RS_ASSERT(rsSamplerGetMagnification(minification) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetMinification(minification) == RS_SAMPLER_LINEAR_MIP_LINEAR);
- _RS_ASSERT(rsSamplerGetWrapS(minification) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetWrapT(minification) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetAnisotropy(minification) == 1.0f);
-
- _RS_ASSERT(rsSamplerGetMagnification(magnification) == RS_SAMPLER_LINEAR);
- _RS_ASSERT(rsSamplerGetMinification(magnification) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetWrapS(magnification) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetWrapT(magnification) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetAnisotropy(magnification) == 1.0f);
-
- _RS_ASSERT(rsSamplerGetMagnification(wrapS) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetMinification(wrapS) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetWrapS(wrapS) == RS_SAMPLER_WRAP);
- _RS_ASSERT(rsSamplerGetWrapT(wrapS) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetAnisotropy(wrapS) == 1.0f);
-
- _RS_ASSERT(rsSamplerGetMagnification(wrapT) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetMinification(wrapT) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetWrapS(wrapT) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetWrapT(wrapT) == RS_SAMPLER_WRAP);
- _RS_ASSERT(rsSamplerGetAnisotropy(wrapT) == 1.0f);
-
- _RS_ASSERT(rsSamplerGetMagnification(anisotropy) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetMinification(anisotropy) == RS_SAMPLER_NEAREST);
- _RS_ASSERT(rsSamplerGetWrapS(anisotropy) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetWrapT(anisotropy) == RS_SAMPLER_CLAMP);
- _RS_ASSERT(rsSamplerGetAnisotropy(anisotropy) == 8.0f);
-
- if (failed) {
- rsDebug("test_sampler_getters FAILED", 0);
- }
- else {
- rsDebug("test_sampler_getters PASSED", 0);
- }
-
- return failed;
-}
-
-void sampler_test() {
- bool failed = false;
- failed |= test_sampler_getters();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/shared.rsh b/tests/RenderScriptTests/tests/src/com/android/rs/test/shared.rsh
deleted file mode 100644
index 3adc999..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/shared.rsh
+++ /dev/null
@@ -1,114 +0,0 @@
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test)
-
-typedef struct TestResult_s {
- rs_allocation name;
- bool pass;
- float score;
- int64_t time;
-} TestResult;
-//TestResult *g_results;
-
-static int64_t g_time;
-
-static void start(void) {
- g_time = rsUptimeMillis();
-}
-
-static float end(uint32_t idx) {
- int64_t t = rsUptimeMillis() - g_time;
- //g_results[idx].time = t;
- //rsDebug("test time", (int)t);
- return ((float)t) / 1000.f;
-}
-
-#define _RS_ASSERT(b) \
-do { \
- if (!(b)) { \
- failed = true; \
- rsDebug(#b " FAILED", 0); \
- } \
-\
-} while (0)
-
-static const int iposinf = 0x7f800000;
-static const int ineginf = 0xff800000;
-
-static const float posinf() {
- float f = *((float*)&iposinf);
- return f;
-}
-
-static const float neginf() {
- float f = *((float*)&ineginf);
- return f;
-}
-
-static bool isposinf(float f) {
- int i = *((int*)(void*)&f);
- return (i == iposinf);
-}
-
-static bool isneginf(float f) {
- int i = *((int*)(void*)&f);
- return (i == ineginf);
-}
-
-static bool isnan(float f) {
- int i = *((int*)(void*)&f);
- return (((i & 0x7f800000) == 0x7f800000) && (i & 0x007fffff));
-}
-
-static bool isposzero(float f) {
- int i = *((int*)(void*)&f);
- return (i == 0x00000000);
-}
-
-static bool isnegzero(float f) {
- int i = *((int*)(void*)&f);
- return (i == 0x80000000);
-}
-
-static bool iszero(float f) {
- return isposzero(f) || isnegzero(f);
-}
-
-/* Absolute epsilon used for floats. Value is similar to float.h. */
-#ifndef FLT_EPSILON
-#define FLT_EPSILON 1.19e7f
-#endif
-/* Max ULPs while still being considered "equal". Only used when this number
- of ULPs is of a greater size than FLT_EPSILON. */
-#define FLT_MAX_ULP 1
-
-/* Calculate the difference in ULPs between the two values. (Return zero on
- perfect equality.) */
-static int float_dist(float f1, float f2) {
- return *((int *)(&f1)) - *((int *)(&f2));
-}
-
-/* Check if two floats are essentially equal. Will fail with some values
- due to design. (Validate using FLT_EPSILON or similar if necessary.) */
-static bool float_almost_equal(float f1, float f2) {
- int *i1 = (int*)(&f1);
- int *i2 = (int*)(&f2);
-
- // Check for sign equality
- if ( ((*i1 >> 31) == 0) != ((*i2 >> 31) == 0) ) {
- // Handle signed zeroes
- if (f1 == f2)
- return true;
- return false;
- }
-
- // Check with ULP distance
- if (float_dist(f1, f2) > FLT_MAX_ULP)
- return false;
- return true;
-}
-
-/* These constants must match those in UnitTest.java */
-static const int RS_MSG_TEST_PASSED = 100;
-static const int RS_MSG_TEST_FAILED = 101;
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/struct.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/struct.rs
deleted file mode 100644
index 1cd728e..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/struct.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "shared.rsh"
-
-typedef struct Point2 {
- int x;
- int y;
-} Point_2;
-Point_2 *point2;
-
-static bool test_Point_2(int expected) {
- bool failed = false;
-
- rsDebug("Point: ", point2[0].x, point2[0].y);
- _RS_ASSERT(point2[0].x == expected);
- _RS_ASSERT(point2[0].y == expected);
-
- if (failed) {
- rsDebug("test_Point_2 FAILED", 0);
- }
- else {
- rsDebug("test_Point_2 PASSED", 0);
- }
-
- return failed;
-}
-
-void struct_test(int expected) {
- bool failed = false;
- failed |= test_Point_2(expected);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/test_root.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/test_root.rs
deleted file mode 100644
index 6dc83ba..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/test_root.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Fountain test script
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test)
-
-#pragma stateFragment(parent)
-
-#include "rs_graphics.rsh"
-
-
-typedef struct TestResult {
- rs_allocation name;
- bool pass;
- float score;
-} TestResult_t;
-TestResult_t *results;
-
-int root() {
-
- return 0;
-}
-
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/unsigned.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/unsigned.rs
deleted file mode 100644
index 2c056f4..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/unsigned.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "shared.rsh"
-
-// Testing unsigned types for Bug 6764163
-unsigned int ui = 37;
-unsigned char uc = 5;
-
-static bool test_unsigned() {
- bool failed = false;
-
- rsDebug("ui", ui);
- rsDebug("uc", uc);
- _RS_ASSERT(ui == 0x7fffffff);
- _RS_ASSERT(uc == 129);
-
- if (failed) {
- rsDebug("test_unsigned FAILED", -1);
- }
- else {
- rsDebug("test_unsigned PASSED", 0);
- }
-
- return failed;
-}
-
-void unsigned_test() {
- bool failed = false;
- failed |= test_unsigned();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/vector.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/vector.rs
deleted file mode 100644
index 0430a2f..0000000
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/vector.rs
+++ /dev/null
@@ -1,198 +0,0 @@
-#include "shared.rsh"
-
-// Testing vector types
-float2 f2 = { 1.0f, 2.0f };
-float3 f3 = { 1.0f, 2.0f, 3.0f };
-float4 f4 = { 1.0f, 2.0f, 3.0f, 4.0f };
-
-double2 d2 = { 1.0, 2.0 };
-double3 d3 = { 1.0, 2.0, 3.0 };
-double4 d4 = { 1.0, 2.0, 3.0, 4.0 };
-
-char2 i8_2 = { 1, 2 };
-char3 i8_3 = { 1, 2, 3 };
-char4 i8_4 = { 1, 2, 3, 4 };
-
-uchar2 u8_2 = { 1, 2 };
-uchar3 u8_3 = { 1, 2, 3 };
-uchar4 u8_4 = { 1, 2, 3, 4 };
-
-short2 i16_2 = { 1, 2 };
-short3 i16_3 = { 1, 2, 3 };
-short4 i16_4 = { 1, 2, 3, 4 };
-
-ushort2 u16_2 = { 1, 2 };
-ushort3 u16_3 = { 1, 2, 3 };
-ushort4 u16_4 = { 1, 2, 3, 4 };
-
-int2 i32_2 = { 1, 2 };
-int3 i32_3 = { 1, 2, 3 };
-int4 i32_4 = { 1, 2, 3, 4 };
-
-uint2 u32_2 = { 1, 2 };
-uint3 u32_3 = { 1, 2, 3 };
-uint4 u32_4 = { 1, 2, 3, 4 };
-
-long2 i64_2 = { 1, 2 };
-long3 i64_3 = { 1, 2, 3 };
-long4 i64_4 = { 1, 2, 3, 4 };
-
-ulong2 u64_2 = { 1, 2 };
-ulong3 u64_3 = { 1, 2, 3 };
-ulong4 u64_4 = { 1, 2, 3, 4 };
-
-static bool test_vector_types() {
- bool failed = false;
-
- rsDebug("Testing F32", 0);
- _RS_ASSERT(f2.x == 2.99f);
- _RS_ASSERT(f2.y == 3.99f);
-
- _RS_ASSERT(f3.x == 2.99f);
- _RS_ASSERT(f3.y == 3.99f);
- _RS_ASSERT(f3.z == 4.99f);
-
- _RS_ASSERT(f4.x == 2.99f);
- _RS_ASSERT(f4.y == 3.99f);
- _RS_ASSERT(f4.z == 4.99f);
- _RS_ASSERT(f4.w == 5.99f);
-
- rsDebug("Testing F64", 0);
- _RS_ASSERT(d2.x == 2.99);
- _RS_ASSERT(d2.y == 3.99);
-
- _RS_ASSERT(d3.x == 2.99);
- _RS_ASSERT(d3.y == 3.99);
- _RS_ASSERT(d3.z == 4.99);
-
- _RS_ASSERT(d4.x == 2.99);
- _RS_ASSERT(d4.y == 3.99);
- _RS_ASSERT(d4.z == 4.99);
- _RS_ASSERT(d4.w == 5.99);
-
- rsDebug("Testing I8", 0);
- _RS_ASSERT(i8_2.x == 2);
- _RS_ASSERT(i8_2.y == 3);
-
- _RS_ASSERT(i8_3.x == 2);
- _RS_ASSERT(i8_3.y == 3);
- _RS_ASSERT(i8_3.z == 4);
-
- _RS_ASSERT(i8_4.x == 2);
- _RS_ASSERT(i8_4.y == 3);
- _RS_ASSERT(i8_4.z == 4);
- _RS_ASSERT(i8_4.w == 5);
-
- rsDebug("Testing U8", 0);
- _RS_ASSERT(u8_2.x == 2);
- _RS_ASSERT(u8_2.y == 3);
-
- _RS_ASSERT(u8_3.x == 2);
- _RS_ASSERT(u8_3.y == 3);
- _RS_ASSERT(u8_3.z == 4);
-
- _RS_ASSERT(u8_4.x == 2);
- _RS_ASSERT(u8_4.y == 3);
- _RS_ASSERT(u8_4.z == 4);
- _RS_ASSERT(u8_4.w == 5);
-
- rsDebug("Testing I16", 0);
- _RS_ASSERT(i16_2.x == 2);
- _RS_ASSERT(i16_2.y == 3);
-
- _RS_ASSERT(i16_3.x == 2);
- _RS_ASSERT(i16_3.y == 3);
- _RS_ASSERT(i16_3.z == 4);
-
- _RS_ASSERT(i16_4.x == 2);
- _RS_ASSERT(i16_4.y == 3);
- _RS_ASSERT(i16_4.z == 4);
- _RS_ASSERT(i16_4.w == 5);
-
- rsDebug("Testing U16", 0);
- _RS_ASSERT(u16_2.x == 2);
- _RS_ASSERT(u16_2.y == 3);
-
- _RS_ASSERT(u16_3.x == 2);
- _RS_ASSERT(u16_3.y == 3);
- _RS_ASSERT(u16_3.z == 4);
-
- _RS_ASSERT(u16_4.x == 2);
- _RS_ASSERT(u16_4.y == 3);
- _RS_ASSERT(u16_4.z == 4);
- _RS_ASSERT(u16_4.w == 5);
-
- rsDebug("Testing I32", 0);
- _RS_ASSERT(i32_2.x == 2);
- _RS_ASSERT(i32_2.y == 3);
-
- _RS_ASSERT(i32_3.x == 2);
- _RS_ASSERT(i32_3.y == 3);
- _RS_ASSERT(i32_3.z == 4);
-
- _RS_ASSERT(i32_4.x == 2);
- _RS_ASSERT(i32_4.y == 3);
- _RS_ASSERT(i32_4.z == 4);
- _RS_ASSERT(i32_4.w == 5);
-
- rsDebug("Testing U32", 0);
- _RS_ASSERT(u32_2.x == 2);
- _RS_ASSERT(u32_2.y == 3);
-
- _RS_ASSERT(u32_3.x == 2);
- _RS_ASSERT(u32_3.y == 3);
- _RS_ASSERT(u32_3.z == 4);
-
- _RS_ASSERT(u32_4.x == 2);
- _RS_ASSERT(u32_4.y == 3);
- _RS_ASSERT(u32_4.z == 4);
- _RS_ASSERT(u32_4.w == 5);
-
- rsDebug("Testing I64", 0);
- _RS_ASSERT(i64_2.x == 2);
- _RS_ASSERT(i64_2.y == 3);
-
- _RS_ASSERT(i64_3.x == 2);
- _RS_ASSERT(i64_3.y == 3);
- _RS_ASSERT(i64_3.z == 4);
-
- _RS_ASSERT(i64_4.x == 2);
- _RS_ASSERT(i64_4.y == 3);
- _RS_ASSERT(i64_4.z == 4);
- _RS_ASSERT(i64_4.w == 5);
-
- rsDebug("Testing U64", 0);
- _RS_ASSERT(u64_2.x == 2);
- _RS_ASSERT(u64_2.y == 3);
-
- _RS_ASSERT(u64_3.x == 2);
- _RS_ASSERT(u64_3.y == 3);
- _RS_ASSERT(u64_3.z == 4);
-
- _RS_ASSERT(u64_4.x == 2);
- _RS_ASSERT(u64_4.y == 3);
- _RS_ASSERT(u64_4.z == 4);
- _RS_ASSERT(u64_4.w == 5);
-
- if (failed) {
- rsDebug("test_vector FAILED", 0);
- }
- else {
- rsDebug("test_vector PASSED", 0);
- }
-
- return failed;
-}
-
-void vector_test() {
- bool failed = false;
- failed |= test_vector_types();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v11/Android.mk b/tests/RenderScriptTests/tests_v11/Android.mk
deleted file mode 100644
index 52d326b..0000000
--- a/tests/RenderScriptTests/tests_v11/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (C) 2008 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.
-#
-
-ifneq ($(TARGET_SIMULATOR),true)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := RSTest_v11
-LOCAL_SDK_VERSION := 11
-
-include $(BUILD_PACKAGE)
-
-endif
diff --git a/tests/RenderScriptTests/tests_v11/AndroidManifest.xml b/tests/RenderScriptTests/tests_v11/AndroidManifest.xml
deleted file mode 100644
index f4aeda2..0000000
--- a/tests/RenderScriptTests/tests_v11/AndroidManifest.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.rs.test_v11">
- <uses-sdk android:minSdkVersion="11" />
- <application
- android:label="_RS_Test_v11"
- android:icon="@drawable/test_pattern">
- <activity android:name="RSTest_v11"
- android:screenOrientation="portrait">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/tests_v11/res/drawable/test_pattern.png b/tests/RenderScriptTests/tests_v11/res/drawable/test_pattern.png
deleted file mode 100644
index e7d1455..0000000
--- a/tests/RenderScriptTests/tests_v11/res/drawable/test_pattern.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/RSTestCore.java
deleted file mode 100644
index 888cfe4..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/RSTestCore.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (C) 2008 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.rs.test_v11;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-import java.util.ArrayList;
-import java.util.ListIterator;
-import java.util.Timer;
-import java.util.TimerTask;
-
-
-public class RSTestCore {
- int mWidth;
- int mHeight;
- Context mCtx;
-
- public RSTestCore(Context ctx) {
- mCtx = ctx;
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
-
- private Font mFont;
- ScriptField_ListAllocs_s mListAllocs;
- int mLastX;
- int mLastY;
- private ScriptC_rslist mScript;
-
- private ArrayList<UnitTest> unitTests;
- private ListIterator<UnitTest> test_iter;
- private UnitTest activeTest;
- private boolean stopTesting;
-
- /* Periodic timer for ensuring future tests get scheduled */
- private Timer mTimer;
- public static final int RS_TIMER_PERIOD = 100;
-
- public void init(RenderScriptGL rs, Resources res, int width, int height) {
- mRS = rs;
- mRes = res;
- mWidth = width;
- mHeight = height;
- stopTesting = false;
-
- mScript = new ScriptC_rslist(mRS, mRes, R.raw.rslist);
-
- unitTests = new ArrayList<UnitTest>();
-
- unitTests.add(new UT_primitives(this, mRes, mCtx));
- unitTests.add(new UT_rsdebug(this, mRes, mCtx));
- unitTests.add(new UT_rstime(this, mRes, mCtx));
- unitTests.add(new UT_rstypes(this, mRes, mCtx));
- unitTests.add(new UT_math(this, mRes, mCtx));
- unitTests.add(new UT_fp_mad(this, mRes, mCtx));
- /*
- unitTests.add(new UnitTest(null, "<Pass>", 1));
- unitTests.add(new UnitTest());
- unitTests.add(new UnitTest(null, "<Fail>", -1));
-
- for (int i = 0; i < 20; i++) {
- unitTests.add(new UnitTest(null, "<Pass>", 1));
- }
- */
-
- UnitTest [] uta = new UnitTest[unitTests.size()];
- uta = unitTests.toArray(uta);
-
- mListAllocs = new ScriptField_ListAllocs_s(mRS, uta.length);
- for (int i = 0; i < uta.length; i++) {
- ScriptField_ListAllocs_s.Item listElem = new ScriptField_ListAllocs_s.Item();
- listElem.text = Allocation.createFromString(mRS, uta[i].name, Allocation.USAGE_SCRIPT);
- listElem.result = uta[i].result;
- mListAllocs.set(listElem, i, false);
- uta[i].setItem(listElem);
- }
-
- mListAllocs.copyAll();
-
- mScript.bind_gList(mListAllocs);
-
- mFont = Font.create(mRS, mRes, "serif", Font.Style.BOLD, 8);
- mScript.set_gFont(mFont);
-
- mRS.bindRootScript(mScript);
-
- test_iter = unitTests.listIterator();
- refreshTestResults(); /* Kick off the first test */
-
- TimerTask pTask = new TimerTask() {
- public void run() {
- refreshTestResults();
- }
- };
-
- mTimer = new Timer();
- mTimer.schedule(pTask, RS_TIMER_PERIOD, RS_TIMER_PERIOD);
- }
-
- public void checkAndRunNextTest() {
- if (activeTest != null) {
- if (!activeTest.isAlive()) {
- /* Properly clean up on our last test */
- try {
- activeTest.join();
- }
- catch (InterruptedException e) {
- }
- activeTest = null;
- }
- }
-
- if (!stopTesting && activeTest == null) {
- if (test_iter.hasNext()) {
- activeTest = test_iter.next();
- activeTest.start();
- /* This routine will only get called once when a new test
- * should start running. The message handler in UnitTest.java
- * ensures this. */
- }
- else {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer.purge();
- mTimer = null;
- }
- }
- }
- }
-
- public void refreshTestResults() {
- checkAndRunNextTest();
-
- if (mListAllocs != null && mScript != null && mRS != null) {
- mListAllocs.copyAll();
-
- mScript.bind_gList(mListAllocs);
- mRS.bindRootScript(mScript);
- }
- }
-
- public void cleanup() {
- stopTesting = true;
- UnitTest t = activeTest;
-
- /* Stop periodic refresh of testing */
- if (mTimer != null) {
- mTimer.cancel();
- mTimer.purge();
- mTimer = null;
- }
-
- /* Wait to exit until we finish the current test */
- if (t != null) {
- try {
- t.join();
- }
- catch (InterruptedException e) {
- }
- t = null;
- }
-
- }
-
- public void newTouchPosition(float x, float y, float pressure, int id) {
- }
-
- public void onActionDown(int x, int y) {
- mScript.set_gDY(0.0f);
- mLastX = x;
- mLastY = y;
- refreshTestResults();
- }
-
- public void onActionMove(int x, int y) {
- int dx = mLastX - x;
- int dy = mLastY - y;
-
- if (Math.abs(dy) <= 2) {
- dy = 0;
- }
-
- mScript.set_gDY(dy);
-
- mLastX = x;
- mLastY = y;
- refreshTestResults();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/RSTestView.java b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/RSTestView.java
deleted file mode 100644
index b5bebe9..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/RSTestView.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2008 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.rs.test_v11;
-
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.concurrent.Semaphore;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-
-public class RSTestView extends RSSurfaceView {
-
- private Context mCtx;
-
- public RSTestView(Context context) {
- super(context);
- mCtx = context;
- //setFocusable(true);
- }
-
- private RenderScriptGL mRS;
- private RSTestCore mRender;
-
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- mRS = createRenderScriptGL(sc);
- mRS.setSurface(holder, w, h);
- mRender = new RSTestCore(mCtx);
- mRender.init(mRS, getResources(), w, h);
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- if(mRS != null) {
- mRender.cleanup();
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- return super.onKeyDown(keyCode, event);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev)
- {
- boolean ret = false;
- int act = ev.getAction();
- if (act == ev.ACTION_DOWN) {
- mRender.onActionDown((int)ev.getX(), (int)ev.getY());
- ret = true;
- }
- else if (act == ev.ACTION_MOVE) {
- mRender.onActionMove((int)ev.getX(), (int)ev.getY());
- ret = true;
- }
-
- return ret;
- }
-}
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/RSTest_v11.java b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/RSTest_v11.java
deleted file mode 100644
index 1dedfce..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/RSTest_v11.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2008 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.rs.test_v11;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.provider.Settings.System;
-import android.util.Config;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.ListView;
-
-import java.lang.Runtime;
-
-public class RSTest_v11 extends Activity {
- //EventListener mListener = new EventListener();
-
- private static final String LOG_TAG = "libRS_jni";
- private static final boolean DEBUG = false;
- private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV;
-
- private RSTestView mView;
-
- // get the current looper (from your Activity UI thread for instance
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new RSTestView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onPause();
- mView.pause();
- }
-
- static void log(String message) {
- if (LOG_ENABLED) {
- Log.v(LOG_TAG, message);
- }
- }
-
-
-}
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_fp_mad.java b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_fp_mad.java
deleted file mode 100644
index 5d72aa6..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_fp_mad.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v11;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_fp_mad extends UnitTest {
- private Resources mRes;
-
- protected UT_fp_mad(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Fp_Mad", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_fp_mad s = new ScriptC_fp_mad(pRS, mRes, R.raw.fp_mad);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_fp_mad_test(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_math.java b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_math.java
deleted file mode 100644
index 7e356f8..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_math.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v11;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_math extends UnitTest {
- private Resources mRes;
-
- protected UT_math(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Math", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_math s = new ScriptC_math(pRS, mRes, R.raw.math);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_math_test(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_primitives.java b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_primitives.java
deleted file mode 100644
index dc3efbc..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_primitives.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v11;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_primitives extends UnitTest {
- private Resources mRes;
-
- protected UT_primitives(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Primitives", ctx);
- mRes = res;
- }
-
- private boolean initializeGlobals(ScriptC_primitives s) {
- float pF = s.get_floatTest();
- if (pF != 1.99f) {
- return false;
- }
- s.set_floatTest(2.99f);
-
- double pD = s.get_doubleTest();
- if (pD != 2.05) {
- return false;
- }
- s.set_doubleTest(3.05);
-
- byte pC = s.get_charTest();
- if (pC != -8) {
- return false;
- }
- s.set_charTest((byte)-16);
-
- short pS = s.get_shortTest();
- if (pS != -16) {
- return false;
- }
- s.set_shortTest((short)-32);
-
- int pI = s.get_intTest();
- if (pI != -32) {
- return false;
- }
- s.set_intTest(-64);
-
- long pL = s.get_longTest();
- if (pL != 17179869184l) {
- return false;
- }
- s.set_longTest(17179869185l);
-
- long puL = s.get_ulongTest();
- if (puL != 4611686018427387904L) {
- return false;
- }
- s.set_ulongTest(4611686018427387903L);
-
-
- long pLL = s.get_longlongTest();
- if (pLL != 68719476736L) {
- return false;
- }
- s.set_longlongTest(68719476735L);
-
- long pu64 = s.get_uint64_tTest();
- if (pu64 != 117179869184l) {
- return false;
- }
- s.set_uint64_tTest(117179869185l);
-
- return true;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_primitives s = new ScriptC_primitives(pRS, mRes, R.raw.primitives);
- pRS.setMessageHandler(mRsMessage);
- if (!initializeGlobals(s)) {
- // initializeGlobals failed
- result = -1;
- } else {
- s.invoke_primitives_test(0, 0);
- pRS.finish();
- waitForMessage();
- }
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_rsdebug.java b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_rsdebug.java
deleted file mode 100644
index 00dbaf5..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_rsdebug.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v11;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_rsdebug extends UnitTest {
- private Resources mRes;
-
- protected UT_rsdebug(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsDebug", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rsdebug s = new ScriptC_rsdebug(pRS, mRes, R.raw.rsdebug);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_test_rsdebug(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_rstime.java b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_rstime.java
deleted file mode 100644
index 5b4c399..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_rstime.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v11;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_rstime extends UnitTest {
- private Resources mRes;
-
- protected UT_rstime(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsTime", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rstime s = new ScriptC_rstime(pRS, mRes, R.raw.rstime);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_test_rstime(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_rstypes.java b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_rstypes.java
deleted file mode 100644
index 72a97c9..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UT_rstypes.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v11;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_rstypes extends UnitTest {
- private Resources mRes;
-
- protected UT_rstypes(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsTypes", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rstypes s = new ScriptC_rstypes(pRS, mRes, R.raw.rstypes);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_test_rstypes(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UnitTest.java b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UnitTest.java
deleted file mode 100644
index b62e535..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/UnitTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v11;
-import android.content.Context;
-import android.renderscript.RenderScript.RSMessageHandler;
-import android.util.Log;
-
-public class UnitTest extends Thread {
- public String name;
- public int result;
- private ScriptField_ListAllocs_s.Item mItem;
- private RSTestCore mRSTC;
- private boolean msgHandled;
- protected Context mCtx;
-
- /* These constants must match those in shared.rsh */
- public static final int RS_MSG_TEST_PASSED = 100;
- public static final int RS_MSG_TEST_FAILED = 101;
-
- private static int numTests = 0;
- public int testID;
-
- protected UnitTest(RSTestCore rstc, String n, int initResult, Context ctx) {
- super();
- mRSTC = rstc;
- name = n;
- msgHandled = false;
- mCtx = ctx;
- result = initResult;
- testID = numTests++;
- }
-
- protected UnitTest(RSTestCore rstc, String n, Context ctx) {
- this(rstc, n, 0, ctx);
- }
-
- protected UnitTest(RSTestCore rstc, Context ctx) {
- this (rstc, "<Unknown>", ctx);
- }
-
- protected UnitTest(Context ctx) {
- this (null, ctx);
- }
-
- protected RSMessageHandler mRsMessage = new RSMessageHandler() {
- public void run() {
- if (result == 0) {
- switch (mID) {
- case RS_MSG_TEST_PASSED:
- result = 1;
- break;
- case RS_MSG_TEST_FAILED:
- result = -1;
- break;
- default:
- android.util.Log.v("RenderScript", "Unit test got unexpected message");
- return;
- }
- }
-
- if (mItem != null) {
- mItem.result = result;
- msgHandled = true;
- try {
- mRSTC.refreshTestResults();
- }
- catch (IllegalStateException e) {
- /* Ignore the case where our message receiver has been
- disconnected. This happens when we leave the application
- before it finishes running all of the unit tests. */
- }
- }
- }
- };
-
- public void waitForMessage() {
- while (!msgHandled) {
- yield();
- }
- }
-
- public void setItem(ScriptField_ListAllocs_s.Item item) {
- mItem = item;
- }
-
- public void run() {
- /* This method needs to be implemented for each subclass */
- if (mRSTC != null) {
- mRSTC.refreshTestResults();
- }
- }
-}
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/fp_mad.rs b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/fp_mad.rs
deleted file mode 100644
index b6f2b2a6..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/fp_mad.rs
+++ /dev/null
@@ -1,174 +0,0 @@
-#include "shared.rsh"
-
-const int TEST_COUNT = 1;
-
-static float data_f1[1025];
-static float4 data_f4[1025];
-
-static void test_mad4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~1 billion ops
- for (int ct=0; ct < 1000 * (1000 / 80); ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = (data_f4[i] * 0.02f +
- data_f4[i+1] * 0.04f +
- data_f4[i+2] * 0.05f +
- data_f4[i+3] * 0.1f +
- data_f4[i+4] * 0.2f +
- data_f4[i+5] * 0.2f +
- data_f4[i+6] * 0.1f +
- data_f4[i+7] * 0.05f +
- data_f4[i+8] * 0.04f +
- data_f4[i+9] * 0.02f + 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_mad4 M ops", 1000.f / time);
-}
-
-static void test_mad(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~1 billion ops
- for (int ct=0; ct < 1000 * (1000 / 20); ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = (data_f1[i] * 0.02f +
- data_f1[i+1] * 0.04f +
- data_f1[i+2] * 0.05f +
- data_f1[i+3] * 0.1f +
- data_f1[i+4] * 0.2f +
- data_f1[i+5] * 0.2f +
- data_f1[i+6] * 0.1f +
- data_f1[i+7] * 0.05f +
- data_f1[i+8] * 0.04f +
- data_f1[i+9] * 0.02f + 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_mad M ops", 1000.f / time);
-}
-
-static void test_norm(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = normalize(data_f4[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_norm M ops", 10.f / time);
-}
-
-static void test_sincos4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10 / 4; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = sin(data_f4[i]) * cos(data_f4[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_sincos4 M ops", 10.f / time);
-}
-
-static void test_sincos(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = sin(data_f1[i]) * cos(data_f1[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_sincos M ops", 10.f / time);
-}
-
-static void test_clamp(uint32_t index) {
- start();
-
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = clamp(data_f1[i], -1.f, 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_clamp M ops", 100.f / time);
-
- start();
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100; ct++) {
- for (int i=0; i < (1000); i++) {
- if (data_f1[i] < -1.f) data_f1[i] = -1.f;
- if (data_f1[i] > -1.f) data_f1[i] = 1.f;
- }
- }
-
- time = end(index);
- rsDebug("fp_clamp ref M ops", 100.f / time);
-}
-
-static void test_clamp4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100 /4; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = clamp(data_f4[i], -1.f, 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_clamp4 M ops", 100.f / time);
-}
-
-void fp_mad_test(uint32_t index, int test_num) {
- int x;
- for (x=0; x < 1025; x++) {
- data_f1[x] = (x & 0xf) * 0.1f;
- data_f4[x].x = (x & 0xf) * 0.1f;
- data_f4[x].y = (x & 0xf0) * 0.1f;
- data_f4[x].z = (x & 0x33) * 0.1f;
- data_f4[x].w = (x & 0x77) * 0.1f;
- }
-
- test_mad4(index);
- test_mad(index);
-
- for (x=0; x < 1025; x++) {
- data_f1[x] = (x & 0xf) * 0.1f + 1.f;
- data_f4[x].x = (x & 0xf) * 0.1f + 1.f;
- data_f4[x].y = (x & 0xf0) * 0.1f + 1.f;
- data_f4[x].z = (x & 0x33) * 0.1f + 1.f;
- data_f4[x].w = (x & 0x77) * 0.1f + 1.f;
- }
-
- test_norm(index);
- test_sincos4(index);
- test_sincos(index);
- test_clamp4(index);
- test_clamp(index);
-
- // TODO Actually verify test result accuracy
- rsDebug("fp_mad_test PASSED", 0);
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
-}
-
-
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/math.rs b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/math.rs
deleted file mode 100644
index 2867be1..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/math.rs
+++ /dev/null
@@ -1,348 +0,0 @@
-#include "shared.rsh"
-
-// Testing math library
-
-volatile float f1;
-volatile float2 f2;
-volatile float3 f3;
-volatile float4 f4;
-
-volatile int i1;
-volatile int2 i2;
-volatile int3 i3;
-volatile int4 i4;
-
-volatile uint ui1;
-volatile uint2 ui2;
-volatile uint3 ui3;
-volatile uint4 ui4;
-
-volatile short s1;
-volatile short2 s2;
-volatile short3 s3;
-volatile short4 s4;
-
-volatile ushort us1;
-volatile ushort2 us2;
-volatile ushort3 us3;
-volatile ushort4 us4;
-
-volatile char c1;
-volatile char2 c2;
-volatile char3 c3;
-volatile char4 c4;
-
-volatile uchar uc1;
-volatile uchar2 uc2;
-volatile uchar3 uc3;
-volatile uchar4 uc4;
-
-#define TEST_FN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1); \
- f2 = fnc(f2); \
- f3 = fnc(f3); \
- f4 = fnc(f4);
-
-#define TEST_FN_FUNC_FN_PFN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (float*) &f1); \
- f2 = fnc(f2, (float2*) &f2); \
- f3 = fnc(f3, (float3*) &f3); \
- f4 = fnc(f4, (float4*) &f4);
-
-#define TEST_FN_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f2); \
- f3 = fnc(f3, f3); \
- f4 = fnc(f4, f4);
-
-#define TEST_FN_FUNC_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f1); \
- f3 = fnc(f3, f1); \
- f4 = fnc(f4, f1);
-
-#define TEST_FN_FUNC_FN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i2); \
- f3 = fnc(f3, i3); \
- f4 = fnc(f4, i4);
-
-#define TEST_FN_FUNC_FN_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i1); \
- f3 = fnc(f3, i1); \
- f4 = fnc(f4, i1);
-
-#define TEST_FN_FUNC_FN_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, f1); \
- f2 = fnc(f2, f2, f2); \
- f3 = fnc(f3, f3, f3); \
- f4 = fnc(f4, f4, f4);
-
-#define TEST_FN_FUNC_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (int*) &i1); \
- f2 = fnc(f2, (int2*) &i2); \
- f3 = fnc(f3, (int3*) &i3); \
- f4 = fnc(f4, (int4*) &i4);
-
-#define TEST_FN_FUNC_FN_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, (int*) &i1); \
- f2 = fnc(f2, f2, (int2*) &i2); \
- f3 = fnc(f3, f3, (int3*) &i3); \
- f4 = fnc(f4, f4, (int4*) &i4);
-
-#define TEST_IN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- i1 = fnc(f1); \
- i2 = fnc(f2); \
- i3 = fnc(f3); \
- i4 = fnc(f4);
-
-
-static bool test_fp_math(uint32_t index) {
- bool failed = false;
- start();
-
- TEST_FN_FUNC_FN(acos);
- TEST_FN_FUNC_FN(acosh);
- TEST_FN_FUNC_FN(acospi);
- TEST_FN_FUNC_FN(asin);
- TEST_FN_FUNC_FN(asinh);
- TEST_FN_FUNC_FN(asinpi);
- TEST_FN_FUNC_FN(atan);
- TEST_FN_FUNC_FN_FN(atan2);
- TEST_FN_FUNC_FN(atanh);
- TEST_FN_FUNC_FN(atanpi);
- TEST_FN_FUNC_FN_FN(atan2pi);
- TEST_FN_FUNC_FN(cbrt);
- TEST_FN_FUNC_FN(ceil);
- TEST_FN_FUNC_FN_FN(copysign);
- TEST_FN_FUNC_FN(cos);
- TEST_FN_FUNC_FN(cosh);
- TEST_FN_FUNC_FN(cospi);
- TEST_FN_FUNC_FN(erfc);
- TEST_FN_FUNC_FN(erf);
- TEST_FN_FUNC_FN(exp);
- TEST_FN_FUNC_FN(exp2);
- TEST_FN_FUNC_FN(exp10);
- TEST_FN_FUNC_FN(expm1);
- TEST_FN_FUNC_FN(fabs);
- TEST_FN_FUNC_FN_FN(fdim);
- TEST_FN_FUNC_FN(floor);
- TEST_FN_FUNC_FN_FN_FN(fma);
- TEST_FN_FUNC_FN_FN(fmax);
- TEST_FN_FUNC_FN_F(fmax);
- TEST_FN_FUNC_FN_FN(fmin);
- TEST_FN_FUNC_FN_F(fmin);
- TEST_FN_FUNC_FN_FN(fmod);
- TEST_FN_FUNC_FN_PFN(fract);
- TEST_FN_FUNC_FN_PIN(frexp);
- TEST_FN_FUNC_FN_FN(hypot);
- TEST_IN_FUNC_FN(ilogb);
- TEST_FN_FUNC_FN_IN(ldexp);
- TEST_FN_FUNC_FN_I(ldexp);
- TEST_FN_FUNC_FN(lgamma);
- TEST_FN_FUNC_FN_PIN(lgamma);
- TEST_FN_FUNC_FN(log);
- TEST_FN_FUNC_FN(log2);
- TEST_FN_FUNC_FN(log10);
- TEST_FN_FUNC_FN(log1p);
- TEST_FN_FUNC_FN(logb);
- TEST_FN_FUNC_FN_FN_FN(mad);
- TEST_FN_FUNC_FN_PFN(modf);
- // nan
- TEST_FN_FUNC_FN_FN(nextafter);
- TEST_FN_FUNC_FN_FN(pow);
- TEST_FN_FUNC_FN_IN(pown);
- TEST_FN_FUNC_FN_FN(powr);
- TEST_FN_FUNC_FN_FN(remainder);
- TEST_FN_FUNC_FN_FN_PIN(remquo);
- TEST_FN_FUNC_FN(rint);
- TEST_FN_FUNC_FN_IN(rootn);
- TEST_FN_FUNC_FN(round);
- TEST_FN_FUNC_FN(rsqrt);
- TEST_FN_FUNC_FN(sin);
- TEST_FN_FUNC_FN_PFN(sincos);
- TEST_FN_FUNC_FN(sinh);
- TEST_FN_FUNC_FN(sinpi);
- TEST_FN_FUNC_FN(sqrt);
- TEST_FN_FUNC_FN(tan);
- TEST_FN_FUNC_FN(tanh);
- TEST_FN_FUNC_FN(tanpi);
- TEST_FN_FUNC_FN(tgamma);
- TEST_FN_FUNC_FN(trunc);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_fp_math FAILED", time);
- }
- else {
- rsDebug("test_fp_math PASSED", time);
- }
-
- return failed;
-}
-
-#define DECL_INT(prefix) \
-volatile char prefix##_c_1 = 1; \
-volatile char2 prefix##_c_2 = 1; \
-volatile char3 prefix##_c_3 = 1; \
-volatile char4 prefix##_c_4 = 1; \
-volatile uchar prefix##_uc_1 = 1; \
-volatile uchar2 prefix##_uc_2 = 1; \
-volatile uchar3 prefix##_uc_3 = 1; \
-volatile uchar4 prefix##_uc_4 = 1; \
-volatile short prefix##_s_1 = 1; \
-volatile short2 prefix##_s_2 = 1; \
-volatile short3 prefix##_s_3 = 1; \
-volatile short4 prefix##_s_4 = 1; \
-volatile ushort prefix##_us_1 = 1; \
-volatile ushort2 prefix##_us_2 = 1; \
-volatile ushort3 prefix##_us_3 = 1; \
-volatile ushort4 prefix##_us_4 = 1; \
-volatile int prefix##_i_1 = 1; \
-volatile int2 prefix##_i_2 = 1; \
-volatile int3 prefix##_i_3 = 1; \
-volatile int4 prefix##_i_4 = 1; \
-volatile uint prefix##_ui_1 = 1; \
-volatile uint2 prefix##_ui_2 = 1; \
-volatile uint3 prefix##_ui_3 = 1; \
-volatile uint4 prefix##_ui_4 = 1; \
-volatile long prefix##_l_1 = 1; \
-volatile ulong prefix##_ul_1 = 1;
-
-#define TEST_INT_OP_TYPE(op, type) \
-rsDebug("Testing " #op " for " #type "1", i++); \
-res_##type##_1 = src1_##type##_1 op src2_##type##_1; \
-rsDebug("Testing " #op " for " #type "2", i++); \
-res_##type##_2 = src1_##type##_2 op src2_##type##_2; \
-rsDebug("Testing " #op " for " #type "3", i++); \
-res_##type##_3 = src1_##type##_3 op src2_##type##_3; \
-rsDebug("Testing " #op " for " #type "4", i++); \
-res_##type##_4 = src1_##type##_4 op src2_##type##_4;
-
-#define TEST_INT_OP(op) \
-TEST_INT_OP_TYPE(op, c) \
-TEST_INT_OP_TYPE(op, uc) \
-TEST_INT_OP_TYPE(op, s) \
-TEST_INT_OP_TYPE(op, us) \
-TEST_INT_OP_TYPE(op, i) \
-TEST_INT_OP_TYPE(op, ui) \
-rsDebug("Testing " #op " for l1", i++); \
-res_l_1 = src1_l_1 op src2_l_1; \
-rsDebug("Testing " #op " for ul1", i++); \
-res_ul_1 = src1_ul_1 op src2_ul_1;
-
-DECL_INT(res)
-DECL_INT(src1)
-DECL_INT(src2)
-
-static bool test_basic_operators() {
- bool failed = false;
- int i = 0;
-
- TEST_INT_OP(+);
- TEST_INT_OP(-);
- TEST_INT_OP(*);
- TEST_INT_OP(/);
- TEST_INT_OP(%);
- TEST_INT_OP(<<);
- TEST_INT_OP(>>);
-
- if (failed) {
- rsDebug("test_basic_operators FAILED", 0);
- }
- else {
- rsDebug("test_basic_operators PASSED", 0);
- }
-
- return failed;
-}
-
-#define TEST_CVT(to, from, type) \
-rsDebug("Testing convert from " #from " to " #to, 0); \
-to##1 = from##1; \
-to##2 = convert_##type##2(from##2); \
-to##3 = convert_##type##3(from##3); \
-to##4 = convert_##type##4(from##4);
-
-#define TEST_CVT_MATRIX(to, type) \
-TEST_CVT(to, c, type); \
-TEST_CVT(to, uc, type); \
-TEST_CVT(to, s, type); \
-TEST_CVT(to, us, type); \
-TEST_CVT(to, i, type); \
-TEST_CVT(to, ui, type); \
-TEST_CVT(to, f, type); \
-
-static bool test_convert() {
- bool failed = false;
-
- TEST_CVT_MATRIX(c, char);
- TEST_CVT_MATRIX(uc, uchar);
- TEST_CVT_MATRIX(s, short);
- TEST_CVT_MATRIX(us, ushort);
- TEST_CVT_MATRIX(i, int);
- TEST_CVT_MATRIX(ui, uint);
- TEST_CVT_MATRIX(f, float);
-
- if (failed) {
- rsDebug("test_convert FAILED", 0);
- }
- else {
- rsDebug("test_convert PASSED", 0);
- }
-
- return failed;
-}
-
-#define INIT_PREFIX_TYPE(prefix, type) \
-prefix##_##type##_1 = 1; \
-prefix##_##type##_2.x = 1; \
-prefix##_##type##_2.y = 1; \
-prefix##_##type##_3.x = 1; \
-prefix##_##type##_3.y = 1; \
-prefix##_##type##_3.z = 1; \
-prefix##_##type##_4.x = 1; \
-prefix##_##type##_4.y = 1; \
-prefix##_##type##_4.z = 1; \
-prefix##_##type##_4.w = 1;
-
-#define INIT_TYPE(type) \
-INIT_PREFIX_TYPE(src1, type) \
-INIT_PREFIX_TYPE(src2, type) \
-INIT_PREFIX_TYPE(res, type)
-
-#define INIT_ALL \
-INIT_TYPE(c); \
-INIT_TYPE(uc); \
-INIT_TYPE(s); \
-INIT_TYPE(us); \
-INIT_TYPE(i); \
-INIT_TYPE(ui);
-
-void math_test(uint32_t index, int test_num) {
- bool failed = false;
- INIT_ALL;
- failed |= test_convert();
- failed |= test_fp_math(index);
- failed |= test_basic_operators();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/primitives.rs b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/primitives.rs
deleted file mode 100644
index ce451da..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/primitives.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "shared.rsh"
-
-// Testing primitive types
-float floatTest = 1.99f;
-double doubleTest = 2.05;
-char charTest = -8;
-short shortTest = -16;
-int intTest = -32;
-long longTest = 17179869184l; // 1 << 34
-long long longlongTest = 68719476736l; // 1 << 36
-
-uchar ucharTest = 8;
-ushort ushortTest = 16;
-uint uintTest = 32;
-ulong ulongTest = 4611686018427387904L;
-int64_t int64_tTest = -17179869184l; // - 1 << 34
-uint64_t uint64_tTest = 117179869184l;
-
-static bool test_primitive_types(uint32_t index) {
- bool failed = false;
- start();
-
- _RS_ASSERT(floatTest == 2.99f);
- _RS_ASSERT(doubleTest == 3.05);
- _RS_ASSERT(charTest == -16);
- _RS_ASSERT(shortTest == -32);
- _RS_ASSERT(intTest == -64);
- _RS_ASSERT(longTest == 17179869185l);
- _RS_ASSERT(longlongTest == 68719476735l);
-
- _RS_ASSERT(ucharTest == 8);
- _RS_ASSERT(ushortTest == 16);
- _RS_ASSERT(uintTest == 32);
- _RS_ASSERT(ulongTest == 4611686018427387903L);
- _RS_ASSERT(int64_tTest == -17179869184l);
- _RS_ASSERT(uint64_tTest == 117179869185l);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_primitives FAILED", time);
- }
- else {
- rsDebug("test_primitives PASSED", time);
- }
-
- return failed;
-}
-
-void primitives_test(uint32_t index, int test_num) {
- bool failed = false;
- failed |= test_primitive_types(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rsdebug.rs b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rsdebug.rs
deleted file mode 100644
index f7942a5..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rsdebug.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "shared.rsh"
-
-// Testing primitive types
-float floatTest = 1.99f;
-double doubleTest = 2.05;
-char charTest = -8;
-short shortTest = -16;
-int intTest = -32;
-long longTest = 17179869184l; // 1 << 34
-long long longlongTest = 68719476736l; // 1 << 36
-
-uchar ucharTest = 8;
-ushort ushortTest = 16;
-uint uintTest = 32;
-ulong ulongTest = 4611686018427387904L;
-int64_t int64_tTest = -17179869184l; // - 1 << 34
-uint64_t uint64_tTest = 117179869184l;
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- // This test focuses primarily on compilation-time, not run-time.
- // For this reason, none of the outputs are actually checked.
-
- rsDebug("floatTest", floatTest);
- rsDebug("doubleTest", doubleTest);
- rsDebug("charTest", charTest);
- rsDebug("shortTest", shortTest);
- rsDebug("intTest", intTest);
- rsDebug("longTest", longTest);
- rsDebug("longlongTest", longlongTest);
-
- rsDebug("ucharTest", ucharTest);
- rsDebug("ushortTest", ushortTest);
- rsDebug("uintTest", uintTest);
- rsDebug("ulongTest", ulongTest);
- rsDebug("int64_tTest", int64_tTest);
- rsDebug("uint64_tTest", uint64_tTest);
-
- return failed;
-}
-
-void test_rsdebug(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rsdebug_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rsdebug_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rslist.rs b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rslist.rs
deleted file mode 100644
index 5b2501f..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rslist.rs
+++ /dev/null
@@ -1,107 +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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test_v11)
-
-#include "rs_graphics.rsh"
-
-float gDY;
-
-rs_font gFont;
-
-typedef struct ListAllocs_s {
- rs_allocation text;
- int result;
-} ListAllocs;
-
-ListAllocs *gList;
-
-void init() {
- gDY = 0.0f;
-}
-
-int textPos = 0;
-
-int root(int launchID) {
-
- rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- rsgClearDepth(1.0f);
-
- textPos -= (int)gDY*2;
- gDY *= 0.95;
-
- rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f);
- rsgBindFont(gFont);
-
- rs_allocation listAlloc;
- rsSetObject(&listAlloc, rsGetAllocation(gList));
- int allocSize = rsAllocationGetDimX(listAlloc);
-
- int width = rsgGetWidth();
- int height = rsgGetHeight();
-
- int itemHeight = 80;
- int totalItemHeight = itemHeight * allocSize;
-
- /* Prevent scrolling above the top of the list */
- int firstItem = height - totalItemHeight;
- if (firstItem < 0) {
- firstItem = 0;
- }
-
- /* Prevent scrolling past the last line of the list */
- int lastItem = -1 * (totalItemHeight - height);
- if (lastItem > 0) {
- lastItem = 0;
- }
-
- if (textPos > firstItem) {
- textPos = firstItem;
- }
- else if (textPos < lastItem) {
- textPos = lastItem;
- }
-
- int currentYPos = itemHeight + textPos;
-
- for(int i = 0; i < allocSize; i ++) {
- if(currentYPos - itemHeight > height) {
- break;
- }
-
- if(currentYPos > 0) {
- switch(gList[i].result) {
- case 1: /* Passed */
- rsgFontColor(0.5f, 0.9f, 0.5f, 1.0f);
- break;
- case -1: /* Failed */
- rsgFontColor(0.9f, 0.5f, 0.5f, 1.0f);
- break;
- case 0: /* Still Testing */
- rsgFontColor(0.9f, 0.9f, 0.5f, 1.0f);
- break;
- default: /* Unknown */
- rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f);
- break;
- }
- rsgDrawRect(0, currentYPos - 1, width, currentYPos, 0);
- rsgDrawText(gList[i].text, 30, currentYPos - 32);
- }
- currentYPos += itemHeight;
- }
-
- return 10;
-}
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rstime.rs b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rstime.rs
deleted file mode 100644
index 5e3e078..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rstime.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "shared.rsh"
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- rs_time_t curTime = rsTime(0);
- rs_tm tm;
- rsDebug("curTime", curTime);
-
- rsLocaltime(&tm, &curTime);
-
- rsDebug("tm.tm_sec", tm.tm_sec);
- rsDebug("tm.tm_min", tm.tm_min);
- rsDebug("tm.tm_hour", tm.tm_hour);
- rsDebug("tm.tm_mday", tm.tm_mday);
- rsDebug("tm.tm_mon", tm.tm_mon);
- rsDebug("tm.tm_year", tm.tm_year);
- rsDebug("tm.tm_wday", tm.tm_wday);
- rsDebug("tm.tm_yday", tm.tm_yday);
- rsDebug("tm.tm_isdst", tm.tm_isdst);
-
- // Test a specific time (only valid for PST localtime)
- curTime = 1294438893;
- rsLocaltime(&tm, &curTime);
-
- _RS_ASSERT(tm.tm_sec == 33);
- _RS_ASSERT(tm.tm_min == 21);
- _RS_ASSERT(tm.tm_hour == 14);
- _RS_ASSERT(tm.tm_mday == 7);
- _RS_ASSERT(tm.tm_mon == 0);
- _RS_ASSERT(tm.tm_year == 111);
- _RS_ASSERT(tm.tm_wday == 5);
- _RS_ASSERT(tm.tm_yday == 6);
- _RS_ASSERT(tm.tm_isdst == 0);
-
- return failed;
-}
-
-void test_rstime(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rstime_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rstime_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rstypes.rs b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rstypes.rs
deleted file mode 100644
index f3bf244..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/rstypes.rs
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "shared.rsh"
-#include "rs_graphics.rsh"
-
-rs_element elementTest;
-rs_type typeTest;
-rs_allocation allocationTest;
-rs_sampler samplerTest;
-rs_script scriptTest;
-rs_mesh meshTest;
-rs_program_fragment program_fragmentTest;
-rs_program_vertex program_vertexTest;
-rs_program_raster program_rasterTest;
-rs_program_store program_storeTest;
-rs_font fontTest;
-
-rs_matrix4x4 matrix4x4Test;
-rs_matrix3x3 matrix3x3Test;
-rs_matrix2x2 matrix2x2Test;
-
-struct my_struct {
- int i;
- rs_font fontTestStruct;
-};
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- rs_matrix4x4 matrix4x4TestLocal;
- rs_matrix3x3 matrix3x3TestLocal;
- rs_matrix2x2 matrix2x2TestLocal;
-
- // This test focuses primarily on compilation-time, not run-time.
- rs_element elementTestLocal;
- rs_type typeTestLocal;
- rs_allocation allocationTestLocal;
- rs_sampler samplerTestLocal;
- rs_script scriptTestLocal;
- rs_mesh meshTestLocal;
- rs_program_fragment program_fragmentTestLocal;
- rs_program_vertex program_vertexTestLocal;
- rs_program_raster program_rasterTestLocal;
- rs_program_store program_storeTestLocal;
- rs_font fontTestLocal;
-
- rs_font fontTestLocalArray[4];
-
- rs_font fontTestLocalPreInit = fontTest;
-
- struct my_struct structTest;
-
- rsSetObject(&fontTestLocal, fontTest);
- //allocationTestLocal = allocationTest;
-
- rsSetObject(&fontTest, fontTestLocal);
- //allocationTest = allocationTestLocal;
-
- /*for (int i = 0; i < 4; i++) {
- rsSetObject(&fontTestLocalArray[i], fontTestLocal);
- }*/
-
- /*rsSetObject(&fontTest, fontTestLocalArray[3]);*/
-
- return failed;
-}
-
-void test_rstypes(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rstypes_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rstypes_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/shared.rsh b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/shared.rsh
deleted file mode 100644
index 6d34481..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/shared.rsh
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test_v11)
-
-typedef struct TestResult_s {
- rs_allocation name;
- bool pass;
- float score;
- int64_t time;
-} TestResult;
-//TestResult *g_results;
-
-static int64_t g_time;
-
-static void start(void) {
- g_time = rsUptimeMillis();
-}
-
-static float end(uint32_t idx) {
- int64_t t = rsUptimeMillis() - g_time;
- //g_results[idx].time = t;
- //rsDebug("test time", (int)t);
- return ((float)t) / 1000.f;
-}
-
-#define _RS_ASSERT(b) \
-do { \
- if (!(b)) { \
- failed = true; \
- rsDebug(#b " FAILED", 0); \
- } \
-\
-} while (0)
-
-/* These constants must match those in UnitTest.java */
-static const int RS_MSG_TEST_PASSED = 100;
-static const int RS_MSG_TEST_FAILED = 101;
-
diff --git a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/test_root.rs b/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/test_root.rs
deleted file mode 100644
index 6dc83ba..0000000
--- a/tests/RenderScriptTests/tests_v11/src/com/android/rs/test/test_root.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Fountain test script
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test)
-
-#pragma stateFragment(parent)
-
-#include "rs_graphics.rsh"
-
-
-typedef struct TestResult {
- rs_allocation name;
- bool pass;
- float score;
-} TestResult_t;
-TestResult_t *results;
-
-int root() {
-
- return 0;
-}
-
-
diff --git a/tests/RenderScriptTests/tests_v14/Android.mk b/tests/RenderScriptTests/tests_v14/Android.mk
deleted file mode 100644
index a4386a44..0000000
--- a/tests/RenderScriptTests/tests_v14/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2008 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := RSTest_v14
-LOCAL_SDK_VERSION := 14
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/tests_v14/AndroidManifest.xml b/tests/RenderScriptTests/tests_v14/AndroidManifest.xml
deleted file mode 100644
index 1cd9bbd..0000000
--- a/tests/RenderScriptTests/tests_v14/AndroidManifest.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.rs.test_v14">
- <uses-sdk android:minSdkVersion="14" />
- <application
- android:label="_RS_Test_v14"
- android:icon="@drawable/test_pattern">
- <activity android:name="RSTest_v14"
- android:screenOrientation="portrait">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/tests_v14/res/drawable-nodpi/test_pattern.png b/tests/RenderScriptTests/tests_v14/res/drawable-nodpi/test_pattern.png
deleted file mode 100644
index e7d1455..0000000
--- a/tests/RenderScriptTests/tests_v14/res/drawable-nodpi/test_pattern.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/RSTestCore.java
deleted file mode 100644
index f1e81a4..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/RSTestCore.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2008-2011 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.rs.test_v14;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-import java.util.ArrayList;
-import java.util.ListIterator;
-import java.util.Timer;
-import java.util.TimerTask;
-
-
-public class RSTestCore {
- int mWidth;
- int mHeight;
- Context mCtx;
-
- public RSTestCore(Context ctx) {
- mCtx = ctx;
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
-
- private Font mFont;
- ScriptField_ListAllocs_s mListAllocs;
- int mLastX;
- int mLastY;
- private ScriptC_rslist mScript;
-
- private ArrayList<UnitTest> unitTests;
- private ListIterator<UnitTest> test_iter;
- private UnitTest activeTest;
- private boolean stopTesting;
-
- /* Periodic timer for ensuring future tests get scheduled */
- private Timer mTimer;
- public static final int RS_TIMER_PERIOD = 100;
-
- public void init(RenderScriptGL rs, Resources res, int width, int height) {
- mRS = rs;
- mRes = res;
- mWidth = width;
- mHeight = height;
- stopTesting = false;
-
- mScript = new ScriptC_rslist(mRS, mRes, R.raw.rslist);
-
- unitTests = new ArrayList<UnitTest>();
-
- unitTests.add(new UT_primitives(this, mRes, mCtx));
- unitTests.add(new UT_vector(this, mRes, mCtx));
- unitTests.add(new UT_rsdebug(this, mRes, mCtx));
- unitTests.add(new UT_rstime(this, mRes, mCtx));
- unitTests.add(new UT_rstypes(this, mRes, mCtx));
- unitTests.add(new UT_alloc(this, mRes, mCtx));
- unitTests.add(new UT_refcount(this, mRes, mCtx));
- unitTests.add(new UT_foreach(this, mRes, mCtx));
- unitTests.add(new UT_math(this, mRes, mCtx));
- unitTests.add(new UT_fp_mad(this, mRes, mCtx));
- /*
- unitTests.add(new UnitTest(null, "<Pass>", 1));
- unitTests.add(new UnitTest());
- unitTests.add(new UnitTest(null, "<Fail>", -1));
-
- for (int i = 0; i < 20; i++) {
- unitTests.add(new UnitTest(null, "<Pass>", 1));
- }
- */
-
- UnitTest [] uta = new UnitTest[unitTests.size()];
- uta = unitTests.toArray(uta);
-
- mListAllocs = new ScriptField_ListAllocs_s(mRS, uta.length);
- for (int i = 0; i < uta.length; i++) {
- ScriptField_ListAllocs_s.Item listElem = new ScriptField_ListAllocs_s.Item();
- listElem.text = Allocation.createFromString(mRS, uta[i].name, Allocation.USAGE_SCRIPT);
- listElem.result = uta[i].result;
- mListAllocs.set(listElem, i, false);
- uta[i].setItem(listElem);
- }
-
- mListAllocs.copyAll();
-
- mScript.bind_gList(mListAllocs);
-
- mFont = Font.create(mRS, mRes, "serif", Font.Style.BOLD, 8);
- mScript.set_gFont(mFont);
-
- mRS.bindRootScript(mScript);
-
- test_iter = unitTests.listIterator();
- refreshTestResults(); /* Kick off the first test */
-
- TimerTask pTask = new TimerTask() {
- public void run() {
- refreshTestResults();
- }
- };
-
- mTimer = new Timer();
- mTimer.schedule(pTask, RS_TIMER_PERIOD, RS_TIMER_PERIOD);
- }
-
- public void checkAndRunNextTest() {
- if (activeTest != null) {
- if (!activeTest.isAlive()) {
- /* Properly clean up on our last test */
- try {
- activeTest.join();
- }
- catch (InterruptedException e) {
- }
- activeTest = null;
- }
- }
-
- if (!stopTesting && activeTest == null) {
- if (test_iter.hasNext()) {
- activeTest = test_iter.next();
- activeTest.start();
- /* This routine will only get called once when a new test
- * should start running. The message handler in UnitTest.java
- * ensures this. */
- }
- else {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer.purge();
- mTimer = null;
- }
- }
- }
- }
-
- public void refreshTestResults() {
- checkAndRunNextTest();
-
- if (mListAllocs != null && mScript != null && mRS != null) {
- mListAllocs.copyAll();
-
- mScript.bind_gList(mListAllocs);
- mRS.bindRootScript(mScript);
- }
- }
-
- public void cleanup() {
- stopTesting = true;
- UnitTest t = activeTest;
-
- /* Stop periodic refresh of testing */
- if (mTimer != null) {
- mTimer.cancel();
- mTimer.purge();
- mTimer = null;
- }
-
- /* Wait to exit until we finish the current test */
- if (t != null) {
- try {
- t.join();
- }
- catch (InterruptedException e) {
- }
- t = null;
- }
-
- }
-
- public void newTouchPosition(float x, float y, float pressure, int id) {
- }
-
- public void onActionDown(int x, int y) {
- mScript.set_gDY(0.0f);
- mLastX = x;
- mLastY = y;
- refreshTestResults();
- }
-
- public void onActionMove(int x, int y) {
- int dx = mLastX - x;
- int dy = mLastY - y;
-
- if (Math.abs(dy) <= 2) {
- dy = 0;
- }
-
- mScript.set_gDY(dy);
-
- mLastX = x;
- mLastY = y;
- refreshTestResults();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/RSTestView.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/RSTestView.java
deleted file mode 100644
index 40192e4..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/RSTestView.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2008 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.rs.test_v14;
-
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.concurrent.Semaphore;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-
-public class RSTestView extends RSSurfaceView {
-
- private Context mCtx;
-
- public RSTestView(Context context) {
- super(context);
- mCtx = context;
- //setFocusable(true);
- }
-
- private RenderScriptGL mRS;
- private RSTestCore mRender;
-
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- mRS = createRenderScriptGL(sc);
- mRS.setSurface(holder, w, h);
- mRender = new RSTestCore(mCtx);
- mRender.init(mRS, getResources(), w, h);
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- if(mRS != null) {
- mRender.cleanup();
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- return super.onKeyDown(keyCode, event);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev)
- {
- boolean ret = false;
- int act = ev.getAction();
- if (act == ev.ACTION_DOWN) {
- mRender.onActionDown((int)ev.getX(), (int)ev.getY());
- ret = true;
- }
- else if (act == ev.ACTION_MOVE) {
- mRender.onActionMove((int)ev.getX(), (int)ev.getY());
- ret = true;
- }
-
- return ret;
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/RSTest_v14.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/RSTest_v14.java
deleted file mode 100644
index da09691..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/RSTest_v14.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2008 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.rs.test_v14;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.provider.Settings.System;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.ListView;
-
-import java.lang.Runtime;
-
-public class RSTest_v14 extends Activity {
- //EventListener mListener = new EventListener();
-
- private static final String LOG_TAG = "RSTest_v14";
- private static final boolean DEBUG = false;
- private static final boolean LOG_ENABLED = false;
-
- private RSTestView mView;
-
- // get the current looper (from your Activity UI thread for instance
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new RSTestView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onPause();
- mView.pause();
- }
-
- @Override
- protected void onStop() {
- // Actually kill the app if we are stopping. We don't want to
- // continue/resume this test ever. It should always start fresh.
- finish();
- super.onStop();
- }
-
- static void log(String message) {
- if (LOG_ENABLED) {
- Log.v(LOG_TAG, message);
- }
- }
-
-
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_alloc.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_alloc.java
deleted file mode 100644
index 079fcce..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_alloc.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test_v14;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_alloc extends UnitTest {
- private Resources mRes;
-
- protected UT_alloc(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Alloc", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_alloc s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- int Y = 7;
- int Z = 0;
- s.set_dimX(X);
- s.set_dimY(Y);
- s.set_dimZ(Z);
- typeBuilder.setX(X).setY(Y);
- Allocation A = Allocation.createTyped(RS, typeBuilder.create());
- s.bind_a(A);
- s.set_aRaw(A);
-
- typeBuilder = new Type.Builder(RS, Element.I32(RS));
- typeBuilder.setX(X).setY(Y).setFaces(true);
- Allocation AFaces = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aFaces(AFaces);
- typeBuilder.setFaces(false).setMipmaps(true);
- Allocation ALOD = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aLOD(ALOD);
- typeBuilder.setFaces(true).setMipmaps(true);
- Allocation AFacesLOD = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aFacesLOD(AFacesLOD);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_alloc s = new ScriptC_alloc(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_root(s.get_aRaw());
- s.invoke_alloc_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_foreach.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_foreach.java
deleted file mode 100644
index 31f4114..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_foreach.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test_v14;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_foreach extends UnitTest {
- private Resources mRes;
- private Allocation A;
-
- protected UT_foreach(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "ForEach", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_foreach s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 5;
- int Y = 7;
- s.set_dimX(X);
- s.set_dimY(Y);
- typeBuilder.setX(X).setY(Y);
- A = Allocation.createTyped(RS, typeBuilder.create());
- s.set_aRaw(A);
-
- return;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_foreach s = new ScriptC_foreach(pRS);
- pRS.setMessageHandler(mRsMessage);
- initializeGlobals(pRS, s);
- s.forEach_root(A);
- s.invoke_verify_root();
- s.invoke_foreach_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_fp_mad.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_fp_mad.java
deleted file mode 100644
index 239496a..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_fp_mad.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v14;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_fp_mad extends UnitTest {
- private Resources mRes;
-
- protected UT_fp_mad(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Fp_Mad", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_fp_mad s = new ScriptC_fp_mad(pRS, mRes, R.raw.fp_mad);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_fp_mad_test(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_math.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_math.java
deleted file mode 100644
index 7b135c4..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_math.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v14;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_math extends UnitTest {
- private Resources mRes;
-
- protected UT_math(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Math", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_math s = new ScriptC_math(pRS, mRes, R.raw.math);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_math_test(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_primitives.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_primitives.java
deleted file mode 100644
index d3c56f3..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_primitives.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v14;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_primitives extends UnitTest {
- private Resources mRes;
-
- protected UT_primitives(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Primitives", ctx);
- mRes = res;
- }
-
- private boolean initializeGlobals(ScriptC_primitives s) {
- float pF = s.get_floatTest();
- if (pF != 1.99f) {
- return false;
- }
- s.set_floatTest(2.99f);
-
- double pD = s.get_doubleTest();
- if (pD != 2.05) {
- return false;
- }
- s.set_doubleTest(3.05);
-
- byte pC = s.get_charTest();
- if (pC != -8) {
- return false;
- }
- s.set_charTest((byte)-16);
-
- short pS = s.get_shortTest();
- if (pS != -16) {
- return false;
- }
- s.set_shortTest((short)-32);
-
- int pI = s.get_intTest();
- if (pI != -32) {
- return false;
- }
- s.set_intTest(-64);
-
- long pL = s.get_longTest();
- if (pL != 17179869184l) {
- return false;
- }
- s.set_longTest(17179869185l);
-
- long puL = s.get_ulongTest();
- if (puL != 4611686018427387904L) {
- return false;
- }
- s.set_ulongTest(4611686018427387903L);
-
-
- long pLL = s.get_longlongTest();
- if (pLL != 68719476736L) {
- return false;
- }
- s.set_longlongTest(68719476735L);
-
- long pu64 = s.get_uint64_tTest();
- if (pu64 != 117179869184l) {
- return false;
- }
- s.set_uint64_tTest(117179869185l);
-
- return true;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_primitives s = new ScriptC_primitives(pRS, mRes, R.raw.primitives);
- pRS.setMessageHandler(mRsMessage);
- if (!initializeGlobals(s)) {
- // initializeGlobals failed
- result = -1;
- } else {
- s.invoke_primitives_test(0, 0);
- pRS.finish();
- waitForMessage();
- }
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_refcount.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_refcount.java
deleted file mode 100644
index 05a516b..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_refcount.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test_v14;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_refcount extends UnitTest {
- private Resources mRes;
-
- protected UT_refcount(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Refcount", ctx);
- mRes = res;
- }
-
- private void initializeGlobals(RenderScript RS, ScriptC_refcount s) {
- Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
- int X = 500;
- int Y = 700;
- typeBuilder.setX(X).setY(Y);
- Allocation A = Allocation.createTyped(RS, typeBuilder.create());
- s.set_globalA(A);
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- pRS.setMessageHandler(mRsMessage);
- ScriptC_refcount s = new ScriptC_refcount(pRS, mRes, R.raw.refcount);
- initializeGlobals(pRS, s);
- s.invoke_refcount_test();
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_rsdebug.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_rsdebug.java
deleted file mode 100644
index 95e92ee..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_rsdebug.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v14;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_rsdebug extends UnitTest {
- private Resources mRes;
-
- protected UT_rsdebug(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsDebug", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rsdebug s = new ScriptC_rsdebug(pRS, mRes, R.raw.rsdebug);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_test_rsdebug(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_rstime.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_rstime.java
deleted file mode 100644
index a72ede9..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_rstime.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v14;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_rstime extends UnitTest {
- private Resources mRes;
-
- protected UT_rstime(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsTime", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rstime s = new ScriptC_rstime(pRS, mRes, R.raw.rstime);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_test_rstime(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_rstypes.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_rstypes.java
deleted file mode 100644
index ab96867..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_rstypes.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v14;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_rstypes extends UnitTest {
- private Resources mRes;
-
- protected UT_rstypes(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "rsTypes", ctx);
- mRes = res;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_rstypes s = new ScriptC_rstypes(pRS, mRes, R.raw.rstypes);
- pRS.setMessageHandler(mRsMessage);
- s.invoke_test_rstypes(0, 0);
- pRS.finish();
- waitForMessage();
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_vector.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_vector.java
deleted file mode 100644
index 657413e..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_vector.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (C) 2011 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.rs.test_v14;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-public class UT_vector extends UnitTest {
- private Resources mRes;
-
- protected UT_vector(RSTestCore rstc, Resources res, Context ctx) {
- super(rstc, "Vector", ctx);
- mRes = res;
- }
-
- private boolean initializeGlobals(ScriptC_vector s) {
- Float2 F2 = s.get_f2();
- if (F2.x != 1.0f || F2.y != 2.0f) {
- return false;
- }
- F2.x = 2.99f;
- F2.y = 3.99f;
- s.set_f2(F2);
-
- Float3 F3 = s.get_f3();
- if (F3.x != 1.0f || F3.y != 2.0f || F3.z != 3.0f) {
- return false;
- }
- F3.x = 2.99f;
- F3.y = 3.99f;
- F3.z = 4.99f;
- s.set_f3(F3);
-
- Float4 F4 = s.get_f4();
- if (F4.x != 1.0f || F4.y != 2.0f || F4.z != 3.0f || F4.w != 4.0f) {
- return false;
- }
- F4.x = 2.99f;
- F4.y = 3.99f;
- F4.z = 4.99f;
- F4.w = 5.99f;
- s.set_f4(F4);
-
- Double2 D2 = s.get_d2();
- if (D2.x != 1.0 || D2.y != 2.0) {
- return false;
- }
- D2.x = 2.99;
- D2.y = 3.99;
- s.set_d2(D2);
-
- Double3 D3 = s.get_d3();
- if (D3.x != 1.0 || D3.y != 2.0 || D3.z != 3.0) {
- return false;
- }
- D3.x = 2.99;
- D3.y = 3.99;
- D3.z = 4.99;
- s.set_d3(D3);
-
- Double4 D4 = s.get_d4();
- if (D4.x != 1.0 || D4.y != 2.0 || D4.z != 3.0 || D4.w != 4.0) {
- return false;
- }
- D4.x = 2.99;
- D4.y = 3.99;
- D4.z = 4.99;
- D4.w = 5.99;
- s.set_d4(D4);
-
- Byte2 B2 = s.get_i8_2();
- if (B2.x != 1 || B2.y != 2) {
- return false;
- }
- B2.x = 2;
- B2.y = 3;
- s.set_i8_2(B2);
-
- Byte3 B3 = s.get_i8_3();
- if (B3.x != 1 || B3.y != 2 || B3.z != 3) {
- return false;
- }
- B3.x = 2;
- B3.y = 3;
- B3.z = 4;
- s.set_i8_3(B3);
-
- Byte4 B4 = s.get_i8_4();
- if (B4.x != 1 || B4.y != 2 || B4.z != 3 || B4.w != 4) {
- return false;
- }
- B4.x = 2;
- B4.y = 3;
- B4.z = 4;
- B4.w = 5;
- s.set_i8_4(B4);
-
- Short2 S2 = s.get_u8_2();
- if (S2.x != 1 || S2.y != 2) {
- return false;
- }
- S2.x = 2;
- S2.y = 3;
- s.set_u8_2(S2);
-
- Short3 S3 = s.get_u8_3();
- if (S3.x != 1 || S3.y != 2 || S3.z != 3) {
- return false;
- }
- S3.x = 2;
- S3.y = 3;
- S3.z = 4;
- s.set_u8_3(S3);
-
- Short4 S4 = s.get_u8_4();
- if (S4.x != 1 || S4.y != 2 || S4.z != 3 || S4.w != 4) {
- return false;
- }
- S4.x = 2;
- S4.y = 3;
- S4.z = 4;
- S4.w = 5;
- s.set_u8_4(S4);
-
- S2 = s.get_i16_2();
- if (S2.x != 1 || S2.y != 2) {
- return false;
- }
- S2.x = 2;
- S2.y = 3;
- s.set_i16_2(S2);
-
- S3 = s.get_i16_3();
- if (S3.x != 1 || S3.y != 2 || S3.z != 3) {
- return false;
- }
- S3.x = 2;
- S3.y = 3;
- S3.z = 4;
- s.set_i16_3(S3);
-
- S4 = s.get_i16_4();
- if (S4.x != 1 || S4.y != 2 || S4.z != 3 || S4.w != 4) {
- return false;
- }
- S4.x = 2;
- S4.y = 3;
- S4.z = 4;
- S4.w = 5;
- s.set_i16_4(S4);
-
- Int2 I2 = s.get_u16_2();
- if (I2.x != 1 || I2.y != 2) {
- return false;
- }
- I2.x = 2;
- I2.y = 3;
- s.set_u16_2(I2);
-
- Int3 I3 = s.get_u16_3();
- if (I3.x != 1 || I3.y != 2 || I3.z != 3) {
- return false;
- }
- I3.x = 2;
- I3.y = 3;
- I3.z = 4;
- s.set_u16_3(I3);
-
- Int4 I4 = s.get_u16_4();
- if (I4.x != 1 || I4.y != 2 || I4.z != 3 || I4.w != 4) {
- return false;
- }
- I4.x = 2;
- I4.y = 3;
- I4.z = 4;
- I4.w = 5;
- s.set_u16_4(I4);
-
- I2 = s.get_i32_2();
- if (I2.x != 1 || I2.y != 2) {
- return false;
- }
- I2.x = 2;
- I2.y = 3;
- s.set_i32_2(I2);
-
- I3 = s.get_i32_3();
- if (I3.x != 1 || I3.y != 2 || I3.z != 3) {
- return false;
- }
- I3.x = 2;
- I3.y = 3;
- I3.z = 4;
- s.set_i32_3(I3);
-
- I4 = s.get_i32_4();
- if (I4.x != 1 || I4.y != 2 || I4.z != 3 || I4.w != 4) {
- return false;
- }
- I4.x = 2;
- I4.y = 3;
- I4.z = 4;
- I4.w = 5;
- s.set_i32_4(I4);
-
- Long2 L2 = s.get_u32_2();
- if (L2.x != 1 || L2.y != 2) {
- return false;
- }
- L2.x = 2;
- L2.y = 3;
- s.set_u32_2(L2);
-
- Long3 L3 = s.get_u32_3();
- if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
- return false;
- }
- L3.x = 2;
- L3.y = 3;
- L3.z = 4;
- s.set_u32_3(L3);
-
- Long4 L4 = s.get_u32_4();
- if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
- return false;
- }
- L4.x = 2;
- L4.y = 3;
- L4.z = 4;
- L4.w = 5;
- s.set_u32_4(L4);
-
- L2 = s.get_i64_2();
- if (L2.x != 1 || L2.y != 2) {
- return false;
- }
- L2.x = 2;
- L2.y = 3;
- s.set_i64_2(L2);
-
- L3 = s.get_i64_3();
- if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
- return false;
- }
- L3.x = 2;
- L3.y = 3;
- L3.z = 4;
- s.set_i64_3(L3);
-
- L4 = s.get_i64_4();
- if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
- return false;
- }
- L4.x = 2;
- L4.y = 3;
- L4.z = 4;
- L4.w = 5;
- s.set_i64_4(L4);
-
- L2 = s.get_u64_2();
- if (L2.x != 1 || L2.y != 2) {
- return false;
- }
- L2.x = 2;
- L2.y = 3;
- s.set_u64_2(L2);
-
- L3 = s.get_u64_3();
- if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
- return false;
- }
- L3.x = 2;
- L3.y = 3;
- L3.z = 4;
- s.set_u64_3(L3);
-
- L4 = s.get_u64_4();
- if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
- return false;
- }
- L4.x = 2;
- L4.y = 3;
- L4.z = 4;
- L4.w = 5;
- s.set_u64_4(L4);
-
- return true;
- }
-
- public void run() {
- RenderScript pRS = RenderScript.create(mCtx);
- ScriptC_vector s = new ScriptC_vector(pRS, mRes, R.raw.vector);
- pRS.setMessageHandler(mRsMessage);
- if (!initializeGlobals(s)) {
- result = -1;
- } else {
- s.invoke_vector_test();
- pRS.finish();
- waitForMessage();
- }
- pRS.destroy();
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UnitTest.java b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UnitTest.java
deleted file mode 100644
index 558a252..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UnitTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2010 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.rs.test_v14;
-import android.content.Context;
-import android.util.Log;
-import android.renderscript.RenderScript.RSMessageHandler;
-
-public class UnitTest extends Thread {
- public String name;
- public int result;
- private ScriptField_ListAllocs_s.Item mItem;
- private RSTestCore mRSTC;
- private boolean msgHandled;
- protected Context mCtx;
-
- /* These constants must match those in shared.rsh */
- public static final int RS_MSG_TEST_PASSED = 100;
- public static final int RS_MSG_TEST_FAILED = 101;
-
- private static int numTests = 0;
- public int testID;
-
- protected UnitTest(RSTestCore rstc, String n, int initResult, Context ctx) {
- super();
- mRSTC = rstc;
- name = n;
- msgHandled = false;
- mCtx = ctx;
- result = initResult;
- testID = numTests++;
- }
-
- protected UnitTest(RSTestCore rstc, String n, Context ctx) {
- this(rstc, n, 0, ctx);
- }
-
- protected UnitTest(RSTestCore rstc, Context ctx) {
- this (rstc, "<Unknown>", ctx);
- }
-
- protected UnitTest(Context ctx) {
- this (null, ctx);
- }
-
- protected void _RS_ASSERT(String message, boolean b) {
- if(b == false) {
- result = -1;
- Log.e(name, message + " FAILED");
- }
- }
-
- protected void updateUI() {
- if (mItem != null) {
- mItem.result = result;
- msgHandled = true;
- try {
- mRSTC.refreshTestResults();
- }
- catch (IllegalStateException e) {
- /* Ignore the case where our message receiver has been
- disconnected. This happens when we leave the application
- before it finishes running all of the unit tests. */
- }
- }
- }
-
- protected RSMessageHandler mRsMessage = new RSMessageHandler() {
- public void run() {
- if (result == 0) {
- switch (mID) {
- case RS_MSG_TEST_PASSED:
- result = 1;
- break;
- case RS_MSG_TEST_FAILED:
- result = -1;
- break;
- default:
- RSTest_v14.log("Unit test got unexpected message");
- return;
- }
- }
-
- updateUI();
- }
- };
-
- public void waitForMessage() {
- while (!msgHandled) {
- yield();
- }
- }
-
- public void setItem(ScriptField_ListAllocs_s.Item item) {
- mItem = item;
- }
-
- public void run() {
- /* This method needs to be implemented for each subclass */
- if (mRSTC != null) {
- mRSTC.refreshTestResults();
- }
- }
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/alloc.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/alloc.rs
deleted file mode 100644
index 1b5e2ac..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/alloc.rs
+++ /dev/null
@@ -1,92 +0,0 @@
-#include "shared.rsh"
-
-int *a;
-int dimX;
-int dimY;
-int dimZ;
-
-rs_allocation aRaw;
-rs_allocation aFaces;
-rs_allocation aLOD;
-rs_allocation aFacesLOD;
-
-void root(int *o, uint32_t x, uint32_t y) {
- *o = x + y * dimX;
-}
-
-static bool test_alloc_dims() {
- bool failed = false;
- int i, j;
-
- _RS_ASSERT(rsAllocationGetDimX(aRaw) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aRaw) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aRaw) == dimZ);
-
- // Test 2D addressing
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- rsDebug("Verifying ", i + j * dimX);
- const void *p = rsGetElementAt(aRaw, i, j);
- int val = *(const int *)p;
- _RS_ASSERT(val == (i + j * dimX));
- }
- }
-
- // Test 1D addressing
- for (i = 0; i < dimX; i++) {
- rsDebug("Verifying ", i);
- const void *p = rsGetElementAt(aRaw, i);
- int val = *(const int *)p;
- _RS_ASSERT(val == i);
- }
-
- // Test 3D addressing
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- rsDebug("Verifying ", i + j * dimX);
- const void *p = rsGetElementAt(aRaw, i, j, 0);
- int val = *(const int *)p;
- _RS_ASSERT(val == (i + j * dimX));
- }
- }
-
- _RS_ASSERT(rsAllocationGetDimX(aFaces) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aFaces) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aFaces) == dimZ);
- _RS_ASSERT(rsAllocationGetDimFaces(aFaces) != 0);
- _RS_ASSERT(rsAllocationGetDimLOD(aFaces) == 0);
-
- _RS_ASSERT(rsAllocationGetDimX(aLOD) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aLOD) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aLOD) == dimZ);
- _RS_ASSERT(rsAllocationGetDimFaces(aLOD) == 0);
- _RS_ASSERT(rsAllocationGetDimLOD(aLOD) != 0);
-
- _RS_ASSERT(rsAllocationGetDimX(aFacesLOD) == dimX);
- _RS_ASSERT(rsAllocationGetDimY(aFacesLOD) == dimY);
- _RS_ASSERT(rsAllocationGetDimZ(aFacesLOD) == dimZ);
- _RS_ASSERT(rsAllocationGetDimFaces(aFacesLOD) != 0);
- _RS_ASSERT(rsAllocationGetDimLOD(aFacesLOD) != 0);
-
- if (failed) {
- rsDebug("test_alloc_dims FAILED", 0);
- }
- else {
- rsDebug("test_alloc_dims PASSED", 0);
- }
-
- return failed;
-}
-
-void alloc_test() {
- bool failed = false;
- failed |= test_alloc_dims();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/foreach.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/foreach.rs
deleted file mode 100644
index 3fa8f85..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/foreach.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "shared.rsh"
-
-rs_allocation aRaw;
-int dimX;
-int dimY;
-static bool failed = false;
-
-void root(int *out, uint32_t x, uint32_t y) {
- *out = x + y * dimX;
-}
-
-static bool test_root_output() {
- bool failed = false;
- int i, j;
-
- for (j = 0; j < dimY; j++) {
- for (i = 0; i < dimX; i++) {
- int v = rsGetElementAt_int(aRaw, i, j);
- _RS_ASSERT(v == (i + j * dimX));
- }
- }
-
- if (failed) {
- rsDebug("test_root_output FAILED", 0);
- }
- else {
- rsDebug("test_root_output PASSED", 0);
- }
-
- return failed;
-}
-
-void verify_root() {
- failed |= test_root_output();
-}
-
-void foreach_test() {
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/fp_mad.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/fp_mad.rs
deleted file mode 100644
index b6f2b2a6..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/fp_mad.rs
+++ /dev/null
@@ -1,174 +0,0 @@
-#include "shared.rsh"
-
-const int TEST_COUNT = 1;
-
-static float data_f1[1025];
-static float4 data_f4[1025];
-
-static void test_mad4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~1 billion ops
- for (int ct=0; ct < 1000 * (1000 / 80); ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = (data_f4[i] * 0.02f +
- data_f4[i+1] * 0.04f +
- data_f4[i+2] * 0.05f +
- data_f4[i+3] * 0.1f +
- data_f4[i+4] * 0.2f +
- data_f4[i+5] * 0.2f +
- data_f4[i+6] * 0.1f +
- data_f4[i+7] * 0.05f +
- data_f4[i+8] * 0.04f +
- data_f4[i+9] * 0.02f + 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_mad4 M ops", 1000.f / time);
-}
-
-static void test_mad(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~1 billion ops
- for (int ct=0; ct < 1000 * (1000 / 20); ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = (data_f1[i] * 0.02f +
- data_f1[i+1] * 0.04f +
- data_f1[i+2] * 0.05f +
- data_f1[i+3] * 0.1f +
- data_f1[i+4] * 0.2f +
- data_f1[i+5] * 0.2f +
- data_f1[i+6] * 0.1f +
- data_f1[i+7] * 0.05f +
- data_f1[i+8] * 0.04f +
- data_f1[i+9] * 0.02f + 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_mad M ops", 1000.f / time);
-}
-
-static void test_norm(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = normalize(data_f4[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_norm M ops", 10.f / time);
-}
-
-static void test_sincos4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10 / 4; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = sin(data_f4[i]) * cos(data_f4[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_sincos4 M ops", 10.f / time);
-}
-
-static void test_sincos(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~10 M ops
- for (int ct=0; ct < 1000 * 10; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = sin(data_f1[i]) * cos(data_f1[i]);
- }
- }
-
- float time = end(index);
- rsDebug("fp_sincos M ops", 10.f / time);
-}
-
-static void test_clamp(uint32_t index) {
- start();
-
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f1[i] = clamp(data_f1[i], -1.f, 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_clamp M ops", 100.f / time);
-
- start();
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100; ct++) {
- for (int i=0; i < (1000); i++) {
- if (data_f1[i] < -1.f) data_f1[i] = -1.f;
- if (data_f1[i] > -1.f) data_f1[i] = 1.f;
- }
- }
-
- time = end(index);
- rsDebug("fp_clamp ref M ops", 100.f / time);
-}
-
-static void test_clamp4(uint32_t index) {
- start();
-
- float total = 0;
- // Do ~100 M ops
- for (int ct=0; ct < 1000 * 100 /4; ct++) {
- for (int i=0; i < (1000); i++) {
- data_f4[i] = clamp(data_f4[i], -1.f, 1.f);
- }
- }
-
- float time = end(index);
- rsDebug("fp_clamp4 M ops", 100.f / time);
-}
-
-void fp_mad_test(uint32_t index, int test_num) {
- int x;
- for (x=0; x < 1025; x++) {
- data_f1[x] = (x & 0xf) * 0.1f;
- data_f4[x].x = (x & 0xf) * 0.1f;
- data_f4[x].y = (x & 0xf0) * 0.1f;
- data_f4[x].z = (x & 0x33) * 0.1f;
- data_f4[x].w = (x & 0x77) * 0.1f;
- }
-
- test_mad4(index);
- test_mad(index);
-
- for (x=0; x < 1025; x++) {
- data_f1[x] = (x & 0xf) * 0.1f + 1.f;
- data_f4[x].x = (x & 0xf) * 0.1f + 1.f;
- data_f4[x].y = (x & 0xf0) * 0.1f + 1.f;
- data_f4[x].z = (x & 0x33) * 0.1f + 1.f;
- data_f4[x].w = (x & 0x77) * 0.1f + 1.f;
- }
-
- test_norm(index);
- test_sincos4(index);
- test_sincos(index);
- test_clamp4(index);
- test_clamp(index);
-
- // TODO Actually verify test result accuracy
- rsDebug("fp_mad_test PASSED", 0);
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
-}
-
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/math.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/math.rs
deleted file mode 100644
index e6b37f6..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/math.rs
+++ /dev/null
@@ -1,462 +0,0 @@
-#include "shared.rsh"
-
-// Testing math library
-
-volatile float f1;
-volatile float2 f2;
-volatile float3 f3;
-volatile float4 f4;
-
-volatile int i1;
-volatile int2 i2;
-volatile int3 i3;
-volatile int4 i4;
-
-volatile uint ui1;
-volatile uint2 ui2;
-volatile uint3 ui3;
-volatile uint4 ui4;
-
-volatile short s1;
-volatile short2 s2;
-volatile short3 s3;
-volatile short4 s4;
-
-volatile ushort us1;
-volatile ushort2 us2;
-volatile ushort3 us3;
-volatile ushort4 us4;
-
-volatile char c1;
-volatile char2 c2;
-volatile char3 c3;
-volatile char4 c4;
-
-volatile uchar uc1;
-volatile uchar2 uc2;
-volatile uchar3 uc3;
-volatile uchar4 uc4;
-
-#define DECL_INT(prefix) \
-volatile char prefix##_c_1 = 1; \
-volatile char2 prefix##_c_2 = 1; \
-volatile char3 prefix##_c_3 = 1; \
-volatile char4 prefix##_c_4 = 1; \
-volatile uchar prefix##_uc_1 = 1; \
-volatile uchar2 prefix##_uc_2 = 1; \
-volatile uchar3 prefix##_uc_3 = 1; \
-volatile uchar4 prefix##_uc_4 = 1; \
-volatile short prefix##_s_1 = 1; \
-volatile short2 prefix##_s_2 = 1; \
-volatile short3 prefix##_s_3 = 1; \
-volatile short4 prefix##_s_4 = 1; \
-volatile ushort prefix##_us_1 = 1; \
-volatile ushort2 prefix##_us_2 = 1; \
-volatile ushort3 prefix##_us_3 = 1; \
-volatile ushort4 prefix##_us_4 = 1; \
-volatile int prefix##_i_1 = 1; \
-volatile int2 prefix##_i_2 = 1; \
-volatile int3 prefix##_i_3 = 1; \
-volatile int4 prefix##_i_4 = 1; \
-volatile uint prefix##_ui_1 = 1; \
-volatile uint2 prefix##_ui_2 = 1; \
-volatile uint3 prefix##_ui_3 = 1; \
-volatile uint4 prefix##_ui_4 = 1; \
-volatile long prefix##_l_1 = 1; \
-volatile ulong prefix##_ul_1 = 1;
-
-DECL_INT(res)
-DECL_INT(src1)
-DECL_INT(src2)
-
-#define TEST_INT_OP_TYPE(op, type) \
-rsDebug("Testing " #op " for " #type "1", i++); \
-res_##type##_1 = src1_##type##_1 op src2_##type##_1; \
-rsDebug("Testing " #op " for " #type "2", i++); \
-res_##type##_2 = src1_##type##_2 op src2_##type##_2; \
-rsDebug("Testing " #op " for " #type "3", i++); \
-res_##type##_3 = src1_##type##_3 op src2_##type##_3; \
-rsDebug("Testing " #op " for " #type "4", i++); \
-res_##type##_4 = src1_##type##_4 op src2_##type##_4;
-
-#define TEST_INT_OP(op) \
-TEST_INT_OP_TYPE(op, c) \
-TEST_INT_OP_TYPE(op, uc) \
-TEST_INT_OP_TYPE(op, s) \
-TEST_INT_OP_TYPE(op, us) \
-TEST_INT_OP_TYPE(op, i) \
-TEST_INT_OP_TYPE(op, ui) \
-rsDebug("Testing " #op " for l1", i++); \
-res_l_1 = src1_l_1 op src2_l_1; \
-rsDebug("Testing " #op " for ul1", i++); \
-res_ul_1 = src1_ul_1 op src2_ul_1;
-
-#define TEST_XN_FUNC_YN(typeout, fnc, typein) \
- res_##typeout##_1 = fnc(src1_##typein##_1); \
- res_##typeout##_2 = fnc(src1_##typein##_2); \
- res_##typeout##_3 = fnc(src1_##typein##_3); \
- res_##typeout##_4 = fnc(src1_##typein##_4);
-
-#define TEST_XN_FUNC_XN_XN(type, fnc) \
- res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1); \
- res_##type##_2 = fnc(src1_##type##_2, src2_##type##_2); \
- res_##type##_3 = fnc(src1_##type##_3, src2_##type##_3); \
- res_##type##_4 = fnc(src1_##type##_4, src2_##type##_4);
-
-#define TEST_X_FUNC_X_X_X(type, fnc) \
- res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1, src2_##type##_1);
-
-#define TEST_IN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_YN(uc, fnc, uc) \
- TEST_XN_FUNC_YN(c, fnc, c) \
- TEST_XN_FUNC_YN(us, fnc, us) \
- TEST_XN_FUNC_YN(s, fnc, s) \
- TEST_XN_FUNC_YN(ui, fnc, ui) \
- TEST_XN_FUNC_YN(i, fnc, i)
-
-#define TEST_UIN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_YN(uc, fnc, c) \
- TEST_XN_FUNC_YN(us, fnc, s) \
- TEST_XN_FUNC_YN(ui, fnc, i) \
-
-#define TEST_IN_FUNC_IN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_XN_XN(uc, fnc) \
- TEST_XN_FUNC_XN_XN(c, fnc) \
- TEST_XN_FUNC_XN_XN(us, fnc) \
- TEST_XN_FUNC_XN_XN(s, fnc) \
- TEST_XN_FUNC_XN_XN(ui, fnc) \
- TEST_XN_FUNC_XN_XN(i, fnc)
-
-#define TEST_I_FUNC_I_I_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_X_FUNC_X_X_X(uc, fnc) \
- TEST_X_FUNC_X_X_X(c, fnc) \
- TEST_X_FUNC_X_X_X(us, fnc) \
- TEST_X_FUNC_X_X_X(s, fnc) \
- TEST_X_FUNC_X_X_X(ui, fnc) \
- TEST_X_FUNC_X_X_X(i, fnc)
-
-#define TEST_FN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1); \
- f2 = fnc(f2); \
- f3 = fnc(f3); \
- f4 = fnc(f4);
-
-#define TEST_FN_FUNC_FN_PFN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (float*) &f1); \
- f2 = fnc(f2, (float2*) &f2); \
- f3 = fnc(f3, (float3*) &f3); \
- f4 = fnc(f4, (float4*) &f4);
-
-#define TEST_FN_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f2); \
- f3 = fnc(f3, f3); \
- f4 = fnc(f4, f4);
-
-#define TEST_F34_FUNC_F34_F34(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f3 = fnc(f3, f3); \
- f4 = fnc(f4, f4);
-
-#define TEST_FN_FUNC_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f1); \
- f3 = fnc(f3, f1); \
- f4 = fnc(f4, f1);
-
-#define TEST_F_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1); \
- f1 = fnc(f2); \
- f1 = fnc(f3); \
- f1 = fnc(f4);
-
-#define TEST_F_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f1 = fnc(f2, f2); \
- f1 = fnc(f3, f3); \
- f1 = fnc(f4, f4);
-
-#define TEST_FN_FUNC_FN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i2); \
- f3 = fnc(f3, i3); \
- f4 = fnc(f4, i4);
-
-#define TEST_FN_FUNC_FN_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i1); \
- f3 = fnc(f3, i1); \
- f4 = fnc(f4, i1);
-
-#define TEST_FN_FUNC_FN_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, f1); \
- f2 = fnc(f2, f2, f2); \
- f3 = fnc(f3, f3, f3); \
- f4 = fnc(f4, f4, f4);
-
-#define TEST_FN_FUNC_FN_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, f1); \
- f2 = fnc(f2, f1, f1); \
- f3 = fnc(f3, f1, f1); \
- f4 = fnc(f4, f1, f1);
-
-#define TEST_FN_FUNC_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (int*) &i1); \
- f2 = fnc(f2, (int2*) &i2); \
- f3 = fnc(f3, (int3*) &i3); \
- f4 = fnc(f4, (int4*) &i4);
-
-#define TEST_FN_FUNC_FN_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, (int*) &i1); \
- f2 = fnc(f2, f2, (int2*) &i2); \
- f3 = fnc(f3, f3, (int3*) &i3); \
- f4 = fnc(f4, f4, (int4*) &i4);
-
-#define TEST_IN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- i1 = fnc(f1); \
- i2 = fnc(f2); \
- i3 = fnc(f3); \
- i4 = fnc(f4);
-
-static bool test_fp_math(uint32_t index) {
- bool failed = false;
- start();
-
- TEST_FN_FUNC_FN(acos);
- TEST_FN_FUNC_FN(acosh);
- TEST_FN_FUNC_FN(acospi);
- TEST_FN_FUNC_FN(asin);
- TEST_FN_FUNC_FN(asinh);
- TEST_FN_FUNC_FN(asinpi);
- TEST_FN_FUNC_FN(atan);
- TEST_FN_FUNC_FN_FN(atan2);
- TEST_FN_FUNC_FN(atanh);
- TEST_FN_FUNC_FN(atanpi);
- TEST_FN_FUNC_FN_FN(atan2pi);
- TEST_FN_FUNC_FN(cbrt);
- TEST_FN_FUNC_FN(ceil);
- TEST_FN_FUNC_FN_FN_FN(clamp);
- TEST_FN_FUNC_FN_FN_F(clamp);
- TEST_FN_FUNC_FN_FN(copysign);
- TEST_FN_FUNC_FN(cos);
- TEST_FN_FUNC_FN(cosh);
- TEST_FN_FUNC_FN(cospi);
- TEST_F34_FUNC_F34_F34(cross);
- TEST_FN_FUNC_FN(degrees);
- TEST_F_FUNC_FN_FN(distance);
- TEST_F_FUNC_FN_FN(dot);
- TEST_FN_FUNC_FN(erfc);
- TEST_FN_FUNC_FN(erf);
- TEST_FN_FUNC_FN(exp);
- TEST_FN_FUNC_FN(exp2);
- TEST_FN_FUNC_FN(exp10);
- TEST_FN_FUNC_FN(expm1);
- TEST_FN_FUNC_FN(fabs);
- TEST_FN_FUNC_FN_FN(fdim);
- TEST_FN_FUNC_FN(floor);
- TEST_FN_FUNC_FN_FN_FN(fma);
- TEST_FN_FUNC_FN_FN(fmax);
- TEST_FN_FUNC_FN_F(fmax);
- TEST_FN_FUNC_FN_FN(fmin);
- TEST_FN_FUNC_FN_F(fmin);
- TEST_FN_FUNC_FN_FN(fmod);
- TEST_FN_FUNC_FN_PFN(fract);
- TEST_FN_FUNC_FN_PIN(frexp);
- TEST_FN_FUNC_FN_FN(hypot);
- TEST_IN_FUNC_FN(ilogb);
- TEST_FN_FUNC_FN_IN(ldexp);
- TEST_FN_FUNC_FN_I(ldexp);
- TEST_F_FUNC_FN(length);
- TEST_FN_FUNC_FN(lgamma);
- TEST_FN_FUNC_FN_PIN(lgamma);
- TEST_FN_FUNC_FN(log);
- TEST_FN_FUNC_FN(log2);
- TEST_FN_FUNC_FN(log10);
- TEST_FN_FUNC_FN(log1p);
- TEST_FN_FUNC_FN(logb);
- TEST_FN_FUNC_FN_FN_FN(mad);
- TEST_FN_FUNC_FN_FN(max);
- TEST_FN_FUNC_FN_F(max);
- TEST_FN_FUNC_FN_FN(min);
- TEST_FN_FUNC_FN_F(min);
- TEST_FN_FUNC_FN_FN_FN(mix);
- TEST_FN_FUNC_FN_FN_F(mix);
- TEST_FN_FUNC_FN_PFN(modf);
- // nan
- TEST_FN_FUNC_FN_FN(nextafter);
- TEST_FN_FUNC_FN(normalize);
- TEST_FN_FUNC_FN_FN(pow);
- TEST_FN_FUNC_FN_IN(pown);
- TEST_FN_FUNC_FN_FN(powr);
- TEST_FN_FUNC_FN(radians);
- TEST_FN_FUNC_FN_FN(remainder);
- TEST_FN_FUNC_FN_FN_PIN(remquo);
- TEST_FN_FUNC_FN(rint);
- TEST_FN_FUNC_FN_IN(rootn);
- TEST_FN_FUNC_FN(round);
- TEST_FN_FUNC_FN(rsqrt);
- TEST_FN_FUNC_FN(sign);
- TEST_FN_FUNC_FN(sin);
- TEST_FN_FUNC_FN_PFN(sincos);
- TEST_FN_FUNC_FN(sinh);
- TEST_FN_FUNC_FN(sinpi);
- TEST_FN_FUNC_FN(sqrt);
- TEST_FN_FUNC_FN_FN(step);
- TEST_FN_FUNC_FN_F(step);
- TEST_FN_FUNC_FN(tan);
- TEST_FN_FUNC_FN(tanh);
- TEST_FN_FUNC_FN(tanpi);
- TEST_FN_FUNC_FN(tgamma);
- TEST_FN_FUNC_FN(trunc);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_fp_math FAILED", time);
- }
- else {
- rsDebug("test_fp_math PASSED", time);
- }
-
- return failed;
-}
-
-static bool test_int_math(uint32_t index) {
- bool failed = false;
- start();
-
- TEST_UIN_FUNC_IN(abs);
- TEST_IN_FUNC_IN(clz);
- TEST_IN_FUNC_IN_IN(min);
- TEST_IN_FUNC_IN_IN(max);
- TEST_I_FUNC_I_I_I(rsClamp);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_int_math FAILED", time);
- }
- else {
- rsDebug("test_int_math PASSED", time);
- }
-
- return failed;
-}
-
-static bool test_basic_operators() {
- bool failed = false;
- int i = 0;
-
- TEST_INT_OP(+);
- TEST_INT_OP(-);
- TEST_INT_OP(*);
- TEST_INT_OP(/);
- TEST_INT_OP(%);
- TEST_INT_OP(<<);
- TEST_INT_OP(>>);
-
- if (failed) {
- rsDebug("test_basic_operators FAILED", 0);
- }
- else {
- rsDebug("test_basic_operators PASSED", 0);
- }
-
- return failed;
-}
-
-#define TEST_CVT(to, from, type) \
-rsDebug("Testing convert from " #from " to " #to, 0); \
-to##1 = from##1; \
-to##2 = convert_##type##2(from##2); \
-to##3 = convert_##type##3(from##3); \
-to##4 = convert_##type##4(from##4);
-
-#define TEST_CVT_MATRIX(to, type) \
-TEST_CVT(to, c, type); \
-TEST_CVT(to, uc, type); \
-TEST_CVT(to, s, type); \
-TEST_CVT(to, us, type); \
-TEST_CVT(to, i, type); \
-TEST_CVT(to, ui, type); \
-TEST_CVT(to, f, type); \
-
-static bool test_convert() {
- bool failed = false;
-
- TEST_CVT_MATRIX(c, char);
- TEST_CVT_MATRIX(uc, uchar);
- TEST_CVT_MATRIX(s, short);
- TEST_CVT_MATRIX(us, ushort);
- TEST_CVT_MATRIX(i, int);
- TEST_CVT_MATRIX(ui, uint);
- TEST_CVT_MATRIX(f, float);
-
- if (failed) {
- rsDebug("test_convert FAILED", 0);
- }
- else {
- rsDebug("test_convert PASSED", 0);
- }
-
- return failed;
-}
-
-#define INIT_PREFIX_TYPE(prefix, type) \
-prefix##_##type##_1 = 1; \
-prefix##_##type##_2.x = 1; \
-prefix##_##type##_2.y = 1; \
-prefix##_##type##_3.x = 1; \
-prefix##_##type##_3.y = 1; \
-prefix##_##type##_3.z = 1; \
-prefix##_##type##_4.x = 1; \
-prefix##_##type##_4.y = 1; \
-prefix##_##type##_4.z = 1; \
-prefix##_##type##_4.w = 1;
-
-#define INIT_TYPE(type) \
-INIT_PREFIX_TYPE(src1, type) \
-INIT_PREFIX_TYPE(src2, type) \
-INIT_PREFIX_TYPE(res, type)
-
-#define INIT_ALL \
-INIT_TYPE(c); \
-INIT_TYPE(uc); \
-INIT_TYPE(s); \
-INIT_TYPE(us); \
-INIT_TYPE(i); \
-INIT_TYPE(ui);
-
-void math_test(uint32_t index, int test_num) {
- bool failed = false;
- INIT_ALL;
- failed |= test_convert();
- failed |= test_fp_math(index);
- failed |= test_int_math(index);
- failed |= test_basic_operators();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/math.rs.bak b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/math.rs.bak
deleted file mode 100644
index ad802ca..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/math.rs.bak
+++ /dev/null
@@ -1,423 +0,0 @@
-#include "shared.rsh"
-
-// Testing math library
-
-volatile float f1;
-volatile float2 f2;
-volatile float3 f3;
-volatile float4 f4;
-
-volatile int i1;
-volatile int2 i2;
-volatile int3 i3;
-volatile int4 i4;
-
-volatile uint ui1;
-volatile uint2 ui2;
-volatile uint3 ui3;
-volatile uint4 ui4;
-
-volatile short s1;
-volatile short2 s2;
-volatile short3 s3;
-volatile short4 s4;
-
-volatile ushort us1;
-volatile ushort2 us2;
-volatile ushort3 us3;
-volatile ushort4 us4;
-
-volatile char c1;
-volatile char2 c2;
-volatile char3 c3;
-volatile char4 c4;
-
-volatile uchar uc1;
-volatile uchar2 uc2;
-volatile uchar3 uc3;
-volatile uchar4 uc4;
-
-#define DECL_INT(prefix) \
-volatile char prefix##_c_1 = 1; \
-volatile char2 prefix##_c_2 = 1; \
-volatile char3 prefix##_c_3 = 1; \
-volatile char4 prefix##_c_4 = 1; \
-volatile uchar prefix##_uc_1 = 1; \
-volatile uchar2 prefix##_uc_2 = 1; \
-volatile uchar3 prefix##_uc_3 = 1; \
-volatile uchar4 prefix##_uc_4 = 1; \
-volatile short prefix##_s_1 = 1; \
-volatile short2 prefix##_s_2 = 1; \
-volatile short3 prefix##_s_3 = 1; \
-volatile short4 prefix##_s_4 = 1; \
-volatile ushort prefix##_us_1 = 1; \
-volatile ushort2 prefix##_us_2 = 1; \
-volatile ushort3 prefix##_us_3 = 1; \
-volatile ushort4 prefix##_us_4 = 1; \
-volatile int prefix##_i_1 = 1; \
-volatile int2 prefix##_i_2 = 1; \
-volatile int3 prefix##_i_3 = 1; \
-volatile int4 prefix##_i_4 = 1; \
-volatile uint prefix##_ui_1 = 1; \
-volatile uint2 prefix##_ui_2 = 1; \
-volatile uint3 prefix##_ui_3 = 1; \
-volatile uint4 prefix##_ui_4 = 1; \
-volatile long prefix##_l_1 = 1; \
-volatile ulong prefix##_ul_1 = 1;
-
-DECL_INT(res)
-DECL_INT(src1)
-DECL_INT(src2)
-
-#define TEST_INT_OP_TYPE(op, type) \
-rsDebug("Testing " #op " for " #type "3", i++); \
-res_##type##_3 = src1_##type##_3 op src2_##type##_3; \
-
-#define TEST_INT_OP(op) \
-TEST_INT_OP_TYPE(op, c) \
-TEST_INT_OP_TYPE(op, uc) \
-
-#define TEST_XN_FUNC_YN(typeout, fnc, typein) \
- res_##typeout##_1 = fnc(src1_##typein##_1); \
- res_##typeout##_2 = fnc(src1_##typein##_2); \
- res_##typeout##_3 = fnc(src1_##typein##_3); \
- res_##typeout##_4 = fnc(src1_##typein##_4);
-
-#define TEST_XN_FUNC_XN_XN(type, fnc) \
- res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1); \
- res_##type##_2 = fnc(src1_##type##_2, src2_##type##_2); \
- res_##type##_3 = fnc(src1_##type##_3, src2_##type##_3); \
- res_##type##_4 = fnc(src1_##type##_4, src2_##type##_4);
-
-#define TEST_X_FUNC_X_X_X(type, fnc) \
- res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1, src2_##type##_1);
-
-#define TEST_IN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_YN(uc, fnc, uc) \
- TEST_XN_FUNC_YN(c, fnc, c) \
- TEST_XN_FUNC_YN(us, fnc, us) \
- TEST_XN_FUNC_YN(s, fnc, s) \
- TEST_XN_FUNC_YN(ui, fnc, ui) \
- TEST_XN_FUNC_YN(i, fnc, i)
-
-#define TEST_UIN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_YN(uc, fnc, c) \
- TEST_XN_FUNC_YN(us, fnc, s) \
- TEST_XN_FUNC_YN(ui, fnc, i) \
-
-#define TEST_IN_FUNC_IN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_XN_XN(uc, fnc) \
- TEST_XN_FUNC_XN_XN(c, fnc) \
- TEST_XN_FUNC_XN_XN(us, fnc) \
- TEST_XN_FUNC_XN_XN(s, fnc) \
- TEST_XN_FUNC_XN_XN(ui, fnc) \
- TEST_XN_FUNC_XN_XN(i, fnc)
-
-#define TEST_I_FUNC_I_I_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_X_FUNC_X_X_X(uc, fnc) \
- TEST_X_FUNC_X_X_X(c, fnc) \
- TEST_X_FUNC_X_X_X(us, fnc) \
- TEST_X_FUNC_X_X_X(s, fnc) \
- TEST_X_FUNC_X_X_X(ui, fnc) \
- TEST_X_FUNC_X_X_X(i, fnc)
-
-#define TEST_FN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1); \
- f2 = fnc(f2); \
- f3 = fnc(f3); \
- f4 = fnc(f4);
-
-#define TEST_FN_FUNC_FN_PFN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (float*) &f1); \
- f2 = fnc(f2, (float2*) &f2); \
- f3 = fnc(f3, (float3*) &f3); \
- f4 = fnc(f4, (float4*) &f4);
-
-#define TEST_FN_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f2); \
- f3 = fnc(f3, f3); \
- f4 = fnc(f4, f4);
-
-#define TEST_F34_FUNC_F34_F34(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f3 = fnc(f3, f3); \
- f4 = fnc(f4, f4);
-
-#define TEST_FN_FUNC_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f1); \
- f3 = fnc(f3, f1); \
- f4 = fnc(f4, f1);
-
-#define TEST_F_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1); \
- f1 = fnc(f2); \
- f1 = fnc(f3); \
- f1 = fnc(f4);
-
-#define TEST_F_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f1 = fnc(f2, f2); \
- f1 = fnc(f3, f3); \
- f1 = fnc(f4, f4);
-
-#define TEST_FN_FUNC_FN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i2); \
- f3 = fnc(f3, i3); \
- f4 = fnc(f4, i4);
-
-#define TEST_FN_FUNC_FN_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i1); \
- f3 = fnc(f3, i1); \
- f4 = fnc(f4, i1);
-
-#define TEST_FN_FUNC_FN_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, f1); \
- f2 = fnc(f2, f2, f2); \
- f3 = fnc(f3, f3, f3); \
- f4 = fnc(f4, f4, f4);
-
-#define TEST_FN_FUNC_FN_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, f1); \
- f2 = fnc(f2, f1, f1); \
- f3 = fnc(f3, f1, f1); \
- f4 = fnc(f4, f1, f1);
-
-#define TEST_FN_FUNC_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (int*) &i1); \
- f2 = fnc(f2, (int2*) &i2); \
- f3 = fnc(f3, (int3*) &i3); \
- f4 = fnc(f4, (int4*) &i4);
-
-#define TEST_FN_FUNC_FN_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, (int*) &i1); \
- f2 = fnc(f2, f2, (int2*) &i2); \
- f3 = fnc(f3, f3, (int3*) &i3); \
- f4 = fnc(f4, f4, (int4*) &i4);
-
-#define TEST_IN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- i1 = fnc(f1); \
- i2 = fnc(f2); \
- i3 = fnc(f3); \
- i4 = fnc(f4);
-
-static bool test_fp_math(uint32_t index) {
- bool failed = false;
- start();
-
- TEST_FN_FUNC_FN(acos);
- TEST_FN_FUNC_FN(acosh);
- TEST_FN_FUNC_FN(acospi);
- TEST_FN_FUNC_FN(asin);
- TEST_FN_FUNC_FN(asinh);
- TEST_FN_FUNC_FN(asinpi);
- TEST_FN_FUNC_FN(atan);
- TEST_FN_FUNC_FN_FN(atan2);
- TEST_FN_FUNC_FN(atanh);
- TEST_FN_FUNC_FN(atanpi);
- TEST_FN_FUNC_FN_FN(atan2pi);
- TEST_FN_FUNC_FN(cbrt);
- TEST_FN_FUNC_FN(ceil);
- TEST_FN_FUNC_FN_FN_FN(clamp);
- TEST_FN_FUNC_FN_FN_F(clamp);
- TEST_FN_FUNC_FN_FN(copysign);
- TEST_FN_FUNC_FN(cos);
- TEST_FN_FUNC_FN(cosh);
- TEST_FN_FUNC_FN(cospi);
- TEST_F34_FUNC_F34_F34(cross);
- TEST_FN_FUNC_FN(degrees);
- TEST_F_FUNC_FN_FN(distance);
- TEST_F_FUNC_FN_FN(dot);
- TEST_FN_FUNC_FN(erfc);
- TEST_FN_FUNC_FN(erf);
- TEST_FN_FUNC_FN(exp);
- TEST_FN_FUNC_FN(exp2);
- TEST_FN_FUNC_FN(exp10);
- TEST_FN_FUNC_FN(expm1);
- TEST_FN_FUNC_FN(fabs);
- TEST_FN_FUNC_FN_FN(fdim);
- TEST_FN_FUNC_FN(floor);
- TEST_FN_FUNC_FN_FN_FN(fma);
- TEST_FN_FUNC_FN_FN(fmax);
- TEST_FN_FUNC_FN_F(fmax);
- TEST_FN_FUNC_FN_FN(fmin);
- TEST_FN_FUNC_FN_F(fmin);
- TEST_FN_FUNC_FN_FN(fmod);
- TEST_FN_FUNC_FN_PFN(fract);
- TEST_FN_FUNC_FN_PIN(frexp);
- TEST_FN_FUNC_FN_FN(hypot);
- TEST_IN_FUNC_FN(ilogb);
- TEST_FN_FUNC_FN_IN(ldexp);
- TEST_FN_FUNC_FN_I(ldexp);
- TEST_F_FUNC_FN(length);
- TEST_FN_FUNC_FN(lgamma);
- TEST_FN_FUNC_FN_PIN(lgamma);
- TEST_FN_FUNC_FN(log);
- TEST_FN_FUNC_FN(log2);
- TEST_FN_FUNC_FN(log10);
- TEST_FN_FUNC_FN(log1p);
- TEST_FN_FUNC_FN(logb);
- TEST_FN_FUNC_FN_FN_FN(mad);
- TEST_FN_FUNC_FN_FN(max);
- TEST_FN_FUNC_FN_F(max);
- TEST_FN_FUNC_FN_FN(min);
- TEST_FN_FUNC_FN_F(min);
- TEST_FN_FUNC_FN_FN_FN(mix);
- TEST_FN_FUNC_FN_FN_F(mix);
- TEST_FN_FUNC_FN_PFN(modf);
- // nan
- TEST_FN_FUNC_FN_FN(nextafter);
- TEST_FN_FUNC_FN(normalize);
- TEST_FN_FUNC_FN_FN(pow);
- TEST_FN_FUNC_FN_IN(pown);
- TEST_FN_FUNC_FN_FN(powr);
- TEST_FN_FUNC_FN(radians);
- TEST_FN_FUNC_FN_FN(remainder);
- TEST_FN_FUNC_FN_FN_PIN(remquo);
- TEST_FN_FUNC_FN(rint);
- TEST_FN_FUNC_FN_IN(rootn);
- TEST_FN_FUNC_FN(round);
- TEST_FN_FUNC_FN(rsqrt);
- TEST_FN_FUNC_FN(sign);
- TEST_FN_FUNC_FN(sin);
- TEST_FN_FUNC_FN_PFN(sincos);
- TEST_FN_FUNC_FN(sinh);
- TEST_FN_FUNC_FN(sinpi);
- TEST_FN_FUNC_FN(sqrt);
- TEST_FN_FUNC_FN_FN(step);
- TEST_FN_FUNC_FN_F(step);
- TEST_FN_FUNC_FN(tan);
- TEST_FN_FUNC_FN(tanh);
- TEST_FN_FUNC_FN(tanpi);
- TEST_FN_FUNC_FN(tgamma);
- TEST_FN_FUNC_FN(trunc);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_fp_math FAILED", time);
- }
- else {
- rsDebug("test_fp_math PASSED", time);
- }
-
- return failed;
-}
-
-static bool test_int_math(uint32_t index) {
- bool failed = false;
- start();
-
- TEST_UIN_FUNC_IN(abs);
- TEST_IN_FUNC_IN(clz);
- TEST_IN_FUNC_IN_IN(min);
- TEST_IN_FUNC_IN_IN(max);
- TEST_I_FUNC_I_I_I(rsClamp);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_int_math FAILED", time);
- }
- else {
- rsDebug("test_int_math PASSED", time);
- }
-
- return failed;
-}
-
-static bool test_basic_operators() {
- bool failed = false;
- int i = 0;
-
- TEST_INT_OP(+);
- TEST_INT_OP(-);
- TEST_INT_OP(*);
- TEST_INT_OP(/);
- TEST_INT_OP(%);
- TEST_INT_OP(<<);
- TEST_INT_OP(>>);
-
- if (failed) {
- rsDebug("test_basic_operators FAILED", 0);
- }
- else {
- rsDebug("test_basic_operators PASSED", 0);
- }
-
- return failed;
-}
-
-#define TEST_CVT(to, from, type) \
-rsDebug("Testing convert from " #from " to " #to, 0); \
-to##1 = from##1; \
-to##2 = convert_##type##2(from##2); \
-to##3 = convert_##type##3(from##3); \
-to##4 = convert_##type##4(from##4);
-
-#define TEST_CVT_MATRIX(to, type) \
-TEST_CVT(to, c, type); \
-TEST_CVT(to, uc, type); \
-TEST_CVT(to, s, type); \
-TEST_CVT(to, us, type); \
-TEST_CVT(to, i, type); \
-TEST_CVT(to, ui, type); \
-TEST_CVT(to, f, type); \
-
-static bool test_convert() {
- bool failed = false;
-
- TEST_CVT_MATRIX(c, char);
- TEST_CVT_MATRIX(uc, uchar);
- TEST_CVT_MATRIX(s, short);
- TEST_CVT_MATRIX(us, ushort);
- TEST_CVT_MATRIX(i, int);
- TEST_CVT_MATRIX(ui, uint);
- TEST_CVT_MATRIX(f, float);
-
- if (failed) {
- rsDebug("test_convert FAILED", 0);
- }
- else {
- rsDebug("test_convert PASSED", 0);
- }
-
- return failed;
-}
-
-void math_test(uint32_t index, int test_num) {
- bool failed = false;
- rsDebug("Here ", 1);
- res_uc_3 = src1_uc_3 / src2_uc_3;
- rsDebug("Here ", 2);
- failed |= test_basic_operators();
- rsDebug("Here ", 3);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/math.rs.orig b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/math.rs.orig
deleted file mode 100644
index aae29a4..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/math.rs.orig
+++ /dev/null
@@ -1,436 +0,0 @@
-#include "shared.rsh"
-
-// Testing math library
-
-volatile float f1;
-volatile float2 f2;
-volatile float3 f3;
-volatile float4 f4;
-
-volatile int i1;
-volatile int2 i2;
-volatile int3 i3;
-volatile int4 i4;
-
-volatile uint ui1;
-volatile uint2 ui2;
-volatile uint3 ui3;
-volatile uint4 ui4;
-
-volatile short s1;
-volatile short2 s2;
-volatile short3 s3;
-volatile short4 s4;
-
-volatile ushort us1;
-volatile ushort2 us2;
-volatile ushort3 us3;
-volatile ushort4 us4;
-
-volatile char c1;
-volatile char2 c2;
-volatile char3 c3;
-volatile char4 c4;
-
-volatile uchar uc1;
-volatile uchar2 uc2;
-volatile uchar3 uc3;
-volatile uchar4 uc4;
-
-#define DECL_INT(prefix) \
-volatile char prefix##_c_1 = 1; \
-volatile char2 prefix##_c_2 = 1; \
-volatile char3 prefix##_c_3 = 1; \
-volatile char4 prefix##_c_4 = 1; \
-volatile uchar prefix##_uc_1 = 1; \
-volatile uchar2 prefix##_uc_2 = 1; \
-volatile uchar3 prefix##_uc_3 = 1; \
-volatile uchar4 prefix##_uc_4 = 1; \
-volatile short prefix##_s_1 = 1; \
-volatile short2 prefix##_s_2 = 1; \
-volatile short3 prefix##_s_3 = 1; \
-volatile short4 prefix##_s_4 = 1; \
-volatile ushort prefix##_us_1 = 1; \
-volatile ushort2 prefix##_us_2 = 1; \
-volatile ushort3 prefix##_us_3 = 1; \
-volatile ushort4 prefix##_us_4 = 1; \
-volatile int prefix##_i_1 = 1; \
-volatile int2 prefix##_i_2 = 1; \
-volatile int3 prefix##_i_3 = 1; \
-volatile int4 prefix##_i_4 = 1; \
-volatile uint prefix##_ui_1 = 1; \
-volatile uint2 prefix##_ui_2 = 1; \
-volatile uint3 prefix##_ui_3 = 1; \
-volatile uint4 prefix##_ui_4 = 1; \
-volatile long prefix##_l_1 = 1; \
-volatile ulong prefix##_ul_1 = 1;
-
-DECL_INT(res)
-DECL_INT(src1)
-DECL_INT(src2)
-
-#define TEST_INT_OP_TYPE(op, type) \
-rsDebug("Testing " #op " for " #type "1", i++); \
-res_##type##_1 = src1_##type##_1 op src2_##type##_1; \
-rsDebug("Testing " #op " for " #type "2", i++); \
-res_##type##_2 = src1_##type##_2 op src2_##type##_2; \
-rsDebug("Testing " #op " for " #type "3", i++); \
-res_##type##_3 = src1_##type##_3 op src2_##type##_3; \
-rsDebug("Testing " #op " for " #type "4", i++); \
-res_##type##_4 = src1_##type##_4 op src2_##type##_4;
-
-#define TEST_INT_OP(op) \
-TEST_INT_OP_TYPE(op, c) \
-TEST_INT_OP_TYPE(op, uc) \
-TEST_INT_OP_TYPE(op, s) \
-TEST_INT_OP_TYPE(op, us) \
-TEST_INT_OP_TYPE(op, i) \
-TEST_INT_OP_TYPE(op, ui) \
-rsDebug("Testing " #op " for l1", i++); \
-res_l_1 = src1_l_1 op src2_l_1; \
-rsDebug("Testing " #op " for ul1", i++); \
-res_ul_1 = src1_ul_1 op src2_ul_1;
-
-#define TEST_XN_FUNC_YN(typeout, fnc, typein) \
- res_##typeout##_1 = fnc(src1_##typein##_1); \
- res_##typeout##_2 = fnc(src1_##typein##_2); \
- res_##typeout##_3 = fnc(src1_##typein##_3); \
- res_##typeout##_4 = fnc(src1_##typein##_4);
-
-#define TEST_XN_FUNC_XN_XN(type, fnc) \
- res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1); \
- res_##type##_2 = fnc(src1_##type##_2, src2_##type##_2); \
- res_##type##_3 = fnc(src1_##type##_3, src2_##type##_3); \
- res_##type##_4 = fnc(src1_##type##_4, src2_##type##_4);
-
-#define TEST_X_FUNC_X_X_X(type, fnc) \
- res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1, src2_##type##_1);
-
-#define TEST_IN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_YN(uc, fnc, uc) \
- TEST_XN_FUNC_YN(c, fnc, c) \
- TEST_XN_FUNC_YN(us, fnc, us) \
- TEST_XN_FUNC_YN(s, fnc, s) \
- TEST_XN_FUNC_YN(ui, fnc, ui) \
- TEST_XN_FUNC_YN(i, fnc, i)
-
-#define TEST_UIN_FUNC_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_YN(uc, fnc, c) \
- TEST_XN_FUNC_YN(us, fnc, s) \
- TEST_XN_FUNC_YN(ui, fnc, i) \
-
-#define TEST_IN_FUNC_IN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_XN_FUNC_XN_XN(uc, fnc) \
- TEST_XN_FUNC_XN_XN(c, fnc) \
- TEST_XN_FUNC_XN_XN(us, fnc) \
- TEST_XN_FUNC_XN_XN(s, fnc) \
- TEST_XN_FUNC_XN_XN(ui, fnc) \
- TEST_XN_FUNC_XN_XN(i, fnc)
-
-#define TEST_I_FUNC_I_I_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- TEST_X_FUNC_X_X_X(uc, fnc) \
- TEST_X_FUNC_X_X_X(c, fnc) \
- TEST_X_FUNC_X_X_X(us, fnc) \
- TEST_X_FUNC_X_X_X(s, fnc) \
- TEST_X_FUNC_X_X_X(ui, fnc) \
- TEST_X_FUNC_X_X_X(i, fnc)
-
-#define TEST_FN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1); \
- f2 = fnc(f2); \
- f3 = fnc(f3); \
- f4 = fnc(f4);
-
-#define TEST_FN_FUNC_FN_PFN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (float*) &f1); \
- f2 = fnc(f2, (float2*) &f2); \
- f3 = fnc(f3, (float3*) &f3); \
- f4 = fnc(f4, (float4*) &f4);
-
-#define TEST_FN_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f2); \
- f3 = fnc(f3, f3); \
- f4 = fnc(f4, f4);
-
-#define TEST_F34_FUNC_F34_F34(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f3 = fnc(f3, f3); \
- f4 = fnc(f4, f4);
-
-#define TEST_FN_FUNC_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f2 = fnc(f2, f1); \
- f3 = fnc(f3, f1); \
- f4 = fnc(f4, f1);
-
-#define TEST_F_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1); \
- f1 = fnc(f2); \
- f1 = fnc(f3); \
- f1 = fnc(f4);
-
-#define TEST_F_FUNC_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1); \
- f1 = fnc(f2, f2); \
- f1 = fnc(f3, f3); \
- f1 = fnc(f4, f4);
-
-#define TEST_FN_FUNC_FN_IN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i2); \
- f3 = fnc(f3, i3); \
- f4 = fnc(f4, i4);
-
-#define TEST_FN_FUNC_FN_I(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, i1); \
- f2 = fnc(f2, i1); \
- f3 = fnc(f3, i1); \
- f4 = fnc(f4, i1);
-
-#define TEST_FN_FUNC_FN_FN_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, f1); \
- f2 = fnc(f2, f2, f2); \
- f3 = fnc(f3, f3, f3); \
- f4 = fnc(f4, f4, f4);
-
-#define TEST_FN_FUNC_FN_FN_F(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, f1); \
- f2 = fnc(f2, f1, f1); \
- f3 = fnc(f3, f1, f1); \
- f4 = fnc(f4, f1, f1);
-
-#define TEST_FN_FUNC_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, (int*) &i1); \
- f2 = fnc(f2, (int2*) &i2); \
- f3 = fnc(f3, (int3*) &i3); \
- f4 = fnc(f4, (int4*) &i4);
-
-#define TEST_FN_FUNC_FN_FN_PIN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- f1 = fnc(f1, f1, (int*) &i1); \
- f2 = fnc(f2, f2, (int2*) &i2); \
- f3 = fnc(f3, f3, (int3*) &i3); \
- f4 = fnc(f4, f4, (int4*) &i4);
-
-#define TEST_IN_FUNC_FN(fnc) \
- rsDebug("Testing " #fnc, 0); \
- i1 = fnc(f1); \
- i2 = fnc(f2); \
- i3 = fnc(f3); \
- i4 = fnc(f4);
-
-static bool test_fp_math(uint32_t index) {
- bool failed = false;
- start();
-
- TEST_FN_FUNC_FN(acos);
- TEST_FN_FUNC_FN(acosh);
- TEST_FN_FUNC_FN(acospi);
- TEST_FN_FUNC_FN(asin);
- TEST_FN_FUNC_FN(asinh);
- TEST_FN_FUNC_FN(asinpi);
- TEST_FN_FUNC_FN(atan);
- TEST_FN_FUNC_FN_FN(atan2);
- TEST_FN_FUNC_FN(atanh);
- TEST_FN_FUNC_FN(atanpi);
- TEST_FN_FUNC_FN_FN(atan2pi);
- TEST_FN_FUNC_FN(cbrt);
- TEST_FN_FUNC_FN(ceil);
- TEST_FN_FUNC_FN_FN_FN(clamp);
- TEST_FN_FUNC_FN_FN_F(clamp);
- TEST_FN_FUNC_FN_FN(copysign);
- TEST_FN_FUNC_FN(cos);
- TEST_FN_FUNC_FN(cosh);
- TEST_FN_FUNC_FN(cospi);
- TEST_F34_FUNC_F34_F34(cross);
- TEST_FN_FUNC_FN(degrees);
- TEST_F_FUNC_FN_FN(distance);
- TEST_F_FUNC_FN_FN(dot);
- TEST_FN_FUNC_FN(erfc);
- TEST_FN_FUNC_FN(erf);
- TEST_FN_FUNC_FN(exp);
- TEST_FN_FUNC_FN(exp2);
- TEST_FN_FUNC_FN(exp10);
- TEST_FN_FUNC_FN(expm1);
- TEST_FN_FUNC_FN(fabs);
- TEST_FN_FUNC_FN_FN(fdim);
- TEST_FN_FUNC_FN(floor);
- TEST_FN_FUNC_FN_FN_FN(fma);
- TEST_FN_FUNC_FN_FN(fmax);
- TEST_FN_FUNC_FN_F(fmax);
- TEST_FN_FUNC_FN_FN(fmin);
- TEST_FN_FUNC_FN_F(fmin);
- TEST_FN_FUNC_FN_FN(fmod);
- TEST_FN_FUNC_FN_PFN(fract);
- TEST_FN_FUNC_FN_PIN(frexp);
- TEST_FN_FUNC_FN_FN(hypot);
- TEST_IN_FUNC_FN(ilogb);
- TEST_FN_FUNC_FN_IN(ldexp);
- TEST_FN_FUNC_FN_I(ldexp);
- TEST_F_FUNC_FN(length);
- TEST_FN_FUNC_FN(lgamma);
- TEST_FN_FUNC_FN_PIN(lgamma);
- TEST_FN_FUNC_FN(log);
- TEST_FN_FUNC_FN(log2);
- TEST_FN_FUNC_FN(log10);
- TEST_FN_FUNC_FN(log1p);
- TEST_FN_FUNC_FN(logb);
- TEST_FN_FUNC_FN_FN_FN(mad);
- TEST_FN_FUNC_FN_FN(max);
- TEST_FN_FUNC_FN_F(max);
- TEST_FN_FUNC_FN_FN(min);
- TEST_FN_FUNC_FN_F(min);
- TEST_FN_FUNC_FN_FN_FN(mix);
- TEST_FN_FUNC_FN_FN_F(mix);
- TEST_FN_FUNC_FN_PFN(modf);
- // nan
- TEST_FN_FUNC_FN_FN(nextafter);
- TEST_FN_FUNC_FN(normalize);
- TEST_FN_FUNC_FN_FN(pow);
- TEST_FN_FUNC_FN_IN(pown);
- TEST_FN_FUNC_FN_FN(powr);
- TEST_FN_FUNC_FN(radians);
- TEST_FN_FUNC_FN_FN(remainder);
- TEST_FN_FUNC_FN_FN_PIN(remquo);
- TEST_FN_FUNC_FN(rint);
- TEST_FN_FUNC_FN_IN(rootn);
- TEST_FN_FUNC_FN(round);
- TEST_FN_FUNC_FN(rsqrt);
- TEST_FN_FUNC_FN(sign);
- TEST_FN_FUNC_FN(sin);
- TEST_FN_FUNC_FN_PFN(sincos);
- TEST_FN_FUNC_FN(sinh);
- TEST_FN_FUNC_FN(sinpi);
- TEST_FN_FUNC_FN(sqrt);
- TEST_FN_FUNC_FN_FN(step);
- TEST_FN_FUNC_FN_F(step);
- TEST_FN_FUNC_FN(tan);
- TEST_FN_FUNC_FN(tanh);
- TEST_FN_FUNC_FN(tanpi);
- TEST_FN_FUNC_FN(tgamma);
- TEST_FN_FUNC_FN(trunc);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_fp_math FAILED", time);
- }
- else {
- rsDebug("test_fp_math PASSED", time);
- }
-
- return failed;
-}
-
-static bool test_int_math(uint32_t index) {
- bool failed = false;
- start();
-
- TEST_UIN_FUNC_IN(abs);
- TEST_IN_FUNC_IN(clz);
- TEST_IN_FUNC_IN_IN(min);
- TEST_IN_FUNC_IN_IN(max);
- TEST_I_FUNC_I_I_I(rsClamp);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_int_math FAILED", time);
- }
- else {
- rsDebug("test_int_math PASSED", time);
- }
-
- return failed;
-}
-
-static bool test_basic_operators() {
- bool failed = false;
- int i = 0;
-
- TEST_INT_OP(+);
- TEST_INT_OP(-);
- TEST_INT_OP(*);
- TEST_INT_OP(/);
- TEST_INT_OP(%);
- TEST_INT_OP(<<);
- TEST_INT_OP(>>);
-
- if (failed) {
- rsDebug("test_basic_operators FAILED", 0);
- }
- else {
- rsDebug("test_basic_operators PASSED", 0);
- }
-
- return failed;
-}
-
-#define TEST_CVT(to, from, type) \
-rsDebug("Testing convert from " #from " to " #to, 0); \
-to##1 = from##1; \
-to##2 = convert_##type##2(from##2); \
-to##3 = convert_##type##3(from##3); \
-to##4 = convert_##type##4(from##4);
-
-#define TEST_CVT_MATRIX(to, type) \
-TEST_CVT(to, c, type); \
-TEST_CVT(to, uc, type); \
-TEST_CVT(to, s, type); \
-TEST_CVT(to, us, type); \
-TEST_CVT(to, i, type); \
-TEST_CVT(to, ui, type); \
-TEST_CVT(to, f, type); \
-
-static bool test_convert() {
- bool failed = false;
-
- TEST_CVT_MATRIX(c, char);
- TEST_CVT_MATRIX(uc, uchar);
- TEST_CVT_MATRIX(s, short);
- TEST_CVT_MATRIX(us, ushort);
- TEST_CVT_MATRIX(i, int);
- TEST_CVT_MATRIX(ui, uint);
- TEST_CVT_MATRIX(f, float);
-
- if (failed) {
- rsDebug("test_convert FAILED", 0);
- }
- else {
- rsDebug("test_convert PASSED", 0);
- }
-
- return failed;
-}
-
-void math_test(uint32_t index, int test_num) {
- bool failed = false;
- failed |= test_convert();
- failed |= test_fp_math(index);
- failed |= test_int_math(index);
- failed |= test_basic_operators();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/primitives.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/primitives.rs
deleted file mode 100644
index ce451da..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/primitives.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "shared.rsh"
-
-// Testing primitive types
-float floatTest = 1.99f;
-double doubleTest = 2.05;
-char charTest = -8;
-short shortTest = -16;
-int intTest = -32;
-long longTest = 17179869184l; // 1 << 34
-long long longlongTest = 68719476736l; // 1 << 36
-
-uchar ucharTest = 8;
-ushort ushortTest = 16;
-uint uintTest = 32;
-ulong ulongTest = 4611686018427387904L;
-int64_t int64_tTest = -17179869184l; // - 1 << 34
-uint64_t uint64_tTest = 117179869184l;
-
-static bool test_primitive_types(uint32_t index) {
- bool failed = false;
- start();
-
- _RS_ASSERT(floatTest == 2.99f);
- _RS_ASSERT(doubleTest == 3.05);
- _RS_ASSERT(charTest == -16);
- _RS_ASSERT(shortTest == -32);
- _RS_ASSERT(intTest == -64);
- _RS_ASSERT(longTest == 17179869185l);
- _RS_ASSERT(longlongTest == 68719476735l);
-
- _RS_ASSERT(ucharTest == 8);
- _RS_ASSERT(ushortTest == 16);
- _RS_ASSERT(uintTest == 32);
- _RS_ASSERT(ulongTest == 4611686018427387903L);
- _RS_ASSERT(int64_tTest == -17179869184l);
- _RS_ASSERT(uint64_tTest == 117179869185l);
-
- float time = end(index);
-
- if (failed) {
- rsDebug("test_primitives FAILED", time);
- }
- else {
- rsDebug("test_primitives PASSED", time);
- }
-
- return failed;
-}
-
-void primitives_test(uint32_t index, int test_num) {
- bool failed = false;
- failed |= test_primitive_types(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/refcount.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/refcount.rs
deleted file mode 100644
index 4ea70e2..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/refcount.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "shared.rsh"
-
-// Testing reference counting of RS object types
-
-rs_allocation globalA;
-static rs_allocation staticGlobalA;
-
-void refcount_test() {
- staticGlobalA = globalA;
- rsClearObject(&globalA);
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
-}
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rsdebug.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rsdebug.rs
deleted file mode 100644
index f7942a5..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rsdebug.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "shared.rsh"
-
-// Testing primitive types
-float floatTest = 1.99f;
-double doubleTest = 2.05;
-char charTest = -8;
-short shortTest = -16;
-int intTest = -32;
-long longTest = 17179869184l; // 1 << 34
-long long longlongTest = 68719476736l; // 1 << 36
-
-uchar ucharTest = 8;
-ushort ushortTest = 16;
-uint uintTest = 32;
-ulong ulongTest = 4611686018427387904L;
-int64_t int64_tTest = -17179869184l; // - 1 << 34
-uint64_t uint64_tTest = 117179869184l;
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- // This test focuses primarily on compilation-time, not run-time.
- // For this reason, none of the outputs are actually checked.
-
- rsDebug("floatTest", floatTest);
- rsDebug("doubleTest", doubleTest);
- rsDebug("charTest", charTest);
- rsDebug("shortTest", shortTest);
- rsDebug("intTest", intTest);
- rsDebug("longTest", longTest);
- rsDebug("longlongTest", longlongTest);
-
- rsDebug("ucharTest", ucharTest);
- rsDebug("ushortTest", ushortTest);
- rsDebug("uintTest", uintTest);
- rsDebug("ulongTest", ulongTest);
- rsDebug("int64_tTest", int64_tTest);
- rsDebug("uint64_tTest", uint64_tTest);
-
- return failed;
-}
-
-void test_rsdebug(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rsdebug_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rsdebug_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rslist.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rslist.rs
deleted file mode 100644
index b3d8b9e..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rslist.rs
+++ /dev/null
@@ -1,107 +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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test_v14)
-
-#include "rs_graphics.rsh"
-
-float gDY;
-
-rs_font gFont;
-
-typedef struct ListAllocs_s {
- rs_allocation text;
- int result;
-} ListAllocs;
-
-ListAllocs *gList;
-
-void init() {
- gDY = 0.0f;
-}
-
-int textPos = 0;
-
-int root(void) {
-
- rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- rsgClearDepth(1.0f);
-
- textPos -= (int)gDY*2;
- gDY *= 0.95;
-
- rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f);
- rsgBindFont(gFont);
-
- rs_allocation listAlloc;
- listAlloc = rsGetAllocation(gList);
- int allocSize = rsAllocationGetDimX(listAlloc);
-
- int width = rsgGetWidth();
- int height = rsgGetHeight();
-
- int itemHeight = 80;
- int totalItemHeight = itemHeight * allocSize;
-
- /* Prevent scrolling above the top of the list */
- int firstItem = height - totalItemHeight;
- if (firstItem < 0) {
- firstItem = 0;
- }
-
- /* Prevent scrolling past the last line of the list */
- int lastItem = -1 * (totalItemHeight - height);
- if (lastItem > 0) {
- lastItem = 0;
- }
-
- if (textPos > firstItem) {
- textPos = firstItem;
- }
- else if (textPos < lastItem) {
- textPos = lastItem;
- }
-
- int currentYPos = itemHeight + textPos;
-
- for(int i = 0; i < allocSize; i ++) {
- if(currentYPos - itemHeight > height) {
- break;
- }
-
- if(currentYPos > 0) {
- switch(gList[i].result) {
- case 1: /* Passed */
- rsgFontColor(0.5f, 0.9f, 0.5f, 1.0f);
- break;
- case -1: /* Failed */
- rsgFontColor(0.9f, 0.5f, 0.5f, 1.0f);
- break;
- case 0: /* Still Testing */
- rsgFontColor(0.9f, 0.9f, 0.5f, 1.0f);
- break;
- default: /* Unknown */
- rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f);
- break;
- }
- rsgDrawRect(0, currentYPos - 1, width, currentYPos, 0);
- rsgDrawText(gList[i].text, 30, currentYPos - 32);
- }
- currentYPos += itemHeight;
- }
-
- return 10;
-}
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rstime.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rstime.rs
deleted file mode 100644
index 5e3e078..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rstime.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "shared.rsh"
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- rs_time_t curTime = rsTime(0);
- rs_tm tm;
- rsDebug("curTime", curTime);
-
- rsLocaltime(&tm, &curTime);
-
- rsDebug("tm.tm_sec", tm.tm_sec);
- rsDebug("tm.tm_min", tm.tm_min);
- rsDebug("tm.tm_hour", tm.tm_hour);
- rsDebug("tm.tm_mday", tm.tm_mday);
- rsDebug("tm.tm_mon", tm.tm_mon);
- rsDebug("tm.tm_year", tm.tm_year);
- rsDebug("tm.tm_wday", tm.tm_wday);
- rsDebug("tm.tm_yday", tm.tm_yday);
- rsDebug("tm.tm_isdst", tm.tm_isdst);
-
- // Test a specific time (only valid for PST localtime)
- curTime = 1294438893;
- rsLocaltime(&tm, &curTime);
-
- _RS_ASSERT(tm.tm_sec == 33);
- _RS_ASSERT(tm.tm_min == 21);
- _RS_ASSERT(tm.tm_hour == 14);
- _RS_ASSERT(tm.tm_mday == 7);
- _RS_ASSERT(tm.tm_mon == 0);
- _RS_ASSERT(tm.tm_year == 111);
- _RS_ASSERT(tm.tm_wday == 5);
- _RS_ASSERT(tm.tm_yday == 6);
- _RS_ASSERT(tm.tm_isdst == 0);
-
- return failed;
-}
-
-void test_rstime(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rstime_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rstime_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rstypes.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rstypes.rs
deleted file mode 100644
index 22d9c13..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/rstypes.rs
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "shared.rsh"
-#include "rs_graphics.rsh"
-
-rs_element elementTest;
-rs_type typeTest;
-rs_allocation allocationTest;
-rs_sampler samplerTest;
-rs_script scriptTest;
-rs_mesh meshTest;
-rs_program_fragment program_fragmentTest;
-rs_program_vertex program_vertexTest;
-rs_program_raster program_rasterTest;
-rs_program_store program_storeTest;
-rs_font fontTest;
-
-rs_matrix4x4 matrix4x4Test;
-rs_matrix3x3 matrix3x3Test;
-rs_matrix2x2 matrix2x2Test;
-
-struct my_struct {
- int i;
- rs_font fontTestStruct;
-};
-
-static bool basic_test(uint32_t index) {
- bool failed = false;
-
- rs_matrix4x4 matrix4x4TestLocal;
- rs_matrix3x3 matrix3x3TestLocal;
- rs_matrix2x2 matrix2x2TestLocal;
-
- // This test focuses primarily on compilation-time, not run-time.
- rs_element elementTestLocal;
- rs_type typeTestLocal;
- rs_allocation allocationTestLocal;
- rs_sampler samplerTestLocal;
- rs_script scriptTestLocal;
- rs_mesh meshTestLocal;
- rs_program_fragment program_fragmentTestLocal;
- rs_program_vertex program_vertexTestLocal;
- rs_program_raster program_rasterTestLocal;
- rs_program_store program_storeTestLocal;
- rs_font fontTestLocal;
-
- rs_font fontTestLocalArray[4];
-
- rs_font fontTestLocalPreInit = fontTest;
-
- struct my_struct structTest;
-
- fontTestLocal = fontTest;
- //allocationTestLocal = allocationTest;
-
- fontTest = fontTestLocal;
- //allocationTest = allocationTestLocal;
-
- /*for (int i = 0; i < 4; i++) {
- fontTestLocalArray[i] = fontTestLocal;
- }*/
-
- /*fontTest = fontTestLocalArray[3];*/
-
- return failed;
-}
-
-void test_rstypes(uint32_t index, int test_num) {
- bool failed = false;
- failed |= basic_test(index);
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- rsDebug("rstypes_test FAILED", -1);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- rsDebug("rstypes_test PASSED", 0);
- }
-}
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/shared.rsh b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/shared.rsh
deleted file mode 100644
index 4a7151f..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/shared.rsh
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test_v14)
-
-typedef struct TestResult_s {
- rs_allocation name;
- bool pass;
- float score;
- int64_t time;
-} TestResult;
-//TestResult *g_results;
-
-static int64_t g_time;
-
-static void start(void) {
- g_time = rsUptimeMillis();
-}
-
-static float end(uint32_t idx) {
- int64_t t = rsUptimeMillis() - g_time;
- //g_results[idx].time = t;
- //rsDebug("test time", (int)t);
- return ((float)t) / 1000.f;
-}
-
-#define _RS_ASSERT(b) \
-do { \
- if (!(b)) { \
- failed = true; \
- rsDebug(#b " FAILED", 0); \
- } \
-\
-} while (0)
-
-/* These constants must match those in UnitTest.java */
-static const int RS_MSG_TEST_PASSED = 100;
-static const int RS_MSG_TEST_FAILED = 101;
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/test_root.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/test_root.rs
deleted file mode 100644
index 88fe34a..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/test_root.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Fountain test script
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.rs.test_v14)
-
-#pragma stateFragment(parent)
-
-#include "rs_graphics.rsh"
-
-
-typedef struct TestResult {
- rs_allocation name;
- bool pass;
- float score;
-} TestResult_t;
-TestResult_t *results;
-
-int root() {
-
- return 0;
-}
-
-
diff --git a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/vector.rs b/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/vector.rs
deleted file mode 100644
index 0430a2f..0000000
--- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/vector.rs
+++ /dev/null
@@ -1,198 +0,0 @@
-#include "shared.rsh"
-
-// Testing vector types
-float2 f2 = { 1.0f, 2.0f };
-float3 f3 = { 1.0f, 2.0f, 3.0f };
-float4 f4 = { 1.0f, 2.0f, 3.0f, 4.0f };
-
-double2 d2 = { 1.0, 2.0 };
-double3 d3 = { 1.0, 2.0, 3.0 };
-double4 d4 = { 1.0, 2.0, 3.0, 4.0 };
-
-char2 i8_2 = { 1, 2 };
-char3 i8_3 = { 1, 2, 3 };
-char4 i8_4 = { 1, 2, 3, 4 };
-
-uchar2 u8_2 = { 1, 2 };
-uchar3 u8_3 = { 1, 2, 3 };
-uchar4 u8_4 = { 1, 2, 3, 4 };
-
-short2 i16_2 = { 1, 2 };
-short3 i16_3 = { 1, 2, 3 };
-short4 i16_4 = { 1, 2, 3, 4 };
-
-ushort2 u16_2 = { 1, 2 };
-ushort3 u16_3 = { 1, 2, 3 };
-ushort4 u16_4 = { 1, 2, 3, 4 };
-
-int2 i32_2 = { 1, 2 };
-int3 i32_3 = { 1, 2, 3 };
-int4 i32_4 = { 1, 2, 3, 4 };
-
-uint2 u32_2 = { 1, 2 };
-uint3 u32_3 = { 1, 2, 3 };
-uint4 u32_4 = { 1, 2, 3, 4 };
-
-long2 i64_2 = { 1, 2 };
-long3 i64_3 = { 1, 2, 3 };
-long4 i64_4 = { 1, 2, 3, 4 };
-
-ulong2 u64_2 = { 1, 2 };
-ulong3 u64_3 = { 1, 2, 3 };
-ulong4 u64_4 = { 1, 2, 3, 4 };
-
-static bool test_vector_types() {
- bool failed = false;
-
- rsDebug("Testing F32", 0);
- _RS_ASSERT(f2.x == 2.99f);
- _RS_ASSERT(f2.y == 3.99f);
-
- _RS_ASSERT(f3.x == 2.99f);
- _RS_ASSERT(f3.y == 3.99f);
- _RS_ASSERT(f3.z == 4.99f);
-
- _RS_ASSERT(f4.x == 2.99f);
- _RS_ASSERT(f4.y == 3.99f);
- _RS_ASSERT(f4.z == 4.99f);
- _RS_ASSERT(f4.w == 5.99f);
-
- rsDebug("Testing F64", 0);
- _RS_ASSERT(d2.x == 2.99);
- _RS_ASSERT(d2.y == 3.99);
-
- _RS_ASSERT(d3.x == 2.99);
- _RS_ASSERT(d3.y == 3.99);
- _RS_ASSERT(d3.z == 4.99);
-
- _RS_ASSERT(d4.x == 2.99);
- _RS_ASSERT(d4.y == 3.99);
- _RS_ASSERT(d4.z == 4.99);
- _RS_ASSERT(d4.w == 5.99);
-
- rsDebug("Testing I8", 0);
- _RS_ASSERT(i8_2.x == 2);
- _RS_ASSERT(i8_2.y == 3);
-
- _RS_ASSERT(i8_3.x == 2);
- _RS_ASSERT(i8_3.y == 3);
- _RS_ASSERT(i8_3.z == 4);
-
- _RS_ASSERT(i8_4.x == 2);
- _RS_ASSERT(i8_4.y == 3);
- _RS_ASSERT(i8_4.z == 4);
- _RS_ASSERT(i8_4.w == 5);
-
- rsDebug("Testing U8", 0);
- _RS_ASSERT(u8_2.x == 2);
- _RS_ASSERT(u8_2.y == 3);
-
- _RS_ASSERT(u8_3.x == 2);
- _RS_ASSERT(u8_3.y == 3);
- _RS_ASSERT(u8_3.z == 4);
-
- _RS_ASSERT(u8_4.x == 2);
- _RS_ASSERT(u8_4.y == 3);
- _RS_ASSERT(u8_4.z == 4);
- _RS_ASSERT(u8_4.w == 5);
-
- rsDebug("Testing I16", 0);
- _RS_ASSERT(i16_2.x == 2);
- _RS_ASSERT(i16_2.y == 3);
-
- _RS_ASSERT(i16_3.x == 2);
- _RS_ASSERT(i16_3.y == 3);
- _RS_ASSERT(i16_3.z == 4);
-
- _RS_ASSERT(i16_4.x == 2);
- _RS_ASSERT(i16_4.y == 3);
- _RS_ASSERT(i16_4.z == 4);
- _RS_ASSERT(i16_4.w == 5);
-
- rsDebug("Testing U16", 0);
- _RS_ASSERT(u16_2.x == 2);
- _RS_ASSERT(u16_2.y == 3);
-
- _RS_ASSERT(u16_3.x == 2);
- _RS_ASSERT(u16_3.y == 3);
- _RS_ASSERT(u16_3.z == 4);
-
- _RS_ASSERT(u16_4.x == 2);
- _RS_ASSERT(u16_4.y == 3);
- _RS_ASSERT(u16_4.z == 4);
- _RS_ASSERT(u16_4.w == 5);
-
- rsDebug("Testing I32", 0);
- _RS_ASSERT(i32_2.x == 2);
- _RS_ASSERT(i32_2.y == 3);
-
- _RS_ASSERT(i32_3.x == 2);
- _RS_ASSERT(i32_3.y == 3);
- _RS_ASSERT(i32_3.z == 4);
-
- _RS_ASSERT(i32_4.x == 2);
- _RS_ASSERT(i32_4.y == 3);
- _RS_ASSERT(i32_4.z == 4);
- _RS_ASSERT(i32_4.w == 5);
-
- rsDebug("Testing U32", 0);
- _RS_ASSERT(u32_2.x == 2);
- _RS_ASSERT(u32_2.y == 3);
-
- _RS_ASSERT(u32_3.x == 2);
- _RS_ASSERT(u32_3.y == 3);
- _RS_ASSERT(u32_3.z == 4);
-
- _RS_ASSERT(u32_4.x == 2);
- _RS_ASSERT(u32_4.y == 3);
- _RS_ASSERT(u32_4.z == 4);
- _RS_ASSERT(u32_4.w == 5);
-
- rsDebug("Testing I64", 0);
- _RS_ASSERT(i64_2.x == 2);
- _RS_ASSERT(i64_2.y == 3);
-
- _RS_ASSERT(i64_3.x == 2);
- _RS_ASSERT(i64_3.y == 3);
- _RS_ASSERT(i64_3.z == 4);
-
- _RS_ASSERT(i64_4.x == 2);
- _RS_ASSERT(i64_4.y == 3);
- _RS_ASSERT(i64_4.z == 4);
- _RS_ASSERT(i64_4.w == 5);
-
- rsDebug("Testing U64", 0);
- _RS_ASSERT(u64_2.x == 2);
- _RS_ASSERT(u64_2.y == 3);
-
- _RS_ASSERT(u64_3.x == 2);
- _RS_ASSERT(u64_3.y == 3);
- _RS_ASSERT(u64_3.z == 4);
-
- _RS_ASSERT(u64_4.x == 2);
- _RS_ASSERT(u64_4.y == 3);
- _RS_ASSERT(u64_4.z == 4);
- _RS_ASSERT(u64_4.w == 5);
-
- if (failed) {
- rsDebug("test_vector FAILED", 0);
- }
- else {
- rsDebug("test_vector PASSED", 0);
- }
-
- return failed;
-}
-
-void vector_test() {
- bool failed = false;
- failed |= test_vector_types();
-
- if (failed) {
- rsSendToClientBlocking(RS_MSG_TEST_FAILED);
- }
- else {
- rsSendToClientBlocking(RS_MSG_TEST_PASSED);
- }
-}
-
diff --git a/tests/SharedLibrary/lib/src/com/google/android/test/shared_library/SharedLibraryMain.java b/tests/SharedLibrary/lib/src/com/google/android/test/shared_library/SharedLibraryMain.java
index c1cd925..2c61b77 100644
--- a/tests/SharedLibrary/lib/src/com/google/android/test/shared_library/SharedLibraryMain.java
+++ b/tests/SharedLibrary/lib/src/com/google/android/test/shared_library/SharedLibraryMain.java
@@ -17,16 +17,14 @@
package com.google.android.test.shared_library;
import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
+import android.app.Fragment;
+import android.app.FragmentManager;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.content.res.Resources;
public class SharedLibraryMain {
- private static String LIBRARY_PACKAGE = "com.google.android.test.shared_library";
+ static String LIBRARY_PACKAGE = "com.google.android.test.shared_library";
/**
* Base version of the library.
@@ -38,6 +36,9 @@
*/
public static int VERSION_SECOND = 2;
+ /**
+ * Return the version number of the currently installed library.
+ */
public static int getVersion(Context context) {
PackageInfo pi = null;
try {
@@ -48,40 +49,34 @@
}
}
- public static void ensureVersion(Activity activity, int minVersion) {
+ /**
+ * Check that the library's version is at least the given minimum version,
+ * displaying a dialog to have the user install an update if that is not true.
+ * The dialog is displayed as a DialogFragment in your activity if a newer
+ * version is needed. If a newer version is needed, false is returned.
+ */
+ public static boolean ensureVersion(final Activity activity, int minVersion) {
+ final FragmentManager fm = activity.getFragmentManager();
+ final String dialogTag = LIBRARY_PACKAGE + ":version";
+ Fragment curDialog = fm.findFragmentByTag(dialogTag);
+
if (getVersion(activity) >= minVersion) {
- return;
+ // Library version is sufficient. Make sure any version dialog
+ // we had shown is removed before returning.
+ if (curDialog != null) {
+ fm.beginTransaction().remove(curDialog).commitAllowingStateLoss();
+ }
+ return true;
}
- // The current version of the library does not meet the required version. Show
- // a dialog to inform the user and have them update to the current version.
- // Note that updating the library will be necessity mean killing the current
- // application (so it can be re-started with the new version, so there is no
- // reason to return a result here.
- final Context context;
- try {
- context = activity.createPackageContext(LIBRARY_PACKAGE, 0);
- } catch (PackageManager.NameNotFoundException e) {
- throw new IllegalStateException("Can't find my package!", e);
+ // The current version of the library does not meet the required version.
+ // If we don't already have a version dialog displayed, display it now.
+ if (curDialog == null) {
+ curDialog = new VersionDialog();
+ fm.beginTransaction().add(curDialog, dialogTag).commitAllowingStateLoss();
}
- // Display the dialog. Note that we don't need to deal with activity lifecycle
- // stuff because if the activity gets recreated, it will first call through to
- // ensureVersion(), causing us to either re-display the dialog if needed or let
- // it now proceed.
- final Resources res = context.getResources();
- AlertDialog.Builder builder = new AlertDialog.Builder(activity);
- builder.setTitle(res.getText(R.string.upgrade_title));
- builder.setMessage(res.getString(R.string.upgrade_body,
- activity.getApplicationInfo().loadLabel(activity.getPackageManager()),
- context.getApplicationInfo().loadLabel(context.getPackageManager())));
- builder.setPositiveButton(res.getText(R.string.upgrade_button),
- new Dialog.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // Launch play store.
- }
- });
- builder.show();
+ // Tell the caller that the current version is not sufficient.
+ return false;
}
}
diff --git a/tests/SharedLibrary/lib/src/com/google/android/test/shared_library/VersionDialog.java b/tests/SharedLibrary/lib/src/com/google/android/test/shared_library/VersionDialog.java
new file mode 100644
index 0000000..f457532
--- /dev/null
+++ b/tests/SharedLibrary/lib/src/com/google/android/test/shared_library/VersionDialog.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 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.google.android.test.shared_library;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.net.Uri;
+import android.os.Bundle;
+
+/**
+ * This is the dialog we show when the library's version is older than
+ * the version the app needs.
+ */
+public class VersionDialog extends DialogFragment {
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final Activity activity = getActivity();
+
+ // Need to use our library's resources for showing the dialog.
+ final Context context;
+ try {
+ context = activity.createPackageContext(SharedLibraryMain.LIBRARY_PACKAGE, 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ throw new IllegalStateException("Can't find my package!", e);
+ }
+
+ final Resources res = context.getResources();
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ builder.setTitle(res.getText(R.string.upgrade_title));
+ builder.setMessage(res.getString(R.string.upgrade_body,
+ activity.getApplicationInfo().loadLabel(activity.getPackageManager()),
+ context.getApplicationInfo().loadLabel(context.getPackageManager())));
+ builder.setPositiveButton(res.getText(R.string.upgrade_button),
+ new Dialog.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // Launch play store into the details of our app.
+ try {
+ activity.startActivity(new Intent(Intent.ACTION_VIEW,
+ Uri.parse("market://details?id="
+ + SharedLibraryMain.LIBRARY_PACKAGE)));
+ } catch (android.content.ActivityNotFoundException anfe) {
+ activity.startActivity(new Intent(Intent.ACTION_VIEW,
+ Uri.parse("http://play.google.com/store/apps/details?id="
+ + SharedLibraryMain.LIBRARY_PACKAGE)));
+ }
+ }
+ });
+ return builder.create();
+ }
+}
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 8cdfe03..b57910f 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -3584,6 +3584,8 @@
setWifiApState(WIFI_AP_STATE_DISABLING);
stopTethering();
transitionTo(mUntetheringState);
+ // More work to do after untethering
+ deferMessage(message);
break;
default:
return NOT_HANDLED;
@@ -3610,15 +3612,11 @@
if (isWifiTethered(stateChange.active)) break;
transitionTo(mSoftApStartedState);
- // Needs to be first thing handled
- sendMessageAtFrontOfQueue(CMD_STOP_AP);
break;
case CMD_TETHER_NOTIFICATION_TIMED_OUT:
if (message.arg1 == mTetherToken) {
loge("Failed to get tether update, force stop access point");
transitionTo(mSoftApStartedState);
- // Needs to be first thing handled
- sendMessageAtFrontOfQueue(CMD_STOP_AP);
}
break;
case CMD_START_SUPPLICANT:
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java
index 55ea34f..81d2e11 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -252,4 +252,14 @@
public void setDependencyMet(boolean met) {
// not supported on this network
}
+
+ @Override
+ public void addStackedLink(LinkProperties link) {
+ mLinkProperties.addStackedLink(link);
+ }
+
+ @Override
+ public void removeStackedLink(LinkProperties link) {
+ mLinkProperties.removeStackedLink(link);
+ }
}