| 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/gfx/icc_profile.h" | 5 #include "ui/gfx/icc_profile.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #include "base/mac/scoped_cftyperef.h" | 8 #include "base/mac/scoped_cftyperef.h" |
| 9 | 9 |
| 10 namespace gfx { | 10 namespace gfx { |
| 11 | 11 |
| 12 // static | 12 // static |
| 13 ICCProfile ICCProfile::FromBestMonitor() { | 13 ICCProfile ICCProfile::FromBestMonitor() { |
| 14 return FromCGColorSpace(base::mac::GetSystemColorSpace()); | 14 return FromCGColorSpace(base::mac::GetSystemColorSpace()); |
| 15 } | 15 } |
| 16 | 16 |
| 17 // static | 17 // static |
| 18 ICCProfile ICCProfile::FromCGColorSpace(CGColorSpaceRef cg_color_space) { | 18 ICCProfile ICCProfile::FromCGColorSpace(CGColorSpaceRef cg_color_space) { |
| 19 if (HasForcedProfile()) |
| 20 return GetForcedProfile(); |
| 21 |
| 19 base::ScopedCFTypeRef<CFDataRef> cf_icc_profile( | 22 base::ScopedCFTypeRef<CFDataRef> cf_icc_profile( |
| 20 CGColorSpaceCopyICCProfile(cg_color_space)); | 23 CGColorSpaceCopyICCProfile(cg_color_space)); |
| 21 if (!cf_icc_profile) | 24 if (!cf_icc_profile) |
| 22 return gfx::ICCProfile(); | 25 return gfx::ICCProfile(); |
| 23 size_t length = CFDataGetLength(cf_icc_profile); | 26 size_t length = CFDataGetLength(cf_icc_profile); |
| 24 const unsigned char* data = CFDataGetBytePtr(cf_icc_profile); | 27 const unsigned char* data = CFDataGetBytePtr(cf_icc_profile); |
| 25 std::vector<char> vector_icc_profile; | 28 std::vector<char> vector_icc_profile; |
| 26 vector_icc_profile.assign(data, data + length); | 29 vector_icc_profile.assign(data, data + length); |
| 27 return FromData(vector_icc_profile.data(), vector_icc_profile.size()); | 30 return FromData(vector_icc_profile.data(), vector_icc_profile.size()); |
| 28 } | 31 } |
| 29 | 32 |
| 30 } // namespace gfx | 33 } // namespace gfx |
| OLD | NEW |