From c7a25adf66b138de66814383540905b83cf12a01 Mon Sep 17 00:00:00 2001 From: Dan Stoza Date: Thu, 12 Apr 2018 11:45:09 -0700 Subject: SF: Fix repaint everything logic This solves the same problem with dirty regions not being updated as Ia7a3dc15c96626a213c4459dac4f695d91540fb5, but it is better in a couple of ways: 1) It no longer updates dirty regions from a binder thread, which was likely causing the memory corruption in b/77919748. 2) It removes the distinction between repaintEverything and repaintEverythingLocked, which is not necessary since both operations in repaintEverything (updating an atomic and signaling a transaction) are threadsafe. Bug: 77335744 Bug: 77546473 Bug: 77919748 Test: Manual - on an ASAN build, played TouchLatency bouncy ball while toggling between GL and HWC composition; doesn't crash whereas it would crash in a matter of a couple minutes before Change-Id: Iecadfecb40e87e400a301de2dcad1664e154982d --- services/surfaceflinger/SurfaceFlinger.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'services/surfaceflinger/SurfaceFlinger.cpp') diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index a8680e2dd8..726d155586 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1387,7 +1387,7 @@ void SurfaceFlinger::onRefreshReceived(int sequenceId, if (sequenceId != getBE().mComposerSequenceId) { return; } - repaintEverythingLocked(); + repaintEverything(); } void SurfaceFlinger::setVsyncEnabled(int disp, int enabled) { @@ -1949,7 +1949,7 @@ void SurfaceFlinger::setUpHWComposer() { ALOGV("setUpHWComposer"); for (size_t dpy=0 ; dpygetDirtyRegion(false).isEmpty(); + bool dirty = !mDisplays[dpy]->getDirtyRegion(mRepaintEverything).isEmpty(); bool empty = mDisplays[dpy]->getVisibleLayersSortedByZ().size() == 0; bool wasEmpty = !mDisplays[dpy]->lastCompositionHadVisibleLayers; @@ -3716,7 +3716,7 @@ void SurfaceFlinger::setPowerModeInternal(const sp& hw, mVisibleRegionsDirty = true; mHasPoweredOff = true; - repaintEverythingLocked(); + repaintEverything(); struct sched_param param = {0}; param.sched_priority = 1; @@ -4637,22 +4637,11 @@ status_t SurfaceFlinger::onTransact( return err; } -void SurfaceFlinger::repaintEverythingLocked() { +void SurfaceFlinger::repaintEverything() { android_atomic_or(1, &mRepaintEverything); - for (size_t dpy = 0; dpy < mDisplays.size(); dpy++) { - const sp& displayDevice(mDisplays[dpy]); - const Rect bounds(displayDevice->getBounds()); - displayDevice->dirtyRegion.orSelf(Region(bounds)); - } signalTransaction(); } -void SurfaceFlinger::repaintEverything() { - ConditionalLock _l(mStateLock, - std::this_thread::get_id() != mMainThreadId); - repaintEverythingLocked(); -} - // A simple RAII class to disconnect from an ANativeWindow* when it goes out of scope class WindowDisconnector { public: -- cgit v1.2.3-59-g8ed1b