| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 #endif | 393 #endif |
| 394 TEST(SimpleColorSpace, MAYBE_SampleShaderSource) { | 394 TEST(SimpleColorSpace, MAYBE_SampleShaderSource) { |
| 395 ColorSpace bt709 = ColorSpace::CreateREC709(); | 395 ColorSpace bt709 = ColorSpace::CreateREC709(); |
| 396 ColorSpace output(ColorSpace::PrimaryID::BT2020, | 396 ColorSpace output(ColorSpace::PrimaryID::BT2020, |
| 397 ColorSpace::TransferID::GAMMA28); | 397 ColorSpace::TransferID::GAMMA28); |
| 398 std::string source = | 398 std::string source = |
| 399 ColorTransform::NewColorTransform( | 399 ColorTransform::NewColorTransform( |
| 400 bt709, output, ColorTransform::Intent::INTENT_PERCEPTUAL) | 400 bt709, output, ColorTransform::Intent::INTENT_PERCEPTUAL) |
| 401 ->GetShaderSource(); | 401 ->GetShaderSource(); |
| 402 std::string expected = | 402 std::string expected = |
| 403 "float TransferFn1(float v) {\n" |
| 404 " if (v < 4.04499359e-02)\n" |
| 405 " return 7.73993805e-02 * v;\n" |
| 406 " return pow(9.47867334e-01 * v + 5.21326549e-02, 2.40000010e+00);\n" |
| 407 "}\n" |
| 408 "float TransferFn3(float v) {\n" |
| 409 " return pow(v, 3.57142866e-01);\n" |
| 410 "}\n" |
| 403 "vec3 DoColorConversion(vec3 color) {\n" | 411 "vec3 DoColorConversion(vec3 color) {\n" |
| 404 " color = mat3(1.16438353e+00, 1.16438353e+00, 1.16438353e+00,\n" | 412 " color = mat3(1.16438353e+00, 1.16438353e+00, 1.16438353e+00,\n" |
| 405 " -2.28029018e-09, -2.13248596e-01, 2.11240172e+00,\n" | 413 " -2.28029018e-09, -2.13248596e-01, 2.11240172e+00,\n" |
| 406 " 1.79274118e+00, -5.32909274e-01, -5.96049432e-10) " | 414 " 1.79274118e+00, -5.32909274e-01, -5.96049432e-10) " |
| 407 "* color;\n" | 415 "* color;\n" |
| 408 " color += vec3(-9.69429970e-01, 3.00019622e-01, -1.12926030e+00);\n" | 416 " color += vec3(-9.69429970e-01, 3.00019622e-01, -1.12926030e+00);\n" |
| 409 " if (color.r < 4.04499359e-02)\n" | 417 " color.r = TransferFn1(color.r);\n" |
| 410 " color.r = 7.73993805e-02 * color.r;\n" | 418 " color.g = TransferFn1(color.g);\n" |
| 411 " else\n" | 419 " color.b = TransferFn1(color.b);\n" |
| 412 " color.r = pow(9.47867334e-01 * color.r + 5.21326549e-02, " | |
| 413 "2.40000010e+00);\n" | |
| 414 " if (color.g < 4.04499359e-02)\n" | |
| 415 " color.g = 7.73993805e-02 * color.g;\n" | |
| 416 " else\n" | |
| 417 " color.g = pow(9.47867334e-01 * color.g + 5.21326549e-02, " | |
| 418 "2.40000010e+00);\n" | |
| 419 " if (color.b < 4.04499359e-02)\n" | |
| 420 " color.b = 7.73993805e-02 * color.b;\n" | |
| 421 " else\n" | |
| 422 " color.b = pow(9.47867334e-01 * color.b + 5.21326549e-02, " | |
| 423 "2.40000010e+00);\n" | |
| 424 " color = mat3(6.27403915e-01, 6.90973178e-02, 1.63914412e-02,\n" | 420 " color = mat3(6.27403915e-01, 6.90973178e-02, 1.63914412e-02,\n" |
| 425 " 3.29283148e-01, 9.19540286e-01, 8.80132914e-02,\n" | 421 " 3.29283148e-01, 9.19540286e-01, 8.80132914e-02,\n" |
| 426 " 4.33131084e-02, 1.13623003e-02, 8.95595253e-01) " | 422 " 4.33131084e-02, 1.13623003e-02, 8.95595253e-01) " |
| 427 "* color;\n" | 423 "* color;\n" |
| 428 " color.r = pow(color.r, 3.57142866e-01);\n" | 424 " color.r = TransferFn3(color.r);\n" |
| 429 " color.g = pow(color.g, 3.57142866e-01);\n" | 425 " color.g = TransferFn3(color.g);\n" |
| 430 " color.b = pow(color.b, 3.57142866e-01);\n" | 426 " color.b = TransferFn3(color.b);\n" |
| 431 " return color;\n" | 427 " return color;\n" |
| 432 "}\n"; | 428 "}\n"; |
| 433 EXPECT_EQ(source, expected); | 429 EXPECT_EQ(source, expected); |
| 434 } | 430 } |
| 435 | 431 |
| 436 class TransferTest : public testing::TestWithParam<ColorSpace::TransferID> {}; | 432 class TransferTest : public testing::TestWithParam<ColorSpace::TransferID> {}; |
| 437 | 433 |
| 438 TEST_P(TransferTest, basicTest) { | 434 TEST_P(TransferTest, basicTest) { |
| 439 gfx::ColorSpace space_with_transfer(ColorSpace::PrimaryID::BT709, GetParam(), | 435 gfx::ColorSpace space_with_transfer(ColorSpace::PrimaryID::BT709, GetParam(), |
| 440 ColorSpace::MatrixID::RGB, | 436 ColorSpace::MatrixID::RGB, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 | 561 |
| 566 INSTANTIATE_TEST_CASE_P( | 562 INSTANTIATE_TEST_CASE_P( |
| 567 C, | 563 C, |
| 568 ColorSpaceTest, | 564 ColorSpaceTest, |
| 569 testing::Combine(testing::ValuesIn(all_primaries), | 565 testing::Combine(testing::ValuesIn(all_primaries), |
| 570 testing::Values(ColorSpace::TransferID::BT709), | 566 testing::Values(ColorSpace::TransferID::BT709), |
| 571 testing::ValuesIn(all_matrices), | 567 testing::ValuesIn(all_matrices), |
| 572 testing::ValuesIn(all_ranges), | 568 testing::ValuesIn(all_ranges), |
| 573 testing::ValuesIn(intents))); | 569 testing::ValuesIn(intents))); |
| 574 } // namespace | 570 } // namespace |
| OLD | NEW |