X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fgradient%2Fgradient-visual.cpp;h=b86f9a7950d70586e20ac48446cd08ea8ef7b443;hb=3b0dbb53f9e300e1dfc642d7040cf955b9c4b064;hp=d5af5a4f08d7d5d5fd34341b672ffc4f2b96d0b0;hpb=3e429d522301e97a4333153145d56b9a127d89e8;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp b/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp index d5af5a4..b86f9a7 100644 --- a/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp +++ b/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp @@ -25,6 +25,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -88,14 +89,14 @@ const char* VERTEX_SHADER[] = DALI_COMPOSE_SHADER( attribute mediump vec2 aPosition;\n uniform highp mat4 uMvpMatrix;\n - uniform mediump vec3 uSize;\n + uniform highp vec3 uSize;\n uniform mediump mat3 uAlignmentMatrix;\n varying mediump vec2 vTexCoord;\n \n //Visual size and offset uniform mediump vec2 offset;\n - uniform mediump vec2 size;\n + uniform highp vec2 size;\n uniform mediump vec4 offsetSizeMode;\n uniform mediump vec2 origin;\n uniform mediump vec2 anchorPoint;\n @@ -120,14 +121,14 @@ DALI_COMPOSE_SHADER( DALI_COMPOSE_SHADER( attribute mediump vec2 aPosition;\n uniform highp mat4 uMvpMatrix;\n - uniform mediump vec3 uSize;\n + uniform highp vec3 uSize;\n uniform mediump mat3 uAlignmentMatrix;\n varying mediump vec2 vTexCoord;\n \n //Visual size and offset uniform mediump vec2 offset;\n - uniform mediump vec2 size;\n + uniform highp vec2 size;\n uniform mediump vec4 offsetSizeMode;\n uniform mediump vec2 origin;\n uniform mediump vec2 anchorPoint;\n @@ -153,7 +154,7 @@ DALI_COMPOSE_SHADER( DALI_COMPOSE_SHADER( attribute mediump vec2 aPosition;\n uniform highp mat4 uMvpMatrix;\n - uniform mediump vec3 uSize;\n + uniform highp vec3 uSize;\n uniform mediump mat3 uAlignmentMatrix;\n varying mediump vec2 vTexCoord;\n varying mediump vec2 vPosition;\n @@ -162,7 +163,7 @@ DALI_COMPOSE_SHADER( \n //Visual size and offset uniform mediump vec2 offset;\n - uniform mediump vec2 size;\n + uniform highp vec2 size;\n uniform mediump vec4 offsetSizeMode;\n uniform mediump vec2 origin;\n uniform mediump vec2 anchorPoint;\n @@ -194,7 +195,7 @@ DALI_COMPOSE_SHADER( DALI_COMPOSE_SHADER( attribute mediump vec2 aPosition;\n uniform highp mat4 uMvpMatrix;\n - uniform mediump vec3 uSize;\n + uniform highp vec3 uSize;\n uniform mediump mat3 uAlignmentMatrix;\n varying mediump vec2 vTexCoord;\n varying mediump vec2 vPosition;\n @@ -203,7 +204,7 @@ DALI_COMPOSE_SHADER( \n //Visual size and offset uniform mediump vec2 offset;\n - uniform mediump vec2 size;\n + uniform highp vec2 size;\n uniform mediump vec4 offsetSizeMode;\n uniform mediump vec2 origin;\n uniform mediump vec2 anchorPoint;\n @@ -384,6 +385,15 @@ void GradientVisual::DoSetOnScene( Actor& actor ) ResourceReady( Toolkit::Visual::ResourceStatus::READY ); } +void GradientVisual::UpdateShader() +{ + if(mImpl->mRenderer) + { + Shader shader = GetShader(); + mImpl->mRenderer.SetShader(shader); + } +} + void GradientVisual::DoCreatePropertyMap( Property::Map& map ) const { map.Clear(); @@ -435,16 +445,7 @@ void GradientVisual::DoCreateInstancePropertyMap( Property::Map& map ) const void GradientVisual::InitializeRenderer() { Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY ); - - Toolkit::GradientVisual::Units::Type gradientUnits = mGradient->GetGradientUnits(); - int roundedCorner = IsRoundedCornerRequired() ? 1 : 0; - VisualFactoryCache::ShaderType shaderType = SHADER_TYPE_TABLE[mGradientType][gradientUnits + roundedCorner * 2]; - Shader shader = mFactoryCache.GetShader( shaderType ); - if( !shader ) - { - shader = Shader::New( VERTEX_SHADER[gradientUnits + roundedCorner * 2], FRAGMENT_SHADER[ mGradientType + roundedCorner * 2 ] ); - mFactoryCache.SaveShader( shaderType, shader ); - } + Shader shader = GetShader(); //Set up the texture set TextureSet textureSet = TextureSet::New(); @@ -458,7 +459,7 @@ void GradientVisual::InitializeRenderer() mImpl->mRenderer = Renderer::New( geometry, shader ); mImpl->mRenderer.SetTextures( textureSet ); - // If opaque then no need to have blending + // If opaque and then no need to have blending if( mIsOpaque ) { mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF ); @@ -553,6 +554,21 @@ bool GradientVisual::NewGradient(Type gradientType, const Property::Map& propert return true; } +Shader GradientVisual::GetShader() +{ + Toolkit::GradientVisual::Units::Type gradientUnits = mGradient->GetGradientUnits(); + int roundedCorner = IsRoundedCornerRequired() ? 1 : 0; + VisualFactoryCache::ShaderType shaderType = SHADER_TYPE_TABLE[mGradientType][gradientUnits + roundedCorner * 2]; + Shader shader = mFactoryCache.GetShader(shaderType); + if(!shader) + { + shader = Shader::New(VERTEX_SHADER[gradientUnits + roundedCorner * 2], FRAGMENT_SHADER[mGradientType + roundedCorner * 2]); + mFactoryCache.SaveShader(shaderType, shader); + } + + return shader; +} + void GradientVisual::GetStopOffsets(const Property::Value* value, Vector& stopOffsets) { @@ -589,7 +605,7 @@ void GradientVisual::GetStopOffsets(const Property::Value* value, Vector& } case Property::ARRAY: { - Property::Array* offsetArray = value->GetArray(); + const Property::Array* offsetArray = value->GetArray(); if( offsetArray ) { unsigned int numStop = offsetArray->Count();