2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali-toolkit/public-api/shader-effects/blind-effect.h>
29 const std::string STEP_PROPERTY_NAME( "uStep" );
33 BlindEffect::BlindEffect()
37 //Call the Parent copy constructor to add reference to the implementation for this object
38 BlindEffect::BlindEffect(ShaderEffect handle)
43 BlindEffect::~BlindEffect()
48 BlindEffect BlindEffect::New()
50 std::string fragmentShader(
51 "uniform mediump float uStep; \n"
54 " mediump vec4 alphaColor; \n"
55 " mediump vec4 baseColor; \n"
56 " baseColor = texture2D( sTexture, vTexCoord); \n"
57 " alphaColor = vec4(0.1,0.1,0.1,1.0); \n"
58 " lowp float index = 0.0; \n"
59 " index = floor(vTexCoord.y/0.1); \n"
60 " if((vTexCoord.y < (index * 0.1 + uStep * 0.005)) && (vTexCoord.y > index * 0.1))\n"
62 " gl_FragColor = alphaColor; \n"
66 " gl_FragColor = baseColor; \n"
68 " gl_FragColor*=uColor; \n"
72 Dali::ShaderEffect shaderEffectCustom = Dali::ShaderEffect::New(
75 Dali::GeometryType( GEOMETRY_TYPE_IMAGE ),
76 ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ));
78 Dali::Toolkit::BlindEffect handle( shaderEffectCustom );
80 handle.SetUniform( STEP_PROPERTY_NAME, 0.0f );
85 void BlindEffect::SetStep(float step)
87 SetUniform( STEP_PROPERTY_NAME, step );
90 const std::string& BlindEffect::GetStepPropertyName() const
92 return STEP_PROPERTY_NAME;
95 } // namespace Toolkit