| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <windows.h> | 7 #include <windows.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 ReleaseDC(NULL, screen_dc); | 26 ReleaseDC(NULL, screen_dc); |
| 27 if (!result) | 27 if (!result) |
| 28 return; | 28 return; |
| 29 std::string profile_data; | 29 std::string profile_data; |
| 30 if (!base::ReadFileToString(base::FilePath(path), &profile_data)) | 30 if (!base::ReadFileToString(base::FilePath(path), &profile_data)) |
| 31 return; | 31 return; |
| 32 size_t length = profile_data.size(); | 32 size_t length = profile_data.size(); |
| 33 profile->assign(profile_data.data(), profile_data.data() + length); | 33 profile->assign(profile_data.data(), profile_data.data() + length); |
| 34 } | 34 } |
| 35 | 35 |
| 36 base::LazyInstance<base::Lock> g_best_monitor_color_space_lock = | 36 base::LazyInstance<base::Lock>::DestructorAtExit |
| 37 LAZY_INSTANCE_INITIALIZER; | 37 g_best_monitor_color_space_lock = LAZY_INSTANCE_INITIALIZER; |
| 38 base::LazyInstance<gfx::ICCProfile> g_best_monitor_color_space = | 38 base::LazyInstance<gfx::ICCProfile>::DestructorAtExit |
| 39 LAZY_INSTANCE_INITIALIZER; | 39 g_best_monitor_color_space = LAZY_INSTANCE_INITIALIZER; |
| 40 bool g_has_initialized_best_monitor_color_space = false; | 40 bool g_has_initialized_best_monitor_color_space = false; |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 // static | 44 // static |
| 45 ICCProfile ICCProfile::FromBestMonitor() { | 45 ICCProfile ICCProfile::FromBestMonitor() { |
| 46 base::AutoLock lock(g_best_monitor_color_space_lock.Get()); | 46 base::AutoLock lock(g_best_monitor_color_space_lock.Get()); |
| 47 return g_best_monitor_color_space.Get(); | 47 return g_best_monitor_color_space.Get(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // static | 50 // static |
| 51 bool ICCProfile::CachedProfilesNeedUpdate() { | 51 bool ICCProfile::CachedProfilesNeedUpdate() { |
| 52 base::AutoLock lock(g_best_monitor_color_space_lock.Get()); | 52 base::AutoLock lock(g_best_monitor_color_space_lock.Get()); |
| 53 return !g_has_initialized_best_monitor_color_space; | 53 return !g_has_initialized_best_monitor_color_space; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| 57 void ICCProfile::UpdateCachedProfilesOnBackgroundThread() { | 57 void ICCProfile::UpdateCachedProfilesOnBackgroundThread() { |
| 58 std::vector<char> icc_profile; | 58 std::vector<char> icc_profile; |
| 59 ReadBestMonitorICCProfile(&icc_profile); | 59 ReadBestMonitorICCProfile(&icc_profile); |
| 60 gfx::ICCProfile color_space = FromData( | 60 gfx::ICCProfile color_space = FromData( |
| 61 icc_profile.data(), icc_profile.size()); | 61 icc_profile.data(), icc_profile.size()); |
| 62 | 62 |
| 63 base::AutoLock lock(g_best_monitor_color_space_lock.Get()); | 63 base::AutoLock lock(g_best_monitor_color_space_lock.Get()); |
| 64 g_best_monitor_color_space.Get() = color_space; | 64 g_best_monitor_color_space.Get() = color_space; |
| 65 g_has_initialized_best_monitor_color_space = true; | 65 g_has_initialized_best_monitor_color_space = true; |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace gfx | 68 } // namespace gfx |
| OLD | NEW |