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

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

Issue 2770093003: Add test for QCMS based color transforms (Closed)
Patch Set: Really add the tests 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 | « no previous file | 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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/gfx/color_space.h" 7 #include "ui/gfx/color_space.h"
8 #include "ui/gfx/color_transform.h" 8 #include "ui/gfx/color_transform.h"
9 #include "ui/gfx/icc_profile.h" 9 #include "ui/gfx/icc_profile.h"
10 #include "ui/gfx/test/icc_profiles.h" 10 #include "ui/gfx/test/icc_profiles.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 EXPECT_NEAR(tmp.y(), 1.0f, 0.001f); 201 EXPECT_NEAR(tmp.y(), 1.0f, 0.001f);
202 EXPECT_NEAR(tmp.z(), 1.0f, 0.001f); 202 EXPECT_NEAR(tmp.z(), 1.0f, 0.001f);
203 203
204 // Test a blue color 204 // Test a blue color
205 tmp = ColorTransform::TriStim(128.0f / 255.0f, 240.0f / 255.0f, 0.5f); 205 tmp = ColorTransform::TriStim(128.0f / 255.0f, 240.0f / 255.0f, 0.5f);
206 t->Transform(&tmp, 1); 206 t->Transform(&tmp, 1);
207 EXPECT_GT(tmp.z(), tmp.x()); 207 EXPECT_GT(tmp.z(), tmp.x());
208 EXPECT_GT(tmp.z(), tmp.y()); 208 EXPECT_GT(tmp.z(), tmp.y());
209 } 209 }
210 210
211 TEST(SimpleColorSpace, ICCProfileOnlyXYZ) {
212 const float kEpsilon = 2.5f / 255.f;
213 ICCProfile icc_profile = ICCProfileForTestingNoAnalyticTrFn();
214 ColorSpace icc_space = icc_profile.GetColorSpace();
215 ColorSpace xyzd50 = ColorSpace::CreateXYZD50();
216
217 ColorTransform::TriStim input_value(127.f / 255, 187.f / 255, 157.f / 255);
218 ColorTransform::TriStim transformed_value = input_value;
219 ColorTransform::TriStim expected_transformed_value(
220 0.34090986847877502f, 0.42633286118507385f, 0.3408740758895874f);
221
222 // One step should be needed, namely, the SkColorSpaceXform.
223 std::unique_ptr<ColorTransform> icc_to_xyzd50(
224 ColorTransform::NewColorTransform(
225 icc_space, xyzd50, ColorTransform::Intent::INTENT_ABSOLUTE));
226 EXPECT_EQ(icc_to_xyzd50->NumberOfStepsForTesting(), 1u);
227 icc_to_xyzd50->Transform(&transformed_value, 1);
228 EXPECT_NEAR(transformed_value.x(), expected_transformed_value.x(), kEpsilon);
229 EXPECT_NEAR(transformed_value.y(), expected_transformed_value.y(), kEpsilon);
230 EXPECT_NEAR(transformed_value.z(), expected_transformed_value.z(), kEpsilon);
231
232 // One step should be needed, namely, the SkColorSpaceXform.
233 std::unique_ptr<ColorTransform> xyzd50_to_icc(
234 ColorTransform::NewColorTransform(
235 xyzd50, icc_space, ColorTransform::Intent::INTENT_ABSOLUTE));
236 EXPECT_EQ(xyzd50_to_icc->NumberOfStepsForTesting(), 1u);
237 xyzd50_to_icc->Transform(&transformed_value, 1);
238 EXPECT_NEAR(input_value.x(), transformed_value.x(), kEpsilon);
239 EXPECT_NEAR(input_value.y(), transformed_value.y(), kEpsilon);
240 EXPECT_NEAR(input_value.z(), transformed_value.z(), kEpsilon);
241 }
242
243 TEST(SimpleColorSpace, ICCProfileOnlyColorSpin) {
244 const float kEpsilon = 2.5f / 255.f;
245 ICCProfile icc_profile = ICCProfileForTestingNoAnalyticTrFn();
246 ColorSpace icc_space = icc_profile.GetColorSpace();
247 ColorSpace colorspin =
248 ICCProfileForTestingColorSpin().GetParametricColorSpace();
249
250 ColorTransform::TriStim input_value(0.25f, 0.5f, 0.75f);
251 ColorTransform::TriStim transformed_value = input_value;
252 ColorTransform::TriStim expected_transformed_value(
253 0.49694931507110596f, 0.74937951564788818f, 0.31359460949897766f);
254
255 // Three steps will be needed.
256 std::unique_ptr<ColorTransform> icc_to_colorspin(
257 ColorTransform::NewColorTransform(
258 icc_space, colorspin, ColorTransform::Intent::INTENT_PERCEPTUAL));
259 EXPECT_EQ(icc_to_colorspin->NumberOfStepsForTesting(), 3u);
260 icc_to_colorspin->Transform(&transformed_value, 1);
261 EXPECT_NEAR(transformed_value.x(), expected_transformed_value.x(), kEpsilon);
262 EXPECT_NEAR(transformed_value.y(), expected_transformed_value.y(), kEpsilon);
263 EXPECT_NEAR(transformed_value.z(), expected_transformed_value.z(), kEpsilon);
264
265 transformed_value = expected_transformed_value;
266 std::unique_ptr<ColorTransform> colorspin_to_icc(
267 ColorTransform::NewColorTransform(
268 colorspin, icc_space, ColorTransform::Intent::INTENT_PERCEPTUAL));
269 EXPECT_EQ(colorspin_to_icc->NumberOfStepsForTesting(), 3u);
270 transformed_value = expected_transformed_value;
271 colorspin_to_icc->Transform(&transformed_value, 1);
272 EXPECT_NEAR(input_value.x(), transformed_value.x(), kEpsilon);
273 EXPECT_NEAR(input_value.y(), transformed_value.y(), kEpsilon);
274 EXPECT_NEAR(input_value.z(), transformed_value.z(), kEpsilon);
275 }
276
211 TEST(SimpleColorSpace, GetColorSpace) { 277 TEST(SimpleColorSpace, GetColorSpace) {
212 ICCProfile srgb_icc = ICCProfileForTestingSRGB(); 278 ICCProfile srgb_icc = ICCProfileForTestingSRGB();
213 ColorSpace sRGB = srgb_icc.GetColorSpace(); 279 ColorSpace sRGB = srgb_icc.GetColorSpace();
214 ColorSpace sRGB2 = sRGB; 280 ColorSpace sRGB2 = sRGB;
215 const float kEpsilon = 1.5f / 255.f; 281 const float kEpsilon = 1.5f / 255.f;
216 282
217 // Prevent sRGB2 from using a cached ICC profile. 283 // Prevent sRGB2 from using a cached ICC profile.
218 sRGB2.icc_profile_id_ = 0; 284 sRGB2.icc_profile_id_ = 0;
219 285
220 std::unique_ptr<ColorTransform> t(ColorTransform::NewColorTransform( 286 std::unique_ptr<ColorTransform> t(ColorTransform::NewColorTransform(
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 627
562 INSTANTIATE_TEST_CASE_P( 628 INSTANTIATE_TEST_CASE_P(
563 C, 629 C,
564 ColorSpaceTest, 630 ColorSpaceTest,
565 testing::Combine(testing::ValuesIn(all_primaries), 631 testing::Combine(testing::ValuesIn(all_primaries),
566 testing::Values(ColorSpace::TransferID::BT709), 632 testing::Values(ColorSpace::TransferID::BT709),
567 testing::ValuesIn(all_matrices), 633 testing::ValuesIn(all_matrices),
568 testing::ValuesIn(all_ranges), 634 testing::ValuesIn(all_ranges),
569 testing::ValuesIn(intents))); 635 testing::ValuesIn(intents)));
570 } // namespace 636 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698