| 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 "ui/gfx/icc_profile.h" | 5 #include "ui/gfx/icc_profile.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/containers/mru_cache.h" | 9 #include "base/containers/mru_cache.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // TODO(ccameron): Support constructing ICC profiles from arbitrary ColorSpace | 96 // TODO(ccameron): Support constructing ICC profiles from arbitrary ColorSpace |
| 97 // objects. | 97 // objects. |
| 98 return ICCProfile(); | 98 return ICCProfile(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 const std::vector<char>& ICCProfile::GetData() const { | 101 const std::vector<char>& ICCProfile::GetData() const { |
| 102 return data_; | 102 return data_; |
| 103 } | 103 } |
| 104 | 104 |
| 105 ColorSpace ICCProfile::GetColorSpace() const { | 105 ColorSpace ICCProfile::GetColorSpace() const { |
| 106 ColorSpace color_space; | 106 ColorSpace color_space(ColorSpace::PrimaryID::CUSTOM, |
| 107 color_space.valid_ = true; | 107 ColorSpace::TransferID::CUSTOM, |
| 108 ColorSpace::MatrixID::RGB, ColorSpace::RangeID::FULL); |
| 108 color_space.icc_profile_id_ = id_; | 109 color_space.icc_profile_id_ = id_; |
| 109 | 110 |
| 110 // Move this ICC profile to the most recently used end of the cache. | 111 // Move this ICC profile to the most recently used end of the cache. |
| 111 { | 112 { |
| 112 Cache& cache = g_cache.Get(); | 113 Cache& cache = g_cache.Get(); |
| 113 base::AutoLock lock(cache.lock); | 114 base::AutoLock lock(cache.lock); |
| 114 | 115 |
| 115 auto found = cache.id_to_icc_profile_mru.Get(id_); | 116 auto found = cache.id_to_icc_profile_mru.Get(id_); |
| 116 if (found == cache.id_to_icc_profile_mru.end()) | 117 if (found == cache.id_to_icc_profile_mru.end()) |
| 117 cache.id_to_icc_profile_mru.Put(id_, *this); | 118 cache.id_to_icc_profile_mru.Put(id_, *this); |
| 118 } | 119 } |
| 119 return color_space; | 120 return color_space; |
| 120 } | 121 } |
| 121 | 122 |
| 122 // static | 123 // static |
| 123 bool ICCProfile::IsValidProfileLength(size_t length) { | 124 bool ICCProfile::IsValidProfileLength(size_t length) { |
| 124 return length >= kMinProfileLength && length <= kMaxProfileLength; | 125 return length >= kMinProfileLength && length <= kMaxProfileLength; |
| 125 } | 126 } |
| 126 | 127 |
| 127 } // namespace gfx | 128 } // namespace gfx |
| OLD | NEW |