X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-base-data-impl.cpp;h=f539dd6650f386823bc5aab5f5ef0700e17d8c1c;hb=2c2f52b1e6f532312359afbf5910a44943bbb87b;hp=8e610f17947da804317b97e130d47f47e5ef1bdd;hpb=99e2ea03e6d6059f5803d700932df1ff1c848cd3;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/visual-base-data-impl.cpp b/dali-toolkit/internal/visuals/visual-base-data-impl.cpp index 8e610f1..f539dd6 100644 --- a/dali-toolkit/internal/visuals/visual-base-data-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-base-data-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -20,8 +20,13 @@ // EXTERNAL INCLUDES #include +#include +#include #include -#include + +// INTERNAL INCLUDES +#include +#include namespace Dali { @@ -34,44 +39,14 @@ namespace Internal namespace { -//custom shader -const char * const CUSTOM_SHADER( "shader" ); -const char * const CUSTOM_VERTEX_SHADER( "vertexShader" ); -const char * const CUSTOM_FRAGMENT_SHADER( "fragmentShader" ); -const char * const CUSTOM_SUBDIVIDE_GRID_X( "subdivideGridX" ); -const char * const CUSTOM_SUBDIVIDE_GRID_Y( "subdivideGridY" ); -const char * const CUSTOM_SHADER_HINTS( "hints" ); ///< type STRING for a hint from the below hint strings or an ARRAY of of hint strings - -/** - * where hints should be contain strings of the following shader hints: - * "none" | corresponds to Shader::Hint::NONE - * "outputIsTransparent" | corresponds to Shader::Hint::OUTPUT_IS_TRANSPARENT - * "modifiesGeometry" | corresponds to Shader::Hint::MODIFIES_GEOMETRY - */ -Shader::Hint::Value HintFromString( std::string hintString ) -{ - if( hintString == "none" ) - { - return Shader::Hint::NONE; - } - else if( hintString == "outputIsTransparent" ) - { - return Shader::Hint::OUTPUT_IS_TRANSPARENT; - } - else if( hintString == "modifiesGeometry" ) - { - return Shader::Hint::MODIFIES_GEOMETRY; - } - else - { - DALI_LOG_ERROR( "'%s' hint string is not recognised", hintString.c_str() ); - } - - return Shader::Hint::NONE; -} +DALI_ENUM_TO_STRING_TABLE_BEGIN( SHADER_HINT ) +DALI_ENUM_TO_STRING_WITH_SCOPE( Shader::Hint, NONE ) +DALI_ENUM_TO_STRING_WITH_SCOPE( Shader::Hint, OUTPUT_IS_TRANSPARENT ) +DALI_ENUM_TO_STRING_WITH_SCOPE( Shader::Hint, MODIFIES_GEOMETRY ) +DALI_ENUM_TO_STRING_TABLE_END( SHADER_HINT ) -}// unnamed namespace +} // unnamed namespace Internal::Visual::Base::Impl::Impl() : mCustomShader(NULL), @@ -99,31 +74,31 @@ void Internal::Visual::Base::Impl::CustomShader::SetPropertyMap( const Property: mGridSize = ImageDimensions( 1, 1 ); mHints = Shader::Hint::NONE; - Property::Value* vertexShaderValue = shaderMap.Find( CUSTOM_VERTEX_SHADER ); + Property::Value* vertexShaderValue = shaderMap.Find( Toolkit::Visual::Shader::Property::VERTEX_SHADER, CUSTOM_VERTEX_SHADER ); if( vertexShaderValue ) { if( !vertexShaderValue->Get( mVertexShader ) ) { - DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_VERTEX_SHADER ); + DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string\n", CUSTOM_VERTEX_SHADER ); } } - Property::Value* fragmentShaderValue = shaderMap.Find( CUSTOM_FRAGMENT_SHADER ); + Property::Value* fragmentShaderValue = shaderMap.Find( Toolkit::Visual::Shader::Property::FRAGMENT_SHADER, CUSTOM_FRAGMENT_SHADER ); if( fragmentShaderValue ) { if( !fragmentShaderValue->Get( mFragmentShader ) ) { - DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_FRAGMENT_SHADER ); + DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string\n", CUSTOM_FRAGMENT_SHADER ); } } - Property::Value* subdivideXValue = shaderMap.Find( CUSTOM_SUBDIVIDE_GRID_X ); + Property::Value* subdivideXValue = shaderMap.Find( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X, CUSTOM_SUBDIVIDE_GRID_X ); if( subdivideXValue ) { int subdivideX; if( !subdivideXValue->Get( subdivideX ) || subdivideX < 1 ) { - DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_X ); + DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1\n", CUSTOM_SUBDIVIDE_GRID_X ); } else { @@ -131,13 +106,13 @@ void Internal::Visual::Base::Impl::CustomShader::SetPropertyMap( const Property: } } - Property::Value* subdivideYValue = shaderMap.Find( CUSTOM_SUBDIVIDE_GRID_Y ); + Property::Value* subdivideYValue = shaderMap.Find( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y, CUSTOM_SUBDIVIDE_GRID_Y ); if( subdivideYValue ) { int subdivideY; if( !subdivideYValue->Get( subdivideY ) || subdivideY < 1 ) { - DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_Y ); + DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1\n", CUSTOM_SUBDIVIDE_GRID_Y ); } else { @@ -145,37 +120,12 @@ void Internal::Visual::Base::Impl::CustomShader::SetPropertyMap( const Property: } } - Property::Value* hintsValue = shaderMap.Find( CUSTOM_SHADER_HINTS ); + Property::Value* hintsValue = shaderMap.Find( Toolkit::Visual::Shader::Property::HINTS, CUSTOM_SHADER_HINTS ); if( hintsValue ) { - std::string hintString; - Property::Array hintsArray; - - if( hintsValue->Get( hintString ) ) - { - mHints = HintFromString( hintString ); - } - else if( hintsValue->Get( hintsArray ) ) - { - int hints = Shader::Hint::NONE; - for( Property::Array::SizeType i = 0; i < hintsArray.Count(); ++i) - { - Property::Value hintValue = hintsArray[ i ]; - if( hintValue.Get( hintString ) ) - { - hints |= static_cast< int >( HintFromString( hintString ) ); - } - else - { - DALI_LOG_ERROR( "'%s' parameter does not correctly specify an hint string at index %d", CUSTOM_SHADER_HINTS, i ); - } - - mHints = static_cast< Shader::Hint::Value >( hints ); - } - } - else + if ( ! Scripting::GetBitmaskEnumerationProperty( *hintsValue, SHADER_HINT_TABLE, SHADER_HINT_TABLE_COUNT, mHints ) ) { - DALI_LOG_ERROR( "'%s' parameter does not correctly specify a hint string or an array of hint strings", CUSTOM_SHADER_HINTS ); + DALI_LOG_ERROR( "'%s' parameter does not correctly specify a hint or an array of hint strings\n", CUSTOM_SHADER_HINTS ); } } } @@ -187,28 +137,28 @@ void Internal::Visual::Base::Impl::CustomShader::CreatePropertyMap( Property::Ma Property::Map customShader; if( !mVertexShader.empty() ) { - customShader.Insert(CUSTOM_VERTEX_SHADER, mVertexShader ); + customShader.Insert( Toolkit::Visual::Shader::Property::VERTEX_SHADER, mVertexShader ); } if( !mFragmentShader.empty() ) { - customShader.Insert(CUSTOM_FRAGMENT_SHADER, mFragmentShader ); + customShader.Insert( Toolkit::Visual::Shader::Property::FRAGMENT_SHADER, mFragmentShader ); } if( mGridSize.GetWidth() != 1 ) { - customShader.Insert(CUSTOM_SUBDIVIDE_GRID_X, mGridSize.GetWidth() ); + customShader.Insert( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X, mGridSize.GetWidth() ); } if( mGridSize.GetHeight() != 1 ) { - customShader.Insert(CUSTOM_SUBDIVIDE_GRID_Y, mGridSize.GetHeight() ); + customShader.Insert( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y, mGridSize.GetHeight() ); } if( mHints != Dali::Shader::Hint::NONE ) { - customShader.Insert(CUSTOM_SHADER_HINTS, static_cast< int >(mHints) ); + customShader.Insert( Toolkit::Visual::Shader::Property::HINTS, static_cast< int >( mHints ) ); } - map.Insert( CUSTOM_SHADER, customShader ); + map.Insert( Toolkit::Visual::Property::SHADER, customShader ); } }