diff options
author | Roman Stratiienko <roman.o.stratiienko@globallogic.com> | 2021-09-29 12:47:31 +0300 |
---|---|---|
committer | Roman Stratiienko <roman.o.stratiienko@globallogic.com> | 2021-09-29 12:47:31 +0300 |
commit | 5063d53ddf7db2c85ec06152be8ffcd0e2fa9639 (patch) | |
tree | 17c2037c67094ffb0bbd221c36ce6e4431f33edd /drm/DrmPlane.cpp | |
parent | 4f1effa2d6bb8c7a56c1deee17ba604e615d6bf6 (diff) | |
download | drm_hwcomposer-5063d53ddf7db2c85ec06152be8ffcd0e2fa9639.tar.gz |
drm_hwcomposer: Improve handling of blending mode
1. Convert to DrmHwcBlending inside HWC hook.
2. Use map for enum_values for cleaner atomic commit preparation.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
Diffstat (limited to 'drm/DrmPlane.cpp')
-rw-r--r-- | drm/DrmPlane.cpp | 75 |
1 files changed, 24 insertions, 51 deletions
diff --git a/drm/DrmPlane.cpp b/drm/DrmPlane.cpp index 78013fb..78b650c 100644 --- a/drm/DrmPlane.cpp +++ b/drm/DrmPlane.cpp @@ -136,8 +136,24 @@ int DrmPlane::Init() { ALOGI("Could not get alpha property"); ret = drm_->GetPlaneProperty(*this, "pixel blend mode", &blend_property_); - if (ret) + if (ret == 0) { + std::tie(enum_value, + ret) = blend_property_.GetEnumValueWithName("Pre-multiplied"); + if (ret == 0) { + blending_enum_map_[DrmHwcBlending::kPreMult] = enum_value; + } + std::tie(enum_value, + ret) = blend_property_.GetEnumValueWithName("Coverage"); + if (ret == 0) { + blending_enum_map_[DrmHwcBlending::kCoverage] = enum_value; + } + std::tie(enum_value, ret) = blend_property_.GetEnumValueWithName("None"); + if (ret == 0) { + blending_enum_map_[DrmHwcBlending::kNone] = enum_value; + } + } else { ALOGI("Could not get pixel blend mode property"); + } ret = drm_->GetPlaneProperty(*this, "IN_FENCE_FD", &in_fence_fd_property_); if (ret) @@ -231,34 +247,10 @@ bool DrmPlane::IsValidForLayer(DrmHwcLayer *layer) { return false; } - if (blend_property_.id() == 0) { - if ((layer->blending != DrmHwcBlending::kNone) && - (layer->blending != DrmHwcBlending::kPreMult)) { - ALOGV("Blending is not supported on plane %d", id_); - return false; - } - } else { - int ret = 0; - - switch (layer->blending) { - case DrmHwcBlending::kPreMult: - std::tie(std::ignore, - ret) = blend_property_.GetEnumValueWithName("Pre-multiplied"); - break; - case DrmHwcBlending::kCoverage: - std::tie(std::ignore, - ret) = blend_property_.GetEnumValueWithName("Coverage"); - break; - case DrmHwcBlending::kNone: - default: - std::tie(std::ignore, - ret) = blend_property_.GetEnumValueWithName("None"); - break; - } - if (ret) { - ALOGV("Expected a valid blend mode on plane %d", id_); - return false; - } + if (blending_enum_map_.count(layer->blending) == 0 && + layer->blending != DrmHwcBlending::kNone) { + ALOGV("Blending is not supported on plane %d", id_); + return false; } uint32_t format = layer->buffer_info.format; @@ -289,14 +281,12 @@ bool DrmPlane::HasNonRgbFormat() const { auto DrmPlane::AtomicSetState(drmModeAtomicReq &pset, DrmHwcLayer &layer, uint32_t zpos, uint32_t crtc_id) -> int { - int ret = 0; uint32_t fb_id = UINT32_MAX; int fence_fd = -1; hwc_rect_t display_frame; hwc_frect_t source_crop; uint64_t rotation = 0; uint64_t alpha = 0xFFFF; - uint64_t blend = UINT64_MAX; if (!layer.FbIdHandle) { ALOGE("Expected a valid framebuffer for pset"); @@ -317,22 +307,6 @@ auto DrmPlane::AtomicSetState(drmModeAtomicReq &pset, DrmHwcLayer &layer, return 0; } - if (blend_property_) { - switch (layer.blending) { - case DrmHwcBlending::kPreMult: - std::tie(blend, - ret) = blend_property_.GetEnumValueWithName("Pre-multiplied"); - break; - case DrmHwcBlending::kCoverage: - std::tie(blend, ret) = blend_property_.GetEnumValueWithName("Coverage"); - break; - case DrmHwcBlending::kNone: - default: - std::tie(blend, ret) = blend_property_.GetEnumValueWithName("None"); - break; - } - } - if (zpos_property_ && !zpos_property_.is_immutable()) { uint64_t min_zpos = 0; @@ -395,10 +369,9 @@ auto DrmPlane::AtomicSetState(drmModeAtomicReq &pset, DrmHwcLayer &layer, } } - if (blend_property_ && blend != UINT64_MAX) { - if (!blend_property_.AtomicSet(pset, blend)) { - return -EINVAL; - } + if (blending_enum_map_.count(layer.blending) != 0 && + !blend_property_.AtomicSet(pset, blending_enum_map_[layer.blending])) { + return -EINVAL; } if (color_encoding_enum_map_.count(layer.color_space) != 0 && |