| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 EXPECT_NEAR(tmp.y(), 1.0f, kEpsilon); | 304 EXPECT_NEAR(tmp.y(), 1.0f, kEpsilon); |
| 305 EXPECT_NEAR(tmp.z(), 0.0f, kEpsilon); | 305 EXPECT_NEAR(tmp.z(), 0.0f, kEpsilon); |
| 306 | 306 |
| 307 tmp = ColorTransform::TriStim(0.0f, 0.0f, 1.0f); | 307 tmp = ColorTransform::TriStim(0.0f, 0.0f, 1.0f); |
| 308 t->Transform(&tmp, 1); | 308 t->Transform(&tmp, 1); |
| 309 EXPECT_NEAR(tmp.x(), 0.0f, kEpsilon); | 309 EXPECT_NEAR(tmp.x(), 0.0f, kEpsilon); |
| 310 EXPECT_NEAR(tmp.y(), 0.0f, kEpsilon); | 310 EXPECT_NEAR(tmp.y(), 0.0f, kEpsilon); |
| 311 EXPECT_NEAR(tmp.z(), 1.0f, kEpsilon); | 311 EXPECT_NEAR(tmp.z(), 1.0f, kEpsilon); |
| 312 } | 312 } |
| 313 | 313 |
| 314 TEST(SimpleColorSpace, UnknownVideoToSRGB) { | |
| 315 // Invalid video spaces should be BT709. | |
| 316 ColorSpace unknown = gfx::ColorSpace::CreateVideo( | |
| 317 -1, -1, -1, gfx::ColorSpace::RangeID::LIMITED); | |
| 318 ColorSpace sRGB = ColorSpace::CreateSRGB(); | |
| 319 std::unique_ptr<ColorTransform> t(ColorTransform::NewColorTransform( | |
| 320 unknown, sRGB, ColorTransform::Intent::INTENT_PERCEPTUAL)); | |
| 321 | |
| 322 ColorTransform::TriStim tmp(16.0f / 255.0f, 0.5f, 0.5f); | |
| 323 t->Transform(&tmp, 1); | |
| 324 EXPECT_NEAR(tmp.x(), 0.0f, 0.001f); | |
| 325 EXPECT_NEAR(tmp.y(), 0.0f, 0.001f); | |
| 326 EXPECT_NEAR(tmp.z(), 0.0f, 0.001f); | |
| 327 | |
| 328 tmp = ColorTransform::TriStim(235.0f / 255.0f, 0.5f, 0.5f); | |
| 329 t->Transform(&tmp, 1); | |
| 330 EXPECT_NEAR(tmp.x(), 1.0f, 0.001f); | |
| 331 EXPECT_NEAR(tmp.y(), 1.0f, 0.001f); | |
| 332 EXPECT_NEAR(tmp.z(), 1.0f, 0.001f); | |
| 333 | |
| 334 // Test a blue color | |
| 335 tmp = ColorTransform::TriStim(128.0f / 255.0f, 240.0f / 255.0f, 0.5f); | |
| 336 t->Transform(&tmp, 1); | |
| 337 EXPECT_GT(tmp.z(), tmp.x()); | |
| 338 EXPECT_GT(tmp.z(), tmp.y()); | |
| 339 } | |
| 340 | |
| 341 TEST(SimpleColorSpace, ToUndefined) { | 314 TEST(SimpleColorSpace, ToUndefined) { |
| 342 ColorSpace null; | 315 ColorSpace null; |
| 343 ColorSpace nonnull = gfx::ColorSpace::CreateSRGB(); | 316 ColorSpace nonnull = gfx::ColorSpace::CreateSRGB(); |
| 344 // Video should have 1 step: YUV to RGB. | 317 // Video should have 1 step: YUV to RGB. |
| 345 // Anything else should have 0 steps. | 318 // Anything else should have 0 steps. |
| 346 ColorSpace video = gfx::ColorSpace::CreateREC709(); | 319 ColorSpace video = gfx::ColorSpace::CreateREC709(); |
| 347 std::unique_ptr<ColorTransform> video_to_null( | 320 std::unique_ptr<ColorTransform> video_to_null( |
| 348 ColorTransform::NewColorTransform( | 321 ColorTransform::NewColorTransform( |
| 349 video, null, ColorTransform::Intent::INTENT_PERCEPTUAL)); | 322 video, null, ColorTransform::Intent::INTENT_PERCEPTUAL)); |
| 350 EXPECT_EQ(video_to_null->NumberOfStepsForTesting(), 1u); | 323 EXPECT_EQ(video_to_null->NumberOfStepsForTesting(), 1u); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 | 600 |
| 628 INSTANTIATE_TEST_CASE_P( | 601 INSTANTIATE_TEST_CASE_P( |
| 629 C, | 602 C, |
| 630 ColorSpaceTest, | 603 ColorSpaceTest, |
| 631 testing::Combine(testing::ValuesIn(all_primaries), | 604 testing::Combine(testing::ValuesIn(all_primaries), |
| 632 testing::Values(ColorSpace::TransferID::BT709), | 605 testing::Values(ColorSpace::TransferID::BT709), |
| 633 testing::ValuesIn(all_matrices), | 606 testing::ValuesIn(all_matrices), |
| 634 testing::ValuesIn(all_ranges), | 607 testing::ValuesIn(all_ranges), |
| 635 testing::ValuesIn(intents))); | 608 testing::ValuesIn(intents))); |
| 636 } // namespace | 609 } // namespace |
| OLD | NEW |