| 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 | |
| 17 | package android.renderscript; |
| 18 | |
| 19 | import android.compat.annotation.UnsupportedAppUsage; |
| 20 | |
| 21 | |
| 22 | /** |
| 23 | * @hide |
| 24 | * @deprecated in API 16 |
| 25 | * <p>The RenderScript fragment program, also known as fragment shader is responsible |
| 26 | * for manipulating pixel data in a user defined way. It's constructed from a GLSL |
| 27 | * shader string containing the program body, textures inputs, and a Type object |
| 28 | * that describes the constants used by the program. Similar to the vertex programs, |
| 29 | * when an allocation with constant input values is bound to the shader, its values |
| 30 | * are sent to the graphics program automatically.</p> |
| 31 | * <p> The values inside the allocation are not explicitly tracked. If they change between two draw |
| 32 | * calls using the same program object, the runtime needs to be notified of that |
| 33 | * change by calling rsgAllocationSyncAll so it could send the new values to hardware. |
| 34 | * Communication between the vertex and fragment programs is handled internally in the |
| 35 | * GLSL code. For example, if the fragment program is expecting a varying input called |
| 36 | * varTex0, the GLSL code inside the program vertex must provide it. |
| 37 | * </p> |
| 38 | * |
| 39 | **/ |
| 40 | @Deprecated |
| 41 | public class ProgramFragment extends Program { |
| 42 | ProgramFragment(long id, RenderScript rs) { |
| 43 | super(id, rs); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @deprecated in API 16 |
| 48 | */ |
| 49 | public static class Builder extends BaseProgramBuilder { |
| 50 | /** |
| 51 | * @deprecated in API 16 |
| 52 | * Create a builder object. |
| 53 | * |
| 54 | * @param rs Context to which the program will belong. |
| 55 | */ |
| 56 | @UnsupportedAppUsage |
| 57 | public Builder(RenderScript rs) { |
| 58 | super(rs); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @deprecated in API 16 |
| 63 | * Creates ProgramFragment from the current state of the builder |
| 64 | * |
| 65 | * @return ProgramFragment |
| 66 | */ |
| 67 | @UnsupportedAppUsage |
| 68 | public ProgramFragment create() { |
| 69 | mRS.validate(); |
| 70 | long[] tmp = new long[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2]; |
| 71 | String[] texNames = new String[mTextureCount]; |
| 72 | int idx = 0; |
| 73 | |
| 74 | for (int i=0; i < mInputCount; i++) { |
| 75 | tmp[idx++] = ProgramParam.INPUT.mID; |
| 76 | tmp[idx++] = mInputs[i].getID(mRS); |
| 77 | } |
| 78 | for (int i=0; i < mOutputCount; i++) { |
| 79 | tmp[idx++] = ProgramParam.OUTPUT.mID; |
| 80 | tmp[idx++] = mOutputs[i].getID(mRS); |
| 81 | } |
| 82 | for (int i=0; i < mConstantCount; i++) { |
| 83 | tmp[idx++] = ProgramParam.CONSTANT.mID; |
| 84 | tmp[idx++] = mConstants[i].getID(mRS); |
| 85 | } |
| 86 | for (int i=0; i < mTextureCount; i++) { |
| 87 | tmp[idx++] = ProgramParam.TEXTURE_TYPE.mID; |
| 88 | tmp[idx++] = mTextureTypes[i].mID; |
| 89 | texNames[i] = mTextureNames[i]; |
| 90 | } |
| 91 | |
| 92 | long id = mRS.nProgramFragmentCreate(mShader, texNames, tmp); |
| 93 | ProgramFragment pf = new ProgramFragment(id, mRS); |
| 94 | initProgram(pf); |
| 95 | return pf; |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | |
| 101 |