X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fshader-effects%2Falpha-discard-effect.h;h=cc69acfdb0666b1d8079e0d125ce4464e53e608b;hb=8b9e1eb2a98b0cbfb30286e097fc03e9c5e6410d;hp=c96f143fa5b618216116b48275878cbe925eb41a;hpb=f58b8383147de70affa1e3949cf1c6757d705d3c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h b/dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h index c96f143..cc69acf 100644 --- a/dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h +++ b/dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_ALPHA_DISCARD_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. @@ -19,7 +19,10 @@ */ // EXTERNAL INCLUDES -#include +#include + +// INTERNAL INCLUDES +#include namespace Dali { @@ -28,41 +31,44 @@ namespace Toolkit { /** + * @brief Creates a new Alpha discard effect + * * Alpha discard effect is used to discard fragments when the alpha colour value is below a threshold. * This is useful for stenciling. * * Usage example: * - * ImageActor actor = ImageActor::New( Image( EXAMPLE_IMAGE_PATH ) ); - * AlphaDiscardEffect alphaDiscardEffect = AlphaDiscardEffect::New(); - * actor.SetShaderEffect( alphaDiscardEffect ); + * ImageView actor = ImageView::New( EXAMPLE_IMAGE_PATH ); + * Property::Map alphaDiscardEffect = CreateAlphaDiscardEffect(); + * actor.SetProperty( ImageView::Property::IMAGE, alphaDiscardEffect ); + * + * @return A property map of the required shaders. */ -class DALI_IMPORT_API AlphaDiscardEffect : public ShaderEffect +inline Property::Map CreateAlphaDiscardEffect() { -public: - - /** - * Create an empty AlphaDiscardEffect handle. - */ - AlphaDiscardEffect(); - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~AlphaDiscardEffect(); + const char* ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE = + "varying mediump vec2 vTexCoord; \n" + " \n" + "uniform sampler2D sTexture; \n" + "uniform lowp vec4 uColor; \n" + "void main() \n" + "{ \n" + " mediump vec4 color = texture2D( sTexture, vTexCoord ); \n" + " if(color.a <= 0.0001) \n" + " { \n" + " discard; \n" + " } \n" + " gl_FragColor = color * uColor; \n" + "} \n"; - /** - * Create a AlphaDiscardEffect. - * @return A handle to a newly allocated AlphaDiscardEffect. - */ - static AlphaDiscardEffect New(); + Property::Map map; -private: // Not intended for application developers + Property::Map customShader; + customShader[ Visual::Shader::Property::FRAGMENT_SHADER ] = ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE; - DALI_INTERNAL AlphaDiscardEffect( ShaderEffect handle ); -}; + map[ Visual::Property::SHADER ] = customShader; + return map; +} } // namespace Toolkit