0e9ae8010c01c1023709211d49a6e4ac0516b7bd
[platform/core/uifw/dali-demo.git] / examples / motion-blur / motion-blur-example.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <sstream>
19 #include <iomanip>
20
21 #include "shared/view.h"
22 #include <dali/dali.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/shader-effects/motion-blur-effect.h>
25 #include <dali-toolkit/devel-api/controls/popup/popup.h>
26
27 using namespace Dali;
28 using namespace Dali::Toolkit;
29
30
31
32 namespace // unnamed namespace
33 {
34
35 ////////////////////////////////////////////////////
36 //
37 // Demo setup parameters
38 //
39
40 //#define MULTIPLE_MOTION_BLURRED_ACTORS
41 #ifndef MULTIPLE_MOTION_BLURRED_ACTORS
42
43 const float MOTION_BLUR_ACTOR_WIDTH = 256;                                          // actor size on screen
44 const float MOTION_BLUR_ACTOR_HEIGHT = 256;                                         // ""
45
46 #else //#ifndef MULTIPLE_MOTION_BLURRED_ACTORS
47
48 const float MOTION_BLUR_ACTOR_WIDTH = 150;                                          // actor size on screen
49 const float MOTION_BLUR_ACTOR_HEIGHT = 112;                                         // ""
50
51 #endif //#ifndef MULTIPLE_MOTION_BLURRED_ACTORS
52
53
54 const unsigned int MOTION_BLUR_NUM_SAMPLES = 8;
55
56 const int MOTION_BLUR_NUM_ACTOR_IMAGES = 5;
57 const char* MOTION_BLUR_ACTOR_IMAGE1( DALI_IMAGE_DIR "image-with-border-1.jpg" );
58 const char* MOTION_BLUR_ACTOR_IMAGE2( DALI_IMAGE_DIR "image-with-border-2.jpg" );
59 const char* MOTION_BLUR_ACTOR_IMAGE3( DALI_IMAGE_DIR "image-with-border-3.jpg" );
60 const char* MOTION_BLUR_ACTOR_IMAGE4( DALI_IMAGE_DIR "image-with-border-4.jpg" );
61 const char* MOTION_BLUR_ACTOR_IMAGE5( DALI_IMAGE_DIR "image-with-border-1.jpg" );
62
63 const char* MOTION_BLUR_ACTOR_IMAGES[] = {
64   MOTION_BLUR_ACTOR_IMAGE1,
65   MOTION_BLUR_ACTOR_IMAGE2,
66   MOTION_BLUR_ACTOR_IMAGE3,
67   MOTION_BLUR_ACTOR_IMAGE4,
68   MOTION_BLUR_ACTOR_IMAGE5,
69 };
70
71 const int NUM_ACTOR_ANIMATIONS = 4;
72 const int NUM_CAMERA_ANIMATIONS = 2;
73
74
75 const char* BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "background-default.png";
76
77 const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" );
78 const char* LAYOUT_IMAGE( DALI_IMAGE_DIR "icon-change.png" );
79 const char* APPLICATION_TITLE( "Motion Blur" );
80 const char* EFFECTS_OFF_ICON( DALI_IMAGE_DIR "icon-effects-off.png" );
81 const char* EFFECTS_ON_ICON( DALI_IMAGE_DIR "icon-effects-on.png" );
82
83 const float UI_MARGIN = 4.0f;                              ///< Screen Margin for placement of UI buttons
84
85 const Vector3 BUTTON_SIZE_CONSTRAINT( 0.24f, 0.09f, 1.0f );
86 const Vector3 BUTTON_TITLE_LABEL_TAP_HERE_SIZE_CONSTRAINT( 0.55f, 0.06f, 1.0f );
87 const Vector3 BUTTON_TITLE_LABEL_INSTRUCTIONS_POPUP_SIZE_CONSTRAINT( 1.0f, 1.0f, 1.0f );
88
89 // move this button down a bit so it is visible on target and not covered up by toolbar
90 const float BUTTON_TITLE_LABEL_Y_OFFSET = 0.05f;
91
92 const float ORIENTATION_DURATION = 0.5f;                  ///< Time to rotate to new orientation.
93
94 /**
95  * @brief Load an image, scaled-down to no more than the dimensions passed in.
96  *
97  * Uses SHRINK_TO_FIT which ensures the resulting image is
98  * smaller than or equal to the specified dimensions while preserving its
99  * original aspect ratio.
100  */
101 ResourceImage LoadImageFittedInBox( const char * const imagePath, uint32_t maxWidth, uint32_t maxHeight )
102 {
103   // Load the image nicely scaled-down to fit within the specified max width and height:
104   return ResourceImage::New( imagePath, ImageDimensions( maxWidth, maxHeight ), FittingMode::SHRINK_TO_FIT, Dali::SamplingMode::BOX_THEN_LINEAR );
105 }
106
107 } // unnamed namespace
108
109
110 //
111 class MotionBlurExampleApp : public ConnectionTracker
112 {
113 public:
114
115   /**
116      * DeviceOrientation describes the four different
117      * orientations the device can be in based on accelerometer reports.
118      */
119   enum DeviceOrientation
120   {
121     PORTRAIT = 0,
122     LANDSCAPE = 90,
123     PORTRAIT_INVERSE = 180,
124     LANDSCAPE_INVERSE = 270
125   };
126
127   /**
128    * Constructor
129    * @param application class, stored as reference
130    */
131   MotionBlurExampleApp(Application &app)
132   : mApplication(app),
133     mActorEffectsEnabled(false),
134     mCurrentActorAnimation(0),
135     mCurrentImage(0)
136   {
137     // Connect to the Application's Init signal
138     app.InitSignal().Connect(this, &MotionBlurExampleApp::OnInit);
139   }
140
141   ~MotionBlurExampleApp()
142   {
143     // Nothing to do here; everything gets deleted automatically
144   }
145
146   /**
147    * This method gets called once the main loop of application is up and running
148    */
149   void OnInit(Application& app)
150   {
151     // The Init signal is received once (only) during the Application lifetime
152
153     Stage::GetCurrent().KeyEventSignal().Connect(this, &MotionBlurExampleApp::OnKeyEvent);
154
155
156     // Creates a default view with a default tool bar.
157     // The view is added to the stage.
158     mContentLayer = DemoHelper::CreateView( mApplication,
159                                             mView,
160                                             mToolBar,
161                                             BACKGROUND_IMAGE_PATH,
162                                             TOOLBAR_IMAGE,
163                                             APPLICATION_TITLE );
164
165     //Add an effects icon on the right of the title
166     mIconEffectsOff = ResourceImage::New( EFFECTS_OFF_ICON );
167     mIconEffectsOn = ResourceImage::New( EFFECTS_ON_ICON );
168     mActorEffectsButton = Toolkit::PushButton::New();
169     mActorEffectsButton.SetBackgroundImage( mIconEffectsOff );
170     mActorEffectsButton.ClickedSignal().Connect( this, &MotionBlurExampleApp::OnEffectButtonClicked );
171     mToolBar.AddControl( mActorEffectsButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING );
172
173     // Creates a mode button.
174     // Create a effect toggle button. (right of toolbar)
175     Image imageLayout = ResourceImage::New( LAYOUT_IMAGE );
176     Toolkit::PushButton layoutButton = Toolkit::PushButton::New();
177     layoutButton.SetBackgroundImage(imageLayout);
178     layoutButton.ClickedSignal().Connect( this, &MotionBlurExampleApp::OnLayoutButtonClicked);
179     layoutButton.SetLeaveRequired( true );
180     mToolBar.AddControl( layoutButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
181
182     // Input
183     mTapGestureDetector = TapGestureDetector::New();
184     mTapGestureDetector.Attach( mContentLayer );
185     mTapGestureDetector.DetectedSignal().Connect( this, &MotionBlurExampleApp::OnTap );
186
187     Dali::Window winHandle = app.GetWindow();
188     winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT );
189     winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE );
190     winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE  );
191     winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE );
192
193     // set initial orientation
194    // winHandle.GetOrientation().ChangedSignal().Connect( this, &MotionBlurExampleApp::OnOrientationChanged );
195     unsigned int degrees = 0;
196     Rotate( static_cast< DeviceOrientation >( degrees ) );
197
198
199     ///////////////////////////////////////////////////////
200     //
201     // Motion blurred actor
202     //
203
204     // Scale down actor to fit on very low resolution screens with space to interact:
205     Size stageSize = Stage::GetCurrent().GetSize();
206     mMotionBlurActorSize = Size( std::min( stageSize.x * 0.3f, MOTION_BLUR_ACTOR_WIDTH ), std::min( stageSize.y * 0.3f, MOTION_BLUR_ACTOR_HEIGHT ) );
207     mMotionBlurActorSize = Size( std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ), std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ) );
208
209     Image image = LoadImageFittedInBox( MOTION_BLUR_ACTOR_IMAGE1, mMotionBlurActorSize.x, mMotionBlurActorSize.y );
210     mMotionBlurImageActor = ImageActor::New(image);
211     mMotionBlurImageActor.SetParentOrigin( ParentOrigin::CENTER );
212     mMotionBlurImageActor.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
213
214     mContentLayer.Add( mMotionBlurImageActor );
215
216     // Create shader used for doing motion blur
217     mMotionBlurEffect = Toolkit::CreateMotionBlurEffect();
218     Dali::Property::Index uModelProperty = mMotionBlurEffect.GetPropertyIndex( "uModelLastFrame" );
219     Constraint constraint = Constraint::New<Matrix>( mMotionBlurEffect, uModelProperty, EqualToConstraint() );
220     constraint.AddSource( Source( mMotionBlurImageActor , Actor::Property::WORLD_MATRIX ) );
221     constraint.Apply();
222     mMotionBlurImageActor.SetShaderEffect( mMotionBlurEffect );
223
224
225 #ifdef MULTIPLE_MOTION_BLURRED_ACTORS
226
227     ///////////////////////////////////////////////////////
228     //
229     // Motion blurred actor 2
230     //
231
232     mMotionBlurImageActor2 = ImageActor::New(image);
233     mMotionBlurImageActor2.SetParentOrigin( ParentOrigin::CENTER );
234     mMotionBlurImageActor2.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
235     mMotionBlurImageActor2.SetPosition(mMotionBlurActorSize.x * 1.1f, 0.0f);
236     mMotionBlurImageActor.Add( mMotionBlurImageActor2 );
237
238     // Create shader used for doing motion blur
239     mMotionBlurEffect2 = CreateMotionBlurEffect(MOTION_BLUR_NUM_SAMPLES);
240
241     // set actor shader to the blur one
242     mMotionBlurImageActor2.SetShaderEffect( mMotionBlurEffect2 );
243
244
245     ///////////////////////////////////////////////////////
246     //
247     // Motion blurred actor 3
248     //
249
250     mMotionBlurImageActor3 = ImageActor::New(image);
251     mMotionBlurImageActor3.SetParentOrigin( ParentOrigin::CENTER );
252     mMotionBlurImageActor3.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
253     mMotionBlurImageActor3.SetPosition(-mMotionBlurActorSize.x * 1.1f, 0.0f);
254     mMotionBlurImageActor.Add( mMotionBlurImageActor3 );
255
256     // Create shader used for doing motion blur
257     mMotionBlurEffect3 = CreateMotionBlurEffect(MOTION_BLUR_NUM_SAMPLES);
258
259     // set actor shader to the blur one
260     mMotionBlurImageActor3.SetShaderEffect( mMotionBlurEffect3 );
261
262
263     ///////////////////////////////////////////////////////
264     //
265     // Motion blurred actor 4
266     //
267
268     mMotionBlurImageActor4 = ImageActor::New(image);
269     mMotionBlurImageActor4.SetParentOrigin( ParentOrigin::CENTER );
270     mMotionBlurImageActor4.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
271     mMotionBlurImageActor4.SetPosition(0.0f, mMotionBlurActorSize.y * 1.1f);
272     mMotionBlurImageActor.Add( mMotionBlurImageActor4 );
273
274     // Create shader used for doing motion blur
275     mMotionBlurEffect4 = CreateMotionBlurEffect(MOTION_BLUR_NUM_SAMPLES);
276
277     // set actor shader to the blur one
278     mMotionBlurImageActor4.SetShaderEffect( mMotionBlurEffect4 );
279
280
281     ///////////////////////////////////////////////////////
282     //
283     // Motion blurred actor 5
284     //
285
286     mMotionBlurImageActor5 = ImageActor::New(image);
287     mMotionBlurImageActor5.SetParentOrigin( ParentOrigin::CENTER );
288     mMotionBlurImageActor5.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
289     mMotionBlurImageActor5.SetPosition(0.0f, -mMotionBlurActorSize.y * 1.1f);
290     mMotionBlurImageActor.Add( mMotionBlurImageActor5 );
291
292     // Create shader used for doing motion blur
293     mMotionBlurEffect5 = CreateMotionBlurEffect(MOTION_BLUR_NUM_SAMPLES);
294
295     // set actor shader to the blur one
296     mMotionBlurImageActor5.SetShaderEffect( mMotionBlurEffect5 );
297 #endif //#ifdef MULTIPLE_MOTION_BLURRED_ACTORS
298   }
299
300   //////////////////////////////////////////////////////////////
301   //
302   // Device Orientation Support
303   //
304   //
305
306   void OnOrientationChanged( Orientation orientation )
307   {
308     unsigned int degrees = orientation.GetDegrees();
309     Rotate( static_cast< DeviceOrientation >( degrees ) );
310   }
311
312   void Rotate( DeviceOrientation orientation )
313   {
314     // Resize the root actor
315     Vector2 stageSize = Stage::GetCurrent().GetSize();
316     Vector2 targetSize = stageSize;
317     if( orientation == LANDSCAPE ||
318         orientation == LANDSCAPE_INVERSE )
319     {
320       targetSize = Vector2( stageSize.y, stageSize.x );
321     }
322
323     if( mOrientation != orientation )
324     {
325       mOrientation = orientation;
326
327       // check if actor is on stage
328       if( mView.GetParent() )
329       {
330         // has parent so we expect it to be on stage, start animation
331         mRotateAnimation = Animation::New( ORIENTATION_DURATION );
332         mRotateAnimation.AnimateTo( Property( mView, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( -orientation ) ), Vector3::ZAXIS ), AlphaFunction::EASE_OUT );
333         mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_WIDTH ), targetSize.width );
334         mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_HEIGHT ), targetSize.height );
335         mRotateAnimation.Play();
336       }
337       else
338       {
339         // set the rotation to match the orientation
340         mView.SetOrientation( Degree( -orientation ), Vector3::ZAXIS );
341         mView.SetSize( targetSize );
342       }
343     }
344     else
345     {
346       // for first time just set size
347       mView.SetSize( targetSize );
348     }
349   }
350
351
352   //////////////////////////////////////////////////////////////
353   //
354   // Actor Animation
355   //
356   //
357
358   // move to point on screen that was tapped
359   void OnTap( Actor actor, const TapGesture& tapGesture )
360   {
361     Vector3 destPos;
362     float originOffsetX, originOffsetY;
363
364     // rotate offset (from top left origin to centre) into actor space
365     Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
366     actor.ScreenToLocal(originOffsetX, originOffsetY, stageSize.width * 0.5f, stageSize.height * 0.5f);
367
368     // get dest point in local actor space
369     destPos.x = tapGesture.localPoint.x - originOffsetX;
370     destPos.y = tapGesture.localPoint.y - originOffsetY;
371     destPos.z = 0.0f;
372
373     float animDuration = 0.5f;
374     mActorTapMovementAnimation = Animation::New( animDuration );
375     if ( mMotionBlurImageActor )
376     {
377       mActorTapMovementAnimation.AnimateTo( Property(mMotionBlurImageActor, Actor::Property::POSITION), destPos, AlphaFunction::EASE_IN_OUT_SINE, TimePeriod(animDuration) );
378     }
379     mActorTapMovementAnimation.SetEndAction( Animation::Bake );
380     mActorTapMovementAnimation.Play();
381
382
383     // perform some spinning etc
384     if(mActorEffectsEnabled)
385     {
386       switch(mCurrentActorAnimation)
387       {
388         // spin around y
389         case 0:
390         {
391           float animDuration = 1.0f;
392           mActorAnimation = Animation::New(animDuration);
393           mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::YAXIS ), AlphaFunction::EASE_IN_OUT );
394           mActorAnimation.SetEndAction( Animation::Bake );
395           mActorAnimation.Play();
396         }
397         break;
398
399         // spin around z
400         case 1:
401         {
402           float animDuration = 1.0f;
403           mActorAnimation = Animation::New(animDuration);
404           mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::ZAXIS ), AlphaFunction::EASE_IN_OUT );
405           mActorAnimation.SetEndAction( Animation::Bake );
406           mActorAnimation.Play();
407         }
408         break;
409
410         // spin around y and z
411         case 2:
412         {
413           float animDuration = 1.0f;
414           mActorAnimation = Animation::New(animDuration);
415           mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::YAXIS ), AlphaFunction::EASE_IN_OUT );
416           mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::ZAXIS ), AlphaFunction::EASE_IN_OUT );
417           mActorAnimation.SetEndAction( Animation::Bake );
418           mActorAnimation.Play();
419         }
420         break;
421
422         // scale
423         case 3:
424         {
425           float animDuration = 1.0f;
426           mActorAnimation = Animation::New(animDuration);
427           mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::SCALE ), Vector3(2.0f, 2.0f, 2.0f), AlphaFunction::BOUNCE, TimePeriod( 0.0f, 1.0f ) );
428           mActorAnimation.SetEndAction( Animation::Bake );
429           mActorAnimation.Play();
430         }
431         break;
432
433         default:
434           break;
435       }
436
437       mCurrentActorAnimation++;
438       if(NUM_ACTOR_ANIMATIONS == mCurrentActorAnimation)
439       {
440         mCurrentActorAnimation = 0;
441       }
442     }
443   }
444
445   void ToggleActorEffects()
446   {
447     if(!mActorEffectsEnabled)
448     {
449       mActorEffectsEnabled = true;
450       mActorEffectsButton.SetBackgroundImage( mIconEffectsOn );
451     }
452     else
453     {
454       mActorEffectsEnabled = false;
455       mActorEffectsButton.SetBackgroundImage( mIconEffectsOff );
456     }
457   }
458
459   //////////////////////////////////////////////////////////////
460   //
461   // Input handlers
462   //
463   //
464
465   bool OnLayoutButtonClicked( Toolkit::Button button )
466   {
467     ChangeImage();
468     return true;
469   }
470
471   bool OnEffectButtonClicked( Toolkit::Button button )
472   {
473     ToggleActorEffects();
474     return true;
475   }
476
477   /**
478    * Main key event handler
479    */
480   void OnKeyEvent(const KeyEvent& event)
481   {
482     if(event.state == KeyEvent::Down)
483     {
484       if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
485       {
486         mApplication.Quit();
487       }
488     }
489   }
490
491   //////////////////////////////////////////////////////////////
492   //
493   // Misc
494   //
495   //
496
497
498   void ChangeImage()
499   {
500     mCurrentImage++;
501     if(MOTION_BLUR_NUM_ACTOR_IMAGES == mCurrentImage)
502     {
503       mCurrentImage = 0;
504     }
505
506     Image blurImage = LoadImageFittedInBox( MOTION_BLUR_ACTOR_IMAGES[mCurrentImage], mMotionBlurActorSize.x, mMotionBlurActorSize.y );
507     mMotionBlurImageActor.SetImage(blurImage);
508   }
509
510
511 private:
512   Application&               mApplication;            ///< Application instance
513   Toolkit::Control           mView;
514   Toolkit::ToolBar           mToolBar;
515   Image                      mIconEffectsOff;
516   Image                      mIconEffectsOn;
517
518   Layer                      mContentLayer;           ///< Content layer (contains actor for this blur demo)
519
520   PushButton                 mActorEffectsButton;     ///< The actor effects toggling Button.
521
522   // Motion blur
523   ShaderEffect mMotionBlurEffect;
524   ImageActor mMotionBlurImageActor;
525   Size mMotionBlurActorSize;
526
527 #ifdef MULTIPLE_MOTION_BLURRED_ACTORS
528   ShaderEffect mMotionBlurEffect2;
529   ShaderEffect mMotionBlurEffect3;
530   ShaderEffect mMotionBlurEffect4;
531   ShaderEffect mMotionBlurEffect5;
532
533   ImageActor mMotionBlurImageActor2;
534   ImageActor mMotionBlurImageActor3;
535   ImageActor mMotionBlurImageActor4;
536   ImageActor mMotionBlurImageActor5;
537 #endif //#ifdef MULTIPLE_MOTION_BLURRED_ACTORS
538
539   // animate actor to position where user taps screen
540   Animation mActorTapMovementAnimation;
541
542   // show different animations to demonstrate blur effect working on an object only movement basis
543   bool mActorEffectsEnabled;
544   Animation mActorAnimation;
545   int mCurrentActorAnimation;
546
547   // offer a selection of images that user can cycle between
548   int mCurrentImage;
549
550   TapGestureDetector mTapGestureDetector;
551
552   DeviceOrientation mOrientation;               ///< Current Device orientation
553   Animation mRotateAnimation;                   ///< Animation for rotating between landscape and portrait.
554
555   Popup mInstructionsPopup;                     ///< Info Popup
556 };
557
558 void RunTest(Application& app)
559 {
560   MotionBlurExampleApp test(app);
561
562   app.MainLoop();
563 }
564
565 // Entry point for Linux & Tizen applications
566 //
567 int main(int argc, char **argv)
568 {
569   Application app = Application::New(&argc, &argv, DALI_DEMO_THEME_PATH);
570
571   RunTest(app);
572
573   return 0;
574 }