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

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

Issue 2203213002: ICC profile color translations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@color_correction7
Patch Set: win compile fix Created 4 years, 4 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/icc_profile_mac.mm » ('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"
(...skipping 28 matching lines...) Expand all
39 ICCProfile::ICCProfile(const ICCProfile& other) = default; 39 ICCProfile::ICCProfile(const ICCProfile& other) = default;
40 ICCProfile& ICCProfile::operator=(ICCProfile&& other) = default; 40 ICCProfile& ICCProfile::operator=(ICCProfile&& other) = default;
41 ICCProfile& ICCProfile::operator=(const ICCProfile& other) = default; 41 ICCProfile& ICCProfile::operator=(const ICCProfile& other) = default;
42 ICCProfile::~ICCProfile() = default; 42 ICCProfile::~ICCProfile() = default;
43 43
44 bool ICCProfile::operator==(const ICCProfile& other) const { 44 bool ICCProfile::operator==(const ICCProfile& other) const {
45 return valid_ == other.valid_ && data_ == other.data_; 45 return valid_ == other.valid_ && data_ == other.data_;
46 } 46 }
47 47
48 // static 48 // static
49 ICCProfile ICCProfile::FromData(const std::vector<char>& icc_profile_data) { 49 ICCProfile ICCProfile::FromData(const char* data, size_t size) {
50 ICCProfile icc_profile; 50 ICCProfile icc_profile;
51 if (IsValidProfileLength(icc_profile_data.size())) { 51 if (IsValidProfileLength(size)) {
52 icc_profile.valid_ = true; 52 icc_profile.valid_ = true;
53 icc_profile.data_ = icc_profile_data; 53 icc_profile.data_.insert(icc_profile.data_.begin(), data, data + size);
54 } 54 }
55 if (!icc_profile.valid_) 55 if (!icc_profile.valid_)
56 return icc_profile; 56 return icc_profile;
57 57
58 Cache& cache = g_cache.Get(); 58 Cache& cache = g_cache.Get();
59 base::AutoLock lock(cache.lock); 59 base::AutoLock lock(cache.lock);
60 60
61 // Linearly search the cached ICC profiles to find one with the same data. 61 // Linearly search the cached ICC profiles to find one with the same data.
62 // If it exists, re-use its id and touch it in the cache. 62 // If it exists, re-use its id and touch it in the cache.
63 for (auto iter = cache.id_to_icc_profile_mru.begin(); 63 for (auto iter = cache.id_to_icc_profile_mru.begin();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 return color_space; 120 return color_space;
121 } 121 }
122 122
123 // static 123 // static
124 bool ICCProfile::IsValidProfileLength(size_t length) { 124 bool ICCProfile::IsValidProfileLength(size_t length) {
125 return length >= kMinProfileLength && length <= kMaxProfileLength; 125 return length >= kMinProfileLength && length <= kMaxProfileLength;
126 } 126 }
127 127
128 } // namespace gfx 128 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/icc_profile.h ('k') | ui/gfx/icc_profile_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698