Merge "sdm: hwc2: Update HDR blend color space in SDM layer stack"

This commit is contained in:
Linux Build Service Account
2018-03-09 12:52:15 -08:00
committed by Gerrit - the friendly Code Review server
4 changed files with 21 additions and 15 deletions

View File

@@ -35,6 +35,7 @@
#include <utils/constants.h> #include <utils/constants.h>
#include <vector> #include <vector>
#include <utility>
#include "layer_buffer.h" #include "layer_buffer.h"
#include "sdm_types.h" #include "sdm_types.h"
@@ -383,6 +384,9 @@ struct Layer {
@sa DisplayInterface::Prepare @sa DisplayInterface::Prepare
@sa DisplayInterface::Commit @sa DisplayInterface::Commit
*/ */
typedef std::pair<ColorPrimaries, GammaTransfer> PrimariesTransfer;
struct LayerStack { struct LayerStack {
std::vector<Layer *> layers = {}; //!< Vector of layer pointers. std::vector<Layer *> layers = {}; //!< Vector of layer pointers.
@@ -400,7 +404,8 @@ struct LayerStack {
LayerStackFlags flags; //!< Flags associated with this layer set. 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 } // namespace sdm

View File

@@ -1527,7 +1527,7 @@ DisplayError DisplayBase::ValidateHDR(LayerStack *layer_stack) {
// HDR color mode is set when hdr layer is present in 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 // If client flags HDR layer as skipped, then blending happens
// in SDR color space. Hence, need to restore the SDR color mode. // 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); error = SetHDRMode(false);
if (error != kErrorNone) { if (error != kErrorNone) {
DLOGW("Failed to restore SDR mode"); DLOGW("Failed to restore SDR mode");

View File

@@ -146,22 +146,22 @@ void ToneMapSession::SetReleaseFence(int fd) {
release_fence_fd_[current_buffer_index_] = dup(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 // 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_.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_.transfer = layer->input_buffer.color_metadata.transfer;
tone_map_config_.secure = layer->request.flags.secure; tone_map_config_.secure = layer->request.flags.secure;
tone_map_config_.format = layer->request.format; 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; LayerBuffer& buffer = layer->input_buffer;
private_handle_t *handle = static_cast<private_handle_t *>(buffer_info_[0].private_data); private_handle_t *handle = static_cast<private_handle_t *>(buffer_info_[0].private_data);
int tonemap_type = buffer.flags.hdr ? TONEMAP_FORWARD : TONEMAP_INVERSE; int tonemap_type = buffer.flags.hdr ? TONEMAP_FORWARD : TONEMAP_INVERSE;
return ((tonemap_type == tone_map_config_.type) && 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) && (buffer.color_metadata.transfer == tone_map_config_.transfer) &&
(layer->request.flags.secure == tone_map_config_.secure) && (layer->request.flags.secure == tone_map_config_.secure) &&
(layer->request.format == tone_map_config_.format) && (layer->request.format == tone_map_config_.format) &&
@@ -197,11 +197,11 @@ int HWCToneMapper::HandleToneMap(LayerStack *layer_stack) {
return 0; return 0;
} }
} }
error = AcquireToneMapSession(layer, &session_index); error = AcquireToneMapSession(layer, &session_index, layer_stack->blend_cs);
fb_session_index_ = INT(session_index); fb_session_index_ = INT(session_index);
break; break;
default: default:
error = AcquireToneMapSession(layer, &session_index); error = AcquireToneMapSession(layer, &session_index, layer_stack->blend_cs);
break; break;
} }
@@ -331,7 +331,8 @@ void HWCToneMapper::DumpToneMapOutput(ToneMapSession *session, int *acquire_fd)
CloseFd(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 // 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 // the Lut3d will be NULL, clients needs to allocate the memory and set correct 3D Lut
// for Tonemapping. // 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. // Check if we can re-use an existing tone map session.
for (uint32_t i = 0; i < tone_map_sessions_.size(); i++) { for (uint32_t i = 0; i < tone_map_sessions_.size(); i++) {
ToneMapSession *tonemap_session = tone_map_sessions_.at(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) % tonemap_session->current_buffer_index_ = (tonemap_session->current_buffer_index_ + 1) %
ToneMapSession::kNumIntermediateBuffers; ToneMapSession::kNumIntermediateBuffers;
tonemap_session->acquired_ = true; tonemap_session->acquired_ = true;
@@ -358,7 +359,7 @@ DisplayError HWCToneMapper::AcquireToneMapSession(Layer *layer, uint32_t *sessio
return kErrorMemory; return kErrorMemory;
} }
session->SetToneMapConfig(layer); session->SetToneMapConfig(layer, blend_cs);
ToneMapGetInstanceContext ctx; ToneMapGetInstanceContext ctx;
ctx.layer = layer; ctx.layer = layer;

View File

@@ -64,7 +64,7 @@ struct ToneMapBlitContext : public SyncTask<ToneMapTaskCode>::TaskContext {
struct ToneMapConfig { struct ToneMapConfig {
int type = 0; int type = 0;
ColorPrimaries colorPrimaries = ColorPrimaries_Max; PrimariesTransfer blend_cs = {ColorPrimaries_BT709_5, Transfer_sRGB};
GammaTransfer transfer = Transfer_Max; GammaTransfer transfer = Transfer_Max;
LayerBufferFormat format = kFormatRGBA8888; LayerBufferFormat format = kFormatRGBA8888;
bool secure = false; bool secure = false;
@@ -78,8 +78,8 @@ class ToneMapSession : public SyncTask<ToneMapTaskCode>::TaskHandler {
void FreeIntermediateBuffers(); void FreeIntermediateBuffers();
void UpdateBuffer(int acquire_fence, LayerBuffer *buffer); void UpdateBuffer(int acquire_fence, LayerBuffer *buffer);
void SetReleaseFence(int fd); void SetReleaseFence(int fd);
void SetToneMapConfig(Layer *layer); void SetToneMapConfig(Layer *layer, PrimariesTransfer blend_cs);
bool IsSameToneMapConfig(Layer *layer); bool IsSameToneMapConfig(Layer *layer, PrimariesTransfer blend_cs);
// TaskHandler methods implementation. // TaskHandler methods implementation.
virtual void OnTask(const ToneMapTaskCode &task_code, virtual void OnTask(const ToneMapTaskCode &task_code,
@@ -110,7 +110,7 @@ class HWCToneMapper {
private: private:
void ToneMap(Layer *layer, ToneMapSession *session); 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); void DumpToneMapOutput(ToneMapSession *session, int *acquire_fence);
std::vector<ToneMapSession*> tone_map_sessions_; std::vector<ToneMapSession*> tone_map_sessions_;