| 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/display/chromeos/display_configurator.h" | 5 #include "ui/display/chromeos/display_configurator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // The delay to perform configuration after RRNotify. See the comment for | 25 // The delay to perform configuration after RRNotify. See the comment for |
| 26 // |configure_timer_|. | 26 // |configure_timer_|. |
| 27 const int kConfigureDelayMs = 500; | 27 const int kConfigureDelayMs = 500; |
| 28 | 28 |
| 29 // The delay spent before reading the display configuration after coming out of | 29 // The delay spent before reading the display configuration after coming out of |
| 30 // suspend. While coming out of suspend the display state may be updating. This | 30 // suspend. While coming out of suspend the display state may be updating. This |
| 31 // is used to wait until the hardware had a chance to update the display state | 31 // is used to wait until the hardware had a chance to update the display state |
| 32 // such that we read an up to date state. | 32 // such that we read an up to date state. |
| 33 const int kResumeDelayMs = 500; | 33 const int kResumeDelayMs = 500; |
| 34 | 34 |
| 35 struct DisplayState { |
| 36 DisplaySnapshot* display = nullptr; // Not owned. |
| 37 |
| 38 // User-selected mode for the display. |
| 39 const DisplayMode* selected_mode = nullptr; |
| 40 |
| 41 // Mode used when displaying the same desktop on multiple displays. |
| 42 const DisplayMode* mirror_mode = nullptr; |
| 43 }; |
| 44 |
| 35 void DoNothing(bool status) { | 45 void DoNothing(bool status) { |
| 36 } | 46 } |
| 37 | 47 |
| 38 } // namespace | 48 } // namespace |
| 39 | 49 |
| 40 | |
| 41 const int DisplayConfigurator::kSetDisplayPowerNoFlags = 0; | 50 const int DisplayConfigurator::kSetDisplayPowerNoFlags = 0; |
| 42 const int DisplayConfigurator::kSetDisplayPowerForceProbe = 1 << 0; | 51 const int DisplayConfigurator::kSetDisplayPowerForceProbe = 1 << 0; |
| 43 const int | 52 const int |
| 44 DisplayConfigurator::kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1; | 53 DisplayConfigurator::kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1; |
| 45 | 54 |
| 46 DisplayConfigurator::DisplayState::DisplayState() | |
| 47 : display(NULL), | |
| 48 selected_mode(NULL), | |
| 49 mirror_mode(NULL) {} | |
| 50 | |
| 51 bool DisplayConfigurator::TestApi::TriggerConfigureTimeout() { | 55 bool DisplayConfigurator::TestApi::TriggerConfigureTimeout() { |
| 52 if (configurator_->configure_timer_.IsRunning()) { | 56 if (configurator_->configure_timer_.IsRunning()) { |
| 53 configurator_->configure_timer_.user_task().Run(); | 57 configurator_->configure_timer_.user_task().Run(); |
| 54 configurator_->configure_timer_.Stop(); | 58 configurator_->configure_timer_.Stop(); |
| 55 return true; | 59 return true; |
| 56 } else { | 60 } else { |
| 57 return false; | 61 return false; |
| 58 } | 62 } |
| 59 } | 63 } |
| 60 | 64 |
| 61 //////////////////////////////////////////////////////////////////////////////// | 65 //////////////////////////////////////////////////////////////////////////////// |
| 62 // DisplayConfigurator::DisplayLayoutManagerImpl implementation | 66 // DisplayConfigurator::DisplayLayoutManagerImpl implementation |
| 63 | 67 |
| 64 class DisplayConfigurator::DisplayLayoutManagerImpl | 68 class DisplayConfigurator::DisplayLayoutManagerImpl |
| 65 : public DisplayLayoutManager { | 69 : public DisplayLayoutManager { |
| 66 public: | 70 public: |
| 67 DisplayLayoutManagerImpl(DisplayConfigurator* configurator); | 71 DisplayLayoutManagerImpl(DisplayConfigurator* configurator); |
| 68 ~DisplayLayoutManagerImpl() override; | 72 ~DisplayLayoutManagerImpl() override; |
| 69 | 73 |
| 70 // DisplayConfigurator::DisplayLayoutManager: | 74 // DisplayConfigurator::DisplayLayoutManager: |
| 71 SoftwareMirroringController* GetSoftwareMirroringController() const override; | 75 SoftwareMirroringController* GetSoftwareMirroringController() const override; |
| 72 StateController* GetStateController() const override; | 76 StateController* GetStateController() const override; |
| 73 MultipleDisplayState GetDisplayState() const override; | 77 MultipleDisplayState GetDisplayState() const override; |
| 74 chromeos::DisplayPowerState GetPowerState() const override; | 78 chromeos::DisplayPowerState GetPowerState() const override; |
| 75 std::vector<DisplayState> ParseDisplays( | 79 bool GetDisplayLayout(const std::vector<DisplaySnapshot*>& displays, |
| 76 const std::vector<DisplaySnapshot*>& displays) const override; | |
| 77 bool GetDisplayLayout(const std::vector<DisplayState>& displays, | |
| 78 MultipleDisplayState new_display_state, | 80 MultipleDisplayState new_display_state, |
| 79 chromeos::DisplayPowerState new_power_state, | 81 chromeos::DisplayPowerState new_power_state, |
| 80 std::vector<DisplayConfigureRequest>* requests, | 82 std::vector<DisplayConfigureRequest>* requests, |
| 81 gfx::Size* framebuffer_size) const override; | 83 gfx::Size* framebuffer_size) const override; |
| 82 | 84 |
| 83 private: | 85 private: |
| 86 // Parses the |displays| into a list of DisplayStates. This effectively adds |
| 87 // |mirror_mode| and |selected_mode| to the returned results. |
| 88 // TODO(dnicoara): Break this into GetSelectedMode() and GetMirrorMode() and |
| 89 // remove DisplayState. |
| 90 std::vector<DisplayState> ParseDisplays( |
| 91 const std::vector<DisplaySnapshot*>& displays) const; |
| 92 |
| 84 // Helper method for ParseDisplays() that initializes the passed-in | 93 // Helper method for ParseDisplays() that initializes the passed-in |
| 85 // displays' |mirror_mode| fields by looking for a mode in |internal_display| | 94 // displays' |mirror_mode| fields by looking for a mode in |internal_display| |
| 86 // and |external_display| having the same resolution. Returns false if a | 95 // and |external_display| having the same resolution. Returns false if a |
| 87 // shared mode wasn't found or created. | 96 // shared mode wasn't found or created. |
| 88 // | 97 // |
| 89 // |try_panel_fitting| allows creating a panel-fitting mode for | 98 // |try_panel_fitting| allows creating a panel-fitting mode for |
| 90 // |internal_display| instead of only searching for a matching mode (note that | 99 // |internal_display| instead of only searching for a matching mode (note that |
| 91 // it may lead to a crash if |internal_display| is not capable of panel | 100 // it may lead to a crash if |internal_display| is not capable of panel |
| 92 // fitting). | 101 // fitting). |
| 93 // | 102 // |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 MultipleDisplayState | 134 MultipleDisplayState |
| 126 DisplayConfigurator::DisplayLayoutManagerImpl::GetDisplayState() const { | 135 DisplayConfigurator::DisplayLayoutManagerImpl::GetDisplayState() const { |
| 127 return configurator_->current_display_state_; | 136 return configurator_->current_display_state_; |
| 128 } | 137 } |
| 129 | 138 |
| 130 chromeos::DisplayPowerState | 139 chromeos::DisplayPowerState |
| 131 DisplayConfigurator::DisplayLayoutManagerImpl::GetPowerState() const { | 140 DisplayConfigurator::DisplayLayoutManagerImpl::GetPowerState() const { |
| 132 return configurator_->current_power_state_; | 141 return configurator_->current_power_state_; |
| 133 } | 142 } |
| 134 | 143 |
| 135 std::vector<DisplayConfigurator::DisplayState> | 144 std::vector<DisplayState> |
| 136 DisplayConfigurator::DisplayLayoutManagerImpl::ParseDisplays( | 145 DisplayConfigurator::DisplayLayoutManagerImpl::ParseDisplays( |
| 137 const std::vector<DisplaySnapshot*>& snapshots) const { | 146 const std::vector<DisplaySnapshot*>& snapshots) const { |
| 138 std::vector<DisplayState> cached_displays; | 147 std::vector<DisplayState> cached_displays; |
| 139 for (auto snapshot : snapshots) { | 148 for (auto snapshot : snapshots) { |
| 140 DisplayState display_state; | 149 DisplayState display_state; |
| 141 display_state.display = snapshot; | 150 display_state.display = snapshot; |
| 142 cached_displays.push_back(display_state); | 151 cached_displays.push_back(display_state); |
| 143 } | 152 } |
| 144 | 153 |
| 145 // Set |selected_mode| fields. | 154 // Set |selected_mode| fields. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 false, preserve_aspect); | 203 false, preserve_aspect); |
| 195 } | 204 } |
| 196 } | 205 } |
| 197 } | 206 } |
| 198 } | 207 } |
| 199 | 208 |
| 200 return cached_displays; | 209 return cached_displays; |
| 201 } | 210 } |
| 202 | 211 |
| 203 bool DisplayConfigurator::DisplayLayoutManagerImpl::GetDisplayLayout( | 212 bool DisplayConfigurator::DisplayLayoutManagerImpl::GetDisplayLayout( |
| 204 const std::vector<DisplayState>& displays, | 213 const std::vector<DisplaySnapshot*>& displays, |
| 205 MultipleDisplayState new_display_state, | 214 MultipleDisplayState new_display_state, |
| 206 chromeos::DisplayPowerState new_power_state, | 215 chromeos::DisplayPowerState new_power_state, |
| 207 std::vector<DisplayConfigureRequest>* requests, | 216 std::vector<DisplayConfigureRequest>* requests, |
| 208 gfx::Size* framebuffer_size) const { | 217 gfx::Size* framebuffer_size) const { |
| 218 std::vector<DisplayState> states = ParseDisplays(displays); |
| 209 std::vector<bool> display_power; | 219 std::vector<bool> display_power; |
| 210 int num_on_displays = | 220 int num_on_displays = |
| 211 GetDisplayPower(displays, new_power_state, &display_power); | 221 GetDisplayPower(displays, new_power_state, &display_power); |
| 212 VLOG(1) << "EnterState: display=" | 222 VLOG(1) << "EnterState: display=" |
| 213 << MultipleDisplayStateToString(new_display_state) | 223 << MultipleDisplayStateToString(new_display_state) |
| 214 << " power=" << DisplayPowerStateToString(new_power_state); | 224 << " power=" << DisplayPowerStateToString(new_power_state); |
| 215 | 225 |
| 216 // Framebuffer dimensions. | 226 // Framebuffer dimensions. |
| 217 gfx::Size size; | 227 gfx::Size size; |
| 218 | 228 |
| 219 for (size_t i = 0; i < displays.size(); ++i) { | 229 for (size_t i = 0; i < displays.size(); ++i) { |
| 220 requests->push_back(DisplayConfigureRequest( | 230 requests->push_back(DisplayConfigureRequest( |
| 221 displays[i].display, displays[i].display->current_mode(), | 231 displays[i], displays[i]->current_mode(), gfx::Point())); |
| 222 gfx::Point())); | |
| 223 } | 232 } |
| 224 | 233 |
| 225 switch (new_display_state) { | 234 switch (new_display_state) { |
| 226 case MULTIPLE_DISPLAY_STATE_INVALID: | 235 case MULTIPLE_DISPLAY_STATE_INVALID: |
| 227 NOTREACHED() << "Ignoring request to enter invalid state with " | 236 NOTREACHED() << "Ignoring request to enter invalid state with " |
| 228 << displays.size() << " connected display(s)"; | 237 << displays.size() << " connected display(s)"; |
| 229 return false; | 238 return false; |
| 230 case MULTIPLE_DISPLAY_STATE_HEADLESS: | 239 case MULTIPLE_DISPLAY_STATE_HEADLESS: |
| 231 if (displays.size() != 0) { | 240 if (displays.size() != 0) { |
| 232 LOG(WARNING) << "Ignoring request to enter headless mode with " | 241 LOG(WARNING) << "Ignoring request to enter headless mode with " |
| 233 << displays.size() << " connected display(s)"; | 242 << displays.size() << " connected display(s)"; |
| 234 return false; | 243 return false; |
| 235 } | 244 } |
| 236 break; | 245 break; |
| 237 case MULTIPLE_DISPLAY_STATE_SINGLE: { | 246 case MULTIPLE_DISPLAY_STATE_SINGLE: { |
| 238 // If there are multiple displays connected, only one should be turned on. | 247 // If there are multiple displays connected, only one should be turned on. |
| 239 if (displays.size() != 1 && num_on_displays != 1) { | 248 if (displays.size() != 1 && num_on_displays != 1) { |
| 240 LOG(WARNING) << "Ignoring request to enter single mode with " | 249 LOG(WARNING) << "Ignoring request to enter single mode with " |
| 241 << displays.size() << " connected displays and " | 250 << displays.size() << " connected displays and " |
| 242 << num_on_displays << " turned on"; | 251 << num_on_displays << " turned on"; |
| 243 return false; | 252 return false; |
| 244 } | 253 } |
| 245 | 254 |
| 246 for (size_t i = 0; i < displays.size(); ++i) { | 255 for (size_t i = 0; i < states.size(); ++i) { |
| 247 const DisplayConfigurator::DisplayState* state = &displays[i]; | 256 const DisplayState* state = &states[i]; |
| 248 (*requests)[i].mode = display_power[i] ? state->selected_mode : NULL; | 257 (*requests)[i].mode = display_power[i] ? state->selected_mode : NULL; |
| 249 | 258 |
| 250 if (display_power[i] || displays.size() == 1) { | 259 if (display_power[i] || states.size() == 1) { |
| 251 const DisplayMode* mode_info = state->selected_mode; | 260 const DisplayMode* mode_info = state->selected_mode; |
| 252 if (!mode_info) { | 261 if (!mode_info) { |
| 253 LOG(WARNING) << "No selected mode when configuring display: " | 262 LOG(WARNING) << "No selected mode when configuring display: " |
| 254 << state->display->ToString(); | 263 << state->display->ToString(); |
| 255 return false; | 264 return false; |
| 256 } | 265 } |
| 257 if (mode_info->size() == gfx::Size(1024, 768)) { | 266 if (mode_info->size() == gfx::Size(1024, 768)) { |
| 258 VLOG(1) << "Potentially misdetecting display(1024x768):" | 267 VLOG(1) << "Potentially misdetecting display(1024x768):" |
| 259 << " displays size=" << displays.size() | 268 << " displays size=" << states.size() |
| 260 << ", num_on_displays=" << num_on_displays | 269 << ", num_on_displays=" << num_on_displays |
| 261 << ", current size:" << size.width() << "x" << size.height() | 270 << ", current size:" << size.width() << "x" << size.height() |
| 262 << ", i=" << i << ", display=" << state->display->ToString() | 271 << ", i=" << i << ", display=" << state->display->ToString() |
| 263 << ", display_mode=" << mode_info->ToString(); | 272 << ", display_mode=" << mode_info->ToString(); |
| 264 } | 273 } |
| 265 size = mode_info->size(); | 274 size = mode_info->size(); |
| 266 } | 275 } |
| 267 } | 276 } |
| 268 break; | 277 break; |
| 269 } | 278 } |
| 270 case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR: { | 279 case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR: { |
| 271 if (displays.size() != 2 || | 280 if (states.size() != 2 || |
| 272 (num_on_displays != 0 && num_on_displays != 2)) { | 281 (num_on_displays != 0 && num_on_displays != 2)) { |
| 273 LOG(WARNING) << "Ignoring request to enter mirrored mode with " | 282 LOG(WARNING) << "Ignoring request to enter mirrored mode with " |
| 274 << displays.size() << " connected display(s) and " | 283 << states.size() << " connected display(s) and " |
| 275 << num_on_displays << " turned on"; | 284 << num_on_displays << " turned on"; |
| 276 return false; | 285 return false; |
| 277 } | 286 } |
| 278 | 287 |
| 279 const DisplayMode* mode_info = displays[0].mirror_mode; | 288 const DisplayMode* mode_info = states[0].mirror_mode; |
| 280 if (!mode_info) { | 289 if (!mode_info) { |
| 281 LOG(WARNING) << "No mirror mode when configuring display: " | 290 LOG(WARNING) << "No mirror mode when configuring display: " |
| 282 << displays[0].display->ToString(); | 291 << states[0].display->ToString(); |
| 283 return false; | 292 return false; |
| 284 } | 293 } |
| 285 size = mode_info->size(); | 294 size = mode_info->size(); |
| 286 | 295 |
| 287 for (size_t i = 0; i < displays.size(); ++i) { | 296 for (size_t i = 0; i < states.size(); ++i) { |
| 288 const DisplayConfigurator::DisplayState* state = &displays[i]; | 297 const DisplayState* state = &states[i]; |
| 289 (*requests)[i].mode = display_power[i] ? state->mirror_mode : NULL; | 298 (*requests)[i].mode = display_power[i] ? state->mirror_mode : NULL; |
| 290 } | 299 } |
| 291 break; | 300 break; |
| 292 } | 301 } |
| 293 case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED: | 302 case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED: |
| 294 case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED: { | 303 case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED: { |
| 295 if ((new_display_state == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED && | 304 if ((new_display_state == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED && |
| 296 displays.size() != 2) || | 305 states.size() != 2) || |
| 297 (new_display_state == MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED && | 306 (new_display_state == MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED && |
| 298 displays.size() <= 2) || | 307 states.size() <= 2) || |
| 299 (num_on_displays != 0 && | 308 (num_on_displays != 0 && |
| 300 num_on_displays != static_cast<int>(displays.size()))) { | 309 num_on_displays != static_cast<int>(displays.size()))) { |
| 301 LOG(WARNING) << "Ignoring request to enter extended mode with " | 310 LOG(WARNING) << "Ignoring request to enter extended mode with " |
| 302 << displays.size() << " connected display(s) and " | 311 << states.size() << " connected display(s) and " |
| 303 << num_on_displays << " turned on"; | 312 << num_on_displays << " turned on"; |
| 304 return false; | 313 return false; |
| 305 } | 314 } |
| 306 | 315 |
| 307 for (size_t i = 0; i < displays.size(); ++i) { | 316 for (size_t i = 0; i < states.size(); ++i) { |
| 308 const DisplayConfigurator::DisplayState* state = &displays[i]; | 317 const DisplayState* state = &states[i]; |
| 309 (*requests)[i].origin.set_y(size.height() ? size.height() + kVerticalGap | 318 (*requests)[i].origin.set_y(size.height() ? size.height() + kVerticalGap |
| 310 : 0); | 319 : 0); |
| 311 (*requests)[i].mode = display_power[i] ? state->selected_mode : NULL; | 320 (*requests)[i].mode = display_power[i] ? state->selected_mode : NULL; |
| 312 | 321 |
| 313 // Retain the full screen size even if all displays are off so the | 322 // Retain the full screen size even if all displays are off so the |
| 314 // same desktop configuration can be restored when the displays are | 323 // same desktop configuration can be restored when the displays are |
| 315 // turned back on. | 324 // turned back on. |
| 316 const DisplayMode* mode_info = displays[i].selected_mode; | 325 const DisplayMode* mode_info = states[i].selected_mode; |
| 317 if (!mode_info) { | 326 if (!mode_info) { |
| 318 LOG(WARNING) << "No selected mode when configuring display: " | 327 LOG(WARNING) << "No selected mode when configuring display: " |
| 319 << state->display->ToString(); | 328 << state->display->ToString(); |
| 320 return false; | 329 return false; |
| 321 } | 330 } |
| 322 | 331 |
| 323 size.set_width(std::max<int>(size.width(), mode_info->size().width())); | 332 size.set_width(std::max<int>(size.width(), mode_info->size().width())); |
| 324 size.set_height(size.height() + (size.height() ? kVerticalGap : 0) + | 333 size.set_height(size.height() + (size.height() ? kVerticalGap : 0) + |
| 325 mode_info->size().height()); | 334 mode_info->size().height()); |
| 326 } | 335 } |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 // In mirror mode, protection request of all displays need to be fulfilled. | 563 // In mirror mode, protection request of all displays need to be fulfilled. |
| 555 // In non-mirror mode, only request of client's display needs to be | 564 // In non-mirror mode, only request of client's display needs to be |
| 556 // fulfilled. | 565 // fulfilled. |
| 557 ContentProtections::const_iterator request_it; | 566 ContentProtections::const_iterator request_it; |
| 558 if (IsMirroring()) { | 567 if (IsMirroring()) { |
| 559 for (request_it = requests.begin(); | 568 for (request_it = requests.begin(); |
| 560 request_it != requests.end(); | 569 request_it != requests.end(); |
| 561 ++request_it) | 570 ++request_it) |
| 562 all_desired |= request_it->second; | 571 all_desired |= request_it->second; |
| 563 } else { | 572 } else { |
| 564 request_it = requests.find(it->display->display_id()); | 573 request_it = requests.find((*it)->display_id()); |
| 565 if (request_it != requests.end()) | 574 if (request_it != requests.end()) |
| 566 all_desired = request_it->second; | 575 all_desired = request_it->second; |
| 567 } | 576 } |
| 568 | 577 |
| 569 switch (it->display->type()) { | 578 switch ((*it)->type()) { |
| 570 case DISPLAY_CONNECTION_TYPE_UNKNOWN: | 579 case DISPLAY_CONNECTION_TYPE_UNKNOWN: |
| 571 return false; | 580 return false; |
| 572 // DisplayPort, DVI, and HDMI all support HDCP. | 581 // DisplayPort, DVI, and HDMI all support HDCP. |
| 573 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: | 582 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: |
| 574 case DISPLAY_CONNECTION_TYPE_DVI: | 583 case DISPLAY_CONNECTION_TYPE_DVI: |
| 575 case DISPLAY_CONNECTION_TYPE_HDMI: { | 584 case DISPLAY_CONNECTION_TYPE_HDMI: { |
| 576 HDCPState current_state; | 585 HDCPState current_state; |
| 577 // Need to poll the driver for updates since other applications may | 586 // Need to poll the driver for updates since other applications may |
| 578 // have updated the state. | 587 // have updated the state. |
| 579 if (!native_display_delegate_->GetHDCPState(*it->display, | 588 if (!native_display_delegate_->GetHDCPState(**it, ¤t_state)) |
| 580 ¤t_state)) | |
| 581 return false; | 589 return false; |
| 582 bool current_desired = (current_state != HDCP_STATE_UNDESIRED); | 590 bool current_desired = (current_state != HDCP_STATE_UNDESIRED); |
| 583 bool new_desired = (all_desired & CONTENT_PROTECTION_METHOD_HDCP); | 591 bool new_desired = (all_desired & CONTENT_PROTECTION_METHOD_HDCP); |
| 584 // Don't enable again if HDCP is already active. Some buggy drivers | 592 // Don't enable again if HDCP is already active. Some buggy drivers |
| 585 // may disable and enable if setting "desired" in active state. | 593 // may disable and enable if setting "desired" in active state. |
| 586 if (current_desired != new_desired) { | 594 if (current_desired != new_desired) { |
| 587 HDCPState new_state = | 595 HDCPState new_state = |
| 588 new_desired ? HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED; | 596 new_desired ? HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED; |
| 589 if (!native_display_delegate_->SetHDCPState(*it->display, new_state)) | 597 if (!native_display_delegate_->SetHDCPState(**it, new_state)) |
| 590 return false; | 598 return false; |
| 591 } | 599 } |
| 592 break; | 600 break; |
| 593 } | 601 } |
| 594 case DISPLAY_CONNECTION_TYPE_INTERNAL: | 602 case DISPLAY_CONNECTION_TYPE_INTERNAL: |
| 595 case DISPLAY_CONNECTION_TYPE_VGA: | 603 case DISPLAY_CONNECTION_TYPE_VGA: |
| 596 case DISPLAY_CONNECTION_TYPE_NETWORK: | 604 case DISPLAY_CONNECTION_TYPE_NETWORK: |
| 597 // No protections for these types. Do nothing. | 605 // No protections for these types. Do nothing. |
| 598 break; | 606 break; |
| 599 case DISPLAY_CONNECTION_TYPE_NONE: | 607 case DISPLAY_CONNECTION_TYPE_NONE: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 if (!configure_display_ || display_externally_controlled_) | 648 if (!configure_display_ || display_externally_controlled_) |
| 641 return false; | 649 return false; |
| 642 | 650 |
| 643 uint32_t enabled = 0; | 651 uint32_t enabled = 0; |
| 644 uint32_t unfulfilled = 0; | 652 uint32_t unfulfilled = 0; |
| 645 *link_mask = 0; | 653 *link_mask = 0; |
| 646 for (DisplayStateList::const_iterator it = cached_displays_.begin(); | 654 for (DisplayStateList::const_iterator it = cached_displays_.begin(); |
| 647 it != cached_displays_.end(); | 655 it != cached_displays_.end(); |
| 648 ++it) { | 656 ++it) { |
| 649 // Query display if it is in mirror mode or client on the same display. | 657 // Query display if it is in mirror mode or client on the same display. |
| 650 if (!IsMirroring() && it->display->display_id() != display_id) | 658 if (!IsMirroring() && (*it)->display_id() != display_id) |
| 651 continue; | 659 continue; |
| 652 | 660 |
| 653 *link_mask |= it->display->type(); | 661 *link_mask |= (*it)->type(); |
| 654 switch (it->display->type()) { | 662 switch ((*it)->type()) { |
| 655 case DISPLAY_CONNECTION_TYPE_UNKNOWN: | 663 case DISPLAY_CONNECTION_TYPE_UNKNOWN: |
| 656 return false; | 664 return false; |
| 657 // DisplayPort, DVI, and HDMI all support HDCP. | 665 // DisplayPort, DVI, and HDMI all support HDCP. |
| 658 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: | 666 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: |
| 659 case DISPLAY_CONNECTION_TYPE_DVI: | 667 case DISPLAY_CONNECTION_TYPE_DVI: |
| 660 case DISPLAY_CONNECTION_TYPE_HDMI: { | 668 case DISPLAY_CONNECTION_TYPE_HDMI: { |
| 661 HDCPState state; | 669 HDCPState state; |
| 662 if (!native_display_delegate_->GetHDCPState(*it->display, &state)) | 670 if (!native_display_delegate_->GetHDCPState(**it, &state)) |
| 663 return false; | 671 return false; |
| 664 if (state == HDCP_STATE_ENABLED) | 672 if (state == HDCP_STATE_ENABLED) |
| 665 enabled |= CONTENT_PROTECTION_METHOD_HDCP; | 673 enabled |= CONTENT_PROTECTION_METHOD_HDCP; |
| 666 else | 674 else |
| 667 unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP; | 675 unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP; |
| 668 break; | 676 break; |
| 669 } | 677 } |
| 670 case DISPLAY_CONNECTION_TYPE_INTERNAL: | 678 case DISPLAY_CONNECTION_TYPE_INTERNAL: |
| 671 case DISPLAY_CONNECTION_TYPE_VGA: | 679 case DISPLAY_CONNECTION_TYPE_VGA: |
| 672 case DISPLAY_CONNECTION_TYPE_NETWORK: | 680 case DISPLAY_CONNECTION_TYPE_NETWORK: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 } | 736 } |
| 729 | 737 |
| 730 return true; | 738 return true; |
| 731 } | 739 } |
| 732 | 740 |
| 733 std::vector<ui::ColorCalibrationProfile> | 741 std::vector<ui::ColorCalibrationProfile> |
| 734 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { | 742 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { |
| 735 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 743 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 736 switches::kDisableDisplayColorCalibration)) { | 744 switches::kDisableDisplayColorCalibration)) { |
| 737 for (size_t i = 0; i < cached_displays_.size(); ++i) { | 745 for (size_t i = 0; i < cached_displays_.size(); ++i) { |
| 738 if (cached_displays_[i].display && | 746 if (cached_displays_[i]->display_id() == display_id) { |
| 739 cached_displays_[i].display->display_id() == display_id) { | |
| 740 return native_display_delegate_->GetAvailableColorCalibrationProfiles( | 747 return native_display_delegate_->GetAvailableColorCalibrationProfiles( |
| 741 *cached_displays_[i].display); | 748 *cached_displays_[i]); |
| 742 } | 749 } |
| 743 } | 750 } |
| 744 } | 751 } |
| 745 | 752 |
| 746 return std::vector<ui::ColorCalibrationProfile>(); | 753 return std::vector<ui::ColorCalibrationProfile>(); |
| 747 } | 754 } |
| 748 | 755 |
| 749 bool DisplayConfigurator::SetColorCalibrationProfile( | 756 bool DisplayConfigurator::SetColorCalibrationProfile( |
| 750 int64_t display_id, | 757 int64_t display_id, |
| 751 ui::ColorCalibrationProfile new_profile) { | 758 ui::ColorCalibrationProfile new_profile) { |
| 752 for (size_t i = 0; i < cached_displays_.size(); ++i) { | 759 for (size_t i = 0; i < cached_displays_.size(); ++i) { |
| 753 if (cached_displays_[i].display && | 760 if (cached_displays_[i]->display_id() == display_id) { |
| 754 cached_displays_[i].display->display_id() == display_id) { | |
| 755 return native_display_delegate_->SetColorCalibrationProfile( | 761 return native_display_delegate_->SetColorCalibrationProfile( |
| 756 *cached_displays_[i].display, new_profile); | 762 *cached_displays_[i], new_profile); |
| 757 } | 763 } |
| 758 } | 764 } |
| 759 | 765 |
| 760 return false; | 766 return false; |
| 761 } | 767 } |
| 762 | 768 |
| 763 void DisplayConfigurator::PrepareForExit() { | 769 void DisplayConfigurator::PrepareForExit() { |
| 764 configure_display_ = false; | 770 configure_display_ = false; |
| 765 } | 771 } |
| 766 | 772 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 requested_display_state_ = MULTIPLE_DISPLAY_STATE_INVALID; | 924 requested_display_state_ = MULTIPLE_DISPLAY_STATE_INVALID; |
| 919 | 925 |
| 920 DCHECK(in_progress_configuration_callbacks_.empty()); | 926 DCHECK(in_progress_configuration_callbacks_.empty()); |
| 921 in_progress_configuration_callbacks_.swap(queued_configuration_callbacks_); | 927 in_progress_configuration_callbacks_.swap(queued_configuration_callbacks_); |
| 922 | 928 |
| 923 configuration_task_->Run(); | 929 configuration_task_->Run(); |
| 924 } | 930 } |
| 925 | 931 |
| 926 void DisplayConfigurator::OnConfigured( | 932 void DisplayConfigurator::OnConfigured( |
| 927 bool success, | 933 bool success, |
| 928 const std::vector<DisplayState>& displays, | 934 const std::vector<DisplaySnapshot*>& displays, |
| 929 const gfx::Size& framebuffer_size, | 935 const gfx::Size& framebuffer_size, |
| 930 MultipleDisplayState new_display_state, | 936 MultipleDisplayState new_display_state, |
| 931 chromeos::DisplayPowerState new_power_state) { | 937 chromeos::DisplayPowerState new_power_state) { |
| 932 VLOG(1) << "OnConfigured: success=" << success << " new_display_state=" | 938 VLOG(1) << "OnConfigured: success=" << success << " new_display_state=" |
| 933 << MultipleDisplayStateToString(new_display_state) | 939 << MultipleDisplayStateToString(new_display_state) |
| 934 << " new_power_state=" << DisplayPowerStateToString(new_power_state); | 940 << " new_power_state=" << DisplayPowerStateToString(new_power_state); |
| 935 | 941 |
| 936 cached_displays_ = displays; | 942 cached_displays_ = displays; |
| 937 if (success) { | 943 if (success) { |
| 938 current_display_state_ = new_display_state; | 944 current_display_state_ = new_display_state; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 FOR_EACH_OBSERVER( | 1013 FOR_EACH_OBSERVER( |
| 1008 Observer, observers_, OnDisplayModeChanged(cached_displays_)); | 1014 Observer, observers_, OnDisplayModeChanged(cached_displays_)); |
| 1009 } else { | 1015 } else { |
| 1010 FOR_EACH_OBSERVER( | 1016 FOR_EACH_OBSERVER( |
| 1011 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, | 1017 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, |
| 1012 attempted_state)); | 1018 attempted_state)); |
| 1013 } | 1019 } |
| 1014 } | 1020 } |
| 1015 | 1021 |
| 1016 } // namespace ui | 1022 } // namespace ui |
| OLD | NEW |