#define __DALI_TOOLKIT_MASK_EFFECT_H__
/*
- * 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.
// EXTERNAL INCLUDES
#include <dali/public-api/images/image.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/devel-api/shader-effects/shader-effect.h>
namespace Dali
{
{
/**
- * @brief MaskEffect is used to control which parts of an image are visible, using the alpha channel of a separate mask image.
+ * @brief Creates a new MaskEffect
+ *
+ * MaskEffect is used to control which parts of an image are visible, using the alpha channel of a separate mask image.
*
* Typically mask images should be the same size as the main image being viewed, but this isn't essential.
*
* Usage example:
*
* ImageActor actor = ImageActor::New( Image( EXAMPLE_IMAGE_PATH ) );
- * MaskEffect maskEffect = MaskEffect::New( Image::New( MASK_IMAGE_PATH ) );
+ * ShaderEffect maskEffect = CreateMaskEffect( Image::New( MASK_IMAGE_PATH ) );
* actor.SetShaderEffect( maskEffect );
+ *
+ * @param[in] maskImage The image to use as a mask
+ * @return A handle to a newly allocated ShaderEffect
*/
-class DALI_IMPORT_API MaskEffect : public ShaderEffect
+inline ShaderEffect CreateMaskEffect(Image maskImage)
{
-public:
-
- /**
- * @brief Create an empty MaskEffect handle.
- */
- MaskEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~MaskEffect();
+ const char* ALPHA_MASK_FRAGMENT_SHADER_SOURCE =
+ "void main() \n"
+ "{ \n"
+ " highp vec4 mask = texture2D(sEffect, vTexCoord); \n"
+ " gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(1,1,1,mask.a); \n"
+ "} \n";
- /**
- * @brief Create a MaskEffect.
- *
- * @param[in] maskImage The image to use as a mask
- * @return A handle to a newly allocated MaskEffect.
- */
- static MaskEffect New( Image maskImage );
+ ShaderEffect shaderEffect = ShaderEffect::New(
+ "", // Use default
+ ALPHA_MASK_FRAGMENT_SHADER_SOURCE,
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
-private: // Not intended for application developers
+ shaderEffect.SetEffectImage( maskImage );
- DALI_INTERNAL MaskEffect( ShaderEffect handle );
-};
+ return shaderEffect;
+}
} // namespace Toolkit