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

Unified Diff: ui/gfx/color_transform_unittest.cc

Issue 2663453002: Revert of 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/color_transform.cc ('k') | ui/gfx/icc_profile.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/color_transform_unittest.cc
diff --git a/ui/gfx/color_transform_unittest.cc b/ui/gfx/color_transform_unittest.cc
index 63ba82a8bf6942222f6bd9134bc3f92c6cdcb4c2..c99268783bc50098e47e990d0e381da989ad52bf 100644
--- a/ui/gfx/color_transform_unittest.cc
+++ b/ui/gfx/color_transform_unittest.cc
@@ -13,7 +13,10 @@
namespace gfx {
// Internal functions, exposted for testing.
+GFX_EXPORT Transform GetPrimaryMatrix(ColorSpace::PrimaryID id);
GFX_EXPORT Transform GetTransferMatrix(ColorSpace::MatrixID id);
+GFX_EXPORT float ToLinear(ColorSpace::TransferID id, float v);
+GFX_EXPORT float FromLinear(ColorSpace::TransferID id, float v);
ColorSpace::PrimaryID all_primaries[] = {
ColorSpace::PrimaryID::BT709, ColorSpace::PrimaryID::BT470M,
@@ -114,7 +117,6 @@
ICCProfile srgb_icc = ICCProfileForTestingSRGB();
ColorSpace sRGB = srgb_icc.GetColorSpace();
ColorSpace sRGB2 = sRGB;
- const float kEpsilon = 1.5f / 255.f;
// Prevent sRGB2 from using a cached ICC profile.
sRGB2.icc_profile_id_ = 0;
@@ -124,27 +126,27 @@
ColorTransform::TriStim tmp(1.0f, 1.0f, 1.0f);
t->transform(&tmp, 1);
- EXPECT_NEAR(tmp.x(), 1.0f, kEpsilon);
- EXPECT_NEAR(tmp.y(), 1.0f, kEpsilon);
- EXPECT_NEAR(tmp.z(), 1.0f, kEpsilon);
+ EXPECT_NEAR(tmp.x(), 1.0f, 0.001f);
+ EXPECT_NEAR(tmp.y(), 1.0f, 0.001f);
+ EXPECT_NEAR(tmp.z(), 1.0f, 0.001f);
tmp = ColorTransform::TriStim(1.0f, 0.0f, 0.0f);
t->transform(&tmp, 1);
- EXPECT_NEAR(tmp.x(), 1.0f, kEpsilon);
- EXPECT_NEAR(tmp.y(), 0.0f, kEpsilon);
- EXPECT_NEAR(tmp.z(), 0.0f, kEpsilon);
+ EXPECT_NEAR(tmp.x(), 1.0f, 0.001f);
+ EXPECT_NEAR(tmp.y(), 0.0f, 0.001f);
+ EXPECT_NEAR(tmp.z(), 0.0f, 0.001f);
tmp = ColorTransform::TriStim(0.0f, 1.0f, 0.0f);
t->transform(&tmp, 1);
- EXPECT_NEAR(tmp.x(), 0.0f, kEpsilon);
- EXPECT_NEAR(tmp.y(), 1.0f, kEpsilon);
- EXPECT_NEAR(tmp.z(), 0.0f, kEpsilon);
+ EXPECT_NEAR(tmp.x(), 0.0f, 0.001f);
+ EXPECT_NEAR(tmp.y(), 1.0f, 0.001f);
+ EXPECT_NEAR(tmp.z(), 0.0f, 0.001f);
tmp = ColorTransform::TriStim(0.0f, 0.0f, 1.0f);
t->transform(&tmp, 1);
- EXPECT_NEAR(tmp.x(), 0.0f, kEpsilon);
- EXPECT_NEAR(tmp.y(), 0.0f, kEpsilon);
- EXPECT_NEAR(tmp.z(), 1.0f, kEpsilon);
+ EXPECT_NEAR(tmp.x(), 0.0f, 0.001f);
+ EXPECT_NEAR(tmp.y(), 0.0f, 0.001f);
+ EXPECT_NEAR(tmp.z(), 1.0f, 0.001f);
}
TEST(SimpleColorSpace, UnknownToSRGB) {
@@ -171,6 +173,18 @@
EXPECT_GT(tmp.z(), tmp.x());
EXPECT_GT(tmp.z(), tmp.y());
}
+
+class PrimaryTest : public testing::TestWithParam<ColorSpace::PrimaryID> {};
+
+TEST_P(PrimaryTest, checkInvertible) {
+ EXPECT_EQ(GetPrimaryMatrix(GetParam()).matrix().get(3, 3), 1.0f);
+ // Check that all primary matrices are invertable.
+ EXPECT_TRUE(GetPrimaryMatrix(GetParam()).IsInvertible());
+}
+
+INSTANTIATE_TEST_CASE_P(ColorSpace,
+ PrimaryTest,
+ testing::ValuesIn(all_primaries));
class MatrixTest : public testing::TestWithParam<ColorSpace::MatrixID> {};
@@ -188,8 +202,8 @@
TEST_P(TransferTest, basicTest) {
for (float x = 0.0f; x <= 1.0f; x += 1.0f / 128.0f) {
- float linear = ColorTransform::ToLinearForTesting(GetParam(), x);
- float x2 = ColorTransform::FromLinearForTesting(GetParam(), linear);
+ float linear = ToLinear(GetParam(), x);
+ float x2 = FromLinear(GetParam(), linear);
EXPECT_NEAR(x, x2, 0.001f);
}
}
« no previous file with comments | « 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