+
+ //Determine declaration order of each sampler
+ char* fragShader = strdup( mProgramData->GetFragmentShader() );
+ char* nextPtr = NULL;
+ const char* token = strtok_r( fragShader, " ;\n", &nextPtr );
+ int samplerPosition = 0;
+ while( token )
+ {
+ if( ( strncmp( token, "sampler2D", 9u ) == 0 ) ||
+ ( strncmp( token, "samplerCube", 11u ) == 0 ) ||
+ ( strncmp( token, "samplerExternalOES", 18u ) == 0 ) )
+ {
+ bool found( false );
+ token = strtok_r( NULL, " ;\n", &nextPtr );
+ for( size_t i=0; i<samplerUniformLocations.size(); ++i )
+ {
+ if( samplerUniformLocations[i].position == -1 &&
+ strncmp( token, samplerNames[i].c_str(), samplerNames[i].size() ) == 0 )
+ {
+ samplerUniformLocations[i].position = samplerPosition++;
+ found = true;
+ break;
+ }
+ }
+ if( !found )
+ {
+ DALI_LOG_ERROR("Sampler uniform %s declared but not used in the shader\n", token );
+ }
+ }
+ else
+ {
+ token = strtok_r( NULL, " ;\n", &nextPtr );
+ }
+ }
+
+ free( fragShader );
+
+ // Re-order according to declaration order in the fragment source.
+ size_t samplerUniformCount = samplerUniformLocations.size();
+ if( samplerUniformCount > 1 )