ProgramFragment.java revision b4d7bb6872f523b4318144202e119766ed9054ed
1/* 2 * Copyright (C) 2008 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 19 20import android.util.Config; 21import android.util.Log; 22 23 24/** 25 * @hide 26 * 27 **/ 28public class ProgramFragment extends Program { 29 ProgramFragment(int id, RenderScript rs) { 30 super(id, rs); 31 } 32 33 public static class Builder extends BaseProgramBuilder { 34 public Builder(RenderScript rs) { 35 super(rs); 36 } 37 38 public ProgramFragment create() { 39 mRS.validate(); 40 int[] tmp = new int[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2]; 41 int idx = 0; 42 43 for (int i=0; i < mInputCount; i++) { 44 tmp[idx++] = ProgramParam.INPUT.mID; 45 tmp[idx++] = mInputs[i].getID(); 46 } 47 for (int i=0; i < mOutputCount; i++) { 48 tmp[idx++] = ProgramParam.OUTPUT.mID; 49 tmp[idx++] = mOutputs[i].getID(); 50 } 51 for (int i=0; i < mConstantCount; i++) { 52 tmp[idx++] = ProgramParam.CONSTANT.mID; 53 tmp[idx++] = mConstants[i].getID(); 54 } 55 for (int i=0; i < mTextureCount; i++) { 56 tmp[idx++] = ProgramParam.TEXTURE_TYPE.mID; 57 tmp[idx++] = mTextureTypes[i].mID; 58 } 59 60 int id = mRS.nProgramFragmentCreate(mShader, tmp); 61 ProgramFragment pf = new ProgramFragment(id, mRS); 62 initProgram(pf); 63 return pf; 64 } 65 } 66} 67 68 69 70