1 #ifndef __DALI_TOOLKIT_MASK_EFFECT_H__
2 #define __DALI_TOOLKIT_MASK_EFFECT_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/images/image.h>
23 #include <dali/public-api/shader-effects/shader-effect.h>
32 * @brief Creates a new MaskEffect
34 * MaskEffect is used to control which parts of an image are visible, using the alpha channel of a separate mask image.
36 * Typically mask images should be the same size as the main image being viewed, but this isn't essential.
40 * ImageActor actor = ImageActor::New( Image( EXAMPLE_IMAGE_PATH ) );
41 * ShaderEffect maskEffect = CreateMaskEffect( Image::New( MASK_IMAGE_PATH ) );
42 * actor.SetShaderEffect( maskEffect );
44 * @param[in] maskImage The image to use as a mask
45 * @return A handle to a newly allocated ShaderEffect
47 inline ShaderEffect CreateMaskEffect(Image maskImage)
49 const char* ALPHA_MASK_FRAGMENT_SHADER_SOURCE =
52 " highp vec4 mask = texture2D(sEffect, vTexCoord); \n"
53 " gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(1,1,1,mask.a); \n"
56 ShaderEffect shaderEffect = ShaderEffect::New(
58 ALPHA_MASK_FRAGMENT_SHADER_SOURCE,
59 ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
61 shaderEffect.SetEffectImage( maskImage );
66 } // namespace Toolkit
70 #endif // __DALI_TOOLKIT_MASK_EFFECT_H__