summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishal Mahaveer2018-02-09 15:29:27 -0600
committerVishal Mahaveer2018-02-09 15:29:27 -0600
commit8cbd65eb764ccd07657c73329db79428a38fd031 (patch)
treec78aa3ea0e10386e3cdc383f629cf2652381a3d3
parent77d61caca9b23b00d7fdb47f9b8e085e0fdb3540 (diff)
parentfe29ba7a9c86bf37b24f9dcf6e765978bc5a9dd0 (diff)
downloadframeworks-native-d-oreo-mr1-release.tar.gz
frameworks-native-d-oreo-mr1-release.tar.xz
frameworks-native-d-oreo-mr1-release.zip
Merge remote-tracking branch 'omap-mirror/oreo-mr1-release' into d-oreo-mr1-released-oreo-mr1-release
-rw-r--r--services/surfaceflinger/MessageQueue.cpp8
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp37
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h3
3 files changed, 41 insertions, 7 deletions
diff --git a/services/surfaceflinger/MessageQueue.cpp b/services/surfaceflinger/MessageQueue.cpp
index bca343079..0b1199c2d 100644
--- a/services/surfaceflinger/MessageQueue.cpp
+++ b/services/surfaceflinger/MessageQueue.cpp
@@ -91,6 +91,14 @@ void MessageQueue::init(const sp<SurfaceFlinger>& flinger)
91 91
92void MessageQueue::setEventThread(const sp<EventThread>& eventThread) 92void MessageQueue::setEventThread(const sp<EventThread>& eventThread)
93{ 93{
94 if (mEventThread == eventThread) {
95 return;
96 }
97
98 if (mEventTube.getFd() >= 0) {
99 mLooper->removeFd(mEventTube.getFd());
100 }
101
94 mEventThread = eventThread; 102 mEventThread = eventThread;
95 mEvents = eventThread->createEventConnection(); 103 mEvents = eventThread->createEventConnection();
96 mEvents->stealReceiveChannel(&mEventTube); 104 mEvents->stealReceiveChannel(&mEventTube);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index bb0e33cb4..4055693e4 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -542,7 +542,9 @@ public:
542 542
543 virtual void onInjectSyncEvent(nsecs_t when) { 543 virtual void onInjectSyncEvent(nsecs_t when) {
544 std::lock_guard<std::mutex> lock(mCallbackMutex); 544 std::lock_guard<std::mutex> lock(mCallbackMutex);
545 mCallback->onVSyncEvent(when); 545 if (mCallback != nullptr) {
546 mCallback->onVSyncEvent(when);
547 }
546 } 548 }
547 549
548 virtual void setVSyncEnabled(bool) {} 550 virtual void setVSyncEnabled(bool) {}
@@ -1037,13 +1039,14 @@ status_t SurfaceFlinger::getHdrCapabilities(const sp<IBinder>& display,
1037 return NO_ERROR; 1039 return NO_ERROR;
1038} 1040}
1039 1041
1040status_t SurfaceFlinger::enableVSyncInjections(bool enable) { 1042void SurfaceFlinger::enableVSyncInjectionsInternal(bool enable) {
1041 if (enable == mInjectVSyncs) { 1043 Mutex::Autolock _l(mStateLock);
1042 return NO_ERROR; 1044
1045 if (mInjectVSyncs == enable) {
1046 return;
1043 } 1047 }
1044 1048
1045 if (enable) { 1049 if (enable) {
1046 mInjectVSyncs = enable;
1047 ALOGV("VSync Injections enabled"); 1050 ALOGV("VSync Injections enabled");
1048 if (mVSyncInjector.get() == nullptr) { 1051 if (mVSyncInjector.get() == nullptr) {
1049 mVSyncInjector = new InjectVSyncSource(); 1052 mVSyncInjector = new InjectVSyncSource();
@@ -1051,15 +1054,33 @@ status_t SurfaceFlinger::enableVSyncInjections(bool enable) {
1051 } 1054 }
1052 mEventQueue.setEventThread(mInjectorEventThread); 1055 mEventQueue.setEventThread(mInjectorEventThread);
1053 } else { 1056 } else {
1054 mInjectVSyncs = enable;
1055 ALOGV("VSync Injections disabled"); 1057 ALOGV("VSync Injections disabled");
1056 mEventQueue.setEventThread(mSFEventThread); 1058 mEventQueue.setEventThread(mSFEventThread);
1057 mVSyncInjector.clear();
1058 } 1059 }
1060
1061 mInjectVSyncs = enable;
1062}
1063
1064status_t SurfaceFlinger::enableVSyncInjections(bool enable) {
1065 class MessageEnableVSyncInjections : public MessageBase {
1066 SurfaceFlinger* mFlinger;
1067 bool mEnable;
1068 public:
1069 MessageEnableVSyncInjections(SurfaceFlinger* flinger, bool enable)
1070 : mFlinger(flinger), mEnable(enable) { }
1071 virtual bool handler() {
1072 mFlinger->enableVSyncInjectionsInternal(mEnable);
1073 return true;
1074 }
1075 };
1076 sp<MessageBase> msg = new MessageEnableVSyncInjections(this, enable);
1077 postMessageSync(msg);
1059 return NO_ERROR; 1078 return NO_ERROR;
1060} 1079}
1061 1080
1062status_t SurfaceFlinger::injectVSync(nsecs_t when) { 1081status_t SurfaceFlinger::injectVSync(nsecs_t when) {
1082 Mutex::Autolock _l(mStateLock);
1083
1063 if (!mInjectVSyncs) { 1084 if (!mInjectVSyncs) {
1064 ALOGE("VSync Injections not enabled"); 1085 ALOGE("VSync Injections not enabled");
1065 return BAD_VALUE; 1086 return BAD_VALUE;
@@ -3891,6 +3912,8 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) {
3891 case GET_ANIMATION_FRAME_STATS: 3912 case GET_ANIMATION_FRAME_STATS:
3892 case SET_POWER_MODE: 3913 case SET_POWER_MODE:
3893 case GET_HDR_CAPABILITIES: 3914 case GET_HDR_CAPABILITIES:
3915 case ENABLE_VSYNC_INJECTIONS:
3916 case INJECT_VSYNC:
3894 { 3917 {
3895 // codes that require permission check 3918 // codes that require permission check
3896 IPCThreadState* ipc = IPCThreadState::self(); 3919 IPCThreadState* ipc = IPCThreadState::self();
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 7606e10a6..99d4a1a63 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -366,6 +366,9 @@ private:
366 // Called on the main thread in response to setActiveColorMode() 366 // Called on the main thread in response to setActiveColorMode()
367 void setActiveColorModeInternal(const sp<DisplayDevice>& hw, android_color_mode_t colorMode); 367 void setActiveColorModeInternal(const sp<DisplayDevice>& hw, android_color_mode_t colorMode);
368 368
369 // Called on the main thread in response to enableVSyncInjections()
370 void enableVSyncInjectionsInternal(bool enable);
371
369 // Returns whether the transaction actually modified any state 372 // Returns whether the transaction actually modified any state
370 bool handleMessageTransaction(); 373 bool handleMessageTransaction();
371 374