Skip to content

Commit 14250cc

Browse files
Jason SamsAndroid (Google) Code Review
authored andcommitted
Merge "Testing java compat lib for RS." into jb-mr1-dev
2 parents 504135b + ebefb2c commit 14250cc

32 files changed

+2037
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Copyright (C) 2009 The Android Open Source Project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
LOCAL_PATH := $(call my-dir)
18+
include $(CLEAR_VARS)
19+
20+
LOCAL_MODULE_TAGS := tests
21+
22+
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
23+
$(call all-renderscript-files-under, src)
24+
25+
LOCAL_STATIC_JAVA_LIBRARIES := android.support.v8.renderscript
26+
27+
LOCAL_PACKAGE_NAME := ImageProcessing2
28+
29+
LOCAL_RENDERSCRIPT_FLAGS := -rs-package-name=android.support.v8.renderscript
30+
LOCAL_REQUIRED_MODULES := librsjni
31+
32+
include $(BUILD_PACKAGE)
33+
34+
#include $(call all-makefiles-under, $(LOCAL_PATH))
35+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
4+
package="com.android.rs.image2">
5+
<uses-sdk android:minSdkVersion="11" />
6+
<application android:label="IP GB"
7+
android:hardwareAccelerated="true">
8+
<activity android:name="ImageProcessingActivity2">
9+
<intent-filter>
10+
<action android:name="android.intent.action.MAIN" />
11+
<category android:name="android.intent.category.LAUNCHER" />
12+
</intent-filter>
13+
</activity>
14+
</application>
15+
</manifest>
597 KB
Loading
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2009 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:orientation="vertical"
19+
android:layout_width="fill_parent"
20+
android:layout_height="fill_parent"
21+
android:id="@+id/toplevel">
22+
<SurfaceView
23+
android:id="@+id/surface"
24+
android:layout_width="1dip"
25+
android:layout_height="1dip" />
26+
<ScrollView
27+
android:layout_width="fill_parent"
28+
android:layout_height="fill_parent">
29+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
30+
android:orientation="vertical"
31+
android:layout_width="fill_parent"
32+
android:layout_height="fill_parent">
33+
<ImageView
34+
android:id="@+id/display"
35+
android:layout_width="wrap_content"
36+
android:layout_height="wrap_content" />
37+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
38+
android:orientation="horizontal"
39+
android:layout_width="fill_parent"
40+
android:layout_height="wrap_content">
41+
<Button
42+
android:layout_width="wrap_content"
43+
android:layout_height="wrap_content"
44+
android:text="@string/benchmark"
45+
android:onClick="benchmark"/>
46+
<TextView
47+
android:id="@+id/benchmarkText"
48+
android:layout_width="match_parent"
49+
android:layout_height="wrap_content"
50+
android:textSize="8pt"
51+
android:text="@string/saturation"/>
52+
</LinearLayout>
53+
<Spinner
54+
android:id="@+id/filterselection"
55+
android:layout_width="fill_parent"
56+
android:layout_height="wrap_content"/>
57+
<TextView
58+
android:id="@+id/slider1Text"
59+
android:layout_width="match_parent"
60+
android:layout_height="wrap_content"
61+
android:textSize="8pt"
62+
android:layout_marginLeft="10sp"
63+
android:layout_marginTop="15sp"
64+
android:text="@string/saturation"/>
65+
<SeekBar
66+
android:id="@+id/slider1"
67+
android:layout_marginLeft="10sp"
68+
android:layout_marginRight="10sp"
69+
android:layout_width="match_parent"
70+
android:layout_height="wrap_content"/>
71+
<TextView
72+
android:id="@+id/slider2Text"
73+
android:layout_width="match_parent"
74+
android:layout_height="wrap_content"
75+
android:textSize="8pt"
76+
android:layout_marginLeft="10sp"
77+
android:layout_marginTop="15sp"
78+
android:text="@string/gamma"/>
79+
<SeekBar
80+
android:id="@+id/slider2"
81+
android:layout_marginLeft="10sp"
82+
android:layout_marginRight="10sp"
83+
android:layout_width="match_parent"
84+
android:layout_height="wrap_content"/>
85+
<TextView
86+
android:id="@+id/slider3Text"
87+
android:layout_width="match_parent"
88+
android:layout_height="wrap_content"
89+
android:layout_marginLeft="10sp"
90+
android:layout_marginTop="15sp"
91+
android:textSize="8pt"
92+
android:text="@string/out_white"/>
93+
<SeekBar
94+
android:id="@+id/slider3"
95+
android:layout_marginLeft="10sp"
96+
android:layout_marginRight="10sp"
97+
android:layout_width="match_parent"
98+
android:layout_height="wrap_content"/>
99+
<TextView
100+
android:id="@+id/slider4Text"
101+
android:layout_width="match_parent"
102+
android:layout_height="wrap_content"
103+
android:textSize="8pt"
104+
android:layout_marginLeft="10sp"
105+
android:layout_marginTop="15sp"
106+
android:text="@string/in_white"/>
107+
<SeekBar
108+
android:id="@+id/slider4"
109+
android:layout_marginLeft="10sp"
110+
android:layout_marginRight="10sp"
111+
android:layout_width="match_parent"
112+
android:layout_height="wrap_content"/>
113+
<TextView
114+
android:id="@+id/slider5Text"
115+
android:layout_width="match_parent"
116+
android:layout_height="wrap_content"
117+
android:textSize="8pt"
118+
android:layout_marginLeft="10sp"
119+
android:layout_marginTop="15sp"
120+
android:text="@string/in_white"/>
121+
<SeekBar
122+
android:id="@+id/slider5"
123+
android:layout_marginLeft="10sp"
124+
android:layout_marginRight="10sp"
125+
android:layout_width="match_parent"
126+
android:layout_height="wrap_content"/>
127+
</LinearLayout>
128+
</ScrollView>
129+
</LinearLayout>
130+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<!-- Copyright (C) 2012 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
19+
android:layout_width="fill_parent"
20+
android:layout_height="fill_parent"
21+
android:padding="10dp"
22+
android:textSize="16sp"
23+
/>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/*
4+
* Copyright (C) 2008 The Android Open Source Project
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
-->
19+
20+
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
21+
<!-- General -->
22+
<skip />
23+
<!--slider label -->
24+
<string name="blur_description">Blur Radius</string>
25+
<string name="in_white">In White</string>
26+
<string name="out_white">Out White</string>
27+
<string name="in_black">In Black</string>
28+
<string name="out_black">Out Black</string>
29+
<string name="gamma">Gamma</string>
30+
<string name="saturation">Saturation</string>
31+
<string name="benchmark">Benchmark</string>
32+
33+
</resources>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.android.rs.image2;
18+
19+
import java.lang.Math;
20+
21+
import android.support.v8.renderscript.*;
22+
import android.util.Log;
23+
import android.widget.SeekBar;
24+
import android.widget.TextView;
25+
26+
public class Blur25 extends TestBase {
27+
private int MAX_RADIUS = 25;
28+
private ScriptC_threshold mScript;
29+
private ScriptC_vertical_blur mScriptVBlur;
30+
private ScriptC_horizontal_blur mScriptHBlur;
31+
private int mRadius = MAX_RADIUS;
32+
private float mSaturation = 1.0f;
33+
private Allocation mScratchPixelsAllocation1;
34+
private Allocation mScratchPixelsAllocation2;
35+
36+
37+
public boolean onBar1Setup(SeekBar b, TextView t) {
38+
t.setText("Radius");
39+
b.setProgress(100);
40+
return true;
41+
}
42+
public boolean onBar2Setup(SeekBar b, TextView t) {
43+
b.setProgress(50);
44+
t.setText("Saturation");
45+
return true;
46+
}
47+
48+
49+
public void onBar1Changed(int progress) {
50+
float fRadius = progress / 100.0f;
51+
fRadius *= (float)(MAX_RADIUS);
52+
mRadius = (int)fRadius;
53+
mScript.set_radius(mRadius);
54+
}
55+
public void onBar2Changed(int progress) {
56+
mSaturation = (float)progress / 50.0f;
57+
mScriptVBlur.invoke_setSaturation(mSaturation);
58+
}
59+
60+
61+
public void createTest(android.content.res.Resources res) {
62+
int width = mInPixelsAllocation.getType().getX();
63+
int height = mInPixelsAllocation.getType().getY();
64+
65+
Type.Builder tb = new Type.Builder(mRS, Element.F32_4(mRS));
66+
tb.setX(width);
67+
tb.setY(height);
68+
mScratchPixelsAllocation1 = Allocation.createTyped(mRS, tb.create());
69+
mScratchPixelsAllocation2 = Allocation.createTyped(mRS, tb.create());
70+
71+
mScriptVBlur = new ScriptC_vertical_blur(mRS, res, R.raw.vertical_blur);
72+
mScriptHBlur = new ScriptC_horizontal_blur(mRS, res, R.raw.horizontal_blur);
73+
74+
mScript = new ScriptC_threshold(mRS, res, R.raw.threshold);
75+
mScript.set_width(width);
76+
mScript.set_height(height);
77+
mScript.set_radius(mRadius);
78+
79+
mScriptVBlur.invoke_setSaturation(mSaturation);
80+
81+
mScript.bind_InPixel(mInPixelsAllocation);
82+
mScript.bind_OutPixel(mOutPixelsAllocation);
83+
mScript.bind_ScratchPixel1(mScratchPixelsAllocation1);
84+
mScript.bind_ScratchPixel2(mScratchPixelsAllocation2);
85+
86+
mScript.set_vBlurScript(mScriptVBlur);
87+
mScript.set_hBlurScript(mScriptHBlur);
88+
}
89+
90+
public void runTest() {
91+
mScript.invoke_filter();
92+
}
93+
94+
public void setupBenchmark() {
95+
mScript.set_radius(MAX_RADIUS);
96+
}
97+
98+
public void exitBenchmark() {
99+
mScript.set_radius(mRadius);
100+
}
101+
}

0 commit comments

Comments
 (0)