Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/extensions/display_info_provider_chromeos.cc

Issue 2196923002: Make ash::DisplayMode more like ui::DisplayMode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(info.display_mode->width_in_native_pixels,
325 new_mode.interlaced = current_mode.interlaced; 324 info.display_mode->height_in_native_pixels);
326 // Set properties from the UI properties.
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 325
333 if (new_mode.IsEquivalent(current_mode)) { 326 // NB: info.display_mode is neither an ash::DisplayMode or a
334 *error = "Display mode mataches crrent mode."; 327 // ui::DisplayMode.
328 scoped_refptr<ash::DisplayMode> new_mode(new ash::DisplayMode(
329 size, current_mode->refresh_rate(), current_mode->is_interlaced(),
330 info.display_mode->is_native, info.display_mode->ui_scale,
331 info.display_mode->device_scale_factor));
332
333 if (new_mode->IsEquivalent(current_mode)) {
334 *error = "Display mode matches current mode.";
335 return false; 335 return false;
336 } 336 }
337 337
338 if (!display_manager->SetDisplayMode(id, new_mode)) { 338 if (!display_manager->SetDisplayMode(id, new_mode)) {
339 *error = "Unable to set the display mode."; 339 *error = "Unable to set the display mode.";
340 return false; 340 return false;
341 } 341 }
342 342
343 if (!display::Display::IsInternalDisplayId(id)) { 343 if (!display::Display::IsInternalDisplayId(id)) {
344 // For external displays, show a notification confirming the resolution 344 // For external displays, show a notification confirming the resolution
345 // change. 345 // change.
346 ash::Shell::GetInstance() 346 ash::Shell::GetInstance()
347 ->resolution_notification_controller() 347 ->resolution_notification_controller()
348 ->PrepareNotification(id, current_mode, new_mode, 348 ->PrepareNotification(id, current_mode, new_mode,
349 base::Bind(&chromeos::StoreDisplayPrefs)); 349 base::Bind(&chromeos::StoreDisplayPrefs));
350 } 350 }
351 } 351 }
352 return true; 352 return true;
353 } 353 }
354 354
355 system_display::DisplayMode GetDisplayMode( 355 system_display::DisplayMode GetDisplayMode(
356 ash::DisplayManager* display_manager, 356 ash::DisplayManager* display_manager,
357 const ash::DisplayInfo& display_info, 357 const ash::DisplayInfo& display_info,
358 const ash::DisplayMode& display_mode) { 358 const scoped_refptr<ash::DisplayMode>& display_mode) {
359 system_display::DisplayMode result; 359 system_display::DisplayMode result;
360 360
361 bool is_internal = display::Display::HasInternalDisplay() && 361 bool is_internal = display::Display::HasInternalDisplay() &&
362 display::Display::InternalDisplayId() == display_info.id(); 362 display::Display::InternalDisplayId() == display_info.id();
363 gfx::Size size_dip = display_mode.GetSizeInDIP(is_internal); 363 gfx::Size size_dip = display_mode->GetSizeInDIP(is_internal);
364 result.width = size_dip.width(); 364 result.width = size_dip.width();
365 result.height = size_dip.height(); 365 result.height = size_dip.height();
366 result.width_in_native_pixels = display_mode.size.width(); 366 result.width_in_native_pixels = display_mode->size().width();
367 result.height_in_native_pixels = display_mode.size.height(); 367 result.height_in_native_pixels = display_mode->size().height();
368 result.ui_scale = display_mode.ui_scale; 368 result.ui_scale = display_mode->ui_scale();
369 result.device_scale_factor = display_mode.device_scale_factor; 369 result.device_scale_factor = display_mode->device_scale_factor();
370 result.is_native = display_mode.native; 370 result.is_native = display_mode->native();
371 result.is_selected = display_mode.IsEquivalent( 371 result.is_selected = display_mode->IsEquivalent(
372 display_manager->GetActiveModeForDisplayId(display_info.id())); 372 display_manager->GetActiveModeForDisplayId(display_info.id()));
373 return result; 373 return result;
374 } 374 }
375 375
376 } // namespace 376 } // namespace
377 377
378 DisplayInfoProviderChromeOS::DisplayInfoProviderChromeOS() {} 378 DisplayInfoProviderChromeOS::DisplayInfoProviderChromeOS() {}
379 379
380 DisplayInfoProviderChromeOS::~DisplayInfoProviderChromeOS() {} 380 DisplayInfoProviderChromeOS::~DisplayInfoProviderChromeOS() {}
381 381
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 unit->dpi_y = device_dpi * display.size().height() / 509 unit->dpi_y = device_dpi * display.size().height() /
510 display_info.bounds_in_native().height(); 510 display_info.bounds_in_native().height();
511 511
512 const gfx::Insets overscan_insets = 512 const gfx::Insets overscan_insets =
513 display_manager->GetOverscanInsets(display.id()); 513 display_manager->GetOverscanInsets(display.id());
514 unit->overscan.left = overscan_insets.left(); 514 unit->overscan.left = overscan_insets.left();
515 unit->overscan.top = overscan_insets.top(); 515 unit->overscan.top = overscan_insets.top();
516 unit->overscan.right = overscan_insets.right(); 516 unit->overscan.right = overscan_insets.right();
517 unit->overscan.bottom = overscan_insets.bottom(); 517 unit->overscan.bottom = overscan_insets.bottom();
518 518
519 for (const ash::DisplayMode& display_mode : display_info.display_modes()) { 519 for (const scoped_refptr<ash::DisplayMode>& display_mode :
520 display_info.display_modes()) {
520 unit->modes.push_back( 521 unit->modes.push_back(
521 GetDisplayMode(display_manager, display_info, display_mode)); 522 GetDisplayMode(display_manager, display_info, display_mode));
522 } 523 }
523 } 524 }
524 525
525 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { 526 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) {
526 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( 527 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(
527 enable); 528 enable);
528 } 529 }
529 530
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 return nullptr; 634 return nullptr;
634 return iter->second.get(); 635 return iter->second.get();
635 } 636 }
636 637
637 // static 638 // static
638 DisplayInfoProvider* DisplayInfoProvider::Create() { 639 DisplayInfoProvider* DisplayInfoProvider::Create() {
639 return new DisplayInfoProviderChromeOS(); 640 return new DisplayInfoProviderChromeOS();
640 } 641 }
641 642
642 } // namespace extensions 643 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698