Skip to content

Commit 545bc05

Browse files
meshulapixar-oss
authored andcommitted
Fix matrix mult order for GfColor constructor
(Internal change: 2367351)
1 parent 395374f commit 545bc05

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

pxr/base/gf/nc/nanocolor.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ NcRGB NcTransformColor(const NcColorSpace* dst, const NcColorSpace* src, NcRGB r
511511
return rgb;
512512
}
513513

514-
NcM33f tx = _M33fMultiply(NcGetRGBToXYZMatrix(src),
515-
NcGetXYZToRGBMatrix(dst));
514+
NcM33f tx = _M33fMultiply(NcGetRGBToXYZMatrix(dst),
515+
NcGetXYZToRGBMatrix(src));
516516

517517
// if the source color space indicates a curve remove it.
518518
rgb.r = _ToLinear(src, rgb.r);
@@ -536,8 +536,8 @@ void NcTransformColors(const NcColorSpace* dst, const NcColorSpace* src, NcRGB*
536536
if (!dst || !src || !rgb)
537537
return;
538538

539-
NcM33f tx = _M33fMultiply(NcGetRGBToXYZMatrix(src),
540-
NcGetXYZToRGBMatrix(dst));
539+
NcM33f tx = _M33fMultiply(NcGetRGBToXYZMatrix(dst),
540+
NcGetXYZToRGBMatrix(src));
541541

542542
// if the source color space indicates a curve remove it.
543543
for (size_t i = 0; i < count; i++) {
@@ -629,8 +629,8 @@ void NcTransformColorsWithAlpha(const NcColorSpace* dst, const NcColorSpace* src
629629
if (!dst || !src || !rgba)
630630
return;
631631

632-
NcM33f tx = _M33fMultiply(NcGetRGBToXYZMatrix(src),
633-
NcGetXYZToRGBMatrix(dst));
632+
NcM33f tx = _M33fMultiply(NcGetRGBToXYZMatrix(dst),
633+
NcGetXYZToRGBMatrix(src));
634634

635635
// if the source color space indicates a curve remove it.
636636
for (size_t i = 0; i < count; i++) {

pxr/base/gf/testenv/testGfColorCpp.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,19 @@ main(int argc, char *argv[])
204204
TF_AXIOM(colG22Rec709.GetColorSpace() == csG22Rec709);
205205

206206
TF_AXIOM(colLinRec709.GetColorSpace() == csLinearRec709);
207-
GfColorTest colSRGB_2(colLinRec709, csSRGB);
208-
GfVec2f xy1 = colG22Rec709.GetChromaticity();
209-
GfVec2f xy2 = colSRGB_2.GetChromaticity();
210-
TF_AXIOM(GfIsClose(xy1, xy2, 1e-5f));
207+
const GfColorTest colSRGB_2(colLinRec709, csSRGB);
208+
const GfVec2f chromaRec709 = colG22Rec709.GetChromaticity();
209+
const GfVec2f chromaRec709_2 = colSRGB_2.GetChromaticity();
210+
TF_AXIOM(GfIsClose(chromaRec709, chromaRec709_2, 1e-5f));
211+
211212
GfColorTest colAp0(colSRGB_2, csAp0);
212-
GfVec2f xy3 = colAp0.GetChromaticity();
213-
TF_AXIOM(GfIsClose(xy1, xy3, 3e-2f));
213+
const GfVec2f chroma_AP0 = colAp0.GetChromaticity();
214214
GfColorTest colSRGB_3(colAp0, csSRGB);
215-
GfVec2f xy4 = colAp0.GetChromaticity();
216-
TF_AXIOM(GfIsClose(xy1, xy4, 3e-2f));
217215
GfColorTest col_SRGBP3(colSRGB_3, csSRGBP3);
218-
GfVec2f xy5 = col_SRGBP3.GetChromaticity();
219-
TF_AXIOM(GfIsClose(xy1, xy5, 3e-2f));
216+
217+
GfColorTest colToAp0(col_SRGBP3, csAp0);
218+
const GfVec2f xy6 = colToAp0.GetChromaticity();
219+
TF_AXIOM(GfIsClose(chroma_AP0, xy6, 3e-2f));
220220

221221
// all the way back to rec709
222222
GfColorTest colLinRec709_2(col_SRGBP3, csLinearRec709);

0 commit comments

Comments
 (0)