From: Seoyeon Kim Date: Tue, 19 Jun 2018 02:28:43 +0000 (+0900) Subject: [Tizen] fixed SVACE issue about Windows Backend X-Git-Tag: accepted/tizen/unified/20180620.131544~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=2b09117e6a001897ef4c7fc58b335fd2ada3d085 [Tizen] fixed SVACE issue about Windows Backend This reverts commit 800547b53cc55b1f508548d9c9419fba0dc42380. Change-Id: I378dfcd81300e99931b2e2d591b1208c4ebbdf79 --- diff --git a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp b/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp index efac274..c1844f6 100755 --- a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp +++ b/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp @@ -24,8 +24,6 @@ #include #include -#include - // INTERNAL INCLUDES #include #include @@ -49,6 +47,19 @@ struct Vertex Dali::Vector2 textureCoord; }; + +/** +* Return a random value between the given interval. +* @param[in] f0 The low bound +* @param[in] f1 The up bound +* @param[in] seed The seed to genergate random number +* @return A random value between the given interval +*/ +float RandomRange(float f0, float f1, unsigned int& seed) +{ + return f0 + (rand_r(&seed) & 0xfff) * (f1 - f0) * (1.0f / 4095.0f); +} + const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( attribute mediump vec2 aPosition;\n attribute mediump vec2 aTexCoord;\n @@ -151,6 +162,7 @@ BubbleEmitter::BubbleEmitter( const Vector2& movementArea, mDensity( 5 ), mTotalNumOfBubble( maximumNumberOfBubble ), mCurrentBubble( 0 ), + mRandomSeed( 0 ), mRenderTaskRunning(false) { // Calculate how many shaders are required @@ -170,6 +182,8 @@ BubbleEmitter::BubbleEmitter( const Vector2& movementArea, mNumBubblePerRenderer = mTotalNumOfBubble; mNumRenderer = 1; } + + mRandomSeed = time(NULL); } BubbleEmitter::~BubbleEmitter() @@ -354,7 +368,7 @@ Geometry BubbleEmitter::CreateGeometry( unsigned int numOfPatch ) for(unsigned int i = 0; i < numOfPatch; i++) { - float halfSize = Random::Range( mBubbleSizeRange.x, mBubbleSizeRange.y ) * 0.5f; + float halfSize = RandomRange(mBubbleSizeRange.x, mBubbleSizeRange.y, mRandomSeed) * 0.5f; float index = static_cast( i ); vertexData.PushBack( Vertex( index, Vector2(-halfSize,-halfSize),Vector2(0.f,0.f) ) ); @@ -392,7 +406,7 @@ void BubbleEmitter::SetBubbleParameter( BubbleRenderer& bubbleRenderer, unsigned int halfRange = displacement.x / 2; // for the y coordinate, always negative, so bubbles always go upwards - Vector2 randomVec( rand() % static_cast( displacement.x ) - halfRange, -rand() % static_cast( displacement.y ) ); + Vector2 randomVec(rand_r(&mRandomSeed) % static_cast(displacement.x) - halfRange, -rand_r(&mRandomSeed) % static_cast(displacement.y)); dir.Normalize(); randomVec.x -= dir.x*halfRange; randomVec.y *= 1.0f - fabsf(dir.x)*0.33f; 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 8c04c6e..e6879ae 100755 --- a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.h +++ b/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.h @@ -170,6 +170,7 @@ private: 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