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

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

Issue 2826513002: color: Use named gamuts in ToSkColorSpace (Closed)
Patch Set: Add named gamut parametric trfn Created 3 years, 8 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_space.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 <cmath> 5 #include <cmath>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/color_space.h" 9 #include "ui/gfx/color_space.h"
10 #include "ui/gfx/skia_color_space_util.h" 10 #include "ui/gfx/skia_color_space_util.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 for (size_t i = 0; i < x.size(); ++i) { 166 for (size_t i = 0; i < x.size(); ++i) {
167 float fn_approx_of_x = SkTransferFnEval(fn_approx, x[i]); 167 float fn_approx_of_x = SkTransferFnEval(fn_approx, x[i]);
168 EXPECT_NEAR(t[i], fn_approx_of_x, expected_error); 168 EXPECT_NEAR(t[i], fn_approx_of_x, expected_error);
169 if (std::abs(t[i] - fn_approx_of_x) > expected_error) 169 if (std::abs(t[i] - fn_approx_of_x) > expected_error)
170 break; 170 break;
171 } 171 }
172 } 172 }
173 } 173 }
174 174
175 TEST(ColorSpace, ToSkColorSpace) {
176 const size_t kNumTests = 4;
177 ColorSpace color_spaces[kNumTests] = {
178 ColorSpace(ColorSpace::PrimaryID::BT709,
179 ColorSpace::TransferID::IEC61966_2_1),
180 ColorSpace(ColorSpace::PrimaryID::ADOBE_RGB,
181 ColorSpace::TransferID::IEC61966_2_1),
182 ColorSpace(ColorSpace::PrimaryID::SMPTEST432_1,
183 ColorSpace::TransferID::LINEAR),
184 ColorSpace(ColorSpace::PrimaryID::BT2020,
185 ColorSpace::TransferID::IEC61966_2_1),
186 };
187 sk_sp<SkColorSpace> sk_color_spaces[kNumTests] = {
188 SkColorSpace::MakeSRGB(),
189 SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
190 SkColorSpace::kAdobeRGB_Gamut),
191 SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma,
192 SkColorSpace::kDCIP3_D65_Gamut),
193 SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
194 SkColorSpace::kRec2020_Gamut),
195 };
196 for (size_t i = 0; i < kNumTests; ++i) {
197 EXPECT_TRUE(SkColorSpace::Equals(color_spaces[i].ToSkColorSpace().get(),
198 sk_color_spaces[i].get()))
199 << " on iteration i = " << i;
200 }
201 }
202
175 } // namespace 203 } // namespace
176 } // namespace gfx 204 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/color_space.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698