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

Side by Side Diff: ash/display/display_change_observer_chromeos.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, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_change_observer_chromeos.h" 5 #include "ash/display/display_change_observer_chromeos.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 23 matching lines...) Expand all
34 // Higher DPI than this will use device_scale_factor=2. 34 // Higher DPI than this will use device_scale_factor=2.
35 const unsigned int kHighDensityDPIThreshold = 160; 35 const unsigned int kHighDensityDPIThreshold = 160;
36 36
37 // 1 inch in mm. 37 // 1 inch in mm.
38 const float kInchInMm = 25.4f; 38 const float kInchInMm = 25.4f;
39 39
40 // Resolution list are sorted by the area in pixels and the larger 40 // Resolution list are sorted by the area in pixels and the larger
41 // one comes first. 41 // one comes first.
42 struct ResolutionSorter { 42 struct ResolutionSorter {
43 bool operator()(const Resolution& a, const Resolution& b) { 43 bool operator()(const Resolution& a, const Resolution& b) {
44 return a.size.width() * a.size.height() > b.size.width() * b.size.height(); 44 if (a.size.GetArea() == b.size.GetArea())
45 return (a.refresh_rate > b.refresh_rate);
46 return (a.size.GetArea() > b.size.GetArea());
45 } 47 }
46 }; 48 };
47 49
48 } // namespace 50 } // namespace
49 51
50 // static 52 // static
51 std::vector<Resolution> DisplayChangeObserver::GetResolutionList( 53 std::vector<Resolution> DisplayChangeObserver::GetResolutionList(
52 const OutputConfigurator::OutputSnapshot& output) { 54 const OutputConfigurator::OutputSnapshot& output) {
53 typedef std::map<std::pair<int,int>, Resolution> ResolutionMap; 55 typedef std::map<std::pair<int,int>, Resolution> ResolutionMap;
54 ResolutionMap resolution_map; 56 ResolutionMap resolution_map;
55 57
56 for (std::map<RRMode, OutputConfigurator::ModeInfo>::const_iterator it = 58 for (std::map<RRMode, OutputConfigurator::ModeInfo>::const_iterator it =
57 output.mode_infos.begin(); it != output.mode_infos.end(); ++it) { 59 output.mode_infos.begin(); it != output.mode_infos.end(); ++it) {
58 const OutputConfigurator::ModeInfo& mode_info = it->second; 60 const OutputConfigurator::ModeInfo& mode_info = it->second;
59 const std::pair<int, int> size(mode_info.width, mode_info.height); 61 const std::pair<int, int> size(mode_info.width, mode_info.height);
60 const Resolution resolution(gfx::Size(mode_info.width, mode_info.height), 62 const Resolution resolution(gfx::Size(mode_info.width, mode_info.height),
63 mode_info.refresh_rate,
61 mode_info.interlaced); 64 mode_info.interlaced);
62 65
63 // Add the resolution if it isn't already present and override interlaced 66 // Add the resolution if it isn't already present and override interlaced
64 // resolutions with non-interlaced ones. 67 // resolutions with non-interlaced ones.
65 ResolutionMap::iterator resolution_it = resolution_map.find(size); 68 ResolutionMap::iterator resolution_it = resolution_map.find(size);
66 if (resolution_it == resolution_map.end()) 69 if (resolution_it == resolution_map.end())
67 resolution_map.insert(std::make_pair(size, resolution)); 70 resolution_map.insert(std::make_pair(size, resolution));
68 else if (resolution_it->second.interlaced && !resolution.interlaced) 71 else if (resolution_it->second.interlaced && !resolution.interlaced)
69 resolution_it->second = resolution; 72 resolution_it->second = resolution;
70 } 73 }
(...skipping 26 matching lines...) Expand all
97 CHECK_EQ(2U, display_ids.size()); 100 CHECK_EQ(2U, display_ids.size());
98 DisplayIdPair pair = std::make_pair(display_ids[0], display_ids[1]); 101 DisplayIdPair pair = std::make_pair(display_ids[0], display_ids[1]);
99 DisplayLayout layout = Shell::GetInstance()->display_manager()-> 102 DisplayLayout layout = Shell::GetInstance()->display_manager()->
100 layout_store()->GetRegisteredDisplayLayout(pair); 103 layout_store()->GetRegisteredDisplayLayout(pair);
101 return layout.mirrored ? 104 return layout.mirrored ?
102 chromeos::STATE_DUAL_MIRROR : chromeos::STATE_DUAL_EXTENDED; 105 chromeos::STATE_DUAL_MIRROR : chromeos::STATE_DUAL_EXTENDED;
103 } 106 }
104 107
105 bool DisplayChangeObserver::GetResolutionForDisplayId(int64 display_id, 108 bool DisplayChangeObserver::GetResolutionForDisplayId(int64 display_id,
106 int* width, 109 int* width,
107 int* height) const { 110 int* height,
111 float* refresh_rate)
112 const {
108 gfx::Size resolution; 113 gfx::Size resolution;
109 if (!Shell::GetInstance()->display_manager()-> 114 if (!Shell::GetInstance()
110 GetSelectedResolutionForDisplayId(display_id, &resolution)) { 115 ->display_manager()
116 ->GetSelectedResolutionForDisplayId(
117 display_id, &resolution, refresh_rate)) {
111 return false; 118 return false;
112 } 119 }
113 120
114 *width = resolution.width(); 121 *width = resolution.width();
115 *height = resolution.height(); 122 *height = resolution.height();
116 return true; 123 return true;
117 } 124 }
118 125
119 void DisplayChangeObserver::OnDisplayModeChanged( 126 void DisplayChangeObserver::OnDisplayModeChanged(
120 const std::vector<OutputConfigurator::OutputSnapshot>& outputs) { 127 const std::vector<OutputConfigurator::OutputSnapshot>& outputs) {
(...skipping 17 matching lines...) Expand all
138 145
139 float device_scale_factor = 1.0f; 146 float device_scale_factor = 1.0f;
140 if (!ui::IsXDisplaySizeBlackListed(output.width_mm, output.height_mm) && 147 if (!ui::IsXDisplaySizeBlackListed(output.width_mm, output.height_mm) &&
141 (kInchInMm * mode_info->width / output.width_mm) > 148 (kInchInMm * mode_info->width / output.width_mm) >
142 kHighDensityDPIThreshold) { 149 kHighDensityDPIThreshold) {
143 device_scale_factor = 2.0f; 150 device_scale_factor = 2.0f;
144 } 151 }
145 gfx::Rect display_bounds( 152 gfx::Rect display_bounds(
146 output.x, output.y, mode_info->width, mode_info->height); 153 output.x, output.y, mode_info->width, mode_info->height);
147 154
148 std::vector<Resolution> resolutions; 155 std::vector<Resolution> resolutions = GetResolutionList(output);
149 if (output.type != chromeos::OUTPUT_TYPE_INTERNAL)
150 resolutions = GetResolutionList(output);
151 156
152 std::string name = output.type == chromeos::OUTPUT_TYPE_INTERNAL ? 157 std::string name = output.type == chromeos::OUTPUT_TYPE_INTERNAL ?
153 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) : 158 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) :
154 chromeos::GetDisplayName(output.output); 159 chromeos::GetDisplayName(output.output);
155 if (name.empty()) 160 if (name.empty())
156 name = l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); 161 name = l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME);
157 162
158 bool has_overscan = false; 163 bool has_overscan = false;
159 chromeos::GetOutputOverscanFlag(output.output, &has_overscan); 164 chromeos::GetOutputOverscanFlag(output.output, &has_overscan);
160 165
(...skipping 19 matching lines...) Expand all
180 void DisplayChangeObserver::OnAppTerminating() { 185 void DisplayChangeObserver::OnAppTerminating() {
181 #if defined(USE_ASH) 186 #if defined(USE_ASH)
182 // Stop handling display configuration events once the shutdown 187 // Stop handling display configuration events once the shutdown
183 // process starts. crbug.com/177014. 188 // process starts. crbug.com/177014.
184 Shell::GetInstance()->output_configurator()->Stop(); 189 Shell::GetInstance()->output_configurator()->Stop();
185 #endif 190 #endif
186 } 191 }
187 192
188 } // namespace internal 193 } // namespace internal
189 } // namespace ash 194 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698