Loading graphics/java/android/renderscript/ScriptIntrinsicBlur.java +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public final class ScriptIntrinsicBlur extends ScriptIntrinsic { * @return ScriptIntrinsicBlur */ public static ScriptIntrinsicBlur create(RenderScript rs, Element e) { if (e != Element.U8_4(rs)) { if ((e != Element.U8_4(rs)) && e != (Element.U8(rs))) { throw new RSIllegalArgumentException("Unsuported element type."); } int id = rs.nScriptIntrinsicCreate(5, e.getID(rs)); Loading tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blur25G.java 0 → 100644 +97 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.rs.image; import java.lang.Math; import android.graphics.Bitmap; import android.renderscript.Allocation; import android.renderscript.Element; import android.renderscript.RenderScript; import android.renderscript.ScriptIntrinsicBlur; import android.renderscript.Type; import android.util.Log; import android.widget.SeekBar; import android.widget.TextView; public class Blur25G extends TestBase { private final int MAX_RADIUS = 25; private float mRadius = MAX_RADIUS; private ScriptIntrinsicBlur mIntrinsic; private ScriptC_greyscale mScript; private Allocation mScratchPixelsAllocation1; private Allocation mScratchPixelsAllocation2; public Blur25G() { } public boolean onBar1Setup(SeekBar b, TextView t) { t.setText("Radius"); b.setProgress(100); return true; } public void onBar1Changed(int progress) { mRadius = ((float)progress) / 100.0f * MAX_RADIUS; if (mRadius <= 0.10f) { mRadius = 0.10f; } mIntrinsic.setRadius(mRadius); } public void createTest(android.content.res.Resources res) { int width = mInPixelsAllocation.getType().getX(); int height = mInPixelsAllocation.getType().getY(); Type.Builder tb = new Type.Builder(mRS, Element.U8(mRS)); tb.setX(width); tb.setY(height); mScratchPixelsAllocation1 = Allocation.createTyped(mRS, tb.create()); mScratchPixelsAllocation2 = Allocation.createTyped(mRS, tb.create()); mScript = new ScriptC_greyscale(mRS); mScript.forEach_toU8(mInPixelsAllocation, mScratchPixelsAllocation1); mIntrinsic = ScriptIntrinsicBlur.create(mRS, Element.U8(mRS)); mIntrinsic.setRadius(MAX_RADIUS); mIntrinsic.setInput(mScratchPixelsAllocation1); } public void runTest() { mIntrinsic.forEach(mScratchPixelsAllocation2); } public void setupBenchmark() { mIntrinsic.setRadius(MAX_RADIUS); } public void exitBenchmark() { mIntrinsic.setRadius(mRadius); } public void updateBitmap(Bitmap b) { mScript.forEach_toU8_4(mScratchPixelsAllocation2, mOutPixelsAllocation); mOutPixelsAllocation.copyTo(b); } } tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java +5 −1 Original line number Diff line number Diff line Loading @@ -270,6 +270,9 @@ public class ImageProcessingActivity extends Activity case 28: mTest = new Blend(); break; case 29: mTest = new Blur25G(); break; } mTest.createBaseTest(this, mBitmapIn, mBitmapIn2); Loading @@ -281,7 +284,7 @@ public class ImageProcessingActivity extends Activity } void setupTests() { mTestNames = new String[29]; mTestNames = new String[30]; mTestNames[0] = "Levels Vec3 Relaxed"; mTestNames[1] = "Levels Vec4 Relaxed"; mTestNames[2] = "Levels Vec3 Full"; Loading Loading @@ -311,6 +314,7 @@ public class ImageProcessingActivity extends Activity mTestNames[26] = "Intrinsics Convolve 5x5"; mTestNames[27] = "Mandelbrot"; mTestNames[28] = "Intrinsics Blend"; mTestNames[29] = "Intrinsics Blur 25 uchar"; mTestSpinner.setAdapter(new ArrayAdapter<String>( this, R.layout.spinner_layout, mTestNames)); Loading tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java +0 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,6 @@ public class TestBase { // Must override public void createTest(android.content.res.Resources res) { android.util.Log.e("img", "implement createTest"); } // Must override Loading tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.fs +8 −0 Original line number Diff line number Diff line Loading @@ -27,4 +27,12 @@ uchar4 __attribute__((kernel)) root(uchar4 v_in) { return rsPackColorTo8888(mono); } uchar __attribute__((kernel)) toU8(uchar4 v_in) { float4 f4 = convert_float4(v_in); return (uchar)dot(f4.rgb, gMonoMult); } uchar4 __attribute__((kernel)) toU8_4(uchar v_in) { return (uchar4)v_in; } Loading
graphics/java/android/renderscript/ScriptIntrinsicBlur.java +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public final class ScriptIntrinsicBlur extends ScriptIntrinsic { * @return ScriptIntrinsicBlur */ public static ScriptIntrinsicBlur create(RenderScript rs, Element e) { if (e != Element.U8_4(rs)) { if ((e != Element.U8_4(rs)) && e != (Element.U8(rs))) { throw new RSIllegalArgumentException("Unsuported element type."); } int id = rs.nScriptIntrinsicCreate(5, e.getID(rs)); Loading
tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blur25G.java 0 → 100644 +97 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.rs.image; import java.lang.Math; import android.graphics.Bitmap; import android.renderscript.Allocation; import android.renderscript.Element; import android.renderscript.RenderScript; import android.renderscript.ScriptIntrinsicBlur; import android.renderscript.Type; import android.util.Log; import android.widget.SeekBar; import android.widget.TextView; public class Blur25G extends TestBase { private final int MAX_RADIUS = 25; private float mRadius = MAX_RADIUS; private ScriptIntrinsicBlur mIntrinsic; private ScriptC_greyscale mScript; private Allocation mScratchPixelsAllocation1; private Allocation mScratchPixelsAllocation2; public Blur25G() { } public boolean onBar1Setup(SeekBar b, TextView t) { t.setText("Radius"); b.setProgress(100); return true; } public void onBar1Changed(int progress) { mRadius = ((float)progress) / 100.0f * MAX_RADIUS; if (mRadius <= 0.10f) { mRadius = 0.10f; } mIntrinsic.setRadius(mRadius); } public void createTest(android.content.res.Resources res) { int width = mInPixelsAllocation.getType().getX(); int height = mInPixelsAllocation.getType().getY(); Type.Builder tb = new Type.Builder(mRS, Element.U8(mRS)); tb.setX(width); tb.setY(height); mScratchPixelsAllocation1 = Allocation.createTyped(mRS, tb.create()); mScratchPixelsAllocation2 = Allocation.createTyped(mRS, tb.create()); mScript = new ScriptC_greyscale(mRS); mScript.forEach_toU8(mInPixelsAllocation, mScratchPixelsAllocation1); mIntrinsic = ScriptIntrinsicBlur.create(mRS, Element.U8(mRS)); mIntrinsic.setRadius(MAX_RADIUS); mIntrinsic.setInput(mScratchPixelsAllocation1); } public void runTest() { mIntrinsic.forEach(mScratchPixelsAllocation2); } public void setupBenchmark() { mIntrinsic.setRadius(MAX_RADIUS); } public void exitBenchmark() { mIntrinsic.setRadius(mRadius); } public void updateBitmap(Bitmap b) { mScript.forEach_toU8_4(mScratchPixelsAllocation2, mOutPixelsAllocation); mOutPixelsAllocation.copyTo(b); } }
tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java +5 −1 Original line number Diff line number Diff line Loading @@ -270,6 +270,9 @@ public class ImageProcessingActivity extends Activity case 28: mTest = new Blend(); break; case 29: mTest = new Blur25G(); break; } mTest.createBaseTest(this, mBitmapIn, mBitmapIn2); Loading @@ -281,7 +284,7 @@ public class ImageProcessingActivity extends Activity } void setupTests() { mTestNames = new String[29]; mTestNames = new String[30]; mTestNames[0] = "Levels Vec3 Relaxed"; mTestNames[1] = "Levels Vec4 Relaxed"; mTestNames[2] = "Levels Vec3 Full"; Loading Loading @@ -311,6 +314,7 @@ public class ImageProcessingActivity extends Activity mTestNames[26] = "Intrinsics Convolve 5x5"; mTestNames[27] = "Mandelbrot"; mTestNames[28] = "Intrinsics Blend"; mTestNames[29] = "Intrinsics Blur 25 uchar"; mTestSpinner.setAdapter(new ArrayAdapter<String>( this, R.layout.spinner_layout, mTestNames)); Loading
tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java +0 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,6 @@ public class TestBase { // Must override public void createTest(android.content.res.Resources res) { android.util.Log.e("img", "implement createTest"); } // Must override Loading
tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.fs +8 −0 Original line number Diff line number Diff line Loading @@ -27,4 +27,12 @@ uchar4 __attribute__((kernel)) root(uchar4 v_in) { return rsPackColorTo8888(mono); } uchar __attribute__((kernel)) toU8(uchar4 v_in) { float4 f4 = convert_float4(v_in); return (uchar)dot(f4.rgb, gMonoMult); } uchar4 __attribute__((kernel)) toU8_4(uchar v_in) { return (uchar4)v_in; }