| OLD | NEW |
| (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 <stddef.h> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "base/strings/string_number_conversions.h" | |
| 11 #include "base/strings/stringprintf.h" | |
| 12 #include "ui/display/types/display_snapshot.h" | |
| 13 | |
| 14 namespace ui { | |
| 15 | |
| 16 std::string DisplayPowerStateToString(chromeos::DisplayPowerState state) { | |
| 17 switch (state) { | |
| 18 case chromeos::DISPLAY_POWER_ALL_ON: | |
| 19 return "ALL_ON"; | |
| 20 case chromeos::DISPLAY_POWER_ALL_OFF: | |
| 21 return "ALL_OFF"; | |
| 22 case chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON: | |
| 23 return "INTERNAL_OFF_EXTERNAL_ON"; | |
| 24 case chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF: | |
| 25 return "INTERNAL_ON_EXTERNAL_OFF"; | |
| 26 default: | |
| 27 return "unknown (" + base::IntToString(state) + ")"; | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 std::string MultipleDisplayStateToString(MultipleDisplayState state) { | |
| 32 switch (state) { | |
| 33 case MULTIPLE_DISPLAY_STATE_INVALID: | |
| 34 return "INVALID"; | |
| 35 case MULTIPLE_DISPLAY_STATE_HEADLESS: | |
| 36 return "HEADLESS"; | |
| 37 case MULTIPLE_DISPLAY_STATE_SINGLE: | |
| 38 return "SINGLE"; | |
| 39 case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR: | |
| 40 return "DUAL_MIRROR"; | |
| 41 case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED: | |
| 42 return "DUAL_EXTENDED"; | |
| 43 case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED: | |
| 44 return "MULTI_EXTENDED"; | |
| 45 } | |
| 46 NOTREACHED() << "Unknown state " << state; | |
| 47 return "INVALID"; | |
| 48 } | |
| 49 | |
| 50 int GetDisplayPower(const std::vector<DisplaySnapshot*>& displays, | |
| 51 chromeos::DisplayPowerState state, | |
| 52 std::vector<bool>* display_power) { | |
| 53 int num_on_displays = 0; | |
| 54 if (display_power) | |
| 55 display_power->resize(displays.size()); | |
| 56 | |
| 57 for (size_t i = 0; i < displays.size(); ++i) { | |
| 58 bool internal = displays[i]->type() == DISPLAY_CONNECTION_TYPE_INTERNAL; | |
| 59 bool on = | |
| 60 displays[i]->type() == DISPLAY_CONNECTION_TYPE_VIRTUAL || | |
| 61 state == chromeos::DISPLAY_POWER_ALL_ON || | |
| 62 (state == chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON && | |
| 63 !internal) || | |
| 64 (state == chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF && internal); | |
| 65 if (display_power) | |
| 66 (*display_power)[i] = on; | |
| 67 if (on) | |
| 68 num_on_displays++; | |
| 69 } | |
| 70 return num_on_displays; | |
| 71 } | |
| 72 | |
| 73 bool IsPhysicalDisplayType(ui::DisplayConnectionType type) { | |
| 74 return !(type & | |
| 75 (DISPLAY_CONNECTION_TYPE_NETWORK | DISPLAY_CONNECTION_TYPE_VIRTUAL)); | |
| 76 } | |
| 77 | |
| 78 } // namespace ui | |
| OLD | NEW |