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

Unified Diff: ui/gfx/color_transform_unittest.cc

Issue 2559273002: color: general transformation -> affine transformation
Patch Set: Created 4 years 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') | no next file » | 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 3c4364bcb9b45e27bfe0826ac7db8a2a712f95d8..67183a532a429e527caee9eace11219dc491604c 100644
--- a/ui/gfx/color_transform_unittest.cc
+++ b/ui/gfx/color_transform_unittest.cc
@@ -83,6 +83,35 @@ TEST(SimpleColorSpace, BT709toSRGB) {
EXPECT_GT(tmp.z(), tmp.y());
}
+TEST(SimpleColorSpace, GetAffineApproximation) {
+ // Two linear color spaces, result should be a perfect translation.
+ ColorSpace from_colorspace(
+ ColorSpace::PrimaryID::BT709, ColorSpace::TransferID::LINEAR,
+ ColorSpace::MatrixID::BT709, ColorSpace::RangeID::FULL);
+ ColorSpace to_colorspace(
+ ColorSpace::PrimaryID::BT2020, ColorSpace::TransferID::LINEAR,
+ ColorSpace::MatrixID::RGB, ColorSpace::RangeID::FULL);
+
+ std::unique_ptr<ColorTransform> t(ColorTransform::NewColorTransform(
+ from_colorspace, to_colorspace, ColorTransform::Intent::INTENT_ABSOLUTE));
+ Transform transform;
+ EXPECT_TRUE(t->GetAffineApproximation(&transform));
+
+ for (int x = 0; x <= 2; x++) {
+ for (int y = 0; y <= 2; y++) {
+ for (int z = 0; z <= 2; z++) {
+ ColorTransform::TriStim A(x / 2.0f, y / 2.0f, z / 2.0f);
+ ColorTransform::TriStim B(A);
+ t->transform(&A, 1);
+ transform.TransformPoint(&B);
+ EXPECT_NEAR(A.x(), B.x(), 0.001);
+ EXPECT_NEAR(A.y(), B.y(), 0.001);
+ EXPECT_NEAR(A.z(), B.z(), 0.001);
+ }
+ }
+ }
+}
+
unsigned char srgb_icc_data[] = {
0x00, 0x00, 0x0b, 0xe8, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20,
« 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