(SVACE Issues Fix) Initialise uninitialised member variables
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / configuration-manager.cpp
index 63b62dc..8ab98aa 100644 (file)
@@ -43,6 +43,8 @@ namespace
 
 const std::string SYSTEM_CACHE_FILE = "gpu-environment.conf";
 const std::string DALI_ENV_MULTIPLE_WINDOW_SUPPORT = "DALI_ENV_MULTIPLE_WINDOW_SUPPORT";
+const std::string DALI_BLEND_EQUATION_ADVANCED_SUPPORT = "DALI_BLEND_EQUATION_ADVANCED_SUPPORT";
+const std::string DALI_GLSL_VERSION = "DALI_GLSL_VERSION";
 
 bool RetrieveKeyFromConfigFile( std::iostream& stream, const std::string& key, std::string& value )
 {
@@ -80,9 +82,13 @@ ConfigurationManager::ConfigurationManager( std::string systemCachePath, EglGrap
   mEglGraphics( eglGraphics ),
   mThreadController( threadController ),
   mMaxTextureSize( 0u ),
+  mGlslVersion( 0u),
   mIsMultipleWindowSupported( true ),
-  mMaxTextureSizeCached( false ) ,
-  mIsMultipleWindowSupportedCached( false )
+  mIsAdvancedBlendEquationSupported( true ),
+  mMaxTextureSizeCached( false ),
+  mIsMultipleWindowSupportedCached( false ),
+  mIsAdvancedBlendEquationSupportedCached( false ),
+  mGlslVersionCached( false )
 {
 }
 
@@ -104,16 +110,30 @@ void ConfigurationManager::RetrieveKeysFromConfigFile( const std::string& config
       mMaxTextureSizeCached = true;
     }
 
+    if( !mGlslVersionCached &&
+        RetrieveKeyFromConfigFile( stream, DALI_GLSL_VERSION, value ) )
+    {
+      mGlslVersion = std::atoi( value.c_str() );
+      mGlslVersionCached = true;
+    }
+
     if( !mIsMultipleWindowSupportedCached &&
         RetrieveKeyFromConfigFile( stream, DALI_ENV_MULTIPLE_WINDOW_SUPPORT, value ) )
     {
       mIsMultipleWindowSupported = std::atoi( value.c_str() );
       mIsMultipleWindowSupportedCached = true;
     }
+
+    if( !mIsAdvancedBlendEquationSupportedCached &&
+        RetrieveKeyFromConfigFile( stream, DALI_BLEND_EQUATION_ADVANCED_SUPPORT, value ) )
+    {
+      mIsAdvancedBlendEquationSupported = std::atoi( value.c_str() );
+      mIsAdvancedBlendEquationSupportedCached = true;
+    }
   }
 }
 
-unsigned int ConfigurationManager::GetMaxTextureSize()
+uint32_t ConfigurationManager::GetMaxTextureSize()
 {
   if( !mMaxTextureSizeCached )
   {
@@ -141,6 +161,43 @@ unsigned int ConfigurationManager::GetMaxTextureSize()
   return mMaxTextureSize;
 }
 
+uint32_t ConfigurationManager::GetShadingLanguageVersion()
+{
+  if ( !mGlslVersionCached )
+  {
+    RetrieveKeysFromConfigFile( mSystemCacheFilePath );
+
+    if ( !mGlslVersionCached )
+    {
+      EglImplementation& eglImpl = mEglGraphics->GetEglImplementation();
+      if ( !eglImpl.IsGlesInitialized() )
+      {
+        // Wait until GLES is initialised, but this will happen once.
+        // This method blocks until the render thread has initialised the graphics.
+        mThreadController->WaitForGraphicsInitialization();
+      }
+
+      // Query from GLES and save the cache
+      mGlslVersion = mEglGraphics->GetGlesInterface().GetShadingLanguageVersion();
+      DALI_LOG_ERROR("mGlslVersion : %d\n", mGlslVersion);
+      mGlslVersionCached = true;
+
+      Dali::FileStream configFile( mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT );
+      std::fstream& stream = dynamic_cast<std::fstream&>( configFile.GetStream() );
+      if ( stream.is_open() )
+      {
+        stream << DALI_GLSL_VERSION << " " << mGlslVersion << std::endl;
+      }
+      else
+      {
+        DALI_LOG_ERROR( "Fail to open file : %s\n", mSystemCacheFilePath.c_str() );
+      }
+    }
+  }
+
+  return mGlslVersion;
+}
+
 bool ConfigurationManager::IsMultipleWindowSupported()
 {
   if ( !mIsMultipleWindowSupportedCached )
@@ -177,6 +234,42 @@ bool ConfigurationManager::IsMultipleWindowSupported()
   return mIsMultipleWindowSupported;
 }
 
+bool ConfigurationManager::IsAdvancedBlendEquationSupported()
+{
+  if ( !mIsAdvancedBlendEquationSupportedCached )
+  {
+    RetrieveKeysFromConfigFile( mSystemCacheFilePath );
+
+    if ( !mIsAdvancedBlendEquationSupportedCached )
+    {
+      EglImplementation& eglImpl = mEglGraphics->GetEglImplementation();
+      if ( !eglImpl.IsGlesInitialized() )
+      {
+        // Wait until GLES is initialised, but this will happen once.
+        // This method blocks until the render thread has initialised the graphics.
+        mThreadController->WaitForGraphicsInitialization();
+      }
+
+      // Query from GLES and save the cache
+      mIsAdvancedBlendEquationSupported = mEglGraphics->GetGlesInterface().IsAdvancedBlendEquationSupported();
+      mIsAdvancedBlendEquationSupportedCached = true;
+
+      Dali::FileStream configFile( mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT );
+      std::fstream& stream = dynamic_cast<std::fstream&>( configFile.GetStream() );
+      if ( stream.is_open() )
+      {
+        stream << DALI_BLEND_EQUATION_ADVANCED_SUPPORT << " " << mIsAdvancedBlendEquationSupported << std::endl;
+      }
+      else
+      {
+        DALI_LOG_ERROR( "Fail to open file : %s\n", mSystemCacheFilePath.c_str() );
+      }
+    }
+  }
+
+  return mIsAdvancedBlendEquationSupported;
+}
+
 } // Adaptor
 
 } // Internal