1 /* 2 // Copyright(c)2014 IntelCorporation 3 // 4 // LicensedundertheApacheLicense,Version2.0(the"License"); 5 // youmaynotusethisfileexceptincompliancewiththeLicense. 6 // YoumayobtainacopyoftheLicenseat 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unlessrequiredbyapplicablelaworagreedtoinwriting,software 11 // distributedundertheLicenseisdistributedonan"ASIS"BASIS, 12 // WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. 13 // SeetheLicenseforthespecificlanguagegoverningpermissionsand 14 // limitationsundertheLicense. 15 */ 16 #ifndef SOFT_VSYNC_OBSERVER_H 17 #define SOFT_VSYNC_OBSERVER_H 18 19 #include <SimpleThread.h> 20 21 namespace android { 22 namespace intel { 23 24 class IDisplayDevice; 25 26 class SoftVsyncObserver { 27 public: 28 SoftVsyncObserver(IDisplayDevice& disp); 29 virtual ~SoftVsyncObserver(); 30 31 public: 32 virtual bool initialize(); 33 virtual void deinitialize(); 34 virtual void setRefreshRate(int rate); 35 virtual bool control(bool enabled); 36 37 private: 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 49 private: 50 DECLARE_THREAD(VsyncEventPollThread, SoftVsyncObserver); 51 }; 52 53 } // namespace intel 54 } // namespace android 55 56 57 58 #endif /* SOFT_VSYNC_OBSERVER_H */ 59 60