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

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

Issue 2652503002: Use SkICC in gfx::ICCProfile and gfx::ColorSpace (Closed)
Patch Set: Created 3 years, 11 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 (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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 tmp = ColorTransform::TriStim(128.0f / 255.0f, 240.0f / 255.0f, 0.5f); 110 tmp = ColorTransform::TriStim(128.0f / 255.0f, 240.0f / 255.0f, 0.5f);
111 t->transform(&tmp, 1); 111 t->transform(&tmp, 1);
112 EXPECT_GT(tmp.z(), tmp.x()); 112 EXPECT_GT(tmp.z(), tmp.x());
113 EXPECT_GT(tmp.z(), tmp.y()); 113 EXPECT_GT(tmp.z(), tmp.y());
114 } 114 }
115 115
116 TEST(SimpleColorSpace, GetColorSpace) { 116 TEST(SimpleColorSpace, GetColorSpace) {
117 ICCProfile srgb_icc = ICCProfileForTestingSRGB(); 117 ICCProfile srgb_icc = ICCProfileForTestingSRGB();
118 ColorSpace sRGB = srgb_icc.GetColorSpace(); 118 ColorSpace sRGB = srgb_icc.GetColorSpace();
119 ColorSpace sRGB2 = sRGB; 119 ColorSpace sRGB2 = sRGB;
120 const float kEpsilon = 0.0012f;
120 121
121 // Prevent sRGB2 from using a cached ICC profile. 122 // Prevent sRGB2 from using a cached ICC profile.
122 sRGB2.icc_profile_id_ = 0; 123 sRGB2.icc_profile_id_ = 0;
123 124
124 std::unique_ptr<ColorTransform> t(ColorTransform::NewColorTransform( 125 std::unique_ptr<ColorTransform> t(ColorTransform::NewColorTransform(
125 sRGB, sRGB2, ColorTransform::Intent::INTENT_ABSOLUTE)); 126 sRGB, sRGB2, ColorTransform::Intent::INTENT_ABSOLUTE));
126 127
127 ColorTransform::TriStim tmp(1.0f, 1.0f, 1.0f); 128 ColorTransform::TriStim tmp(1.0f, 1.0f, 1.0f);
128 t->transform(&tmp, 1); 129 t->transform(&tmp, 1);
129 EXPECT_NEAR(tmp.x(), 1.0f, 0.001f); 130 EXPECT_NEAR(tmp.x(), 1.0f, kEpsilon);
130 EXPECT_NEAR(tmp.y(), 1.0f, 0.001f); 131 EXPECT_NEAR(tmp.y(), 1.0f, kEpsilon);
131 EXPECT_NEAR(tmp.z(), 1.0f, 0.001f); 132 EXPECT_NEAR(tmp.z(), 1.0f, kEpsilon);
132 133
133 tmp = ColorTransform::TriStim(1.0f, 0.0f, 0.0f); 134 tmp = ColorTransform::TriStim(1.0f, 0.0f, 0.0f);
134 t->transform(&tmp, 1); 135 t->transform(&tmp, 1);
135 EXPECT_NEAR(tmp.x(), 1.0f, 0.001f); 136 EXPECT_NEAR(tmp.x(), 1.0f, kEpsilon);
136 EXPECT_NEAR(tmp.y(), 0.0f, 0.001f); 137 EXPECT_NEAR(tmp.y(), 0.0f, kEpsilon);
137 EXPECT_NEAR(tmp.z(), 0.0f, 0.001f); 138 EXPECT_NEAR(tmp.z(), 0.0f, kEpsilon);
138 139
139 tmp = ColorTransform::TriStim(0.0f, 1.0f, 0.0f); 140 tmp = ColorTransform::TriStim(0.0f, 1.0f, 0.0f);
140 t->transform(&tmp, 1); 141 t->transform(&tmp, 1);
141 EXPECT_NEAR(tmp.x(), 0.0f, 0.001f); 142 EXPECT_NEAR(tmp.x(), 0.0f, kEpsilon);
142 EXPECT_NEAR(tmp.y(), 1.0f, 0.001f); 143 EXPECT_NEAR(tmp.y(), 1.0f, kEpsilon);
143 EXPECT_NEAR(tmp.z(), 0.0f, 0.001f); 144 EXPECT_NEAR(tmp.z(), 0.0f, kEpsilon);
144 145
145 tmp = ColorTransform::TriStim(0.0f, 0.0f, 1.0f); 146 tmp = ColorTransform::TriStim(0.0f, 0.0f, 1.0f);
146 t->transform(&tmp, 1); 147 t->transform(&tmp, 1);
147 EXPECT_NEAR(tmp.x(), 0.0f, 0.001f); 148 EXPECT_NEAR(tmp.x(), 0.0f, kEpsilon);
148 EXPECT_NEAR(tmp.y(), 0.0f, 0.001f); 149 EXPECT_NEAR(tmp.y(), 0.0f, kEpsilon);
149 EXPECT_NEAR(tmp.z(), 1.0f, 0.001f); 150 EXPECT_NEAR(tmp.z(), 1.0f, kEpsilon);
150 } 151 }
151 152
152 TEST(SimpleColorSpace, UnknownToSRGB) { 153 TEST(SimpleColorSpace, UnknownToSRGB) {
153 ColorSpace unknown; 154 ColorSpace unknown;
154 ColorSpace sRGB = ColorSpace::CreateSRGB(); 155 ColorSpace sRGB = ColorSpace::CreateSRGB();
155 std::unique_ptr<ColorTransform> t(ColorTransform::NewColorTransform( 156 std::unique_ptr<ColorTransform> t(ColorTransform::NewColorTransform(
156 unknown, sRGB, ColorTransform::Intent::INTENT_PERCEPTUAL)); 157 unknown, sRGB, ColorTransform::Intent::INTENT_PERCEPTUAL));
157 158
158 ColorTransform::TriStim tmp(16.0f / 255.0f, 0.5f, 0.5f); 159 ColorTransform::TriStim tmp(16.0f / 255.0f, 0.5f, 0.5f);
159 t->transform(&tmp, 1); 160 t->transform(&tmp, 1);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 277
277 INSTANTIATE_TEST_CASE_P( 278 INSTANTIATE_TEST_CASE_P(
278 C, 279 C,
279 ColorSpaceTest, 280 ColorSpaceTest,
280 testing::Combine(testing::ValuesIn(all_primaries), 281 testing::Combine(testing::ValuesIn(all_primaries),
281 testing::Values(ColorSpace::TransferID::BT709), 282 testing::Values(ColorSpace::TransferID::BT709),
282 testing::ValuesIn(all_matrices), 283 testing::ValuesIn(all_matrices),
283 testing::ValuesIn(all_ranges), 284 testing::ValuesIn(all_ranges),
284 testing::ValuesIn(intents))); 285 testing::ValuesIn(intents)));
285 } // namespace 286 } // namespace
OLDNEW
« ui/gfx/color_transform.cc ('K') | « ui/gfx/color_transform.cc ('k') | ui/gfx/icc_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698