15729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams/* 25729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * Copyright (C) 2012 The Android Open Source Project 35729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * 45729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * Licensed under the Apache License, Version 2.0 (the "License"); 55729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * you may not use this file except in compliance with the License. 65729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * You may obtain a copy of the License at 75729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * 85729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * http://www.apache.org/licenses/LICENSE-2.0 95729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * 105729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * Unless required by applicable law or agreed to in writing, software 115729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * distributed under the License is distributed on an "AS IS" BASIS, 125729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * See the License for the specific language governing permissions and 145729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * limitations under the License. 155729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams */ 165729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams 175729fcdf950eb909b0ab90a49af58731ed8f92cdJason Samspackage android.renderscript; 185729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams 195729fcdf950eb909b0ab90a49af58731ed8f92cdJason Samsimport android.util.Log; 205729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams 215729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams/** 2280d819033d4687507907f787d47379b7b37eae19Jason Sams * Intrinsic for applying a color matrix to allocations. 2380d819033d4687507907f787d47379b7b37eae19Jason Sams * 24d979208974d995438ebd51e8070eaeabf63461dbJason Sams * If the element type is {@link Element.DataType#UNSIGNED_8}, 25d979208974d995438ebd51e8070eaeabf63461dbJason Sams * it is converted to {@link Element.DataType#FLOAT_32} and 26d979208974d995438ebd51e8070eaeabf63461dbJason Sams * normalized from (0-255) to (0-1). If the incoming vector size 27d979208974d995438ebd51e8070eaeabf63461dbJason Sams * is less than four, a {@link Element#F32_4} is created by 28d979208974d995438ebd51e8070eaeabf63461dbJason Sams * filling the missing vector channels with zero. This value is 29d979208974d995438ebd51e8070eaeabf63461dbJason Sams * then multiplied by the 4x4 color matrix as performed by 30d979208974d995438ebd51e8070eaeabf63461dbJason Sams * rsMatrixMultiply(), adding a {@link Element#F32_4}, and then 31d979208974d995438ebd51e8070eaeabf63461dbJason Sams * writing it to the output {@link Allocation}. 32d979208974d995438ebd51e8070eaeabf63461dbJason Sams * 33d979208974d995438ebd51e8070eaeabf63461dbJason Sams * If the ouptut type is unsigned, the value is normalized from 34d979208974d995438ebd51e8070eaeabf63461dbJason Sams * (0-1) to (0-255) and converted. If the output vector size is 35d979208974d995438ebd51e8070eaeabf63461dbJason Sams * less than four, the unused channels are discarded. 36d979208974d995438ebd51e8070eaeabf63461dbJason Sams * 37d979208974d995438ebd51e8070eaeabf63461dbJason Sams * Supported elements types are {@link Element#U8}, {@link 38d979208974d995438ebd51e8070eaeabf63461dbJason Sams * Element#U8_2}, {@link Element#U8_3}, {@link Element#U8_4}, 39d979208974d995438ebd51e8070eaeabf63461dbJason Sams * {@link Element#F32}, {@link Element#F32_2}, {@link 40d979208974d995438ebd51e8070eaeabf63461dbJason Sams * Element#F32_3}, and {@link Element#F32_4}. 415729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams **/ 4280d819033d4687507907f787d47379b7b37eae19Jason Samspublic final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic { 4380d819033d4687507907f787d47379b7b37eae19Jason Sams private final Matrix4f mMatrix = new Matrix4f(); 44d979208974d995438ebd51e8070eaeabf63461dbJason Sams private final Float4 mAdd = new Float4(); 455729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams 4680d819033d4687507907f787d47379b7b37eae19Jason Sams private ScriptIntrinsicColorMatrix(int id, RenderScript rs) { 475729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams super(id, rs); 485729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams } 495729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams 505729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams /** 5180d819033d4687507907f787d47379b7b37eae19Jason Sams * Create an intrinsic for applying a color matrix to an 5280d819033d4687507907f787d47379b7b37eae19Jason Sams * allocation. 535729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * 54c11e25c4e653124def1fb18e203b894f42106cbeTim Murray * @param rs The RenderScript context 55d979208974d995438ebd51e8070eaeabf63461dbJason Sams * @param e Element type for inputs and outputs, As of API 19, 56d979208974d995438ebd51e8070eaeabf63461dbJason Sams * this parameter is ignored. The Element type check is 57d979208974d995438ebd51e8070eaeabf63461dbJason Sams * performed in the kernel launch. 585729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * 59a49e89d2288827e2c96bc006e1e4893d22b41f3bJason Sams * @deprecated Use the single argument version as Element is now 60a49e89d2288827e2c96bc006e1e4893d22b41f3bJason Sams * ignored. 61a49e89d2288827e2c96bc006e1e4893d22b41f3bJason Sams * 625729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams * @return ScriptIntrinsicColorMatrix 635729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams */ 64a49e89d2288827e2c96bc006e1e4893d22b41f3bJason Sams @Deprecated 655729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams public static ScriptIntrinsicColorMatrix create(RenderScript rs, Element e) { 66d979208974d995438ebd51e8070eaeabf63461dbJason Sams return create(rs); 67d979208974d995438ebd51e8070eaeabf63461dbJason Sams } 68d979208974d995438ebd51e8070eaeabf63461dbJason Sams 69d979208974d995438ebd51e8070eaeabf63461dbJason Sams /** 70d979208974d995438ebd51e8070eaeabf63461dbJason Sams * Create an intrinsic for applying a color matrix to an 71d979208974d995438ebd51e8070eaeabf63461dbJason Sams * allocation. 72d979208974d995438ebd51e8070eaeabf63461dbJason Sams * 73d979208974d995438ebd51e8070eaeabf63461dbJason Sams * @param rs The RenderScript context 74d979208974d995438ebd51e8070eaeabf63461dbJason Sams * 75d979208974d995438ebd51e8070eaeabf63461dbJason Sams * @return ScriptIntrinsicColorMatrix 76d979208974d995438ebd51e8070eaeabf63461dbJason Sams */ 77d979208974d995438ebd51e8070eaeabf63461dbJason Sams public static ScriptIntrinsicColorMatrix create(RenderScript rs) { 78d979208974d995438ebd51e8070eaeabf63461dbJason Sams int id = rs.nScriptIntrinsicCreate(2, 0); 795729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams return new ScriptIntrinsicColorMatrix(id, rs); 805729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams 815729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams } 825729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams 838fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams private void setMatrix() { 845729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams FieldPacker fp = new FieldPacker(16*4); 858fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams fp.addMatrix(mMatrix); 865729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams setVar(0, fp); 875729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams } 885729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams 898fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams /** 9080d819033d4687507907f787d47379b7b37eae19Jason Sams * Set the color matrix which will be applied to each cell of 9180d819033d4687507907f787d47379b7b37eae19Jason Sams * the image. 928fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * 938fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * @param m The 4x4 matrix to set. 948fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams */ 958fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams public void setColorMatrix(Matrix4f m) { 968fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.load(m); 978fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams setMatrix(); 988fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams } 998fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams 1008fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams /** 1018fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * Set the color matrix which will be applied to each cell of the image. 1028fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * This will set the alpha channel to be a copy. 1038fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * 1048fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * @param m The 3x3 matrix to set. 1058fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams */ 1068fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams public void setColorMatrix(Matrix3f m) { 1078fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.load(m); 1088fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams setMatrix(); 1098fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams } 1108fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams 1118fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams /** 112d979208974d995438ebd51e8070eaeabf63461dbJason Sams * Set the value to be added after the color matrix has been 113d979208974d995438ebd51e8070eaeabf63461dbJason Sams * applied. The default value is {0, 0, 0, 0} 114d979208974d995438ebd51e8070eaeabf63461dbJason Sams * 115d979208974d995438ebd51e8070eaeabf63461dbJason Sams * @param f The float4 value to be added. 116d979208974d995438ebd51e8070eaeabf63461dbJason Sams */ 117d979208974d995438ebd51e8070eaeabf63461dbJason Sams public void setAdd(Float4 f) { 118d979208974d995438ebd51e8070eaeabf63461dbJason Sams mAdd.x = f.x; 119d979208974d995438ebd51e8070eaeabf63461dbJason Sams mAdd.y = f.y; 120d979208974d995438ebd51e8070eaeabf63461dbJason Sams mAdd.z = f.z; 121d979208974d995438ebd51e8070eaeabf63461dbJason Sams mAdd.w = f.w; 122d979208974d995438ebd51e8070eaeabf63461dbJason Sams 123d979208974d995438ebd51e8070eaeabf63461dbJason Sams FieldPacker fp = new FieldPacker(4*4); 124d979208974d995438ebd51e8070eaeabf63461dbJason Sams fp.addF32(f.x); 125d979208974d995438ebd51e8070eaeabf63461dbJason Sams fp.addF32(f.y); 126d979208974d995438ebd51e8070eaeabf63461dbJason Sams fp.addF32(f.z); 127d979208974d995438ebd51e8070eaeabf63461dbJason Sams fp.addF32(f.w); 128d979208974d995438ebd51e8070eaeabf63461dbJason Sams setVar(1, fp); 129d979208974d995438ebd51e8070eaeabf63461dbJason Sams } 130d979208974d995438ebd51e8070eaeabf63461dbJason Sams 131d979208974d995438ebd51e8070eaeabf63461dbJason Sams /** 132d979208974d995438ebd51e8070eaeabf63461dbJason Sams * Set the value to be added after the color matrix has been 133d979208974d995438ebd51e8070eaeabf63461dbJason Sams * applied. The default value is {0, 0, 0, 0} 134d979208974d995438ebd51e8070eaeabf63461dbJason Sams * 135d979208974d995438ebd51e8070eaeabf63461dbJason Sams * @param r The red add value. 136d979208974d995438ebd51e8070eaeabf63461dbJason Sams * @param g The green add value. 137d979208974d995438ebd51e8070eaeabf63461dbJason Sams * @param b The blue add value. 138d979208974d995438ebd51e8070eaeabf63461dbJason Sams * @param a The alpha add value. 139d979208974d995438ebd51e8070eaeabf63461dbJason Sams */ 140d979208974d995438ebd51e8070eaeabf63461dbJason Sams public void setAdd(float r, float g, float b, float a) { 141d979208974d995438ebd51e8070eaeabf63461dbJason Sams mAdd.x = r; 142d979208974d995438ebd51e8070eaeabf63461dbJason Sams mAdd.y = g; 143d979208974d995438ebd51e8070eaeabf63461dbJason Sams mAdd.z = b; 144d979208974d995438ebd51e8070eaeabf63461dbJason Sams mAdd.w = a; 145d979208974d995438ebd51e8070eaeabf63461dbJason Sams 146d979208974d995438ebd51e8070eaeabf63461dbJason Sams FieldPacker fp = new FieldPacker(4*4); 147d979208974d995438ebd51e8070eaeabf63461dbJason Sams fp.addF32(mAdd.x); 148d979208974d995438ebd51e8070eaeabf63461dbJason Sams fp.addF32(mAdd.y); 149d979208974d995438ebd51e8070eaeabf63461dbJason Sams fp.addF32(mAdd.z); 150d979208974d995438ebd51e8070eaeabf63461dbJason Sams fp.addF32(mAdd.w); 151d979208974d995438ebd51e8070eaeabf63461dbJason Sams setVar(1, fp); 152d979208974d995438ebd51e8070eaeabf63461dbJason Sams } 153d979208974d995438ebd51e8070eaeabf63461dbJason Sams 154d979208974d995438ebd51e8070eaeabf63461dbJason Sams /** 15517fec32bba9da8df2062b52e414435574652ad50Jason Sams * Set a color matrix to convert from RGB to luminance. The alpha channel 1568fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * will be a copy. 1578fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * 1588fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams */ 1598fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams public void setGreyscale() { 1608fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.loadIdentity(); 1618fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(0, 0, 0.299f); 1628fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(1, 0, 0.587f); 1638fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(2, 0, 0.114f); 1648fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(0, 1, 0.299f); 1658fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(1, 1, 0.587f); 1668fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(2, 1, 0.114f); 1678fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(0, 2, 0.299f); 1688fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(1, 2, 0.587f); 1698fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(2, 2, 0.114f); 1708fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams setMatrix(); 1718fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams } 1728fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams 1738fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams /** 1748fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * Set the matrix to convert from YUV to RGB with a direct copy of the 4th 1758fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * channel. 1768fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * 1778fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams */ 1788fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams public void setYUVtoRGB() { 1798fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.loadIdentity(); 1808fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(0, 0, 1.f); 1818fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(1, 0, 0.f); 1828fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(2, 0, 1.13983f); 1838fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(0, 1, 1.f); 1848fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(1, 1, -0.39465f); 1858fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(2, 1, -0.5806f); 1868fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(0, 2, 1.f); 1878fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(1, 2, 2.03211f); 1888fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(2, 2, 0.f); 1898fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams setMatrix(); 1908fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams } 1918fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams 1928fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams /** 1938fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * Set the matrix to convert from RGB to YUV with a direct copy of the 4th 1948fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * channel. 1958fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * 1968fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams */ 1978fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams public void setRGBtoYUV() { 1988fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.loadIdentity(); 1998fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(0, 0, 0.299f); 2008fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(1, 0, 0.587f); 2018fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(2, 0, 0.114f); 2028fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(0, 1, -0.14713f); 2038fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(1, 1, -0.28886f); 2048fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(2, 1, 0.436f); 2058fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(0, 2, 0.615f); 2068fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(1, 2, -0.51499f); 2078fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams mMatrix.set(2, 2, -0.10001f); 2088fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams setMatrix(); 2098fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams } 2108fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams 2118fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams 2128fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams /** 213d979208974d995438ebd51e8070eaeabf63461dbJason Sams * Invoke the kernel and apply the matrix to each cell of input 214d979208974d995438ebd51e8070eaeabf63461dbJason Sams * {@link Allocation} and copy to the output {@link Allocation}. 215d979208974d995438ebd51e8070eaeabf63461dbJason Sams * 216d979208974d995438ebd51e8070eaeabf63461dbJason Sams * If the vector size of the input is less than four, the 217d979208974d995438ebd51e8070eaeabf63461dbJason Sams * remaining components are treated as zero for the matrix 218d979208974d995438ebd51e8070eaeabf63461dbJason Sams * multiply. 219d979208974d995438ebd51e8070eaeabf63461dbJason Sams * 220d979208974d995438ebd51e8070eaeabf63461dbJason Sams * If the output vector size is less than four, the unused 221d979208974d995438ebd51e8070eaeabf63461dbJason Sams * vector components are discarded. 222d979208974d995438ebd51e8070eaeabf63461dbJason Sams * 2238fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * 2248fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * @param ain Input allocation 2258fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams * @param aout Output allocation 2268fd5853c1c07c2fd3954b3c5e64702d70af31144Jason Sams */ 2275729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams public void forEach(Allocation ain, Allocation aout) { 228d979208974d995438ebd51e8070eaeabf63461dbJason Sams if (!ain.getElement().isCompatible(Element.U8(mRS)) && 229d979208974d995438ebd51e8070eaeabf63461dbJason Sams !ain.getElement().isCompatible(Element.U8_2(mRS)) && 230d979208974d995438ebd51e8070eaeabf63461dbJason Sams !ain.getElement().isCompatible(Element.U8_3(mRS)) && 231d979208974d995438ebd51e8070eaeabf63461dbJason Sams !ain.getElement().isCompatible(Element.U8_4(mRS)) && 232d979208974d995438ebd51e8070eaeabf63461dbJason Sams !ain.getElement().isCompatible(Element.F32(mRS)) && 233d979208974d995438ebd51e8070eaeabf63461dbJason Sams !ain.getElement().isCompatible(Element.F32_2(mRS)) && 234d979208974d995438ebd51e8070eaeabf63461dbJason Sams !ain.getElement().isCompatible(Element.F32_3(mRS)) && 235d979208974d995438ebd51e8070eaeabf63461dbJason Sams !ain.getElement().isCompatible(Element.F32_4(mRS))) { 236d979208974d995438ebd51e8070eaeabf63461dbJason Sams 237d979208974d995438ebd51e8070eaeabf63461dbJason Sams throw new RSIllegalArgumentException("Unsuported element type."); 238d979208974d995438ebd51e8070eaeabf63461dbJason Sams } 239d979208974d995438ebd51e8070eaeabf63461dbJason Sams 240d979208974d995438ebd51e8070eaeabf63461dbJason Sams if (!aout.getElement().isCompatible(Element.U8(mRS)) && 241d979208974d995438ebd51e8070eaeabf63461dbJason Sams !aout.getElement().isCompatible(Element.U8_2(mRS)) && 242d979208974d995438ebd51e8070eaeabf63461dbJason Sams !aout.getElement().isCompatible(Element.U8_3(mRS)) && 243d979208974d995438ebd51e8070eaeabf63461dbJason Sams !aout.getElement().isCompatible(Element.U8_4(mRS)) && 244d979208974d995438ebd51e8070eaeabf63461dbJason Sams !aout.getElement().isCompatible(Element.F32(mRS)) && 245d979208974d995438ebd51e8070eaeabf63461dbJason Sams !aout.getElement().isCompatible(Element.F32_2(mRS)) && 246d979208974d995438ebd51e8070eaeabf63461dbJason Sams !aout.getElement().isCompatible(Element.F32_3(mRS)) && 247d979208974d995438ebd51e8070eaeabf63461dbJason Sams !aout.getElement().isCompatible(Element.F32_4(mRS))) { 248d979208974d995438ebd51e8070eaeabf63461dbJason Sams 249d979208974d995438ebd51e8070eaeabf63461dbJason Sams throw new RSIllegalArgumentException("Unsuported element type."); 250d979208974d995438ebd51e8070eaeabf63461dbJason Sams } 251d979208974d995438ebd51e8070eaeabf63461dbJason Sams 2525729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams forEach(0, ain, aout, null); 2535729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams } 2545729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams 25508a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams /** 25608a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams * Get a KernelID for this intrinsic kernel. 25708a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams * 25808a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams * @return Script.KernelID The KernelID object. 25908a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams */ 26008a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams public Script.KernelID getKernelID() { 26108a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams return createKernelID(0, 3, null, null); 26208a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams } 26308a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams 2645729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams} 2655729fcdf950eb909b0ab90a49af58731ed8f92cdJason Sams 266