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

Side by Side Diff: ash/display/display_manager.cc

Issue 138903025: Read compositor VSync information from platform, when possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 041e3518 Cleaned up. Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/display/display_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 const std::vector<Resolution>& resolutions = display_info.resolutions(); 445 const std::vector<Resolution>& resolutions = display_info.resolutions();
446 DCHECK_NE(0u, resolutions.size()); 446 DCHECK_NE(0u, resolutions.size());
447 std::vector<Resolution>::const_iterator iter = 447 std::vector<Resolution>::const_iterator iter =
448 std::find_if(resolutions.begin(), 448 std::find_if(resolutions.begin(),
449 resolutions.end(), 449 resolutions.end(),
450 ResolutionMatcher(resolution)); 450 ResolutionMatcher(resolution));
451 if (iter == resolutions.end()) { 451 if (iter == resolutions.end()) {
452 LOG(WARNING) << "Unsupported resolution was requested:" 452 LOG(WARNING) << "Unsupported resolution was requested:"
453 << resolution.ToString(); 453 << resolution.ToString();
454 return; 454 return;
455 } else if (iter == resolutions.begin()) {
456 // The best resolution was set, so forget it.
457 resolutions_.erase(display_id);
458 } else {
459 resolutions_[display_id] = resolution;
460 } 455 }
456 resolutions_[display_id] = *iter;
461 #if defined(OS_CHROMEOS) && defined(USE_X11) 457 #if defined(OS_CHROMEOS) && defined(USE_X11)
462 if (base::SysInfo::IsRunningOnChromeOS()) 458 if (base::SysInfo::IsRunningOnChromeOS())
463 Shell::GetInstance()->output_configurator()->ScheduleConfigureOutputs(); 459 Shell::GetInstance()->output_configurator()->ScheduleConfigureOutputs();
464 #endif 460 #endif
465 } 461 }
466 462
467 void DisplayManager::RegisterDisplayProperty( 463 void DisplayManager::RegisterDisplayProperty(
468 int64 display_id, 464 int64 display_id,
469 gfx::Display::Rotation rotation, 465 gfx::Display::Rotation rotation,
470 float ui_scale, 466 float ui_scale,
471 const gfx::Insets* overscan_insets, 467 const gfx::Insets* overscan_insets,
472 const gfx::Size& resolution_in_pixels) { 468 const gfx::Size& resolution_in_pixels,
469 float refresh_rate) {
473 if (display_info_.find(display_id) == display_info_.end()) { 470 if (display_info_.find(display_id) == display_info_.end()) {
474 display_info_[display_id] = 471 display_info_[display_id] =
475 DisplayInfo(display_id, std::string(""), false); 472 DisplayInfo(display_id, std::string(""), false);
476 } 473 }
477 474
478 display_info_[display_id].set_rotation(rotation); 475 display_info_[display_id].set_rotation(rotation);
479 // Just in case the preference file was corrupted. 476 // Just in case the preference file was corrupted.
480 if (0.5f <= ui_scale && ui_scale <= 2.0f) 477 if (0.5f <= ui_scale && ui_scale <= 2.0f)
481 display_info_[display_id].set_configured_ui_scale(ui_scale); 478 display_info_[display_id].set_configured_ui_scale(ui_scale);
482 if (overscan_insets) 479 if (overscan_insets)
483 display_info_[display_id].SetOverscanInsets(*overscan_insets); 480 display_info_[display_id].SetOverscanInsets(*overscan_insets);
484 if (!resolution_in_pixels.IsEmpty()) 481 if (!resolution_in_pixels.IsEmpty()) {
485 resolutions_[display_id] = resolution_in_pixels; 482 resolutions_[display_id] =
483 Resolution(resolution_in_pixels, refresh_rate, false);
484 }
486 } 485 }
487 486
488 bool DisplayManager::GetSelectedResolutionForDisplayId( 487 bool DisplayManager::GetSelectedResolutionForDisplayId(
489 int64 id, 488 int64 id,
490 gfx::Size* resolution_out) const { 489 gfx::Size* resolution_out,
491 std::map<int64, gfx::Size>::const_iterator iter = 490 float* refresh_rate_out) const {
492 resolutions_.find(id); 491 std::map<int64, Resolution>::const_iterator iter = resolutions_.find(id);
493 if (iter == resolutions_.end()) 492 if (iter == resolutions_.end())
494 return false; 493 return false;
495 *resolution_out = iter->second; 494 *resolution_out = iter->second.size;
495 *refresh_rate_out = iter->second.refresh_rate;
496 return true; 496 return true;
497 } 497 }
498 498
499 bool DisplayManager::IsDisplayUIScalingEnabled() const { 499 bool DisplayManager::IsDisplayUIScalingEnabled() const {
500 return GetDisplayIdForUIScaling() != gfx::Display::kInvalidDisplayID; 500 return GetDisplayIdForUIScaling() != gfx::Display::kInvalidDisplayID;
501 } 501 }
502 502
503 gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const { 503 gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const {
504 std::map<int64, DisplayInfo>::const_iterator it = 504 std::map<int64, DisplayInfo>::const_iterator it =
505 display_info_.find(display_id); 505 display_info_.find(display_id);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 const gfx::Size& resolution = iter->bounds_in_native().size(); 568 const gfx::Size& resolution = iter->bounds_in_native().size();
569 const std::vector<Resolution>& resolutions = iter->resolutions(); 569 const std::vector<Resolution>& resolutions = iter->resolutions();
570 // This is empty the displays are initialized from InitFromCommandLine. 570 // This is empty the displays are initialized from InitFromCommandLine.
571 if (!resolutions.size()) 571 if (!resolutions.size())
572 continue; 572 continue;
573 std::vector<Resolution>::const_iterator resolution_iter = 573 std::vector<Resolution>::const_iterator resolution_iter =
574 std::find_if(resolutions.begin(), 574 std::find_if(resolutions.begin(),
575 resolutions.end(), 575 resolutions.end(),
576 ResolutionMatcher(resolution)); 576 ResolutionMatcher(resolution));
577 // Update the actual resolution selected as the resolution request may fail. 577 // Update the actual resolution selected as the resolution request may fail.
578 if (resolution_iter == resolutions.begin()) 578 if (resolution_iter != resolutions.end())
579 resolutions_[iter->id()] = *resolution_iter;
580 else
579 resolutions_.erase(iter->id()); 581 resolutions_.erase(iter->id());
580 else if (resolutions_.find(iter->id()) != resolutions_.end())
581 resolutions_[iter->id()] = resolution;
582 } 582 }
583 if (HasInternalDisplay() && 583 if (HasInternalDisplay() &&
584 !internal_display_connected && 584 !internal_display_connected &&
585 display_info_.find(gfx::Display::InternalDisplayId()) == 585 display_info_.find(gfx::Display::InternalDisplayId()) ==
586 display_info_.end()) { 586 display_info_.end()) {
587 DisplayInfo internal_display_info( 587 DisplayInfo internal_display_info(
588 gfx::Display::InternalDisplayId(), 588 gfx::Display::InternalDisplayId(),
589 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME), 589 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME),
590 false /*Internal display must not have overscan */); 590 false /*Internal display must not have overscan */);
591 internal_display_info.SetBounds(gfx::Rect(0, 0, 800, 600)); 591 internal_display_info.SetBounds(gfx::Rect(0, 0, 800, 600));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 while (curr_iter != displays_.end() || 652 while (curr_iter != displays_.end() ||
653 new_info_iter != new_display_info_list.end()) { 653 new_info_iter != new_display_info_list.end()) {
654 if (new_info_iter != new_display_info_list.end() && 654 if (new_info_iter != new_display_info_list.end() &&
655 non_desktop_display_id == new_info_iter->id()) { 655 non_desktop_display_id == new_info_iter->id()) {
656 DisplayInfo info = *new_info_iter; 656 DisplayInfo info = *new_info_iter;
657 info.SetOverscanInsets(gfx::Insets()); 657 info.SetOverscanInsets(gfx::Insets());
658 InsertAndUpdateDisplayInfo(info); 658 InsertAndUpdateDisplayInfo(info);
659 non_desktop_display_ = 659 non_desktop_display_ =
660 CreateDisplayFromDisplayInfoById(non_desktop_display_id); 660 CreateDisplayFromDisplayInfoById(non_desktop_display_id);
661 ++new_info_iter; 661 ++new_info_iter;
662 // Remove existing external dispaly if it is going to be used as 662 // Remove existing external display if it is going to be used as
663 // non desktop. 663 // non desktop.
664 if (curr_iter != displays_.end() && 664 if (curr_iter != displays_.end() &&
665 curr_iter->id() == non_desktop_display_id) { 665 curr_iter->id() == non_desktop_display_id) {
666 removed_displays.push_back(*curr_iter); 666 removed_displays.push_back(*curr_iter);
667 ++curr_iter; 667 ++curr_iter;
668 } 668 }
669 continue; 669 continue;
670 } 670 }
671 671
672 if (curr_iter == displays_.end()) { 672 if (curr_iter == displays_.end()) {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 break; 1081 break;
1082 } 1082 }
1083 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); 1083 gfx::Insets insets = secondary_display->GetWorkAreaInsets();
1084 secondary_display->set_bounds( 1084 secondary_display->set_bounds(
1085 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 1085 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
1086 secondary_display->UpdateWorkAreaFromInsets(insets); 1086 secondary_display->UpdateWorkAreaFromInsets(insets);
1087 } 1087 }
1088 1088
1089 } // namespace internal 1089 } // namespace internal
1090 } // namespace ash 1090 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698