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

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

Merge "[Lut screenshot] backend implementation" into main

parents 0c487eb7 2beca489
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -1678,6 +1678,29 @@ Error AidlComposer::setLayerPictureProfileId(Display display, Layer layer, Pictu
    return error;
}

Error AidlComposer::getLuts(Display display, const std::vector<sp<GraphicBuffer>>& buffers,
                            std::vector<aidl::android::hardware::graphics::composer3::Luts>* luts) {
    std::vector<aidl::android::hardware::graphics::composer3::Buffer> aidlBuffers;
    aidlBuffers.reserve(buffers.size());

    for (auto& buffer : buffers) {
        if (buffer.get()) {
            aidl::android::hardware::graphics::composer3::Buffer aidlBuffer;
            aidlBuffer.handle.emplace(::android::dupToAidl(buffer->getNativeBuffer()->handle));
            aidlBuffers.emplace_back(std::move(aidlBuffer));
        }
    }

    const auto status =
            mAidlComposerClient->getLuts(translate<int64_t>(display), aidlBuffers, luts);
    if (!status.isOk()) {
        ALOGE("getLuts failed %s", status.getDescription().c_str());
        return static_cast<Error>(status.getServiceSpecificError());
    }

    return Error::NONE;
}

ftl::Optional<std::reference_wrapper<ComposerClientWriter>> AidlComposer::getWriter(Display display)
        REQUIRES_SHARED(mMutex) {
    return mWriters.get(display);
+2 −0
Original line number Diff line number Diff line
@@ -245,6 +245,8 @@ public:
    Error getMaxLayerPictureProfiles(Display, int32_t* outMaxProfiles) override;
    Error setDisplayPictureProfileId(Display, PictureProfileId id) override;
    Error setLayerPictureProfileId(Display, Layer, PictureProfileId id) override;
    Error getLuts(Display, const std::vector<sp<GraphicBuffer>>&,
                  std::vector<aidl::android::hardware::graphics::composer3::Luts>*) override;

private:
    // Many public functions above simply write a command into the command
+3 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#include <aidl/android/hardware/graphics/composer3/DisplayConfiguration.h>
#include <aidl/android/hardware/graphics/composer3/DisplayLuts.h>
#include <aidl/android/hardware/graphics/composer3/IComposerCallback.h>
#include <aidl/android/hardware/graphics/composer3/Luts.h>
#include <aidl/android/hardware/graphics/composer3/OverlayProperties.h>

#include <optional>
@@ -313,6 +314,8 @@ public:
    virtual Error getMaxLayerPictureProfiles(Display display, int32_t* outMaxProfiles) = 0;
    virtual Error setDisplayPictureProfileId(Display display, PictureProfileId id) = 0;
    virtual Error setLayerPictureProfileId(Display display, Layer layer, PictureProfileId id) = 0;
    virtual Error getLuts(Display display, const std::vector<sp<GraphicBuffer>>&,
                          std::vector<V3_0::Luts>*) = 0;
};

} // namespace Hwc2
+6 −0
Original line number Diff line number Diff line
@@ -669,6 +669,12 @@ Error Display::setPictureProfileHandle(const PictureProfileHandle& handle) {
    return static_cast<Error>(error);
}

Error Display::getLuts(const std::vector<sp<GraphicBuffer>>& buffers,
                       std::vector<aidl::android::hardware::graphics::composer3::Luts>* outLuts) {
    const auto error = mComposer.getLuts(mId, buffers, outLuts);
    return static_cast<Error>(error);
}

// For use by Device

void Display::setConnected(bool connected) {
+5 −0
Original line number Diff line number Diff line
@@ -203,6 +203,9 @@ public:
    [[nodiscard]] virtual hal::Error getMaxLayerPictureProfiles(int32_t* maxProfiles) = 0;
    [[nodiscard]] virtual hal::Error setPictureProfileHandle(
            const PictureProfileHandle& handle) = 0;
    [[nodiscard]] virtual hal::Error getLuts(
            const std::vector<android::sp<android::GraphicBuffer>>&,
            std::vector<aidl::android::hardware::graphics::composer3::Luts>*) = 0;
};

namespace impl {
@@ -288,6 +291,8 @@ public:
    hal::Error setIdleTimerEnabled(std::chrono::milliseconds timeout) override;
    hal::Error getMaxLayerPictureProfiles(int32_t* maxProfiles) override;
    hal::Error setPictureProfileHandle(const android::PictureProfileHandle& handle) override;
    hal::Error getLuts(const std::vector<android::sp<android::GraphicBuffer>>&,
                       std::vector<aidl::android::hardware::graphics::composer3::Luts>*) override;

    // Other Display methods
    hal::HWDisplayId getId() const override { return mId; }
Loading