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 VSYNC_MANAGER_H 17 #define VSYNC_MANAGER_H 18 19 #include <IDisplayDevice.h> 20 #include <utils/threads.h> 21 22 namespace android { 23 namespace intel { 24 25 26 class Hwcomposer; 27 28 class VsyncManager { 29 public: 30 VsyncManager(Hwcomposer& hwc); 31 virtual ~VsyncManager(); 32 33 public: 34 bool initialize(); 35 void deinitialize(); 36 bool handleVsyncControl(int disp, bool enabled); 37 void resetVsyncSource(); 38 int getVsyncSource(); 39 void enableDynamicVsync(bool enable); 40 41 private: 42 inline int getCandidate(); 43 inline bool enableVsync(int candidate); 44 inline void disableVsync(); 45 IDisplayDevice* getDisplayDevice(int dispType); 46 47 private: 48 Hwcomposer &mHwc; 49 bool mInitialized; 50 bool mEnableDynamicVsync; 51 bool mEnabled; 52 int mVsyncSource; 53 Mutex mLock; 54 55 private: 56 // toggle this constant to use primary vsync only or enable dynamic vsync. 57 static const bool scUsePrimaryVsyncOnly = false; 58 }; 59 60 } // namespace intel 61 } // namespace android 62 63 64 65 #endif /* VSYNC_MANAGER_H */ 66