OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 extern "C" { | 7 extern "C" { |
8 #include <X11/Xatom.h> | 8 #include <X11/Xatom.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 } | 10 } |
11 | 11 |
12 #include "ui/gfx/color_space.h" | 12 #include "ui/gfx/color_space.h" |
13 | 13 |
14 #include "ui/gfx/x/x11_types.h" | 14 #include "ui/gfx/x/x11_types.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 | 17 |
18 // static | 18 // static |
19 ColorSpace ColorSpace::FromBestMonitor() { | 19 ColorSpace ColorSpace::FromBestMonitor() { |
| 20 ColorSpace color_space; |
20 Atom property = XInternAtom(GetXDisplay(), "_ICC_PROFILE", true); | 21 Atom property = XInternAtom(GetXDisplay(), "_ICC_PROFILE", true); |
21 if (property != None) { | 22 if (property != None) { |
22 Atom prop_type = None; | 23 Atom prop_type = None; |
23 int prop_format = 0; | 24 int prop_format = 0; |
24 unsigned long nitems = 0; | 25 unsigned long nitems = 0; |
25 unsigned long nbytes = 0; | 26 unsigned long nbytes = 0; |
26 char* property_data = NULL; | 27 char* property_data = NULL; |
27 if (XGetWindowProperty( | 28 if (XGetWindowProperty( |
28 GetXDisplay(), DefaultRootWindow(GetXDisplay()), property, 0, | 29 GetXDisplay(), DefaultRootWindow(GetXDisplay()), property, 0, |
29 0x1FFFFFFF /* MAXINT32 / 4 */, False, AnyPropertyType, &prop_type, | 30 0x1FFFFFFF /* MAXINT32 / 4 */, False, AnyPropertyType, &prop_type, |
30 &prop_format, &nitems, &nbytes, | 31 &prop_format, &nitems, &nbytes, |
31 reinterpret_cast<unsigned char**>(&property_data)) == Success) { | 32 reinterpret_cast<unsigned char**>(&property_data)) == Success) { |
32 std::vector<char> icc_profile; | 33 color_space.icc_profile_.assign(property_data, property_data + nitems); |
33 icc_profile.assign(property_data, property_data + nitems); | |
34 XFree(property_data); | 34 XFree(property_data); |
35 return FromICCProfile(icc_profile); | |
36 } | 35 } |
37 } | 36 } |
38 return ColorSpace(); | 37 return color_space; |
39 } | 38 } |
40 | 39 |
41 } // namespace gfx | 40 } // namespace gfx |
OLD | NEW |