diff options
Diffstat (limited to 'tests')
18 files changed, 591 insertions, 73 deletions
diff --git a/tests/ActivityTests/AndroidManifest.xml b/tests/ActivityTests/AndroidManifest.xml index 9dfe4a1..15d075c 100644 --- a/tests/ActivityTests/AndroidManifest.xml +++ b/tests/ActivityTests/AndroidManifest.xml @@ -21,6 +21,8 @@ <uses-permission android:name="android.permission.REMOVE_TASKS" /> <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> + <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" /> + <uses-permission android:name="android.permission.MANAGE_USERS" /> <application android:label="ActivityTest"> <activity android:name="ActivityTestMain"> <intent-filter> @@ -31,6 +33,8 @@ <service android:name="SingleUserService" android:singleUser="true" android:exported="true"> </service> + <service android:name="ServiceUserTarget"> + </service> <receiver android:name="UserTarget"> </receiver> <receiver android:name="SingleUserReceiver" 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 2348e99..f0c3b22 100644 --- a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java +++ b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java @@ -16,6 +16,7 @@ package com.google.android.test.activity; +import java.util.ArrayList; import java.util.List; import android.app.Activity; @@ -31,6 +32,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; +import android.os.UserManager; import android.graphics.Bitmap; import android.widget.ImageView; import android.widget.LinearLayout; @@ -41,6 +43,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.content.Context; +import android.content.pm.UserInfo; import android.content.res.Configuration; import android.util.Log; @@ -51,6 +54,9 @@ public class ActivityTestMain extends Activity { ActivityManager mAm; Configuration mOverrideConfig; + int mSecondUser; + + ArrayList<ServiceConnection> mConnections = new ArrayList<ServiceConnection>(); class BroadcastResultReceiver extends BroadcastReceiver { @Override @@ -122,6 +128,15 @@ public class ActivityTestMain extends Activity { applyOverrideConfiguration(mOverrideConfig); } } + + UserManager um = (UserManager)getSystemService(Context.USER_SERVICE); + List<UserInfo> users = um.getUsers(); + mSecondUser = Integer.MAX_VALUE; + for (UserInfo ui : users) { + if (ui.id != 0 && mSecondUser > ui.id) { + mSecondUser = ui.id; + } + } } @Override @@ -148,7 +163,12 @@ public class ActivityTestMain extends Activity { Log.i(TAG, "Service disconnected " + name); } }; - bindService(intent, conn, Context.BIND_AUTO_CREATE); + if (bindService(intent, conn, Context.BIND_AUTO_CREATE)) { + mConnections.add(conn); + } else { + Toast.makeText(ActivityTestMain.this, "Failed to bind", + Toast.LENGTH_LONG).show(); + } return true; } }); @@ -185,15 +205,70 @@ public class ActivityTestMain extends Activity { return true; } }); - menu.add("Send to user 1!").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + menu.add("Send to user 0!").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override public boolean onMenuItemClick(MenuItem item) { + Intent intent = new Intent(ActivityTestMain.this, UserTarget.class); + sendOrderedBroadcastAsUser(intent, new UserHandle(0), null, + new BroadcastResultReceiver(), + null, Activity.RESULT_OK, null, null); + return true; + } + }); + menu.add("Send to user " + mSecondUser + "!").setOnMenuItemClickListener( + new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Intent intent = new Intent(ActivityTestMain.this, UserTarget.class); - sendOrderedBroadcastAsUser(intent, new UserHandle(1), null, + sendOrderedBroadcastAsUser(intent, new UserHandle(mSecondUser), null, new BroadcastResultReceiver(), null, Activity.RESULT_OK, null, null); return true; } }); + menu.add("Bind to user 0!").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override public boolean onMenuItemClick(MenuItem item) { + Intent intent = new Intent(ActivityTestMain.this, ServiceUserTarget.class); + ServiceConnection conn = new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName name, IBinder service) { + Log.i(TAG, "Service connected " + name + " " + service); + } + @Override + public void onServiceDisconnected(ComponentName name) { + Log.i(TAG, "Service disconnected " + name); + } + }; + if (bindService(intent, conn, Context.BIND_AUTO_CREATE, 0)) { + mConnections.add(conn); + } else { + Toast.makeText(ActivityTestMain.this, "Failed to bind", + Toast.LENGTH_LONG).show(); + } + return true; + } + }); + menu.add("Bind to user " + mSecondUser + "!").setOnMenuItemClickListener( + new MenuItem.OnMenuItemClickListener() { + @Override public boolean onMenuItemClick(MenuItem item) { + Intent intent = new Intent(ActivityTestMain.this, ServiceUserTarget.class); + ServiceConnection conn = new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName name, IBinder service) { + Log.i(TAG, "Service connected " + name + " " + service); + } + @Override + public void onServiceDisconnected(ComponentName name) { + Log.i(TAG, "Service disconnected " + name); + } + }; + if (bindService(intent, conn, Context.BIND_AUTO_CREATE, mSecondUser)) { + mConnections.add(conn); + } else { + Toast.makeText(ActivityTestMain.this, "Failed to bind", + Toast.LENGTH_LONG).show(); + } + return true; + } + }); menu.add("Density!").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (mOverrideConfig == null) { @@ -226,6 +301,15 @@ public class ActivityTestMain extends Activity { } } + @Override + protected void onStop() { + super.onStop(); + for (ServiceConnection conn : mConnections) { + unbindService(conn); + } + mConnections.clear(); + } + private View scrollWrap(View view) { ScrollView scroller = new ScrollView(this); scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT, diff --git a/tests/ActivityTests/src/com/google/android/test/activity/ServiceUserTarget.java b/tests/ActivityTests/src/com/google/android/test/activity/ServiceUserTarget.java new file mode 100644 index 0000000..a7474ec --- /dev/null +++ b/tests/ActivityTests/src/com/google/android/test/activity/ServiceUserTarget.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.activity; + +import android.app.Service; +import android.content.Intent; +import android.os.Binder; +import android.os.IBinder; +import android.os.UserHandle; +import android.widget.Toast; + +public class ServiceUserTarget extends Service { + Binder mBinder = new Binder(); + + @Override + public void onCreate() { + super.onCreate(); + Toast.makeText(this, + "Service created as user " + UserHandle.myUserId(), + Toast.LENGTH_LONG).show(); + } + + @Override + public IBinder onBind(Intent intent) { + return mBinder; + } +} diff --git a/tests/ActivityTests/src/com/google/android/test/activity/SingleUserService.java b/tests/ActivityTests/src/com/google/android/test/activity/SingleUserService.java index c40582a..e9c340f 100644 --- a/tests/ActivityTests/src/com/google/android/test/activity/SingleUserService.java +++ b/tests/ActivityTests/src/com/google/android/test/activity/SingleUserService.java @@ -20,11 +20,21 @@ import android.app.Service; import android.content.Intent; import android.os.Binder; import android.os.IBinder; +import android.os.UserHandle; +import android.widget.Toast; public class SingleUserService extends Service { Binder mBinder = new Binder(); @Override + public void onCreate() { + super.onCreate(); + Toast.makeText(this, + "Service created as user " + UserHandle.myUserId(), + Toast.LENGTH_LONG).show(); + } + + @Override public IBinder onBind(Intent intent) { return mBinder; } diff --git a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067b.jpg b/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067b.jpg Binary files differnew file mode 100644 index 0000000..aed0781 --- /dev/null +++ b/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067b.jpg diff --git a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img640x427.jpg b/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img640x427.jpg Binary files differdeleted file mode 100644 index 5bce392..0000000 --- a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img640x427.jpg +++ /dev/null diff --git a/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml b/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml index 4715d6e..f0a2b92 100644 --- a/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml +++ b/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml @@ -54,6 +54,10 @@ 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" diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java new file mode 100644 index 0000000..2920824 --- /dev/null +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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; + 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/ImageProcessingActivity.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java index c171a64..db0ef78 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java @@ -55,9 +55,11 @@ public class ImageProcessingActivity extends Activity 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; @@ -81,6 +83,10 @@ public class ImageProcessingActivity extends Activity private TestBase mTest; + public void updateDisplay() { + mTest.updateBitmap(mBitmapOut); + mDisplayView.invalidate(); + } public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { @@ -98,8 +104,7 @@ public class ImageProcessingActivity extends Activity } mTest.runTest(); - mTest.updateBitmap(mBitmapOut); - mDisplayView.invalidate(); + updateDisplay(); } } @@ -110,6 +115,9 @@ public class ImageProcessingActivity extends Activity } void setupBars() { + mSpinner.setVisibility(View.VISIBLE); + mTest.onSpinner1Setup(mSpinner); + mBar1.setVisibility(View.VISIBLE); mText1.setVisibility(View.VISIBLE); mTest.onBar1Setup(mBar1, mText1); @@ -221,19 +229,21 @@ public class ImageProcessingActivity extends Activity case 27: mTest = new Mandelbrot(); break; + case 28: + mTest = new Blend(); + break; } - mTest.createBaseTest(this, mBitmapIn); + mTest.createBaseTest(this, mBitmapIn, mBitmapIn2); setupBars(); mTest.runTest(); - mTest.updateBitmap(mBitmapOut); - mDisplayView.invalidate(); + updateDisplay(); mBenchmarkResult.setText("Result: not run"); } void setupTests() { - mTestNames = new String[28]; + mTestNames = new String[29]; mTestNames[0] = "Levels Vec3 Relaxed"; mTestNames[1] = "Levels Vec4 Relaxed"; mTestNames[2] = "Levels Vec3 Full"; @@ -262,6 +272,7 @@ public class ImageProcessingActivity extends Activity 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)); @@ -284,6 +295,7 @@ public class ImageProcessingActivity extends Activity 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); @@ -291,6 +303,8 @@ public class ImageProcessingActivity extends Activity 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); @@ -377,7 +391,7 @@ public class ImageProcessingActivity extends Activity long result = 0; //Log.v(TAG, "Warming"); - long t = java.lang.System.currentTimeMillis() + 2000; + long t = java.lang.System.currentTimeMillis() + 250; do { mTest.runTest(); mTest.finish(); @@ -391,7 +405,7 @@ public class ImageProcessingActivity extends Activity mTest.runTest(); mTest.finish(); ct++; - } while ((t+5000) > java.lang.System.currentTimeMillis()); + } while ((t+1000) > java.lang.System.currentTimeMillis()); t = java.lang.System.currentTimeMillis() - t; float ft = (float)t; ft /= ct; diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java index 6885181..8009daa 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java @@ -36,14 +36,18 @@ 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) { } @@ -84,11 +88,20 @@ public class TestBase { return false; } - public final void createBaseTest(ImageProcessingActivity act, Bitmap b) { + 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); diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/blend.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/blend.rs new file mode 100644 index 0000000..87b56f7 --- /dev/null +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/blend.rs @@ -0,0 +1,24 @@ +// 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/convolve3x3.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.rs index 455fcc2..9812827 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.rs @@ -30,15 +30,15 @@ void root(uchar4 *out, uint32_t x, uint32_t y) { uint32_t y1 = min((int32_t)y+1, gHeight-1); 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]); + 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]; diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.rs index fe6cf31..e6d03c9 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.rs @@ -37,35 +37,35 @@ void root(uchar4 *out, uint32_t x, uint32_t 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(((uchar4 *)rsGetElementAt(gIn, x0, y0))[0]) * gCoeffs[0] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x1, y0))[0]) * gCoeffs[1] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x2, y0))[0]) * gCoeffs[2] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x3, y0))[0]) * gCoeffs[3] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x4, y0))[0]) * gCoeffs[4]; + 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(((uchar4 *)rsGetElementAt(gIn, x0, y1))[0]) * gCoeffs[5] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x1, y1))[0]) * gCoeffs[6] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x2, y1))[0]) * gCoeffs[7] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x3, y1))[0]) * gCoeffs[8] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x4, y1))[0]) * gCoeffs[9]; + 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(((uchar4 *)rsGetElementAt(gIn, x0, y2))[0]) * gCoeffs[10] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x1, y2))[0]) * gCoeffs[11] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x2, y2))[0]) * gCoeffs[12] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x3, y2))[0]) * gCoeffs[13] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x4, y2))[0]) * gCoeffs[14]; + 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(((uchar4 *)rsGetElementAt(gIn, x0, y3))[0]) * gCoeffs[15] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x1, y3))[0]) * gCoeffs[16] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x2, y3))[0]) * gCoeffs[17] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x3, y3))[0]) * gCoeffs[18] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x4, y3))[0]) * gCoeffs[19]; + 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(((uchar4 *)rsGetElementAt(gIn, x0, y4))[0]) * gCoeffs[20] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x1, y4))[0]) * gCoeffs[21] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x2, y4))[0]) * gCoeffs[22] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x3, y4))[0]) * gCoeffs[23] - + convert_float4(((uchar4 *)rsGetElementAt(gIn, x4, y4))[0]) * gCoeffs[24]; + 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/ImageProcessing/src/com/android/rs/image/grain.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs index 783bc4a..ea42524 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs @@ -48,15 +48,15 @@ void blend9(uchar *out, uint32_t x, uint32_t y) { uint32_t y1 = min((int32_t)y+1, (int32_t)(gHeight -1)); uint32_t y2 = max((int32_t)y-1, (int32_t)0); - uint p00 = 56 * ((uchar *)rsGetElementAt(gBlendSource, x1, y1))[0]; - uint p01 = 114 * ((uchar *)rsGetElementAt(gBlendSource, x, y1))[0]; - uint p02 = 56 * ((uchar *)rsGetElementAt(gBlendSource, x2, y1))[0]; - uint p10 = 114 * ((uchar *)rsGetElementAt(gBlendSource, x1, y))[0]; - uint p11 = 230 * ((uchar *)rsGetElementAt(gBlendSource, x, y))[0]; - uint p12 = 114 * ((uchar *)rsGetElementAt(gBlendSource, x2, y))[0]; - uint p20 = 56 * ((uchar *)rsGetElementAt(gBlendSource, x1, y2))[0]; - uint p21 = 114 * ((uchar *)rsGetElementAt(gBlendSource, x, y2))[0]; - uint p22 = 56 * ((uchar *)rsGetElementAt(gBlendSource, x2, y2))[0]; + 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; @@ -78,7 +78,7 @@ 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) ((uchar *)rsGetElementAt(gNoise, x, y))[0]; + float pnoise = (float) rsGetElementAt_uchar(gNoise, x, y); float energy_level = ip.r + ip.g + ip.b; float energy_mask = (28.f - sqrt(energy_level)) * 0.03571f; diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java index 2a06491..83fadcb 100644 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java @@ -76,6 +76,7 @@ public class RSTestCore { 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)); 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 new file mode 100644 index 0000000..380f6ec --- /dev/null +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_copy_test.java @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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/copy_test.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/copy_test.rs new file mode 100644 index 0000000..f4243eb --- /dev/null +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/copy_test.rs @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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/StatusBar/src/com/android/statusbartest/StatusBarTest.java b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java index 94ad620..3b6e107 100644 --- a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java +++ b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java @@ -16,29 +16,15 @@ package com.android.statusbartest; -import android.app.ListActivity; import android.app.Notification; import android.app.NotificationManager; -import android.widget.ArrayAdapter; import android.view.View; -import android.widget.ListView; import android.content.Intent; import android.app.PendingIntent; -import android.app.Notification; -import android.app.NotificationManager; import android.app.StatusBarManager; -import android.content.Context; -import android.util.AttributeSet; -import android.os.Vibrator; -import android.os.Bundle; import android.os.Handler; import android.util.Log; -import android.net.Uri; import android.os.SystemClock; -import android.widget.RemoteViews; -import android.widget.Toast; -import android.os.PowerManager; -import android.view.View; import android.view.Window; import android.view.WindowManager; @@ -300,14 +286,14 @@ public class StatusBarTest extends TestActivity }, new Test("Expand") { public void run() { - mStatusBarManager.expand(); + mStatusBarManager.expandNotifications(); } }, new Test("Expand in 3 sec.") { public void run() { mHandler.postDelayed(new Runnable() { public void run() { - mStatusBarManager.expand(); + mStatusBarManager.expandNotifications(); } }, 3000); } @@ -316,7 +302,7 @@ public class StatusBarTest extends TestActivity public void run() { mHandler.postDelayed(new Runnable() { public void run() { - mStatusBarManager.collapse(); + mStatusBarManager.collapseNotifications(); } }, 3000); } |