diff options
author | Mike Klein <mtklein@chromium.org> | 2018-04-12 09:21:02 -0400 |
---|---|---|
committer | Mike Klein <mtklein@chromium.org> | 2018-04-12 14:07:02 +0000 |
commit | 7b67b4af1fcfa76a0551f9055d2b6336c1a66b75 (patch) | |
tree | 095fc2166d1d68ee924c43f0d72b81dfddf97507 | |
parent | c6c5eade823a399efc1671c2c7f1bc278273d2d5 (diff) |
skcms→1654786 concat gamut transform matrices together
No-Tree-Checks: true
Change-Id: Ibfbbfe35caf9e2ed8a80aa9add2c4cae50585120
Reviewed-on: https://skia-review.googlesource.com/120997
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
-rw-r--r-- | third_party/skcms/src/Transform.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/third_party/skcms/src/Transform.c b/third_party/skcms/src/Transform.c index 1f46e35f75..7428ea6be4 100644 --- a/third_party/skcms/src/Transform.c +++ b/third_party/skcms/src/Transform.c @@ -301,6 +301,17 @@ static size_t bytes_per_pixel(skcms_PixelFormat fmt) { return 0; } +static skcms_Matrix3x3 concat_3x3(const skcms_Matrix3x3* A, const skcms_Matrix3x3* B) { + skcms_Matrix3x3 m = {{ {0,0,0}, {0,0,0}, {0,0,0} }}; + for (int r = 0; r < 3; r++) + for (int c = 0; c < 3; c++) { + m.vals[r][c] = A->vals[r][0] * B->vals[0][c] + + A->vals[r][1] * B->vals[1][c] + + A->vals[r][2] * B->vals[2][c]; + } + return m; +} + bool skcms_Transform(const void* src, skcms_PixelFormat srcFmt, skcms_AlphaFormat srcAlpha, @@ -467,9 +478,11 @@ bool skcms_Transform(const void* src, if (!skcms_Matrix3x3_invert(&dstProfile->toXYZD50, &from_xyz)) { return false; } - // TODO: concat these here and only append one matrix_3x3 op. - *ops++ = Op_matrix_3x3; *args++ = to_xyz; - *ops++ = Op_matrix_3x3; *args++ = &from_xyz; + // Concat the entire gamut transform into from_xyz, + // now slightly misnamed but it's a handy spot to stash the result. + from_xyz = concat_3x3(&from_xyz, to_xyz); + *ops++ = Op_matrix_3x3; + *args++ = &from_xyz; } // Encode back to dst RGB using its parametric transfer functions. |