ozone: Clean DrmDisplay::SetColorspaceProperty
If the function DrmWrapper::GetProperty returns an element with prop_id equals to 0, then the property does not exist. Logicially, it makes sense to have it right next to ::GetProperty, and not next to ::SetProperty. Move the return value check accordingly. Also, improve readabiltiy of the function by minimizing nested function calls. Bug: b:326980151 , b:339498874 , b:378982496 , b:386722343 , b:388332124 Change-Id: Ica6e6ee1f574a6e9a0830b94936027de12cddb6c Signed-off-by: Paz Zcharya <pazz@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6170634 Reviewed-by: Sasha McIntosh <sashamcintosh@chromium.org> Reviewed-by: Gil Dekel <gildekel@chromium.org> Cr-Commit-Position: refs/heads/main@{#1405700}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
02aaab3bc7
commit
5001c8889c
@ -586,20 +586,21 @@ bool DrmDisplay::SetColorspaceProperty(const gfx::ColorSpace color_space) {
|
||||
|
||||
ScopedDrmPropertyPtr color_space_property(
|
||||
drm_->GetProperty(crtc_connector_pair.connector.get(), kColorSpace));
|
||||
if (!color_space_property) {
|
||||
if (!color_space_property || !color_space_property->prop_id) {
|
||||
PLOG(INFO) << "'" << kColorSpace << "' property doesn't exist.";
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint64_t enum_value_for_colorspace =
|
||||
GetEnumValueForName(*drm_, color_space_property->prop_id,
|
||||
GetNameForColorspace(color_space));
|
||||
|
||||
// TODO(b/342617770): Atomically set connector properties across all
|
||||
// connectors owned by DrmDisplay to prevent scenarios where SetProperty()
|
||||
// succeeds for a subset of the connectors and creates inconsistencies.
|
||||
if (!color_space_property->prop_id ||
|
||||
!drm_->SetProperty(
|
||||
crtc_connector_pair.connector->connector_id,
|
||||
color_space_property->prop_id,
|
||||
GetEnumValueForName(*drm_, color_space_property->prop_id,
|
||||
GetNameForColorspace(color_space)))) {
|
||||
if (!drm_->SetProperty(crtc_connector_pair.connector->connector_id,
|
||||
color_space_property->prop_id,
|
||||
enum_value_for_colorspace)) {
|
||||
PLOG(ERROR) << "Cannot set '" << GetNameForColorspace(color_space)
|
||||
<< "' to '" << kColorSpace << "' property for connector "
|
||||
<< crtc_connector_pair.connector->connector_id;
|
||||
|
Reference in New Issue
Block a user