diff options
Diffstat (limited to 'tests')
347 files changed, 3513 insertions, 22791 deletions
diff --git a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java index f0c3b22..c7cd975 100644 --- a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java +++ b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java @@ -237,7 +237,7 @@ public class ActivityTestMain extends Activity { Log.i(TAG, "Service disconnected " + name); } }; - if (bindService(intent, conn, Context.BIND_AUTO_CREATE, 0)) { + if (bindServiceAsUser(intent, conn, Context.BIND_AUTO_CREATE, UserHandle.OWNER)) { mConnections.add(conn); } else { Toast.makeText(ActivityTestMain.this, "Failed to bind", @@ -260,7 +260,8 @@ public class ActivityTestMain extends Activity { Log.i(TAG, "Service disconnected " + name); } }; - if (bindService(intent, conn, Context.BIND_AUTO_CREATE, mSecondUser)) { + if (bindServiceAsUser(intent, conn, Context.BIND_AUTO_CREATE, + new UserHandle(mSecondUser))) { mConnections.add(conn); } else { Toast.makeText(ActivityTestMain.this, "Failed to bind", diff --git a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java index e2cb65d..62f6aff 100644 --- a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java +++ b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 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,6 +15,8 @@ */ package com.android.tests.applaunch; +import android.accounts.Account; +import android.accounts.AccountManager; import android.app.ActivityManager; import android.app.ActivityManager.ProcessErrorStateInfo; import android.app.ActivityManagerNative; @@ -32,9 +34,12 @@ import android.test.InstrumentationTestCase; import android.test.InstrumentationTestRunner; import android.util.Log; +import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; /** * This test is intended to measure the time it takes for the apps to start. @@ -48,43 +53,88 @@ import java.util.Map; public class AppLaunch extends InstrumentationTestCase { private static final int JOIN_TIMEOUT = 10000; - private static final String TAG = "AppLaunch"; + private static final String TAG = AppLaunch.class.getSimpleName(); private static final String KEY_APPS = "apps"; + private static final String KEY_LAUNCH_ITERATIONS = "launch_iterations"; + // optional parameter: comma separated list of required account types before proceeding + // with the app launch + private static final String KEY_REQUIRED_ACCOUNTS = "required_accounts"; + private static final int INITIAL_LAUNCH_IDLE_TIMEOUT = 7500; //7.5s to allow app to idle + private static final int POST_LAUNCH_IDLE_TIMEOUT = 750; //750ms idle for non initial launches + private static final int BETWEEN_LAUNCH_SLEEP_TIMEOUT = 2000; //2s between launching apps private Map<String, Intent> mNameToIntent; private Map<String, String> mNameToProcess; private Map<String, String> mNameToResultKey; - + private Map<String, Long> mNameToLaunchTime; private IActivityManager mAm; + private int mLaunchIterations = 10; + private Bundle mResult = new Bundle(); + private Set<String> mRequiredAccounts; - public void testMeasureStartUpTime() throws RemoteException { + public void testMeasureStartUpTime() throws RemoteException, NameNotFoundException { InstrumentationTestRunner instrumentation = (InstrumentationTestRunner)getInstrumentation(); - Bundle args = instrumentation.getBundle(); + Bundle args = instrumentation.getArguments(); mAm = ActivityManagerNative.getDefault(); createMappings(); parseArgs(args); + checkAccountSignIn(); - Bundle results = new Bundle(); + // do initial app launch, without force stopping for (String app : mNameToResultKey.keySet()) { - try { - startApp(app, results); - sleep(750); - closeApp(app); - sleep(2000); - } catch (NameNotFoundException e) { - Log.i(TAG, "Application " + app + " not found"); + long launchTime = startApp(app, false); + if (launchTime <=0 ) { + mNameToLaunchTime.put(app, -1L); + // simply pass the app if launch isn't successful + // error should have already been logged by startApp + continue; + } + sleep(INITIAL_LAUNCH_IDLE_TIMEOUT); + closeApp(app, false); + sleep(BETWEEN_LAUNCH_SLEEP_TIMEOUT); + } + // do the real app launch now + for (int i = 0; i < mLaunchIterations; i++) { + for (String app : mNameToResultKey.keySet()) { + long totalLaunchTime = mNameToLaunchTime.get(app); + long launchTime = 0; + if (totalLaunchTime < 0) { + // skip if the app has previous failures + continue; + } + launchTime = startApp(app, true); + if (launchTime <= 0) { + // if it fails once, skip the rest of the launches + mNameToLaunchTime.put(app, -1L); + continue; + } + totalLaunchTime += launchTime; + mNameToLaunchTime.put(app, totalLaunchTime); + sleep(POST_LAUNCH_IDLE_TIMEOUT); + closeApp(app, true); + sleep(BETWEEN_LAUNCH_SLEEP_TIMEOUT); + } + } + for (String app : mNameToResultKey.keySet()) { + long totalLaunchTime = mNameToLaunchTime.get(app); + if (totalLaunchTime != -1) { + mResult.putDouble(mNameToResultKey.get(app), + ((double) totalLaunchTime) / mLaunchIterations); } - } - instrumentation.sendStatus(0, results); + instrumentation.sendStatus(0, mResult); } private void parseArgs(Bundle args) { mNameToResultKey = new LinkedHashMap<String, String>(); + mNameToLaunchTime = new HashMap<String, Long>(); + String launchIterations = args.getString(KEY_LAUNCH_ITERATIONS); + if (launchIterations != null) { + mLaunchIterations = Integer.parseInt(launchIterations); + } String appList = args.getString(KEY_APPS); - if (appList == null) return; @@ -97,6 +147,14 @@ public class AppLaunch extends InstrumentationTestCase { } mNameToResultKey.put(parts[0], parts[1]); + mNameToLaunchTime.put(parts[0], 0L); + } + String requiredAccounts = args.getString(KEY_REQUIRED_ACCOUNTS); + if (requiredAccounts != null) { + mRequiredAccounts = new HashSet<String>(); + for (String accountType : requiredAccounts.split(",")) { + mRequiredAccounts.add(accountType); + } } } @@ -118,23 +176,26 @@ public class AppLaunch extends InstrumentationTestCase { | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); startIntent.setClassName(ri.activityInfo.packageName, ri.activityInfo.name); - mNameToIntent.put(ri.loadLabel(pm).toString(), startIntent); - mNameToProcess.put(ri.loadLabel(pm).toString(), - ri.activityInfo.processName); + String appName = ri.loadLabel(pm).toString(); + if (appName != null) { + mNameToIntent.put(appName, startIntent); + mNameToProcess.put(appName, ri.activityInfo.processName); + } } } } - private void startApp(String appName, Bundle results) + private long startApp(String appName, boolean forceStopBeforeLaunch) throws NameNotFoundException, RemoteException { Log.i(TAG, "Starting " + appName); Intent startIntent = mNameToIntent.get(appName); if (startIntent == null) { Log.w(TAG, "App does not exist: " + appName); - return; + mResult.putString(mNameToResultKey.get(appName), "App does not exist"); + return -1; } - AppLaunchRunnable runnable = new AppLaunchRunnable(startIntent); + AppLaunchRunnable runnable = new AppLaunchRunnable(startIntent, forceStopBeforeLaunch); Thread t = new Thread(runnable); t.start(); try { @@ -143,27 +204,69 @@ public class AppLaunch extends InstrumentationTestCase { // ignore } WaitResult result = runnable.getResult(); - if(t.isAlive() || (result != null && result.result != ActivityManager.START_SUCCESS)) { + // report error if any of the following is true: + // * launch thread is alive + // * result is not null, but: + // * result is not START_SUCESS + // * or in case of no force stop, result is not TASK_TO_FRONT either + if (t.isAlive() || (result != null + && ((result.result != ActivityManager.START_SUCCESS) + && (!forceStopBeforeLaunch + && result.result != ActivityManager.START_TASK_TO_FRONT)))) { Log.w(TAG, "Assuming app " + appName + " crashed."); - reportError(appName, mNameToProcess.get(appName), results); + reportError(appName, mNameToProcess.get(appName)); + return -1; + } + return result.thisTime; + } + + private void checkAccountSignIn() { + // ensure that the device has the required account types before starting test + // e.g. device must have a valid Google account sign in to measure a meaningful launch time + // for Gmail + if (mRequiredAccounts == null || mRequiredAccounts.isEmpty()) { return; } - results.putString(mNameToResultKey.get(appName), String.valueOf(result.thisTime)); + final AccountManager am = + (AccountManager) getInstrumentation().getTargetContext().getSystemService( + Context.ACCOUNT_SERVICE); + Account[] accounts = am.getAccounts(); + // use set here in case device has multiple accounts of the same type + Set<String> foundAccounts = new HashSet<String>(); + for (Account account : accounts) { + if (mRequiredAccounts.contains(account.type)) { + foundAccounts.add(account.type); + } + } + // check if account type matches, if not, fail test with message on what account types + // are missing + if (mRequiredAccounts.size() != foundAccounts.size()) { + mRequiredAccounts.removeAll(foundAccounts); + StringBuilder sb = new StringBuilder("Device missing these accounts:"); + for (String account : mRequiredAccounts) { + sb.append(' '); + sb.append(account); + } + fail(sb.toString()); + } } - private void closeApp(String appName) { + private void closeApp(String appName, boolean forceStopApp) { Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); getInstrumentation().getContext().startActivity(homeIntent); - Intent startIntent = mNameToIntent.get(appName); - if (startIntent != null) { - String packageName = startIntent.getComponent().getPackageName(); - try { - mAm.forceStopPackage(packageName, UserHandle.USER_CURRENT); - } catch (RemoteException e) { - Log.w(TAG, "Error closing app", e); + sleep(POST_LAUNCH_IDLE_TIMEOUT); + if (forceStopApp) { + Intent startIntent = mNameToIntent.get(appName); + if (startIntent != null) { + String packageName = startIntent.getComponent().getPackageName(); + try { + mAm.forceStopPackage(packageName, UserHandle.USER_CURRENT); + } catch (RemoteException e) { + Log.w(TAG, "Error closing app", e); + } } } } @@ -176,7 +279,7 @@ public class AppLaunch extends InstrumentationTestCase { } } - private void reportError(String appName, String processName, Bundle results) { + private void reportError(String appName, String processName) { ActivityManager am = (ActivityManager) getInstrumentation() .getContext().getSystemService(Context.ACTIVITY_SERVICE); List<ProcessErrorStateInfo> crashes = am.getProcessesInErrorState(); @@ -186,12 +289,12 @@ public class AppLaunch extends InstrumentationTestCase { continue; Log.w(TAG, appName + " crashed: " + crash.shortMsg); - results.putString(mNameToResultKey.get(appName), crash.shortMsg); + mResult.putString(mNameToResultKey.get(appName), crash.shortMsg); return; } } - results.putString(mNameToResultKey.get(appName), + mResult.putString(mNameToResultKey.get(appName), "Crashed for unknown reason"); Log.w(TAG, appName + " not found in process list, most likely it is crashed"); @@ -200,8 +303,11 @@ public class AppLaunch extends InstrumentationTestCase { private class AppLaunchRunnable implements Runnable { private Intent mLaunchIntent; private IActivityManager.WaitResult mResult; - public AppLaunchRunnable(Intent intent) { + private boolean mForceStopBeforeLaunch; + + public AppLaunchRunnable(Intent intent, boolean forceStopBeforeLaunch) { mLaunchIntent = intent; + mForceStopBeforeLaunch = forceStopBeforeLaunch; } public IActivityManager.WaitResult getResult() { @@ -211,7 +317,9 @@ public class AppLaunch extends InstrumentationTestCase { public void run() { try { String packageName = mLaunchIntent.getComponent().getPackageName(); - mAm.forceStopPackage(packageName, UserHandle.USER_CURRENT); + if (mForceStopBeforeLaunch) { + mAm.forceStopPackage(packageName, UserHandle.USER_CURRENT); + } String mimeType = mLaunchIntent.getType(); if (mimeType == null && mLaunchIntent.getData() != null && "content".equals(mLaunchIntent.getData().getScheme())) { @@ -219,7 +327,7 @@ public class AppLaunch extends InstrumentationTestCase { UserHandle.USER_CURRENT); } - mResult = mAm.startActivityAndWait(null, mLaunchIntent, mimeType, + mResult = mAm.startActivityAndWait(null, null, mLaunchIntent, mimeType, null, null, 0, mLaunchIntent.getFlags(), null, null, null, UserHandle.USER_CURRENT); } catch (RemoteException e) { diff --git a/tests/BiDiTests/res/layout/canvas.xml b/tests/BiDiTests/res/layout/canvas.xml deleted file mode 100644 index 0319a83..0000000 --- a/tests/BiDiTests/res/layout/canvas.xml +++ /dev/null @@ -1,40 +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. ---> - -<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 209597e..b88a885 100644 --- a/tests/BiDiTests/src/com/android/bidi/BiDiTestActivity.java +++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestActivity.java @@ -101,7 +101,6 @@ public class BiDiTestActivity extends Activity { 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 deleted file mode 100644 index 33ed731..0000000 --- a/tests/BiDiTests/src/com/android/bidi/BiDiTestCanvas.java +++ /dev/null @@ -1,67 +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.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 deleted file mode 100644 index 0b1974a..0000000 --- a/tests/BiDiTests/src/com/android/bidi/BiDiTestView.java +++ /dev/null @@ -1,212 +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.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/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java index 1b72486..ab60f21 100644 --- a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java +++ b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java @@ -21,6 +21,7 @@ import android.app.ActivityThread; import android.graphics.Bitmap; import android.os.Bundle; import android.os.Handler; +import android.os.Looper; import android.os.Message; import android.util.Log; import android.view.ViewGroup; @@ -180,7 +181,7 @@ public class PowerTestActivity extends Activity { } private final void validateNotAppThread() { - if (ActivityThread.currentActivityThread() != null) { + if (Looper.myLooper() == Looper.getMainLooper()) { throw new RuntimeException( "This method can not be called from the main application thread"); } diff --git a/tests/RenderScriptTests/SampleTest/Android.mk b/tests/CanvasCompare/Android.mk index f3439b0..642c9e9 100644 --- a/tests/RenderScriptTests/SampleTest/Android.mk +++ b/tests/CanvasCompare/Android.mk @@ -14,13 +14,15 @@ # limitations under the License. # -LOCAL_PATH := $(call my-dir) +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 +LOCAL_PACKAGE_NAME := CanvasCompare + +LOCAL_MODULE_TAGS := tests + +LOCAL_JAVA_LIBRARIES := android.test.runner include $(BUILD_PACKAGE) diff --git a/tests/CanvasCompare/AndroidManifest.xml b/tests/CanvasCompare/AndroidManifest.xml new file mode 100644 index 0000000..b55e290 --- /dev/null +++ b/tests/CanvasCompare/AndroidManifest.xml @@ -0,0 +1,48 @@ +<!-- 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.test.hwuicompare" > + + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> + + <application + android:label="@string/app_name" + android:theme="@android:style/Theme.Holo.Light.NoActionBar"> + <activity + android:name="AutomaticActivity" + android:label="CanvasAutoCompare" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity + android:name="ManualActivity" + android:label="CanvasManualCompare" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <uses-library android:name="android.test.runner" /> + </application> + <instrumentation + android:name="android.test.InstrumentationTestRunner" + android:targetPackage="com.android.test.hwuicompare" + android:label="HW/SW Canvas comparison tool."/> + +</manifest> diff --git a/tests/CanvasCompare/res/drawable/sunset1.jpg b/tests/CanvasCompare/res/drawable/sunset1.jpg Binary files differnew file mode 100644 index 0000000..92851f3 --- /dev/null +++ b/tests/CanvasCompare/res/drawable/sunset1.jpg diff --git a/tests/CanvasCompare/res/layout/automatic_layout.xml b/tests/CanvasCompare/res/layout/automatic_layout.xml new file mode 100644 index 0000000..e049ec0 --- /dev/null +++ b/tests/CanvasCompare/res/layout/automatic_layout.xml @@ -0,0 +1,38 @@ +<?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. +--> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + + <com.android.test.hwuicompare.MainView + android:id="@+id/hardware_view" + android:layout_width="@dimen/layer_width" + android:layout_height="@dimen/layer_width" /> + + <ImageView + android:id="@+id/software_image_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" /> + + <ImageView + android:id="@+id/hardware_image_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentRight="true" /> + +</RelativeLayout> diff --git a/tests/CanvasCompare/res/layout/manual_layout.xml b/tests/CanvasCompare/res/layout/manual_layout.xml new file mode 100644 index 0000000..1a9288c --- /dev/null +++ b/tests/CanvasCompare/res/layout/manual_layout.xml @@ -0,0 +1,119 @@ +<?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" + android:gravity="center_horizontal" + android:orientation="vertical" > + + <HorizontalScrollView + android:layout_width="wrap_content" + android:layout_height="wrap_content" > + + <LinearLayout + android:id="@+id/spinner_layout" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" /> + </HorizontalScrollView> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="0dip" + android:layout_weight="1" + android:baselineAligned="true" + android:orientation="horizontal" > + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:orientation="horizontal" > + + <com.android.test.hwuicompare.MainView + android:id="@+id/hardware_view" + android:layout_width="@dimen/layer_width" + android:layout_height="@dimen/layer_width" /> + </LinearLayout> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:orientation="horizontal" > + + <com.android.test.hwuicompare.MainView + android:id="@+id/software_view" + android:layout_width="@dimen/layer_width" + android:layout_height="@dimen/layer_width" /> + </LinearLayout> + </LinearLayout> + + <ImageView + android:id="@+id/compare_image_view" + android:layout_width="@dimen/layer_width_double" + android:layout_height="@dimen/layer_height_double" + android:filter="false" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center" + android:orientation="horizontal" > + + <ImageButton + android:id="@+id/previous" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:contentDescription="@string/previous_combination" + android:src="@android:drawable/ic_media_previous" /> + + <ImageButton + android:id="@+id/next" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:contentDescription="@string/next_combination" + android:src="@android:drawable/ic_media_next" /> + + <TextView + android:id="@+id/current_error" + android:layout_width="100dp" + android:layout_height="wrap_content" + android:gravity="center" + android:textAppearance="?android:attr/textAppearanceLarge" /> + + <Button + android:id="@+id/show_hardware_version" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/show_hardware_version" /> + + <Button + android:id="@+id/show_software_version" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/show_software_version" /> + + <Button + android:id="@+id/show_error_heatmap" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/show_error_heatmap" /> + </LinearLayout> + +</LinearLayout> diff --git a/tests/CanvasCompare/res/values/strings.xml b/tests/CanvasCompare/res/values/strings.xml new file mode 100644 index 0000000..edd4610 --- /dev/null +++ b/tests/CanvasCompare/res/values/strings.xml @@ -0,0 +1,31 @@ +<?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> + <string name="app_name">Canvas Compare Test</string> + + <!-- show hardware rendered version of the layer --> + <string name="show_hardware_version">Hardware</string> + <!-- show software rendered version of the layer --> + <string name="show_software_version">Software</string> + <!-- show layer error --> + <string name="show_error_values">Error</string> + <!-- show layer error heatmap --> + <string name="show_error_heatmap">Heatmap</string> + <!-- select and display the next combination of painting options--> + <string name="next_combination">Next Combination</string> + <!-- select and display the previous combination of painting options--> + <string name="previous_combination">Previous Combination</string> +</resources> diff --git a/tests/RenderScriptTests/LivePreview/res/layout/cf_format_list_item.xml b/tests/CanvasCompare/res/values/values.xml index 8196bbf..f69378d 100644 --- a/tests/RenderScriptTests/LivePreview/res/layout/cf_format_list_item.xml +++ b/tests/CanvasCompare/res/values/values.xml @@ -1,5 +1,4 @@ <?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"); @@ -14,10 +13,13 @@ See the License for the specific language governing permissions and limitations under the License. --> +<resources> + + <!-- NOTE: the below MUST be multiples of 64 --> + <dimen name="layer_height">320px</dimen> + <dimen name="layer_width">320px</dimen> + + <dimen name="layer_height_double">640px</dimen> + <dimen name="layer_width_double">640px</dimen> -<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" -/> +</resources> diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/AutomaticActivity.java b/tests/CanvasCompare/src/com/android/test/hwuicompare/AutomaticActivity.java new file mode 100644 index 0000000..1ed4723 --- /dev/null +++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/AutomaticActivity.java @@ -0,0 +1,310 @@ +/* + * 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.test.hwuicompare; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.TreeSet; + +import org.json.JSONException; +import org.json.JSONObject; + +import android.os.Bundle; +import android.os.Environment; +import android.os.Trace; +import android.util.Log; +import android.widget.ImageView; +import android.widget.Toast; + +public class AutomaticActivity extends CompareActivity { + private static final String LOG_TAG = "AutomaticActivity"; + private static final float ERROR_DISPLAY_THRESHOLD = 0.01f; + protected static final boolean DRAW_BITMAPS = false; + + /** + * Threshold of error change required to consider a test regressed/improved + */ + private static final float ERROR_CHANGE_THRESHOLD = 0.001f; + + private static final float[] ERROR_CUTOFFS = { + 0, 0.005f, 0.01f, 0.02f, 0.05f, 0.1f, 0.25f, 0.5f, 1f, 2f + }; + + private final float[] mErrorRates = new float[ERROR_CUTOFFS.length]; + private float mTotalTests = 0; + private float mTotalError = 0; + private int mTestsRegressed = 0; + private int mTestsImproved = 0; + + private ImageView mSoftwareImageView = null; + private ImageView mHardwareImageView = null; + + + public abstract static class FinalCallback { + abstract void report(String name, float value); + void complete() {}; + } + + private final ArrayList<FinalCallback> mFinalCallbacks = new ArrayList<FinalCallback>(); + + Runnable mRunnable = new Runnable() { + @Override + public void run() { + loadBitmaps(); + if (mSoftwareBitmap == null || mHardwareBitmap == null) { + Log.e(LOG_TAG, "bitmap is null"); + return; + } + + if (DRAW_BITMAPS) { + mSoftwareImageView.setImageBitmap(mSoftwareBitmap); + mHardwareImageView.setImageBitmap(mHardwareBitmap); + } + + Trace.traceBegin(Trace.TRACE_TAG_ALWAYS, "calculateError"); + float error = mErrorCalculator.calcErrorRS(mSoftwareBitmap, mHardwareBitmap); + Trace.traceEnd(Trace.TRACE_TAG_ALWAYS); + + final String[] modifierNames = DisplayModifier.getLastAppliedModifications(); + handleError(modifierNames, error); + + if (DisplayModifier.step()) { + finishTest(); + } else { + mHardwareView.invalidate(); + if (DRAW_BITMAPS) { + mSoftwareImageView.invalidate(); + mHardwareImageView.invalidate(); + } + } + mHandler.removeCallbacks(mRunnable); + } + }; + + @Override + protected void onPause() { + super.onPause(); + mHandler.removeCallbacks(mRunnable); + }; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.automatic_layout); + + mSoftwareImageView = (ImageView) findViewById(R.id.software_image_view); + mHardwareImageView = (ImageView) findViewById(R.id.hardware_image_view); + + onCreateCommon(mRunnable); + beginTest(); + } + + private static class TestResult { + TestResult(String label, float error) { + mLabel = label; + mTotalError = error; + mCount = 1; + } + public void addInto(float error) { + mTotalError += error; + mCount++; + } + public float getAverage() { + return mTotalError / mCount; + } + final String mLabel; + float mTotalError; + int mCount; + } + + JSONObject mOutputJson = null; + JSONObject mInputJson = null; + final HashMap<String, TestResult> mModifierResults = new HashMap<String, TestResult>(); + final HashMap<String, TestResult> mIndividualResults = new HashMap<String, TestResult>(); + final HashMap<String, TestResult> mModifierDiffResults = new HashMap<String, TestResult>(); + final HashMap<String, TestResult> mIndividualDiffResults = new HashMap<String, TestResult>(); + private void beginTest() { + mFinalCallbacks.add(new FinalCallback() { + @Override + void report(String name, float value) { + Log.d(LOG_TAG, name + " " + value); + }; + }); + + File inputFile = new File(Environment.getExternalStorageDirectory(), + "CanvasCompareInput.json"); + if (inputFile.exists() && inputFile.canRead() && inputFile.length() > 0) { + try { + FileInputStream inputStream = new FileInputStream(inputFile); + Log.d(LOG_TAG, "Parsing input file..."); + StringBuffer content = new StringBuffer((int)inputFile.length()); + byte[] buffer = new byte[1024]; + while (inputStream.read(buffer) != -1) { + content.append(new String(buffer)); + } + mInputJson = new JSONObject(content.toString()); + inputStream.close(); + Log.d(LOG_TAG, "Parsed input file with " + mInputJson.length() + " entries"); + } catch (JSONException e) { + Log.e(LOG_TAG, "error parsing input json", e); + } catch (IOException e) { + Log.e(LOG_TAG, "error reading input json from sd", e); + } + } + + mOutputJson = new JSONObject(); + } + + private static void logTestResultHash(String label, HashMap<String, TestResult> map) { + Log.d(LOG_TAG, "---------------"); + Log.d(LOG_TAG, label + ":"); + Log.d(LOG_TAG, "---------------"); + TreeSet<TestResult> set = new TreeSet<TestResult>(new Comparator<TestResult>() { + @Override + public int compare(TestResult lhs, TestResult rhs) { + if (lhs == rhs) return 0; // don't need to worry about complex equality + + int cmp = Float.compare(lhs.getAverage(), rhs.getAverage()); + if (cmp != 0) { + return cmp; + } + return lhs.mLabel.compareTo(rhs.mLabel); + } + }); + + for (TestResult t : map.values()) { + set.add(t); + } + + for (TestResult t : set.descendingSet()) { + if (Math.abs(t.getAverage()) > ERROR_DISPLAY_THRESHOLD) { + Log.d(LOG_TAG, String.format("%2.4f : %s", t.getAverage(), t.mLabel)); + } + } + Log.d(LOG_TAG, ""); + } + + private void finishTest() { + for (FinalCallback c : mFinalCallbacks) { + c.report("averageError", (mTotalError / mTotalTests)); + for (int i = 1; i < ERROR_CUTOFFS.length; i++) { + c.report(String.format("tests with error over %1.3f", ERROR_CUTOFFS[i]), + mErrorRates[i]); + } + if (mInputJson != null) { + c.report("tests regressed", mTestsRegressed); + c.report("tests improved", mTestsImproved); + } + c.complete(); + } + + try { + if (mOutputJson != null) { + String outputString = mOutputJson.toString(4); + File outputFile = new File(Environment.getExternalStorageDirectory(), + "CanvasCompareOutput.json"); + FileOutputStream outputStream = new FileOutputStream(outputFile); + outputStream.write(outputString.getBytes()); + outputStream.close(); + Log.d(LOG_TAG, "Saved output file with " + mOutputJson.length() + " entries"); + } + } catch (JSONException e) { + Log.e(LOG_TAG, "error during JSON stringify", e); + } catch (IOException e) { + Log.e(LOG_TAG, "error storing JSON output on sd", e); + } + + logTestResultHash("Modifier change vs previous", mModifierDiffResults); + logTestResultHash("Invidual test change vs previous", mIndividualDiffResults); + logTestResultHash("Modifier average test results", mModifierResults); + logTestResultHash("Individual test results", mIndividualResults); + + Toast.makeText(getApplicationContext(), "done!", Toast.LENGTH_SHORT).show(); + finish(); + } + + /** + * Inserts the error value into all TestResult objects, associated with each of its modifiers + */ + private static void addForAllModifiers(String fullName, float error, String[] modifierNames, + HashMap<String, TestResult> modifierResults) { + for (String modifierName : modifierNames) { + TestResult r = modifierResults.get(fullName); + if (r == null) { + modifierResults.put(modifierName, new TestResult(modifierName, error)); + } else { + r.addInto(error); + } + } + } + + private void handleError(final String[] modifierNames, final float error) { + String fullName = ""; + for (String s : modifierNames) { + fullName = fullName.concat("." + s); + } + fullName = fullName.substring(1); + + float deltaError = 0; + if (mInputJson != null) { + try { + deltaError = error - (float)mInputJson.getDouble(fullName); + } catch (JSONException e) { + Log.w(LOG_TAG, "Warning: unable to read from input json", e); + } + if (deltaError > ERROR_CHANGE_THRESHOLD) mTestsRegressed++; + if (deltaError < -ERROR_CHANGE_THRESHOLD) mTestsImproved++; + mIndividualDiffResults.put(fullName, new TestResult(fullName, deltaError)); + addForAllModifiers(fullName, deltaError, modifierNames, mModifierDiffResults); + } + + mIndividualResults.put(fullName, new TestResult(fullName, error)); + addForAllModifiers(fullName, error, modifierNames, mModifierResults); + + try { + if (mOutputJson != null) { + mOutputJson.put(fullName, error); + } + } catch (JSONException e) { + Log.e(LOG_TAG, "exception during JSON recording", e); + mOutputJson = null; + } + + for (int i = 0; i < ERROR_CUTOFFS.length; i++) { + if (error <= ERROR_CUTOFFS[i]) break; + mErrorRates[i]++; + } + mTotalError += error; + mTotalTests++; + } + + @Override + protected boolean forceRecreateBitmaps() { + // disable, unless needed for drawing into imageviews + return DRAW_BITMAPS; + } + + // FOR TESTING + public void setFinalCallback(FinalCallback c) { + mFinalCallbacks.add(c); + } +} diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/CompareActivity.java b/tests/CanvasCompare/src/com/android/test/hwuicompare/CompareActivity.java new file mode 100644 index 0000000..0b85189 --- /dev/null +++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/CompareActivity.java @@ -0,0 +1,122 @@ +/* + * 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.test.hwuicompare; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import com.android.test.hwuicompare.R; + +import android.app.Activity; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Handler; +import android.os.Trace; +import android.util.Log; +import android.view.View; + +abstract public class CompareActivity extends Activity { + private static final String LOG_TAG = "CompareActivity"; + + protected MainView mHardwareView = null; + + protected Bitmap mSoftwareBitmap; + protected Bitmap mHardwareBitmap; + + protected ErrorCalculator mErrorCalculator; + + protected Handler mHandler; + + Runnable mDrawCallback = null; + protected boolean mRedrewFlag = true; + + protected void onCreateCommon(final Runnable postDrawCallback) { + mDrawCallback = new Runnable() { + @Override + public void run() { + mRedrewFlag = true; + mHandler.post(postDrawCallback); + }; + }; + getWindow().setBackgroundDrawable(new ColorDrawable(0xffefefef)); + ResourceModifiers.init(getResources()); + + mHardwareView = (MainView) findViewById(R.id.hardware_view); + mHardwareView.setLayerType(View.LAYER_TYPE_HARDWARE, null); + mHardwareView.setBackgroundColor(Color.WHITE); + mHardwareView.addDrawCallback(mDrawCallback); + + int width = getResources().getDimensionPixelSize(R.dimen.layer_width); + int height = getResources().getDimensionPixelSize(R.dimen.layer_height); + mSoftwareBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + mHardwareBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + + mErrorCalculator = new ErrorCalculator(getApplicationContext(), getResources()); + + mHandler = new Handler(); + } + + protected abstract boolean forceRecreateBitmaps(); + + protected void loadBitmaps() { + Trace.traceBegin(Trace.TRACE_TAG_ALWAYS, "loadBitmaps"); + if (forceRecreateBitmaps()) { + int width = mSoftwareBitmap.getWidth(); + int height = mSoftwareBitmap.getHeight(); + + mSoftwareBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + mHardwareBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + } + + Trace.traceBegin(Trace.TRACE_TAG_ALWAYS, "softwareDraw"); + mHardwareView.draw(new Canvas(mSoftwareBitmap)); + Trace.traceEnd(Trace.TRACE_TAG_ALWAYS); + + try { + Method getHardwareLayer = View.class.getDeclaredMethod("getHardwareLayer"); + if (!getHardwareLayer.isAccessible()) + getHardwareLayer.setAccessible(true); + Object hardwareLayer = getHardwareLayer.invoke(mHardwareView); + if (hardwareLayer == null) { + Log.d(LOG_TAG, "failure to access hardware layer"); + return; + } + Method copyInto = hardwareLayer.getClass().getSuperclass() + .getDeclaredMethod("copyInto", Bitmap.class); + if (!copyInto.isAccessible()) + copyInto.setAccessible(true); + + Trace.traceBegin(Trace.TRACE_TAG_ALWAYS, "copyInto"); + boolean success = (Boolean) copyInto.invoke(hardwareLayer, mHardwareBitmap); + Trace.traceEnd(Trace.TRACE_TAG_ALWAYS); + if (!success) { + Log.d(LOG_TAG, "failure to copy hardware layer into bitmap"); + } + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + Trace.traceEnd(Trace.TRACE_TAG_ALWAYS); + } +} diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/DisplayModifier.java b/tests/CanvasCompare/src/com/android/test/hwuicompare/DisplayModifier.java new file mode 100644 index 0000000..9939c08 --- /dev/null +++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/DisplayModifier.java @@ -0,0 +1,502 @@ +/* + * 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.test.hwuicompare; + +import java.util.LinkedHashMap; +import java.util.Map.Entry; + +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.RectF; +import android.util.Log; + +public abstract class DisplayModifier { + + // automated tests ignore any combination of operations that don't together return TOTAL_MASK + protected final static int TOTAL_MASK = 0x1F; + + // if we're filling, ensure we're not also sweeping over stroke parameters + protected final static int SWEEP_STROKE_WIDTH_BIT = 0x1 << 0; + protected final static int SWEEP_STROKE_CAP_BIT = 0x1 << 1; + protected final static int SWEEP_STROKE_JOIN_BIT = 0x1 << 2; + + protected final static int SWEEP_SHADER_BIT = 0x1 << 3; // only allow non-simple shaders to use rectangle drawing + protected final static int SWEEP_TRANSFORM_BIT = 0x1 << 4; // only sweep over specified transforms + + abstract public void modifyDrawing(Paint paint, Canvas canvas); + protected int mask() { return 0x0; }; + + private static final RectF gRect = new RectF(0, 0, 200, 175); + private static final float[] gPts = new float[] { + 0, 100, 100, 0, 100, 200, 200, 100 + }; + + private static final int NUM_PARALLEL_LINES = 24; + private static final float[] gTriPts = new float[] { + 75, 0, 130, 130, 130, 130, 0, 130, 0, 130, 75, 0 + }; + private static final float[] gLinePts = new float[NUM_PARALLEL_LINES * 8 + gTriPts.length]; + static { + int index; + for (index = 0; index < gTriPts.length; index++) { + gLinePts[index] = gTriPts[index]; + } + float val = 0; + for (int i = 0; i < NUM_PARALLEL_LINES; i++) { + gLinePts[index + 0] = 150; + gLinePts[index + 1] = val; + gLinePts[index + 2] = 300; + gLinePts[index + 3] = val; + index += 4; + val += 8 + (2.0f/NUM_PARALLEL_LINES); + } + val = 0; + for (int i = 0; i < NUM_PARALLEL_LINES; i++) { + gLinePts[index + 0] = val; + gLinePts[index + 1] = 150; + gLinePts[index + 2] = val; + gLinePts[index + 3] = 300; + index += 4; + val += 8 + (2.0f/NUM_PARALLEL_LINES); + } + }; + + @SuppressWarnings("serial") + private static final LinkedHashMap<String, LinkedHashMap<String, DisplayModifier>> gMaps = new LinkedHashMap<String, LinkedHashMap<String, DisplayModifier>>() { + { + put("aa", new LinkedHashMap<String, DisplayModifier>() { + { + put("true", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setAntiAlias(true); + } + }); + put("false", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setAntiAlias(false); + } + }); + } + }); + put("style", new LinkedHashMap<String, DisplayModifier>() { + { + put("fill", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStyle(Paint.Style.FILL); + } + }); + put("stroke", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStyle(Paint.Style.STROKE); + } + @Override + protected int mask() { return SWEEP_STROKE_WIDTH_BIT; } + }); + put("fillAndStroke", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStyle(Paint.Style.FILL_AND_STROKE); + } + + @Override + protected int mask() { return SWEEP_STROKE_WIDTH_BIT; } + }); + } + }); + put("strokeWidth", new LinkedHashMap<String, DisplayModifier>() { + { + put("hair", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStrokeWidth(0); + } + @Override + protected int mask() { return SWEEP_STROKE_WIDTH_BIT; } + }); + put("0.3", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStrokeWidth(0.3f); + } + }); + put("1", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStrokeWidth(1); + } + }); + put("5", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStrokeWidth(5); + } + }); + put("30", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStrokeWidth(30); + } + }); + } + }); + put("strokeCap", new LinkedHashMap<String, DisplayModifier>() { + { + put("butt", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStrokeCap(Paint.Cap.BUTT); + } + @Override + protected int mask() { return SWEEP_STROKE_CAP_BIT; } + }); + put("round", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStrokeCap(Paint.Cap.ROUND); + } + }); + put("square", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStrokeCap(Paint.Cap.SQUARE); + } + }); + } + }); + put("strokeJoin", new LinkedHashMap<String, DisplayModifier>() { + { + put("bevel", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStrokeJoin(Paint.Join.BEVEL); + } + @Override + protected int mask() { return SWEEP_STROKE_JOIN_BIT; } + }); + put("round", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStrokeJoin(Paint.Join.ROUND); + } + }); + put("miter", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setStrokeJoin(Paint.Join.MITER); + } + }); + // TODO: add miter0, miter1 etc to test miter distances + } + }); + + put("transform", new LinkedHashMap<String, DisplayModifier>() { + { + put("noTransform", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) {} + @Override + protected int mask() { return SWEEP_TRANSFORM_BIT; }; + }); + put("rotate5", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.rotate(5); + } + }); + put("rotate45", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.rotate(5); + } + }); + put("rotate90", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.rotate(90); + canvas.translate(0, -200); + } + }); + put("scale2x2", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.scale(2, 2); + } + @Override + protected int mask() { return SWEEP_TRANSFORM_BIT; }; + }); + put("rot20scl1x4", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.rotate(20); + canvas.scale(1, 4); + } + @Override + protected int mask() { return SWEEP_TRANSFORM_BIT; }; + }); + } + }); + + put("shader", new LinkedHashMap<String, DisplayModifier>() { + { + put("noShader", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) {} + @Override + protected int mask() { return SWEEP_SHADER_BIT; }; + }); + put("repeatShader", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setShader(ResourceModifiers.instance().mRepeatShader); + } + @Override + protected int mask() { return SWEEP_SHADER_BIT; }; + }); + put("translatedShader", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setShader(ResourceModifiers.instance().mTranslatedShader); + } + }); + put("scaledShader", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setShader(ResourceModifiers.instance().mScaledShader); + } + }); + put("horGradient", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setShader(ResourceModifiers.instance().mHorGradient); + } + }); + put("diagGradient", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setShader(ResourceModifiers.instance().mDiagGradient); + } + @Override + protected int mask() { return SWEEP_SHADER_BIT; }; + }); + put("vertGradient", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setShader(ResourceModifiers.instance().mVertGradient); + } + }); + } + }); + + // FINAL MAP: DOES ACTUAL DRAWING + put("drawing", new LinkedHashMap<String, DisplayModifier>() { + { + put("roundRect", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.drawRoundRect(gRect, 20, 20, paint); + } + }); + put("rect", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.drawRect(gRect, paint); + } + @Override + protected int mask() { return SWEEP_SHADER_BIT | SWEEP_STROKE_CAP_BIT; }; + }); + put("circle", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.drawCircle(100, 100, 75, paint); + } + }); + put("oval", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.drawOval(gRect, paint); + } + }); + put("lines", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.drawLines(gLinePts, paint); + } + @Override + protected int mask() { return SWEEP_STROKE_CAP_BIT; }; + }); + put("plusPoints", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.drawPoints(gPts, paint); + } + }); + put("text", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setTextSize(36); + canvas.drawText("TEXTTEST", 0, 50, paint); + } + }); + put("shadowtext", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + paint.setTextSize(36); + paint.setShadowLayer(3.0f, 0.0f, 3.0f, 0xffff00ff); + canvas.drawText("TEXTTEST", 0, 50, paint); + } + }); + put("bitmapMesh", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.drawBitmapMesh(ResourceModifiers.instance().mBitmap, 3, 3, + ResourceModifiers.instance().mBitmapVertices, 0, null, 0, null); + } + }); + put("arc", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.drawArc(gRect, 260, 285, false, paint); + } + @Override + protected int mask() { return SWEEP_STROKE_CAP_BIT; }; + }); + put("arcFromCenter", new DisplayModifier() { + @Override + public void modifyDrawing(Paint paint, Canvas canvas) { + canvas.drawArc(gRect, 260, 285, true, paint); + } + @Override + protected int mask() { return SWEEP_STROKE_JOIN_BIT; }; + }); + } + }); + // WARNING: DON'T PUT MORE MAPS BELOW THIS + } + }; + + private static LinkedHashMap<String, DisplayModifier> getMapAtIndex(int index) { + for (LinkedHashMap<String, DisplayModifier> map : gMaps.values()) { + if (index == 0) { + return map; + } + index--; + } + return null; + } + + // indices instead of iterators for easier bidirectional traversal + private static final int mIndices[] = new int[gMaps.size()]; + private static final String[] mLastAppliedModifications = new String[gMaps.size()]; + + private static boolean stepInternal(boolean forward) { + int modifierMapIndex = gMaps.size() - 1; + while (modifierMapIndex >= 0) { + LinkedHashMap<String, DisplayModifier> map = getMapAtIndex(modifierMapIndex); + mIndices[modifierMapIndex] += (forward ? 1 : -1); + + if (mIndices[modifierMapIndex] >= 0 && mIndices[modifierMapIndex] < map.size()) { + break; + } + + mIndices[modifierMapIndex] = (forward ? 0 : map.size() - 1); + modifierMapIndex--; + } + return modifierMapIndex < 0; // true if resetting + } + + public static boolean step() { + boolean ret = false; + do { + ret |= stepInternal(true); + } while (!checkModificationStateMask()); + return ret; + } + + public static boolean stepBack() { + boolean ret = false; + do { + ret |= stepInternal(false); + } while (!checkModificationStateMask()); + return ret; + } + + private static boolean checkModificationStateMask() { + int operatorMask = 0x0; + int mapIndex = 0; + for (LinkedHashMap<String, DisplayModifier> map : gMaps.values()) { + int displayModifierIndex = mIndices[mapIndex]; + for (Entry<String, DisplayModifier> modifierEntry : map.entrySet()) { + if (displayModifierIndex == 0) { + mLastAppliedModifications[mapIndex] = modifierEntry.getKey(); + operatorMask |= modifierEntry.getValue().mask(); + break; + } + displayModifierIndex--; + } + mapIndex++; + } + return operatorMask == TOTAL_MASK; + } + + public static void apply(Paint paint, Canvas canvas) { + int mapIndex = 0; + for (LinkedHashMap<String, DisplayModifier> map : gMaps.values()) { + int displayModifierIndex = mIndices[mapIndex]; + for (Entry<String, DisplayModifier> modifierEntry : map.entrySet()) { + if (displayModifierIndex == 0) { + mLastAppliedModifications[mapIndex] = modifierEntry.getKey(); + modifierEntry.getValue().modifyDrawing(paint, canvas); + break; + } + displayModifierIndex--; + } + mapIndex++; + } + } + + public static String[] getLastAppliedModifications() { + return mLastAppliedModifications.clone(); + } + + public static String[][] getStrings() { + String[][] keys = new String[gMaps.size()][]; + + int i = 0; + for (LinkedHashMap<String, DisplayModifier> map : gMaps.values()) { + keys[i] = new String[map.size()]; + int j = 0; + for (String key : map.keySet()) { + keys[i][j++] = key; + } + i++; + } + + return keys; + } + + public static void setIndex(int mapIndex, int newIndexValue) { + mIndices[mapIndex] = newIndexValue; + } + + public static int[] getIndices() { + return mIndices; + } +} diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/ErrorCalculator.java b/tests/CanvasCompare/src/com/android/test/hwuicompare/ErrorCalculator.java new file mode 100644 index 0000000..a08b558 --- /dev/null +++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/ErrorCalculator.java @@ -0,0 +1,190 @@ +/* + * 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.test.hwuicompare; + +import com.android.test.hwuicompare.R; +import com.android.test.hwuicompare.ScriptC_errorCalculator; + +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.renderscript.Allocation; +import android.renderscript.Element; +import android.renderscript.RenderScript; +import android.util.Log; + +public class ErrorCalculator { + private static final String LOG_TAG = "ErrorCalculator"; + private static final int REGION_SIZE = 8; + + private static final boolean LOG_TIMING = false; + private static final boolean LOG_CALC = false; + + private final RenderScript mRS; + private Allocation mIdealPixelsAllocation; + private Allocation mGivenPixelsAllocation; + private Allocation mOutputPixelsAllocation; + + private final Allocation mInputRowsAllocation; + private final Allocation mOutputRegionsAllocation; + + private final ScriptC_errorCalculator mScript; + + private final int[] mOutputRowRegions; + + public ErrorCalculator(Context c, Resources resources) { + int width = resources.getDimensionPixelSize(R.dimen.layer_width); + int height = resources.getDimensionPixelSize(R.dimen.layer_height); + mOutputRowRegions = new int[height / REGION_SIZE]; + + mRS = RenderScript.create(c); + int[] rowIndices = new int[height / REGION_SIZE]; + for (int i = 0; i < rowIndices.length; i++) + rowIndices[i] = i * REGION_SIZE; + + mScript = new ScriptC_errorCalculator(mRS, resources, R.raw.errorcalculator); + mScript.set_HEIGHT(height); + mScript.set_WIDTH(width); + mScript.set_REGION_SIZE(REGION_SIZE); + + mInputRowsAllocation = Allocation.createSized(mRS, Element.I32(mRS), rowIndices.length, + Allocation.USAGE_SCRIPT); + mInputRowsAllocation.copyFrom(rowIndices); + mOutputRegionsAllocation = Allocation.createSized(mRS, Element.I32(mRS), + mOutputRowRegions.length, Allocation.USAGE_SCRIPT); + } + + + private static long startMillis, middleMillis; + + public float calcErrorRS(Bitmap ideal, Bitmap given) { + if (LOG_TIMING) { + startMillis = System.currentTimeMillis(); + } + + mIdealPixelsAllocation = Allocation.createFromBitmap(mRS, ideal, + Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); + mGivenPixelsAllocation = Allocation.createFromBitmap(mRS, given, + Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); + + mScript.bind_ideal(mIdealPixelsAllocation); + mScript.bind_given(mGivenPixelsAllocation); + + mScript.forEach_countInterestingRegions(mInputRowsAllocation, mOutputRegionsAllocation); + mOutputRegionsAllocation.copyTo(mOutputRowRegions); + + int regionCount = 0; + for (int region : mOutputRowRegions) { + regionCount += region; + } + int interestingPixels = Math.max(1, regionCount) * REGION_SIZE * REGION_SIZE; + + if (LOG_TIMING) { + long startMillis2 = System.currentTimeMillis(); + } + + mScript.forEach_accumulateError(mInputRowsAllocation, mOutputRegionsAllocation); + mOutputRegionsAllocation.copyTo(mOutputRowRegions); + float totalError = 0; + for (int row : mOutputRowRegions) { + totalError += row; + } + totalError /= 1024.0f; + + if (LOG_TIMING) { + long finalMillis = System.currentTimeMillis(); + Log.d(LOG_TAG, "rs: first part took " + (middleMillis - startMillis) + "ms"); + Log.d(LOG_TAG, "rs: last part took " + (finalMillis - middleMillis) + "ms"); + } + if (LOG_CALC) { + Log.d(LOG_TAG, "rs: error " + totalError + ", pixels " + interestingPixels); + } + return totalError / interestingPixels; + } + + public void calcErrorHeatmapRS(Bitmap ideal, Bitmap given, Bitmap output) { + mIdealPixelsAllocation = Allocation.createFromBitmap(mRS, ideal, + Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); + mGivenPixelsAllocation = Allocation.createFromBitmap(mRS, given, + Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); + + mScript.bind_ideal(mIdealPixelsAllocation); + mScript.bind_given(mGivenPixelsAllocation); + + mOutputPixelsAllocation = Allocation.createFromBitmap(mRS, output, + Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); + mScript.forEach_displayDifference(mOutputPixelsAllocation, mOutputPixelsAllocation); + mOutputPixelsAllocation.copyTo(output); + } + + public static float calcError(Bitmap ideal, Bitmap given) { + if (LOG_TIMING) { + startMillis = System.currentTimeMillis(); + } + + int interestingRegions = 0; + for (int x = 0; x < ideal.getWidth(); x += REGION_SIZE) { + for (int y = 0; y < ideal.getWidth(); y += REGION_SIZE) { + if (inspectRegion(ideal, x, y)) { + interestingRegions++; + } + } + } + + int interestingPixels = Math.max(1, interestingRegions) * REGION_SIZE * REGION_SIZE; + + if (LOG_TIMING) { + long startMillis2 = System.currentTimeMillis(); + } + + float totalError = 0; + for (int x = 0; x < ideal.getWidth(); x++) { + for (int y = 0; y < ideal.getHeight(); y++) { + int idealColor = ideal.getPixel(x, y); + int givenColor = given.getPixel(x, y); + if (idealColor == givenColor) + continue; + totalError += Math.abs(Color.red(idealColor) - Color.red(givenColor)); + totalError += Math.abs(Color.green(idealColor) - Color.green(givenColor)); + totalError += Math.abs(Color.blue(idealColor) - Color.blue(givenColor)); + totalError += Math.abs(Color.alpha(idealColor) - Color.alpha(givenColor)); + } + } + totalError /= 1024.0f; + if (LOG_TIMING) { + long finalMillis = System.currentTimeMillis(); + Log.d(LOG_TAG, "dvk: first part took " + (middleMillis - startMillis) + "ms"); + Log.d(LOG_TAG, "dvk: last part took " + (finalMillis - middleMillis) + "ms"); + } + if (LOG_CALC) { + Log.d(LOG_TAG, "dvk: error " + totalError + ", pixels " + interestingPixels); + } + return totalError / interestingPixels; + } + + private static boolean inspectRegion(Bitmap ideal, int x, int y) { + int regionColor = ideal.getPixel(x, y); + for (int i = 0; i < REGION_SIZE; i++) { + for (int j = 0; j < REGION_SIZE; j++) { + if (ideal.getPixel(x + i, y + j) != regionColor) + return true; + } + } + return false; + } +} diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/MainView.java b/tests/CanvasCompare/src/com/android/test/hwuicompare/MainView.java new file mode 100644 index 0000000..454fe7b --- /dev/null +++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/MainView.java @@ -0,0 +1,56 @@ +/* + * 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.test.hwuicompare; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.util.AttributeSet; +import android.view.View; + +public class MainView extends View { + Paint mPaint = new Paint(); + + public MainView(Context context) { + super(context); + } + + public MainView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public MainView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + mPaint.reset(); + DisplayModifier.apply(mPaint, canvas); + + if (mDrawCallback != null) { + mDrawCallback.run(); + } + } + + private Runnable mDrawCallback; + public void addDrawCallback(Runnable drawCallback) { + mDrawCallback = drawCallback; + } +} diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/ManualActivity.java b/tests/CanvasCompare/src/com/android/test/hwuicompare/ManualActivity.java new file mode 100644 index 0000000..400dff0 --- /dev/null +++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/ManualActivity.java @@ -0,0 +1,211 @@ +/* + * 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.test.hwuicompare; + +import com.android.test.hwuicompare.R; + +import android.graphics.Bitmap; +import android.graphics.Color; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.Spinner; +import android.widget.TextView; + +public class ManualActivity extends CompareActivity { + private static final String LOG_TAG = "ManualActivity"; + private ImageView mCompareImageView; + private Bitmap mCompareBitmap; + private TextView mErrorTextView; + private MainView mSoftwareView; + + private static final int COMPARE_VIEW_UNINITIALIZED = -1; + private static final int COMPARE_VIEW_HARDWARE = 0; + private static final int COMPARE_VIEW_SOFTWARE = 1; + private static final int COMPARE_VIEW_HEATMAP = 2; // TODO: add more like this? any ideas? + + private int mCompareImageViewState = COMPARE_VIEW_UNINITIALIZED; + private int mLastCompareImageViewState = COMPARE_VIEW_UNINITIALIZED; + + Runnable mRunnable = new Runnable() { + @Override + public void run() { + Log.d(LOG_TAG, "mRunnable running, mRedrewFlag = " + mRedrewFlag); + + if (mRedrewFlag) { + loadBitmaps(); + // recalculate error + float error = mErrorCalculator.calcErrorRS(mSoftwareBitmap, mHardwareBitmap); + String modname = ""; + for (String s : DisplayModifier.getLastAppliedModifications()) { + modname = modname.concat(s + "."); + } + + Log.d(LOG_TAG, "error for " + modname + " is " + error); + mErrorTextView.setText(String.format("%.4f", error)); + } + + if (mCompareImageViewState != mLastCompareImageViewState || mRedrewFlag) { + switch (mCompareImageViewState) { + case COMPARE_VIEW_UNINITIALIZED: + // set to hardware + case COMPARE_VIEW_HARDWARE: + mCompareImageView.setImageBitmap(mHardwareBitmap); + break; + case COMPARE_VIEW_SOFTWARE: + mCompareImageView.setImageBitmap(mSoftwareBitmap); + break; + case COMPARE_VIEW_HEATMAP: + mErrorCalculator.calcErrorHeatmapRS(mSoftwareBitmap, mHardwareBitmap, + mCompareBitmap); + mCompareImageView.setImageBitmap(mCompareBitmap); + break; + } + mCompareImageView.invalidate(); + } + + mLastCompareImageViewState = mCompareImageViewState; + mRedrewFlag = false; + mHandler.removeCallbacks(mRunnable); + } + }; + + private void redrawViews() { + mHardwareView.invalidate(); + mSoftwareView.invalidate(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.manual_layout); + onCreateCommon(mRunnable); + + mSoftwareView = (MainView) findViewById(R.id.software_view); + mSoftwareView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); + mSoftwareView.setBackgroundColor(Color.WHITE); + mSoftwareView.addDrawCallback(mDrawCallback); + + mCompareImageView = (ImageView) findViewById(R.id.compare_image_view); + + int width = getResources().getDimensionPixelSize(R.dimen.layer_width); + int height = getResources().getDimensionPixelSize(R.dimen.layer_height); + mCompareBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + + mErrorTextView = (TextView) findViewById(R.id.current_error); + ((ImageButton) findViewById(R.id.next)).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + DisplayModifier.step(); + updateSpinners(); + redrawViews(); + } + }); + ((ImageButton) findViewById(R.id.previous)).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + DisplayModifier.stepBack(); + updateSpinners(); + redrawViews(); + } + }); + ((Button) findViewById(R.id.show_hardware_version)) + .setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + mCompareImageViewState = COMPARE_VIEW_HARDWARE; + mHandler.post(mRunnable); + } + }); + ((Button) findViewById(R.id.show_software_version)) + .setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + mCompareImageViewState = COMPARE_VIEW_SOFTWARE; + mHandler.post(mRunnable); + } + }); + ((Button) findViewById(R.id.show_error_heatmap)).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + mCompareImageViewState = COMPARE_VIEW_HEATMAP; + mHandler.post(mRunnable); + } + }); + + buildSpinnerLayout(); + } + + private class DisplayModifierSpinner extends Spinner { + private final int mIndex; + + public DisplayModifierSpinner(int index) { + super(ManualActivity.this); + mIndex = index; + setOnItemSelectedListener(new OnItemSelectedListener() { + + @Override + public void onItemSelected(AdapterView<?> parentView, View selectedItem, + int position, long id) { + DisplayModifier.setIndex(mIndex, position); + redrawViews(); + } + + @Override + public void onNothingSelected(AdapterView<?> parentView) { + } + }); + } + } + + private Spinner[] mSpinners; + + private void buildSpinnerLayout() { + LinearLayout layout = (LinearLayout) findViewById(R.id.spinner_layout); + String[][] mapsStrings = DisplayModifier.getStrings(); + mSpinners = new Spinner[mapsStrings.length]; + int index = 0; + for (String[] spinnerValues : mapsStrings) { + mSpinners[index] = new DisplayModifierSpinner(index); + mSpinners[index].setAdapter(new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_dropdown_item, spinnerValues)); + layout.addView(mSpinners[index]); + index++; + } + Log.d(LOG_TAG, "created " + index + " spinners"); + } + + private void updateSpinners() { + int[] indices = DisplayModifier.getIndices(); + for (int i = 0; i < mSpinners.length; i++) { + mSpinners[i].setSelection(indices[i]); + } + } + + @Override + protected boolean forceRecreateBitmaps() { + // continually recreate bitmaps to avoid modifying bitmaps currently being drawn + return true; + } +} diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/ResourceModifiers.java b/tests/CanvasCompare/src/com/android/test/hwuicompare/ResourceModifiers.java new file mode 100644 index 0000000..c705443 --- /dev/null +++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/ResourceModifiers.java @@ -0,0 +1,111 @@ +/* + * 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.test.hwuicompare; + +import com.android.test.hwuicompare.R; + +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.BitmapShader; +import android.graphics.Color; +import android.graphics.LinearGradient; +import android.graphics.Matrix; +import android.graphics.Shader; + +public class ResourceModifiers { + public final BitmapShader mRepeatShader; + public final BitmapShader mTranslatedShader; + public final BitmapShader mScaledShader; + private final int mTexWidth; + private final int mTexHeight; + private final float mDrawWidth; + private final float mDrawHeight; + public final LinearGradient mHorGradient; + public final LinearGradient mDiagGradient; + public final LinearGradient mVertGradient; + public final Bitmap mBitmap; + private final Matrix mMtx1; + private final Matrix mMtx2; + private final Matrix mMtx3; + + public final float[] mBitmapVertices; + public final int[] mBitmapColors; + + private static ResourceModifiers sInstance = null; + public static ResourceModifiers instance() { return sInstance; } + public static void init(Resources resources) { + sInstance = new ResourceModifiers(resources); + } + + public ResourceModifiers(Resources resources) { + mBitmap = BitmapFactory.decodeResource(resources, R.drawable.sunset1); + mTexWidth = mBitmap.getWidth(); + mTexHeight = mBitmap.getHeight(); + + mDrawWidth = resources.getDimensionPixelSize(R.dimen.layer_width); + mDrawHeight = resources.getDimensionPixelSize(R.dimen.layer_height); + + mRepeatShader = new BitmapShader(mBitmap, Shader.TileMode.REPEAT, + Shader.TileMode.REPEAT); + + mTranslatedShader = new BitmapShader(mBitmap, Shader.TileMode.REPEAT, + Shader.TileMode.REPEAT); + mMtx1 = new Matrix(); + mMtx1.setTranslate(mTexWidth / 2.0f, mTexHeight / 2.0f); + mMtx1.postRotate(45, 0, 0); + mTranslatedShader.setLocalMatrix(mMtx1); + + mScaledShader = new BitmapShader(mBitmap, Shader.TileMode.MIRROR, + Shader.TileMode.MIRROR); + mMtx2 = new Matrix(); + mMtx2.setScale(0.5f, 0.5f); + mScaledShader.setLocalMatrix(mMtx2); + + mHorGradient = new LinearGradient(0.0f, 0.0f, 1.0f, 0.0f, + Color.RED, Color.GREEN, Shader.TileMode.CLAMP); + mMtx3 = new Matrix(); + mMtx3.setScale(mDrawHeight, 1.0f); + mMtx3.postRotate(-90.0f); + mMtx3.postTranslate(0.0f, mDrawHeight); + mHorGradient.setLocalMatrix(mMtx3); + + mDiagGradient = new LinearGradient(0.0f, 0.0f, mDrawWidth / 2.0f, mDrawHeight / 2.0f, + Color.BLUE, Color.RED, Shader.TileMode.CLAMP); + + mVertGradient = new LinearGradient(0.0f, 0.0f, 0.0f, mDrawHeight / 2.0f, + Color.YELLOW, Color.MAGENTA, Shader.TileMode.MIRROR); + + final float width = mBitmap.getWidth() / 8.0f; + final float height = mBitmap.getHeight() / 8.0f; + + mBitmapVertices = new float[] { + 0.0f, 0.0f, width, 0.0f, width * 2, 0.0f, width * 3, 0.0f, + 0.0f, height, width, height, width * 2, height, width * 4, height, + 0.0f, height * 2, width, height * 2, width * 2, height * 2, width * 3, height * 2, + 0.0f, height * 4, width, height * 4, width * 2, height * 4, width * 4, height * 4, + }; + + mBitmapColors = new int[] { + 0xffff0000, 0xff00ff00, 0xff0000ff, 0xffff0000, + 0xff0000ff, 0xffff0000, 0xff00ff00, 0xff00ff00, + 0xff00ff00, 0xff0000ff, 0xffff0000, 0xff00ff00, + 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00ff0000, + }; + } + +} diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/Test.java b/tests/CanvasCompare/src/com/android/test/hwuicompare/Test.java new file mode 100644 index 0000000..1ff153c --- /dev/null +++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/Test.java @@ -0,0 +1,46 @@ +package com.android.test.hwuicompare; + +import com.android.test.hwuicompare.AutomaticActivity.FinalCallback; + +import android.os.Bundle; +import android.test.ActivityInstrumentationTestCase2; + +public class Test extends ActivityInstrumentationTestCase2<AutomaticActivity> { + AutomaticActivity mActivity; + private Bundle mBundle; + + public Test() { + super(AutomaticActivity.class); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + mBundle = new Bundle(); + mActivity = getActivity(); + mActivity.setFinalCallback(new FinalCallback() { + + @Override + void report(String key, float value) { + mBundle.putFloat(key, value); + } + @Override + void complete() { + synchronized(mBundle) { + mBundle.notify(); + } + } + }); + } + + public void testCanvas() { + synchronized(mBundle) { + try { + mBundle.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + getInstrumentation().sendStatus(0, mBundle); + } +} diff --git a/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rs b/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rs new file mode 100644 index 0000000..668f61d --- /dev/null +++ b/tests/CanvasCompare/src/com/android/test/hwuicompare/errorCalculator.rs @@ -0,0 +1,56 @@ +#pragma version(1) +#pragma rs java_package_name(com.android.test.hwuicompare) + +int REGION_SIZE; +int WIDTH; +int HEIGHT; + +const uchar4 *ideal; +const uchar4 *given; + +void countInterestingRegions(const int32_t *v_in, int32_t *v_out) { + int y = v_in[0]; + v_out[0] = 0; + + for (int x = 0; x < HEIGHT; x += REGION_SIZE) { + bool interestingRegion = false; + int regionColor = (int)ideal[y * WIDTH + x]; + for (int i = 0; i < REGION_SIZE && !interestingRegion; i++) { + for (int j = 0; j < REGION_SIZE && !interestingRegion; j++) { + interestingRegion |= (int)(ideal[(y + i) * WIDTH + (x + j)]) != regionColor; + } + } + if (interestingRegion) { + v_out[0]++; + } + } +} + +void accumulateError(const int32_t *v_in, int32_t *v_out) { + int startY = v_in[0]; + int error = 0; + for (int y = startY; y < startY + REGION_SIZE; y++) { + for (int x = 0; x < HEIGHT; x++) { + uchar4 idealPixel = ideal[y * WIDTH + x]; + uchar4 givenPixel = given[y * WIDTH + x]; + error += abs(idealPixel.x - givenPixel.x); + error += abs(idealPixel.y - givenPixel.y); + error += abs(idealPixel.z - givenPixel.z); + error += abs(idealPixel.w - givenPixel.w); + } + } + v_out[0] = error; +} + +void displayDifference(const uchar4 *v_in, uchar4 *v_out, uint32_t x, uint32_t y) { + float4 idealPixel = rsUnpackColor8888(ideal[y * WIDTH + x]); + float4 givenPixel = rsUnpackColor8888(given[y * WIDTH + x]); + + float4 diff = idealPixel - givenPixel; + float totalDiff = diff.x + diff.y + diff.z + diff.w; + if (totalDiff < 0) { + v_out[0] = rsPackColorTo8888(0, 0, clamp(-totalDiff/2, 0, 1)); + } else { + v_out[0] = rsPackColorTo8888(clamp(totalDiff/2, 0, 1), 0, 0); + } +} diff --git a/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java b/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java index 4d60c83..7ae0fb8 100644 --- a/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java +++ b/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java @@ -127,6 +127,10 @@ public class AppCompatibility extends InstrumentationTestCase { homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Intent intent = mPackageManager.getLaunchIntentForPackage(packageName); + // Skip if the apk does not have a launch intent. + if (intent == null) { + return null; + } // We check for any Crash or ANR dialogs that are already up, and we ignore them. This is // so that we don't report crashes that were caused by prior apps (which those particular diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java index 9a4e99e..22b587f 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java @@ -22,6 +22,7 @@ import android.graphics.Bitmap; import android.net.http.SslError; import android.os.Bundle; import android.os.Handler; +import android.os.Looper; import android.os.Message; import android.util.Log; import android.view.ViewGroup; @@ -184,7 +185,7 @@ public class ReliabilityTestActivity extends Activity { } private final void validateNotAppThread() { - if (ActivityThread.currentActivityThread() != null) { + if (Looper.myLooper() == Looper.getMainLooper()) { throw new RuntimeException( "This method can not be called from the main application thread"); } diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java index 30a968f..6633787 100644 --- a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java @@ -272,7 +272,7 @@ public class FrameworkPerfActivity extends Activity args.bgOp = mCurOpIndex; } else { args.fgOp = mCurOpIndex; - args.bgOp = mFgTestIndex; + args.bgOp = mBgTestIndex; } } Bundle bundle = new Bundle(); @@ -424,6 +424,8 @@ public class FrameworkPerfActivity extends Activity updateWakeLock(); stopService(new Intent(this, SchedulerService.class)); synchronized (mResults) { + Log.i("PerfRes", "\tTEST\tFgOps\tFgMsPerOp\tFgTime\tFgName\tBgOps\tBgMsPerOp\t" + + "BgTime\tBgName"); for (int i=0; i<mResults.size(); i++) { RunResult result = mResults.get(i); float fgMsPerOp = result.getFgMsPerOp(); diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java b/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java index a8c43e9..5f4f006 100644 --- a/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java @@ -300,7 +300,7 @@ public class TestService extends Service { threadFinished(false); } }, Process.THREAD_PRIORITY_BACKGROUND); - mForegroundThread = new RunnerThread("background", new Runnable() { + mForegroundThread = new RunnerThread("foreground", new Runnable() { @Override public void run() { boolean running; int ops = 0; diff --git a/tests/GridLayoutTest/src/com/android/test/layout/LayoutInsetsTest.java b/tests/GridLayoutTest/src/com/android/test/layout/LayoutInsetsTest.java index 103de2f..81440a5 100644 --- a/tests/GridLayoutTest/src/com/android/test/layout/LayoutInsetsTest.java +++ b/tests/GridLayoutTest/src/com/android/test/layout/LayoutInsetsTest.java @@ -10,9 +10,8 @@ import android.widget.Button; import android.widget.GridLayout; import android.widget.TextView; -import static android.widget.GridLayout.ALIGN_BOUNDS; import static android.widget.GridLayout.LayoutParams; -import static android.widget.GridLayout.OPTICAL_BOUNDS; +import static android.widget.GridLayout.LAYOUT_MODE_OPTICAL_BOUNDS; public class LayoutInsetsTest extends Activity { static int[] GRAVITIES = {Gravity.LEFT, Gravity.LEFT, Gravity.CENTER_HORIZONTAL, Gravity.RIGHT, Gravity.RIGHT}; @@ -23,7 +22,7 @@ public class LayoutInsetsTest extends Activity { GridLayout p = new GridLayout(context); p.setUseDefaultMargins(true); //p.setAlignmentMode(ALIGN_BOUNDS); - p.setLayoutMode(OPTICAL_BOUNDS); + p.setLayoutMode(LAYOUT_MODE_OPTICAL_BOUNDS); p.setColumnCount(N); diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml index 9118aea..46a539e 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -30,393 +30,466 @@ android:label="HwUi" android:hardwareAccelerated="true"> - <meta-data android:name="android.graphics.renderThread" android:value="true" /> + <activity + android:name="HwTests" + android:label="OpenGL Renderer Tests"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.DEFAULT" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + <activity + android:name="ScaledTextActivity" + android:label="Text/Scaled" + android:theme="@android:style/Theme.Holo.Light"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + + <activity + android:name="Rotate3dTextActivity" + android:label="Text/3D Rotation" + android:theme="@android:style/Theme.Holo.Light"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + + <activity + android:name="NoAATextActivity" + android:label="Text/Aliased"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + + <activity + android:name="ScaledPathsActivity" + android:label="Path/Scaled"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + + <activity + android:name="Alpha8BitmapActivity" + android:label="Bitmaps/Alpha8"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> <activity android:name="MipMapActivity" - android:label="_MipMap"> + android:label="Bitmaps/MipMap"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="PathOffsetActivity" - android:label="_PathOffset"> + android:label="Path/Offset"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="MultiLayersActivity" - android:label="_MultiLayers"> + android:label="Layers/Multiple"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="TJunctionActivity" - android:label="_T-Junction"> + android:label="Layers/T-Junction"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="TextPathActivity" - android:label="_TextPath"> + android:label="Text/As Path"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="GradientStopsActivity" - android:label="_GradientStops"> + android:label="Gradients/Multi-stops"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="PaintDrawFilterActivity" - android:label="_DrawFilter"> + android:label="Paint/Draw Filter"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="BigGradientActivity" - android:label="_BigGradient"> + android:label="Gradients/Large"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="DatePickerActivity" - android:label="_DatePicker"> + android:label="View/DatePicker"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ClipRegionActivity" - android:label="_ClipRegion"> + android:label="Clip/Region 1"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> - + + <activity + android:name="ClipRegion2Activity" + android:label="Clip/Region 2"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + + <activity + android:name="ClipRegion3Activity" + android:label="Clip/Region 3"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + <activity android:name="DisplayListLayersActivity" - android:label="__DisplayListLayers"> + android:label="Layers/Display Lists"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="MatrixActivity" - android:label="_Matrix"> + android:label="Misc/Matrix"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="TextFadeActivity" - android:label="_TextFade"> + android:label="Text/Fade"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="MaxBitmapSizeActivity" - android:label="_MaxBitmapSize"> + android:label="Bitmaps/Max Size"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="TimeDialogActivity" - android:label="_TimeDialog"> + android:label="View/TimeDialog"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="OpaqueActivity" - android:label="_Opaque"> + android:label="Window/Opaque"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="GetBitmapActivity" - android:label="_GetBitmap"> + android:label="TextureView/Get Bitmap"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="SmallCircleActivity" - android:label="_SmallCircle"> + android:label="Draw/Small Circle"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ClearActivity" - android:label="_Clear"> + android:label="Window/Clear"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="TextureViewActivity" - android:label="_TextureView"> + android:label="TextureView/Camera"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="GlyphCacheActivity" - android:label="_GlyphCache"> + android:label="Text/Glyph Cache"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="CanvasTextureViewActivity" - android:label="_CanvasTextureView"> + android:label="TextureView/Canvas"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="GLTextureViewActivity" - android:label="_TextureViewGL"> + android:label="TextureView/OpenGL"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="BitmapMeshActivity" - android:label="_BitmapMesh"> + android:label="Bitmaps/Mesh"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="BitmapMutateActivity" - android:label="_BitmapMutate"> + android:label="Bitmaps/Mutate"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="BitmapMeshLayerActivity" - android:label="_BitmapMeshLayer"> + android:label="Bitmaps/Mesh in Layer"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="MarqueeActivity" - android:label="_Marquee"> + android:label="Text/Marquee"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ShapesActivity" - android:label="_Shapes"> + android:label="Path/Shapes"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ColoredRectsActivity" - android:label="_Rects"> + android:label="Draw/Rects"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="SimplePatchActivity" - android:label="_SimplePatch" + android:label="Draw/9-Patch" android:theme="@android:style/Theme.Translucent.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ViewLayersActivity" - android:label="_ViewLayers"> + android:label="Layers/Views 1"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ViewLayersActivity2" - android:label="_ViewLayers2"> + android:label="Layers/Views 2"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ViewLayersActivity3" - android:label="_ViewLayers3"> + android:label="Layers/Views 3"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ViewLayersActivity4" - android:label="_ViewLayers4"> + android:label="Layers/Views 4"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ViewLayersActivity5" - android:label="_ViewLayers5"> + android:label="Layers/Views 5"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="AlphaLayersActivity" - android:label="_αLayers"> + android:label="Layers/Alpha"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="AdvancedGradientsActivity" - android:label="_Advanced Gradients"> + android:label="Gradients/Advanced"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="Bitmaps3dActivity" - android:label="_Bitmaps3d"> + android:label="Bitmaps/3D Rotation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="LabelsActivity" - android:label="_Labels"> + android:label="View/TextView"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ViewFlipperActivity" - android:label="_ViewFlipper" + android:label="View/ViewFlipper" android:theme="@android:style/Theme.Translucent.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ResizeActivity" - android:label="_Resize" + android:label="Window/Resize" android:windowSoftInputMode="adjustResize"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="TextGammaActivity" - android:label="_Gamma" + android:label="Text/Gamma" android:theme="@android:style/Theme.Translucent.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="TextGammaActivity$SubGammaActivity" - android:label="_Sub Gamma" + android:label="Text/Sub Gamma" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:hardwareAccelerated="false"> <intent-filter> @@ -426,333 +499,333 @@ <activity android:name="LayersActivity" - android:label="_Layers" + android:label="Layers/Canvas Layers" android:theme="@android:style/Theme.Translucent.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="NewLayersActivity" - android:label="_NewLayers"> + android:label="Layers/Overlapping Layers"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="XfermodeActivity" - android:label="_Xfermodes" + android:label="Draw/Xfermodes" android:theme="@android:style/Theme.Translucent.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="BitmapsActivity" - android:label="_Bitmaps" + android:label="Bitmaps/Draw Bitmaps" android:theme="@android:style/Theme.Translucent.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="BitmapsSkewActivity" - android:label="_BitmapsSkew"> + android:label="Bitmaps/Skew"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="BitmapsAlphaActivity" - android:label="_BitmapsAlpha" + android:label="Bitmaps/Alpha" android:theme="@android:style/Theme.Translucent.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="BitmapsRectActivity" - android:label="_BitmapsRect" + android:label="Bitmaps/Rect" android:theme="@android:style/Theme.Translucent.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ThinPatchesActivity" - android:label="_9patchThin" + android:label="Draw/9-Patch Thin Drawable" android:theme="@android:style/Theme.Translucent.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="NinePatchesActivity" - android:label="_9patch"> + android:label="Draw/9-Patch Drawable"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="MoreNinePatchesActivity" - android:label="_9patch2"> + android:label="Draw/9-Patch Vertical Drawable"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="QuickRejectActivity" - android:label="_QuickReject"> + android:label="Clip/QuickReject"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="RotationActivity" - android:label="_Rotation"> + android:label="View/Rotation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="GradientsActivity" - android:label="_Gradients"> + android:label="Gradients/Gradients"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ShadersActivity" - android:label="_Shaders"> + android:label="Shaders/Shaders"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="TextActivity" - android:label="_Text" + android:label="Text/Simple Text" android:theme="@android:style/Theme.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="PosTextActivity" - android:label="_PosText" + android:label="Text/Pos Text" android:theme="@android:style/Theme.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ListActivity" - android:label="__List"> + android:label="View/List"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="TransparentListActivity" - android:label="_TransparentList"> + android:label="View/Transparent List"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="MoreShadersActivity" - android:label="_Shaders2"> + android:label="Shaders/Compose Shaders"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ColorFiltersActivity" - android:label="_ColorFilters"> + android:label="ColorFilters/Filters"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="LinesActivity" - android:label="_Lines"> + android:label="Draw/Lines"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="Lines2Activity" - android:label="_Lines2"> + android:label="Draw/Lines 2"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="PathsActivity" - android:label="_Paths"> + android:label="Path/Paths"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="TextOnPathActivity" - android:label="_TextOnPath"> + android:label="Text/Text on Path"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="PathsCacheActivity" - android:label="_PathsCache"> + android:label="Path/Cache"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="PointsActivity" - android:label="_Points"> + android:label="Draw/Points"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="Transform3dActivity" - android:label="_3d"> + android:label="Draw/3D Transform"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="Animated3dActivity" - android:label="_Animated 3d"> + android:label="Draw/Animated 3D Transform"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="SimplePathsActivity" - android:label="_SimplePaths"> + android:label="Path/Simple Paths"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="AdvancedBlendActivity" - android:label="_Advanced Blend"> + android:label="Draw/Advanced Blend"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="FramebufferBlendActivity" - android:label="_FramebufferBlend"> + android:label="Draw/Framebuffer Blend"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="StackActivity" - android:label="_Stacks"> + android:label="View/Stacks"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="PathDestructionActivity" - android:label="_PathDestruction"> + android:label="Path/Path Destruction"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="TransformsAndAnimationsActivity" - android:label="_TransformAnim"> + android:label="Draw/Transforms and Animations"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ViewPropertyAlphaActivity" - android:label="_ViewPropAlpha"> + android:label="View/Alpha Property"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> <activity android:name="ViewLayerInvalidationActivity" - android:label="_ViewLayerInvalidation"> + android:label="Layers/Invalidation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> diff --git a/tests/HwAccelerationTest/res/drawable-nodpi/spot_mask.png b/tests/HwAccelerationTest/res/drawable-nodpi/spot_mask.png Binary files differnew file mode 100644 index 0000000..8953759 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable-nodpi/spot_mask.png diff --git a/tests/HwAccelerationTest/res/drawable/patch.9.png b/tests/HwAccelerationTest/res/drawable/patch.9.png Binary files differdeleted file mode 100644 index e3b3639..0000000 --- a/tests/HwAccelerationTest/res/drawable/patch.9.png +++ /dev/null diff --git a/tests/HwAccelerationTest/res/layout/view_layers_5.xml b/tests/HwAccelerationTest/res/layout/view_layers_5.xml index 36cf8c9..5baf583 100644 --- a/tests/HwAccelerationTest/res/layout/view_layers_5.xml +++ b/tests/HwAccelerationTest/res/layout/view_layers_5.xml @@ -48,13 +48,32 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Grow layer" /> + + <Button + android:onClick="enableClip" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Circle clip" /> + + <Button + android:onClick="disableClip" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="No clip" /> </LinearLayout> - <ListView - android:id="@+id/list1" + <view class="com.android.test.hwui.ViewLayersActivity5$ClipFrameLayout" + android:id="@+id/container" android:layout_width="0dip" android:layout_height="match_parent" - android:layout_weight="1" /> + android:layout_weight="1"> + + <ListView + android:id="@+id/list1" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + + </view> </LinearLayout> diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/Alpha8BitmapActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/Alpha8BitmapActivity.java new file mode 100644 index 0000000..5fe512e --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/Alpha8BitmapActivity.java @@ -0,0 +1,97 @@ +/* + * 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.test.hwui; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.BitmapShader; +import android.graphics.Canvas; +import android.graphics.Matrix; +import android.graphics.Paint; +import android.graphics.Rect; +import android.graphics.RectF; +import android.graphics.Shader; +import android.os.Bundle; +import android.view.View; + +@SuppressWarnings({"UnusedDeclaration"}) +public class Alpha8BitmapActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(new BitmapsView(this)); + } + + static class BitmapsView extends View { + private Paint mBitmapPaint; + private final Bitmap mBitmap1; + private final float[] mVertices; + + BitmapsView(Context c) { + super(c); + + Bitmap texture = BitmapFactory.decodeResource(c.getResources(), R.drawable.spot_mask); + mBitmap1 = Bitmap.createBitmap(texture.getWidth(), texture.getHeight(), + Bitmap.Config.ALPHA_8); + Canvas canvas = new Canvas(mBitmap1); + canvas.drawBitmap(texture, 0.0f, 0.0f, null); + + texture = BitmapFactory.decodeResource(c.getResources(), R.drawable.sunset1); + BitmapShader shader = new BitmapShader(texture, + Shader.TileMode.REPEAT, Shader.TileMode.REPEAT); + + final float width = texture.getWidth() / 3.0f; + final float height = texture.getHeight() / 3.0f; + + mVertices = new float[] { + 0.0f, 0.0f, width, 0.0f, width * 2, 0.0f, width * 3, 0.0f, + 0.0f, height, width, height, width * 2, height, width * 4, height, + 0.0f, height * 2, width, height * 2, width * 2, height * 2, width * 3, height * 2, + 0.0f, height * 4, width, height * 4, width * 2, height * 4, width * 4, height * 4, + }; + + mBitmapPaint = new Paint(); + mBitmapPaint.setFilterBitmap(true); + mBitmapPaint.setShader(shader); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + canvas.drawColor(0xffffffff); + canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mBitmapPaint); + + Matrix matrix = new Matrix(); + matrix.setScale(2.0f, 2.0f); + matrix.postTranslate(0.0f, mBitmap1.getHeight()); + canvas.drawBitmap(mBitmap1, matrix, mBitmapPaint); + + Rect src = new Rect(0, 0, mBitmap1.getWidth() / 2, mBitmap1.getHeight() / 2); + Rect dst = new Rect(0, mBitmap1.getHeight() * 3, mBitmap1.getWidth(), + mBitmap1.getHeight() * 4); + canvas.drawBitmap(mBitmap1, src, dst, mBitmapPaint); + + canvas.translate(0.0f, mBitmap1.getHeight() * 4); + canvas.drawBitmapMesh(mBitmap1, 3, 3, mVertices, 0, null, 0, mBitmapPaint); + + invalidate(); + } + } +} diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/BitmapMeshActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/BitmapMeshActivity.java index 854dd69..69d34a5 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/BitmapMeshActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/BitmapMeshActivity.java @@ -54,7 +54,7 @@ public class BitmapMeshActivity extends Activity { 0.0f, height * 2, width, height * 2, width * 2, height * 2, width * 3, height * 2, 0.0f, height * 4, width, height * 4, width * 2, height * 4, width * 4, height * 4, }; - + mColors = new int[] { 0xffff0000, 0xff00ff00, 0xff0000ff, 0xffff0000, 0xff0000ff, 0xffff0000, 0xff00ff00, 0xff00ff00, diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegion2Activity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegion2Activity.java new file mode 100644 index 0000000..066e35c --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegion2Activity.java @@ -0,0 +1,86 @@ +/* + * 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.test.hwui; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Region; +import android.os.Bundle; +import android.widget.FrameLayout; +import android.widget.TextView; + +@SuppressWarnings({"UnusedDeclaration"}) +public class ClipRegion2Activity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final RegionView group = new RegionView(this); + + final TextView text = new TextView(this); + text.setText(buildText()); + group.addView(text); + + setContentView(group); + } + + private static CharSequence buildText() { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < 10; i++) { + buffer.append(LOREM_IPSUM); + } + return buffer; + } + + public static class RegionView extends FrameLayout { + private final Region mRegion = new Region(); + private float mClipPosition = 0.0f; + + public RegionView(Context c) { + super(c); + } + + public float getClipPosition() { + return mClipPosition; + } + + public void setClipPosition(float clipPosition) { + mClipPosition = clipPosition; + invalidate(); + } + + @Override + protected void dispatchDraw(Canvas canvas) { + + canvas.save(); + + mRegion.setEmpty(); + mRegion.op(0, 0, getWidth(), getHeight(), + Region.Op.REPLACE); + mRegion.op(getWidth() / 4, getHeight() / 4, 3 * getWidth() / 4, 3 * getHeight() / 4, + Region.Op.DIFFERENCE); + + canvas.clipRegion(mRegion); + super.dispatchDraw(canvas); + + canvas.restore(); + } + } + + private static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sagittis molestie aliquam. Donec metus metus, laoreet nec sagittis vitae, ultricies sit amet eros. Suspendisse sed massa sit amet felis consectetur gravida. In vitae erat mi, in egestas nisl. Phasellus quis ipsum massa, at scelerisque arcu. Nam lectus est, pellentesque eget lacinia non, congue vitae augue. Aliquam erat volutpat. Pellentesque bibendum tincidunt viverra. Aliquam erat volutpat. Maecenas pretium vulputate placerat. Nulla varius elementum rutrum. Aenean mollis blandit imperdiet. Pellentesque interdum fringilla ligula."; +} diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegion3Activity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegion3Activity.java new file mode 100644 index 0000000..6fd03fb --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegion3Activity.java @@ -0,0 +1,82 @@ +/* + * 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.test.hwui; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Path; +import android.os.Bundle; +import android.widget.FrameLayout; +import android.widget.TextView; + +@SuppressWarnings({"UnusedDeclaration"}) +public class ClipRegion3Activity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final RegionView group = new RegionView(this); + + final TextView text = new TextView(this); + text.setText(buildText()); + group.addView(text); + + setContentView(group); + } + + private static CharSequence buildText() { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < 10; i++) { + buffer.append(LOREM_IPSUM); + } + return buffer; + } + + public static class RegionView extends FrameLayout { + private final Path mClipPath = new Path(); + private float mClipPosition = 0.5f; + + public RegionView(Context c) { + super(c); + setAlpha(0.5f); + } + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + mClipPath.reset(); + mClipPath.addCircle(0.0f, 0.0f, getWidth() / 4.0f, Path.Direction.CW); + } + + @Override + protected void dispatchDraw(Canvas canvas) { + canvas.drawARGB(255, 255, 255, 255); + + canvas.save(Canvas.MATRIX_SAVE_FLAG); + canvas.translate(mClipPosition * getWidth(), getHeight() / 2.0f); + canvas.clipPath(mClipPath); + canvas.restore(); + + super.dispatchDraw(canvas); + + invalidate(); + } + } + + private static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sagittis molestie aliquam. Donec metus metus, laoreet nec sagittis vitae, ultricies sit amet eros. Suspendisse sed massa sit amet felis consectetur gravida. In vitae erat mi, in egestas nisl. Phasellus quis ipsum massa, at scelerisque arcu. Nam lectus est, pellentesque eget lacinia non, congue vitae augue. Aliquam erat volutpat. Pellentesque bibendum tincidunt viverra. Aliquam erat volutpat. Maecenas pretium vulputate placerat. Nulla varius elementum rutrum. Aenean mollis blandit imperdiet. Pellentesque interdum fringilla ligula."; +} diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegionActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegionActivity.java index b2a508b..774811e 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegionActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegionActivity.java @@ -16,42 +16,78 @@ package com.android.test.hwui; +import android.animation.ObjectAnimator; +import android.animation.ValueAnimator; import android.app.Activity; import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Canvas; -import android.graphics.Paint; import android.graphics.Path; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffXfermode; -import android.graphics.Region; import android.os.Bundle; -import android.view.View; +import android.widget.FrameLayout; +import android.widget.TextView; @SuppressWarnings({"UnusedDeclaration"}) public class ClipRegionActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - final RegionView view = new RegionView(this); - setContentView(view); + + final RegionView group = new RegionView(this); + + final TextView text = new TextView(this); + text.setText(buildText()); + group.addView(text); + + setContentView(group); + + ObjectAnimator animator = ObjectAnimator.ofFloat(group, "clipPosition", 0.0f, 1.0f); + animator.setDuration(3000); + animator.setRepeatCount(ValueAnimator.INFINITE); + animator.setRepeatMode(ValueAnimator.REVERSE); + animator.start(); } - public static class RegionView extends View { + private static CharSequence buildText() { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < 10; i++) { + buffer.append(LOREM_IPSUM); + } + return buffer; + } + + public static class RegionView extends FrameLayout { + private final Path mClipPath = new Path(); + private float mClipPosition = 0.0f; + public RegionView(Context c) { super(c); + setAlpha(0.5f); + } + + public float getClipPosition() { + return mClipPosition; + } + + public void setClipPosition(float clipPosition) { + mClipPosition = clipPosition; + invalidate(); } @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); + protected void dispatchDraw(Canvas canvas) { canvas.save(); - canvas.clipRect(100.0f, 100.0f, getWidth() - 100.0f, getHeight() - 100.0f, - Region.Op.DIFFERENCE); - canvas.drawARGB(255, 255, 0, 0); + + mClipPath.reset(); + mClipPath.addCircle(mClipPosition * getWidth(), getHeight() / 2.0f, + getWidth() / 4.0f, Path.Direction.CW); + + canvas.clipPath(mClipPath); + super.dispatchDraw(canvas); + canvas.restore(); } } + + private static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sagittis molestie aliquam. Donec metus metus, laoreet nec sagittis vitae, ultricies sit amet eros. Suspendisse sed massa sit amet felis consectetur gravida. In vitae erat mi, in egestas nisl. Phasellus quis ipsum massa, at scelerisque arcu. Nam lectus est, pellentesque eget lacinia non, congue vitae augue. Aliquam erat volutpat. Pellentesque bibendum tincidunt viverra. Aliquam erat volutpat. Maecenas pretium vulputate placerat. Nulla varius elementum rutrum. Aenean mollis blandit imperdiet. Pellentesque interdum fringilla ligula."; } diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/HwTests.java b/tests/HwAccelerationTest/src/com/android/test/hwui/HwTests.java new file mode 100644 index 0000000..b1c32a8 --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/HwTests.java @@ -0,0 +1,153 @@ +/* + * 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.test.hwui; + +import android.app.*; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.os.Bundle; +import android.view.View; +import android.widget.ListView; +import android.widget.SimpleAdapter; + +import java.text.Collator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@SuppressWarnings("UnusedDeclaration") +public class HwTests extends android.app.ListActivity { + private static final String EXTRA_PATH = "com.android.test.hwui.Path"; + private static final String CATEGORY_HWUI_TEST = "com.android.test.hwui.TEST"; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent intent = getIntent(); + String path = intent.getStringExtra("com.android.test.hwui.Path"); + + if (path == null) { + path = ""; + } + + setListAdapter(new SimpleAdapter(this, getData(path), + android.R.layout.simple_list_item_1, new String[] { "title" }, + new int[] { android.R.id.text1 })); + getListView().setTextFilterEnabled(true); + } + + protected List<Map<String, Object>> getData(String prefix) { + List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>(); + + Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); + mainIntent.addCategory(CATEGORY_HWUI_TEST); + + PackageManager pm = getPackageManager(); + List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0); + + if (null == list) + return myData; + + String[] prefixPath; + String prefixWithSlash = prefix; + + if (prefix.equals("")) { + prefixPath = null; + } else { + prefixPath = prefix.split("/"); + prefixWithSlash = prefix + "/"; + } + + int len = list.size(); + + Map<String, Boolean> entries = new HashMap<String, Boolean>(); + + for (int i = 0; i < len; i++) { + ResolveInfo info = list.get(i); + CharSequence labelSeq = info.loadLabel(pm); + String label = labelSeq != null + ? labelSeq.toString() + : info.activityInfo.name; + + if (prefixWithSlash.length() == 0 || label.startsWith(prefixWithSlash)) { + + String[] labelPath = label.split("/"); + + String nextLabel = prefixPath == null ? labelPath[0] : labelPath[prefixPath.length]; + + if ((prefixPath != null ? prefixPath.length : 0) == labelPath.length - 1) { + addItem(myData, nextLabel, activityIntent( + info.activityInfo.applicationInfo.packageName, + info.activityInfo.name)); + } else { + if (entries.get(nextLabel) == null) { + addItem(myData, nextLabel, browseIntent(prefix.equals("") ? + nextLabel : prefix + "/" + nextLabel)); + entries.put(nextLabel, true); + } + } + } + } + + Collections.sort(myData, sDisplayNameComparator); + + return myData; + } + + private final static Comparator<Map<String, Object>> sDisplayNameComparator = + new Comparator<Map<String, Object>>() { + private final Collator collator = Collator.getInstance(); + + public int compare(Map<String, Object> map1, Map<String, Object> map2) { + return collator.compare(map1.get("title"), map2.get("title")); + } + }; + + protected Intent activityIntent(String pkg, String componentName) { + Intent result = new Intent(); + result.setClassName(pkg, componentName); + return result; + } + + protected Intent browseIntent(String path) { + Intent result = new Intent(); + result.setClass(this, HwTests.class); + result.putExtra(EXTRA_PATH, path); + return result; + } + + protected void addItem(List<Map<String, Object>> data, String name, Intent intent) { + Map<String, Object> temp = new HashMap<String, Object>(); + temp.put("title", name); + temp.put("intent", intent); + data.add(temp); + } + + @Override + @SuppressWarnings({ "unchecked", "UnusedParameters" }) + protected void onListItemClick(ListView l, View v, int position, long id) { + Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position); + + Intent intent = (Intent) map.get("intent"); + startActivity(intent); + } +} 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 @@ public class MoreShadersActivity extends Activity { private Paint mLargePaint; private BitmapShader mScaled2Shader; private ColorFilter mColorFilter; + private final Matrix mMtx1; ShadersView(Context c) { super(c); @@ -70,7 +71,7 @@ public class MoreShadersActivity extends Activity { 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 @@ public class MoreShadersActivity extends Activity { 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/NoAATextActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/NoAATextActivity.java new file mode 100644 index 0000000..5bd2f58 --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/NoAATextActivity.java @@ -0,0 +1,57 @@ +/* + * 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.test.hwui; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.os.Bundle; +import android.view.View; + +@SuppressWarnings({"UnusedDeclaration"}) +public class NoAATextActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final ScaledNoAA view = new ScaledNoAA(this); + setContentView(view); + } + + public static class ScaledNoAA extends View { + private static final String TEXT = "Hello libhwui!"; + + private final Paint mPaint; + + public ScaledNoAA(Context c) { + super(c); + + mPaint = new Paint(); + mPaint.setTextSize(60.0f); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + canvas.drawARGB(255, 255, 255, 255); + canvas.drawText(TEXT, 30.0f, 150.0f, mPaint); + } + } +} diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/PathsCacheActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/PathsCacheActivity.java index 9ab2a86..9f97311 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/PathsCacheActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/PathsCacheActivity.java @@ -33,6 +33,7 @@ public class PathsCacheActivity extends Activity { private Path mPath; private final Random mRandom = new Random(); + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") private final ArrayList<Path> mPathList = new ArrayList<Path>(); @Override @@ -45,19 +46,32 @@ public class PathsCacheActivity extends Activity { setContentView(view); } - private Path makePath() { + private static Path makePath() { Path path = new Path(); buildPath(path); return path; } - private void buildPath(Path path) { + private static void buildPath(Path path) { path.moveTo(0.0f, 0.0f); path.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f); path.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f); path.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f); } + private static Path makeLargePath() { + Path path = new Path(); + buildLargePath(path); + return path; + } + + private static void buildLargePath(Path path) { + path.moveTo(0.0f, 0.0f); + path.cubicTo(0.0f, 0.0f, 10000.0f, 15000.0f, 10000.0f, 20000.0f); + path.cubicTo(10000.0f, 20000.0f, 5000.0f, 30000.0f, -8000.0f, 20000.0f); + path.cubicTo(-8000.0f, 20000.0f, 10000.0f, 20000.0f, 20000.0f, 0.0f); + } + public class PathsView extends View { private final Paint mMediumPaint; @@ -97,6 +111,9 @@ public class PathsCacheActivity extends Activity { int r = mRandom.nextInt(10); if (r == 5 || r == 3) { mPathList.add(path); + } else if (r == 7) { + path = makeLargePath(); + mPathList.add(path); } canvas.save(); diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/Rotate3dTextActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/Rotate3dTextActivity.java new file mode 100644 index 0000000..0368b2f --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/Rotate3dTextActivity.java @@ -0,0 +1,82 @@ +/* + * 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.test.hwui; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.os.Bundle; +import android.view.View; +import android.widget.FrameLayout; +import android.widget.LinearLayout; + +@SuppressWarnings({"UnusedDeclaration"}) +public class Rotate3dTextActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final LinearLayout layout = new LinearLayout(this); + layout.setOrientation(LinearLayout.VERTICAL); + + Rotate3dTextView view = new Rotate3dTextView(this); + layout.addView(view, makeLayoutParams()); + + view = new Rotate3dTextView(this); + + FrameLayout container = new FrameLayout(this); + container.setLayerType(View.LAYER_TYPE_HARDWARE, null); + container.addView(view); + + layout.addView(container, makeLayoutParams()); + + setContentView(layout); + } + + private static LinearLayout.LayoutParams makeLayoutParams() { + LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, 0); + lp.weight = 1.0f; + return lp; + } + + public static class Rotate3dTextView extends View { + private static final String TEXT = "Hello libhwui! "; + + private final Paint mPaint; + + public Rotate3dTextView(Context c) { + super(c); + + mPaint = new Paint(); + mPaint.setAntiAlias(true); + mPaint.setTextSize(50.0f); + mPaint.setTextAlign(Paint.Align.CENTER); + + setRotationY(45.0f); + setScaleX(2.0f); + setScaleY(2.0f); + } + + @Override + protected void onDraw(Canvas canvas) { + canvas.drawText(TEXT, getWidth() / 2.0f, getHeight() / 2.0f, mPaint); + } + } +} diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledPathsActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledPathsActivity.java new file mode 100644 index 0000000..deb4b6b --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledPathsActivity.java @@ -0,0 +1,92 @@ +/* + * 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.test.hwui; + +import android.app.Activity; +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; + +@SuppressWarnings({"UnusedDeclaration"}) +public class ScaledPathsActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final PathsView view = new PathsView(this); + setContentView(view); + } + + public static class PathsView extends View { + private final Paint mPathPaint; + private final Path mPath; + private final RectF mPathBounds = new RectF(); + + public PathsView(Context c) { + super(c); + + mPathPaint = new Paint(); + mPathPaint.setAntiAlias(true); + mPathPaint.setColor(0xff0000ff); + mPathPaint.setStrokeWidth(5.0f); + mPathPaint.setStyle(Paint.Style.FILL); + + mPath = new Path(); + mPath.moveTo(0.0f, 0.0f); + mPath.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f); + mPath.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f); + mPath.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f); + + mPath.computeBounds(mPathBounds, true); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + canvas.drawARGB(255, 255, 255, 255); + + mPathPaint.setColor(0xff0000ff); + mPathPaint.setStyle(Paint.Style.FILL); + + canvas.save(); + drawPath(canvas, 1.0f, 1.0f); + drawPath(canvas, 2.0f, 2.0f); + drawPath(canvas, 4.0f, 4.0f); + canvas.restore(); + + mPathPaint.setColor(0xffff0000); + mPathPaint.setStyle(Paint.Style.STROKE); + + canvas.save(); + drawPath(canvas, 1.0f, 1.0f); + drawPath(canvas, 2.0f, 2.0f); + drawPath(canvas, 4.0f, 4.0f); + canvas.restore(); + } + + private void drawPath(Canvas canvas, float scaleX, float scaleY) { + canvas.save(); + canvas.scale(scaleX, scaleY); + canvas.drawPath(mPath, mPathPaint); + canvas.restore(); + canvas.translate(mPathBounds.width() * scaleX, 0.0f); + } + } +} diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java new file mode 100644 index 0000000..a4e9b52 --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java @@ -0,0 +1,140 @@ +/* + * 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.test.hwui; + +import android.animation.ObjectAnimator; +import android.app.Activity; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Path; +import android.os.Bundle; +import android.view.View; + +@SuppressWarnings({"UnusedDeclaration"}) +public class ScaledTextActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final ScaledTextView view = new ScaledTextView(this); + setContentView(view); + + ObjectAnimator animation = ObjectAnimator.ofFloat(view, "textScale", 1.0f, 10.0f); + animation.setDuration(3000); + animation.setRepeatCount(ObjectAnimator.INFINITE); + animation.setRepeatMode(ObjectAnimator.REVERSE); + animation.start(); + + } + + public static class ScaledTextView extends View { + private static final String TEXT = "Hello libhwui! "; + + private final Paint mPaint; + private final Paint mShadowPaint; + private final Path mPath; + + private float mScale = 1.0f; + + public ScaledTextView(Context c) { + super(c); + setLayerType(LAYER_TYPE_HARDWARE, null); + + mPath = makePath(); + + mPaint = new Paint(); + mPaint.setAntiAlias(true); + mPaint.setTextSize(20.0f); + + mShadowPaint = new Paint(); + mShadowPaint.setAntiAlias(true); + mShadowPaint.setShadowLayer(3.0f, 0.0f, 3.0f, 0xff000000); + mShadowPaint.setTextSize(20.0f); + } + + public float getTextScale() { + return mScale; + } + + public void setTextScale(float scale) { + mScale = scale; + invalidate(); + } + + private static Path makePath() { + Path path = new Path(); + buildPath(path); + return path; + } + + private static void buildPath(Path path) { + path.moveTo(0.0f, 0.0f); + path.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f); + path.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f); + path.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + canvas.drawText(TEXT, 30.0f, 30.0f, mPaint); + mPaint.setTextAlign(Paint.Align.CENTER); + canvas.drawText(TEXT, 30.0f, 50.0f, mPaint); + mPaint.setTextAlign(Paint.Align.RIGHT); + canvas.drawText(TEXT, 30.0f, 70.0f, mPaint); + + canvas.save(); + canvas.translate(400.0f, 0.0f); + canvas.scale(3.0f, 3.0f); + mPaint.setTextAlign(Paint.Align.LEFT); + mPaint.setStrikeThruText(true); + canvas.drawText(TEXT, 30.0f, 30.0f, mPaint); + mPaint.setStrikeThruText(false); + mPaint.setTextAlign(Paint.Align.CENTER); + canvas.drawText(TEXT, 30.0f, 50.0f, mPaint); + mPaint.setTextAlign(Paint.Align.RIGHT); + canvas.drawText(TEXT, 30.0f, 70.0f, mPaint); + canvas.restore(); + + mPaint.setTextAlign(Paint.Align.LEFT); + canvas.translate(0.0f, 100.0f); + + canvas.save(); + canvas.scale(mScale, mScale); + canvas.drawText(TEXT, 30.0f, 30.0f, mPaint); + canvas.restore(); + + canvas.translate(0.0f, 250.0f); + canvas.save(); + canvas.scale(3.0f, 3.0f); + canvas.drawText(TEXT, 30.0f, 30.0f, mShadowPaint); + canvas.translate(100.0f, 0.0f); +// canvas.drawTextOnPath(TEXT + TEXT + TEXT, mPath, 0.0f, 0.0f, mPaint); + canvas.restore(); + + float width = mPaint.measureText(TEXT); + + canvas.translate(500.0f, 0.0f); + canvas.rotate(45.0f, width * 3.0f / 2.0f, 0.0f); + canvas.scale(3.0f, 3.0f); + canvas.drawText(TEXT, 30.0f, 30.0f, mPaint); + } + } +} 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.app.Activity; 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 @@ public class ShapesActivity extends Activity { } 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 @@ public class ShapesActivity extends Activity { 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 @@ public class ShapesActivity extends Activity { 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/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java index 9849e3c..ceccfaa 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java @@ -41,26 +41,26 @@ public class TextOnPathActivity extends Activity { setContentView(view); } - private Path makePath() { + private static Path makePath() { Path path = new Path(); buildPath(path); return path; } - private void buildPath(Path path) { + private static void buildPath(Path path) { path.moveTo(0.0f, 0.0f); path.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f); path.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f); path.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f); } - private Path makeStraightPath() { + private static Path makeStraightPath() { Path path = new Path(); buildStraightPath(path); return path; } - private void buildStraightPath(Path path) { + private static void buildStraightPath(Path path) { path.moveTo(0.0f, 0.0f); path.lineTo(400.0f, 0.0f); } diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity5.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity5.java index 2664977..cbbb7ef 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity5.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity5.java @@ -19,14 +19,18 @@ package com.android.test.hwui; import android.app.Activity; import android.content.Context; import android.content.res.Resources; +import android.graphics.Canvas; import android.graphics.Paint; +import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.os.Bundle; +import android.util.AttributeSet; import android.util.DisplayMetrics; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.FrameLayout; import android.widget.ListView; import android.widget.TextView; @@ -37,30 +41,75 @@ public class ViewLayersActivity5 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + + init(); + setContentView(R.layout.view_layers_5); + setupList(R.id.list1); + } + + public static class ClipFrameLayout extends FrameLayout { + private final Path mClipPath = new Path(); + private boolean mClipEnabled; + + public ClipFrameLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public ClipFrameLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + public boolean isClipEnabled() { + return mClipEnabled; + } + public void setClipEnabled(boolean clipEnabled) { + mClipEnabled = clipEnabled; + invalidate(); + } + + @Override + protected void dispatchDraw(Canvas canvas) { + if (mClipEnabled) { + mClipPath.reset(); + mClipPath.addCircle(getWidth() / 2.0f, getHeight() / 2.0f, + Math.min(getWidth(), getHeight()) / 3.0f, Path.Direction.CW); + + canvas.clipPath(mClipPath); + } + super.dispatchDraw(canvas); + } + } + + private void init() { mPaint.setColorFilter(new PorterDuffColorFilter(0xff00ff00, PorterDuff.Mode.MULTIPLY)); + } - setupList(R.id.list1); + public void enableClip(View v) { + ((ClipFrameLayout) findViewById(R.id.container)).setClipEnabled(true); + } + + public void disableClip(View v) { + ((ClipFrameLayout) findViewById(R.id.container)).setClipEnabled(false); } public void enableLayer(View v) { - findViewById(R.id.list1).setLayerType(View.LAYER_TYPE_HARDWARE, mPaint); + findViewById(R.id.container).setLayerType(View.LAYER_TYPE_HARDWARE, mPaint); } public void disableLayer(View v) { - findViewById(R.id.list1).setLayerType(View.LAYER_TYPE_NONE, null); + findViewById(R.id.container).setLayerType(View.LAYER_TYPE_NONE, null); } public void growLayer(View v) { - findViewById(R.id.list1).getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; - findViewById(R.id.list1).requestLayout(); + findViewById(R.id.container).getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; + findViewById(R.id.container).requestLayout(); } public void shrinkLayer(View v) { - findViewById(R.id.list1).getLayoutParams().height = 300; - findViewById(R.id.list1).requestLayout(); + findViewById(R.id.container).getLayoutParams().height = 300; + findViewById(R.id.container).requestLayout(); } private void setupList(int listId) { diff --git a/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java b/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java index 854a3f4..dbaedf9 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java +++ b/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java @@ -47,7 +47,7 @@ public class ButtonActivity extends Activity { public void onClick (View v) { - InputMethodManager imm = InputMethodManager.getInstance(instance); + InputMethodManager imm = InputMethodManager.getInstance(); if (mKeyboardIsActive) { imm.hideSoftInputFromInputMethod(v.getWindowToken(), 0); diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java b/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java index bc77e04..32f80a3 100644 --- a/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java @@ -66,7 +66,7 @@ public abstract class ImfBaseTestCase<T extends Activity> extends Instrumentatio mExpectAutoPop = (keyboardType == Configuration.KEYBOARD_NOKEYS || keyboardType == Configuration.KEYBOARD_UNDEFINED); - mImm = InputMethodManager.getInstance(mTargetActivity); + mImm = InputMethodManager.getInstance(); KeyguardManager keyguardManager = (KeyguardManager) getInstrumentation().getContext().getSystemService( diff --git a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java index b550957..397ef13 100644 --- a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java +++ b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java @@ -275,7 +275,7 @@ public class MemoryUsageTest extends InstrumentationTestCase { UserHandle.USER_CURRENT); } - mAm.startActivityAndWait(null, mLaunchIntent, mimeType, + mAm.startActivityAndWait(null, null, mLaunchIntent, mimeType, null, null, 0, mLaunchIntent.getFlags(), null, null, null, UserHandle.USER_CURRENT_OR_SELF); } catch (RemoteException e) { 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 Binary files differdeleted file mode 100644 index 3a5c970..0000000 --- a/tests/RenderScriptTests/Balls/res/drawable/flares.png +++ /dev/null diff --git a/tests/RenderScriptTests/Balls/res/drawable/test_pattern.png b/tests/RenderScriptTests/Balls/res/drawable/test_pattern.png Binary files differdeleted file mode 100644 index e7d1455..0000000 --- a/tests/RenderScriptTests/Balls/res/drawable/test_pattern.png +++ /dev/null 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 8cab9b8..0000000 --- a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/BallsRS.java +++ /dev/null @@ -1,143 +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 = 900; - - public BallsRS() { - } - - private Resources mRes; - private RenderScriptGL mRS; - private ScriptC_balls mScript; - private ScriptC_ball_physics mPhysicsScript; - private ProgramFragment mPFLines; - private ProgramFragment mPFPoints; - private ProgramVertex mPV; - private ScriptField_Point mPoints; - private ScriptField_VpConsts mVpConsts; - - 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 = vec4(1.0, 1.0, 1.0, 1.0);\n" + - " gl_PointSize = ATTRIB_size;\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(); - } - - public void init(RenderScriptGL rs, Resources res, int width, int height) { - mRS = rs; - mRes = res; - - ProgramFragmentFixedFunction.Builder pfb = new ProgramFragmentFixedFunction.Builder(rs); - pfb.setPointSpriteTexCoordinateReplacement(true); - pfb.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.MODULATE, - ProgramFragmentFixedFunction.Builder.Format.RGBA, 0); - pfb.setVaryingColor(true); - mPFPoints = pfb.create(); - - pfb = new ProgramFragmentFixedFunction.Builder(rs); - pfb.setVaryingColor(true); - mPFLines = pfb.create(); - - android.util.Log.e("rs", "Load texture"); - 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(); - - mPhysicsScript = new ScriptC_ball_physics(mRS, mRes, R.raw.ball_physics); - - mScript = new ScriptC_balls(mRS, mRes, R.raw.balls); - mScript.set_partMesh(smP); - mScript.set_physics_script(mPhysicsScript); - mScript.bind_point(mPoints); - mScript.bind_balls1(new ScriptField_Ball(mRS, PART_COUNT, Allocation.USAGE_SCRIPT)); - mScript.bind_balls2(new ScriptField_Ball(mRS, PART_COUNT, Allocation.USAGE_SCRIPT)); - - mScript.set_gPFLines(mPFLines); - 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)); - - 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, 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 8a3db6d..0000000 --- a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/ball_physics.rs +++ /dev/null @@ -1,146 +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]; - -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(const Ball_t *ballIn, Ball_t *ballOut, const BallControl_t *ctl, uint32_t x) { - float2 fv = {0, 0}; - float2 pos = ballIn->position; - - int arcID = -1; - float arcInvStr = 100000; - - const Ball_t * bPtr = rsGetElementAt(ctl->ain, 0); - for (uint32_t xin = 0; xin < ctl->dimX; xin++) { - float2 vec = bPtr[xin].position - pos; - float2 vec2 = vec * vec; - float len2 = vec2.x + vec2.y; - - if (len2 < 10000) { - //float minDist = ballIn->size + bPtr[xin].size; - float forceScale = ballIn->size * bPtr[xin].size; - forceScale *= forceScale; - - if (len2 > 16 /* (minDist*minDist)*/) { - // Repulsion - float len = sqrt(len2); - fv -= (vec / (len * len * len)) * 20000.f * forceScale; - } else { - if (len2 < 1) { - if (xin == x) { - continue; - } - ballOut->delta = 0.f; - ballOut->position = ballIn->position; - if (xin > x) { - ballOut->position.x += 1.f; - } else { - ballOut->position.x -= 1.f; - } - //ballOut->color.rgb = 1.f; - //ballOut->arcID = -1; - //ballOut->arcStr = 0; - continue; - } - // Collision - float2 axis = normalize(vec); - float e1 = dot(axis, ballIn->delta); - float e2 = dot(axis, bPtr[xin].delta); - float e = (e1 - e2) * 0.45f; - if (e1 > 0) { - fv -= axis * e; - } else { - fv += axis * e; - } - } - } - } - - fv /= ballIn->size * ballIn->size * ballIn->size; - fv -= gGravityVector * 4.f; - fv *= ctl->dt; - - for (int i=0; i < 10; i++) { - if (touchPressure[i] > 0.1f) { - float2 vec = touchPos[i] - ballIn->position; - float2 vec2 = vec * vec; - float len2 = max(2.f, vec2.x + vec2.y); - fv -= (vec / len2) * touchPressure[i] * 300.f; - } - } - - ballOut->delta = (ballIn->delta * (1.f - 0.004f)) + fv; - ballOut->position = ballIn->position + (ballOut->delta * ctl->dt); - - const float wallForce = 400.f; - if (ballOut->position.x > (gMaxPos.x - 20.f)) { - float d = gMaxPos.x - ballOut->position.x; - if (d < 0.f) { - if (ballOut->delta.x > 0) { - ballOut->delta.x *= -0.7f; - } - ballOut->position.x = gMaxPos.x; - } else { - ballOut->delta.x -= min(wallForce / (d * d), 10.f); - } - } - - if (ballOut->position.x < (gMinPos.x + 20.f)) { - float d = ballOut->position.x - gMinPos.x; - if (d < 0.f) { - if (ballOut->delta.x < 0) { - ballOut->delta.x *= -0.7f; - } - ballOut->position.x = gMinPos.x + 1.f; - } else { - ballOut->delta.x += min(wallForce / (d * d), 10.f); - } - } - - if (ballOut->position.y > (gMaxPos.y - 20.f)) { - float d = gMaxPos.y - ballOut->position.y; - if (d < 0.f) { - if (ballOut->delta.y > 0) { - ballOut->delta.y *= -0.7f; - } - ballOut->position.y = gMaxPos.y; - } else { - ballOut->delta.y -= min(wallForce / (d * d), 10.f); - } - } - - if (ballOut->position.y < (gMinPos.y + 20.f)) { - float d = ballOut->position.y - gMinPos.y; - if (d < 0.f) { - if (ballOut->delta.y < 0) { - ballOut->delta.y *= -0.7f; - } - ballOut->position.y = gMinPos.y + 1.f; - } else { - ballOut->delta.y += min(wallForce / (d * d * d), 10.f); - } - } - - ballOut->size = ballIn->size; - - //rsDebug("physics pos out", ballOut->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 dcdd586..0000000 --- a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/balls.rs +++ /dev/null @@ -1,83 +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_program_fragment gPFLines; -rs_mesh partMesh; - -typedef struct __attribute__((packed, aligned(4))) Point { - float2 position; - float size; -} Point_t; -Point_t *point; - -typedef struct VpConsts { - rs_matrix4x4 MVP; -} VpConsts_t; -VpConsts_t *vpConstants; - -rs_script physics_script; - -Ball_t *balls1; -Ball_t *balls2; - -static int frame = 0; - -void initParts(int w, int h) -{ - uint32_t dimX = rsAllocationGetDimX(rsGetAllocation(balls1)); - - for (uint32_t ct=0; ct < dimX; ct++) { - balls1[ct].position.x = rsRand(0.f, (float)w); - balls1[ct].position.y = rsRand(0.f, (float)h); - balls1[ct].delta.x = 0.f; - balls1[ct].delta.y = 0.f; - balls1[ct].size = 1.f; - - float r = rsRand(100.f); - if (r > 90.f) { - balls1[ct].size += pow(10.f, rsRand(0.f, 2.f)) * 0.07f; - } - } -} - - - -int root() { - rsgClearColor(0.f, 0.f, 0.f, 1.f); - - BallControl_t bc; - Ball_t *bout; - - if (frame & 1) { - bc.ain = rsGetAllocation(balls2); - bc.aout = rsGetAllocation(balls1); - bout = balls1; - } else { - bc.ain = rsGetAllocation(balls1); - bc.aout = rsGetAllocation(balls2); - bout = balls2; - } - - bc.dimX = rsAllocationGetDimX(bc.ain); - bc.dt = 1.f / 30.f; - - rsForEach(physics_script, bc.ain, bc.aout, &bc, sizeof(bc)); - - for (uint32_t ct=0; ct < bc.dimX; ct++) { - point[ct].position = bout[ct].position; - point[ct].size = 6.f /*+ bout[ct].color.g * 6.f*/ * bout[ct].size; - } - - frame++; - 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 fc886f9..0000000 --- a/tests/RenderScriptTests/Balls/src/com/example/android/rs/balls/balls.rsh +++ /dev/null @@ -1,18 +0,0 @@ - -typedef struct __attribute__((packed, aligned(4))) Ball { - float2 delta; - float2 position; - //float3 color; - float size; - //int arcID; - //float arcStr; -} Ball_t; -Ball_t *balls; - - -typedef struct BallControl { - uint32_t dimX; - rs_allocation ain; - rs_allocation aout; - float dt; -} BallControl_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/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/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/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/FBOTest/Android.mk b/tests/RenderScriptTests/FBOTest/Android.mk index 434d592..7a578d9 100644 --- a/tests/RenderScriptTests/FBOTest/Android.mk +++ b/tests/RenderScriptTests/FBOTest/Android.mk @@ -23,4 +23,6 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-fil LOCAL_PACKAGE_NAME := FBOTest +LOCAL_SDK_VERSION := 17 + include $(BUILD_PACKAGE) diff --git a/tests/RenderScriptTests/Fountain/Android.mk b/tests/RenderScriptTests/Fountain/Android.mk index 4a6560b..0517aef 100644 --- a/tests/RenderScriptTests/Fountain/Android.mk +++ b/tests/RenderScriptTests/Fountain/Android.mk @@ -21,8 +21,7 @@ LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src) -# TODO: build fails with this set -# LOCAL_SDK_VERSION := current +LOCAL_SDK_VERSION := 17 LOCAL_PACKAGE_NAME := RsFountain diff --git a/tests/RenderScriptTests/HelloWorld/Android.mk b/tests/RenderScriptTests/HelloWorld/Android.mk index 54824f4..c1c08ec 100644 --- a/tests/RenderScriptTests/HelloWorld/Android.mk +++ b/tests/RenderScriptTests/HelloWorld/Android.mk @@ -23,6 +23,6 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-fil LOCAL_PACKAGE_NAME := RsHelloWorld -LOCAL_SDK_VERSION := current +LOCAL_SDK_VERSION := 17 include $(BUILD_PACKAGE) 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 Binary files differdeleted file mode 100644 index 05d3ee2..0000000 --- a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067.jpg +++ /dev/null diff --git a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067b.jpg b/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067b.jpg Binary files differdeleted file mode 100644 index aed0781..0000000 --- a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067b.jpg +++ /dev/null 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/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/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/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/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/Fisheye.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Fisheye.java deleted file mode 100644 index 81868b1..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 ebe4d73..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java +++ /dev/null @@ -1,419 +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.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.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"; - - /** - * Define enum type for test names - */ - public enum TestName { - 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"); - - 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; - - 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; - } - - mTest.createBaseTest(this, mBitmapIn, mBitmapIn2); - 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 = loadBitmap(R.drawable.img1600x1067); - - 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"); - - 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 copyBitmap(BitmapFactory.decodeResource(getResources(), resource, options)); - } - - private static Bitmap copyBitmap(Bitmap source) { - Bitmap b = Bitmap.createBitmap(source.getWidth(), source.getHeight(), source.getConfig()); - Canvas c = new Canvas(b); - c.drawBitmap(source, 0, 0, null); - source.recycle(); - return b; - } - - // 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/src/com/android/rs/image/ImageProcessingTest.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTest.java deleted file mode 100644 index 1b38e1f..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTest.java +++ /dev/null @@ -1,316 +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 - @LargeTest - public void testIntrinsicsBlend() { - TestAction ta = new TestAction(TestName.INTRINSICS_BLEND); - runTest(ta, TestName.INTRINSICS_BLEND.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/TestBase.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java deleted file mode 100644 index bb3f2f3..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java +++ /dev/null @@ -1,140 +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; - - // 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) { - act = ipact; - mRS = RenderScript.create(act); - mInPixelsAllocation = Allocation.createFromBitmap(mRS, b, - Allocation.MipmapControl.MIPMAP_NONE, - Allocation.USAGE_SCRIPT); - mInPixelsAllocation2 = Allocation.createFromBitmap(mRS, b2, - Allocation.MipmapControl.MIPMAP_NONE, - Allocation.USAGE_SCRIPT); - mOutPixelsAllocation = Allocation.createFromBitmap(mRS, b, - Allocation.MipmapControl.MIPMAP_NONE, - Allocation.USAGE_SCRIPT); - createTest(act.getResources()); - } - - // Must override - public void createTest(android.content.res.Resources res) { - android.util.Log.e("img", "implement createTest"); - } - - // Must override - public void runTest() { - } - - public void finish() { - mRS.finish(); - } - - public void destroy() { - mRS.destroy(); - mRS = 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/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/blend.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/blend.rs deleted file mode 100644 index 87b56f7..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/blend.rs +++ /dev/null @@ -1,24 +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.android.rs.image) - -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/colormatrix.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.fs deleted file mode 100644 index ba8711b..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.fs +++ /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. - */ - -#pragma version(1) -#pragma rs java_package_name(com.android.rs.image) -#pragma rs_fp_relaxed - - -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/convolve3x3.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.fs deleted file mode 100644 index 772503f..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.fs +++ /dev/null @@ -1,67 +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.image) -#pragma rs_fp_relaxed - -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 a916bfb..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.fs +++ /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. - */ - -#pragma version(1) -#pragma rs java_package_name(com.android.rs.image) -#pragma rs_fp_relaxed - -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 5f03483..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.fs +++ /dev/null @@ -1,24 +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.image) - -uchar4 __attribute__((kernel)) root(uchar4 v_in) { - return v_in; -} - - 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 1ea37db..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_full.rs +++ /dev/null @@ -1,21 +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.image) - -#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 3e76368..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.fs +++ /dev/null @@ -1,22 +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.image) -#pragma rs_fp_relaxed - -#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 20f27e2..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_full.rs +++ /dev/null @@ -1,21 +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.image) - -#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 dc3ffcb..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.fs +++ /dev/null @@ -1,22 +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.image) -#pragma rs_fp_relaxed - -#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 4ae095d..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.fs +++ /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. - */ - -#pragma version(1) -#pragma rs java_package_name(com.android.rs.image) -#pragma rs_fp_relaxed - -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 90ba058..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.fs +++ /dev/null @@ -1,30 +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.image) -#pragma rs_fp_relaxed - -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); -} - - 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 da6a291..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_full.rs +++ /dev/null @@ -1,21 +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.image) - -#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 b115445..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.fs +++ /dev/null @@ -1,22 +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.image) -#pragma rs_fp_relaxed - -#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 ac2061b..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs +++ /dev/null @@ -1,56 +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.android.rs.image) - -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/threshold.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.fs deleted file mode 100644 index 86e155a..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.fs +++ /dev/null @@ -1,104 +0,0 @@ -#pragma version(1) -#pragma rs java_package_name(com.android.rs.image) -#pragma rs_fp_relaxed - - -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/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 05a5929..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh +++ /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. - */ - -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; - // TODO: add half_exp once implemented - 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/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 c83c6e1..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_full.rs +++ /dev/null @@ -1,21 +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.image) - -#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 9120612..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.fs +++ /dev/null @@ -1,22 +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.image) -#pragma rs_fp_relaxed - -#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 64942d9..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_full.rs +++ /dev/null @@ -1,21 +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.image) - -#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 8e47ea9..0000000 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.fs +++ /dev/null @@ -1,22 +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.image) -#pragma rs_fp_relaxed - -#include "vignette.rsh" - diff --git a/tests/RenderScriptTests/ImageProcessing2/Android.mk b/tests/RenderScriptTests/ImageProcessing2/Android.mk deleted file mode 100644 index e05a518..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/Android.mk +++ /dev/null @@ -1,39 +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 := 17 -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 Binary files differdeleted file mode 100644 index 856eeff..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/city.png +++ /dev/null diff --git a/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067.jpg b/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067.jpg Binary files differdeleted file mode 100644 index 05d3ee2..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067.jpg +++ /dev/null diff --git a/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067b.jpg b/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067b.jpg Binary files differdeleted file mode 100644 index aed0781..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/res/drawable-nodpi/img1600x1067b.jpg +++ /dev/null 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/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/Blend.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Blend.java deleted file mode 100644 index ac02101..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Blend.java +++ /dev/null @@ -1,168 +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; - 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/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/Convolve3x3.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Convolve3x3.java deleted file mode 100644 index 7635e13..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_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/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/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 2d85ae7..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Greyscale.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 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 227518f..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ImageProcessingActivity2.java +++ /dev/null @@ -1,413 +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"; - private final String RESULT_FILE = "image_processing_result.csv"; - - Bitmap mBitmapIn; - Bitmap mBitmapIn2; - Bitmap mBitmapOut; - String mTestNames[]; - - 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; - - 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(int testID) { - if (mTest != null) { - mTest.destroy(); - } - switch(testID) { - case 0: - mTest = new LevelsV4(false, false); - break; - case 1: - mTest = new LevelsV4(false, true); - break; - case 2: - mTest = new LevelsV4(true, false); - break; - case 3: - mTest = new LevelsV4(true, true); - break; - case 4: - mTest = new Blur25(false); - break; - case 5: - mTest = new Blur25(true); - break; - case 6: - mTest = new Greyscale(); - break; - case 7: - mTest = new Grain(); - break; - case 8: - mTest = new Fisheye(false, false); - break; - case 9: - mTest = new Fisheye(false, true); - break; - case 10: - mTest = new Fisheye(true, false); - break; - case 11: - mTest = new Fisheye(true, true); - break; - case 12: - mTest = new Vignette(false, false); - break; - case 13: - mTest = new Vignette(false, true); - break; - case 14: - mTest = new Vignette(true, false); - break; - case 15: - mTest = new Vignette(true, true); - break; - case 16: - mTest = new GroupTest(false); - break; - case 17: - mTest = new GroupTest(true); - break; - case 18: - mTest = new Convolve3x3(false); - break; - case 19: - mTest = new Convolve3x3(true); - break; - case 20: - mTest = new ColorMatrix(false, false); - break; - case 21: - mTest = new ColorMatrix(true, false); - break; - case 22: - mTest = new ColorMatrix(true, true); - break; - case 23: - mTest = new Copy(); - break; - case 24: - mTest = new CrossProcess(); - break; - case 25: - mTest = new Convolve5x5(false); - break; - case 26: - mTest = new Convolve5x5(true); - break; - case 27: - mTest = new Mandelbrot(); - break; - case 28: - mTest = new Blend(); - break; - } - - mTest.createBaseTest(this, mBitmapIn, mBitmapIn2); - setupBars(); - - mTest.runTest(); - updateDisplay(); - mBenchmarkResult.setText("Result: not run"); - } - - void setupTests() { - mTestNames = new String[29]; - mTestNames[0] = "Levels Vec3 Relaxed"; - mTestNames[1] = "Levels Vec4 Relaxed"; - mTestNames[2] = "Levels Vec3 Full"; - mTestNames[3] = "Levels Vec4 Full"; - mTestNames[4] = "Blur radius 25"; - mTestNames[5] = "Intrinsic Blur radius 25"; - mTestNames[6] = "Greyscale"; - mTestNames[7] = "Grain"; - mTestNames[8] = "Fisheye Full"; - mTestNames[9] = "Fisheye Relaxed"; - mTestNames[10] = "Fisheye Approximate Full"; - mTestNames[11] = "Fisheye Approximate Relaxed"; - mTestNames[12] = "Vignette Full"; - mTestNames[13] = "Vignette Relaxed"; - mTestNames[14] = "Vignette Approximate Full"; - mTestNames[15] = "Vignette Approximate Relaxed"; - mTestNames[16] = "Group Test (emulated)"; - mTestNames[17] = "Group Test (native)"; - mTestNames[18] = "Convolve 3x3"; - mTestNames[19] = "Intrinsics Convolve 3x3"; - mTestNames[20] = "ColorMatrix"; - mTestNames[21] = "Intrinsics ColorMatrix"; - mTestNames[22] = "Intrinsics ColorMatrix Grey"; - mTestNames[23] = "Copy"; - mTestNames[24] = "CrossProcess (using LUT)"; - mTestNames[25] = "Convolve 5x5"; - mTestNames[26] = "Intrinsics Convolve 5x5"; - mTestNames[27] = "Mandelbrot"; - mTestNames[28] = "Intrinsics Blend"; - - mTestSpinner.setAdapter(new ArrayAdapter<String>( - this, R.layout.spinner_layout, mTestNames)); - } - - private AdapterView.OnItemSelectedListener mTestSpinnerListener = - new AdapterView.OnItemSelectedListener() { - public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { - changeTest(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 = loadBitmap(R.drawable.img1600x1067); - - 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"); - - setupTests(); - changeTest(0); - } - - - private Bitmap loadBitmap(int resource) { - final BitmapFactory.Options options = new BitmapFactory.Options(); - options.inPreferredConfig = Bitmap.Config.ARGB_8888; - return copyBitmap(BitmapFactory.decodeResource(getResources(), resource, options)); - } - - private static Bitmap copyBitmap(Bitmap source) { - Bitmap b = Bitmap.createBitmap(source.getWidth(), source.getHeight(), source.getConfig()); - Canvas c = new Canvas(b); - c.drawBitmap(source, 0, 0, null); - source.recycle(); - return b; - } - - // 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 (int i = 0; i < mTestNames.length; i++ ) { - changeTest(i); - float t = getBenchmark(); - String s = new String("" + mTestNames[i] + ", " + 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(0); - } - - // 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 556d797..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Mandelbrot.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.support.v8.renderscript.*; -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/TestBase.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/TestBase.java deleted file mode 100644 index 9df2eff..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/TestBase.java +++ /dev/null @@ -1,134 +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) { - act = ipact; - mRS = RenderScript.create(act); - mInPixelsAllocation = Allocation.createFromBitmap(mRS, b, - Allocation.MipmapControl.MIPMAP_NONE, - Allocation.USAGE_SCRIPT); - mInPixelsAllocation2 = Allocation.createFromBitmap(mRS, b2, - Allocation.MipmapControl.MIPMAP_NONE, - Allocation.USAGE_SCRIPT); - mOutPixelsAllocation = Allocation.createFromBitmap(mRS, b, - Allocation.MipmapControl.MIPMAP_NONE, - Allocation.USAGE_SCRIPT); - createTest(act.getResources()); - } - - // Must override - public void createTest(android.content.res.Resources res) { - android.util.Log.e("img", "implement createTest"); - } - - // Must override - public void runTest() { - } - - public void finish() { - mRS.finish(); - } - - public void destroy() { - mRS.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/Vignette.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Vignette.java deleted file mode 100644 index 8618d5a..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/Vignette.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.image2; - -import android.support.v8.renderscript.*; -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/blend.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/blend.rs deleted file mode 100644 index 4d90725..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/blend.rs +++ /dev/null @@ -1,24 +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.android.rs.image2) - -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/colormatrix.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/colormatrix.rs deleted file mode 100644 index e93bef3..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/colormatrix.rs +++ /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. - */ - -#pragma version(1) -#pragma rs java_package_name(com.android.rs.image2) -#pragma rs_fp_relaxed - - -static rs_matrix4x4 Mat; - -void init() { - rsMatrixLoadIdentity(&Mat); -} - -void setMatrix(rs_matrix4x4 m) { - Mat = m; -} - -void root(const uchar4 *in, uchar4 *out) { - float4 f = convert_float4(*in); - f = rsMatrixMultiply(&Mat, f); - f = clamp(f, 0.f, 255.f); - *out = convert_uchar4(f); -} - diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/convolve3x3.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/convolve3x3.rs deleted file mode 100644 index b55190c..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/convolve3x3.rs +++ /dev/null @@ -1,67 +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.image2) -#pragma rs_fp_relaxed - -int32_t gWidth; -int32_t gHeight; -rs_allocation gIn; - -float gCoeffs[9]; - -void root(uchar4 *out, uint32_t x, uint32_t y) { - uint32_t x1 = min((int32_t)x+1, gWidth); - uint32_t x2 = max((int32_t)x-1, 0); - uint32_t y1 = min((int32_t)y+1, gHeight); - uint32_t y2 = max((int32_t)y-1, 0); - - float4 p00 = convert_float4(((uchar4 *)rsGetElementAt(gIn, x1, y1))[0]); - float4 p01 = convert_float4(((uchar4 *)rsGetElementAt(gIn, x, y1))[0]); - float4 p02 = convert_float4(((uchar4 *)rsGetElementAt(gIn, x2, y1))[0]); - float4 p10 = convert_float4(((uchar4 *)rsGetElementAt(gIn, x1, y))[0]); - float4 p11 = convert_float4(((uchar4 *)rsGetElementAt(gIn, x, y))[0]); - float4 p12 = convert_float4(((uchar4 *)rsGetElementAt(gIn, x2, y))[0]); - float4 p20 = convert_float4(((uchar4 *)rsGetElementAt(gIn, x1, y2))[0]); - float4 p21 = convert_float4(((uchar4 *)rsGetElementAt(gIn, x, y2))[0]); - float4 p22 = convert_float4(((uchar4 *)rsGetElementAt(gIn, x2, y2))[0]); - 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); - *out = convert_uchar4(p20); -} - - diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/convolve5x5.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/convolve5x5.rs deleted file mode 100644 index b110b88..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/convolve5x5.rs +++ /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. - */ - -#pragma version(1) -#pragma rs java_package_name(com.android.rs.image2) -#pragma rs_fp_relaxed - -int32_t gWidth; -int32_t gHeight; -rs_allocation gIn; - -float gCoeffs[25]; - -void root(uchar4 *out, 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); - *out = convert_uchar4(p0); -} - - diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/copy.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/copy.rs deleted file mode 100644 index 31e4241..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/copy.rs +++ /dev/null @@ -1,24 +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.image2) - -void root(const uchar4 *v_in, uchar4 *v_out) { - *v_out = *v_in; -} - - 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 3809912..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.0 + 0.75; - - 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.25 * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y); - const float bound = sqrt(bound2); - const float radius = 1.15 * bound; - radius2 = radius*radius; - const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2)); - factor = bound / max_radian; -} - -void root(uchar4 *out, 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); - *out = 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 08b4126..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.0 + 0.75; - - 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.25 * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y); - const float bound = sqrt(bound2); - const float radius = 1.15 * bound; - radius2 = radius*radius; - const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2)); - factor = bound / max_radian; -} - -void root(uchar4 *out, 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); - *out = 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 cce42f9..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx_full.rs +++ /dev/null @@ -1,21 +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.image2) - -#include "fisheye_approx.rsh" - diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx_relaxed.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx_relaxed.rs deleted file mode 100644 index 64d27ed..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_approx_relaxed.rs +++ /dev/null @@ -1,22 +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.image2) -#pragma rs_fp_relaxed - -#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 e42df13..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_full.rs +++ /dev/null @@ -1,21 +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.image2) - -#include "fisheye.rsh" - diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_relaxed.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_relaxed.rs deleted file mode 100644 index 990310b..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/fisheye_relaxed.rs +++ /dev/null @@ -1,22 +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.image2) -#pragma rs_fp_relaxed - -#include "fisheye.rsh" - diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/grain.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/grain.rs deleted file mode 100644 index 44320a5..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/grain.rs +++ /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. - */ - -#pragma version(1) -#pragma rs java_package_name(com.android.rs.image2) -#pragma rs_fp_relaxed - -void genRand(uchar *out) { - *out = (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; -void blend9(uchar *out, 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); - *out = (uchar)p20; -} - -float gNoiseStrength; - -rs_allocation gNoise; -void root(const uchar4 *in, uchar4 *out, 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; - *out = p; -} diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/greyscale.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/greyscale.rs deleted file mode 100644 index b5abf3f..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/greyscale.rs +++ /dev/null @@ -1,30 +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.image2) -#pragma rs_fp_relaxed - -const static float3 gMonoMult = {0.299f, 0.587f, 0.114f}; - -void root(const uchar4 *v_in, uchar4 *v_out) { - float4 f4 = rsUnpackColor8888(*v_in); - - float3 mono = dot(f4.rgb, gMonoMult); - *v_out = rsPackColorTo8888(mono); -} - - 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 7c5d930..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels.rsh +++ /dev/null @@ -1,44 +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; - -void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { - float3 pixel = convert_float4(in[0]).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; -} - -void root4(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { - float4 pixel = convert_float4(in[0]); - 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); - out->xyzw = 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 a4aa388..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels_full.rs +++ /dev/null @@ -1,21 +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.image2) - -#include "levels.rsh" - diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels_relaxed.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels_relaxed.rs deleted file mode 100644 index ffdcfe3..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/levels_relaxed.rs +++ /dev/null @@ -1,22 +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.image2) -#pragma rs_fp_relaxed - -#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 55e5304..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/mandelbrot.rs +++ /dev/null @@ -1,56 +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.android.rs.image2) - -uint32_t gMaxIteration = 500; -uint32_t gDimX = 1024; -uint32_t gDimY = 1024; - -float lowerBoundX = -2.f; -float lowerBoundY = -2.f; -float scaleFactor = 4.f; - -void root(uchar4 *v_out, 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 - *v_out = (uchar4){0, 0, 0, 0xff}; - } else { - float mi3 = gMaxIteration / 3.; - if (iter <= (gMaxIteration / 3)) - *v_out = (uchar4){0xff * (iter / mi3), 0, 0, 0xff}; - else if (iter <= (((gMaxIteration / 3) * 2))) - *v_out = (uchar4){0xff - (0xff * ((iter - mi3) / mi3)), - (0xff * ((iter - mi3) / mi3)), 0, 0xff}; - else - *v_out = (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/threshold.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/threshold.rs deleted file mode 100644 index 9ef4898..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/threshold.rs +++ /dev/null @@ -1,106 +0,0 @@ -#pragma version(1) -#pragma rs java_package_name(com.android.rs.image2) -#pragma rs_fp_relaxed - - -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; - } -} - -void copyIn(const uchar4 *in, float4 *out) { - *out = convert_float4(*in); -} - -void vert(uchar4 *out, uint32_t x, uint32_t y) { - float3 blurredPixel = 0; - const float *gPtr = gaussian; - if ((y > radius) && (y < (height - radius))) { - for (int r = -radius; r <= radius; r ++) { - const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel2, x, y + r); - blurredPixel += i->xyz * gPtr[0]; - gPtr++; - } - } else { - for (int r = -radius; r <= radius; r ++) { - int validH = rsClamp((int)y + r, (int)0, (int)(height - 1)); - const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel2, x, validH); - blurredPixel += i->xyz * gPtr[0]; - gPtr++; - } - } - - out->xyz = convert_uchar3(clamp(blurredPixel, 0.f, 255.f)); - out->w = 0xff; -} - -void horz(float4 *out, uint32_t x, uint32_t y) { - float3 blurredPixel = 0; - const float *gPtr = gaussian; - if ((x > radius) && (x < (width - radius))) { - for (int r = -radius; r <= radius; r ++) { - const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel1, x + r, y); - blurredPixel += i->xyz * gPtr[0]; - gPtr++; - } - } 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)); - const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel1, validX, y); - blurredPixel += i->xyz * gPtr[0]; - gPtr++; - } - } - - out->xyz = blurredPixel; -} - 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 a1e4ae5..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.5 * 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.7*sqrt(desired_scale) - 1.3; - sloped_neg_range = exp(neg_range * desired_slope); - - shade = desired_shade; - opp_shade = 1.f - desired_shade; -} - -void root(const uchar4 *in, uchar4 *out, 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.0 + sloped_neg_range * exp(sloped_dist_ratio) ); - float4 fout; - fout.rgb = fin.rgb * lumen; - fout.w = fin.w; - *out = 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 7f7bdcf..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx.rsh +++ /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. - */ - -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.5 * 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.7*sqrt(desired_scale) - 1.3; - sloped_neg_range = exp(neg_range * desired_slope); - - shade = desired_shade; - opp_shade = 1.f - desired_shade; -} - -void root(const uchar4 *in, uchar4 *out, 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; - // TODO: add half_exp once implemented - 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; - *out = 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 3612509..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx_full.rs +++ /dev/null @@ -1,21 +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.image2) - -#include "vignette_approx.rsh" - diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx_relaxed.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx_relaxed.rs deleted file mode 100644 index b714e9b..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_approx_relaxed.rs +++ /dev/null @@ -1,22 +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.image2) -#pragma rs_fp_relaxed - -#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 5fc2dda..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_full.rs +++ /dev/null @@ -1,21 +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.image2) - -#include "vignette.rsh" - diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_relaxed.rs b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_relaxed.rs deleted file mode 100644 index 430b685..0000000 --- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/vignette_relaxed.rs +++ /dev/null @@ -1,22 +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.image2) -#pragma rs_fp_relaxed - -#include "vignette.rsh" - 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 Binary files differdeleted file mode 100644 index 856eeff..0000000 --- a/tests/RenderScriptTests/LivePreview/res/drawable-nodpi/city.png +++ /dev/null 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 c7dcca5..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" > - - <ImageView - 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 89eec2c..0000000 --- a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/CameraPreviewActivity.java +++ /dev/null @@ -1,379 +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.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 ImageView 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 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); - mFormatView = (ImageView) 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); - } - - @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(0); - mResolutionSpinner.setSelection(0); - - 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); - - 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, mCallbackBitmap); - - 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) { - mFormatView.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 (mCallbackBitmap == null || - mPreviewSize.width != mCallbackBitmap.getWidth() || - mPreviewSize.height != mCallbackBitmap.getHeight() ) { - mCallbackBitmap = - Bitmap.createBitmap( - mPreviewSize.width, mPreviewSize.height, - Bitmap.Config.ARGB_8888); - mFilterYuv = new RsYuv(mRS, getResources(), mPreviewSize.width, mPreviewSize.height); - mFormatView.setImageBitmap(mCallbackBitmap); - } - - - mFormatView.invalidate(); - - mCamera.addCallbackBuffer(data); - 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 978ae12..0000000 --- a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/RsYuv.java +++ /dev/null @@ -1,78 +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.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 -{ - private int mHeight; - private int mWidth; - private RenderScript mRS; - private Allocation mAllocationOut; - private Allocation mAllocationIn; - private ScriptC_yuv mScript; - private ScriptIntrinsicYuvToRGB mYuv; - - RsYuv(RenderScript rs, Resources res, int width, int height) { - mHeight = height; - mWidth = width; - mRS = rs; - mScript = new ScriptC_yuv(mRS, res, R.raw.yuv); - mScript.invoke_setSize(mWidth, mHeight); - - mYuv = ScriptIntrinsicYuvToRGB.create(rs, Element.RGBA_8888(mRS)); - - Type.Builder tb = new Type.Builder(mRS, Element.RGBA_8888(mRS)); - tb.setX(mWidth); - tb.setY(mHeight); - - mAllocationOut = Allocation.createTyped(rs, tb.create()); - mAllocationIn = Allocation.createSized(rs, Element.U8(mRS), (mHeight * mWidth) + - ((mHeight / 2) * (mWidth / 2) * 2)); - - mYuv.setInput(mAllocationIn); - } - - private long mTiming[] = new long[50]; - private int mTimingSlot = 0; - - void execute(byte[] yuv, Bitmap b) { - mAllocationIn.copyFrom(yuv); - mYuv.forEach(mAllocationOut); - mScript.forEach_root(mAllocationOut, mAllocationOut); - mAllocationOut.copyTo(b); - } - -} - 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 884812d..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/MiscSamples/Android.mk b/tests/RenderScriptTests/MiscSamples/Android.mk index bdff46a..ee3567b 100644 --- a/tests/RenderScriptTests/MiscSamples/Android.mk +++ b/tests/RenderScriptTests/MiscSamples/Android.mk @@ -23,6 +23,6 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-fil LOCAL_PACKAGE_NAME := RsMiscSamples -LOCAL_SDK_VERSION := current +LOCAL_SDK_VERSION := 17 include $(BUILD_PACKAGE) diff --git a/tests/RenderScriptTests/ModelViewer/Android.mk b/tests/RenderScriptTests/ModelViewer/Android.mk index 18ceac5..86724cf 100644 --- a/tests/RenderScriptTests/ModelViewer/Android.mk +++ b/tests/RenderScriptTests/ModelViewer/Android.mk @@ -22,6 +22,8 @@ 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_SDK_VERSION := 17 + LOCAL_PACKAGE_NAME := ModelViewer include $(BUILD_PACKAGE) diff --git a/tests/RenderScriptTests/PerfTest/Android.mk b/tests/RenderScriptTests/PerfTest/Android.mk index 0d1e7d2..e9ee771 100644 --- a/tests/RenderScriptTests/PerfTest/Android.mk +++ b/tests/RenderScriptTests/PerfTest/Android.mk @@ -24,6 +24,8 @@ 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_SDK_VERSION := 17 + LOCAL_PACKAGE_NAME := PerfTest 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 Binary files differdeleted file mode 100644 index 27c4618..0000000 --- a/tests/RenderScriptTests/SampleTest/res/drawable-nodpi/city.png +++ /dev/null diff --git a/tests/RenderScriptTests/SampleTest/res/drawable-nodpi/twobytwo.png b/tests/RenderScriptTests/SampleTest/res/drawable-nodpi/twobytwo.png Binary files differdeleted file mode 100644 index 98cf963..0000000 --- a/tests/RenderScriptTests/SampleTest/res/drawable-nodpi/twobytwo.png +++ /dev/null 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/SceneGraph/Android.mk b/tests/RenderScriptTests/SceneGraph/Android.mk index 163a95d..6047305 100644 --- a/tests/RenderScriptTests/SceneGraph/Android.mk +++ b/tests/RenderScriptTests/SceneGraph/Android.mk @@ -21,6 +21,8 @@ LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src) +LOCAL_SDK_VERSION := 17 + LOCAL_PACKAGE_NAME := SceneGraphTest include $(BUILD_PACKAGE) diff --git a/tests/RenderScriptTests/ShadersTest/Android.mk b/tests/RenderScriptTests/ShadersTest/Android.mk index 0912591..fb6356e 100644 --- a/tests/RenderScriptTests/ShadersTest/Android.mk +++ b/tests/RenderScriptTests/ShadersTest/Android.mk @@ -21,6 +21,8 @@ LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src) +LOCAL_SDK_VERSION := 17 + LOCAL_PACKAGE_NAME := ShadersTest include $(BUILD_PACKAGE) diff --git a/tests/RenderScriptTests/SurfaceTexture/Android.mk b/tests/RenderScriptTests/SurfaceTexture/Android.mk deleted file mode 100644 index d5262ee..0000000 --- a/tests/RenderScriptTests/SurfaceTexture/Android.mk +++ /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. -# - -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) - -# TODO: build fails with this set -# LOCAL_SDK_VERSION := current - -LOCAL_PACKAGE_NAME := RsSurfaceTextureOpaque - -include $(BUILD_PACKAGE) diff --git a/tests/RenderScriptTests/SurfaceTexture/AndroidManifest.xml b/tests/RenderScriptTests/SurfaceTexture/AndroidManifest.xml deleted file mode 100644 index 8aaa239..0000000 --- a/tests/RenderScriptTests/SurfaceTexture/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.example.android.rs.sto"> - <uses-sdk android:minSdkVersion="14" /> - <uses-permission android:name="android.permission.CAMERA" /> - <uses-feature android:name="android.hardware.camera" /> - <uses-feature android:name="android.hardware.camera.autofocus" /> - - <application - android:label="RsSurfaceTextureOpaque" - android:hardwareAccelerated="true" - android:icon="@drawable/test_pattern"> - - <activity android:name="SurfaceTextureOpaque"> - <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/SurfaceTexture/res/drawable/test_pattern.png b/tests/RenderScriptTests/SurfaceTexture/res/drawable/test_pattern.png Binary files differdeleted file mode 100644 index e7d1455..0000000 --- a/tests/RenderScriptTests/SurfaceTexture/res/drawable/test_pattern.png +++ /dev/null diff --git a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/CameraCapture.java b/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/CameraCapture.java deleted file mode 100644 index afdab41..0000000 --- a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/CameraCapture.java +++ /dev/null @@ -1,234 +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.sto; - -import android.graphics.SurfaceTexture; -import android.hardware.Camera; -import android.os.SystemClock; -import android.util.Log; - -import java.io.IOException; -import java.util.List; - -public class CameraCapture { - - public interface CameraFrameListener { - public void onNewCameraFrame(); - } - - static final int FRAMES_PER_SEC = 30; - - private Camera mCamera; - private SurfaceTexture mSurfaceTexture; - - private int mProgram; - - private int mCameraTransformHandle; - private int mTexSamplerHandle; - private int mTexCoordHandle; - private int mPosCoordHandle; - - private float[] mCameraTransform = new float[16]; - - private int mCameraId = 0; - private int mWidth; - private int mHeight; - - private long mStartCaptureTime = 0; - - private boolean mNewFrameAvailable = false; - private boolean mIsOpen = false; - - private CameraFrameListener mListener; - - public synchronized void beginCapture(int cameraId, int width, int height, - SurfaceTexture st) { - mCameraId = cameraId; - mSurfaceTexture = st; - - // Open the camera - openCamera(width, height); - - // Start the camera - mStartCaptureTime = SystemClock.elapsedRealtime(); - mCamera.startPreview(); - mIsOpen = true; - } - - public void getCurrentFrame() { - if (checkNewFrame()) { - if (mStartCaptureTime > 0 && SystemClock.elapsedRealtime() - mStartCaptureTime > 2000) { - // Lock white-balance and exposure for effects - Log.i("CC", "Locking white-balance and exposure!"); - Camera.Parameters params = mCamera.getParameters(); - params.setAutoWhiteBalanceLock(true); - params.setAutoExposureLock(true); - //mCamera.setParameters(params); - mStartCaptureTime = 0; - } - - mSurfaceTexture.updateTexImage(); - mSurfaceTexture.getTransformMatrix(mCameraTransform); - - // display it here - } - } - - public synchronized boolean hasNewFrame() { - return mNewFrameAvailable; - } - - public synchronized void endCapture() { - mIsOpen = false; - if (mCamera != null) { - mCamera.release(); - mCamera = null; - mSurfaceTexture = null; - } - } - - public synchronized boolean isOpen() { - return mIsOpen; - } - - public int getWidth() { - return mWidth; - } - - public int getHeight() { - return mHeight; - } - - public void setCameraFrameListener(CameraFrameListener listener) { - mListener = listener; - } - - private void openCamera(int width, int height) { - // Setup camera - mCamera = Camera.open(mCameraId); - mCamera.setParameters(calcCameraParameters(width, height)); - - // Create camera surface texture - try { - mCamera.setPreviewTexture(mSurfaceTexture); - } catch (IOException e) { - throw new RuntimeException("Could not bind camera surface texture: " + - e.getMessage() + "!"); - } - - // Connect SurfaceTexture to callback - mSurfaceTexture.setOnFrameAvailableListener(onCameraFrameAvailableListener); - } - - private Camera.Parameters calcCameraParameters(int width, int height) { - Camera.Parameters params = mCamera.getParameters(); - params.setPreviewSize(mWidth, mHeight); - - // Find closest size - int closestSize[] = findClosestSize(width, height, params); - mWidth = closestSize[0]; - mHeight = closestSize[1]; - params.setPreviewSize(mWidth, mHeight); - - // Find closest FPS - int closestRange[] = findClosestFpsRange(FRAMES_PER_SEC, params); - - params.setPreviewFpsRange(closestRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX], - closestRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]); - - return params; - } - - private int[] findClosestSize(int width, int height, Camera.Parameters parameters) { - List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes(); - int closestWidth = -1; - int closestHeight = -1; - int smallestWidth = previewSizes.get(0).width; - int smallestHeight = previewSizes.get(0).height; - for (Camera.Size size : previewSizes) { - // Best match defined as not being larger in either dimension than - // the requested size, but as close as possible. The below isn't a - // stable selection (reording the size list can give different - // results), but since this is a fallback nicety, that's acceptable. - if ( size.width <= width && - size.height <= height && - size.width >= closestWidth && - size.height >= closestHeight) { - closestWidth = size.width; - closestHeight = size.height; - } - if ( size.width < smallestWidth && - size.height < smallestHeight) { - smallestWidth = size.width; - smallestHeight = size.height; - } - } - if (closestWidth == -1) { - // Requested size is smaller than any listed size; match with smallest possible - closestWidth = smallestWidth; - closestHeight = smallestHeight; - } - int[] closestSize = {closestWidth, closestHeight}; - return closestSize; - } - - private int[] findClosestFpsRange(int fps, Camera.Parameters params) { - List<int[]> supportedFpsRanges = params.getSupportedPreviewFpsRange(); - int[] closestRange = supportedFpsRanges.get(0); - int fpsk = fps * 1000; - int minDiff = 1000000; - for (int[] range : supportedFpsRanges) { - int low = range[Camera.Parameters.PREVIEW_FPS_MIN_INDEX]; - int high = range[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]; - if (low <= fpsk && high >= fpsk) { - int diff = (fpsk - low) + (high - fpsk); - if (diff < minDiff) { - closestRange = range; - minDiff = diff; - } - } - } - Log.i("CC", "Found closest range: " - + closestRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX] + " - " - + closestRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]); - return closestRange; - } - - private synchronized void signalNewFrame() { - mNewFrameAvailable = true; - if (mListener != null) { - mListener.onNewCameraFrame(); - } - } - - private synchronized boolean checkNewFrame() { - if (mNewFrameAvailable) { - mNewFrameAvailable = false; - return true; - } - return false; - } - - private SurfaceTexture.OnFrameAvailableListener onCameraFrameAvailableListener = - new SurfaceTexture.OnFrameAvailableListener() { - @Override - public void onFrameAvailable(SurfaceTexture surfaceTexture) { - signalNewFrame(); - } - }; -} diff --git a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaque.java b/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaque.java deleted file mode 100644 index a51edaa..0000000 --- a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaque.java +++ /dev/null @@ -1,71 +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.sto; - -import android.app.Activity; -import android.os.Bundle; -import android.provider.Settings.System; -import android.util.Log; -import android.view.View; -import android.graphics.SurfaceTexture; - -import java.lang.Runtime; - -public class SurfaceTextureOpaque extends Activity { - private SurfaceTextureOpaqueView mView; - CameraCapture mCC; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - mView = new SurfaceTextureOpaqueView(this); - setContentView(mView); - } - - @Override - protected void onResume() { - super.onResume(); - mView.resume(); - startCamera(); - } - - @Override - protected void onPause() { - super.onPause(); - mView.pause(); - mCC.endCapture(); - } - - cfl mCFL; - public void startCamera() { - mCC = new CameraCapture(); - mCFL = new cfl(); - - mCC.setCameraFrameListener(mCFL); - - mCC.beginCapture(1, 640, 480, mView.getST()); - } - - public class cfl implements CameraCapture.CameraFrameListener { - public void onNewCameraFrame() { - mView.mRender.newFrame(); - } - } - -} - diff --git a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueRS.java b/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueRS.java deleted file mode 100644 index b638b7d..0000000 --- a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueRS.java +++ /dev/null @@ -1,83 +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.sto; - -import android.content.res.Resources; -import android.renderscript.*; -import android.graphics.SurfaceTexture; -import android.util.Log; - - -public class SurfaceTextureOpaqueRS { - static final private int NUM_CAMERA_PREVIEW_BUFFERS = 2; - - public SurfaceTextureOpaqueRS() { - } - - private Resources mRes; - private RenderScriptGL mRS; - private ScriptC_sto mScript; - private SurfaceTexture mST; - private Allocation mSto; - private Allocation mSto2; - private Allocation mRto; - private ProgramFragment mPF; - - public void init(RenderScriptGL rs, Resources res) { - mRS = rs; - mRes = res; - - Type.Builder tb = new Type.Builder(mRS, Element.RGBA_8888(mRS)); - tb.setX(640); - tb.setY(480); - mSto = Allocation.createTyped(mRS, tb.create(), Allocation.USAGE_GRAPHICS_TEXTURE | - Allocation.USAGE_IO_INPUT); - mRto = Allocation.createTyped(mRS, tb.create(), Allocation.USAGE_GRAPHICS_RENDER_TARGET | - Allocation.USAGE_IO_OUTPUT); - mSto2 = Allocation.createTyped(mRS, tb.create(), Allocation.USAGE_GRAPHICS_TEXTURE | - Allocation.USAGE_IO_INPUT); - mST = mSto.getSurfaceTexture(); - mRto.setSurfaceTexture(mSto2.getSurfaceTexture()); - - ProgramFragmentFixedFunction.Builder pfb = new ProgramFragmentFixedFunction.Builder(rs); - pfb.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE, - ProgramFragmentFixedFunction.Builder.Format.RGBA, 0); - mPF = pfb.create(); - mPF.bindSampler(Sampler.CLAMP_NEAREST(mRS), 0); - rs.bindProgramFragment(mPF); - - mScript = new ScriptC_sto(mRS, mRes, R.raw.sto); - mScript.set_sto(mSto); - mScript.set_rto(mRto); - mScript.set_sto2(mSto2); - mScript.set_pf(mPF); - - mRS.bindRootScript(mScript); - - - android.util.Log.v("sto", "Init complete"); - } - - SurfaceTexture getST() { - return mST; - } - - public void newFrame() { - mSto.ioReceive(); - } - -} diff --git a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueView.java b/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueView.java deleted file mode 100644 index f5e49f2..0000000 --- a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueView.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.example.android.rs.sto; - - -import android.renderscript.RSSurfaceView; -import android.renderscript.RenderScriptGL; -import android.content.Context; -import android.content.res.Resources; -import android.graphics.SurfaceTexture; -import android.util.Log; - -public class SurfaceTextureOpaqueView extends RSSurfaceView { - - public SurfaceTextureOpaqueView(Context context) { - super(context); - } - - RenderScriptGL mRS; - SurfaceTextureOpaqueRS mRender; - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - if (mRS != null) { - mRS = null; - destroyRenderScriptGL(); - } - } - - SurfaceTexture getST() { - RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig(); - mRS = createRenderScriptGL(sc); - mRender = new SurfaceTextureOpaqueRS(); - mRender.init(mRS, getResources()); - return mRender.getST(); - } - -} - - diff --git a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/sto.rs b/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/sto.rs deleted file mode 100644 index efa901a..0000000 --- a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/sto.rs +++ /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. - */ - -#pragma version(1) -#pragma rs java_package_name(com.example.android.rs.sto) - -#pragma stateFragment(parent) - -#include "rs_graphics.rsh" - - -rs_program_fragment pf; -rs_allocation sto; // camera in -rs_allocation sto2; -rs_allocation rto; // render target - -int root() { - rsgBindTexture(pf, 0, sto); - -#if 1 - rsgBindColorTarget(rto, 0); - - rsgClearColor(0.f, 1.f, 0.f, 1.f); - rsgDrawQuadTexCoords(0, 0, 0, 0,0, - 0,500,0, 1,0, - 500,500,0, 1, 1, - 500, 0, 0, 0, 1 ); - rsgClearColorTarget(0); - - // io ops - rsAllocationIoSend(rto); - rsAllocationIoReceive(sto2); - - rsgBindTexture(pf, 0, sto2); -#endif - - rsgClearColor(0.f, 1.f, 0.f, 1.f); - rsgDrawQuadTexCoords(0, 0, 0, 0,0, - 0,500,0, 1,0, - 500,500,0, 1, 1, - 500, 0, 0, 0, 1 ); - - return 1; -} - 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 Binary files differdeleted file mode 100644 index e7d1455..0000000 --- a/tests/RenderScriptTests/tests/res/drawable-nodpi/test_pattern.png +++ /dev/null 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 7662007..0000000 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java +++ /dev/null @@ -1,235 +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_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 a06d820..0000000 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_alloc.java +++ /dev/null @@ -1,67 +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); - - 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.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 4951970..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.bind_a(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_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 cc48591..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.bind_a(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 3116e5a..0000000 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/alloc.rs +++ /dev/null @@ -1,94 +0,0 @@ -#include "shared.rsh" - -int *a; -int dimX; -int dimY; -int dimZ; - -rs_allocation aFaces; -rs_allocation aLOD; -rs_allocation aFacesLOD; - -static bool test_alloc_dims() { - bool failed = false; - int i, j; - - for (j = 0; j < dimY; j++) { - for (i = 0; i < dimX; i++) { - a[i + j * dimX] = i + j * dimX; - } - } - - rs_allocation alloc = rsGetAllocation(a); - _RS_ASSERT(rsAllocationGetDimX(alloc) == dimX); - _RS_ASSERT(rsAllocationGetDimY(alloc) == dimY); - _RS_ASSERT(rsAllocationGetDimZ(alloc) == 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(alloc, i, j); - int val = *(const int *)p; - _RS_ASSERT(val == (i + j * dimX)); - } - } - - // Test 1D addressing - for (i = 0; i < dimX * dimY; i++) { - rsDebug("Verifying ", i); - const void *p = rsGetElementAt(alloc, 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(alloc, 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 ac527b5..0000000 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach.rs +++ /dev/null @@ -1,74 +0,0 @@ -#include "shared.rsh" - -int *a; -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++) { - _RS_ASSERT(a[i + j * dimX] == (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++) { - _RS_ASSERT(a[i + j * dimX] == (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/fp_mad.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/fp_mad.rs deleted file mode 100644 index b6f2b2a..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 aae29a4..0000000 --- a/tests/RenderScriptTests/tests/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/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 33944aa..0000000 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/noroot.rs +++ /dev/null @@ -1,44 +0,0 @@ -#include "shared.rsh" - -int *a; -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++) { - _RS_ASSERT(a[i + j * dimX] == (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 Binary files differdeleted file mode 100644 index e7d1455..0000000 --- a/tests/RenderScriptTests/tests_v11/res/drawable/test_pattern.png +++ /dev/null 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 b6f2b2a..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 a4386a4..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 Binary files differdeleted file mode 100644 index e7d1455..0000000 --- a/tests/RenderScriptTests/tests_v14/res/drawable-nodpi/test_pattern.png +++ /dev/null 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 da42b29..0000000 --- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_alloc.java +++ /dev/null @@ -1,67 +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); - - 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, mRes, R.raw.alloc); - pRS.setMessageHandler(mRsMessage); - initializeGlobals(pRS, s); - 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 aeb5bb7..0000000 --- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/UT_foreach.java +++ /dev/null @@ -1,56 +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.bind_a(A); - - return; - } - - public void run() { - RenderScript pRS = RenderScript.create(mCtx); - ScriptC_foreach s = new ScriptC_foreach(pRS, mRes, R.raw.foreach); - pRS.setMessageHandler(mRsMessage); - initializeGlobals(pRS, s); - s.forEach_root(A); - 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 3116e5a..0000000 --- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/alloc.rs +++ /dev/null @@ -1,94 +0,0 @@ -#include "shared.rsh" - -int *a; -int dimX; -int dimY; -int dimZ; - -rs_allocation aFaces; -rs_allocation aLOD; -rs_allocation aFacesLOD; - -static bool test_alloc_dims() { - bool failed = false; - int i, j; - - for (j = 0; j < dimY; j++) { - for (i = 0; i < dimX; i++) { - a[i + j * dimX] = i + j * dimX; - } - } - - rs_allocation alloc = rsGetAllocation(a); - _RS_ASSERT(rsAllocationGetDimX(alloc) == dimX); - _RS_ASSERT(rsAllocationGetDimY(alloc) == dimY); - _RS_ASSERT(rsAllocationGetDimZ(alloc) == 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(alloc, i, j); - int val = *(const int *)p; - _RS_ASSERT(val == (i + j * dimX)); - } - } - - // Test 1D addressing - for (i = 0; i < dimX * dimY; i++) { - rsDebug("Verifying ", i); - const void *p = rsGetElementAt(alloc, 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(alloc, 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 3ba3eef..0000000 --- a/tests/RenderScriptTests/tests_v14/src/com/android/rs/test/foreach.rs +++ /dev/null @@ -1,42 +0,0 @@ -#include "shared.rsh" - -int *a; -int dimX; -int dimY; - -void root(int *out, uint32_t x, uint32_t y) { - *out = x + y * dimX; -} - -static bool test_foreach_output() { - bool failed = false; - int i, j; - - for (j = 0; j < dimY; j++) { - for (i = 0; i < dimX; i++) { - _RS_ASSERT(a[i + j * dimX] == (i + j * dimX)); - } - } - - if (failed) { - rsDebug("test_foreach_output FAILED", 0); - } - else { - rsDebug("test_foreach_output PASSED", 0); - } - - return failed; -} - -void foreach_test() { - bool failed = false; - failed |= test_foreach_output(); - - 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 b6f2b2a..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/client/Android.mk b/tests/SharedLibrary/client/Android.mk new file mode 100644 index 0000000..60ef92a --- /dev/null +++ b/tests/SharedLibrary/client/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_APK_LIBRARIES := SharedLibrary + +LOCAL_PACKAGE_NAME := SharedLibraryClient + +LOCAL_MODULE_TAGS := tests + +include $(BUILD_PACKAGE) diff --git a/tests/RenderScriptTests/ComputeBenchmark/AndroidManifest.xml b/tests/SharedLibrary/client/AndroidManifest.xml index c8fcc17..c6a43c0 100644 --- a/tests/RenderScriptTests/ComputeBenchmark/AndroidManifest.xml +++ b/tests/SharedLibrary/client/AndroidManifest.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2012 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,12 +15,11 @@ --> <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"> + package="com.google.android.test.lib_client"> + <application android:label="@string/app_title"> + <uses-library android:name="android.test.runner" /> + <uses-library android:name="com.google.android.test.shared_library" /> + <activity android:name="ActivityMain"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> diff --git a/tests/RenderScriptTests/ImageProcessing2/res/layout/spinner_layout.xml b/tests/SharedLibrary/client/res/values/strings.xml index 8196bbf..3757a25 100644 --- a/tests/RenderScriptTests/ImageProcessing2/res/layout/spinner_layout.xml +++ b/tests/SharedLibrary/client/res/values/strings.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> - -<!-- Copyright (C) 2012 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,9 +14,6 @@ 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" -/> +<resources> + <string name="app_title">SharedLibrary client</string> +</resources> diff --git a/tests/SharedLibrary/client/src/com/google/android/test/lib_client/ActivityMain.java b/tests/SharedLibrary/client/src/com/google/android/test/lib_client/ActivityMain.java new file mode 100644 index 0000000..d6121a5 --- /dev/null +++ b/tests/SharedLibrary/client/src/com/google/android/test/lib_client/ActivityMain.java @@ -0,0 +1,35 @@ +/* + * 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.lib_client; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.TextView; +import com.google.android.test.shared_library.SharedLibraryMain; + +public class ActivityMain extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + TextView content = new TextView(this); + content.setText("Library version: " + SharedLibraryMain.getVersion(this) + "!"); + + SharedLibraryMain.ensureVersion(this, SharedLibraryMain.VERSION_BASE); + setContentView(content); + } +} diff --git a/tests/SharedLibrary/lib/Android.mk b/tests/SharedLibrary/lib/Android.mk new file mode 100644 index 0000000..c19e23a --- /dev/null +++ b/tests/SharedLibrary/lib/Android.mk @@ -0,0 +1,10 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_PACKAGE_NAME := SharedLibrary + +LOCAL_MODULE_TAGS := tests + +include $(BUILD_PACKAGE) diff --git a/tests/RenderScriptTests/ComputePerf/AndroidManifest.xml b/tests/SharedLibrary/lib/AndroidManifest.xml index a9193b5..31fac20 100644 --- a/tests/RenderScriptTests/ComputePerf/AndroidManifest.xml +++ b/tests/SharedLibrary/lib/AndroidManifest.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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,12 +15,11 @@ --> <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"> + package="com.google.android.test.shared_library" + android:versionCode="2"> + <application android:label="SharedLibrary"> + <library android:name="com.google.android.test.shared_library" /> + <activity android:name="ActivityMain"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> diff --git a/tests/RenderScriptTests/ImageProcessing/res/layout/spinner_layout.xml b/tests/SharedLibrary/lib/res/values/strings.xml index 8196bbf..bbfb0b4 100644 --- a/tests/RenderScriptTests/ImageProcessing/res/layout/spinner_layout.xml +++ b/tests/SharedLibrary/lib/res/values/strings.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> - -<!-- Copyright (C) 2012 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,9 +14,9 @@ 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" -/> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="upgrade_title">Upgrade required</string> + <string name="upgrade_body"><xliff:g id="app">%1$s</xliff:g> requires a newer version + of <xliff:g id="lib">%2$s</xliff:g> to run.</string> + <string name="upgrade_button">Upgrade</string> +</resources> diff --git a/tests/RenderScriptTests/ComputeBenchmark/src/com/example/android/rs/computebench/ComputeBench.java b/tests/SharedLibrary/lib/src/com/google/android/test/shared_library/ActivityMain.java index 2d3e843..895aced 100644 --- a/tests/RenderScriptTests/ComputeBenchmark/src/com/example/android/rs/computebench/ComputeBench.java +++ b/tests/SharedLibrary/lib/src/com/google/android/test/shared_library/ActivityMain.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 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. @@ -14,24 +14,19 @@ * limitations under the License. */ -package com.example.android.rs.computebench; +package com.google.android.test.shared_library; import android.app.Activity; import android.os.Bundle; -import android.renderscript.RenderScript; - -public class ComputeBench extends Activity { - private RenderScript mRS; - private Benchmark mBenchmark; +import android.widget.TextView; +public class ActivityMain extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - mRS = RenderScript.create(this); - mBenchmark = new Benchmark(mRS, getResources()); - mBenchmark.run(); + TextView content = new TextView(this); + content.setText("Dummy main entry for this apk; not really needed..."); + setContentView(content); } } 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 new file mode 100644 index 0000000..2c61b77 --- /dev/null +++ b/tests/SharedLibrary/lib/src/com/google/android/test/shared_library/SharedLibraryMain.java @@ -0,0 +1,82 @@ +/* + * 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.Fragment; +import android.app.FragmentManager; +import android.content.Context; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; + +public class SharedLibraryMain { + static String LIBRARY_PACKAGE = "com.google.android.test.shared_library"; + + /** + * Base version of the library. + */ + public static int VERSION_BASE = 1; + + /** + * The second version of the library. + */ + 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 { + pi = context.getPackageManager().getPackageInfo(LIBRARY_PACKAGE, 0); + return pi.versionCode; + } catch (PackageManager.NameNotFoundException e) { + throw new IllegalStateException("Can't find my package!", e); + } + } + + /** + * 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) { + // 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. + // 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(); + } + + // 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/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java index 5d0b155..9862116 100644 --- a/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java +++ b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java @@ -49,6 +49,8 @@ public class NotificationBuilderTest extends Activity { private final static String TAG = "NotificationTestList"; + private final static String NOTIFY_TAG = "foo"; + NotificationManager mNM; Handler mHandler; int mStartDelay; @@ -117,34 +119,34 @@ public class NotificationBuilderTest extends Activity public void onClick(View v) { switch (v.getId()) { case R.id.clear_1: - mNM.cancel(1); + cancelNotification(1); break; case R.id.clear_2: - mNM.cancel(2); + cancelNotification(2); break; case R.id.clear_3: - mNM.cancel(3); + cancelNotification(3); break; case R.id.clear_4: - mNM.cancel(4); + cancelNotification(4); break; case R.id.clear_5: - mNM.cancel(5); + cancelNotification(5); break; case R.id.clear_6: - mNM.cancel(6); + cancelNotification(6); break; case R.id.clear_7: - mNM.cancel(7); + cancelNotification(7); break; case R.id.clear_8: - mNM.cancel(8); + cancelNotification(8); break; case R.id.clear_9: - mNM.cancel(9); + cancelNotification(9); break; case R.id.clear_10: - mNM.cancel(10); + cancelNotification(10); break; case R.id.notify_1: sendNotification(1); @@ -196,11 +198,15 @@ public class NotificationBuilderTest extends Activity final Notification n = buildNotification(id); mHandler.postDelayed(new Runnable() { public void run() { - mNM.notify(id, n); + mNM.notify(NOTIFY_TAG, id, n); } }, mStartDelay); } + private void cancelNotification(final int id) { + mNM.cancel(NOTIFY_TAG, id); + } + private static CharSequence subst(CharSequence in, char ch, CharSequence sub) { int i=0; SpannableStringBuilder edit = new SpannableStringBuilder(in); diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java index ec39aab..ba160b1 100644 --- a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java +++ b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java @@ -33,13 +33,10 @@ import android.util.Log; import android.net.Uri; import android.os.SystemClock; import android.widget.RemoteViews; -import android.widget.TextView; -import android.widget.ProgressBar; import android.os.PowerManager; // private NM API import android.app.INotificationManager; -import com.android.internal.statusbar.StatusBarNotification; public class NotificationTestList extends TestActivity { @@ -796,6 +793,7 @@ public class NotificationTestList extends TestActivity INotificationManager directLine = mNM.getService(); directLine.enqueueNotificationWithTag( getPackageName(), + getPackageName(), null, 100, n, @@ -821,7 +819,8 @@ public class NotificationTestList extends TestActivity INotificationManager directLine = mNM.getService(); directLine.enqueueNotificationWithTag( getPackageName(), - null, + getPackageName(), + null, 200, n, idOut, @@ -846,7 +845,8 @@ public class NotificationTestList extends TestActivity INotificationManager directLine = mNM.getService(); directLine.enqueueNotificationWithTag( getPackageName(), - null, + getPackageName(), + null, 1, n, idOut, diff --git a/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java b/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java index 274ac00..90b6abc 100644 --- a/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java +++ b/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java @@ -20,6 +20,7 @@ import junit.framework.TestCase; import android.os.Binder; import android.os.IVibratorService; +import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.test.suitebuilder.annotation.SmallTest; @@ -46,7 +47,7 @@ public class VibratorServicePermissionTest extends TestCase { */ public void testVibrate() throws RemoteException { try { - mVibratorService.vibrate(2000, new Binder()); + mVibratorService.vibrate(Process.myUid(), null, 2000, new Binder()); fail("vibrate did not throw SecurityException as expected"); } catch (SecurityException e) { // expected @@ -62,7 +63,7 @@ public class VibratorServicePermissionTest extends TestCase { */ public void testVibratePattern() throws RemoteException { try { - mVibratorService.vibratePattern(new long[] {0}, 0, new Binder()); + mVibratorService.vibratePattern(Process.myUid(), null, new long[] {0}, 0, new Binder()); fail("vibratePattern did not throw SecurityException as expected"); } catch (SecurityException e) { // expected diff --git a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java index 596f722..746ac06 100644 --- a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java +++ b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java @@ -93,7 +93,7 @@ public class WindowManagerPermissionTests extends TestCase { } try { - mWm.addAppToken(0, 0, null, 0, 0, false, false); + mWm.addAppToken(0, null, 0, 0, false, false); fail("IWindowManager.addAppToken did not throw SecurityException as" + " expected"); } catch (SecurityException e) { |
