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

Commit 1d42093c authored by Sally Qi's avatar Sally Qi Committed by Android (Google) Code Review
Browse files

Merge "[Lut] clear out the lut if an invalud lut is provided." into main

parents 35e8e4e1 1f7ad4ea
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -384,8 +384,13 @@ void Display::applyLayerLutsToLayers(const LayerLuts& layerLuts) {

        if (auto lutsIt = layerLuts.find(hwcLayer); lutsIt != layerLuts.end()) {
            if (auto mapperIt = mapper.find(hwcLayer); mapperIt != mapper.end()) {
                layer->applyDeviceLayerLut(::android::base::unique_fd(mapperIt->second.release()),
                if (mapperIt->second.ok()) {
                    layer->applyDeviceLayerLut(::android::base::unique_fd(
                                                       mapperIt->second.release()),
                                               lutsIt->second);
                } else {
                    layer->applyDeviceLayerLut(::android::base::unique_fd(), lutsIt->second);
                }
            }
        }
    }
+19 −15
Original line number Diff line number Diff line
@@ -1012,6 +1012,7 @@ void OutputLayer::applyDeviceLayerLut(
    auto& state = editState();
    LOG_FATAL_IF(!state.hwc);
    auto& hwcState = *state.hwc;
    if (lutFd.ok()) {
        std::vector<int32_t> offsets;
        std::vector<int32_t> dimensions;
        std::vector<int32_t> sizes;
@@ -1029,6 +1030,9 @@ void OutputLayer::applyDeviceLayerLut(
        hwcState.luts = std::make_shared<gui::DisplayLuts>(std::move(lutFd), std::move(offsets),
                                                           std::move(dimensions), std::move(sizes),
                                                           std::move(samplingKeys));
    } else {
        hwcState.luts = nullptr;
    }
}

bool OutputLayer::needsFiltering() const {
+6 −2
Original line number Diff line number Diff line
@@ -626,9 +626,9 @@ Error Display::getRequestedLuts(LayerLuts* outLuts,
        auto layer = getLayerById(layerIds[i]);
        if (layer) {
            auto& layerLut = tmpLuts[i];
            std::vector<std::pair<int32_t, LutProperties>> lutOffsetsAndProperties;
            if (layerLut.luts.pfd.get() >= 0 && layerLut.luts.offsets.has_value()) {
                const auto& offsets = layerLut.luts.offsets.value();
                std::vector<std::pair<int32_t, LutProperties>> lutOffsetsAndProperties;
                lutOffsetsAndProperties.reserve(offsets.size());
                std::transform(offsets.begin(), offsets.end(), layerLut.luts.lutProperties.begin(),
                               std::back_inserter(lutOffsetsAndProperties),
@@ -637,8 +637,12 @@ Error Display::getRequestedLuts(LayerLuts* outLuts,
                lutFileDescriptorMapper.emplace_or_replace(layer.get(),
                                                           ::android::base::unique_fd(
                                                                   layerLut.luts.pfd.release()));
            } else if (layerLut.luts.pfd.get() < 0) {
                outLuts->emplace_or_replace(layer.get(), lutOffsetsAndProperties);
                lutFileDescriptorMapper.emplace_or_replace(layer.get(),
                                                           ::android::base::unique_fd());
            } else {
                ALOGE("getRequestedLuts: invalid luts on layer %" PRIu64 " found"
                ALOGE("getRequestedLuts: invalid luts offsets on layer %" PRIu64 " found"
                      " on display %" PRIu64 ". pfd.get()=%d, offsets.has_value()=%d",
                      layerIds[i], mId, layerLut.luts.pfd.get(), layerLut.luts.offsets.has_value());
            }