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

Commit d1e6ba78 authored by Dominik Laskowski's avatar Dominik Laskowski Committed by Automerger Merge Worker
Browse files

Merge "SF: Defer setDisplayBrightness to Binder thread" into rvc-dev am: 6650884c

Change-Id: I4f0a24c04f3e9560fc7a9c103d66f8f867fad0ca
parents 341ef1b0 6650884c
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -74,7 +74,7 @@ public:
    MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(DisplayId, bool, uint8_t, uint64_t));
    MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(DisplayId, bool, uint8_t, uint64_t));
    MOCK_METHOD4(getDisplayedContentSample,
    MOCK_METHOD4(getDisplayedContentSample,
                 status_t(DisplayId, uint64_t, uint64_t, DisplayedFrameStats*));
                 status_t(DisplayId, uint64_t, uint64_t, DisplayedFrameStats*));
    MOCK_METHOD2(setDisplayBrightness, status_t(DisplayId, float));
    MOCK_METHOD2(setDisplayBrightness, std::future<status_t>(DisplayId, float));
    MOCK_METHOD2(getDisplayBrightnessSupport, status_t(DisplayId, bool*));
    MOCK_METHOD2(getDisplayBrightnessSupport, status_t(DisplayId, bool*));


    MOCK_METHOD2(onHotplug,
    MOCK_METHOD2(onHotplug,
+10 −6
Original line number Original line Diff line number Diff line
@@ -25,7 +25,6 @@
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#define ATRACE_TAG ATRACE_TAG_GRAPHICS


#include "HWC2.h"
#include "HWC2.h"
#include "ComposerHal.h"


#include <ui/Fence.h>
#include <ui/Fence.h>
#include <ui/FloatRect.h>
#include <ui/FloatRect.h>
@@ -38,6 +37,9 @@
#include <iterator>
#include <iterator>
#include <set>
#include <set>


#include "../Promise.h"
#include "ComposerHal.h"

namespace android {
namespace android {


using android::Fence;
using android::Fence;
@@ -640,12 +642,14 @@ Error Display::presentOrValidate(uint32_t* outNumTypes, uint32_t* outNumRequests
    return error;
    return error;
}
}


Error Display::setDisplayBrightness(float brightness) const {
std::future<Error> Display::setDisplayBrightness(float brightness) {
    const auto intError = mComposer.setDisplayBrightness(mId, brightness);
    return promise::defer([composer = &mComposer, id = mId, brightness] {
        const auto intError = composer->setDisplayBrightness(id, brightness);
        return static_cast<Error>(intError);
        return static_cast<Error>(intError);
    });
}
}


Error Display::setAutoLowLatencyMode(bool on) const {
Error Display::setAutoLowLatencyMode(bool on) {
    auto intError = mComposer.setAutoLowLatencyMode(mId, on);
    auto intError = mComposer.setAutoLowLatencyMode(mId, on);
    return static_cast<Error>(intError);
    return static_cast<Error>(intError);
}
}
@@ -659,7 +663,7 @@ Error Display::getSupportedContentTypes(std::vector<ContentType>* outSupportedCo
    return static_cast<Error>(intError);
    return static_cast<Error>(intError);
}
}


Error Display::setContentType(ContentType contentType) const {
Error Display::setContentType(ContentType contentType) {
    auto intError = mComposer.setContentType(mId, contentType);
    auto intError = mComposer.setContentType(mId, contentType);
    return static_cast<Error>(intError);
    return static_cast<Error>(intError);
}
}
+8 −7
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@
#include <utils/Timers.h>
#include <utils/Timers.h>


#include <functional>
#include <functional>
#include <future>
#include <string>
#include <string>
#include <unordered_map>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
@@ -221,18 +222,18 @@ public:
    [[clang::warn_unused_result]] virtual hal::Error presentOrValidate(
    [[clang::warn_unused_result]] virtual hal::Error presentOrValidate(
            uint32_t* outNumTypes, uint32_t* outNumRequests,
            uint32_t* outNumTypes, uint32_t* outNumRequests,
            android::sp<android::Fence>* outPresentFence, uint32_t* state) = 0;
            android::sp<android::Fence>* outPresentFence, uint32_t* state) = 0;
    [[clang::warn_unused_result]] virtual hal::Error setDisplayBrightness(
    [[clang::warn_unused_result]] virtual std::future<hal::Error> setDisplayBrightness(
            float brightness) const = 0;
            float brightness) = 0;
    [[clang::warn_unused_result]] virtual hal::Error getDisplayVsyncPeriod(
    [[clang::warn_unused_result]] virtual hal::Error getDisplayVsyncPeriod(
            nsecs_t* outVsyncPeriod) const = 0;
            nsecs_t* outVsyncPeriod) const = 0;
    [[clang::warn_unused_result]] virtual hal::Error setActiveConfigWithConstraints(
    [[clang::warn_unused_result]] virtual hal::Error setActiveConfigWithConstraints(
            const std::shared_ptr<const HWC2::Display::Config>& config,
            const std::shared_ptr<const HWC2::Display::Config>& config,
            const hal::VsyncPeriodChangeConstraints& constraints,
            const hal::VsyncPeriodChangeConstraints& constraints,
            hal::VsyncPeriodChangeTimeline* outTimeline) = 0;
            hal::VsyncPeriodChangeTimeline* outTimeline) = 0;
    [[clang::warn_unused_result]] virtual hal::Error setAutoLowLatencyMode(bool on) const = 0;
    [[clang::warn_unused_result]] virtual hal::Error setAutoLowLatencyMode(bool on) = 0;
    [[clang::warn_unused_result]] virtual hal::Error getSupportedContentTypes(
    [[clang::warn_unused_result]] virtual hal::Error getSupportedContentTypes(
            std::vector<hal::ContentType>*) const = 0;
            std::vector<hal::ContentType>*) const = 0;
    [[clang::warn_unused_result]] virtual hal::Error setContentType(hal::ContentType) const = 0;
    [[clang::warn_unused_result]] virtual hal::Error setContentType(hal::ContentType) = 0;
};
};


