blob: 94e63faa5079f82823ed9e7b52515be119247d0c
1 | /* |
2 | // Copyright (c) 2014 Intel Corporation |
3 | // |
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 |
7 | // |
8 | // http://www.apache.org/licenses/LICENSE-2.0 |
9 | // |
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. |
15 | // |
16 | // This file is modified by Amlogic, Inc. 2017.01.17. |
17 | */ |
18 | |
19 | #ifndef SOFT_VSYNC_OBSERVER_H |
20 | #define SOFT_VSYNC_OBSERVER_H |
21 | |
22 | #include <SimpleThread.h> |
23 | |
24 | namespace android { |
25 | namespace amlogic { |
26 | |
27 | class IDisplayDevice; |
28 | |
29 | class SoftVsyncObserver { |
30 | public: |
31 | SoftVsyncObserver(IDisplayDevice& disp); |
32 | virtual ~SoftVsyncObserver(); |
33 | |
34 | public: |
35 | virtual bool initialize(); |
36 | virtual void deinitialize(); |
37 | virtual void setRefreshPeriod(nsecs_t period); |
38 | virtual bool control(bool enabled); |
39 | virtual nsecs_t getRefreshPeriod() const { return mRefreshPeriod; } |
40 | |
41 | private: |
42 | IDisplayDevice& mDisplayDevice; |
43 | int mDevice; |
44 | bool mEnabled; |
45 | nsecs_t mRefreshPeriod; |
46 | mutable Mutex mLock; |
47 | Condition mCondition; |
48 | mutable nsecs_t mNextFakeVSync; |
49 | bool mExitThread; |
50 | bool mInitialized; |
51 | |
52 | private: |
53 | DECLARE_THREAD(VsyncEventPollThread, SoftVsyncObserver); |
54 | }; |
55 | |
56 | } // namespace amlogic |
57 | } // namespace android |
58 | |
59 | |
60 | |
61 | #endif /* SOFT_VSYNC_OBSERVER_H */ |
62 | |
63 |