Merge "sdm: hwc2: Update HDR blend color space in SDM layer stack"
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
commit
ecc9fcd1cc
@@ -35,6 +35,7 @@
|
||||
#include <utils/constants.h>
|
||||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
#include "layer_buffer.h"
|
||||
#include "sdm_types.h"
|
||||
@@ -383,6 +384,9 @@ struct Layer {
|
||||
@sa DisplayInterface::Prepare
|
||||
@sa DisplayInterface::Commit
|
||||
*/
|
||||
|
||||
typedef std::pair<ColorPrimaries, GammaTransfer> PrimariesTransfer;
|
||||
|
||||
struct LayerStack {
|
||||
std::vector<Layer *> layers = {}; //!< Vector of layer pointers.
|
||||
|
||||
@@ -400,7 +404,8 @@ struct LayerStack {
|
||||
|
||||
LayerStackFlags flags; //!< Flags associated with this layer set.
|
||||
|
||||
ColorPrimaries blend_cs = ColorPrimaries_BT709_5; //!< o/p - Blending color space updated by SDM
|
||||
PrimariesTransfer blend_cs = {ColorPrimaries_BT709_5, Transfer_sRGB};
|
||||
//!< o/p - Blending color space updated by SDM
|
||||
};
|
||||
|
||||
} // namespace sdm
|
||||
|
||||
@@ -1527,7 +1527,7 @@ DisplayError DisplayBase::ValidateHDR(LayerStack *layer_stack) {
|
||||
// HDR color mode is set when hdr layer is present in layer_stack.
|
||||
// If client flags HDR layer as skipped, then blending happens
|
||||
// in SDR color space. Hence, need to restore the SDR color mode.
|
||||
if (layer_stack->blend_cs != ColorPrimaries_BT2020) {
|
||||
if (layer_stack->blend_cs.first != ColorPrimaries_BT2020) {
|
||||
error = SetHDRMode(false);
|
||||
if (error != kErrorNone) {
|
||||
DLOGW("Failed to restore SDR mode");
|
||||
|
||||
@@ -146,22 +146,22 @@ void ToneMapSession::SetReleaseFence(int fd) {
|
||||
release_fence_fd_[current_buffer_index_] = dup(fd);
|
||||
}
|
||||
|
||||
void ToneMapSession::SetToneMapConfig(Layer *layer) {
|
||||
void ToneMapSession::SetToneMapConfig(Layer *layer, PrimariesTransfer blend_cs) {
|
||||
// HDR -> SDR is FORWARD and SDR - > HDR is INVERSE
|
||||
tone_map_config_.type = layer->input_buffer.flags.hdr ? TONEMAP_FORWARD : TONEMAP_INVERSE;
|
||||
tone_map_config_.colorPrimaries = layer->input_buffer.color_metadata.colorPrimaries;
|
||||
tone_map_config_.blend_cs = blend_cs;
|
||||
tone_map_config_.transfer = layer->input_buffer.color_metadata.transfer;
|
||||
tone_map_config_.secure = layer->request.flags.secure;
|
||||
tone_map_config_.format = layer->request.format;
|
||||
}
|
||||
|
||||
bool ToneMapSession::IsSameToneMapConfig(Layer *layer) {
|
||||
bool ToneMapSession::IsSameToneMapConfig(Layer *layer, PrimariesTransfer blend_cs) {
|
||||
LayerBuffer& buffer = layer->input_buffer;
|
||||
private_handle_t *handle = static_cast<private_handle_t *>(buffer_info_[0].private_data);
|
||||
int tonemap_type = buffer.flags.hdr ? TONEMAP_FORWARD : TONEMAP_INVERSE;
|
||||
|
||||
return ((tonemap_type == tone_map_config_.type) &&
|
||||
(buffer.color_metadata.colorPrimaries == tone_map_config_.colorPrimaries) &&
|
||||
(blend_cs == tone_map_config_.blend_cs) &&
|
||||
(buffer.color_metadata.transfer == tone_map_config_.transfer) &&
|
||||
(layer->request.flags.secure == tone_map_config_.secure) &&
|
||||
(layer->request.format == tone_map_config_.format) &&
|
||||
@@ -197,11 +197,11 @@ int HWCToneMapper::HandleToneMap(LayerStack *layer_stack) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
error = AcquireToneMapSession(layer, &session_index);
|
||||
error = AcquireToneMapSession(layer, &session_index, layer_stack->blend_cs);
|
||||
fb_session_index_ = INT(session_index);
|
||||
break;
|
||||
default:
|
||||
error = AcquireToneMapSession(layer, &session_index);
|
||||
error = AcquireToneMapSession(layer, &session_index, layer_stack->blend_cs);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -331,7 +331,8 @@ void HWCToneMapper::DumpToneMapOutput(ToneMapSession *session, int *acquire_fd)
|
||||
CloseFd(acquire_fd);
|
||||
}
|
||||
|
||||
DisplayError HWCToneMapper::AcquireToneMapSession(Layer *layer, uint32_t *session_index) {
|
||||
DisplayError HWCToneMapper::AcquireToneMapSession(Layer *layer, uint32_t *session_index,
|
||||
PrimariesTransfer blend_cs) {
|
||||
// When the property sdm.disable_hdr_lut_gen is set, the lutEntries and gridEntries in
|
||||
// the Lut3d will be NULL, clients needs to allocate the memory and set correct 3D Lut
|
||||
// for Tonemapping.
|
||||
@@ -344,7 +345,7 @@ DisplayError HWCToneMapper::AcquireToneMapSession(Layer *layer, uint32_t *sessio
|
||||
// Check if we can re-use an existing tone map session.
|
||||
for (uint32_t i = 0; i < tone_map_sessions_.size(); i++) {
|
||||
ToneMapSession *tonemap_session = tone_map_sessions_.at(i);
|
||||
if (!tonemap_session->acquired_ && tonemap_session->IsSameToneMapConfig(layer)) {
|
||||
if (!tonemap_session->acquired_ && tonemap_session->IsSameToneMapConfig(layer, blend_cs)) {
|
||||
tonemap_session->current_buffer_index_ = (tonemap_session->current_buffer_index_ + 1) %
|
||||
ToneMapSession::kNumIntermediateBuffers;
|
||||
tonemap_session->acquired_ = true;
|
||||
@@ -358,7 +359,7 @@ DisplayError HWCToneMapper::AcquireToneMapSession(Layer *layer, uint32_t *sessio
|
||||
return kErrorMemory;
|
||||
}
|
||||
|
||||
session->SetToneMapConfig(layer);
|
||||
session->SetToneMapConfig(layer, blend_cs);
|
||||
|
||||
ToneMapGetInstanceContext ctx;
|
||||
ctx.layer = layer;
|
||||
|
||||
@@ -64,7 +64,7 @@ struct ToneMapBlitContext : public SyncTask<ToneMapTaskCode>::TaskContext {
|
||||
|
||||
struct ToneMapConfig {
|
||||
int type = 0;
|
||||
ColorPrimaries colorPrimaries = ColorPrimaries_Max;
|
||||
PrimariesTransfer blend_cs = {ColorPrimaries_BT709_5, Transfer_sRGB};
|
||||
GammaTransfer transfer = Transfer_Max;
|
||||
LayerBufferFormat format = kFormatRGBA8888;
|
||||
bool secure = false;
|
||||
@@ -78,8 +78,8 @@ class ToneMapSession : public SyncTask<ToneMapTaskCode>::TaskHandler {
|
||||
void FreeIntermediateBuffers();
|
||||
void UpdateBuffer(int acquire_fence, LayerBuffer *buffer);
|
||||
void SetReleaseFence(int fd);
|
||||
void SetToneMapConfig(Layer *layer);
|
||||
bool IsSameToneMapConfig(Layer *layer);
|
||||
void SetToneMapConfig(Layer *layer, PrimariesTransfer blend_cs);
|
||||
bool IsSameToneMapConfig(Layer *layer, PrimariesTransfer blend_cs);
|
||||
|
||||
// TaskHandler methods implementation.
|
||||
virtual void OnTask(const ToneMapTaskCode &task_code,
|
||||
@@ -110,7 +110,7 @@ class HWCToneMapper {
|
||||
|
||||
private:
|
||||
void ToneMap(Layer *layer, ToneMapSession *session);
|
||||
DisplayError AcquireToneMapSession(Layer *layer, uint32_t *session_index);
|
||||
DisplayError AcquireToneMapSession(Layer *layer, uint32_t *sess_idx, PrimariesTransfer blend_cs);
|
||||
void DumpToneMapOutput(ToneMapSession *session, int *acquire_fence);
|
||||
|
||||
std::vector<ToneMapSession*> tone_map_sessions_;
|
||||
|
||||
Reference in New Issue
Block a user