namespace impl {
namespace impl {
@@ -294,16 +295,16 @@ public:
    hal::Error presentOrValidate(uint32_t* outNumTypes, uint32_t* outNumRequests,
    hal::Error presentOrValidate(uint32_t* outNumTypes, uint32_t* outNumRequests,
                                 android::sp<android::Fence>* outPresentFence,
                                 android::sp<android::Fence>* outPresentFence,
                                 uint32_t* state) override;
                                 uint32_t* state) override;
    hal::Error setDisplayBrightness(float brightness) const override;
    std::future<hal::Error> setDisplayBrightness(float brightness) override;
    hal::Error getDisplayVsyncPeriod(nsecs_t* outVsyncPeriod) const override;
    hal::Error getDisplayVsyncPeriod(nsecs_t* outVsyncPeriod) const override;
    hal::Error setActiveConfigWithConstraints(
    hal::Error setActiveConfigWithConstraints(
            const std::shared_ptr<const HWC2::Display::Config>& config,
            const std::shared_ptr<const HWC2::Display::Config>& config,
            const hal::VsyncPeriodChangeConstraints& constraints,
            const hal::VsyncPeriodChangeConstraints& constraints,
            hal::VsyncPeriodChangeTimeline* outTimeline) override;
            hal::VsyncPeriodChangeTimeline* outTimeline) override;
    hal::Error setAutoLowLatencyMode(bool on) const override;
    hal::Error setAutoLowLatencyMode(bool on) override;
    hal::Error getSupportedContentTypes(
    hal::Error getSupportedContentTypes(
            std::vector<hal::ContentType>* outSupportedContentTypes) const override;
            std::vector<hal::ContentType>* outSupportedContentTypes) const override;
    hal::Error setContentType(hal::ContentType contentType) const override;
    hal::Error setContentType(hal::ContentType) override;
    // Other Display methods
    // Other Display methods
    hal::HWDisplayId getId() const override { return mId; }
    hal::HWDisplayId getId() const override { return mId; }
    bool isConnected() const override { return mIsConnected; }
    bool isConnected() const override { return mIsConnected; }
+16 −11
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@
#include <utils/Trace.h>
#include <utils/Trace.h>


#include "../Layer.h" // needed only for debugging
#include "../Layer.h" // needed only for debugging
#include "../Promise.h"
#include "../SurfaceFlinger.h"
#include "../SurfaceFlinger.h"
#include "ComposerHal.h"
#include "ComposerHal.h"
#include "HWC2.h"
#include "HWC2.h"
@@ -794,9 +795,12 @@ status_t HWComposer::getDisplayedContentSample(DisplayId displayId, uint64_t max
    return NO_ERROR;
    return NO_ERROR;
}
}


status_t HWComposer::setDisplayBrightness(DisplayId displayId, float brightness) {
std::future<status_t> HWComposer::setDisplayBrightness(DisplayId displayId, float brightness) {
    RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
    RETURN_IF_INVALID_DISPLAY(displayId, promise::yield<status_t>(BAD_INDEX));
    const auto error = mDisplayData[displayId].hwcDisplay->setDisplayBrightness(brightness);
    auto& display = mDisplayData[displayId].hwcDisplay;

    return promise::chain(display->setDisplayBrightness(brightness))
            .then([displayId](hal::Error error) -> status_t {
                if (error == hal::Error::UNSUPPORTED) {
                if (error == hal::Error::UNSUPPORTED) {
                    RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
                    RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
                }
                }
@@ -805,6 +809,7 @@ status_t HWComposer::setDisplayBrightness(DisplayId displayId, float brightness)
                }
                }
                RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
                RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
                return NO_ERROR;
                return NO_ERROR;
            });
}
}


bool HWComposer::isUsingVrComposer() const {
bool HWComposer::isUsingVrComposer() const {
+3 −2
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@
#define ANDROID_SF_HWCOMPOSER_H
#define ANDROID_SF_HWCOMPOSER_H


#include <cstdint>
#include <cstdint>
#include <future>
#include <memory>
#include <memory>
#include <mutex>
#include <mutex>
#include <optional>
#include <optional>
@@ -163,7 +164,7 @@ public:
                                               DisplayedFrameStats* outStats) = 0;
                                               DisplayedFrameStats* outStats) = 0;


    // Sets the brightness of a display.
    // Sets the brightness of a display.
    virtual status_t setDisplayBrightness(DisplayId displayId, float brightness) = 0;
    virtual std::future<status_t> setDisplayBrightness(DisplayId displayId, float brightness) = 0;


    // Events handling ---------------------------------------------------------
    // Events handling ---------------------------------------------------------


@@ -305,7 +306,7 @@ public:
                                              uint8_t componentMask, uint64_t maxFrames) override;
                                              uint8_t componentMask, uint64_t maxFrames) override;
    status_t getDisplayedContentSample(DisplayId displayId, uint64_t maxFrames, uint64_t timestamp,
    status_t getDisplayedContentSample(DisplayId displayId, uint64_t maxFrames, uint64_t timestamp,
                                       DisplayedFrameStats* outStats) override;
                                       DisplayedFrameStats* outStats) override;
    status_t setDisplayBrightness(DisplayId displayId, float brightness) override;
    std::future<status_t> setDisplayBrightness(DisplayId displayId, float brightness) override;


    // Events handling ---------------------------------------------------------
    // Events handling ---------------------------------------------------------


Loading