Chromium Code Reviews| 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 "chrome/browser/extensions/display_info_provider_chromeos.h" | 5 #include "chrome/browser/extensions/display_info_provider_chromeos.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "ash/display/display_configuration_controller.h" | 9 #include "ash/display/display_configuration_controller.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 } | 310 } |
| 311 | 311 |
| 312 if ((info.overscan->top + info.overscan->bottom) * 2 > screen_height) { | 312 if ((info.overscan->top + info.overscan->bottom) * 2 > screen_height) { |
| 313 *error = "Vertical overscan is more than half of the screen height."; | 313 *error = "Vertical overscan is more than half of the screen height."; |
| 314 return false; | 314 return false; |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 | 317 |
| 318 // Set the display mode. | 318 // Set the display mode. |
| 319 if (info.display_mode) { | 319 if (info.display_mode) { |
| 320 ash::DisplayMode current_mode = | 320 scoped_refptr<ash::DisplayMode> current_mode = |
| 321 display_manager->GetActiveModeForDisplayId(id); | 321 display_manager->GetActiveModeForDisplayId(id); |
| 322 ash::DisplayMode new_mode; | |
| 323 // Copy properties not set in the UI from the current mode. | 322 // Copy properties not set in the UI from the current mode. |
| 324 new_mode.refresh_rate = current_mode.refresh_rate; | 323 gfx::Size size; |
|
oshima
2016/08/02 19:44:57
size(info.display_mode-> .... ) ?
rjkroege
2016/08/04 00:12:04
Done.
| |
| 325 new_mode.interlaced = current_mode.interlaced; | 324 size.SetSize(info.display_mode->width_in_native_pixels, |
| 326 // Set properties from the UI properties. | 325 info.display_mode->height_in_native_pixels); |
| 327 new_mode.size.SetSize(info.display_mode->width_in_native_pixels, | |
| 328 info.display_mode->height_in_native_pixels); | |
| 329 new_mode.ui_scale = info.display_mode->ui_scale; | |
| 330 new_mode.device_scale_factor = info.display_mode->device_scale_factor; | |
| 331 new_mode.native = info.display_mode->is_native; | |
| 332 | 326 |
| 333 if (new_mode.IsEquivalent(current_mode)) { | 327 // NB: info.display_mode is neither an ash::DisplayMode or a |
| 334 *error = "Display mode mataches crrent mode."; | 328 // ui::DisplayMode. |
| 329 scoped_refptr<ash::DisplayMode> new_mode(new ash::DisplayMode( | |
| 330 size, current_mode->refresh_rate(), current_mode->is_interlaced(), | |
| 331 info.display_mode->is_native, info.display_mode->ui_scale, | |
| 332 info.display_mode->device_scale_factor)); | |
| 333 | |
| 334 if (new_mode->IsEquivalent(current_mode)) { | |
| 335 *error = "Display mode matches current mode."; | |
| 335 return false; | 336 return false; |
| 336 } | 337 } |
| 337 | 338 |
| 338 if (!display_manager->SetDisplayMode(id, new_mode)) { | 339 if (!display_manager->SetDisplayMode(id, new_mode)) { |
| 339 *error = "Unable to set the display mode."; | 340 *error = "Unable to set the display mode."; |
| 340 return false; | 341 return false; |
| 341 } | 342 } |
| 342 | 343 |
| 343 if (!display::Display::IsInternalDisplayId(id)) { | 344 if (!display::Display::IsInternalDisplayId(id)) { |
| 344 // For external displays, show a notification confirming the resolution | 345 // For external displays, show a notification confirming the resolution |
| 345 // change. | 346 // change. |
| 346 ash::Shell::GetInstance() | 347 ash::Shell::GetInstance() |
| 347 ->resolution_notification_controller() | 348 ->resolution_notification_controller() |
| 348 ->PrepareNotification(id, current_mode, new_mode, | 349 ->PrepareNotification(id, current_mode, new_mode, |
| 349 base::Bind(&chromeos::StoreDisplayPrefs)); | 350 base::Bind(&chromeos::StoreDisplayPrefs)); |
| 350 } | 351 } |
| 351 } | 352 } |
| 352 return true; | 353 return true; |
| 353 } | 354 } |
| 354 | 355 |
| 355 system_display::DisplayMode GetDisplayMode( | 356 system_display::DisplayMode GetDisplayMode( |
| 356 ash::DisplayManager* display_manager, | 357 ash::DisplayManager* display_manager, |
| 357 const ash::DisplayInfo& display_info, | 358 const ash::DisplayInfo& display_info, |
| 358 const ash::DisplayMode& display_mode) { | 359 const scoped_refptr<ash::DisplayMode>& display_mode) { |
| 359 system_display::DisplayMode result; | 360 system_display::DisplayMode result; |
| 360 | 361 |
| 361 bool is_internal = display::Display::HasInternalDisplay() && | 362 bool is_internal = display::Display::HasInternalDisplay() && |
| 362 display::Display::InternalDisplayId() == display_info.id(); | 363 display::Display::InternalDisplayId() == display_info.id(); |
| 363 gfx::Size size_dip = display_mode.GetSizeInDIP(is_internal); | 364 gfx::Size size_dip = display_mode->GetSizeInDIP(is_internal); |
| 364 result.width = size_dip.width(); | 365 result.width = size_dip.width(); |
| 365 result.height = size_dip.height(); | 366 result.height = size_dip.height(); |
| 366 result.width_in_native_pixels = display_mode.size.width(); | 367 result.width_in_native_pixels = display_mode->size().width(); |
| 367 result.height_in_native_pixels = display_mode.size.height(); | 368 result.height_in_native_pixels = display_mode->size().height(); |
| 368 result.ui_scale = display_mode.ui_scale; | 369 result.ui_scale = display_mode->ui_scale(); |
| 369 result.device_scale_factor = display_mode.device_scale_factor; | 370 result.device_scale_factor = display_mode->device_scale_factor(); |
| 370 result.is_native = display_mode.native; | 371 result.is_native = display_mode->native(); |
| 371 result.is_selected = display_mode.IsEquivalent( | 372 result.is_selected = display_mode->IsEquivalent( |
| 372 display_manager->GetActiveModeForDisplayId(display_info.id())); | 373 display_manager->GetActiveModeForDisplayId(display_info.id())); |
| 373 return result; | 374 return result; |
| 374 } | 375 } |
| 375 | 376 |
| 376 } // namespace | 377 } // namespace |
| 377 | 378 |
| 378 DisplayInfoProviderChromeOS::DisplayInfoProviderChromeOS() {} | 379 DisplayInfoProviderChromeOS::DisplayInfoProviderChromeOS() {} |
| 379 | 380 |
| 380 DisplayInfoProviderChromeOS::~DisplayInfoProviderChromeOS() {} | 381 DisplayInfoProviderChromeOS::~DisplayInfoProviderChromeOS() {} |
| 381 | 382 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 unit->dpi_y = device_dpi * display.size().height() / | 510 unit->dpi_y = device_dpi * display.size().height() / |
| 510 display_info.bounds_in_native().height(); | 511 display_info.bounds_in_native().height(); |
| 511 | 512 |
| 512 const gfx::Insets overscan_insets = | 513 const gfx::Insets overscan_insets = |
| 513 display_manager->GetOverscanInsets(display.id()); | 514 display_manager->GetOverscanInsets(display.id()); |
| 514 unit->overscan.left = overscan_insets.left(); | 515 unit->overscan.left = overscan_insets.left(); |
| 515 unit->overscan.top = overscan_insets.top(); | 516 unit->overscan.top = overscan_insets.top(); |
| 516 unit->overscan.right = overscan_insets.right(); | 517 unit->overscan.right = overscan_insets.right(); |
| 517 unit->overscan.bottom = overscan_insets.bottom(); | 518 unit->overscan.bottom = overscan_insets.bottom(); |
| 518 | 519 |
| 519 for (const ash::DisplayMode& display_mode : display_info.display_modes()) { | 520 for (const scoped_refptr<ash::DisplayMode>& display_mode : |
| 521 display_info.display_modes()) { | |
| 520 unit->modes.push_back( | 522 unit->modes.push_back( |
| 521 GetDisplayMode(display_manager, display_info, display_mode)); | 523 GetDisplayMode(display_manager, display_info, display_mode)); |
| 522 } | 524 } |
| 523 } | 525 } |
| 524 | 526 |
| 525 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { | 527 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { |
| 526 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( | 528 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( |
| 527 enable); | 529 enable); |
| 528 } | 530 } |
| 529 | 531 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 return nullptr; | 635 return nullptr; |
| 634 return iter->second.get(); | 636 return iter->second.get(); |
| 635 } | 637 } |
| 636 | 638 |
| 637 // static | 639 // static |
| 638 DisplayInfoProvider* DisplayInfoProvider::Create() { | 640 DisplayInfoProvider* DisplayInfoProvider::Create() { |
| 639 return new DisplayInfoProviderChromeOS(); | 641 return new DisplayInfoProviderChromeOS(); |
| 640 } | 642 } |
| 641 | 643 |
| 642 } // namespace extensions | 644 } // namespace extensions |
| OLD | NEW |