| /* |
| * Copyright (C) 2014 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. |
| */ |
| |
| // Don't edit this file! It is auto-generated by frameworks/rs/api/gen_runtime. |
| |
| package android.renderscript.cts; |
| |
| import android.renderscript.Allocation; |
| import android.renderscript.RSRuntimeException; |
| import android.renderscript.Element; |
| |
| public class TestNativeDistance extends RSBaseCompute { |
| |
| private ScriptC_TestNativeDistance script; |
| private ScriptC_TestNativeDistanceRelaxed scriptRelaxed; |
| |
| @Override |
| protected void setUp() throws Exception { |
| super.setUp(); |
| script = new ScriptC_TestNativeDistance(mRS); |
| scriptRelaxed = new ScriptC_TestNativeDistanceRelaxed(mRS); |
| } |
| |
| private void checkNativeDistanceFloatFloatFloat() { |
| Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe0fd4252f8556ff6l, false); |
| Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe0fd4252f8559b4cl, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| script.set_gAllocInRhs(inRhs); |
| script.forEach_testNativeDistanceFloatFloatFloat(inLhs, out); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloatFloatFloat: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInRhs(inRhs); |
| scriptRelaxed.forEach_testNativeDistanceFloatFloatFloat(inLhs, out); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloatFloatFloat: " + e.toString()); |
| } |
| } |
| |
| private void checkNativeDistanceFloat2Float2Float() { |
| Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x28a9ea2ea1fd926al, false); |
| Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x28a9ea2ea1fdbdc0l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| script.set_gAllocInRhs(inRhs); |
| script.forEach_testNativeDistanceFloat2Float2Float(inLhs, out); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat2Float2Float: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInRhs(inRhs); |
| scriptRelaxed.forEach_testNativeDistanceFloat2Float2Float(inLhs, out); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat2Float2Float: " + e.toString()); |
| } |
| } |
| |
| private void checkNativeDistanceFloat3Float3Float() { |
| Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x559b398ef213adc4l, false); |
| Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x559b398ef213d91al, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| script.set_gAllocInRhs(inRhs); |
| script.forEach_testNativeDistanceFloat3Float3Float(inLhs, out); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat3Float3Float: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInRhs(inRhs); |
| scriptRelaxed.forEach_testNativeDistanceFloat3Float3Float(inLhs, out); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat3Float3Float: " + e.toString()); |
| } |
| } |
| |
| private void checkNativeDistanceFloat4Float4Float() { |
| Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x828c88ef4229c91el, false); |
| Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x828c88ef4229f474l, false); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| script.set_gAllocInRhs(inRhs); |
| script.forEach_testNativeDistanceFloat4Float4Float(inLhs, out); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat4Float4Float: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE); |
| scriptRelaxed.set_gAllocInRhs(inRhs); |
| scriptRelaxed.forEach_testNativeDistanceFloat4Float4Float(inLhs, out); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat4Float4Float: " + e.toString()); |
| } |
| } |
| |
| public void testNativeDistance() { |
| checkNativeDistanceFloatFloatFloat(); |
| checkNativeDistanceFloat2Float2Float(); |
| checkNativeDistanceFloat3Float3Float(); |
| checkNativeDistanceFloat4Float4Float(); |
| } |
| } |