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#ifndef SOFT_VSYNC_OBSERVER_H
17#define SOFT_VSYNC_OBSERVER_H
18
19#include <SimpleThread.h>
20
21namespace android {
22namespace intel {
23
24class IDisplayDevice;
25
26class SoftVsyncObserver {
27public:
28    SoftVsyncObserver(IDisplayDevice& disp);
29    virtual ~SoftVsyncObserver();
30
31public:
32    virtual bool initialize();
33    virtual void deinitialize();
34    virtual void setRefreshRate(int rate);
35    virtual bool control(bool enabled);
36
37private:
38    IDisplayDevice& mDisplayDevice;
39    int  mDevice;
40    bool mEnabled;
41    int mRefreshRate;
42    nsecs_t mRefreshPeriod;
43    mutable Mutex mLock;
44    Condition mCondition;
45    mutable nsecs_t mNextFakeVSync;
46    bool mExitThread;
47    bool mInitialized;
48
49private:
50    DECLARE_THREAD(VsyncEventPollThread, SoftVsyncObserver);
51};
52
53} // namespace intel
54} // namespace android
55
56
57
58#endif /* SOFT_VSYNC_OBSERVER_H */
59
60