Commit 8d2e32de905116f05b4cf62572f3a016c128e408

Authored by adam.b
Committed by Adam Bialogonski
1 parent 0ebe1f65

Replaced Image with Texture when using cube transition effect. All references to…

… the Image type have been removed.

Change-Id: Ibc08cbaf72fa8f0f65bd434998adc17b9a9c7c64
examples/cube-transition-effect/cube-transition-effect-example.cpp
... ... @@ -148,15 +148,22 @@ private:
148 148 /**
149 149 * Callback function of cube transition completed signal
150 150 * @param[in] effect The cube effect used for the transition
151   - * @param[in] image The target Image of the completed transition
  151 + * @param[in] texture The target Texture of the completed transition
152 152 */
153   - void OnTransitionCompleted(Toolkit::CubeTransitionEffect effect, Image image );
  153 + void OnTransitionCompleted(Toolkit::CubeTransitionEffect effect, Texture image );
154 154 /**
155 155 * Callback function of timer tick
156 156 * The timer is used to count the image display duration in slideshow,
157 157 */
158 158 bool OnTimerTick();
159 159  
  160 + /**
  161 + * Loads image, resizes it to the size of stage and creates a textue out of it
  162 + * @param[in] filepath Path to the image file
  163 + * @return New texture object
  164 + */
  165 + Texture LoadStageFillingTexture( const char* filepath );
  166 +
160 167 private:
161 168 Application& mApplication;
162 169 Toolkit::Control mView;
... ... @@ -166,8 +173,8 @@ private:
166 173  
167 174 Vector2 mViewSize;
168 175  
169   - Image mCurrentImage;
170   - Image mNextImage;
  176 + Texture mCurrentTexture;
  177 + Texture mNextTexture;
171 178 unsigned int mIndex;
172 179 bool mIsImageLoading;
173 180  
... ... @@ -232,7 +239,7 @@ void CubeTransitionApp::OnInit( Application& application )
232 239 mViewSize = Stage::GetCurrent().GetSize();
233 240  
234 241 // show the first image
235   - mCurrentImage = DemoHelper::LoadStageFillingImage( IMAGES[mIndex] );
  242 + mCurrentTexture = LoadStageFillingTexture( IMAGES[mIndex] );
236 243  
237 244 //use small cubes
238 245 mCubeWaveEffect = Toolkit::CubeTransitionWaveEffect::New( NUM_ROWS_WAVE, NUM_COLUMNS_WAVE );
... ... @@ -242,7 +249,7 @@ void CubeTransitionApp::OnInit( Application& application )
242 249  
243 250 mCubeWaveEffect.SetSize( mViewSize );
244 251 mCubeWaveEffect.SetParentOrigin( ParentOrigin::CENTER );
245   - mCubeWaveEffect.SetCurrentImage( mCurrentImage );
  252 + mCubeWaveEffect.SetCurrentTexture( mCurrentTexture );
246 253  
247 254 // use big cubes
248 255 mCubeCrossEffect = Toolkit::CubeTransitionCrossEffect::New(NUM_ROWS_CROSS, NUM_COLUMNS_CROSS );
... ... @@ -252,7 +259,7 @@ void CubeTransitionApp::OnInit( Application& application )
252 259  
253 260 mCubeCrossEffect.SetSize( mViewSize );
254 261 mCubeCrossEffect.SetParentOrigin( ParentOrigin::CENTER );
255   - mCubeCrossEffect.SetCurrentImage( mCurrentImage );
  262 + mCubeCrossEffect.SetCurrentTexture( mCurrentTexture );
256 263  
257 264 mCubeFoldEffect = Toolkit::CubeTransitionFoldEffect::New( NUM_ROWS_FOLD, NUM_COLUMNS_FOLD );
258 265 mCubeFoldEffect.SetTransitionDuration( ANIMATION_DURATION_FOLD );
... ... @@ -260,7 +267,7 @@ void CubeTransitionApp::OnInit( Application& application )
260 267  
261 268 mCubeFoldEffect.SetSize( mViewSize );
262 269 mCubeFoldEffect.SetParentOrigin( ParentOrigin::CENTER );
263   - mCubeFoldEffect.SetCurrentImage( mCurrentImage );
  270 + mCubeFoldEffect.SetCurrentTexture( mCurrentTexture );
264 271  
265 272 mViewTimer = Timer::New( VIEWINGTIME );
266 273 mViewTimer.TickSignal().Connect( this, &CubeTransitionApp::OnTimerTick );
... ... @@ -303,11 +310,11 @@ void CubeTransitionApp::OnPanGesture( Actor actor, const PanGesture& gesture )
303 310  
304 311 void CubeTransitionApp::GoToNextImage()
305 312 {
306   - mNextImage = DemoHelper::LoadStageFillingImage( IMAGES[ mIndex ] );
307   - mCurrentEffect.SetTargetImage( mNextImage );
  313 + mNextTexture = LoadStageFillingTexture( IMAGES[ mIndex ] );
  314 + mCurrentEffect.SetTargetTexture( mNextTexture );
308 315 mIsImageLoading = false;
309 316 mCurrentEffect.StartTransition( mPanPosition, mPanDisplacement );
310   - mCurrentImage = mNextImage;
  317 + mCurrentTexture = mNextTexture;
311 318 }
312 319  
313 320 bool CubeTransitionApp::OnEffectButtonClicked( Toolkit::Button button )
... ... @@ -339,7 +346,7 @@ bool CubeTransitionApp::OnEffectButtonClicked( Toolkit::Button button )
339 346  
340 347 // Set the current image to cube transition effect
341 348 // only need to set at beginning or change from another effect
342   - mCurrentEffect.SetCurrentImage( mCurrentImage );
  349 + mCurrentEffect.SetCurrentTexture( mCurrentTexture );
343 350 return true;
344 351 }
345 352  
... ... @@ -365,7 +372,7 @@ bool CubeTransitionApp::OnSildeshowButtonClicked( Toolkit::Button button )
365 372 return true;
366 373 }
367 374  
368   -void CubeTransitionApp::OnTransitionCompleted(Toolkit::CubeTransitionEffect effect, Image image )
  375 +void CubeTransitionApp::OnTransitionCompleted(Toolkit::CubeTransitionEffect effect, Texture texture )
369 376 {
370 377 if( mSlideshow )
371 378 {
... ... @@ -385,6 +392,17 @@ bool CubeTransitionApp::OnTimerTick()
385 392 return false;
386 393 }
387 394  
  395 +Texture CubeTransitionApp::LoadStageFillingTexture( const char* filepath )
  396 +{
  397 + ImageDimensions dimensions( Stage::GetCurrent().GetSize().x, Stage::GetCurrent().GetSize().y );
  398 + BitmapLoader loader = BitmapLoader::New( filepath, dimensions, FittingMode::SCALE_TO_FILL );
  399 + loader.Load();
  400 + PixelData pixelData = loader.GetPixelData();
  401 + Texture texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
  402 + texture.Upload( pixelData );
  403 + return texture;
  404 +}
  405 +
388 406 void CubeTransitionApp::OnKeyEvent(const KeyEvent& event)
389 407 {
390 408 if(event.state == KeyEvent::Down)
... ...