X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbubble-effect%2Fcolor-adjuster.h;h=3f1afb8a4afe586c77288b492fa7c4d5bf08f314;hb=ec503e92aa01bc67f8ea118cf14aa3b1ed9d390e;hp=c48dfe76a4470d71503c113948ffa2f5ca33f8d2;hpb=bfdf7a73a4d50dfb60d0f7fa5b214f61c920bf9c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/bubble-effect/color-adjuster.h b/dali-toolkit/internal/controls/bubble-effect/color-adjuster.h index c48dfe7..3f1afb8 100644 --- a/dali-toolkit/internal/controls/bubble-effect/color-adjuster.h +++ b/dali-toolkit/internal/controls/bubble-effect/color-adjuster.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H_ -#define __DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H_ +#ifndef DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H +#define DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -17,24 +17,25 @@ * limitations under the License. * */ + +// EXTERNAL INCLUDES #include #include -#define DALI_COMPOSE_SHADER(STR) #STR +// INTERNAL INCLUDES +#include +#include namespace Dali { - namespace Toolkit { - namespace Internal { - -inline void SetColorAdjusterProperties( Actor& actor, const Vector3& hsvDelta, bool ignoreAlpha = false ) +inline void SetColorAdjusterProperties(Actor& actor, const Vector3& hsvDelta, bool ignoreAlpha = false) { - actor.RegisterProperty( "uHSVDelta", hsvDelta ); - actor.RegisterProperty( "uIgnoreAlpha", ignoreAlpha ? 1.f : 0.f ); + actor.RegisterProperty("uHSVDelta", hsvDelta); + actor.RegisterProperty("uIgnoreAlpha", ignoreAlpha ? 1.f : 0.f); } /** @@ -46,53 +47,11 @@ inline void SetColorAdjusterProperties( Actor& actor, const Vector3& hsvDelta, b */ inline Property::Map CreateColorAdjuster() { - std::string fragmentShader = DALI_COMPOSE_SHADER( - precision highp float;\n - uniform vec3 uHSVDelta;\n - uniform float uIgnoreAlpha;\n - varying mediump vec2 vTexCoord;\n - uniform sampler2D sTexture;\n - float rand(vec2 co) \n - {\n - return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n} - \n - vec3 rgb2hsv(vec3 c)\n - {\n - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n - \n - float d = q.x - min(q.w, q.y);\n - float e = 1.0e-10;\n - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n - }\n - vec3 hsv2rgb(vec3 c)\n - {\n - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n - }\n - void main() {\n - vec4 color = texture2D(sTexture, vTexCoord); \n - vec3 hsvColor = rgb2hsv( color.rgb );\n - // modify the hsv Value - hsvColor += uHSVDelta * rand(vTexCoord); \n - // if the new vale exceeds one, then decrease it - hsvColor -= max(hsvColor*2.0 - vec3(2.0), 0.0);\n - // if the new vale drops below zero, then increase it - hsvColor -= min(hsvColor*2.0, 0.0);\n - color.rgb = hsv2rgb( hsvColor ); \n - // uIgnoreAlpha decide the result alpha will be 1.0 or source's alpha - color.a += uIgnoreAlpha;\n - gl_FragColor = color; \n - }\n - ); - Property::Map customShader; - customShader[ "fragmentShader" ] = fragmentShader; + customShader[Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = SHADER_BUBBLE_EFFECT_COLOR_ADJUSTER_FRAG.data(); Property::Map map; - map[ "shader" ] = customShader; + map[Toolkit::Visual::Property::SHADER] = customShader; return map; } @@ -103,4 +62,4 @@ inline Property::Map CreateColorAdjuster() } // namespace Dali -#endif /* __DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H_ */ +#endif // DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H