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/x11/edid_parser_x11.h" | 5 #include "ui/display/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 |
11 #include "base/message_loop/message_loop.h" | |
12 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
13 #include "ui/display/edid_parser.h" | 12 #include "ui/display/edid_parser.h" |
| 13 #include "ui/gfx/x/x11_types.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 bool IsRandRAvailable() { | 19 bool IsRandRAvailable() { |
20 int randr_version_major = 0; | 20 int randr_version_major = 0; |
21 int randr_version_minor = 0; | 21 int randr_version_minor = 0; |
22 static bool is_randr_available = XRRQueryVersion( | 22 static bool is_randr_available = XRRQueryVersion( |
23 base::MessagePumpX11::GetDefaultXDisplay(), | 23 gfx::GetXDisplay(), |
24 &randr_version_major, &randr_version_minor); | 24 &randr_version_major, &randr_version_minor); |
25 return is_randr_available; | 25 return is_randr_available; |
26 } | 26 } |
27 | 27 |
28 // Get the EDID data from the |output| and stores to |edid|. | 28 // Get the EDID data from the |output| and stores to |edid|. |
29 // Returns true if EDID property is successfully obtained. Otherwise returns | 29 // Returns true if EDID property is successfully obtained. Otherwise returns |
30 // false and does not touch |edid|. | 30 // false and does not touch |edid|. |
31 bool GetEDIDProperty(XID output, std::vector<uint8_t>* edid) { | 31 bool GetEDIDProperty(XID output, std::vector<uint8_t>* edid) { |
32 if (!IsRandRAvailable()) | 32 if (!IsRandRAvailable()) |
33 return false; | 33 return false; |
34 | 34 |
35 Display* display = base::MessagePumpX11::GetDefaultXDisplay(); | 35 Display* display = gfx::GetXDisplay(); |
36 | 36 |
37 static Atom edid_property = XInternAtom( | 37 static Atom edid_property = XInternAtom( |
38 base::MessagePumpX11::GetDefaultXDisplay(), | 38 gfx::GetXDisplay(), |
39 RR_PROPERTY_RANDR_EDID, false); | 39 RR_PROPERTY_RANDR_EDID, false); |
40 | 40 |
41 bool has_edid_property = false; | 41 bool has_edid_property = false; |
42 int num_properties = 0; | 42 int num_properties = 0; |
43 Atom* properties = XRRListOutputProperties(display, output, &num_properties); | 43 Atom* properties = XRRListOutputProperties(display, output, &num_properties); |
44 for (int i = 0; i < num_properties; ++i) { | 44 for (int i = 0; i < num_properties; ++i) { |
45 if (properties[i] == edid_property) { | 45 if (properties[i] == edid_property) { |
46 has_edid_property = true; | 46 has_edid_property = true; |
47 break; | 47 break; |
48 } | 48 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 bool GetOutputOverscanFlag(RROutput output, bool* flag) { | 114 bool GetOutputOverscanFlag(RROutput output, bool* flag) { |
115 std::vector<uint8_t> edid; | 115 std::vector<uint8_t> edid; |
116 if (!GetEDIDProperty(output, &edid)) | 116 if (!GetEDIDProperty(output, &edid)) |
117 return false; | 117 return false; |
118 | 118 |
119 bool found = ParseOutputOverscanFlag(edid, flag); | 119 bool found = ParseOutputOverscanFlag(edid, flag); |
120 return found; | 120 return found; |
121 } | 121 } |
122 | 122 |
123 } // namespace ui | 123 } // namespace ui |
OLD | NEW |