| OLD | NEW |
| 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 #include "ui/display/util/x11/edid_parser_x11.h" | 5 #include "ui/display/util/x11/edid_parser_x11.h" |
| 6 | 6 |
| 7 #include <X11/extensions/Xrandr.h> | 7 #include <X11/extensions/Xrandr.h> |
| 8 #include <X11/Xatom.h> | 8 #include <X11/Xatom.h> |
| 9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 XFree(properties); | 49 XFree(properties); |
| 50 if (!has_edid_property) | 50 if (!has_edid_property) |
| 51 return false; | 51 return false; |
| 52 | 52 |
| 53 Atom actual_type; | 53 Atom actual_type; |
| 54 int actual_format; | 54 int actual_format; |
| 55 unsigned long bytes_after; | 55 unsigned long bytes_after; |
| 56 unsigned long nitems = 0; | 56 unsigned long nitems = 0; |
| 57 unsigned char* prop = NULL; | 57 unsigned char* prop = nullptr; |
| 58 XRRGetOutputProperty(display, | 58 XRRGetOutputProperty(display, |
| 59 output, | 59 output, |
| 60 edid_property, | 60 edid_property, |
| 61 0, // offset | 61 0, // offset |
| 62 128, // length | 62 128, // length |
| 63 false, // _delete | 63 false, // _delete |
| 64 false, // pending | 64 false, // pending |
| 65 AnyPropertyType, // req_type | 65 AnyPropertyType, // req_type |
| 66 &actual_type, | 66 &actual_type, |
| 67 &actual_format, | 67 &actual_format, |
| 68 &nitems, | 68 &nitems, |
| 69 &bytes_after, | 69 &bytes_after, |
| 70 &prop); | 70 &prop); |
| 71 DCHECK_EQ(XA_INTEGER, actual_type); | 71 DCHECK_EQ(XA_INTEGER, actual_type); |
| 72 DCHECK_EQ(8, actual_format); | 72 DCHECK_EQ(8, actual_format); |
| 73 edid->assign(prop, prop + nitems); | 73 edid->assign(prop, prop + nitems); |
| 74 XFree(prop); | 74 XFree(prop); |
| 75 return true; | 75 return true; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Gets some useful data from the specified output device, such like | 78 // Gets some useful data from the specified output device, such like |
| 79 // manufacturer's ID, product code, and human readable name. Returns false if it | 79 // manufacturer's ID, product code, and human readable name. Returns false if it |
| 80 // fails to get those data and doesn't touch manufacturer ID/product code/name. | 80 // fails to get those data and doesn't touch manufacturer ID/product code/name. |
| 81 // NULL can be passed for unwanted output parameters. | 81 // nullptr can be passed for unwanted output parameters. |
| 82 bool GetOutputDeviceData(XID output, | 82 bool GetOutputDeviceData(XID output, |
| 83 uint16_t* manufacturer_id, | 83 uint16_t* manufacturer_id, |
| 84 std::string* human_readable_name) { | 84 std::string* human_readable_name) { |
| 85 std::vector<uint8_t> edid; | 85 std::vector<uint8_t> edid; |
| 86 if (!GetEDIDProperty(output, &edid)) | 86 if (!GetEDIDProperty(output, &edid)) |
| 87 return false; | 87 return false; |
| 88 | 88 |
| 89 bool result = ParseOutputDeviceData( | 89 return ParseOutputDeviceData(edid, manufacturer_id, human_readable_name, |
| 90 edid, manufacturer_id, human_readable_name); | 90 nullptr, nullptr); |
| 91 return result; | |
| 92 } | 91 } |
| 93 | 92 |
| 94 } // namespace | 93 } // namespace |
| 95 | 94 |
| 96 bool GetDisplayId(XID output_id, | 95 bool GetDisplayId(XID output_id, |
| 97 uint8_t output_index, | 96 uint8_t output_index, |
| 98 int64_t* display_id_out) { | 97 int64_t* display_id_out) { |
| 99 std::vector<uint8_t> edid; | 98 std::vector<uint8_t> edid; |
| 100 if (!GetEDIDProperty(output_id, &edid)) | 99 if (!GetEDIDProperty(output_id, &edid)) |
| 101 return false; | 100 return false; |
| 102 | 101 |
| 103 bool result = GetDisplayIdFromEDID(edid, output_index, display_id_out); | 102 bool result = GetDisplayIdFromEDID(edid, output_index, display_id_out); |
| 104 return result; | 103 return result; |
| 105 } | 104 } |
| 106 | 105 |
| 107 std::string GetDisplayName(RROutput output) { | 106 std::string GetDisplayName(RROutput output) { |
| 108 std::string display_name; | 107 std::string display_name; |
| 109 GetOutputDeviceData(output, NULL, &display_name); | 108 GetOutputDeviceData(output, nullptr, &display_name); |
| 110 return display_name; | 109 return display_name; |
| 111 } | 110 } |
| 112 | 111 |
| 113 bool GetOutputOverscanFlag(RROutput output, bool* flag) { | 112 bool GetOutputOverscanFlag(RROutput output, bool* flag) { |
| 114 std::vector<uint8_t> edid; | 113 std::vector<uint8_t> edid; |
| 115 if (!GetEDIDProperty(output, &edid)) | 114 if (!GetEDIDProperty(output, &edid)) |
| 116 return false; | 115 return false; |
| 117 | 116 |
| 118 bool found = ParseOutputOverscanFlag(edid, flag); | 117 bool found = ParseOutputOverscanFlag(edid, flag); |
| 119 return found; | 118 return found; |
| 120 } | 119 } |
| 121 | 120 |
| 122 } // namespace ui | 121 } // namespace ui |
| OLD | NEW |