Loading services/surfaceflinger/CompositionEngine/tests/MockHWComposer.h +1 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public: MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(DisplayId, bool, uint8_t, uint64_t)); MOCK_METHOD4(getDisplayedContentSample, 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(onHotplug, Loading services/surfaceflinger/DisplayHardware/HWC2.cpp +10 −6 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include "HWC2.h" #include "ComposerHal.h" #include <ui/Fence.h> #include <ui/FloatRect.h> Loading @@ -38,6 +37,9 @@ #include <iterator> #include <set> #include "../Promise.h" #include "ComposerHal.h" namespace android { using android::Fence; Loading Loading @@ -640,12 +642,14 @@ Error Display::presentOrValidate(uint32_t* outNumTypes, uint32_t* outNumRequests return error; } Error Display::setDisplayBrightness(float brightness) const { const auto intError = mComposer.setDisplayBrightness(mId, brightness); std::future<Error> Display::setDisplayBrightness(float brightness) { return promise::defer([composer = &mComposer, id = mId, brightness] { const auto intError = composer->setDisplayBrightness(id, brightness); return static_cast<Error>(intError); }); } Error Display::setAutoLowLatencyMode(bool on) const { Error Display::setAutoLowLatencyMode(bool on) { auto intError = mComposer.setAutoLowLatencyMode(mId, on); return static_cast<Error>(intError); } Loading @@ -659,7 +663,7 @@ Error Display::getSupportedContentTypes(std::vector<ContentType>* outSupportedCo return static_cast<Error>(intError); } Error Display::setContentType(ContentType contentType) const { Error Display::setContentType(ContentType contentType) { auto intError = mComposer.setContentType(mId, contentType); return static_cast<Error>(intError); } Loading services/surfaceflinger/DisplayHardware/HWC2.h +8 −7 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <utils/Timers.h> #include <functional> #include <future> #include <string> #include <unordered_map> #include <unordered_set> Loading Loading @@ -221,18 +222,18 @@ public: [[clang::warn_unused_result]] virtual hal::Error presentOrValidate( uint32_t* outNumTypes, uint32_t* outNumRequests, android::sp<android::Fence>* outPresentFence, uint32_t* state) = 0; [[clang::warn_unused_result]] virtual hal::Error setDisplayBrightness( float brightness) const = 0; [[clang::warn_unused_result]] virtual std::future<hal::Error> setDisplayBrightness( float brightness) = 0; [[clang::warn_unused_result]] virtual hal::Error getDisplayVsyncPeriod( nsecs_t* outVsyncPeriod) const = 0; [[clang::warn_unused_result]] virtual hal::Error setActiveConfigWithConstraints( const std::shared_ptr<const HWC2::Display::Config>& config, const hal::VsyncPeriodChangeConstraints& constraints, 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( 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 { Loading Loading @@ -294,16 +295,16 @@ public: hal::Error presentOrValidate(uint32_t* outNumTypes, uint32_t* outNumRequests, android::sp<android::Fence>* outPresentFence, 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 setActiveConfigWithConstraints( const std::shared_ptr<const HWC2::Display::Config>& config, const hal::VsyncPeriodChangeConstraints& constraints, hal::VsyncPeriodChangeTimeline* outTimeline) override; hal::Error setAutoLowLatencyMode(bool on) const override; hal::Error setAutoLowLatencyMode(bool on) override; hal::Error getSupportedContentTypes( std::vector<hal::ContentType>* outSupportedContentTypes) const override; hal::Error setContentType(hal::ContentType contentType) const override; hal::Error setContentType(hal::ContentType) override; // Other Display methods hal::HWDisplayId getId() const override { return mId; } bool isConnected() const override { return mIsConnected; } Loading services/surfaceflinger/DisplayHardware/HWComposer.cpp +16 −11 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include <utils/Trace.h> #include "../Layer.h" // needed only for debugging #include "../Promise.h" #include "../SurfaceFlinger.h" #include "ComposerHal.h" #include "HWC2.h" Loading Loading @@ -794,9 +795,12 @@ status_t HWComposer::getDisplayedContentSample(DisplayId displayId, uint64_t max return NO_ERROR; } status_t HWComposer::setDisplayBrightness(DisplayId displayId, float brightness) { RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); const auto error = mDisplayData[displayId].hwcDisplay->setDisplayBrightness(brightness); std::future<status_t> HWComposer::setDisplayBrightness(DisplayId displayId, float brightness) { RETURN_IF_INVALID_DISPLAY(displayId, promise::yield<status_t>(BAD_INDEX)); auto& display = mDisplayData[displayId].hwcDisplay; return promise::chain(display->setDisplayBrightness(brightness)) .then([displayId](hal::Error error) -> status_t { if (error == hal::Error::UNSUPPORTED) { RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION); } Loading @@ -805,6 +809,7 @@ status_t HWComposer::setDisplayBrightness(DisplayId displayId, float brightness) } RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); return NO_ERROR; }); } bool HWComposer::isUsingVrComposer() const { Loading services/surfaceflinger/DisplayHardware/HWComposer.h +3 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define ANDROID_SF_HWCOMPOSER_H #include <cstdint> #include <future> #include <memory> #include <mutex> #include <optional> Loading Loading @@ -163,7 +164,7 @@ public: DisplayedFrameStats* outStats) = 0; // 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 --------------------------------------------------------- Loading Loading @@ -305,7 +306,7 @@ public: uint8_t componentMask, uint64_t maxFrames) override; status_t getDisplayedContentSample(DisplayId displayId, uint64_t maxFrames, uint64_t timestamp, DisplayedFrameStats* outStats) override; status_t setDisplayBrightness(DisplayId displayId, float brightness) override; std::future<status_t> setDisplayBrightness(DisplayId displayId, float brightness) override; // Events handling --------------------------------------------------------- Loading Loading
services/surfaceflinger/CompositionEngine/tests/MockHWComposer.h +1 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public: MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(DisplayId, bool, uint8_t, uint64_t)); MOCK_METHOD4(getDisplayedContentSample, 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(onHotplug, Loading
services/surfaceflinger/DisplayHardware/HWC2.cpp +10 −6 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include "HWC2.h" #include "ComposerHal.h" #include <ui/Fence.h> #include <ui/FloatRect.h> Loading @@ -38,6 +37,9 @@ #include <iterator> #include <set> #include "../Promise.h" #include "ComposerHal.h" namespace android { using android::Fence; Loading Loading @@ -640,12 +642,14 @@ Error Display::presentOrValidate(uint32_t* outNumTypes, uint32_t* outNumRequests return error; } Error Display::setDisplayBrightness(float brightness) const { const auto intError = mComposer.setDisplayBrightness(mId, brightness); std::future<Error> Display::setDisplayBrightness(float brightness) { return promise::defer([composer = &mComposer, id = mId, brightness] { const auto intError = composer->setDisplayBrightness(id, brightness); return static_cast<Error>(intError); }); } Error Display::setAutoLowLatencyMode(bool on) const { Error Display::setAutoLowLatencyMode(bool on) { auto intError = mComposer.setAutoLowLatencyMode(mId, on); return static_cast<Error>(intError); } Loading @@ -659,7 +663,7 @@ Error Display::getSupportedContentTypes(std::vector<ContentType>* outSupportedCo return static_cast<Error>(intError); } Error Display::setContentType(ContentType contentType) const { Error Display::setContentType(ContentType contentType) { auto intError = mComposer.setContentType(mId, contentType); return static_cast<Error>(intError); } Loading
services/surfaceflinger/DisplayHardware/HWC2.h +8 −7 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <utils/Timers.h> #include <functional> #include <future> #include <string> #include <unordered_map> #include <unordered_set> Loading Loading @@ -221,18 +222,18 @@ public: [[clang::warn_unused_result]] virtual hal::Error presentOrValidate( uint32_t* outNumTypes, uint32_t* outNumRequests, android::sp<android::Fence>* outPresentFence, uint32_t* state) = 0; [[clang::warn_unused_result]] virtual hal::Error setDisplayBrightness( float brightness) const = 0; [[clang::warn_unused_result]] virtual std::future<hal::Error> setDisplayBrightness( float brightness) = 0; [[clang::warn_unused_result]] virtual hal::Error getDisplayVsyncPeriod( nsecs_t* outVsyncPeriod) const = 0; [[clang::warn_unused_result]] virtual hal::Error setActiveConfigWithConstraints( const std::shared_ptr<const HWC2::Display::Config>& config, const hal::VsyncPeriodChangeConstraints& constraints, 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( 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 { Loading Loading @@ -294,16 +295,16 @@ public: hal::Error presentOrValidate(uint32_t* outNumTypes, uint32_t* outNumRequests, android::sp<android::Fence>* outPresentFence, 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 setActiveConfigWithConstraints( const std::shared_ptr<const HWC2::Display::Config>& config, const hal::VsyncPeriodChangeConstraints& constraints, hal::VsyncPeriodChangeTimeline* outTimeline) override; hal::Error setAutoLowLatencyMode(bool on) const override; hal::Error setAutoLowLatencyMode(bool on) override; hal::Error getSupportedContentTypes( std::vector<hal::ContentType>* outSupportedContentTypes) const override; hal::Error setContentType(hal::ContentType contentType) const override; hal::Error setContentType(hal::ContentType) override; // Other Display methods hal::HWDisplayId getId() const override { return mId; } bool isConnected() const override { return mIsConnected; } Loading
services/surfaceflinger/DisplayHardware/HWComposer.cpp +16 −11 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include <utils/Trace.h> #include "../Layer.h" // needed only for debugging #include "../Promise.h" #include "../SurfaceFlinger.h" #include "ComposerHal.h" #include "HWC2.h" Loading Loading @@ -794,9 +795,12 @@ status_t HWComposer::getDisplayedContentSample(DisplayId displayId, uint64_t max return NO_ERROR; } status_t HWComposer::setDisplayBrightness(DisplayId displayId, float brightness) { RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); const auto error = mDisplayData[displayId].hwcDisplay->setDisplayBrightness(brightness); std::future<status_t> HWComposer::setDisplayBrightness(DisplayId displayId, float brightness) { RETURN_IF_INVALID_DISPLAY(displayId, promise::yield<status_t>(BAD_INDEX)); auto& display = mDisplayData[displayId].hwcDisplay; return promise::chain(display->setDisplayBrightness(brightness)) .then([displayId](hal::Error error) -> status_t { if (error == hal::Error::UNSUPPORTED) { RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION); } Loading @@ -805,6 +809,7 @@ status_t HWComposer::setDisplayBrightness(DisplayId displayId, float brightness) } RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); return NO_ERROR; }); } bool HWComposer::isUsingVrComposer() const { Loading
services/surfaceflinger/DisplayHardware/HWComposer.h +3 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define ANDROID_SF_HWCOMPOSER_H #include <cstdint> #include <future> #include <memory> #include <mutex> #include <optional> Loading Loading @@ -163,7 +164,7 @@ public: DisplayedFrameStats* outStats) = 0; // 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 --------------------------------------------------------- Loading Loading @@ -305,7 +306,7 @@ public: uint8_t componentMask, uint64_t maxFrames) override; status_t getDisplayedContentSample(DisplayId displayId, uint64_t maxFrames, uint64_t timestamp, DisplayedFrameStats* outStats) override; status_t setDisplayBrightness(DisplayId displayId, float brightness) override; std::future<status_t> setDisplayBrightness(DisplayId displayId, float brightness) override; // Events handling --------------------------------------------------------- Loading