X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbubble-effect%2Fbubble-emitter-impl.h;h=fecbd85f7d493b509f12a0dff0512fd1dbaf539a;hp=5a42bc71c498e0fac23b6984de4ab4198b54f2e4;hb=7bc9bb47cb9c552982e9144b202861190eeadc96;hpb=e2eda444afbe82e9591fe198eef339227f90a616 diff --git a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.h b/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.h index 5a42bc7..fecbd85 100644 --- a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.h +++ b/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.h @@ -1,29 +1,37 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_BUBBLE_EMITTER_IMPL_H__ -#define __DALI_TOOLKIT_INTERNAL_BUBBLE_EMITTER_IMPL_H__ - -// -// 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. -// +#ifndef DALI_TOOLKIT_INTERNAL_BUBBLE_EMITTER_IMPL_H +#define DALI_TOOLKIT_INTERNAL_BUBBLE_EMITTER_IMPL_H + +/* + * 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. + * 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include +#include // INTERNAL INCLUDES -#include #include -#include -#include - -#include +#include namespace Dali { @@ -34,10 +42,13 @@ namespace Toolkit namespace Internal { +class BubbleActor; +typedef IntrusivePtr BubbleActorPtr; + /** * BubbleEmitter implementation class. */ -class BubbleEmitter : public ControlImpl +class BubbleEmitter : public Control { public: @@ -80,21 +91,11 @@ public: void SetBubbleDensity( unsigned int density ); /** - * @copydoc Toolkit::BubbleEmitter::SetBlendMode - */ - void SetBlendMode( bool enable ); - - /** * @copydoc Toolkit::BubbleEmitter::EmitBubble */ void EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement ); /** - * @copydoc Toolkit::BubbleEmitter::StartExplosion - */ - void StartExplosion( float duration, float multiple ); - - /** * @copydoc Toolkit::BubbleEmitter::Restore */ void Restore(); @@ -120,100 +121,58 @@ private: void OnInitialize(); /** - * Callback function of the finished signal of off-screen render task. - * @param[in] source The render task used to create the color adjusted background image. - */ - void OnRenderFinished(RenderTask& source); - - /** - * Generate the material object which is attached to the meshActor to describe its color, texture, texture mapping mode etc. - */ - void GenMaterial(); - - /** - * Add a vertex to the mesh data. - * @param[in] vertices The collection of vertices. - * @param[in] XYZ The vertex position coordinates. - * @param[in] UV The vertex texture coordinate. - */ - void AddVertex(MeshData::VertexContainer& vertices, Vector3 XYZ, Vector2 UV); - - /** - * Add a triangle to the mesh data. - * @param[in] faces The collection od FaceIndex items. - * @param[in] v0 The index of the first point of the triangle. - * @param[in] v1 The index of the second point of the triangle. - * @param[in] v3 The index of the first point of the triangle. + * Create the geometry of a mesh. + * @param[in] numOfPatch The triangle number in the mesh is 2*numOfPatch; two triangles for each bubble. + * @return The mesh geometry. */ - void AddTriangle(MeshData::FaceIndices& faces,size_t v0, size_t v1, size_t v2); + Geometry CreateGeometry( unsigned int numOfPatch ); /** - * Create a new mesh. - * @param[in] meshData The MeshData object which encompasses all the data required to describe and render the 3D mesh. - * @param[in] numberOfBubble The triangle number in the meshData is 2*numOfBubble; two triangles for each bubble + * Callback function of the finished signal of off-screen render task. + * @param[in] source The render task used to create the color adjusted background image. */ - void ConstructBubbleMesh( MeshData& meshData, unsigned int numOfBubble); + void OnRenderFinished(RenderTask& source); /** - * Set the uniform values to the shader effect to emit a bubble - * @param[in] effect The BubbleEffect to render the current bubble - * @param[in] curUniform The index of the uniform array in the shader - * @param[in] emitPosition The start position of the bubble movement. - * @param[in] displacement The displacement used to bound the moving distance of the bubble. + * Callback function from Stage to tell us if the context has been regained. */ - void SetBubbleParameter( BubbleEffect& effect, unsigned int curUniform, - const Vector2& emitPosition, const Vector2& displacement ); + void OnContextRegained(); /** * Set the uniform values to the shader effect to emit a bubble - * @param[in] effect The BubbleEffect to render the current bubble + * @param[in] bubbleActor The BubbleActor to render the current bubble * @param[in] curUniform The index of the uniform array in the shader * @param[in] emitPosition The start position of the bubble movement. * @param[in] direction The direction used to constrain the bubble to move in an adjacent direction around it. * @param[in] displacement The displacement used to bound the moving distance of the bubble. */ - void SetBubbleParameter( BubbleEffect& effect, unsigned int curUniform, + void SetBubbleParameter( BubbleActorPtr bubbleActor, unsigned int curUniform, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement ); - /** - * Callback function of the explosion animation finished signal to reset the shader parameters - * @param[in] source The explosion animation. - */ - void OnExplosionFinished( Animation& source ); - - /** - * Return a random value between the given interval. - * @param[in] f0 The low bound - * @param[in] f1 The up bound - * @return A random value between the given interval - */ - float RandomRange(float f0, float f1); - private: - Vector2 mMovementArea; ///< The size of the bubble moving area, usually the same size as the background image actor. - Image mShapeImage; ///< The alpha channnel of this texture defines the bubble shape. Actor mBubbleRoot; /// mMesh; ///< The mesh vector, each mesh is used to create a meshActor which applies a BubbleEffect. - std::vector mMeshActor; ///< The meshActor vector, its size is mNumShader. - MeshActor mMeshActorForNoise; ///< An Extra mesh data to emit bubbles which emit bubble in totally random angle. - Material mCustomMaterial; ///< The material object which is attached to the meshActor to describe its color, texture, texture mapping mode etc. - - std::vector mEffect; ///< The bubbleEffect vector, corresponding to the mMeshActoe vector. - BubbleEffect mEffectForNoise; ///< The extra bubbleEffect, corresponding to the mMeshActorForNoise. - - unsigned int mCurrentUniform; ///< Keep track of the uniform index for the newly emitted bubble - + Image mShapeImage; ///< The alpha channnel of this texture defines the bubble shape. + Image mBackgroundImage; ///< The original background image FrameBufferImage mEffectImage; ///< The image stores the adjusted color of the background image.The bubbles pick color from this image. CameraActor mCameraActor; ///< The render task views the scene from the perspective of this actor. + Geometry mMeshGeometry; ///< The mesh geometry which contains the vertices and indices data + TextureSet mTextureSet; ///< The texture set which controls the bubble display + std::vector mBubbleActors; ///< The meshActor vector, its size is mNumShader. + + Vector2 mMovementArea; ///< The size of the bubble moving area, usually the same size as the background. + Vector2 mBubbleSizeRange; ///< The size range of the bubbles; x component is the low bound, and y component is the up bound. + Vector3 mHSVDelta; ///< The HSV difference used to adjust the background image color. + + unsigned int mNumBubblePerActor; ///< How many bubbles for each BubbleActor. + unsigned int mNumActor; ///< How many BubbleActors are used. unsigned int mDensity; ///< How many bubbles will emit at each time, they are controlled by same uniforms in the shader. + unsigned int mTotalNumOfBubble; ///< mNumBubblePerShader*mNumShader. + unsigned int mCurrentBubble; ///< Keep track of the index for the newly emitted bubble + unsigned int mRandomSeed; ///< Seed to generate random number. + + bool mRenderTaskRunning; ///< If the background render task is currently running }; @@ -238,4 +197,4 @@ inline const Internal::BubbleEmitter& GetImpl(const Dali::Toolkit::BubbleEmitter } // namespace Dali -#endif /* __DALI_TOOLKIT_INTERNAL_BUBBLE_EMITTER_IMPL_H__ */ +#endif // DALI_TOOLKIT_INTERNAL_BUBBLE_EMITTER_IMPL_H