diff options
author | John Reck <jreck@google.com> | 2019-06-12 18:10:47 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-06-12 18:10:47 -0700 |
commit | 282048a2b0b717b638a237454d38e421aa2503dc (patch) | |
tree | 6f1e3c385383c596a476b97acc181a19ede10e6f | |
parent | c746066221bb36939d19d1ac84fb71a5ddbda2e2 (diff) | |
parent | 2c52298236d5f8214938402c06e6adaba0fe873b (diff) | |
download | base-282048a2b0b717b638a237454d38e421aa2503dc.tar.gz |
Merge "Fix setPositionListener race condition" into qt-dev
am: 2c52298236
Change-Id: Iea1515f11646a38bf7252ac7ee547296aeddced1
-rw-r--r-- | libs/hwui/RenderNode.cpp | 6 | ||||
-rw-r--r-- | libs/hwui/RenderNode.h | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index e0ed3e4940a8..b73347b233d7 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -264,6 +264,12 @@ void RenderNode::syncProperties() { } void RenderNode::pushStagingPropertiesChanges(TreeInfo& info) { + if (mPositionListenerDirty) { + mPositionListener = std::move(mStagingPositionListener); + mStagingPositionListener = nullptr; + mPositionListenerDirty = false; + } + // Push the animators first so that setupStartValueIfNecessary() is called // before properties() is trampled by stagingProperties(), as they are // required by some animators. diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h index 23e7a0e60554..c6db7f1ba60d 100644 --- a/libs/hwui/RenderNode.h +++ b/libs/hwui/RenderNode.h @@ -188,11 +188,9 @@ public: virtual void onPositionLost(RenderNode& node, const TreeInfo* info) = 0; }; - // Note this is not thread safe, this needs to be called - // before the RenderNode is used for drawing. - // RenderNode takes ownership of the pointer ANDROID_API void setPositionListener(PositionListener* listener) { - mPositionListener = listener; + mStagingPositionListener = listener; + mPositionListenerDirty = true; } // This is only modified in MODE_FULL, so it can be safely accessed @@ -275,6 +273,8 @@ private: // mDisplayList, not mStagingDisplayList. uint32_t mParentCount; + bool mPositionListenerDirty = false; + sp<PositionListener> mStagingPositionListener; sp<PositionListener> mPositionListener; UsageHint mUsageHint = UsageHint::Unknown; |