X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fshader-effects%2Fdissolve-local-effect.h;h=a5097959fca7aca55bbabae5651d6e4e83a57bb4;hp=f140eeed10f83ed337d1fa9eda25d14a04967fc9;hb=1c5674a11a51310ee689d6daf4e6b7d94dec607e;hpb=5f6e04b26996da4c06716ce044bdfdb0e7e2e61b diff --git a/dali-toolkit/devel-api/shader-effects/dissolve-local-effect.h b/dali-toolkit/devel-api/shader-effects/dissolve-local-effect.h index f140eee..a509795 100644 --- a/dali-toolkit/devel-api/shader-effects/dissolve-local-effect.h +++ b/dali-toolkit/devel-api/shader-effects/dissolve-local-effect.h @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include namespace Dali { @@ -28,102 +29,89 @@ namespace Toolkit { /** + * @brief Create a new DissolveLocalEffect + * * DissolveLocalEffect is a custom shader effect to achieve Dissolve effects in multiple small areas of Image actors + * + * Animatable/Constrainable uniforms: + * "uTransparency" + * "uCenter" - The center positions of each dimples + * "uRadius" - The propagation radius of each dimple + * "uPercentage" - The distortion applied to the effect texture. A value of zero means no distortion + * + * @param[in] numberOfDimples The number of dimples + * @return A handle to a newly allocated ShaderEffect */ -class DALI_IMPORT_API DissolveLocalEffect : public ShaderEffect +inline ShaderEffect CreateDissolveLocalEffect( unsigned int numberOfDimples ) { -public: - - /** - * Create an uninitialized DissolveLocalEffect; this can be initialized with DissolveLocalEffect::New() - * Calling member functions with an uninitialized Dali::Object is not allowed. - */ - DissolveLocalEffect(); - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~DissolveLocalEffect(); - - /** - * Create an initialized DissolveLocalEffect. - * @param[in] numberOfDimples The number of dimples - * @return A handle to a newly allocated Dali resource. - */ - static DissolveLocalEffect New( unsigned int numberOfDimples ); - - /** - * Get the number of dimples the shader supports. - * @return The number of dimples in the shader. - */ - unsigned int GetNumberOfDimples() const; - - /** - * Set the transparency of the drifted pixels. - * @param[in] transparency The transparency of the drifted pixels. - */ - void SetTransparency( float transparency); - - /** - * Set the certer position of a dimple. - * @param[in] index The index of the dimple to change. - * @param[in] center The center position of the dimple. - * @pre index has to be between 0 and GetNumberOfDimples() - 1 - */ - void SetCenter( unsigned int index, const Vector2& center ); - - /** - * Set the propogation radius of a dimple. - * @param[in] index The index of the dimple to change. - * @param[in] radius The propagation radius of the dimple. - * @pre index has to be between 0 and GetNumberOfDimples() - 1 - */ - void SetRadius( unsigned int index, float radius ); - - /** - * Sets the distortion applied to the effect texture. - * This value is proportional to the distortion applied; a value of zero means no distortion. - * @param[in] index The index of the dimple to change. - * @param[in] distortion The distortion value. - * @pre index has to be between 0 and GetNumberOfDimples() - 1 - */ - void SetDistortion( unsigned int index, float distortion ); - - /** - * Get the name of the center property of a dimple. - * @param[in] index The index of the dimple. - * @return A std::string containing the property name. - * @pre index has to be between 0 and GetNumberOfDimples() - 1 - */ - std::string GetCenterPropertyName( unsigned int index ) const; - - /** - * Get the name of the radius property of a dimple. - * @param[in] index The index of the dimple. - * @return A std::string containing the property name - * @pre index has to be between 0 and GetNumberOfDimples() - 1 - */ - std::string GetRadiusPropertyName( unsigned int index ) const; - - /** - * Get the name for the distortion property of a dimple - * @param[in] index the index of a dimple. - * @return A std::string containing the property name - * @pre index has to be between 0 and GetNumberOfDimples() - 1 - */ - std::string GetDistortionPropertyName( unsigned int index ) const; - -private: // Not intended for application developers - - DALI_INTERNAL DissolveLocalEffect( ShaderEffect handle ); - -private: - - unsigned int mNumberOfDimples; ///< The number of dimples the shader supports - -}; + std::ostringstream vertexShaderStringStream; + vertexShaderStringStream << "#define NUMBER_OF_DIMPLE "<< numberOfDimples << "\n"; + std::string vertexShader( + "precision highp float;\n" + "uniform vec2 uCenter[ NUMBER_OF_DIMPLE ];\n" + "uniform float uRadius[ NUMBER_OF_DIMPLE ]; \n" + "uniform float uPercentage[ NUMBER_OF_DIMPLE ]; \n" + "varying float vPercentage;\n" + "void main()\n" + "{\n" + " vec4 position = uModelView * vec4( aPosition, 1.0 );\n" + " float percentage = 0.0;\n" + " for( int i=0; i