| OLD | NEW |
| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 EXPECT_NEAR(tmp.y(), 1.0f, 0.001f); | 212 EXPECT_NEAR(tmp.y(), 1.0f, 0.001f); |
| 213 EXPECT_NEAR(tmp.z(), 1.0f, 0.001f); | 213 EXPECT_NEAR(tmp.z(), 1.0f, 0.001f); |
| 214 | 214 |
| 215 // Test a blue color | 215 // Test a blue color |
| 216 tmp = ColorTransform::TriStim(128.0f / 255.0f, 240.0f / 255.0f, 0.5f); | 216 tmp = ColorTransform::TriStim(128.0f / 255.0f, 240.0f / 255.0f, 0.5f); |
| 217 t->Transform(&tmp, 1); | 217 t->Transform(&tmp, 1); |
| 218 EXPECT_GT(tmp.z(), tmp.x()); | 218 EXPECT_GT(tmp.z(), tmp.x()); |
| 219 EXPECT_GT(tmp.z(), tmp.y()); | 219 EXPECT_GT(tmp.z(), tmp.y()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 TEST(SimpleColorSpace, ToUndefined) { |
| 223 ColorSpace null; |
| 224 ColorSpace nonnull = gfx::ColorSpace::CreateSRGB(); |
| 225 // Video should have 1 step: YUV to RGB. |
| 226 // Anything else should have 0 steps. |
| 227 ColorSpace video = gfx::ColorSpace::CreateREC709(); |
| 228 std::unique_ptr<ColorTransform> video_to_null( |
| 229 ColorTransform::NewColorTransform( |
| 230 video, null, ColorTransform::Intent::INTENT_PERCEPTUAL)); |
| 231 EXPECT_EQ(video_to_null->NumberOfStepsForTesting(), 1u); |
| 232 |
| 233 // Test with an ICC profile that can't be represented as matrix+transfer. |
| 234 ColorSpace luttrcicc = ICCProfileForTestingNoAnalyticTrFn().GetColorSpace(); |
| 235 std::unique_ptr<ColorTransform> luttrcicc_to_null( |
| 236 ColorTransform::NewColorTransform( |
| 237 luttrcicc, null, ColorTransform::Intent::INTENT_PERCEPTUAL)); |
| 238 EXPECT_EQ(luttrcicc_to_null->NumberOfStepsForTesting(), 0u); |
| 239 std::unique_ptr<ColorTransform> luttrcicc_to_nonnull( |
| 240 ColorTransform::NewColorTransform( |
| 241 luttrcicc, nonnull, ColorTransform::Intent::INTENT_PERCEPTUAL)); |
| 242 EXPECT_GT(luttrcicc_to_nonnull->NumberOfStepsForTesting(), 0u); |
| 243 |
| 244 // Test with an ICC profile that can. |
| 245 ColorSpace adobeicc = ICCProfileForTestingAdobeRGB().GetColorSpace(); |
| 246 std::unique_ptr<ColorTransform> adobeicc_to_null( |
| 247 ColorTransform::NewColorTransform( |
| 248 adobeicc, null, ColorTransform::Intent::INTENT_PERCEPTUAL)); |
| 249 EXPECT_EQ(adobeicc_to_null->NumberOfStepsForTesting(), 0u); |
| 250 std::unique_ptr<ColorTransform> adobeicc_to_nonnull( |
| 251 ColorTransform::NewColorTransform( |
| 252 adobeicc, nonnull, ColorTransform::Intent::INTENT_PERCEPTUAL)); |
| 253 EXPECT_GT(adobeicc_to_nonnull->NumberOfStepsForTesting(), 0u); |
| 254 |
| 255 // And with something analytic. |
| 256 ColorSpace srgb = gfx::ColorSpace::CreateXYZD50(); |
| 257 std::unique_ptr<ColorTransform> srgb_to_null( |
| 258 ColorTransform::NewColorTransform( |
| 259 srgb, null, ColorTransform::Intent::INTENT_PERCEPTUAL)); |
| 260 EXPECT_EQ(srgb_to_null->NumberOfStepsForTesting(), 0u); |
| 261 std::unique_ptr<ColorTransform> srgb_to_nonnull( |
| 262 ColorTransform::NewColorTransform( |
| 263 srgb, nonnull, ColorTransform::Intent::INTENT_PERCEPTUAL)); |
| 264 EXPECT_GT(srgb_to_nonnull->NumberOfStepsForTesting(), 0u); |
| 265 } |
| 266 |
| 222 TEST(SimpleColorSpace, DefaultToSRGB) { | 267 TEST(SimpleColorSpace, DefaultToSRGB) { |
| 223 // The default value should do no transformation, regardless of destination. | 268 // The default value should do no transformation, regardless of destination. |
| 224 ColorSpace unknown; | 269 ColorSpace unknown; |
| 225 std::unique_ptr<ColorTransform> t1(ColorTransform::NewColorTransform( | 270 std::unique_ptr<ColorTransform> t1(ColorTransform::NewColorTransform( |
| 226 unknown, ColorSpace::CreateSRGB(), | 271 unknown, ColorSpace::CreateSRGB(), |
| 227 ColorTransform::Intent::INTENT_PERCEPTUAL)); | 272 ColorTransform::Intent::INTENT_PERCEPTUAL)); |
| 228 EXPECT_EQ(t1->NumberOfStepsForTesting(), 0u); | 273 EXPECT_EQ(t1->NumberOfStepsForTesting(), 0u); |
| 229 std::unique_ptr<ColorTransform> t2(ColorTransform::NewColorTransform( | 274 std::unique_ptr<ColorTransform> t2(ColorTransform::NewColorTransform( |
| 230 unknown, ColorSpace::CreateXYZD50(), | 275 unknown, ColorSpace::CreateXYZD50(), |
| 231 ColorTransform::Intent::INTENT_PERCEPTUAL)); | 276 ColorTransform::Intent::INTENT_PERCEPTUAL)); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 378 |
| 334 INSTANTIATE_TEST_CASE_P( | 379 INSTANTIATE_TEST_CASE_P( |
| 335 C, | 380 C, |
| 336 ColorSpaceTest, | 381 ColorSpaceTest, |
| 337 testing::Combine(testing::ValuesIn(all_primaries), | 382 testing::Combine(testing::ValuesIn(all_primaries), |
| 338 testing::Values(ColorSpace::TransferID::BT709), | 383 testing::Values(ColorSpace::TransferID::BT709), |
| 339 testing::ValuesIn(all_matrices), | 384 testing::ValuesIn(all_matrices), |
| 340 testing::ValuesIn(all_ranges), | 385 testing::ValuesIn(all_ranges), |
| 341 testing::ValuesIn(intents))); | 386 testing::ValuesIn(intents))); |
| 342 } // namespace | 387 } // namespace |
| OLD | NEW |