Commit 600298efc4cf2a684b92767700793f4807261525

Authored by Seungho, Baek
1 parent ffa6fd3e

Modify gaussian-blur-view example

 - Made not create new gaussian blur for every activation.

Change-Id: I8d5377d804760286188212923e95fb4737bae274
Signed-off-by: Seungho, Baek <sbsh.baek@samsung.com>
examples/gaussian-blur-view/gaussian-blur-view-example.cpp
1 1 /*
2   - * Copyright (c) 2019 Samsung Electronics Co., Ltd.
  2 + * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3 3 *
4 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 5 * you may not use this file except in compliance with the License.
... ... @@ -42,7 +42,8 @@ public:
42 42 GaussianBlurViewExample( Application& application )
43 43 : mApplication( application ),
44 44 mExcessWidth( 0.0f ),
45   - mStrength( 1.0f )
  45 + mStrength( 1.0f ),
  46 + mActivate( false )
46 47 {
47 48 mApplication.InitSignal().Connect( this, &GaussianBlurViewExample::Create );
48 49 }
... ... @@ -61,8 +62,6 @@ private:
61 62 mImageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
62 63 mImageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
63 64  
64   - stage.Add( mImageView );
65   -
66 65 float excessWidth = std::max( 0.0f, (BACKGROUND_IMAGE_WIDTH - stageSize.width) * 0.5f );
67 66  
68 67 if( excessWidth > 0.0f )
... ... @@ -102,46 +101,41 @@ private:
102 101 mOffLabel.SetProperty( Actor::Property::VISIBLE, true );
103 102 onTop.Add( mOffLabel );
104 103  
  104 + mGaussianBlurView = GaussianBlurView::New( 30, 8.0f, Pixel::RGBA8888, 0.5f, 0.5f, false );
  105 + mGaussianBlurView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
  106 + mGaussianBlurView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
  107 + mGaussianBlurView.SetProperty( Actor::Property::SIZE, stage.GetSize() );
  108 + stage.Add( mGaussianBlurView );
  109 +
  110 + mGaussianBlurView.Add( mImageView );
  111 + mGaussianBlurView.SetProperty( mGaussianBlurView.GetBlurStrengthPropertyIndex(), mStrength );
  112 +
105 113 stage.GetRootLayer().TouchSignal().Connect( this, &GaussianBlurViewExample::OnTouch );
106 114 }
107 115  
108 116 bool OnTouch( Actor actor, const TouchData& touch )
109 117 {
110   - const PointState::Type state = touch.GetState( 0 );
  118 + const PointState::Type state = touch.GetState( 0 );
111 119  
112   - if( PointState::DOWN == state )
  120 + if( PointState::DOWN == state )
  121 + {
  122 + if( !mActivate )
113 123 {
114   - Stage stage = Stage::GetCurrent();
115   -
116   - // Enable/disable blur effect
117   -
118   - if( !mGaussianBlurView )
119   - {
120   - mGaussianBlurView = GaussianBlurView::New( 30, 8.0f, Pixel::RGBA8888, 0.5f, 0.5f, false );
121   - mGaussianBlurView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
122   - mGaussianBlurView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
123   - mGaussianBlurView.SetProperty( Actor::Property::SIZE, stage.GetSize() );
124   - stage.Add( mGaussianBlurView );
125   -
126   - mGaussianBlurView.Add( mImageView );
127   - mGaussianBlurView.Activate();
  124 + mActivate = true;
  125 + mGaussianBlurView.Activate();
128 126  
129   - mGaussianBlurView.SetProperty( mGaussianBlurView.GetBlurStrengthPropertyIndex(), mStrength );
130   -
131   - mOnLabel.SetProperty( Actor::Property::VISIBLE, true );
132   - mOffLabel.SetProperty( Actor::Property::VISIBLE, false );
133   - }
134   - else
135   - {
136   - stage.Add( mImageView );
137   -
138   - UnparentAndReset( mGaussianBlurView );
139   -
140   - mOnLabel.SetProperty( Actor::Property::VISIBLE, false );
141   - mOffLabel.SetProperty( Actor::Property::VISIBLE, true );
142   - }
  127 + mOnLabel.SetProperty( Actor::Property::VISIBLE, true );
  128 + mOffLabel.SetProperty( Actor::Property::VISIBLE, false );
  129 + }
  130 + else
  131 + {
  132 + mActivate = false;
  133 + mGaussianBlurView.Deactivate();
143 134  
  135 + mOnLabel.SetProperty( Actor::Property::VISIBLE, false );
  136 + mOffLabel.SetProperty( Actor::Property::VISIBLE, true );
144 137 }
  138 + }
145 139  
146 140 return true;
147 141 }
... ... @@ -172,6 +166,8 @@ private:
172 166  
173 167 float mExcessWidth;
174 168 float mStrength;
  169 +
  170 + bool mActivate;
175 171 };
176 172  
177 173 int DALI_EXPORT_API main( int argc, char **argv )
... ...