diff options
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 959d22fb7b..78af35b87d 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -632,6 +632,8 @@ void SurfaceFlinger::init() { auto vrFlingerRequestDisplayCallback = [this] (bool requestDisplay) { ALOGI("VR request display mode: requestDisplay=%d", requestDisplay); mVrFlingerRequestsDisplay = requestDisplay; + ConditionalLock _l(mStateLock, + std::this_thread::get_id() != mMainThreadId); signalTransaction(); }; mVrFlinger = dvr::VrFlinger::Create(mHwc->getComposer(), @@ -719,6 +721,8 @@ status_t SurfaceFlinger::getSupportedFrameTimestamps( FrameEvent::DEQUEUE_READY, FrameEvent::RELEASE, }; + ConditionalLock _l(mStateLock, + std::this_thread::get_id() != mMainThreadId); if (!getHwComposer().hasCapability( HWC2::Capability::PresentFenceIsNotReliable)) { outSupported->push_back(FrameEvent::DISPLAY_PRESENT); @@ -766,6 +770,8 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display, configs->clear(); + ConditionalLock _l(mStateLock, + std::this_thread::get_id() != mMainThreadId); for (const auto& hwConfig : getHwComposer().getConfigs(type)) { DisplayInfo info = DisplayInfo(); @@ -789,7 +795,7 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display, info.density = density; // TODO: this needs to go away (currently needed only by webkit) - sp<const DisplayDevice> hw(getDefaultDisplayDevice()); + sp<const DisplayDevice> hw(getDefaultDisplayDeviceLocked()); info.orientation = hw->getOrientation(); } else { // TODO: where should this value come from? @@ -932,7 +938,12 @@ status_t SurfaceFlinger::getDisplayColorModes(const sp<IBinder>& display, return type; } - std::vector<android_color_mode_t> modes = getHwComposer().getColorModes(type); + std::vector<android_color_mode_t> modes; + { + ConditionalLock _l(mStateLock, + std::this_thread::get_id() != mMainThreadId); + modes = getHwComposer().getColorModes(type); + } outColorModes->clear(); std::copy(modes.cbegin(), modes.cend(), std::back_inserter(*outColorModes)); @@ -1340,7 +1351,7 @@ void SurfaceFlinger::onRefreshReceived(int sequenceId, if (sequenceId != mComposerSequenceId) { return; } - repaintEverything(); + repaintEverythingLocked(); } void SurfaceFlinger::setVsyncEnabled(int disp, int enabled) { @@ -3348,7 +3359,7 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& hw, mVisibleRegionsDirty = true; mHasPoweredOff = true; - repaintEverything(); + repaintEverythingLocked(); struct sched_param param = {0}; param.sched_priority = 1; @@ -3992,6 +4003,7 @@ status_t SurfaceFlinger::onTransact( return NO_ERROR; } case 1005:{ // force transaction + Mutex::Autolock _l(mStateLock); setTransactionFlags( eTransactionNeeded| eDisplayTransactionNeeded| @@ -4128,11 +4140,17 @@ status_t SurfaceFlinger::onTransact( return err; } -void SurfaceFlinger::repaintEverything() { +void SurfaceFlinger::repaintEverythingLocked() { android_atomic_or(1, &mRepaintEverything); signalTransaction(); } +void SurfaceFlinger::repaintEverything() { + ConditionalLock _l(mStateLock, + std::this_thread::get_id() != mMainThreadId); + repaintEverythingLocked(); +} + // Checks that the requested width and height are valid and updates them to the display dimensions // if they are set to 0 static status_t updateDimensionsLocked(const sp<const DisplayDevice>& displayDevice, |