diff options
author | Vishnu Nair <vishnun@google.com> | 2020-06-26 22:14:35 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-06-26 22:14:35 +0000 |
commit | f403598e6134bc4b110c7d7759dfaf83768bfcf1 (patch) | |
tree | 2d4afb076b36b62ebae6a31472312d7579d4c875 | |
parent | d1a1d6486c5b79bf8f87ad2c540ddf6ba03bdfef (diff) | |
parent | f3f2130ec1c35c3bccc1790b839de8202ddbd29e (diff) | |
download | native-f403598e6134bc4b110c7d7759dfaf83768bfcf1.tar.gz |
Merge "Call Layer::getLayerDebugInfo from the main thread" into qt-dev am: f3f2130ec1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/11973468
Change-Id: I17c0038e40757656834779531635d315104cabc5
-rw-r--r-- | libs/gui/ISurfaceComposer.cpp | 2 | ||||
-rw-r--r-- | libs/gui/include/gui/ISurfaceComposer.h | 2 | ||||
-rw-r--r-- | libs/gui/tests/Surface_test.cpp | 2 | ||||
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 2 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 19 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 2 |
6 files changed, 11 insertions, 18 deletions
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index e487792c87..233325599c 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -611,7 +611,7 @@ public: return result; } - virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const + virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) { if (!outLayers) { return UNEXPECTED_NULL; diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h index c84910b6ec..7060bb1fa7 100644 --- a/libs/gui/include/gui/ISurfaceComposer.h +++ b/libs/gui/include/gui/ISurfaceComposer.h @@ -310,7 +310,7 @@ public: * * Requires the ACCESS_SURFACE_FLINGER permission. */ - virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const = 0; + virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) = 0; virtual status_t getColorManagement(bool* outGetColorManagement) const = 0; diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index a8516872fd..293789b955 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -774,7 +774,7 @@ public: return NO_ERROR; } status_t injectVSync(nsecs_t /*when*/) override { return NO_ERROR; } - status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* /*layers*/) const override { + status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* /*layers*/) override { return NO_ERROR; } status_t getCompositionPreference( diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 44f3eae1ea..3ee4ef1296 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -1280,7 +1280,7 @@ LayerDebugInfo Layer::getLayerDebugInfo() const { LayerDebugInfo info; const State& ds = getDrawingState(); info.mName = getName(); - sp<Layer> parent = getParent(); + sp<Layer> parent = mDrawingParent.promote(); info.mParentName = (parent == nullptr ? std::string("none") : parent->getName().string()); info.mType = std::string(getTypeId()); info.mTransparentRegion = ds.activeTransparentRegion_legacy; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index fd7f128411..3f32d05fda 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1265,22 +1265,15 @@ status_t SurfaceFlinger::injectVSync(nsecs_t when) { return NO_ERROR; } -status_t SurfaceFlinger::getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const +status_t SurfaceFlinger::getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) NO_THREAD_SAFETY_ANALYSIS { - // Try to acquire a lock for 1s, fail gracefully - const status_t err = mStateLock.timedLock(s2ns(1)); - const bool locked = (err == NO_ERROR); - if (!locked) { - ALOGE("LayerDebugInfo: SurfaceFlinger unresponsive (%s [%d]) - exit", strerror(-err), err); - return TIMED_OUT; - } - outLayers->clear(); - mCurrentState.traverseInZOrder([&](Layer* layer) { - outLayers->push_back(layer->getLayerDebugInfo()); - }); + postMessageSync(new LambdaMessage([&]() { + mDrawingState.traverseInZOrder([&](Layer* layer) { + outLayers->push_back(layer->getLayerDebugInfo()); + }); - mStateLock.unlock(); + })); return NO_ERROR; } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index a22d6fc649..7767789526 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -446,7 +446,7 @@ private: HdrCapabilities* outCapabilities) const override; status_t enableVSyncInjections(bool enable) override; status_t injectVSync(nsecs_t when) override; - status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const override; + status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) override; status_t getColorManagement(bool* outGetColorManagement) const override; status_t getCompositionPreference(ui::Dataspace* outDataspace, ui::PixelFormat* outPixelFormat, ui::Dataspace* outWideColorGamutDataspace, |