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

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

Issue 2705203003: color: Tests for fix accidental partial color conversion (Closed)
Patch Set: Use smaller ICC profile 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
« no previous file with comments | « ui/gfx/icc_profile.h ('k') | ui/gfx/test/icc_profiles.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "third_party/skia/include/core/SkICC.h" 12 #include "third_party/skia/include/core/SkICC.h"
13 #include "ui/gfx/color_transform.h" 13 #include "ui/gfx/color_transform.h"
14 14
15 namespace gfx { 15 namespace gfx {
16 16
17 const uint64_t ICCProfile::test_id_adobe_rgb_ = 1; 17 const uint64_t ICCProfile::test_id_adobe_rgb_ = 1;
18 const uint64_t ICCProfile::test_id_color_spin_ = 2; 18 const uint64_t ICCProfile::test_id_color_spin_ = 2;
19 const uint64_t ICCProfile::test_id_generic_rgb_ = 3; 19 const uint64_t ICCProfile::test_id_generic_rgb_ = 3;
20 const uint64_t ICCProfile::test_id_srgb_ = 4; 20 const uint64_t ICCProfile::test_id_srgb_ = 4;
21 const uint64_t ICCProfile::test_id_no_analytic_tr_fn_ = 5;
21 22
22 namespace { 23 namespace {
23 const size_t kMinProfileLength = 128; 24 const size_t kMinProfileLength = 128;
24 const size_t kMaxProfileLength = 4 * 1024 * 1024; 25 const size_t kMaxProfileLength = 4 * 1024 * 1024;
25 26
26 // Allow keeping around a maximum of 8 cached ICC profiles. Beware that 27 // Allow keeping around a maximum of 8 cached ICC profiles. Beware that
27 // we will do a linear search thorugh currently-cached ICC profiles, 28 // we will do a linear search thorugh currently-cached ICC profiles,
28 // when creating a new ICC profile. 29 // when creating a new ICC profile.
29 const size_t kMaxCachedICCProfiles = 8; 30 const size_t kMaxCachedICCProfiles = 8;
30 31
31 struct Cache { 32 struct Cache {
32 Cache() : id_to_icc_profile_mru(kMaxCachedICCProfiles) {} 33 Cache() : id_to_icc_profile_mru(kMaxCachedICCProfiles) {}
33 ~Cache() {} 34 ~Cache() {}
34 35
35 // Start from-ICC-data IDs at the end of the hard-coded test id list above. 36 // Start from-ICC-data IDs at the end of the hard-coded test id list above.
36 uint64_t next_unused_id = 5; 37 uint64_t next_unused_id = 10;
msarett1 2017/02/22 20:58:46 I don't really understand what's going on here.
ccameron 2017/02/22 21:03:27 This is sort of weird. It's ensuring that we don't
37 base::MRUCache<uint64_t, ICCProfile> id_to_icc_profile_mru; 38 base::MRUCache<uint64_t, ICCProfile> id_to_icc_profile_mru;
38 base::Lock lock; 39 base::Lock lock;
39 }; 40 };
40 static base::LazyInstance<Cache> g_cache; 41 static base::LazyInstance<Cache> g_cache;
41 42
42 } // namespace 43 } // namespace
43 44
44 ICCProfile::ICCProfile() = default; 45 ICCProfile::ICCProfile() = default;
45 ICCProfile::ICCProfile(ICCProfile&& other) = default; 46 ICCProfile::ICCProfile(ICCProfile&& other) = default;
46 ICCProfile::ICCProfile(const ICCProfile& other) = default; 47 ICCProfile::ICCProfile(const ICCProfile& other) = default;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 cache.id_to_icc_profile_mru.Put(id_, *this); 209 cache.id_to_icc_profile_mru.Put(id_, *this);
209 } 210 }
210 } 211 }
211 212
212 // static 213 // static
213 bool ICCProfile::IsValidProfileLength(size_t length) { 214 bool ICCProfile::IsValidProfileLength(size_t length) {
214 return length >= kMinProfileLength && length <= kMaxProfileLength; 215 return length >= kMinProfileLength && length <= kMaxProfileLength;
215 } 216 }
216 217
217 } // namespace gfx 218 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/icc_profile.h ('k') | ui/gfx/test/icc_profiles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698