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

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

Issue 226183004: Renamed OutputConfigurator to DisplayConfigurator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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>
11 11
12 #include "ash/ash_switches.h" 12 #include "ash/ash_switches.h"
13 #include "ash/display/display_info.h" 13 #include "ash/display/display_info.h"
14 #include "ash/display/display_layout_store.h" 14 #include "ash/display/display_layout_store.h"
15 #include "ash/display/display_manager.h" 15 #include "ash/display/display_manager.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "grit/ash_strings.h" 19 #include "grit/ash_strings.h"
20 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/x/x11_util.h" 21 #include "ui/base/x/x11_util.h"
22 #include "ui/compositor/dip_util.h" 22 #include "ui/compositor/dip_util.h"
23 #include "ui/display/chromeos/display_mode.h" 23 #include "ui/display/chromeos/display_mode.h"
24 #include "ui/display/chromeos/display_snapshot.h" 24 #include "ui/display/chromeos/display_snapshot.h"
25 #include "ui/gfx/display.h" 25 #include "ui/gfx/display.h"
26 26
27 namespace ash { 27 namespace ash {
28 28
29 using ui::OutputConfigurator; 29 using ui::DisplayConfigurator;
30 30
31 namespace { 31 namespace {
32 32
33 // The DPI threshold to detect high density screen. 33 // The DPI threshold to detect high density screen.
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 = 170; 35 const unsigned int kHighDensityDPIThreshold = 170;
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 // Display mode list is sorted by (in descending priority): 40 // Display mode list is sorted by (in descending priority):
41 // * the area in pixels. 41 // * the area in pixels.
42 // * refresh rate. 42 // * refresh rate.
43 struct DisplayModeSorter { 43 struct DisplayModeSorter {
44 bool operator()(const DisplayMode& a, const DisplayMode& b) { 44 bool operator()(const DisplayMode& a, const DisplayMode& b) {
45 if (a.size.GetArea() == b.size.GetArea()) 45 if (a.size.GetArea() == b.size.GetArea())
46 return (a.refresh_rate > b.refresh_rate); 46 return (a.refresh_rate > b.refresh_rate);
47 return (a.size.GetArea() > b.size.GetArea()); 47 return (a.size.GetArea() > b.size.GetArea());
48 } 48 }
49 }; 49 };
50 50
51 } // namespace 51 } // namespace
52 52
53 // static 53 // static
54 std::vector<DisplayMode> DisplayChangeObserver::GetDisplayModeList( 54 std::vector<DisplayMode> DisplayChangeObserver::GetDisplayModeList(
55 const OutputConfigurator::DisplayState& output) { 55 const DisplayConfigurator::DisplayState& output) {
56 typedef std::map<std::pair<int, int>, DisplayMode> DisplayModeMap; 56 typedef std::map<std::pair<int, int>, DisplayMode> DisplayModeMap;
57 DisplayModeMap display_mode_map; 57 DisplayModeMap display_mode_map;
58 58
59 for (std::vector<const ui::DisplayMode*>::const_iterator it = 59 for (std::vector<const ui::DisplayMode*>::const_iterator it =
60 output.display->modes().begin(); 60 output.display->modes().begin();
61 it != output.display->modes().end(); 61 it != output.display->modes().end();
62 ++it) { 62 ++it) {
63 const ui::DisplayMode& mode_info = **it; 63 const ui::DisplayMode& mode_info = **it;
64 const std::pair<int, int> size(mode_info.size().width(), 64 const std::pair<int, int> size(mode_info.size().width(),
65 mode_info.size().height()); 65 mode_info.size().height());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 DisplayMode mode; 111 DisplayMode mode;
112 if (!Shell::GetInstance()->display_manager()->GetSelectedModeForDisplayId( 112 if (!Shell::GetInstance()->display_manager()->GetSelectedModeForDisplayId(
113 display_id, &mode)) 113 display_id, &mode))
114 return false; 114 return false;
115 115
116 *size = mode.size; 116 *size = mode.size;
117 return true; 117 return true;
118 } 118 }
119 119
120 void DisplayChangeObserver::OnDisplayModeChanged( 120 void DisplayChangeObserver::OnDisplayModeChanged(
121 const std::vector<OutputConfigurator::DisplayState>& outputs) { 121 const std::vector<DisplayConfigurator::DisplayState>& outputs) {
122 std::vector<DisplayInfo> displays; 122 std::vector<DisplayInfo> displays;
123 std::set<int64> ids; 123 std::set<int64> ids;
124 for (size_t i = 0; i < outputs.size(); ++i) { 124 for (size_t i = 0; i < outputs.size(); ++i) {
125 const OutputConfigurator::DisplayState& output = outputs[i]; 125 const DisplayConfigurator::DisplayState& output = outputs[i];
126 126
127 if (output.display->type() == ui::OUTPUT_TYPE_INTERNAL && 127 if (output.display->type() == ui::OUTPUT_TYPE_INTERNAL &&
128 gfx::Display::InternalDisplayId() == gfx::Display::kInvalidDisplayID) { 128 gfx::Display::InternalDisplayId() == gfx::Display::kInvalidDisplayID) {
129 gfx::Display::SetInternalDisplayId(output.display->display_id()); 129 gfx::Display::SetInternalDisplayId(output.display->display_id());
130 } 130 }
131 131
132 const ui::DisplayMode* mode_info = output.display->current_mode(); 132 const ui::DisplayMode* mode_info = output.display->current_mode();
133 if (!mode_info) 133 if (!mode_info)
134 continue; 134 continue;
135 135
(...skipping 23 matching lines...) Expand all
159 displays.push_back(DisplayInfo(id, name, has_overscan)); 159 displays.push_back(DisplayInfo(id, name, has_overscan));
160 DisplayInfo& new_info = displays.back(); 160 DisplayInfo& new_info = displays.back();
161 new_info.set_device_scale_factor(device_scale_factor); 161 new_info.set_device_scale_factor(device_scale_factor);
162 new_info.SetBounds(display_bounds); 162 new_info.SetBounds(display_bounds);
163 new_info.set_native(true); 163 new_info.set_native(true);
164 new_info.set_display_modes(display_modes); 164 new_info.set_display_modes(display_modes);
165 new_info.set_touch_support( 165 new_info.set_touch_support(
166 output.touch_device_id == 0 ? gfx::Display::TOUCH_SUPPORT_UNAVAILABLE : 166 output.touch_device_id == 0 ? gfx::Display::TOUCH_SUPPORT_UNAVAILABLE :
167 gfx::Display::TOUCH_SUPPORT_AVAILABLE); 167 gfx::Display::TOUCH_SUPPORT_AVAILABLE);
168 new_info.set_available_color_profiles( 168 new_info.set_available_color_profiles(
169 Shell::GetInstance()->output_configurator()-> 169 Shell::GetInstance()
170 GetAvailableColorCalibrationProfiles(id)); 170 ->display_configurator()
171 ->GetAvailableColorCalibrationProfiles(id));
171 } 172 }
172 173
173 // DisplayManager can be null during the boot. 174 // DisplayManager can be null during the boot.
174 Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays); 175 Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays);
175 } 176 }
176 177
177 void DisplayChangeObserver::OnAppTerminating() { 178 void DisplayChangeObserver::OnAppTerminating() {
178 #if defined(USE_ASH) 179 #if defined(USE_ASH)
179 // Stop handling display configuration events once the shutdown 180 // Stop handling display configuration events once the shutdown
180 // process starts. crbug.com/177014. 181 // process starts. crbug.com/177014.
181 Shell::GetInstance()->output_configurator()->PrepareForExit(); 182 Shell::GetInstance()->display_configurator()->PrepareForExit();
182 #endif 183 #endif
183 } 184 }
184 185
185 } // namespace ash 186 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698