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

Side by Side Diff: ui/display/chromeos/display_configurator.h

Issue 972153004: Make ui::DisplayConfigurator a singleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make a Singleton Created 5 years, 9 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 #ifndef UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ 5 #ifndef UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_
6 #define UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ 6 #define UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/event_types.h" 14 #include "base/event_types.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/singleton.h"
16 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h" 18 #include "base/observer_list.h"
18 #include "base/timer/timer.h" 19 #include "base/timer/timer.h"
19 #include "third_party/cros_system_api/dbus/service_constants.h" 20 #include "third_party/cros_system_api/dbus/service_constants.h"
20 #include "ui/display/display_export.h" 21 #include "ui/display/display_export.h"
21 #include "ui/display/types/display_constants.h" 22 #include "ui/display/types/display_constants.h"
22 #include "ui/display/types/native_display_observer.h" 23 #include "ui/display/types/native_display_observer.h"
23 #include "ui/gfx/geometry/size.h" 24 #include "ui/gfx/geometry/size.h"
24 25
25 namespace gfx { 26 namespace gfx {
26 class Point; 27 class Point;
27 class Size; 28 class Size;
28 } 29 }
29 30
30 namespace ui { 31 namespace ui {
31 struct DisplayConfigureRequest; 32 struct DisplayConfigureRequest;
32 class DisplayMode; 33 class DisplayMode;
33 class DisplaySnapshot; 34 class DisplaySnapshot;
34 class NativeDisplayDelegate; 35 class NativeDisplayDelegate;
35 class UpdateDisplayConfigurationTask; 36 class UpdateDisplayConfigurationTask;
36 37
38 namespace test {
39 class DisplayConfiguratorTest;
40 } // namespace test
41
37 // This class interacts directly with the system display configurator. 42 // This class interacts directly with the system display configurator.
38 class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { 43 class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
39 public: 44 public:
40 typedef uint64_t ContentProtectionClientId; 45 typedef uint64_t ContentProtectionClientId;
41 static const ContentProtectionClientId kInvalidClientId = 0; 46 static const ContentProtectionClientId kInvalidClientId = 0;
42 47
43 typedef base::Callback<void(bool)> ConfigurationCallback; 48 typedef base::Callback<void(bool)> ConfigurationCallback;
44 49
45 struct DisplayState { 50 struct DisplayState {
46 DisplayState(); 51 DisplayState();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // need to use for the DPI calculation. 173 // need to use for the DPI calculation.
169 // See crbug.com/130188 for initial discussion. 174 // See crbug.com/130188 for initial discussion.
170 static const int kVerticalGap = 60; 175 static const int kVerticalGap = 60;
171 176
172 // Returns the mode within |display| that matches the given size with highest 177 // Returns the mode within |display| that matches the given size with highest
173 // refresh rate. Returns None if no matching display was found. 178 // refresh rate. Returns None if no matching display was found.
174 static const DisplayMode* FindDisplayModeMatchingSize( 179 static const DisplayMode* FindDisplayModeMatchingSize(
175 const DisplaySnapshot& display, 180 const DisplaySnapshot& display,
176 const gfx::Size& size); 181 const gfx::Size& size);
177 182
178 DisplayConfigurator();
179 ~DisplayConfigurator() override;
180
181 MultipleDisplayState display_state() const { return current_display_state_; } 183 MultipleDisplayState display_state() const { return current_display_state_; }
182 chromeos::DisplayPowerState requested_power_state() const { 184 chromeos::DisplayPowerState requested_power_state() const {
183 return requested_power_state_; 185 return requested_power_state_;
184 } 186 }
185 const gfx::Size framebuffer_size() const { return framebuffer_size_; } 187 const gfx::Size framebuffer_size() const { return framebuffer_size_; }
186 const std::vector<DisplayState>& cached_displays() const { 188 const std::vector<DisplayState>& cached_displays() const {
187 return cached_displays_; 189 return cached_displays_;
188 } 190 }
189 191
190 // Called when an external process no longer needs to control the display 192 // Called when an external process no longer needs to control the display
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 282
281 // Checks the available color profiles for |display_id| and fills the result 283 // Checks the available color profiles for |display_id| and fills the result
282 // into |profiles|. 284 // into |profiles|.
283 std::vector<ui::ColorCalibrationProfile> GetAvailableColorCalibrationProfiles( 285 std::vector<ui::ColorCalibrationProfile> GetAvailableColorCalibrationProfiles(
284 int64_t display_id); 286 int64_t display_id);
285 287
286 // Updates the color calibration to |new_profile|. 288 // Updates the color calibration to |new_profile|.
287 bool SetColorCalibrationProfile(int64_t display_id, 289 bool SetColorCalibrationProfile(int64_t display_id,
288 ui::ColorCalibrationProfile new_profile); 290 ui::ColorCalibrationProfile new_profile);
289 291
292 // static
293 static DisplayConfigurator* GetInstance();
294
290 private: 295 private:
296 friend struct DefaultSingletonTraits<DisplayConfigurator>;
297 friend class ui::test::DisplayConfiguratorTest;
291 class DisplayLayoutManagerImpl; 298 class DisplayLayoutManagerImpl;
292 299
300 DisplayConfigurator();
301 ~DisplayConfigurator() override;
302
293 // Mapping a display_id to a protection request bitmask. 303 // Mapping a display_id to a protection request bitmask.
294 typedef std::map<int64_t, uint32_t> ContentProtections; 304 typedef std::map<int64_t, uint32_t> ContentProtections;
295 // Mapping a client to its protection request. 305 // Mapping a client to its protection request.
296 typedef std::map<ContentProtectionClientId, ContentProtections> 306 typedef std::map<ContentProtectionClientId, ContentProtections>
297 ProtectionRequests; 307 ProtectionRequests;
298 308
299 // Performs platform specific delegate initialization. 309 // Performs platform specific delegate initialization.
300 scoped_ptr<NativeDisplayDelegate> CreatePlatformNativeDisplayDelegate(); 310 scoped_ptr<NativeDisplayDelegate> CreatePlatformNativeDisplayDelegate();
301 311
302 // Configures displays. Invoked by |configure_timer_|. 312 // Configures displays. Invoked by |configure_timer_|.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 435
426 // This must be the last variable. 436 // This must be the last variable.
427 base::WeakPtrFactory<DisplayConfigurator> weak_ptr_factory_; 437 base::WeakPtrFactory<DisplayConfigurator> weak_ptr_factory_;
428 438
429 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator); 439 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator);
430 }; 440 };
431 441
432 } // namespace ui 442 } // namespace ui
433 443
434 #endif // UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ 444 #endif // UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_
OLDNEW
« no previous file with comments | « extensions/shell/browser/shell_desktop_controller_aura.cc ('k') | ui/display/chromeos/display_configurator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698