FileDocCategorySizeDatePackage
FragmentShader.javaAPI DocAndroid 5.1 API5775Thu Mar 12 22:22:44 GMT 2015com.android.scenegraph

FragmentShader

public class FragmentShader extends Shader
hide

Fields Summary
ProgramFragment
mProgram
ScriptField_FragmentShader_s
mField
Constructors Summary
Methods Summary
public ProgramFragmentgetProgram()

        return mProgram;
    
ScriptField_FragmentShader_sgetRSData()

        if (mField != null) {
            return mField;
        }

        RenderScriptGL rs = SceneManager.getRS();
        Resources res = SceneManager.getRes();
        if (rs == null || res == null) {
            return null;
        }

        ScriptField_FragmentShader_s.Item item = new ScriptField_FragmentShader_s.Item();
        item.program = mProgram;

        ScriptField_ShaderParam_s texParams = getTextureParams();
        if (texParams != null) {
            item.shaderTextureParams = texParams.getAllocation();
        }

        linkConstants(rs);
        if (mPerShaderConstants != null) {
            item.shaderConst = mConstantBuffer;
            item.shaderConstParams = mConstantBufferParams.getAllocation();
            mProgram.bindConstants(item.shaderConst, 0);
        }

        item.objectConstIndex = -1;
        if (mPerObjConstants != null) {
            item.objectConstIndex = mPerShaderConstants != null ? 1 : 0;
        }

        mField = new ScriptField_FragmentShader_s(rs, 1);
        mField.set(item, 0, true);
        return mField;
    
ScriptField_ShaderParam_sgetTextureParams()

        RenderScriptGL rs = SceneManager.getRS();
        Resources res = SceneManager.getRes();
        if (rs == null || res == null) {
            return null;
        }

        ArrayList<ScriptField_ShaderParam_s.Item> paramList;
        paramList = new ArrayList<ScriptField_ShaderParam_s.Item>();

        int shaderTextureStart = mTextureTypes.size();
        for (int i = 0; i < mShaderTextureNames.size(); i ++) {
            ShaderParam sp = mSourceParams.get(mShaderTextureNames.get(i));
            if (sp != null && sp instanceof TextureParam) {
                TextureParam p = (TextureParam)sp;
                ScriptField_ShaderParam_s.Item paramRS = new ScriptField_ShaderParam_s.Item();
                paramRS.bufferOffset = shaderTextureStart + i;
                paramRS.transformTimestamp = 0;
                paramRS.dataTimestamp = 0;
                paramRS.data = p.getRSData().getAllocation();
                paramList.add(paramRS);
            }
        }

        ScriptField_ShaderParam_s rsParams = null;
        int paramCount = paramList.size();
        if (paramCount != 0) {
            rsParams = new ScriptField_ShaderParam_s(rs, paramCount);
            for (int i = 0; i < paramCount; i++) {
                rsParams.set(paramList.get(i), i, false);
            }
            rsParams.copyAll();
        }
        return rsParams;