1/* 2 * Copyright (C) 2013 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 17package android.support.v8.renderscript; 18 19import android.util.Log; 20 21class ScriptIntrinsicLUTThunker extends ScriptIntrinsicLUT { 22 android.renderscript.ScriptIntrinsicLUT mN; 23 24 android.renderscript.ScriptIntrinsicLUT getNObj() { 25 return mN; 26 } 27 28 private ScriptIntrinsicLUTThunker(int id, RenderScript rs) { 29 super(id, rs); 30 } 31 32 public static ScriptIntrinsicLUTThunker create(RenderScript rs, Element e) { 33 RenderScriptThunker rst = (RenderScriptThunker) rs; 34 ElementThunker et = (ElementThunker) e; 35 36 ScriptIntrinsicLUTThunker si = new ScriptIntrinsicLUTThunker(0, rs); 37 try { 38 si.mN = android.renderscript.ScriptIntrinsicLUT.create(rst.mN, et.getNObj()); 39 } catch (android.renderscript.RSRuntimeException exc) { 40 throw ExceptionThunker.convertException(exc); 41 } 42 return si; 43 } 44 45 public void setRed(int index, int value) { 46 try { 47 mN.setRed(index, value); 48 } catch (android.renderscript.RSRuntimeException e) { 49 throw ExceptionThunker.convertException(e); 50 } 51 } 52 53 public void setGreen(int index, int value) { 54 try { 55 mN.setGreen(index, value); 56 } catch (android.renderscript.RSRuntimeException e) { 57 throw ExceptionThunker.convertException(e); 58 } 59 } 60 61 public void setBlue(int index, int value) { 62 try { 63 mN.setBlue(index, value); 64 } catch (android.renderscript.RSRuntimeException e) { 65 throw ExceptionThunker.convertException(e); 66 } 67 } 68 69 public void setAlpha(int index, int value) { 70 try { 71 mN.setAlpha(index, value); 72 } catch (android.renderscript.RSRuntimeException e) { 73 throw ExceptionThunker.convertException(e); 74 } 75 } 76 77 public void forEach(Allocation ain, Allocation aout) { 78 AllocationThunker aint = (AllocationThunker)ain; 79 AllocationThunker aoutt = (AllocationThunker)aout; 80 try { 81 mN.forEach(aint.getNObj(), aoutt.getNObj()); 82 } catch (android.renderscript.RSRuntimeException e) { 83 throw ExceptionThunker.convertException(e); 84 } 85 } 86 87 public Script.KernelID getKernelID() { 88 Script.KernelID k = createKernelID(0, 3, null, null); 89 try { 90 k.mN = mN.getKernelID(); 91 } catch (android.renderscript.RSRuntimeException e) { 92 throw ExceptionThunker.convertException(e); 93 } 94 return k; 95 } 96} 97 98