/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/internal/system/common/configuration-manager.h>
// EXTERNAL INCLUDES
-#include <fstream>
#include <dali/integration-api/debug.h>
+#include <fstream>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/file-stream.h>
-#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
#include <dali/internal/system/common/environment-options.h>
#include <dali/internal/system/common/environment-variables.h>
#include <dali/internal/system/common/thread-controller.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
-const std::string SYSTEM_CACHE_FILE = "gpu-environment.conf";
-const std::string DALI_ENV_MULTIPLE_WINDOW_SUPPORT = "DALI_ENV_MULTIPLE_WINDOW_SUPPORT";
-
-bool RetrieveKeyFromConfigFile( std::iostream& stream, const std::string& key, std::string& value )
-{
- bool keyFound = false;
-
- std::string line;
- while( std::getline( stream, line ) )
- {
- line.erase( line.find_last_not_of( " \t\r\n" ) + 1 );
- line.erase( 0, line.find_first_not_of( " \t\r\n" ) );
- if( '#' == *( line.cbegin() ) || line == "" )
- {
- continue;
- }
-
- std::istringstream stream( line );
- std::string name;
- std::getline(stream, name, ' ');
- if( name == key )
- {
- std::getline(stream, value);
- keyFound = true;
- break;
- }
- }
-
- return keyFound;
-}
-
+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";
} // unnamed namespace
-ConfigurationManager::ConfigurationManager( std::string systemCachePath, EglGraphics* eglGraphics, ThreadController* threadController )
-: mSystemCacheFilePath( systemCachePath + SYSTEM_CACHE_FILE ),
- mEglGraphics( eglGraphics ),
- mThreadController( threadController ),
- mMaxTextureSize( 0u ),
- mIsMultipleWindowSupported( true ),
- mMaxTextureSizeCached( false ) ,
- mIsMultipleWindowSupportedCached( false )
+ConfigurationManager::ConfigurationManager(std::string systemCachePath, GraphicsInterface* graphics, ThreadController* threadController)
+: mSystemCacheFilePath(systemCachePath + SYSTEM_CACHE_FILE),
+ mGraphics(graphics),
+ mThreadController(threadController),
+ mMaxTextureSize(0u),
+ mShaderLanguageVersion(0u),
+ mIsMultipleWindowSupported(true),
+ mIsAdvancedBlendEquationSupported(true),
+ mMaxTextureSizeCached(false),
+ mIsMultipleWindowSupportedCached(false),
+ mIsAdvancedBlendEquationSupportedCached(false),
+ mShaderLanguageVersionCached(false)
{
}
{
}
-void ConfigurationManager::RetrieveKeysFromConfigFile( const std::string& configFilePath )
+void ConfigurationManager::RetrieveKeysFromConfigFile(const std::string& configFilePath)
{
- Dali::FileStream configFile( configFilePath, Dali::FileStream::READ | Dali::FileStream::TEXT );
- std::iostream& stream = configFile.GetStream();
- if( stream.rdbuf()->in_avail() )
+ Dali::FileStream configFile(configFilePath, Dali::FileStream::READ | Dali::FileStream::TEXT);
+ std::iostream& stream = configFile.GetStream();
+ if(stream.rdbuf()->in_avail())
{
- std::string value;
- if( !mMaxTextureSizeCached &&
- RetrieveKeyFromConfigFile( stream, DALI_ENV_MAX_TEXTURE_SIZE, value ) )
+ std::string line;
+ while( std::getline( stream, line ) )
{
- mMaxTextureSize = std::atoi( value.c_str() );
- mMaxTextureSizeCached = true;
- }
+ line.erase( line.find_last_not_of( " \t\r\n" ) + 1 );
+ line.erase( 0, line.find_first_not_of( " \t\r\n" ) );
+ if( '#' == *( line.cbegin() ) || line == "" )
+ {
+ continue;
+ }
- if( !mIsMultipleWindowSupportedCached &&
- RetrieveKeyFromConfigFile( stream, DALI_ENV_MULTIPLE_WINDOW_SUPPORT, value ) )
- {
- mIsMultipleWindowSupported = std::atoi( value.c_str() );
- mIsMultipleWindowSupportedCached = true;
+ std::istringstream subStream(line);
+ std::string name;
+ std::string value;
+ std::getline(subStream, name, ' ');
+ if(!mMaxTextureSizeCached && name == DALI_ENV_MAX_TEXTURE_SIZE)
+ {
+ std::getline(subStream, value);
+ mMaxTextureSize = std::atoi(value.c_str());
+ mMaxTextureSizeCached = true;
+ }
+ else if(!mIsAdvancedBlendEquationSupportedCached && name == DALI_BLEND_EQUATION_ADVANCED_SUPPORT)
+ {
+ std::getline(subStream, value);
+ mIsAdvancedBlendEquationSupported = std::atoi(value.c_str());
+ mIsAdvancedBlendEquationSupportedCached = true;
+ }
+ else if(!mShaderLanguageVersionCached && name == DALI_GLSL_VERSION)
+ {
+ std::getline(subStream, value);
+ mShaderLanguageVersion = std::atoi(value.c_str());
+ mShaderLanguageVersionCached = true;
+ }
+ else if(!mIsMultipleWindowSupportedCached && name == DALI_ENV_MULTIPLE_WINDOW_SUPPORT)
+ {
+ std::getline(subStream, value);
+ mIsMultipleWindowSupported = std::atoi(value.c_str());
+ mIsMultipleWindowSupportedCached = true;
+ }
}
}
}
-unsigned int ConfigurationManager::GetMaxTextureSize()
+uint32_t ConfigurationManager::GetMaxTextureSize()
{
- if( !mMaxTextureSizeCached )
+ if(!mMaxTextureSizeCached)
{
- RetrieveKeysFromConfigFile( mSystemCacheFilePath );
+ RetrieveKeysFromConfigFile(mSystemCacheFilePath);
- if( !mMaxTextureSizeCached )
+ if(!mMaxTextureSizeCached)
{
- GlImplementation& mGLES = mEglGraphics->GetGlesInterface();
- mMaxTextureSize = mGLES.GetMaxTextureSize();
+ mMaxTextureSize = mGraphics->GetMaxTextureSize();
mMaxTextureSizeCached = 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() )
+ 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_ENV_MAX_TEXTURE_SIZE << " " << mMaxTextureSize << std::endl;
}
else
{
- DALI_LOG_ERROR( "Fail to open file : %s\n", mSystemCacheFilePath.c_str() );
+ DALI_LOG_ERROR("Fail to open file : %s\n", mSystemCacheFilePath.c_str());
}
}
}
return mMaxTextureSize;
}
+uint32_t ConfigurationManager::GetShadingLanguageVersion()
+{
+ if(!mShaderLanguageVersionCached)
+ {
+ RetrieveKeysFromConfigFile(mSystemCacheFilePath);
+
+ if(!mShaderLanguageVersionCached)
+ {
+ if(!mGraphics->IsInitialized())
+ {
+ // Wait until Graphics Subsystem is initialised, but this will happen once.
+ // This method blocks until the render thread has initialised the graphics.
+ mThreadController->WaitForGraphicsInitialization();
+ }
+
+ // Query from graphics and save the cache
+ mShaderLanguageVersion = mGraphics->GetShaderLanguageVersion();
+ mShaderLanguageVersionCached = 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 << " " << mShaderLanguageVersion << std::endl;
+ }
+ else
+ {
+ DALI_LOG_ERROR("Fail to open file : %s\n", mSystemCacheFilePath.c_str());
+ }
+ }
+ }
+
+ return mShaderLanguageVersion;
+}
+
bool ConfigurationManager::IsMultipleWindowSupported()
{
- if ( !mIsMultipleWindowSupportedCached )
+ if(!mIsMultipleWindowSupportedCached)
{
- RetrieveKeysFromConfigFile( mSystemCacheFilePath );
+ RetrieveKeysFromConfigFile(mSystemCacheFilePath);
- if ( !mIsMultipleWindowSupportedCached )
+ if(!mIsMultipleWindowSupportedCached)
{
- EglImplementation& eglImpl = mEglGraphics->GetEglImplementation();
- if ( !eglImpl.IsGlesInitialized() )
+ if(!mGraphics->IsInitialized())
{
- // Wait until GLES is initialised, but this will happen once.
+ // Wait until Graphics Subsystem 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
- mIsMultipleWindowSupported = eglImpl.IsSurfacelessContextSupported();
+ // Query from Graphics Subsystem and save the cache
+ mIsMultipleWindowSupported = mGraphics->IsResourceContextSupported();
mIsMultipleWindowSupportedCached = 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() )
+ 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_ENV_MULTIPLE_WINDOW_SUPPORT << " " << mIsMultipleWindowSupported << std::endl;
}
else
{
- DALI_LOG_ERROR( "Fail to open file : %s\n", mSystemCacheFilePath.c_str() );
+ DALI_LOG_ERROR("Fail to open file : %s\n", mSystemCacheFilePath.c_str());
}
}
}
return mIsMultipleWindowSupported;
}
-} // Adaptor
+bool ConfigurationManager::IsAdvancedBlendEquationSupported()
+{
+ if(!mIsAdvancedBlendEquationSupportedCached)
+ {
+ RetrieveKeysFromConfigFile(mSystemCacheFilePath);
+
+ if(!mIsAdvancedBlendEquationSupportedCached)
+ {
+ if(!mGraphics->IsInitialized())
+ {
+ // Wait until graphics subsystem is initialised, but this will happen once per factory reset.
+ // This method blocks until the render thread has initialised the graphics.
+ mThreadController->WaitForGraphicsInitialization();
+ }
+
+ // Query from Graphics Subsystem and save the cache
+ mIsAdvancedBlendEquationSupported = mGraphics->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;
+}
+
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali