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

Commit a1f13f4c authored by Rob Carr's avatar Rob Carr Committed by Android (Google) Code Review
Browse files

Merge "Optimize mirror layer management" into sc-dev

parents 06e31f95 6a0382d6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -177,6 +177,9 @@ Layer::~Layer() {
    if (mDrawingState.sidebandStream != nullptr) {
        mFlinger->mTunnelModeEnabledReporter->decrementTunnelModeCount();
    }
    if (mHadClonedChild) {
        mFlinger->mNumClones--;
    }
}

LayerCreationArgs::LayerCreationArgs(SurfaceFlinger* flinger, sp<Client> client, std::string name,
@@ -2536,6 +2539,12 @@ bool Layer::getPrimaryDisplayOnly() const {
    return parent == nullptr ? false : parent->getPrimaryDisplayOnly();
}

void Layer::setClonedChild(const sp<Layer>& clonedChild) {
    mClonedChild = clonedChild;
    mHadClonedChild = true;
    mFlinger->mNumClones++;
}

// ---------------------------------------------------------------------------

std::ostream& operator<<(std::ostream& stream, const Layer::FrameRate& rate) {
+2 −0
Original line number Diff line number Diff line
@@ -863,6 +863,8 @@ public:
    // The layers in the cloned hierarchy will match the lifetime of the real layers. That is
    // if the real layer is destroyed, then the clone layer will also be destroyed.
    sp<Layer> mClonedChild;
    bool mHadClonedChild = false;
    void setClonedChild(const sp<Layer>& mClonedChild);

    mutable bool contentDirty{false};
    Region surfaceDamageRegion;
+7 −3
Original line number Diff line number Diff line
@@ -3255,8 +3255,10 @@ void SurfaceFlinger::commitTransactionLocked() {
    }

    commitOffscreenLayers();
    if (mNumClones > 0) {
        mDrawingState.traverse([&](Layer* layer) { layer->updateMirrorInfo(); });
    }
}

void SurfaceFlinger::commitOffscreenLayers() {
    for (Layer* offscreenLayer : mOffscreenLayers) {
@@ -3361,7 +3363,9 @@ bool SurfaceFlinger::handlePageFlip() {
        mBootStage = BootStage::BOOTANIMATION;
    }

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

    // Only continue with the refresh if there is actually new work to do
    return !mLayersWithQueuedFrames.empty() && newDataLatched;
@@ -4246,7 +4250,7 @@ status_t SurfaceFlinger::mirrorLayer(const sp<Client>& client, const sp<IBinder>
            return result;
        }

        mirrorLayer->mClonedChild = mirrorFrom->createClone();
        mirrorLayer->setClonedChild(mirrorFrom->createClone());
    }

    *outLayerId = mirrorLayer->sequence;
+3 −0
Original line number Diff line number Diff line
@@ -316,6 +316,9 @@ public:
    void removeHierarchyFromOffscreenLayers(Layer* layer);
    void removeFromOffscreenLayers(Layer* layer);

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

    TransactionCallbackInvoker& getTransactionCallbackInvoker() {
        return mTransactionCallbackInvoker;
    }