Correctly track texture cleared state for sharing
[chromium-blink-merge.git] / ui / display / chromeos / display_util.cc
blob212144cf20740c297d7d081a20cddd4bbc0c5934
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.
5 #include "ui/display/chromeos/display_util.h"
7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h"
9 #include "ui/display/types/display_snapshot.h"
11 namespace ui {
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) + ")";
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";
43 NOTREACHED() << "Unknown state " << state;
44 return "INVALID";
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());
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++;
68 return num_on_displays;
71 } // namespace ui