Commit ffd7134b authored by dnicoara's avatar dnicoara Committed by Commit bot

[Ozone-DRI] Make sure the display configuration is up-to-date on the GPU

When probing for new displays we create new snapshots. We need to make
sure that existing ones will contain the same state as the old ones
otherwise the state between the Browser and GPU process will be out of
sync.

BUG=434115
NOTRY=true

Review URL: https://codereview.chromium.org/845383002

Cr-Commit-Position: refs/heads/master@{#311510}
parent b75aff40
...@@ -127,8 +127,9 @@ DisplaySnapshotDri::~DisplaySnapshotDri() { ...@@ -127,8 +127,9 @@ DisplaySnapshotDri::~DisplaySnapshotDri() {
std::string DisplaySnapshotDri::ToString() const { std::string DisplaySnapshotDri::ToString() const {
return base::StringPrintf( return base::StringPrintf(
"[type=%d, connector=%" PRIu32 ", crtc=%" PRIu32 ", mode=%s, dim=%s]", "[type=%d, connector=%" PRIu32 ", crtc=%" PRIu32
type_, connector_, crtc_, ", origin=%s, mode=%s, dim=%s]",
type_, connector_, crtc_, origin_.ToString().c_str(),
current_mode_ ? current_mode_->ToString().c_str() : "NULL", current_mode_ ? current_mode_->ToString().c_str() : "NULL",
physical_size_.ToString().c_str()); physical_size_.ToString().c_str());
} }
......
...@@ -313,8 +313,13 @@ void DriGpuPlatformSupport::OnConfigureNativeDisplay( ...@@ -313,8 +313,13 @@ void DriGpuPlatformSupport::OnConfigureNativeDisplay(
return; return;
} }
sender_->Send(new OzoneHostMsg_DisplayConfigured( bool success = ndd_->Configure(*display, mode, origin);
id, ndd_->Configure(*display, mode, origin))); if (success) {
display->set_origin(origin);
display->set_current_mode(mode);
}
sender_->Send(new OzoneHostMsg_DisplayConfigured(id, success));
} }
void DriGpuPlatformSupport::OnDisableNativeDisplay(int64_t id) { void DriGpuPlatformSupport::OnDisableNativeDisplay(int64_t id) {
......
...@@ -49,19 +49,19 @@ uint32_t GetContentProtectionValue(drmModePropertyRes* property, ...@@ -49,19 +49,19 @@ uint32_t GetContentProtectionValue(drmModePropertyRes* property,
class DisplaySnapshotComparator { class DisplaySnapshotComparator {
public: public:
DisplaySnapshotComparator(const DisplaySnapshotDri* snapshot) explicit DisplaySnapshotComparator(const DisplaySnapshotDri* snapshot)
: snapshot_(snapshot) {} : crtc_(snapshot->crtc()), connector_(snapshot->connector()) {}
bool operator()(const DisplaySnapshotDri* other) const { DisplaySnapshotComparator(uint32_t crtc, uint32_t connector)
if (snapshot_->connector() == other->connector() && : crtc_(crtc), connector_(connector) {}
snapshot_->crtc() == other->crtc())
return true;
return false; bool operator()(const DisplaySnapshotDri* other) const {
return connector_ == other->connector() && crtc_ == other->crtc();
} }
private: private:
const DisplaySnapshotDri* snapshot_; uint32_t crtc_;
uint32_t connector_;
}; };
} // namespace } // namespace
...@@ -140,13 +140,25 @@ void NativeDisplayDelegateDri::ForceDPMSOn() { ...@@ -140,13 +140,25 @@ void NativeDisplayDelegateDri::ForceDPMSOn() {
std::vector<DisplaySnapshot*> NativeDisplayDelegateDri::GetDisplays() { std::vector<DisplaySnapshot*> NativeDisplayDelegateDri::GetDisplays() {
ScopedVector<DisplaySnapshotDri> old_displays(cached_displays_.Pass()); ScopedVector<DisplaySnapshotDri> old_displays(cached_displays_.Pass());
cached_modes_.clear(); ScopedVector<const DisplayMode> old_modes(cached_modes_.Pass());
ScopedVector<HardwareDisplayControllerInfo> displays = ScopedVector<HardwareDisplayControllerInfo> displays =
GetAvailableDisplayControllerInfos(dri_->get_fd()); GetAvailableDisplayControllerInfos(dri_->get_fd());
for (size_t i = 0; i < displays.size(); ++i) { for (size_t i = 0; i < displays.size(); ++i) {
DisplaySnapshotDri* display = new DisplaySnapshotDri( DisplaySnapshotDri* display = new DisplaySnapshotDri(
dri_, displays[i]->connector(), displays[i]->crtc(), i); dri_, displays[i]->connector(), displays[i]->crtc(), i);
// If the display exists make sure to sync up the new snapshot with the old
// one to keep the user configured details.
auto it = std::find_if(
old_displays.begin(), old_displays.end(),
DisplaySnapshotComparator(displays[i]->crtc()->crtc_id,
displays[i]->connector()->connector_id));
// Origin is only used within the platform code to keep track of the display
// location.
if (it != old_displays.end())
display->set_origin((*it)->origin());
cached_displays_.push_back(display); cached_displays_.push_back(display);
cached_modes_.insert(cached_modes_.end(), display->modes().begin(), cached_modes_.insert(cached_modes_.end(), display->modes().begin(),
display->modes().end()); display->modes().end());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment