blob: 03f1cfc3581e77896c1d1bc9a4793250a2d916e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fsdk_mgr.h"
std::vector<CFWL_TimerInfo*> CXFA_FWLAdapterTimerMgr::s_TimerArray;
FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer,
FX_DWORD dwElapse,
FWL_HTIMER& hTimer,
FX_BOOL bImmediately) {
if (!m_pEnv)
return FWL_ERR_Indefinite;
uint32_t uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc);
s_TimerArray.push_back(new CFWL_TimerInfo(uIDEvent, pTimer));
hTimer = reinterpret_cast<FWL_HTIMER>(s_TimerArray.back());
return FWL_ERR_Succeeded;
}
FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) {
if (!hTimer || !m_pEnv)
return FWL_ERR_Indefinite;
CFWL_TimerInfo* pInfo = reinterpret_cast<CFWL_TimerInfo*>(hTimer);
m_pEnv->FFI_KillTimer(pInfo->uIDEvent);
auto it = std::find(s_TimerArray.begin(), s_TimerArray.end(), pInfo);
if (it != s_TimerArray.end()) {
s_TimerArray.erase(it);
delete pInfo;
}
return FWL_ERR_Succeeded;
}
void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) {
for (CFWL_TimerInfo* pInfo : s_TimerArray) {
if (pInfo->uIDEvent == idEvent) {
pInfo->pTimer->Run(reinterpret_cast<FWL_HTIMER>(pInfo));
break;
}
}
}
|