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

Commit 4e700e91 authored by Alec Mouri's avatar Alec Mouri Committed by Android (Google) Code Review
Browse files

Merge "SF caching: Skip BT601_625 layers for caching and hole-punch" into sc-dev

parents aabd53ca a7e006b3
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -141,7 +141,7 @@ public:


    compositionengine::OutputLayer* getBlurLayer() const;
    compositionengine::OutputLayer* getBlurLayer() const;


    bool hasHdrLayers() const;
    bool hasUnsupportedDataspace() const;


    bool hasProtectedLayers() const;
    bool hasProtectedLayers() const;


+0 −7
Original line number Original line Diff line number Diff line
@@ -242,13 +242,6 @@ public:


    ui::Dataspace getDataspace() const { return mOutputDataspace.get(); }
    ui::Dataspace getDataspace() const { return mOutputDataspace.get(); }


    bool isHdr() const {
        const ui::Dataspace transfer =
                static_cast<ui::Dataspace>(getDataspace() & ui::Dataspace::TRANSFER_MASK);
        return (transfer == ui::Dataspace::TRANSFER_ST2084 ||
                transfer == ui::Dataspace::TRANSFER_HLG);
    }

    bool isProtected() const {
    bool isProtected() const {
        return getOutputLayer()->getLayerFE().getCompositionState()->hasProtectedContent;
        return getOutputLayer()->getLayerFE().getCompositionState()->hasProtectedContent;
    }
    }
+17 −6
Original line number Original line Diff line number Diff line
@@ -295,9 +295,7 @@ bool CachedSet::requiresHolePunch() const {
        return false;
        return false;
    }
    }


    // Do not use a hole punch with an HDR layer; this should be done in client
    if (hasUnsupportedDataspace()) {
    // composition to properly mix HDR with SDR.
    if (hasHdrLayers()) {
        return false;
        return false;
    }
    }


@@ -352,9 +350,22 @@ compositionengine::OutputLayer* CachedSet::getBlurLayer() const {
    return mBlurLayer ? mBlurLayer->getOutputLayer() : nullptr;
    return mBlurLayer ? mBlurLayer->getOutputLayer() : nullptr;
}
}


bool CachedSet::hasHdrLayers() const {
bool CachedSet::hasUnsupportedDataspace() const {
    return std::any_of(mLayers.cbegin(), mLayers.cend(),
    return std::any_of(mLayers.cbegin(), mLayers.cend(), [](const Layer& layer) {
                       [](const Layer& layer) { return layer.getState()->isHdr(); });
        auto dataspace = layer.getState()->getDataspace();
        const auto transfer = static_cast<ui::Dataspace>(dataspace & ui::Dataspace::TRANSFER_MASK);
        if (transfer == ui::Dataspace::TRANSFER_ST2084 || transfer == ui::Dataspace::TRANSFER_HLG) {
            // Skip HDR.
            return true;
        }

        if ((dataspace & HAL_DATASPACE_STANDARD_MASK) == HAL_DATASPACE_STANDARD_BT601_625) {
            // RenderEngine does not match some DPUs, so skip
            // to avoid flickering/color differences.
            return true;
        }
        return false;
    });
}
}


bool CachedSet::hasProtectedLayers() const {
bool CachedSet::hasProtectedLayers() const {
+1 −1
Original line number Original line Diff line number Diff line
@@ -420,7 +420,7 @@ std::vector<Flattener::Run> Flattener::findCandidateRuns(time_point now) const {
        const bool layerIsInactive = now - currentSet->getLastUpdate() > mActiveLayerTimeout;
        const bool layerIsInactive = now - currentSet->getLastUpdate() > mActiveLayerTimeout;
        const bool layerHasBlur = currentSet->hasBlurBehind();
        const bool layerHasBlur = currentSet->hasBlurBehind();
        if (layerIsInactive && (firstLayer || runHasFirstLayer || !layerHasBlur) &&
        if (layerIsInactive && (firstLayer || runHasFirstLayer || !layerHasBlur) &&
            !currentSet->hasHdrLayers()) {
            !currentSet->hasUnsupportedDataspace()) {
            if (isPartOfRun) {
            if (isPartOfRun) {
                builder.append(currentSet->getLayerCount());
                builder.append(currentSet->getLayerCount());
            } else {
            } else {
+14 −0
Original line number Original line Diff line number Diff line
@@ -457,6 +457,20 @@ TEST_F(CachedSetTest, holePunch_requiresNonHdr) {
    EXPECT_FALSE(cachedSet.requiresHolePunch());
    EXPECT_FALSE(cachedSet.requiresHolePunch());
}
}


TEST_F(CachedSetTest, holePunch_requiresNonBT601_625) {
    mTestLayers[0]->outputLayerCompositionState.dataspace = ui::Dataspace::STANDARD_BT601_625;
    mTestLayers[0]->layerState->update(&mTestLayers[0]->outputLayer);

    CachedSet::Layer& layer = *mTestLayers[0]->cachedSetLayer.get();
    mTestLayers[0]->layerFECompositionState.buffer = sp<GraphicBuffer>::make();
    sp<mock::LayerFE> layerFE = mTestLayers[0]->layerFE;

    CachedSet cachedSet(layer);
    EXPECT_CALL(*layerFE, hasRoundedCorners()).WillRepeatedly(Return(true));

    EXPECT_FALSE(cachedSet.requiresHolePunch());
}

TEST_F(CachedSetTest, requiresHolePunch) {
TEST_F(CachedSetTest, requiresHolePunch) {
    CachedSet::Layer& layer = *mTestLayers[0]->cachedSetLayer.get();
    CachedSet::Layer& layer = *mTestLayers[0]->cachedSetLayer.get();
    mTestLayers[0]->layerFECompositionState.buffer = sp<GraphicBuffer>::make();
    mTestLayers[0]->layerFECompositionState.buffer = sp<GraphicBuffer>::make();
Loading