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

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

Issue 2697863003: color: Clarify default behaviors (Closed)
Patch Set: Do less Created 3 years, 10 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 <cmath> 5 #include <cmath>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/color_space.h" 9 #include "ui/gfx/color_space.h"
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 SkMatrix44 range_adjust_inv; 72 SkMatrix44 range_adjust_inv;
73 range_adjust.invert(&range_adjust_inv); 73 range_adjust.invert(&range_adjust_inv);
74 74
75 for (size_t j = 0; j < kNumTestRGBs; ++j) { 75 for (size_t j = 0; j < kNumTestRGBs; ++j) {
76 SkVector4 yuv = range_adjust_inv * transfer * test_rgbs[j]; 76 SkVector4 yuv = range_adjust_inv * transfer * test_rgbs[j];
77 EXPECT_LT(Diff(yuv, expected_yuvs[i][j]), kEpsilon); 77 EXPECT_LT(Diff(yuv, expected_yuvs[i][j]), kEpsilon);
78 } 78 }
79 } 79 }
80 } 80 }
81 81
82 TEST(ColorSpace, VideoFormats) {
83 int primary_min = 0;
84 int primary_default = 1;
85 int primary_max = 12;
86
87 int transfer_min = 0;
88 int transfer_default = 1;
89 int transfer_max = 18;
90
91 int matrix_min = 0;
92 int matrix_default = 1;
93 int matrix_max = 11;
94
95 for (int i = -10; i < 30; ++i) {
96 int primary = primary_min + i;
97 int transfer = transfer_min + i;
98 int matrix = primary_min + i;
99 gfx::ColorSpace space = gfx::ColorSpace::CreateVideo(
100 primary, transfer, matrix, gfx::ColorSpace::RangeID::FULL);
101
102 int out_primary = -1;
103 int out_transfer = -1;
104 int out_matrix = -1;
105 bool full_range = false;
106 space.GetVideoParameters(&out_primary, &out_transfer, &out_matrix,
107 &full_range);
108 if (primary >= primary_min && primary <= primary_max)
109 EXPECT_EQ(primary, out_primary);
110 else
111 EXPECT_EQ(primary_default, out_primary);
112
113 if (transfer >= transfer_min && transfer <= transfer_max)
114 EXPECT_EQ(transfer, out_transfer);
115 else
116 EXPECT_EQ(transfer_default, out_transfer);
117
118 if (matrix >= matrix_min && matrix <= matrix_max)
119 EXPECT_EQ(matrix, out_matrix);
120 else
121 EXPECT_EQ(matrix_default, out_matrix);
122
123 EXPECT_TRUE(full_range);
124 }
125 }
126
82 } // namespace 127 } // namespace
83 } // namespace gfx 128 } // namespace gfx
OLDNEW
« ui/gfx/color_space.h ('K') | « ui/gfx/color_space.cc ('k') | ui/gfx/color_space_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698