Add results to return value of DrmDevice::ConfigureNativeDisplays
This change updates the DrmDevice::ConfigureNativeDisplays mojom API by
adding a returned value which is meant to hold the requests that were
used in the configuration. In some cases, the executed requests may not
be equal to what was initially requested, and the return value allows
those updates to be communicated.
Bug: b:321725211
Change-Id: I085f2cf6f4c536802aedde06e1c38a5a99693765
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5756188
Reviewed-by: Gil Dekel <[email protected]>
Reviewed-by: Mitsuru Oshima <[email protected]>
Reviewed-by: Sean Topping <[email protected]>
Commit-Queue: Andrew Wolfers <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1340533}
diff --git a/ui/display/manager/configure_displays_task.cc b/ui/display/manager/configure_displays_task.cc
index a6002c1..8c23bcf 100644
--- a/ui/display/manager/configure_displays_task.cc
+++ b/ui/display/manager/configure_displays_task.cc
@@ -232,13 +232,17 @@
}
}
-// After a successful configuration, the DisplaySnapshot associated with a
-// request needs to have its state updated to reflect the new configuration.
-void UpdateSnapshotAfterConfiguration(const DisplayConfigureRequest& request) {
- request.display->set_current_mode(request.mode.get());
- request.display->set_origin(request.origin);
- if (request.display->IsVrrCapable()) {
- request.display->set_variable_refresh_rate_state(
+// Updates properties of the |display| according to the given |request| after a
+// successful configuration. The display ids of |display| and |request| must
+// match.
+void UpdateSnapshotAfterConfiguration(
+ DisplaySnapshot* display,
+ const DisplayConfigurationParams& request) {
+ CHECK_EQ(display->display_id(), request.id);
+ display->set_current_mode(request.mode.get());
+ display->set_origin(request.origin);
+ if (display->IsVrrCapable()) {
+ display->set_variable_refresh_rate_state(
request.enable_vrr ? display::kVrrEnabled : display::kVrrDisabled);
}
}
@@ -341,7 +345,9 @@
std::move(callback_).Run(task_status_);
}
-void ConfigureDisplaysTask::OnFirstAttemptConfigured(bool config_success) {
+void ConfigureDisplaysTask::OnFirstAttemptConfigured(
+ const std::vector<DisplayConfigurationParams>& request_results,
+ bool config_success) {
UpdateAttemptSucceededUma(requests_, config_success);
if (!config_success) {
@@ -362,7 +368,10 @@
}
// This code execute only when the first modeset attempt fully succeeds.
- // Submit the current |requests_| for modeset.
+ // Submit the current |requests_| for modeset. Note that |requests_| is used
+ // directly instead of |request_results|, since that is what was tested (ozone
+ // sometimes alters the resulting requests to achieve better results during
+ // mode matching).
std::vector<display::DisplayConfigurationParams> config_requests;
for (const auto& request : requests_) {
final_requests_status_.emplace_back(&request, true);
@@ -380,7 +389,9 @@
modeset_flags);
}
-void ConfigureDisplaysTask::OnRetryConfigured(bool config_success) {
+void ConfigureDisplaysTask::OnRetryConfigured(
+ const std::vector<DisplayConfigurationParams>& request_results,
+ bool config_success) {
UpdateAttemptSucceededUma(requests_, config_success);
if (!config_success) {
@@ -401,9 +412,12 @@
task_status_ = ERROR;
}
} else {
- // This configuration attempt passed test-modeset. Cache it so we can use it
- // to modeset the displays once we are done testing, or if no other future
- // attempts succeed.
+ // This configuration attempt passed test-modeset. Cache |requests_| so we
+ // can use it to modeset the displays once we are done testing, or if no
+ // other future attempts succeed. Note that |requests_| is used directly
+ // instead of |request_results|, since that is what was tested (ozone
+ // sometimes alters the resulting requests to achieve better results during
+ // mode matching).
last_successful_config_parameters_.clear();
for (const auto& request : requests_) {
last_successful_config_parameters_.emplace_back(
@@ -454,10 +468,19 @@
modeset_flags);
}
-void ConfigureDisplaysTask::OnConfigured(bool config_success) {
+void ConfigureDisplaysTask::OnConfigured(
+ const std::vector<DisplayConfigurationParams>& request_results,
+ bool config_success) {
if (config_success) {
+ base::flat_map<int64_t, DisplaySnapshot*> snapshot_map;
for (const DisplayConfigureRequest& request : requests_) {
- UpdateSnapshotAfterConfiguration(request);
+ snapshot_map.emplace(request.display->display_id(), request.display);
+ }
+ // Use |request_results| to update the snapshots.
+ for (const DisplayConfigurationParams& request : request_results) {
+ const auto it = snapshot_map.find(request.id);
+ CHECK(it != snapshot_map.end());
+ UpdateSnapshotAfterConfiguration(it->second, request);
}
}