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

Commit c1498e6e authored by David Sodman's avatar David Sodman
Browse files

SF: Use getVisibleLayers... in doComposeSurfaces

in b/114101122, it is discovered that there is a problem
in indexing the SF mCompositionInfo by displayId because
there are multiple displays that have the same id (-1).

This change uses getVisibleLayersSortedByZ in doComposeSurfaces
until we can fix the indexing of mCompositionInfo.

Bug: 114101122
Test: run cts -m CtsViewTestCases, CtsMediaTestCases

Change-Id: I90adb957c183400c396f25fa9583b668e1da8417
parent 78bc0453
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -500,6 +500,8 @@ status_t HWComposer::prepare(DisplayDevice& display,
            validateChange(compositionInfo.compositionType,
                    changedTypes[&*hwcLayer]);
            compositionInfo.compositionType = changedTypes[&*hwcLayer];
            compositionInfo.layer->mLayer->setCompositionType(displayId,
                    compositionInfo.compositionType, false);
        }

        switch (compositionInfo.compositionType) {
@@ -520,6 +522,7 @@ status_t HWComposer::prepare(DisplayDevice& display,
                layerRequests[&*hwcLayer] ==
                        HWC2::LayerRequest::ClearClientTarget) {
            compositionInfo.hwc.clearClientTarget = true;
            compositionInfo.layer->mLayer->setClearClientTarget(displayId, true);
        } else {
            if (layerRequests.count(&*hwcLayer) != 0) {
                LOG_DISPLAY_ERROR(displayId,
@@ -527,6 +530,7 @@ status_t HWComposer::prepare(DisplayDevice& display,
                                          .c_str());
            }
            compositionInfo.hwc.clearClientTarget = false;
            compositionInfo.layer->mLayer->setClearClientTarget(displayId, false);
        }
    }

+4 −0
Original line number Diff line number Diff line
@@ -680,6 +680,10 @@ void Layer::clearWithOpenGL(const RenderArea& renderArea, float red, float green
    engine.drawMesh(getBE().mMesh);
}

void Layer::clearWithOpenGL(const RenderArea& renderArea) const {
    clearWithOpenGL(renderArea, 0, 0, 0, 0);
}

void Layer::setCompositionType(int32_t displayId, HWC2::Composition type, bool /*callIntoHwc*/) {
    if (getBE().mHwcLayers.count(displayId) == 0) {
        ALOGE("setCompositionType called without a valid HWC layer");
+1 −0
Original line number Diff line number Diff line
@@ -503,6 +503,7 @@ public:
    }

    // -----------------------------------------------------------------------
    void clearWithOpenGL(const RenderArea& renderArea) const;

    inline const State& getDrawingState() const { return mDrawingState; }
    inline const State& getCurrentState() const { return mCurrentState; }
+1 −1
Original line number Diff line number Diff line
@@ -94,8 +94,8 @@ public:
    void clear(renderengine::RenderEngine& renderEngine);
    renderengine::Mesh& getMesh() { return mMesh; }

private:
    Layer*const mLayer;
private:
    // The mesh used to draw the layer in GLES composition mode
    renderengine::Mesh mMesh;

+11 −12
Original line number Diff line number Diff line
@@ -3218,30 +3218,29 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& display) {
    ALOGV("Rendering client layers");
    const ui::Transform& displayTransform = display->getTransform();
    bool firstLayer = true;
    for (auto& compositionInfo : getBE().mCompositionInfo[displayId]) {
        const Region bounds(display->bounds());
    for (auto& layer : display->getVisibleLayersSortedByZ()) {
        const Region clip(bounds.intersect(
                displayTransform.transform(compositionInfo.layer->mLayer->visibleRegion)));
        ALOGV("Layer: %s", compositionInfo.layerName.c_str());
                displayTransform.transform(layer->visibleRegion)));
        ALOGV("Layer: %s", layer->getName().string());
        ALOGV("  Composition type: %s", to_string(layer->getCompositionType(displayId)).c_str());
        if (!clip.isEmpty()) {
            switch (compositionInfo.compositionType) {
            switch (layer->getCompositionType(displayId)) {
                case HWC2::Composition::Cursor:
                case HWC2::Composition::Device:
                case HWC2::Composition::Sideband:
                case HWC2::Composition::SolidColor: {
                    const Layer::State& state(compositionInfo.layer->mLayer->getDrawingState());
                    const bool opaque = compositionInfo.layer->mLayer->isOpaque(state) &&
                                        compositionInfo.layer->mLayer->getAlpha() == 1.0f;
                    if (compositionInfo.hwc.clearClientTarget && !firstLayer && opaque &&
                    const Layer::State& state(layer->getDrawingState());
                    if (layer->getClearClientTarget(displayId) && !firstLayer &&
                        layer->isOpaque(state) && (layer->getAlpha() == 1.0f) &&
                        hasClientComposition) {
                        // never clear the very first layer since we're
                        // guaranteed the FB is already cleared
                        compositionInfo.layer->clear(getRenderEngine());
                        layer->clearWithOpenGL(renderArea);
                    }
                    break;
                }
                case HWC2::Composition::Client: {
                    compositionInfo.layer->mLayer->draw(renderArea, clip);
                    layer->draw(renderArea, clip);
                    break;
                }
                default: