Loading tests/RenderScriptTests/ImageProcessing_jb/Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,6 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) \ #LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript LOCAL_PACKAGE_NAME := ImageProcessingJB LOCAL_SDK_VERSION := 16 LOCAL_SDK_VERSION := 17 include $(BUILD_PACKAGE) tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/BWFilter.java 0 → 100644 +34 −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.imagejb; import java.lang.Math; public class BWFilter extends TestBase { private ScriptC_bwfilter mScript; public void createTest(android.content.res.Resources res) { mScript = new ScriptC_bwfilter(mRS); } public void runTest() { mScript.invoke_prepareBwFilter(50, 50, 50); mScript.forEach_bwFilterKernel(mInPixelsAllocation, mOutPixelsAllocation); } } tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Blend.java 0 → 100644 +178 −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.imagejb; import java.lang.Math; import java.lang.Short; import android.renderscript.Allocation; import android.renderscript.Element; import android.renderscript.Matrix4f; import android.renderscript.RenderScript; import android.renderscript.Script; import android.renderscript.ScriptC; import android.renderscript.ScriptGroup; import android.renderscript.ScriptIntrinsicBlend; import android.renderscript.Type; import android.util.Log; import android.widget.SeekBar; import android.widget.TextView; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.view.View; import android.widget.Spinner; public class Blend extends TestBase { private ScriptIntrinsicBlend mBlend; private ScriptC_blend mBlendHelper; private short image1Alpha = 128; private short image2Alpha = 128; String mIntrinsicNames[]; private Allocation image1; private Allocation image2; private int currentIntrinsic = 0; private AdapterView.OnItemSelectedListener mIntrinsicSpinnerListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { currentIntrinsic = pos; if (mRS != null) { runTest(); act.updateDisplay(); } } public void onNothingSelected(AdapterView parent) { } }; public void createTest(android.content.res.Resources res) { mBlend = ScriptIntrinsicBlend.create(mRS, Element.U8_4(mRS)); mBlendHelper = new ScriptC_blend(mRS); mBlendHelper.set_alpha((short)128); image1 = Allocation.createTyped(mRS, mInPixelsAllocation.getType()); image2 = Allocation.createTyped(mRS, mInPixelsAllocation2.getType()); mIntrinsicNames = new String[14]; mIntrinsicNames[0] = "Source"; mIntrinsicNames[1] = "Destination"; mIntrinsicNames[2] = "Source Over"; mIntrinsicNames[3] = "Destination Over"; mIntrinsicNames[4] = "Source In"; mIntrinsicNames[5] = "Destination In"; mIntrinsicNames[6] = "Source Out"; mIntrinsicNames[7] = "Destination Out"; mIntrinsicNames[8] = "Source Atop"; mIntrinsicNames[9] = "Destination Atop"; mIntrinsicNames[10] = "XOR"; mIntrinsicNames[11] = "Add"; mIntrinsicNames[12] = "Subtract"; mIntrinsicNames[13] = "Multiply"; } public boolean onSpinner1Setup(Spinner s) { s.setAdapter(new ArrayAdapter<String>( act, R.layout.spinner_layout, mIntrinsicNames)); s.setOnItemSelectedListener(mIntrinsicSpinnerListener); return true; } public boolean onBar1Setup(SeekBar b, TextView t) { t.setText("Image 1 Alpha"); b.setMax(255); b.setProgress(image1Alpha); return true; } public void onBar1Changed(int progress) { image1Alpha = (short)progress; } public boolean onBar2Setup(SeekBar b, TextView t) { t.setText("Image 2 Alpha"); b.setMax(255); b.setProgress(image2Alpha); return true; } public void onBar2Changed(int progress) { image2Alpha = (short)progress; } public void runTest() { image1.copy2DRangeFrom(0, 0, mInPixelsAllocation.getType().getX(), mInPixelsAllocation.getType().getY(), mInPixelsAllocation, 0, 0); image2.copy2DRangeFrom(0, 0, mInPixelsAllocation2.getType().getX(), mInPixelsAllocation2.getType().getY(), mInPixelsAllocation2, 0, 0); mBlendHelper.set_alpha(image1Alpha); mBlendHelper.forEach_setImageAlpha(image1); mBlendHelper.set_alpha(image2Alpha); mBlendHelper.forEach_setImageAlpha(image2); switch (currentIntrinsic) { case 0: mBlend.forEachSrc(image1, image2); break; case 1: mBlend.forEachDst(image1, image2); break; case 2: mBlend.forEachSrcOver(image1, image2); break; case 3: mBlend.forEachDstOver(image1, image2); break; case 4: mBlend.forEachSrcIn(image1, image2); break; case 5: mBlend.forEachDstIn(image1, image2); break; case 6: mBlend.forEachSrcOut(image1, image2); break; case 7: mBlend.forEachDstOut(image1, image2); break; case 8: mBlend.forEachSrcAtop(image1, image2); break; case 9: mBlend.forEachDstAtop(image1, image2); break; case 10: mBlend.forEachXor(image1, image2); break; case 11: mBlend.forEachAdd(image1, image2); break; case 12: mBlend.forEachSubtract(image1, image2); break; case 13: mBlend.forEachMultiply(image1, image2); break; } mOutPixelsAllocation.copy2DRangeFrom(0, 0, image2.getType().getX(), image2.getType().getY(), image2, 0, 0); } } tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Blur25.java +49 −21 Original line number Diff line number Diff line Loading @@ -21,12 +21,16 @@ 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; Loading @@ -35,7 +39,8 @@ public class Blur25 extends TestBase { private Allocation mScratchPixelsAllocation2; public Blur25() { public Blur25(boolean useIntrinsic) { mUseIntrinsic = useIntrinsic; } public boolean onBar1Setup(SeekBar b, TextView t) { Loading @@ -50,14 +55,24 @@ public class Blur25 extends TestBase { 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); Loading @@ -73,18 +88,31 @@ public class Blur25 extends TestBase { 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); } } } tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/ColorMatrix.java +22 −4 Original line number Diff line number Diff line Loading @@ -24,14 +24,19 @@ 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 useGrey) { public ColorMatrix(boolean useIntrinsic, boolean useGrey) { mUseIntrinsic = useIntrinsic; mUseGrey = useGrey; } Loading @@ -41,12 +46,25 @@ public class ColorMatrix extends TestBase { 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); } } } Loading
tests/RenderScriptTests/ImageProcessing_jb/Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,6 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) \ #LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript LOCAL_PACKAGE_NAME := ImageProcessingJB LOCAL_SDK_VERSION := 16 LOCAL_SDK_VERSION := 17 include $(BUILD_PACKAGE)
tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/BWFilter.java 0 → 100644 +34 −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.imagejb; import java.lang.Math; public class BWFilter extends TestBase { private ScriptC_bwfilter mScript; public void createTest(android.content.res.Resources res) { mScript = new ScriptC_bwfilter(mRS); } public void runTest() { mScript.invoke_prepareBwFilter(50, 50, 50); mScript.forEach_bwFilterKernel(mInPixelsAllocation, mOutPixelsAllocation); } }
tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Blend.java 0 → 100644 +178 −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.imagejb; import java.lang.Math; import java.lang.Short; import android.renderscript.Allocation; import android.renderscript.Element; import android.renderscript.Matrix4f; import android.renderscript.RenderScript; import android.renderscript.Script; import android.renderscript.ScriptC; import android.renderscript.ScriptGroup; import android.renderscript.ScriptIntrinsicBlend; import android.renderscript.Type; import android.util.Log; import android.widget.SeekBar; import android.widget.TextView; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.view.View; import android.widget.Spinner; public class Blend extends TestBase { private ScriptIntrinsicBlend mBlend; private ScriptC_blend mBlendHelper; private short image1Alpha = 128; private short image2Alpha = 128; String mIntrinsicNames[]; private Allocation image1; private Allocation image2; private int currentIntrinsic = 0; private AdapterView.OnItemSelectedListener mIntrinsicSpinnerListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { currentIntrinsic = pos; if (mRS != null) { runTest(); act.updateDisplay(); } } public void onNothingSelected(AdapterView parent) { } }; public void createTest(android.content.res.Resources res) { mBlend = ScriptIntrinsicBlend.create(mRS, Element.U8_4(mRS)); mBlendHelper = new ScriptC_blend(mRS); mBlendHelper.set_alpha((short)128); image1 = Allocation.createTyped(mRS, mInPixelsAllocation.getType()); image2 = Allocation.createTyped(mRS, mInPixelsAllocation2.getType()); mIntrinsicNames = new String[14]; mIntrinsicNames[0] = "Source"; mIntrinsicNames[1] = "Destination"; mIntrinsicNames[2] = "Source Over"; mIntrinsicNames[3] = "Destination Over"; mIntrinsicNames[4] = "Source In"; mIntrinsicNames[5] = "Destination In"; mIntrinsicNames[6] = "Source Out"; mIntrinsicNames[7] = "Destination Out"; mIntrinsicNames[8] = "Source Atop"; mIntrinsicNames[9] = "Destination Atop"; mIntrinsicNames[10] = "XOR"; mIntrinsicNames[11] = "Add"; mIntrinsicNames[12] = "Subtract"; mIntrinsicNames[13] = "Multiply"; } public boolean onSpinner1Setup(Spinner s) { s.setAdapter(new ArrayAdapter<String>( act, R.layout.spinner_layout, mIntrinsicNames)); s.setOnItemSelectedListener(mIntrinsicSpinnerListener); return true; } public boolean onBar1Setup(SeekBar b, TextView t) { t.setText("Image 1 Alpha"); b.setMax(255); b.setProgress(image1Alpha); return true; } public void onBar1Changed(int progress) { image1Alpha = (short)progress; } public boolean onBar2Setup(SeekBar b, TextView t) { t.setText("Image 2 Alpha"); b.setMax(255); b.setProgress(image2Alpha); return true; } public void onBar2Changed(int progress) { image2Alpha = (short)progress; } public void runTest() { image1.copy2DRangeFrom(0, 0, mInPixelsAllocation.getType().getX(), mInPixelsAllocation.getType().getY(), mInPixelsAllocation, 0, 0); image2.copy2DRangeFrom(0, 0, mInPixelsAllocation2.getType().getX(), mInPixelsAllocation2.getType().getY(), mInPixelsAllocation2, 0, 0); mBlendHelper.set_alpha(image1Alpha); mBlendHelper.forEach_setImageAlpha(image1); mBlendHelper.set_alpha(image2Alpha); mBlendHelper.forEach_setImageAlpha(image2); switch (currentIntrinsic) { case 0: mBlend.forEachSrc(image1, image2); break; case 1: mBlend.forEachDst(image1, image2); break; case 2: mBlend.forEachSrcOver(image1, image2); break; case 3: mBlend.forEachDstOver(image1, image2); break; case 4: mBlend.forEachSrcIn(image1, image2); break; case 5: mBlend.forEachDstIn(image1, image2); break; case 6: mBlend.forEachSrcOut(image1, image2); break; case 7: mBlend.forEachDstOut(image1, image2); break; case 8: mBlend.forEachSrcAtop(image1, image2); break; case 9: mBlend.forEachDstAtop(image1, image2); break; case 10: mBlend.forEachXor(image1, image2); break; case 11: mBlend.forEachAdd(image1, image2); break; case 12: mBlend.forEachSubtract(image1, image2); break; case 13: mBlend.forEachMultiply(image1, image2); break; } mOutPixelsAllocation.copy2DRangeFrom(0, 0, image2.getType().getX(), image2.getType().getY(), image2, 0, 0); } }
tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/Blur25.java +49 −21 Original line number Diff line number Diff line Loading @@ -21,12 +21,16 @@ 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; Loading @@ -35,7 +39,8 @@ public class Blur25 extends TestBase { private Allocation mScratchPixelsAllocation2; public Blur25() { public Blur25(boolean useIntrinsic) { mUseIntrinsic = useIntrinsic; } public boolean onBar1Setup(SeekBar b, TextView t) { Loading @@ -50,14 +55,24 @@ public class Blur25 extends TestBase { 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); Loading @@ -73,18 +88,31 @@ public class Blur25 extends TestBase { 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); } } }
tests/RenderScriptTests/ImageProcessing_jb/src/com/android/rs/image/ColorMatrix.java +22 −4 Original line number Diff line number Diff line Loading @@ -24,14 +24,19 @@ 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 useGrey) { public ColorMatrix(boolean useIntrinsic, boolean useGrey) { mUseIntrinsic = useIntrinsic; mUseGrey = useGrey; } Loading @@ -41,12 +46,25 @@ public class ColorMatrix extends TestBase { 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); } } }