ScriptIntrinsicColorMatrix.java revision 5729fcdf950eb909b0ab90a49af58731ed8f92cd
1/* 2 * Copyright (C) 2012 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.renderscript; 18 19import android.content.Context; 20import android.content.res.Resources; 21import android.util.Log; 22 23import java.io.File; 24import java.io.IOException; 25import java.io.InputStream; 26import java.util.Map.Entry; 27import java.util.HashMap; 28 29 30/** 31 * @hide 32 **/ 33public class ScriptIntrinsicColorMatrix extends ScriptIntrinsic { 34 private Matrix4f mMatrix = new Matrix4f(); 35 private Allocation mInput; 36 37 ScriptIntrinsicColorMatrix(int id, RenderScript rs) { 38 super(id, rs); 39 } 40 41 /** 42 * Supported elements types are float, float4, uchar, uchar4 43 * 44 * 45 * @param rs 46 * @param e 47 * 48 * @return ScriptIntrinsicColorMatrix 49 */ 50 public static ScriptIntrinsicColorMatrix create(RenderScript rs, Element e) { 51 int id = rs.nScriptIntrinsicCreate(2, e.getID(rs)); 52 return new ScriptIntrinsicColorMatrix(id, rs); 53 54 } 55 56 public void setColorMatrix(Matrix4f m) { 57 mMatrix.load(m); 58 FieldPacker fp = new FieldPacker(16*4); 59 fp.addMatrix(m); 60 setVar(0, fp); 61 } 62 63 public void forEach(Allocation ain, Allocation aout) { 64 forEach(0, ain, aout, null); 65 } 66 67} 68 69