2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/system/common/timer-impl.h>
21 // Ecore is littered with C style cast
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-Wold-style-cast"
26 #include <dali/internal/window-system/windows/platform-implement-win.h>
40 void TimerSourceFunc (void *data)
42 Timer* timer = static_cast<Timer*>(data);
44 bool keepRunning = timer->Tick();
49 * Struct to hide away Ecore implementation details
53 Impl( unsigned int milliSec ) :
61 unsigned int mInterval;
64 TimerPtr Timer::New( unsigned int milliSec )
66 TimerPtr timer( new Timer( milliSec ) );
70 Timer::Timer( unsigned int milliSec )
71 : mImpl(new Impl(milliSec))
88 mImpl->mId = WindowsPlatformImplement::SetTimer( mImpl->mInterval, TimerSourceFunc, this );
96 WindowsPlatformImplement::KillTimer( mImpl->mId );
101 void Timer::SetInterval( unsigned int interval )
103 // stop existing timer
105 mImpl->mInterval = interval;
110 unsigned int Timer::GetInterval() const
112 return mImpl->mInterval;
117 // Guard against destruction during signal emission
118 Dali::Timer handle( this );
120 bool retVal( false );
122 // Override with new signal if used
123 if( !mTickSignal.Empty() )
125 retVal = mTickSignal.Emit();
127 // Timer stops if return value is false
134 retVal = true; // continue emission
137 else // no callbacks registered
139 // periodic timer is started but nobody listens, continue
146 Dali::Timer::TimerSignalType& Timer::TickSignal()
151 bool Timer::IsRunning() const
153 return 0 <= mImpl->mId;
156 } // namespace Adaptor
158 } // namespace Internal
162 #pragma GCC diagnostic pop