| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/ozone/platform/dri/chromeos/display_message_handler.h" | 5 #include "ui/ozone/platform/dri/chromeos/display_message_handler.h" |
| 6 | 6 |
| 7 #include "ui/display/types/chromeos/display_mode.h" | 7 #include "ui/display/types/chromeos/display_mode.h" |
| 8 #include "ui/display/types/chromeos/display_snapshot.h" | 8 #include "ui/display/types/chromeos/display_snapshot.h" |
| 9 #include "ui/ozone/common/chromeos/display_util.h" | 9 #include "ui/ozone/common/chromeos/display_util.h" |
| 10 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" | 10 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" |
| 11 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" | 11 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" |
| 12 #include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h" | 12 #include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h" |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 | 15 |
| 16 namespace { | |
| 17 | |
| 18 class FindDisplayById { | |
| 19 public: | |
| 20 FindDisplayById(int64_t display_id) : display_id_(display_id) {} | |
| 21 | |
| 22 bool operator()(const DisplaySnapshot_Params& display) const { | |
| 23 return display.display_id == display_id_; | |
| 24 } | |
| 25 | |
| 26 private: | |
| 27 int64_t display_id_; | |
| 28 }; | |
| 29 | |
| 30 } // namespace | |
| 31 | |
| 32 DisplayMessageHandler::DisplayMessageHandler( | 16 DisplayMessageHandler::DisplayMessageHandler( |
| 33 scoped_ptr<NativeDisplayDelegateDri> ndd) | 17 scoped_ptr<NativeDisplayDelegateDri> ndd) |
| 34 : sender_(NULL), | 18 : sender_(NULL), |
| 35 ndd_(ndd.Pass()) {} | 19 ndd_(ndd.Pass()) {} |
| 36 | 20 |
| 37 DisplayMessageHandler::~DisplayMessageHandler() {} | 21 DisplayMessageHandler::~DisplayMessageHandler() {} |
| 38 | 22 |
| 39 void DisplayMessageHandler::OnChannelEstablished(IPC::Sender* sender) { | 23 void DisplayMessageHandler::OnChannelEstablished(IPC::Sender* sender) { |
| 40 sender_ = sender; | 24 sender_ = sender; |
| 41 } | 25 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 54 IPC_MESSAGE_UNHANDLED(handled = false); | 38 IPC_MESSAGE_UNHANDLED(handled = false); |
| 55 IPC_END_MESSAGE_MAP() | 39 IPC_END_MESSAGE_MAP() |
| 56 | 40 |
| 57 return handled; | 41 return handled; |
| 58 } | 42 } |
| 59 | 43 |
| 60 void DisplayMessageHandler::OnForceDPMSOn() { | 44 void DisplayMessageHandler::OnForceDPMSOn() { |
| 61 ndd_->ForceDPMSOn(); | 45 ndd_->ForceDPMSOn(); |
| 62 } | 46 } |
| 63 | 47 |
| 64 void DisplayMessageHandler::OnRefreshNativeDisplays( | 48 void DisplayMessageHandler::OnRefreshNativeDisplays() { |
| 65 const std::vector<DisplaySnapshot_Params>& cached_displays) { | |
| 66 std::vector<DisplaySnapshot_Params> displays; | 49 std::vector<DisplaySnapshot_Params> displays; |
| 67 std::vector<DisplaySnapshot*> native_displays = ndd_->GetDisplays(); | 50 std::vector<DisplaySnapshot*> native_displays = ndd_->GetDisplays(); |
| 68 | |
| 69 // If any of the cached displays are in the list of new displays then apply | |
| 70 // their configuration immediately. | |
| 71 for (size_t i = 0; i < native_displays.size(); ++i) { | |
| 72 std::vector<DisplaySnapshot_Params>::const_iterator it = | |
| 73 std::find_if(cached_displays.begin(), | |
| 74 cached_displays.end(), | |
| 75 FindDisplayById(native_displays[i]->display_id())); | |
| 76 | |
| 77 if (it == cached_displays.end()) | |
| 78 continue; | |
| 79 | |
| 80 if (it->has_current_mode) | |
| 81 OnConfigureNativeDisplay(it->display_id, it->current_mode, it->origin); | |
| 82 else | |
| 83 OnDisableNativeDisplay(it->display_id); | |
| 84 } | |
| 85 | |
| 86 for (size_t i = 0; i < native_displays.size(); ++i) | 51 for (size_t i = 0; i < native_displays.size(); ++i) |
| 87 displays.push_back(GetDisplaySnapshotParams(*native_displays[i])); | 52 displays.push_back(GetDisplaySnapshotParams(*native_displays[i])); |
| 88 | 53 |
| 89 sender_->Send(new OzoneHostMsg_UpdateNativeDisplays(displays)); | 54 sender_->Send(new OzoneHostMsg_UpdateNativeDisplays(displays)); |
| 90 } | 55 } |
| 91 | 56 |
| 92 void DisplayMessageHandler::OnConfigureNativeDisplay( | 57 void DisplayMessageHandler::OnConfigureNativeDisplay( |
| 93 int64_t id, | 58 int64_t id, |
| 94 const DisplayMode_Params& mode_param, | 59 const DisplayMode_Params& mode_param, |
| 95 const gfx::Point& origin) { | 60 const gfx::Point& origin) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 95 |
| 131 void DisplayMessageHandler::OnDisableNativeDisplay(int64_t id) { | 96 void DisplayMessageHandler::OnDisableNativeDisplay(int64_t id) { |
| 132 DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id); | 97 DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id); |
| 133 if (display) | 98 if (display) |
| 134 ndd_->Configure(*display, NULL, gfx::Point()); | 99 ndd_->Configure(*display, NULL, gfx::Point()); |
| 135 else | 100 else |
| 136 LOG(ERROR) << "There is no display with ID " << id; | 101 LOG(ERROR) << "There is no display with ID " << id; |
| 137 } | 102 } |
| 138 | 103 |
| 139 } // namespace ui | 104 } // namespace ui |
| OLD | NEW |