diff options
| author | 2022-03-31 23:34:14 +0000 | |
|---|---|---|
| committer | 2022-03-31 23:34:14 +0000 | |
| commit | 963291017c870adf628bff8bafd98d3c4c47fc9e (patch) | |
| tree | f5d1c83a5207aa04ad039f550c8d427bde42b957 /libs/gui | |
| parent | d7590c4ad67981c141a7801ac0535100b97cfaf9 (diff) | |
| parent | 9c604e3c31869d1a7a1654ea791267a29b053966 (diff) | |
Merge "Polish up metadata propagation for native window" into tm-dev
Diffstat (limited to 'libs/gui')
| -rw-r--r-- | libs/gui/Surface.cpp | 13 | ||||
| -rw-r--r-- | libs/gui/include/gui/HdrMetadata.h | 23 | ||||
| -rw-r--r-- | libs/gui/include/gui/Surface.h | 7 |
3 files changed, 43 insertions, 0 deletions
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index 20c41460d4..1fb11e0675 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -1096,6 +1096,17 @@ void Surface::getQueueBufferInputLocked(android_native_buffer_t* buffer, int fen *out = input; } +void Surface::applyGrallocMetadataLocked( + android_native_buffer_t* buffer, + const IGraphicBufferProducer::QueueBufferInput& queueBufferInput) { + ATRACE_CALL(); + auto& mapper = GraphicBufferMapper::get(); + mapper.setDataspace(buffer->handle, static_cast<ui::Dataspace>(queueBufferInput.dataSpace)); + mapper.setSmpte2086(buffer->handle, queueBufferInput.getHdrMetadata().getSmpte2086()); + mapper.setCta861_3(buffer->handle, queueBufferInput.getHdrMetadata().getCta8613()); + mapper.setSmpte2094_40(buffer->handle, queueBufferInput.getHdrMetadata().getHdr10Plus()); +} + void Surface::onBufferQueuedLocked(int slot, sp<Fence> fence, const IGraphicBufferProducer::QueueBufferOutput& output) { mDequeuedSlots.erase(slot); @@ -1166,9 +1177,11 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { IGraphicBufferProducer::QueueBufferOutput output; IGraphicBufferProducer::QueueBufferInput input; getQueueBufferInputLocked(buffer, fenceFd, mTimestamp, &input); + applyGrallocMetadataLocked(buffer, input); sp<Fence> fence = input.fence; nsecs_t now = systemTime(); + status_t err = mGraphicBufferProducer->queueBuffer(i, input, &output); mLastQueueDuration = systemTime() - now; if (err != OK) { diff --git a/libs/gui/include/gui/HdrMetadata.h b/libs/gui/include/gui/HdrMetadata.h index 0bdffac5c6..98a07a3c07 100644 --- a/libs/gui/include/gui/HdrMetadata.h +++ b/libs/gui/include/gui/HdrMetadata.h @@ -17,6 +17,8 @@ #pragma once #include <stdint.h> +#include <ui/GraphicTypes.h> +#include <optional> #include <vector> #include <system/graphics.h> @@ -43,6 +45,27 @@ struct HdrMetadata : public LightFlattenable<HdrMetadata> { status_t flatten(void* buffer, size_t size) const; status_t unflatten(void const* buffer, size_t size); + std::optional<ui::Smpte2086> getSmpte2086() const { + if (validTypes & Type::SMPTE2086) { + return ui::translate(smpte2086); + } + return {}; + } + + std::optional<ui::Cta861_3> getCta8613() const { + if (validTypes & Type::CTA861_3) { + return ui::translate(cta8613); + } + return {}; + } + + std::optional<std::vector<uint8_t>> getHdr10Plus() const { + if (validTypes & Type::HDR10PLUS) { + return hdr10plus; + } + return {}; + } + bool operator==(const HdrMetadata& rhs) const; bool operator!=(const HdrMetadata& rhs) const { return !(*this == rhs); } }; diff --git a/libs/gui/include/gui/Surface.h b/libs/gui/include/gui/Surface.h index 40d096e1e5..5fe308cf9f 100644 --- a/libs/gui/include/gui/Surface.h +++ b/libs/gui/include/gui/Surface.h @@ -398,6 +398,13 @@ protected: void getQueueBufferInputLocked(android_native_buffer_t* buffer, int fenceFd, nsecs_t timestamp, IGraphicBufferProducer::QueueBufferInput* out); + // For easing in adoption of gralloc4 metadata by vendor components, as well as for supporting + // the public ANativeWindow api, allow setting relevant metadata when queueing a buffer through + // a native window + void applyGrallocMetadataLocked( + android_native_buffer_t* buffer, + const IGraphicBufferProducer::QueueBufferInput& queueBufferInput); + void onBufferQueuedLocked(int slot, sp<Fence> fence, const IGraphicBufferProducer::QueueBufferOutput& output); |