diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2016-03-14 13:51:24 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2016-03-14 13:51:24 -0400 |
commit | f766ad219f66543654520f6a1955836f519e26d1 (patch) | |
tree | 2edf8bc93b89503a3669f7add5b6c2a407b8a78c /fpdfsdk/fpdfxfa/fpdfxfa_util.cpp | |
parent | 54b0abed08048008498471e39b7c72b034474090 (diff) | |
download | pdfium-f766ad219f66543654520f6a1955836f519e26d1.tar.xz |
Move fpdfsdk/src up to fpdfsdk/.
This CL moves the files in fpdfsdk/src/ up one level to fpdfsdk/ and fixes
up the include paths, include guards and build files.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1799773002 .
Diffstat (limited to 'fpdfsdk/fpdfxfa/fpdfxfa_util.cpp')
-rw-r--r-- | fpdfsdk/fpdfxfa/fpdfxfa_util.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp new file mode 100644 index 0000000000..7814d8bd8a --- /dev/null +++ b/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp @@ -0,0 +1,58 @@ +// 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 <vector> + +#include "fpdfsdk/include/fsdk_define.h" +#include "fpdfsdk/include/fsdk_mgr.h" + +std::vector<CFWL_TimerInfo*>* CXFA_FWLAdapterTimerMgr::s_TimerArray = nullptr; + +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); + if (!s_TimerArray) + s_TimerArray = new std::vector<CFWL_TimerInfo*>; + 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); + if (s_TimerArray) { + 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; +} + +// static +void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) { + if (!s_TimerArray) + return; + + for (CFWL_TimerInfo* pInfo : *s_TimerArray) { + if (pInfo->uIDEvent == idEvent) { + pInfo->pTimer->Run(reinterpret_cast<FWL_HTIMER>(pInfo)); + break; + } + } +} |