| 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 |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "ui/display/util/edid_parser.h" | 12 #include "ui/display/util/edid_parser.h" |
| 13 #include "ui/gfx/x/x11_atom_cache.h" |
| 13 #include "ui/gfx/x/x11_types.h" | 14 #include "ui/gfx/x/x11_types.h" |
| 14 | 15 |
| 15 namespace display { | 16 namespace display { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 bool IsRandRAvailable() { | 20 bool IsRandRAvailable() { |
| 20 int randr_version_major = 0; | 21 int randr_version_major = 0; |
| 21 int randr_version_minor = 0; | 22 int randr_version_minor = 0; |
| 22 static bool is_randr_available = XRRQueryVersion( | 23 static bool is_randr_available = XRRQueryVersion( |
| 23 gfx::GetXDisplay(), &randr_version_major, &randr_version_minor); | 24 gfx::GetXDisplay(), &randr_version_major, &randr_version_minor); |
| 24 return is_randr_available; | 25 return is_randr_available; |
| 25 } | 26 } |
| 26 | 27 |
| 27 // Get the EDID data from the |output| and stores to |edid|. | 28 // Get the EDID data from the |output| and stores to |edid|. |
| 28 // Returns true if EDID property is successfully obtained. Otherwise returns | 29 // Returns true if EDID property is successfully obtained. Otherwise returns |
| 29 // false and does not touch |edid|. | 30 // false and does not touch |edid|. |
| 30 bool GetEDIDProperty(XID output, std::vector<uint8_t>* edid) { | 31 bool GetEDIDProperty(XID output, std::vector<uint8_t>* edid) { |
| 31 if (!IsRandRAvailable()) | 32 if (!IsRandRAvailable()) |
| 32 return false; | 33 return false; |
| 33 | 34 |
| 34 Display* display = gfx::GetXDisplay(); | 35 Display* display = gfx::GetXDisplay(); |
| 35 | 36 |
| 36 static Atom edid_property = XInternAtom( | 37 static Atom edid_property = |
| 37 gfx::GetXDisplay(), | 38 ui::X11AtomCache::GetInstance()->GetAtom(RR_PROPERTY_RANDR_EDID); |
| 38 RR_PROPERTY_RANDR_EDID, false); | |
| 39 | 39 |
| 40 bool has_edid_property = false; | 40 bool has_edid_property = false; |
| 41 int num_properties = 0; | 41 int num_properties = 0; |
| 42 gfx::XScopedPtr<Atom[]> properties( | 42 gfx::XScopedPtr<Atom[]> properties( |
| 43 XRRListOutputProperties(display, output, &num_properties)); | 43 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool EDIDParserX11::GetOutputOverscanFlag(bool* out_flag) const { | 102 bool EDIDParserX11::GetOutputOverscanFlag(bool* out_flag) const { |
| 103 if (edid_.empty()) | 103 if (edid_.empty()) |
| 104 return false; | 104 return false; |
| 105 | 105 |
| 106 return ParseOutputOverscanFlag(edid_, out_flag); | 106 return ParseOutputOverscanFlag(edid_, out_flag); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace display | 109 } // namespace display |
| OLD | NEW |