Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6c0dffa authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/22898934']...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/22898934'] into sparse-9966157-L20600000960323900.
SPARSE_CHANGE: I07e3f2c89d62d44455fda9fe3f8203215c22abf7

Change-Id: I5b1970ecfea2b5c46cacf8168298fff343815bd1
parents beacbb63 7adc2aad
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -254,7 +254,8 @@ Layer::~Layer() {
        mFlinger->mTunnelModeEnabledReporter->decrementTunnelModeCount();
    }
    if (mHadClonedChild) {
        mFlinger->mNumClones--;
        auto& roots = mFlinger->mLayerMirrorRoots;
        roots.erase(std::remove(roots.begin(), roots.end(), this), roots.end());
    }
    if (hasTrustedPresentationListener()) {
        mFlinger->mNumTrustedPresentationListeners--;
@@ -2591,7 +2592,7 @@ void Layer::updateCloneBufferInfo() {
    mDrawingState.inputInfo = tmpInputInfo;
}

void Layer::updateMirrorInfo() {
bool Layer::updateMirrorInfo(const std::deque<Layer*>& cloneRootsPendingUpdates) {
    if (mClonedChild == nullptr || !mClonedChild->isClonedFromAlive()) {
        // If mClonedChild is null, there is nothing to mirror. If isClonedFromAlive returns false,
        // it means that there is a clone, but the layer it was cloned from has been destroyed. In
@@ -2599,7 +2600,7 @@ void Layer::updateMirrorInfo() {
        // destroyed. The root, this layer, will still be around since the client can continue
        // to hold a reference, but no cloned layers will be displayed.
        mClonedChild = nullptr;
        return;
        return true;
    }

    std::map<sp<Layer>, sp<Layer>> clonedLayersMap;
@@ -2614,6 +2615,13 @@ void Layer::updateMirrorInfo() {
    mClonedChild->updateClonedDrawingState(clonedLayersMap);
    mClonedChild->updateClonedChildren(sp<Layer>::fromExisting(this), clonedLayersMap);
    mClonedChild->updateClonedRelatives(clonedLayersMap);

    for (Layer* root : cloneRootsPendingUpdates) {
        if (clonedLayersMap.find(sp<Layer>::fromExisting(root)) != clonedLayersMap.end()) {
            return false;
        }
    }
    return true;
}

void Layer::updateClonedDrawingState(std::map<sp<Layer>, sp<Layer>>& clonedLayersMap) {
@@ -2761,7 +2769,7 @@ bool Layer::isInternalDisplayOverlay() const {
void Layer::setClonedChild(const sp<Layer>& clonedChild) {
    mClonedChild = clonedChild;
    mHadClonedChild = true;
    mFlinger->mNumClones++;
    mFlinger->mLayerMirrorRoots.push_back(this);
}

bool Layer::setDropInputMode(gui::DropInputMode mode) {
+1 −1
Original line number Diff line number Diff line
@@ -645,7 +645,7 @@ public:

    gui::WindowInfo::Type getWindowType() const { return mWindowType; }

    void updateMirrorInfo();
    bool updateMirrorInfo(const std::deque<Layer*>& cloneRootsPendingUpdates);

    /*
     * doTransaction - process the transaction. This is a good place to figure
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ void LayerRenderArea::render(std::function<void()> drawLayers) {
    // If layer is offscreen, update mirroring info if it exists
    if (mLayer->isRemovedFromCurrentState()) {
        mLayer->traverse(LayerVector::StateSet::Drawing,
                         [&](Layer* layer) { layer->updateMirrorInfo(); });
                         [&](Layer* layer) { layer->updateMirrorInfo({}); });
        mLayer->traverse(LayerVector::StateSet::Drawing,
                         [&](Layer* layer) { layer->updateCloneBufferInfo(); });
    }
+16 −3
Original line number Diff line number Diff line
@@ -3988,8 +3988,21 @@ void SurfaceFlinger::doCommitTransactions() {
    }

    commitOffscreenLayers();
    if (mNumClones > 0) {
        mDrawingState.traverse([&](Layer* layer) { layer->updateMirrorInfo(); });
    if (mLayerMirrorRoots.size() > 0) {
        std::deque<Layer*> pendingUpdates;
        pendingUpdates.insert(pendingUpdates.end(), mLayerMirrorRoots.begin(),
                              mLayerMirrorRoots.end());
        std::vector<Layer*> needsUpdating;
        for (Layer* cloneRoot : mLayerMirrorRoots) {
            pendingUpdates.pop_front();
            if (cloneRoot->updateMirrorInfo(pendingUpdates)) {
            } else {
                needsUpdating.push_back(cloneRoot);
            }
        }
        for (Layer* cloneRoot : needsUpdating) {
            cloneRoot->updateMirrorInfo({});
        }
    }
}

@@ -4093,7 +4106,7 @@ bool SurfaceFlinger::latchBuffers() {
        mBootStage = BootStage::BOOTANIMATION;
    }

    if (mNumClones > 0) {
    if (mLayerMirrorRoots.size() > 0) {
        mDrawingState.traverse([&](Layer* layer) { layer->updateCloneBufferInfo(); });
    }

+1 −2
Original line number Diff line number Diff line
@@ -295,8 +295,7 @@ public:
    // the client can no longer modify this layer directly.
    void onHandleDestroyed(BBinder* handle, sp<Layer>& layer, uint32_t layerId);

    // TODO: Remove atomic if move dtor to main thread CL lands
    std::atomic<uint32_t> mNumClones;
    std::vector<Layer*> mLayerMirrorRoots;

    TransactionCallbackInvoker& getTransactionCallbackInvoker() {
        return mTransactionCallbackInvoker;