- CustomPropertyLookup::const_iterator entry = GetCustomPropertyLookup().find( index );
-
- DALI_ASSERT_ALWAYS( GetCustomPropertyLookup().end() != entry && "Property index is invalid" );
-
- DALI_ASSERT_ALWAYS( entry->second.IsAnimatable() && "shader effect has only animatable properties" );
-
- return entry->second.GetSceneGraphProperty();
-}
-
-void ShaderEffect::SetPrograms( GeometryType geometryTypes,
- const std::string& vertexShaderPrefix,
- const std::string& vertexShader,
- const std::string& fragmentShaderPrefix,
- const std::string& fragmentShader )
-{
- static std::string emptyStr;
-
- if( geometryTypes & GEOMETRY_TYPE_IMAGE )
- {
- SetWrappedProgram( GEOMETRY_TYPE_IMAGE, SHADER_SUBTYPE_ALL, vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
- }
- else
- {
- SetWrappedProgram( GEOMETRY_TYPE_IMAGE, SHADER_SUBTYPE_ALL, emptyStr, emptyStr, emptyStr, emptyStr );
- }
-
- if( geometryTypes & GEOMETRY_TYPE_TEXT )
- {
- // Only change the default program, leaving the other sub-types as-is.
- SetWrappedProgram( GEOMETRY_TYPE_TEXT, SHADER_DEFAULT, vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
- }
- else
- {
- SetWrappedProgram( GEOMETRY_TYPE_TEXT, SHADER_DEFAULT, emptyStr, emptyStr, emptyStr, emptyStr );
- }
-
- if( geometryTypes & GEOMETRY_TYPE_TEXTURED_MESH )
- {
- SetWrappedProgram( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_SUBTYPE_ALL, vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
- }
- else
- {
- SetWrappedProgram( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_SUBTYPE_ALL, emptyStr, emptyStr, emptyStr, emptyStr );
- }
-
- if( geometryTypes & GEOMETRY_TYPE_MESH )
- {
- SetWrappedProgram( GEOMETRY_TYPE_MESH, SHADER_SUBTYPE_ALL, vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
- }
- else
- {
- SetWrappedProgram( GEOMETRY_TYPE_MESH, SHADER_SUBTYPE_ALL, emptyStr, emptyStr, emptyStr, emptyStr );
- }
-}
-
-void ShaderEffect::SetWrappedProgram( GeometryType geometryType, ShaderSubTypes subType,
- const string& vertexPrefix, const string& fragmentPrefix,
- const string& vertexSnippet, const string& fragmentSnippet )
-{
- // create complete shader program strings for the given geometry type
- unsigned int index = 0;
- switch( geometryType )
- {
- case GEOMETRY_TYPE_IMAGE:
- {
- index = 0;
- break;
- }
- case GEOMETRY_TYPE_TEXT:
- {
- index = 1;
- break;
- }
- case GEOMETRY_TYPE_MESH:
- case GEOMETRY_TYPE_TEXTURED_MESH:
- {
- index = 2;
- break;
- }
- case GEOMETRY_TYPE_LAST:
- {
- DALI_ASSERT_DEBUG(0 && "Wrong geometry type");
- break;
- }
- }
-
- string vertexSource = vertexPrefix + customShaderWrappers[index].vertexShaderPrefix;
- string fragmentSource = fragmentPrefix + customShaderWrappers[index].fragmentShaderPrefix;
-
- // Append the custom vertex shader code if supplied, otherwise append the default
- if ( vertexSnippet.length() > 0 )
- {
- vertexSource.append( vertexSnippet );
- }
- else
- {
- vertexSource.append( customShaderWrappers[index].vertexShaderPostfix );
- }
-
- // Append the custom fragment shader code if supplied, otherwise append the default
- if ( fragmentSnippet.length() > 0 )
- {
- fragmentSource.append( fragmentSnippet );
- }
- else
- {
- fragmentSource.append( customShaderWrappers[index].fragmentShaderPostfix );
- }
-
- // Add the program
- SetProgramImpl( geometryType, subType, vertexSource, fragmentSource );
-}
-
-void ShaderEffect::SetProgramImpl( GeometryType geometryType, ShaderSubTypes subType,
- const string& vertexSource, const string& fragmentSource )
-{
- GeometryState modifiesGeometry = MODIFIES_GEOMETRY;
-
- if( (mGeometryHints & Dali::ShaderEffect::HINT_DOESNT_MODIFY_GEOMETRY ) != 0 )
- {
- modifiesGeometry = DOESNT_MODIFY_GEOMETRY;
- }
-
- SetProgramImpl( geometryType, subType, vertexSource, fragmentSource, modifiesGeometry );