@@ -10,129 +10,137 @@ namespace OCIO = OCIO_NAMESPACE;
10
10
11
11
OCIO_ADD_TEST (GradingHueCurveOpData, accessors)
12
12
{
13
- // Create GradingRGBCurveOpData and check values. Changes them and check.
14
- // OCIO::GradingHueCurveOpData gc;
15
-
16
- // static constexpr char expected[]{ "log forward "
17
- // "<red=<control_points=[<x=0, y=0><x=0.5, y=0.5><x=1, y=1>]>, "
18
- // "green=<control_points=[<x=0, y=0><x=0.5, y=0.5><x=1, y=1>]>, "
19
- // "blue=<control_points=[<x=0, y=0><x=0.5, y=0.5><x=1, y=1>]>, "
20
- // "master=<control_points=[<x=0, y=0><x=0.5, y=0.5><x=1, y=1>]>>" };
21
- // OCIO_CHECK_EQUAL(gc.getCacheID(), expected);
22
-
23
- // OCIO_CHECK_EQUAL(gc.getStyle(), OCIO::GRADING_LOG);
24
- // auto curves = gc.getValue();
25
- // OCIO_REQUIRE_ASSERT(curves);
26
- // OCIO_CHECK_ASSERT(curves->isIdentity());
27
- // OCIO_CHECK_ASSERT(gc.isIdentity());
28
- // OCIO_CHECK_ASSERT(gc.isNoOp());
29
- // OCIO_CHECK_ASSERT(!gc.hasChannelCrosstalk());
30
- // OCIO_CHECK_ASSERT(!gc.getBypassLinToLog());
13
+ // Create GradingHueCurveOpData and check values. Changes them and check.
14
+ OCIO::GradingHueCurveOpData gc ( OCIO::GRADING_LOG );
15
+
16
+ static constexpr char expected[]{ " log forward "
17
+ " <hue_hue=<control_points=[<x=0, y=0><x=0.1666667, y=0.1666667><x=0.3333333, y=0.3333333><x=0.5, y=0.5><x=0.6666667, y=0.6666667><x=0.8333333, y=0.8333333>]>, "
18
+ " hue_sat=<control_points=[<x=0, y=1><x=0.1666667, y=1><x=0.3333333, y=1><x=0.5, y=1><x=0.6666667, y=1><x=0.8333333, y=1>]>, "
19
+ " hue_lum=<control_points=[<x=0, y=1><x=0.1666667, y=1><x=0.3333333, y=1><x=0.5, y=1><x=0.6666667, y=1><x=0.8333333, y=1>]>, "
20
+ " lum_sat=<control_points=[<x=0, y=1><x=0.5, y=1><x=1, y=1>]>, "
21
+ " sat_sat=<control_points=[<x=0, y=0><x=0.5, y=0.5><x=1, y=1>]>, "
22
+ " lum_lum=<control_points=[<x=0, y=0><x=0.5, y=0.5><x=1, y=1>]>, "
23
+ " sat_lum=<control_points=[<x=0, y=1><x=0.5, y=1><x=1, y=1>]>, "
24
+ " hue_fx=<control_points=[<x=0, y=0><x=0.1666667, y=0><x=0.3333333, y=0><x=0.5, y=0><x=0.6666667, y=0><x=0.8333333, y=0>]>>" };
25
+ OCIO_CHECK_EQUAL (gc.getCacheID (), expected);
26
+
27
+ OCIO_CHECK_EQUAL (gc.getStyle (), OCIO::GRADING_LOG);
28
+ auto curves = gc.getValue ();
29
+ OCIO_REQUIRE_ASSERT (curves);
30
+ OCIO_CHECK_ASSERT (curves->isIdentity ());
31
+ OCIO_CHECK_ASSERT (gc.isIdentity ());
32
+ OCIO_CHECK_ASSERT (gc.isNoOp ());
33
+ OCIO_CHECK_ASSERT (!gc.hasChannelCrosstalk ());
34
+ OCIO_CHECK_ASSERT (!gc.getBypassLinToLog ());
31
35
32
- // gc.setStyle(OCIO::GRADING_LIN);
33
- // OCIO_CHECK_EQUAL(gc.getStyle(), OCIO::GRADING_LIN);
34
- // gc.setBypassLinToLog(true);
35
- // OCIO_CHECK_ASSERT(gc.getBypassLinToLog());
36
+ gc.setStyle (OCIO::GRADING_LIN);
37
+ OCIO_CHECK_EQUAL (gc.getStyle (), OCIO::GRADING_LIN);
38
+ gc.setBypassLinToLog (true );
39
+ OCIO_CHECK_ASSERT (gc.getBypassLinToLog ());
36
40
37
41
// Get dynamic property as a generic dynamic property and as a type one and verify they are
38
42
// the same and can be made dynamic.
39
- // OCIO_CHECK_ASSERT(!gc.isDynamic());
40
- // auto dp = gc.getDynamicProperty();
41
- // OCIO_REQUIRE_ASSERT(dp);
42
- // OCIO_CHECK_EQUAL(dp->getType(), OCIO::DYNAMIC_PROPERTY_GRADING_RGBCURVE );
43
- // auto dpImpl = gc.getDynamicPropertyInternal();
44
- // OCIO_REQUIRE_ASSERT(dpImpl);
45
- // OCIO_CHECK_ASSERT(dp == dpImpl);
46
- // OCIO_CHECK_ASSERT(!dpImpl->isDynamic());
47
- // dpImpl->makeDynamic();
48
- // OCIO_CHECK_ASSERT(gc.isDynamic());
49
- //
50
- // OCIO_CHECK_EQUAL(gc.getDirection(), OCIO::TRANSFORM_DIR_FORWARD);
51
- // gc.setDirection(OCIO::TRANSFORM_DIR_INVERSE);
52
- // OCIO_CHECK_EQUAL(gc.getDirection(), OCIO::TRANSFORM_DIR_INVERSE);
43
+ OCIO_CHECK_ASSERT (!gc.isDynamic ());
44
+ auto dp = gc.getDynamicProperty ();
45
+ OCIO_REQUIRE_ASSERT (dp);
46
+ OCIO_CHECK_EQUAL (dp->getType (), OCIO::DYNAMIC_PROPERTY_GRADING_HUECURVE );
47
+ auto dpImpl = gc.getDynamicPropertyInternal ();
48
+ OCIO_REQUIRE_ASSERT (dpImpl);
49
+ OCIO_CHECK_ASSERT (dp == dpImpl);
50
+ OCIO_CHECK_ASSERT (!dpImpl->isDynamic ());
51
+ dpImpl->makeDynamic ();
52
+ OCIO_CHECK_ASSERT (gc.isDynamic ());
53
+
54
+ OCIO_CHECK_EQUAL (gc.getDirection (), OCIO::TRANSFORM_DIR_FORWARD);
55
+ gc.setDirection (OCIO::TRANSFORM_DIR_INVERSE);
56
+ OCIO_CHECK_EQUAL (gc.getDirection (), OCIO::TRANSFORM_DIR_INVERSE);
53
57
54
58
// Test operator==.
55
- // OCIO::GradingHueCurveOpData gc1{};
56
- // OCIO::GradingHueCurveOpData gc2{};
57
- //
58
- // OCIO_CHECK_ASSERT(gc1 == gc2);
59
- // gc1.setDirection(OCIO::TRANSFORM_DIR_INVERSE);
60
- // OCIO_CHECK_ASSERT(!(gc1 == gc2));
61
- // gc2.setDirection(OCIO::TRANSFORM_DIR_INVERSE);
62
- // OCIO_CHECK_ASSERT(gc1 == gc2);
63
-
64
- // gc1.setStyle(OCIO::GRADING_LOG);
65
- // OCIO_CHECK_ASSERT(!(gc1 == gc2));
66
- // gc2.setStyle(OCIO::GRADING_LOG);
67
- // OCIO_CHECK_ASSERT(gc1 == gc2);
68
- //
69
- // auto v1 = gc1.getValue()->createEditableCopy();
70
- // auto red = v1->getCurve(OCIO::RGB_RED );
71
- // red ->setNumControlPoints(4);
72
- // red ->getControlPoint(3).m_x = red ->getControlPoint(2).m_x + 1.f;
73
- // red ->getControlPoint(3).m_y = red ->getControlPoint(2).m_y + 0.5f;
74
- // gc1.setValue(v1);
75
- // OCIO_CHECK_ASSERT(!(gc1 == gc2));
76
- // auto v2 = gc2.getValue()->createEditableCopy();
77
- // auto red2 = v2->getCurve(OCIO::RGB_RED );
78
- // red2 ->setNumControlPoints(4);
79
- // red2 ->getControlPoint(3).m_x = red2 ->getControlPoint(2).m_x + 1.f;
80
- // red2 ->getControlPoint(3).m_y = red2 ->getControlPoint(2).m_y + 0.5f;
81
- // gc2.setValue(v2);
82
- // OCIO_CHECK_ASSERT(gc1 == gc2);
83
- //
84
- // gc1.setSlope(OCIO::RGB_BLUE , 2, 0.9f);
85
- // OCIO_CHECK_EQUAL(gc1.getSlope(OCIO::RGB_BLUE , 2), 0.9f);
86
- // OCIO_CHECK_ASSERT(gc1.slopesAreDefault(OCIO::RGB_GREEN ));
87
- // OCIO_CHECK_ASSERT(!gc1.slopesAreDefault(OCIO::RGB_BLUE ));
88
- //
89
- // OCIO_CHECK_EQUAL(gc1.isIdentity(), false);
90
- // OCIO_CHECK_ASSERT(!gc1.hasChannelCrosstalk());
91
- //
92
- // // Check isInverse.
93
- //
94
- // // We have equal ops, inverse one.
95
- // gc1.setDirection(OCIO::TRANSFORM_DIR_FORWARD);
96
- // // Need a shared pointer for the parameter.
97
- // OCIO::ConstGradingRGBCurveOpDataRcPtr gcptr2 = gc1.clone();
98
- // gc1.setDirection(OCIO::TRANSFORM_DIR_INVERSE);
99
- // OCIO_CHECK_ASSERT(gc1.isInverse(gcptr2));
100
- // // Change value of one: no longer inverse.
101
- // red ->getControlPoint(3).m_y += 0.1f;
102
- // gc1.setValue(v1);
103
- // OCIO_CHECK_ASSERT(!gc1.isInverse(gcptr2));
104
- // // Restore value.
105
- // red ->getControlPoint(3).m_y -= 0.1f;
106
- // gc1.setValue(v1);
107
- // OCIO_CHECK_ASSERT(gc1.isInverse(gcptr2));
108
- // // Change direction: no longer inverse.
109
- // gc1.setDirection(OCIO::TRANSFORM_DIR_FORWARD);
110
- // OCIO_CHECK_ASSERT(!gc1.isInverse(gcptr2));
59
+ OCIO::GradingHueCurveOpData gc1{ OCIO::GRADING_LIN };
60
+ OCIO::GradingHueCurveOpData gc2{ OCIO::GRADING_LIN };
61
+
62
+ OCIO_CHECK_ASSERT (gc1 == gc2);
63
+ gc1.setDirection (OCIO::TRANSFORM_DIR_INVERSE);
64
+ OCIO_CHECK_ASSERT (!(gc1 == gc2));
65
+ gc2.setDirection (OCIO::TRANSFORM_DIR_INVERSE);
66
+ OCIO_CHECK_ASSERT (gc1 == gc2);
67
+
68
+ gc1.setStyle (OCIO::GRADING_LOG);
69
+ OCIO_CHECK_ASSERT (!(gc1 == gc2));
70
+ gc2.setStyle (OCIO::GRADING_LOG);
71
+ OCIO_CHECK_ASSERT (gc1 == gc2);
72
+
73
+ auto v1 = gc1.getValue ()->createEditableCopy ();
74
+ auto hueHue = v1->getCurve (OCIO::HUE_HUE );
75
+ hueHue ->setNumControlPoints (4 );
76
+ hueHue ->getControlPoint (3 ).m_x = hueHue ->getControlPoint (2 ).m_x + 1 .f ;
77
+ hueHue ->getControlPoint (3 ).m_y = hueHue ->getControlPoint (2 ).m_y + 0 .5f ;
78
+ gc1.setValue (v1);
79
+ OCIO_CHECK_ASSERT (!(gc1 == gc2));
80
+ auto v2 = gc2.getValue ()->createEditableCopy ();
81
+ auto hueHue2 = v2->getCurve (OCIO::HUE_HUE );
82
+ hueHue2 ->setNumControlPoints (4 );
83
+ hueHue2 ->getControlPoint (3 ).m_x = hueHue2 ->getControlPoint (2 ).m_x + 1 .f ;
84
+ hueHue2 ->getControlPoint (3 ).m_y = hueHue2 ->getControlPoint (2 ).m_y + 0 .5f ;
85
+ gc2.setValue (v2);
86
+ OCIO_CHECK_ASSERT (gc1 == gc2);
87
+
88
+ gc1.setSlope (OCIO::HUE_SAT , 2 , 0 .9f );
89
+ OCIO_CHECK_EQUAL (gc1.getSlope (OCIO::HUE_SAT , 2 ), 0 .9f );
90
+ OCIO_CHECK_ASSERT (gc1.slopesAreDefault (OCIO::HUE_LUM ));
91
+ OCIO_CHECK_ASSERT (!gc1.slopesAreDefault (OCIO::HUE_SAT ));
92
+
93
+ OCIO_CHECK_EQUAL (gc1.isIdentity (), false );
94
+ OCIO_CHECK_ASSERT (!gc1.hasChannelCrosstalk ());
95
+
96
+ // Check isInverse.
97
+
98
+ // We have equal ops, inverse one.
99
+ gc1.setDirection (OCIO::TRANSFORM_DIR_FORWARD);
100
+ // Need a shared pointer for the parameter.
101
+ OCIO::ConstGradingHueCurveOpDataRcPtr gcptr2 = gc1.clone ();
102
+ gc1.setDirection (OCIO::TRANSFORM_DIR_INVERSE);
103
+ OCIO_CHECK_ASSERT (gc1.isInverse (gcptr2));
104
+ // Change value of one: no longer inverse.
105
+ hueHue ->getControlPoint (3 ).m_y += 0 .1f ;
106
+ gc1.setValue (v1);
107
+ OCIO_CHECK_ASSERT (!gc1.isInverse (gcptr2));
108
+ // Restore value.
109
+ hueHue ->getControlPoint (3 ).m_y -= 0 .1f ;
110
+ gc1.setValue (v1);
111
+ OCIO_CHECK_ASSERT (gc1.isInverse (gcptr2));
112
+ // Change direction: no longer inverse.
113
+ gc1.setDirection (OCIO::TRANSFORM_DIR_FORWARD);
114
+ OCIO_CHECK_ASSERT (!gc1.isInverse (gcptr2));
111
115
}
112
116
113
117
OCIO_ADD_TEST (GradingHueCurveOpData, validate)
114
118
{
115
119
// Default is valid.
116
- // OCIO::GradingHueCurveOpData gc;
117
- // OCIO_CHECK_NO_THROW(gc.validate());
120
+ OCIO::GradingHueCurveOpData gc{ OCIO::GRADING_LOG } ;
121
+ OCIO_CHECK_NO_THROW (gc.validate ());
118
122
119
123
// Curves with a single control point are not valid.
120
- // auto curve = OCIO::GradingBSplineCurve::Create(1);
121
- // auto curves = OCIO::GradingRGBCurve::Create(curve, curve, curve, curve);
122
- // OCIO_CHECK_THROW_WHAT(gc.setValue(curves), OCIO::Exception,
123
- // "There must be at least 2 control points.");
124
- //
125
- // // Curve x coordinates have to increase.
126
- // curve = OCIO::GradingBSplineCurve::Create({ { 0.f,0.f },{ 0.7f,0.3f },
127
- // { 0.5f,0.7f },{ 1.f,1.f } });
128
- // curves = OCIO::GradingRGBCurve::Create(curve, curve, curve, curve);
129
- // OCIO_CHECK_THROW_WHAT(gc.setValue(curves), OCIO::Exception,
130
- // "has a x coordinate '0.5' that is less from previous control "
131
- // "point x cooordinate '0.7'.");
132
- //
133
- // // Fix the curve x coordinate.
134
- // curve->getControlPoint(1).m_x = 0.3f;
135
- // curves = OCIO::GradingRGBCurve::Create(curve, curve, curve, curve);
136
- // OCIO_CHECK_NO_THROW(gc.setValue(curves));
137
- // OCIO_CHECK_NO_THROW(gc.validate());
124
+ auto curve = OCIO::GradingBSplineCurve::Create (1 );
125
+ OCIO::GradingHueCurves curvesStruct{curve, curve, curve, curve, curve, curve, curve, curve};
126
+ auto curves = OCIO::GradingHueCurve::Create (curvesStruct);
127
+ OCIO_CHECK_THROW_WHAT (gc.setValue (curves), OCIO::Exception,
128
+ " There must be at least 2 control points." );
129
+
130
+ // Curve x coordinates have to increase.
131
+ curve = OCIO::GradingBSplineCurve::Create ({ { 0 .f ,0 .f },{ 0 .7f ,0 .3f },
132
+ { 0 .5f ,0 .7f },{ 1 .f ,1 .f } });
133
+
134
+ curvesStruct = OCIO::GradingHueCurves{curve, curve, curve, curve, curve, curve, curve, curve};
135
+ curves = OCIO::GradingHueCurve::Create (curvesStruct);
136
+ OCIO_CHECK_THROW_WHAT (gc.setValue (curves), OCIO::Exception,
137
+ " has a x coordinate '0.5' that is less from previous control "
138
+ " point x cooordinate '0.7'." );
139
+
140
+ // Fix the curve x coordinate.
141
+ curve->getControlPoint (1 ).m_x = 0 .3f ;
142
+ curvesStruct = OCIO::GradingHueCurves{curve, curve, curve, curve, curve, curve, curve, curve};
143
+ curves = OCIO::GradingHueCurve::Create (curvesStruct);
144
+ OCIO_CHECK_NO_THROW (gc.setValue (curves));
145
+ OCIO_CHECK_NO_THROW (gc.validate ());
138
146
}
0 commit comments