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>
This commit is contained in:
Mike Klein 2018-04-12 09:21:02 -04:00
parent c6c5eade82
commit 7b67b4af1f

View File

@ -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.