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

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

Issue 2742613002: color: Always use parametric color spaces for raster (Closed)
Patch Set: Incorporate review feedback Created 3 years, 9 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/color_transform.cc ('k') | ui/gfx/icc_profile.cc » ('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 #ifndef UI_GFX_ICC_PROFILE_H_ 5 #ifndef UI_GFX_ICC_PROFILE_H_
6 #define UI_GFX_ICC_PROFILE_H_ 6 #define UI_GFX_ICC_PROFILE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #endif 50 #endif
51 51
52 // This will recover a ICCProfile from a compact ColorSpace representation. 52 // This will recover a ICCProfile from a compact ColorSpace representation.
53 // Internally, this will make an effort to create an identical ICCProfile 53 // Internally, this will make an effort to create an identical ICCProfile
54 // to the one that created |color_space|, but this is not guaranteed. 54 // to the one that created |color_space|, but this is not guaranteed.
55 static ICCProfile FromColorSpace(const gfx::ColorSpace& color_space); 55 static ICCProfile FromColorSpace(const gfx::ColorSpace& color_space);
56 56
57 // Create directly from profile data. 57 // Create directly from profile data.
58 static ICCProfile FromData(const void* icc_profile, size_t size); 58 static ICCProfile FromData(const void* icc_profile, size_t size);
59 59
60 // This will perform a potentially-lossy conversion to a more compact color 60 // Return a ColorSpace that references this ICCProfile. ColorTransforms
61 // space representation. 61 // created using this ColorSpace will match this ICCProfile precisely.
62 const ColorSpace& GetColorSpace() const; 62 const ColorSpace& GetColorSpace() const;
63 63
64 // Return a ColorSpace that is the best parametric approximation of this
65 // ICCProfile. The resulting ColorSpace will reference this ICCProfile only
66 // if the parametric approximation is almost exact.
67 const ColorSpace& GetParametricColorSpace() const;
68
64 const std::vector<char>& GetData() const; 69 const std::vector<char>& GetData() const;
65 70
66 #if defined(OS_WIN) 71 #if defined(OS_WIN)
67 // This will read monitor ICC profiles from disk and cache the results for the 72 // This will read monitor ICC profiles from disk and cache the results for the
68 // other functions to read. This should not be called on the UI or IO thread. 73 // other functions to read. This should not be called on the UI or IO thread.
69 static void UpdateCachedProfilesOnBackgroundThread(); 74 static void UpdateCachedProfilesOnBackgroundThread();
70 static bool CachedProfilesNeedUpdate(); 75 static bool CachedProfilesNeedUpdate();
71 #endif 76 #endif
72 77
73 private: 78 private:
74 friend ICCProfile ICCProfileForTestingAdobeRGB(); 79 friend ICCProfile ICCProfileForTestingAdobeRGB();
75 friend ICCProfile ICCProfileForTestingColorSpin(); 80 friend ICCProfile ICCProfileForTestingColorSpin();
76 friend ICCProfile ICCProfileForTestingGenericRGB(); 81 friend ICCProfile ICCProfileForTestingGenericRGB();
77 friend ICCProfile ICCProfileForTestingSRGB(); 82 friend ICCProfile ICCProfileForTestingSRGB();
78 friend ICCProfile ICCProfileForTestingNoAnalyticTrFn(); 83 friend ICCProfile ICCProfileForTestingNoAnalyticTrFn();
84 friend ICCProfile ICCProfileForTestingA2BOnly();
79 static const uint64_t test_id_adobe_rgb_; 85 static const uint64_t test_id_adobe_rgb_;
80 static const uint64_t test_id_color_spin_; 86 static const uint64_t test_id_color_spin_;
81 static const uint64_t test_id_generic_rgb_; 87 static const uint64_t test_id_generic_rgb_;
82 static const uint64_t test_id_srgb_; 88 static const uint64_t test_id_srgb_;
83 static const uint64_t test_id_no_analytic_tr_fn_; 89 static const uint64_t test_id_no_analytic_tr_fn_;
90 static const uint64_t test_id_a2b_only_;
84 91
85 // Populate |icc_profile| with the ICCProfile corresponding to id |id|. Return 92 // Populate |icc_profile| with the ICCProfile corresponding to id |id|. Return
86 // false if |id| is not in the cache. If |only_if_needed| is true, then return 93 // false if |id| is not in the cache.
87 // false if |color_space_is_accurate_| is true for this profile (that is, if 94 static bool FromId(uint64_t id, ICCProfile* icc_profile);
88 // the ICCProfile is needed to know the space precisely).
89 static bool FromId(uint64_t id, bool only_if_needed, ICCProfile* icc_profile);
90 95
91 // This method is used to hard-code the |id_| to a specific value, and is 96 // This method is used to hard-code the |id_| to a specific value, and is
92 // used by test methods to ensure that they don't conflict with the values 97 // used by test methods to ensure that they don't conflict with the values
93 // generated in the browser. 98 // generated in the browser.
94 static ICCProfile FromDataWithId(const void* icc_profile, 99 static ICCProfile FromDataWithId(const void* icc_profile,
95 size_t size, 100 size_t size,
96 uint64_t id); 101 uint64_t id);
97 102
98 static bool IsValidProfileLength(size_t length);
99 void ComputeColorSpaceAndCache(); 103 void ComputeColorSpaceAndCache();
100 104
101 // This globally identifies this ICC profile. It is used to look up this ICC 105 // This globally identifies this ICC profile. It is used to look up this ICC
102 // profile from a ColorSpace object created from it. The object is invalid if 106 // profile from a ColorSpace object created from it. The object is invalid if
103 // |id_| is zero. 107 // |id_| is zero.
104 uint64_t id_ = 0; 108 uint64_t id_ = 0;
105 std::vector<char> data_; 109 std::vector<char> data_;
106 110
111 // |color_space| always links back to this ICC profile, and its SkColorSpace
112 // is always equal to the SkColorSpace created from this ICCProfile.
107 gfx::ColorSpace color_space_; 113 gfx::ColorSpace color_space_;
108 114
109 // True if |color_space_| accurately represents this color space (this is 115 // |parametric_color_space_| will only link back to this ICC profile if it
110 // false e.g, for lookup-based profiles). 116 // is accurate, and its SkColorSpace will always be parametrically created.
111 bool color_space_is_accurate_ = false; 117 gfx::ColorSpace parametric_color_space_;
112 118
113 // This is set to true if SkICC successfully parsed this profile. 119 // This is set to true if SkICC successfully parsed this profile.
114 bool successfully_parsed_by_sk_icc_ = false; 120 bool successfully_parsed_by_sk_icc_ = false;
115 121
116 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, BT709toSRGBICC); 122 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, BT709toSRGBICC);
117 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace); 123 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace);
118 friend int ::LLVMFuzzerTestOneInput(const uint8_t*, size_t); 124 friend int ::LLVMFuzzerTestOneInput(const uint8_t*, size_t);
119 friend class ColorSpace; 125 friend class ColorSpace;
120 friend class ColorTransformInternal; 126 friend class ColorTransformInternal;
121 friend struct IPC::ParamTraits<gfx::ICCProfile>; 127 friend struct IPC::ParamTraits<gfx::ICCProfile>;
122 }; 128 };
123 129
124 } // namespace gfx 130 } // namespace gfx
125 131
126 #endif // UI_GFX_ICC_PROFILE_H_ 132 #endif // UI_GFX_ICC_PROFILE_H_
OLDNEW
« no previous file with comments | « ui/gfx/color_transform.cc ('k') | ui/gfx/icc_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698