diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-22 07:01:50 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-22 07:01:50 +0000 |
commit | 38472463f750a820e5c3f727b7bb9d60764dfb00 (patch) | |
tree | 3d92aebd573b5f3a5c37e0ff7c49bf06e1804684 /ash/display | |
parent | 773217067a3016c17fac70c0efe5ac568f404d12 (diff) | |
download | chromium_src-38472463f750a820e5c3f727b7bb9d60764dfb00.zip chromium_src-38472463f750a820e5c3f727b7bb9d60764dfb00.tar.gz chromium_src-38472463f750a820e5c3f727b7bb9d60764dfb00.tar.bz2 |
Refactors getting available color profiles code.
My first CL got affected the recent refactoring of display/chromeos
and it needs some cleanups. I think the new code makes more sense.
- DisplayState struct isn't accessible from native_display_delegate
but the color profiles are in the native layer. It doesn't make
sense to put the list there.
- Instead of moving the data into DisplaySnapshot, it seems nicer
to query the list of available profiles and to treat the list
as a cache. This also avoids duplicating the same list both in
DisplayInfo and another struct.
- The destructor of DisplayState was introduced by me because
it gets a complicated struct due to available_color_profiles.
Now it's gone, so it doesn't necessarily exist.
BUG=None
R=oshima@chromium.org, marcheu@chromium.org
TEST=build succeeds
Review URL: https://codereview.chromium.org/208943002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/display')
-rw-r--r-- | ash/display/display_change_observer_chromeos.cc | 16 | ||||
-rw-r--r-- | ash/display/display_info.cc | 12 | ||||
-rw-r--r-- | ash/display/display_info.h | 3 | ||||
-rw-r--r-- | ash/display/display_manager.cc | 3 |
4 files changed, 23 insertions, 11 deletions
diff --git a/ash/display/display_change_observer_chromeos.cc b/ash/display/display_change_observer_chromeos.cc index 461b7be..97c9d26 100644 --- a/ash/display/display_change_observer_chromeos.cc +++ b/ash/display/display_change_observer_chromeos.cc @@ -158,15 +158,17 @@ void DisplayChangeObserver::OnDisplayModeChanged( ids.insert(id); displays.push_back(DisplayInfo(id, name, has_overscan)); - displays.back().set_device_scale_factor(device_scale_factor); - displays.back().SetBounds(display_bounds); - displays.back().set_native(true); - displays.back().set_display_modes(display_modes); - displays.back().set_touch_support( + DisplayInfo& new_info = displays.back(); + new_info.set_device_scale_factor(device_scale_factor); + new_info.SetBounds(display_bounds); + new_info.set_native(true); + new_info.set_display_modes(display_modes); + new_info.set_touch_support( output.touch_device_id == 0 ? gfx::Display::TOUCH_SUPPORT_UNAVAILABLE : gfx::Display::TOUCH_SUPPORT_AVAILABLE); - displays.back().set_available_color_profiles( - output.available_color_profiles); + new_info.set_available_color_profiles( + Shell::GetInstance()->output_configurator()-> + GetAvailableColorCalibrationProfiles(id)); } // DisplayManager can be null during the boot. diff --git a/ash/display/display_info.cc b/ash/display/display_info.cc index 25b6a74..e3a4b63 100644 --- a/ash/display/display_info.cc +++ b/ash/display/display_info.cc @@ -305,11 +305,15 @@ std::string DisplayInfo::ToFullString() const { } void DisplayInfo::SetColorProfile(ui::ColorCalibrationProfile profile) { - if (std::find(available_color_profiles_.begin(), - available_color_profiles_.end(), - profile) != available_color_profiles_.end()) { + if (IsColorProfileAvailable(profile)) color_profile_ = profile; - } +} + +bool DisplayInfo::IsColorProfileAvailable( + ui::ColorCalibrationProfile profile) const { + return std::find(available_color_profiles_.begin(), + available_color_profiles_.end(), + profile) != available_color_profiles_.end(); } } // namespace internal diff --git a/ash/display/display_info.h b/ash/display/display_info.h index d47ac37..14af285 100644 --- a/ash/display/display_info.h +++ b/ash/display/display_info.h @@ -163,6 +163,9 @@ class ASH_EXPORT DisplayInfo { // |available_color_profiles_|. void SetColorProfile(ui::ColorCalibrationProfile profile); + // Returns true if |profile| is in |available_color_profiles_|. + bool IsColorProfileAvailable(ui::ColorCalibrationProfile profile) const; + const std::vector<ui::ColorCalibrationProfile>& available_color_profiles() const { return available_color_profiles_; diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc index c548428..8c02f44 100644 --- a/ash/display/display_manager.cc +++ b/ash/display/display_manager.cc @@ -508,6 +508,9 @@ void DisplayManager::SetColorCalibrationProfile( int64 display_id, ui::ColorCalibrationProfile profile) { #if defined(OS_CHROMEOS) + if (!display_info_[display_id].IsColorProfileAvailable(profile)) + return; + if (delegate_) delegate_->PreDisplayConfigurationChange(false); if (Shell::GetInstance()->output_configurator()->SetColorCalibrationProfile( |