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