X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fpublic-api%2Fshader-effects%2Fbubble-effect%2Fbubble-effect.cpp;h=2a4f0436e3e126d3c25ea5e894def4373adff8ef;hp=71e7f05e4d0bf6cd0b1598ba3385dd2a227c58a3;hb=b1794535bb9e63b0706dcbd92af82a13962b51c4;hpb=e2eda444afbe82e9591fe198eef339227f90a616 diff --git a/dali-toolkit/public-api/shader-effects/bubble-effect/bubble-effect.cpp b/dali-toolkit/public-api/shader-effects/bubble-effect/bubble-effect.cpp index 71e7f05..2a4f043 100644 --- a/dali-toolkit/public-api/shader-effects/bubble-effect/bubble-effect.cpp +++ b/dali-toolkit/public-api/shader-effects/bubble-effect/bubble-effect.cpp @@ -1,25 +1,28 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -// EXTERNAL HEADERS -#include +/* + * Copyright (c) 2015 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // CLASS HEADER #include "bubble-effect.h" +// EXTERNAL HEADERS +#include +#include +#include + namespace Dali { @@ -49,15 +52,14 @@ BubbleEffect::~BubbleEffect() { } -BubbleEffect BubbleEffect::New( unsigned int numberOfBubble, const std::string& shapeImagePath) +BubbleEffect BubbleEffect::New( unsigned int numberOfBubble) { std::ostringstream vertexShaderStringStream; vertexShaderStringStream << "#define NUMBER_OF_BUBBLE "<< numberOfBubble << "\n"; std::string vertexShader( + " precision mediump float;\n" // the gravity applied to the y direction " uniform float uGravity; \n" - // Width of the texture in pixels - " uniform float uShapeWidth; \n" // xy: the emit position of the bubble; zw: the destinationof the bubble. // The bubble is moving from (xy) to (zw plus the y drop influenced by gravity). " uniform vec4 uStartAndEndPos[NUMBER_OF_BUBBLE];\n" @@ -114,9 +116,7 @@ BubbleEffect BubbleEffect::New( unsigned int numberOfBubble, const std::string& " gl_Position = uMvpMatrix * position;\n" "\n" // Add multiple bubble shapes in the effect - " mediump float texCoordX = floor( mod(startAndEnd.z, uShapeWidth) );\n " - " mediump float texCoordY = floor( mod(startAndEnd.w, uShapeWidth) );\n " - " vTexCoord = vec2( (texCoordX + aTexCoord.x)/ uShapeWidth,(texCoordY + aTexCoord.y)/ uShapeWidth );\n" + " vTexCoord = aTexCoord;\n" " vPercentage = percentage;\n" // Use the emit position color for the bubble " vEffectTexCoord = startAndEnd.xy * uInvertedMovementArea;\n" @@ -124,6 +124,7 @@ BubbleEffect BubbleEffect::New( unsigned int numberOfBubble, const std::string& vertexShaderStringStream << vertexShader; std::string fragmentShader( + " precision mediump float;\n" " varying float vPercentage;\n" " varying vec2 vEffectTexCoord;\n" "\n" @@ -137,23 +138,21 @@ BubbleEffect BubbleEffect::New( unsigned int numberOfBubble, const std::string& " gl_FragColor = fragColor;\n" " }\n"); - ShaderEffect shaderEffect = ShaderEffect::New( vertexShaderStringStream.str(), fragmentShader, - GeometryType( GEOMETRY_TYPE_TEXTURED_MESH), - ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) ); + ShaderEffect shaderEffect = ShaderEffect::New( + vertexShaderStringStream.str(), + fragmentShader, + GeometryType( GEOMETRY_TYPE_TEXTURED_MESH), + ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) ); + BubbleEffect handle( shaderEffect ); handle.mNumberOfBubbles = numberOfBubble; handle.SetMovementArea( Stage::GetCurrent().GetSize() ); - handle.SetUniform( "uGravity", 50.f ); handle.SetUniform( "uMagnification", 1.f ); handle.SetUniform( "uDynamicScale", 1.f ); - //Get pixel width of the shape - float width = Image::GetImageSize(shapeImagePath).width; - handle.SetUniform( "uShapeWidth", (width/EACH_WIDTH_PER_SHAPE) ); - Vector4 zeroVector; for( unsigned int i=0; i