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

Side by Side Diff: ui/display/chromeos/display_util.cc

Issue 788423002: Add display task to trigger display configuration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async-refactor3
Patch Set: Remove include in favour of forward declare Created 6 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/display/chromeos/display_util.h"
6
7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h"
9 #include "ui/display/types/display_snapshot.h"
10
11 namespace ui {
12
13 std::string DisplayPowerStateToString(chromeos::DisplayPowerState state) {
14 switch (state) {
15 case chromeos::DISPLAY_POWER_ALL_ON:
16 return "ALL_ON";
17 case chromeos::DISPLAY_POWER_ALL_OFF:
18 return "ALL_OFF";
19 case chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON:
20 return "INTERNAL_OFF_EXTERNAL_ON";
21 case chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF:
22 return "INTERNAL_ON_EXTERNAL_OFF";
23 default:
24 return "unknown (" + base::IntToString(state) + ")";
25 }
26 }
27
28 std::string MultipleDisplayStateToString(MultipleDisplayState state) {
29 switch (state) {
30 case MULTIPLE_DISPLAY_STATE_INVALID:
31 return "INVALID";
32 case MULTIPLE_DISPLAY_STATE_HEADLESS:
33 return "HEADLESS";
34 case MULTIPLE_DISPLAY_STATE_SINGLE:
35 return "SINGLE";
36 case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR:
37 return "DUAL_MIRROR";
38 case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED:
39 return "DUAL_EXTENDED";
40 case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED:
41 return "MULTI_EXTENDED";
42 }
43 NOTREACHED() << "Unknown state " << state;
44 return "INVALID";
45 }
46
47 int GetDisplayPower(
48 const std::vector<DisplayConfigurator::DisplayState>& display_states,
49 chromeos::DisplayPowerState state,
50 std::vector<bool>* display_power) {
51 int num_on_displays = 0;
52 if (display_power)
53 display_power->resize(display_states.size());
54
55 for (size_t i = 0; i < display_states.size(); ++i) {
56 bool internal =
57 display_states[i].display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL;
58 bool on =
59 state == chromeos::DISPLAY_POWER_ALL_ON ||
60 (state == chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON &&
61 !internal) ||
62 (state == chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF && internal);
63 if (display_power)
64 (*display_power)[i] = on;
65 if (on)
66 num_on_displays++;
67 }
68 return num_on_displays;
69 }
70
71 } // namespace ui
OLDNEW
« no previous file with comments | « ui/display/chromeos/display_util.h ('k') | ui/display/chromeos/test/test_native_display_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698