| 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 "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "ui/gfx/icc_profile.h" | 13 #include "ui/gfx/icc_profile.h" |
| 14 #include "ui/gfx/switches.h" | 14 #include "ui/gfx/switches.h" |
| 15 #include "ui/gfx/x/x11_types.h" | 15 #include "ui/gfx/x/x11_types.h" |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 | 18 |
| 19 // static | 19 // static |
| 20 ICCProfile ICCProfile::FromBestMonitor() { | 20 ICCProfile ICCProfile::FromBestMonitor() { |
| 21 if (HasForcedProfile()) |
| 22 return GetForcedProfile(); |
| 23 |
| 21 ICCProfile icc_profile; | 24 ICCProfile icc_profile; |
| 22 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless)) | 25 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless)) |
| 23 return icc_profile; | 26 return icc_profile; |
| 24 Atom property = XInternAtom(GetXDisplay(), "_ICC_PROFILE", true); | 27 Atom property = XInternAtom(GetXDisplay(), "_ICC_PROFILE", true); |
| 25 if (property != None) { | 28 if (property != None) { |
| 26 Atom prop_type = None; | 29 Atom prop_type = None; |
| 27 int prop_format = 0; | 30 int prop_format = 0; |
| 28 unsigned long nitems = 0; | 31 unsigned long nitems = 0; |
| 29 unsigned long nbytes = 0; | 32 unsigned long nbytes = 0; |
| 30 char* property_data = NULL; | 33 char* property_data = NULL; |
| 31 if (XGetWindowProperty( | 34 if (XGetWindowProperty( |
| 32 GetXDisplay(), DefaultRootWindow(GetXDisplay()), property, 0, | 35 GetXDisplay(), DefaultRootWindow(GetXDisplay()), property, 0, |
| 33 0x1FFFFFFF /* MAXINT32 / 4 */, False, AnyPropertyType, &prop_type, | 36 0x1FFFFFFF /* MAXINT32 / 4 */, False, AnyPropertyType, &prop_type, |
| 34 &prop_format, &nitems, &nbytes, | 37 &prop_format, &nitems, &nbytes, |
| 35 reinterpret_cast<unsigned char**>(&property_data)) == Success) { | 38 reinterpret_cast<unsigned char**>(&property_data)) == Success) { |
| 36 icc_profile = FromData(property_data, nitems); | 39 icc_profile = FromData(property_data, nitems); |
| 37 XFree(property_data); | 40 XFree(property_data); |
| 38 } | 41 } |
| 39 } | 42 } |
| 40 return icc_profile; | 43 return icc_profile; |
| 41 } | 44 } |
| 42 | 45 |
| 43 } // namespace gfx | 46 } // namespace gfx |
| OLD | NEW |