diff options
author | Long Ling <longling@google.com> | 2021-11-23 19:50:02 -0800 |
---|---|---|
committer | Long Ling <longling@google.com> | 2022-01-11 12:15:34 -0800 |
commit | e738bcf694db42aaee4fc9e8f416b4c1cf0cdb5b (patch) | |
tree | c61637ea063ec251d50d87ee87aebafe4dda2eeb /hwc3/ComposerCommandEngine.cpp | |
parent | b1d95bc1041c4fabd9e8ba11a46590b174ba002d (diff) |
hwc3: support SDR and HDR blending
Add support for setLayerWhitePointNits, setClientTargetWhitePointNits
and setDisplayBrightness commands.
Bug: 196171661
Change-Id: I5b2c5510ae758805396e678f1e2d5c4ea1e716b5
Diffstat (limited to 'hwc3/ComposerCommandEngine.cpp')
-rw-r--r-- | hwc3/ComposerCommandEngine.cpp | 61 |
1 files changed, 47 insertions, 14 deletions
diff --git a/hwc3/ComposerCommandEngine.cpp b/hwc3/ComposerCommandEngine.cpp index 05ab3dc..65bdb9e 100644 --- a/hwc3/ComposerCommandEngine.cpp +++ b/hwc3/ComposerCommandEngine.cpp @@ -14,15 +14,11 @@ * limitations under the License. */ +#include <set> + #include "ComposerCommandEngine.h" #include "Util.h" -/// The command engine interface is not 'pure' aidl. Conversion to aidl -// structure is done within this class. Don't mix it with impl/translate. -// Expect to have an AIDL command interface in the future. -// -// The initial implementation is a combination of asop ComposerCommandEngine 2.1 to 2.4 -// and adapt to aidl structures. namespace aidl::android::hardware::graphics::composer3::impl { #define DISPATCH_LAYER_COMMAND(display, layerCmd, field, funcName) \ @@ -60,17 +56,38 @@ bool ComposerCommandEngine::init() { int32_t ComposerCommandEngine::execute(const std::vector<DisplayCommand>& commands, std::vector<CommandResultPayload>* result) { + std::set<int64_t> displaysPendingBrightenssChange; mCommandIndex = 0; for (const auto& command : commands) { dispatchDisplayCommand(command); ++mCommandIndex; + // The input commands could have 2+ commands for the same display. + // If the first has pending brightness change, the second presentDisplay will apply it. + if (command.validateDisplay || command.presentDisplay || + command.presentOrValidateDisplay) { + displaysPendingBrightenssChange.erase(command.display); + } else if (command.brightness) { + displaysPendingBrightenssChange.insert(command.display); + } } *result = mWriter->getPendingCommandResults(); - return 0; + mWriter->reset(); + + // standalone display brightness command shouldn't wait for next present or validate + for (auto display : displaysPendingBrightenssChange) { + auto err = mHal->flushDisplayBrightnessChange(display); + if (err) { + return err; + } + } + return ::android::NO_ERROR; } void ComposerCommandEngine::dispatchDisplayCommand(const DisplayCommand& command) { + // place SetDisplayBrightness before SetLayerWhitePointNits since current + // display brightness is used to validate the layer white point nits. + DISPATCH_DISPLAY_COMMAND(command, brightness, SetDisplayBrightness); for (const auto& layerCmd : command.layers) { dispatchLayerCommand(command.display, layerCmd); } @@ -78,8 +95,6 @@ void ComposerCommandEngine::dispatchDisplayCommand(const DisplayCommand& command DISPATCH_DISPLAY_COMMAND(command, colorTransformMatrix, SetColorTransform); DISPATCH_DISPLAY_COMMAND(command, clientTarget, SetClientTarget); DISPATCH_DISPLAY_COMMAND(command, virtualDisplayOutputBuffer, SetOutputBuffer); - // TODO: (b/196171661) SDR & HDR blending - // DISPATCH_DISPLAY_COMMAND(command, brightness, SetBrightness); DISPATCH_DISPLAY_BOOL_COMMAND_AND_DATA(command, validateDisplay, expectedPresentTime, ValidateDisplay); DISPATCH_DISPLAY_BOOL_COMMAND(command, acceptDisplayChanges, AcceptDisplayChanges); @@ -105,8 +120,7 @@ void ComposerCommandEngine::dispatchLayerCommand(int64_t display, const LayerCom DISPATCH_LAYER_COMMAND(display, command, visibleRegion, VisibleRegion); DISPATCH_LAYER_COMMAND(display, command, z, ZOrder); DISPATCH_LAYER_COMMAND(display, command, colorTransform, ColorTransform); - // TODO: (b/196171661) add support for mixed composition - // DISPATCH_LAYER_COMMAND(display, command, whitePointNits, WhitePointNits); + DISPATCH_LAYER_COMMAND(display, command, whitePointNits, WhitePointNits); DISPATCH_LAYER_COMMAND(display, command, perFrameMetadata, PerFrameMetadata); DISPATCH_LAYER_COMMAND(display, command, perFrameMetadataBlob, PerFrameMetadataBlobs); } @@ -117,17 +131,17 @@ int32_t ComposerCommandEngine::executeValidateDisplayInternal(int64_t display) { uint32_t displayRequestMask = 0x0; std::vector<int64_t> requestedLayers; std::vector<int32_t> requestMasks; + float clientTargetWhitePointNits; ClientTargetProperty clientTargetProperty{common::PixelFormat::RGBA_8888, common::Dataspace::UNKNOWN}; auto err = mHal->validateDisplay(display, &changedLayers, &compositionTypes, &displayRequestMask, &requestedLayers, &requestMasks, - &clientTargetProperty); + &clientTargetProperty, &clientTargetWhitePointNits); mResources->setDisplayMustValidateState(display, false); if (!err) { mWriter->setChangedCompositionTypes(display, changedLayers, compositionTypes); mWriter->setDisplayRequests(display, displayRequestMask, requestedLayers, requestMasks); - // TODO: (b/196171661) sdr/hdr composition, use 1.0 - mWriter->setClientTargetProperty(display, clientTargetProperty, 1.0f); + mWriter->setClientTargetProperty(display, clientTargetProperty, clientTargetWhitePointNits); } else { LOG(ERROR) << __func__ << ": err " << err; mWriter->setError(mCommandIndex, err); @@ -198,6 +212,15 @@ void ComposerCommandEngine::executeValidateDisplay( executeValidateDisplayInternal(display); } +void ComposerCommandEngine::executeSetDisplayBrightness(uint64_t display, + const DisplayBrightness& command) { + auto err = mHal->setDisplayBrightness(display, command.brightness); + if (err) { + LOG(ERROR) << __func__ << ": err " << err; + mWriter->setError(mCommandIndex, err); + } +} + void ComposerCommandEngine::executePresentOrValidateDisplay( int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime) { executeSetExpectedPresentTimeInternal(display, expectedPresentTime); @@ -238,6 +261,7 @@ int ComposerCommandEngine::executePresentDisplay(int64_t display) { mWriter->setPresentFence(display, std::move(presentFence)); mWriter->setReleaseFences(display, layers, std::move(fences)); } + return err; } @@ -415,6 +439,15 @@ void ComposerCommandEngine::executeSetLayerColorTransform(int64_t display, int64 } } +void ComposerCommandEngine::executeSetLayerWhitePointNits(int64_t display, int64_t layer, + const Luminance& nits) { + auto err = mHal->setLayerWhitePointNits(display, layer, nits.nits); + if (err) { + LOG(ERROR) << __func__ << ": err " << err; + mWriter->setError(mCommandIndex, err); + } +} + void ComposerCommandEngine::executeSetLayerPerFrameMetadataBlobs(int64_t display, int64_t layer, const std::vector<std::optional<PerFrameMetadataBlob>>& metadata) { auto err = mHal->setLayerPerFrameMetadataBlobs(display, layer, metadata); |