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

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

Issue 2784673006: color: Do not enforce T(0)=0 and T(1)=1 constraints in approxmation (Closed)
Patch Set: Fix the right error bound Created 3 years, 8 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 | « no previous file | ui/gfx/icc_profile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/gfx/skia_color_space_util.h" 10 #include "ui/gfx/skia_color_space_util.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 t.push_back(SkTransferFnEval(tr_fn, v)); 102 t.push_back(SkTransferFnEval(tr_fn, v));
103 } 103 }
104 104
105 SkColorSpaceTransferFn fn_approx; 105 SkColorSpaceTransferFn fn_approx;
106 bool converged = 106 bool converged =
107 SkApproximateTransferFn(x.data(), t.data(), x.size(), &fn_approx); 107 SkApproximateTransferFn(x.data(), t.data(), x.size(), &fn_approx);
108 EXPECT_TRUE(converged); 108 EXPECT_TRUE(converged);
109 109
110 for (size_t i = 0; i < x.size(); ++i) { 110 for (size_t i = 0; i < x.size(); ++i) {
111 float fn_approx_of_x = SkTransferFnEval(fn_approx, x[i]); 111 float fn_approx_of_x = SkTransferFnEval(fn_approx, x[i]);
112 EXPECT_NEAR(t[i], fn_approx_of_x, 2.f / 256.f); 112 EXPECT_NEAR(t[i], fn_approx_of_x, 3.f / 256.f);
113 if (std::abs(t[i] - fn_approx_of_x) > 2.f / 256.f) 113 if (std::abs(t[i] - fn_approx_of_x) > 3.f / 256.f)
114 break; 114 break;
115 } 115 }
116 } 116 }
117 117
118 ColorSpace::TransferID all_transfers[] = { 118 ColorSpace::TransferID all_transfers[] = {
119 ColorSpace::TransferID::GAMMA22, ColorSpace::TransferID::GAMMA24, 119 ColorSpace::TransferID::GAMMA22, ColorSpace::TransferID::GAMMA24,
120 ColorSpace::TransferID::GAMMA28, ColorSpace::TransferID::BT709, 120 ColorSpace::TransferID::GAMMA28, ColorSpace::TransferID::BT709,
121 ColorSpace::TransferID::SMPTE240M, ColorSpace::TransferID::IEC61966_2_1, 121 ColorSpace::TransferID::SMPTE240M, ColorSpace::TransferID::IEC61966_2_1,
122 ColorSpace::TransferID::LINEAR}; 122 ColorSpace::TransferID::LINEAR};
123 123
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 float fn_approx_of_x = SkTransferFnEval(fn_approx, x[i]); 167 float fn_approx_of_x = SkTransferFnEval(fn_approx, x[i]);
168 EXPECT_NEAR(t[i], fn_approx_of_x, expected_error); 168 EXPECT_NEAR(t[i], fn_approx_of_x, expected_error);
169 if (std::abs(t[i] - fn_approx_of_x) > expected_error) 169 if (std::abs(t[i] - fn_approx_of_x) > expected_error)
170 break; 170 break;
171 } 171 }
172 } 172 }
173 } 173 }
174 174
175 } // namespace 175 } // namespace
176 } // namespace gfx 176 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/icc_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698