diff options
author | Ben Murdoch <benm@google.com> | 2011-05-05 14:36:32 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-10 15:38:30 +0100 |
commit | f05b935882198ccf7d81675736e3aeb089c5113a (patch) | |
tree | 4ea0ca838d9ef1b15cf17ddb3928efb427c7e5a1 /WebCore/platform/efl/SharedTimerEfl.cpp | |
parent | 60fbdcc62bced8db2cb1fd233cc4d1e4ea17db1b (diff) | |
download | external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.zip external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.gz external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.bz2 |
Merge WebKit at r74534: Initial merge by git.
Change-Id: I6ccd1154fa1b19c2ec2a66878eb675738735f1eb
Diffstat (limited to 'WebCore/platform/efl/SharedTimerEfl.cpp')
-rw-r--r-- | WebCore/platform/efl/SharedTimerEfl.cpp | 55 |
1 files changed, 4 insertions, 51 deletions
diff --git a/WebCore/platform/efl/SharedTimerEfl.cpp b/WebCore/platform/efl/SharedTimerEfl.cpp index 990d0c8..2534c60 100644 --- a/WebCore/platform/efl/SharedTimerEfl.cpp +++ b/WebCore/platform/efl/SharedTimerEfl.cpp @@ -30,25 +30,16 @@ #include "SharedTimer.h" #include <Ecore.h> -#include <pthread.h> -#include <stdio.h> #include <wtf/Assertions.h> #include <wtf/CurrentTime.h> #include <wtf/MainThread.h> namespace WebCore { -static pthread_mutex_t timerMutex = PTHREAD_MUTEX_INITIALIZER; static Ecore_Timer *_sharedTimer = 0; -static Ecore_Pipe *_pipe = 0; static void (*_timerFunction)(); -struct timerOp { - double time; - unsigned char op; // 0 - add a timer; 1 - del a timer; -}; - void setSharedTimerFiredFunction(void (*func)()) { _timerFunction = func; @@ -64,58 +55,20 @@ static Eina_Bool timerEvent(void*) return ECORE_CALLBACK_CANCEL; } -void processTimers(struct timerOp *tOp) +void stopSharedTimer() { if (_sharedTimer) { ecore_timer_del(_sharedTimer); _sharedTimer = 0; } - - if (tOp->op == 1) - return; - - double interval = tOp->time - currentTime(); - - if (interval <= ecore_animator_frametime_get()) { - if (_timerFunction) - _timerFunction(); - return; - } - - _sharedTimer = ecore_timer_add(interval, timerEvent, 0); -} - -void pipeHandlerCb(void *data, void *buffer, unsigned int nbyte) -{ - ASSERT(nbyte == sizeof(struct timerOp)); - - struct timerOp *tOp = (struct timerOp *)buffer; - processTimers(tOp); -} - -void stopSharedTimer() -{ - struct timerOp tOp; - pthread_mutex_lock(&timerMutex); - if (!_pipe) - _pipe = ecore_pipe_add(pipeHandlerCb, 0); - pthread_mutex_unlock(&timerMutex); - - tOp.op = 1; - ecore_pipe_write(_pipe, &tOp, sizeof(tOp)); } void addNewTimer(double fireTime) { - struct timerOp tOp; - pthread_mutex_lock(&timerMutex); - if (!_pipe) - _pipe = ecore_pipe_add(pipeHandlerCb, 0); - pthread_mutex_unlock(&timerMutex); + double interval = fireTime - currentTime(); + stopSharedTimer(); - tOp.time = fireTime; - tOp.op = 0; - ecore_pipe_write(_pipe, &tOp, sizeof(tOp)); + _sharedTimer = ecore_timer_loop_add(interval, timerEvent, 0); } void setSharedTimerFireTime(double fireTime) |