summaryrefslogtreecommitdiff
path: root/hwc2/common/observers/SoftVsyncObserver.h (plain)
blob: 1a7be89f18d19761d25bb0e9e0ef7f68f27f12cc
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
24namespace android {
25namespace amlogic {
26
27class IDisplayDevice;
28
29class SoftVsyncObserver {
30public:
31 SoftVsyncObserver(IDisplayDevice& disp);
32 virtual ~SoftVsyncObserver();
33
34public:
35 virtual bool initialize();
36 virtual void deinitialize();
37 virtual void setRefreshRate(int rate);
38 virtual bool control(bool enabled);
39 virtual nsecs_t getRefreshPeriod() const { return mRefreshPeriod; }
40
41private:
42 IDisplayDevice& mDisplayDevice;
43 int mDevice;
44 bool mEnabled;
45 int mRefreshRate;
46 nsecs_t mRefreshPeriod;
47 mutable Mutex mLock;
48 Condition mCondition;
49 mutable nsecs_t mNextFakeVSync;
50 bool mExitThread;
51 bool mInitialized;
52
53private:
54 DECLARE_THREAD(VsyncEventPollThread, SoftVsyncObserver);
55};
56
57} // namespace amlogic
58} // namespace android
59
60
61
62#endif /* SOFT_VSYNC_OBSERVER_H */
63
64