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

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

Issue 2742273002: color: Use classic locale for printing (Closed)
Patch Set: 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 | « ui/gfx/color_transform.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 (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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 TEST(SimpleColorSpace, MAYBE_SampleShaderSource) { 381 TEST(SimpleColorSpace, MAYBE_SampleShaderSource) {
382 ColorSpace bt709 = ColorSpace::CreateREC709(); 382 ColorSpace bt709 = ColorSpace::CreateREC709();
383 ColorSpace output(ColorSpace::PrimaryID::BT2020, 383 ColorSpace output(ColorSpace::PrimaryID::BT2020,
384 ColorSpace::TransferID::GAMMA28); 384 ColorSpace::TransferID::GAMMA28);
385 std::string source = 385 std::string source =
386 ColorTransform::NewColorTransform( 386 ColorTransform::NewColorTransform(
387 bt709, output, ColorTransform::Intent::INTENT_PERCEPTUAL) 387 bt709, output, ColorTransform::Intent::INTENT_PERCEPTUAL)
388 ->GetShaderSource(); 388 ->GetShaderSource();
389 std::string expected = 389 std::string expected =
390 "vec3 DoColorConversion(vec3 color) {\n" 390 "vec3 DoColorConversion(vec3 color) {\n"
391 " color = mat3(+1.16438353e+00, +1.16438353e+00, +1.16438353e+00,\n" 391 " color = mat3(1.16438353e+00, 1.16438353e+00, 1.16438353e+00,\n"
392 " -2.28029018e-09, -2.13248596e-01, +2.11240172e+00,\n" 392 " -2.28029018e-09, -2.13248596e-01, 2.11240172e+00,\n"
393 " +1.79274118e+00, -5.32909274e-01, -5.96049432e-10)" 393 " 1.79274118e+00, -5.32909274e-01, -5.96049432e-10) "
394 " * color;\n" 394 "* color;\n"
395 " color = vec3(-9.69429970e-01, +3.00019622e-01, -1.12926030e+00)" 395 " color += vec3(-9.69429970e-01, 3.00019622e-01, -1.12926030e+00);\n"
396 " + color;\n" 396 " if (color.r < 4.04499359e-02)\n"
397 " if (color.r < 0.040450)\n" 397 " color.r = 7.73993805e-02 * color.r;\n"
398 " color.r = +7.73993805e-02 * color.r;\n"
399 " else\n" 398 " else\n"
400 " color.r = pow(+9.47867334e-01 * color.r + +5.21326549e-02, " 399 " color.r = pow(9.47867334e-01 * color.r + 5.21326549e-02, "
401 "+2.40000010e+00);\n" 400 "2.40000010e+00);\n"
402 " if (color.g < 0.040450)\n" 401 " if (color.g < 4.04499359e-02)\n"
403 " color.g = +7.73993805e-02 * color.g;\n" 402 " color.g = 7.73993805e-02 * color.g;\n"
404 " else\n" 403 " else\n"
405 " color.g = pow(+9.47867334e-01 * color.g + +5.21326549e-02, " 404 " color.g = pow(9.47867334e-01 * color.g + 5.21326549e-02, "
406 "+2.40000010e+00);\n" 405 "2.40000010e+00);\n"
407 " if (color.b < 0.040450)\n" 406 " if (color.b < 4.04499359e-02)\n"
408 " color.b = +7.73993805e-02 * color.b;\n" 407 " color.b = 7.73993805e-02 * color.b;\n"
409 " else\n" 408 " else\n"
410 " color.b = pow(+9.47867334e-01 * color.b + +5.21326549e-02, " 409 " color.b = pow(9.47867334e-01 * color.b + 5.21326549e-02, "
411 "+2.40000010e+00);\n" 410 "2.40000010e+00);\n"
412 " color = mat3(+6.27403915e-01, +6.90973178e-02, +1.63914412e-02,\n" 411 " color = mat3(6.27403915e-01, 6.90973178e-02, 1.63914412e-02,\n"
413 " +3.29283148e-01, +9.19540286e-01, +8.80132914e-02,\n" 412 " 3.29283148e-01, 9.19540286e-01, 8.80132914e-02,\n"
414 " +4.33131084e-02, +1.13623003e-02, +8.95595253e-01) " 413 " 4.33131084e-02, 1.13623003e-02, 8.95595253e-01) "
415 "* color;\n" 414 "* color;\n"
416 " color = vec3(+0.00000000e+00, +0.00000000e+00, +0.00000000e+00) " 415 " color.r = pow(color.r, 3.57142866e-01);\n"
417 "+ color;\n" 416 " color.g = pow(color.g, 3.57142866e-01);\n"
418 " color.r = pow(color.r, +3.57142866e-01);\n" 417 " color.b = pow(color.b, 3.57142866e-01);\n"
419 " color.g = pow(color.g, +3.57142866e-01);\n"
420 " color.b = pow(color.b, +3.57142866e-01);\n"
421 " return color;\n" 418 " return color;\n"
422 "}\n"; 419 "}\n";
423 EXPECT_EQ(source, expected); 420 EXPECT_EQ(source, expected);
424 } 421 }
425 422
426 class TransferTest : public testing::TestWithParam<ColorSpace::TransferID> {}; 423 class TransferTest : public testing::TestWithParam<ColorSpace::TransferID> {};
427 424
428 TEST_P(TransferTest, basicTest) { 425 TEST_P(TransferTest, basicTest) {
429 gfx::ColorSpace space_with_transfer(ColorSpace::PrimaryID::BT709, GetParam(), 426 gfx::ColorSpace space_with_transfer(ColorSpace::PrimaryID::BT709, GetParam(),
430 ColorSpace::MatrixID::RGB, 427 ColorSpace::MatrixID::RGB,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 521
525 INSTANTIATE_TEST_CASE_P( 522 INSTANTIATE_TEST_CASE_P(
526 C, 523 C,
527 ColorSpaceTest, 524 ColorSpaceTest,
528 testing::Combine(testing::ValuesIn(all_primaries), 525 testing::Combine(testing::ValuesIn(all_primaries),
529 testing::Values(ColorSpace::TransferID::BT709), 526 testing::Values(ColorSpace::TransferID::BT709),
530 testing::ValuesIn(all_matrices), 527 testing::ValuesIn(all_matrices),
531 testing::ValuesIn(all_ranges), 528 testing::ValuesIn(all_ranges),
532 testing::ValuesIn(intents))); 529 testing::ValuesIn(intents)));
533 } // namespace 530 } // namespace
OLDNEW
« no previous file with comments | « ui/gfx/color_transform.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698