OSDN Git Service

Snap for 7952937 from f2cf7639a80206c43c83cf6076998b45f4feb24b to sc-v2-release
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>
Tue, 30 Nov 2021 00:07:13 +0000 (00:07 +0000)
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>
Tue, 30 Nov 2021 00:07:13 +0000 (00:07 +0000)
Change-Id: Iea8c6feaff3595322af47d8fbda5f2160afbb297

libs/gui/BLASTBufferQueue.cpp
libs/gui/include/gui/BLASTBufferQueue.h
services/surfaceflinger/BufferLayer.cpp
services/surfaceflinger/BufferStateLayer.cpp
services/surfaceflinger/Layer.cpp
services/surfaceflinger/Layer.h

index 085a11a..f357c17 100644 (file)
@@ -988,4 +988,9 @@ uint32_t BLASTBufferQueue::getLastTransformHint() const {
     }
 }
 
+uint64_t BLASTBufferQueue::getLastAcquiredFrameNum() {
+    std::unique_lock _lock{mMutex};
+    return mLastAcquiredFrameNumber;
+}
+
 } // namespace android
index 615f284..698844c 100644 (file)
@@ -110,6 +110,8 @@ public:
     uint32_t getLastTransformHint() const;
     void flushShadowQueue();
 
+    uint64_t getLastAcquiredFrameNum();
+
     virtual ~BLASTBufferQueue();
 
 private:
index 71db330..8c97f12 100644 (file)
@@ -831,7 +831,7 @@ void BufferLayer::updateCloneBufferInfo() {
     wp<Layer> tmpTouchableRegionCrop = mDrawingState.touchableRegionCrop;
     WindowInfo tmpInputInfo = mDrawingState.inputInfo;
 
-    mDrawingState = clonedFrom->mDrawingState;
+    cloneDrawingState(clonedFrom.get());
 
     mDrawingState.touchableRegionCrop = tmpTouchableRegionCrop;
     mDrawingState.zOrderRelativeOf = tmpZOrderRelativeOf;
index cd531d6..df91904 100644 (file)
@@ -66,7 +66,7 @@ BufferStateLayer::~BufferStateLayer() {
     // one of the layers, in this case the original layer, needs to handle the deletion. The
     // original layer and the clone should be removed at the same time so there shouldn't be any
     // issue with the clone layer trying to use the texture.
-    if (mBufferInfo.mBuffer != nullptr && !isClone()) {
+    if (mBufferInfo.mBuffer != nullptr) {
         callReleaseBufferCallback(mDrawingState.releaseBufferListener,
                                   mBufferInfo.mBuffer->getBuffer(), mBufferInfo.mFrameNumber,
                                   mBufferInfo.mFence, mTransformHint,
index e2f34fa..80c61b9 100644 (file)
@@ -2485,8 +2485,7 @@ Region Layer::getVisibleRegion(const DisplayDevice* display) const {
 }
 
 void Layer::setInitialValuesForClone(const sp<Layer>& clonedFrom) {
-    // copy drawing state from cloned layer
-    mDrawingState = clonedFrom->mDrawingState;
+    cloneDrawingState(clonedFrom.get());
     mClonedFrom = clonedFrom;
 }
 
@@ -2521,7 +2520,7 @@ void Layer::updateClonedDrawingState(std::map<sp<Layer>, sp<Layer>>& clonedLayer
     // since we may be able to pull out other children that are still alive.
     if (isClonedFromAlive()) {
         sp<Layer> clonedFrom = getClonedFrom();
-        mDrawingState = clonedFrom->mDrawingState;
+        cloneDrawingState(clonedFrom.get());
         clonedLayersMap.emplace(clonedFrom, this);
     }
 
@@ -2684,6 +2683,13 @@ bool Layer::setDropInputMode(gui::DropInputMode mode) {
     return true;
 }
 
+void Layer::cloneDrawingState(const Layer* from) {
+    mDrawingState = from->mDrawingState;
+    // Skip callback info since they are not applicable for cloned layers.
+    mDrawingState.releaseBufferListener = nullptr;
+    mDrawingState.callbackHandles = {};
+}
+
 // ---------------------------------------------------------------------------
 
 std::ostream& operator<<(std::ostream& stream, const Layer::FrameRate& rate) {
index b107f8e..c1af468 100644 (file)
@@ -929,6 +929,7 @@ protected:
     bool isClone() { return mClonedFrom != nullptr; }
     bool isClonedFromAlive() { return getClonedFrom() != nullptr; }
 
+    void cloneDrawingState(const Layer* from);
     void updateClonedDrawingState(std::map<sp<Layer>, sp<Layer>>& clonedLayersMap);
     void updateClonedChildren(const sp<Layer>& mirrorRoot,
                               std::map<sp<Layer>, sp<Layer>>& clonedLayersMap);