Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(771)

Side by Side Diff: ui/gfx/icc_profile.cc

Issue 2660393002: Use gfx::ColorSpace instead of SkColorSpace in Blink (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return ICCProfile(); 125 return ICCProfile();
126 } 126 }
127 127
128 // gfx::ColorTransform assumes that this will return an empty profile for any 128 // gfx::ColorTransform assumes that this will return an empty profile for any
129 // color space that was not constructed from an ICC profile. 129 // color space that was not constructed from an ICC profile.
130 // TODO(ccameron): Fix this assumption. 130 // TODO(ccameron): Fix this assumption.
131 // return FromData(data->data(), data->size()); 131 // return FromData(data->data(), data->size());
132 return ICCProfile(); 132 return ICCProfile();
133 } 133 }
134 134
135 ICCProfile ICCProfile::FromSkColorSpace(sk_sp<SkColorSpace> color_space) {
136 ICCProfile icc_profile;
137
138 Cache& cache = g_cache.Get();
139 base::AutoLock lock(cache.lock);
140
141 // Linearly search the cached ICC profiles to find one with the same data.
142 // If it exists, re-use its id and touch it in the cache.
143 for (auto iter = cache.id_to_icc_profile_mru.begin();
144 iter != cache.id_to_icc_profile_mru.end(); ++iter) {
145 sk_sp<SkColorSpace> iter_color_space =
146 iter->second.color_space_.ToSkColorSpace();
147 if (SkColorSpace::Equals(color_space.get(), iter_color_space.get())) {
148 icc_profile = iter->second;
149 cache.id_to_icc_profile_mru.Get(icc_profile.id_);
150 return icc_profile;
151 }
152 }
153
154 // TODO(ccameron): Support constructing ICC profiles from arbitrary
155 // SkColorSpace objects.
156 DLOG(ERROR) << "Failed to find ICC profile matching SkColorSpace.";
157 return icc_profile;
158 }
159
160 const std::vector<char>& ICCProfile::GetData() const { 135 const std::vector<char>& ICCProfile::GetData() const {
161 return data_; 136 return data_;
162 } 137 }
163 138
164 const ColorSpace& ICCProfile::GetColorSpace() const { 139 const ColorSpace& ICCProfile::GetColorSpace() const {
165 // Move this ICC profile to the most recently used end of the cache, 140 // Move this ICC profile to the most recently used end of the cache,
166 // inserting if needed. 141 // inserting if needed.
167 if (id_) { 142 if (id_) {
168 Cache& cache = g_cache.Get(); 143 Cache& cache = g_cache.Get();
169 base::AutoLock lock(cache.lock); 144 base::AutoLock lock(cache.lock);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 cache.id_to_icc_profile_mru.Put(id_, *this); 216 cache.id_to_icc_profile_mru.Put(id_, *this);
242 } 217 }
243 } 218 }
244 219
245 // static 220 // static
246 bool ICCProfile::IsValidProfileLength(size_t length) { 221 bool ICCProfile::IsValidProfileLength(size_t length) {
247 return length >= kMinProfileLength && length <= kMaxProfileLength; 222 return length >= kMinProfileLength && length <= kMaxProfileLength;
248 } 223 }
249 224
250 } // namespace gfx 225 } // namespace gfx
OLDNEW
« third_party/WebKit/Source/platform/graphics/ContentLayerDelegate.cpp ('K') | « ui/gfx/icc_profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698