Chromium Code Reviews| Index: third_party/qcms/src/transform.c |
| diff --git a/third_party/qcms/src/transform.c b/third_party/qcms/src/transform.c |
| index 9fd82389f84c0aef8a0515a6f4616836c9df1b43..947f1fad00df069388314fecbe31e1bca6eb5ba1 100644 |
| --- a/third_party/qcms/src/transform.c |
| +++ b/third_party/qcms/src/transform.c |
| @@ -1167,6 +1167,69 @@ qcms_transform* qcms_transform_precacheLUT_float(qcms_transform *transform, qcms |
| return transform; |
| } |
| +qcms_bool qcms_transform_create_color_cube_skia(qcms_profile *in, qcms_profile *out, |
| + int samples, unsigned char* cube) |
| +{ |
| + uint16_t z,y,x; |
| + uint32_t l,index; |
| + uint32_t lutSize = 3 * samples * samples * samples; |
| + |
| + float* src = NULL; |
| + float* dest = NULL; |
| + float* lut = NULL; |
| + float inverse; |
| + |
| + src = malloc(lutSize*sizeof(float)); |
| + dest = malloc(lutSize*sizeof(float)); |
| + |
| + if (src && dest) { |
| + /* Prepare a list of points we want to sample: z, y, x order */ |
| + l = 0; |
| + inverse = 1 / (float)(samples-1); |
| + for (z = 0; z < samples; z++) { |
| + for (y = 0; y < samples; y++) { |
| + for (x = 0; x < samples; x++) { |
| + src[l++] = x * inverse; // r |
| + src[l++] = y * inverse; // g |
| + src[l++] = z * inverse; // b |
| + } |
| + } |
| + } |
| + |
| + lut = qcms_chain_transform(in, out, src, dest, lutSize); |
| + |
| + if (lut) { |
| + index = l = 0; |
| + for (z = 0; z < samples; z++) { |
| + for (y = 0; y < samples; y++) { |
| + for (x = 0; x < samples; x++) { |
| + cube[index++] = (int)floorf(lut[l + 2] * 255.0f + 0.5f); // b |
|
Ken Russell (switch to Gerrit)
2015/02/04 22:23:05
Not sure, but I thought the way to do this convers
Noel Gordon
2015/02/05 16:28:52
Interesting thought, not sure of the correct answe
Ken Russell (switch to Gerrit)
2015/02/06 02:49:54
My understanding is that the formulation above (mu
Mike Lawther (Google)
2015/02/06 03:20:06
My understanding was the same as Ken's. With "mult
Ken Russell (switch to Gerrit)
2015/02/06 03:31:35
That's correct. The unsigned conversions were unch
|
| + cube[index++] = (int)floorf(lut[l + 1] * 255.0f + 0.5f); // g |
| + cube[index++] = (int)floorf(lut[l + 0] * 255.0f + 0.5f); // r |
| + cube[index++] = 255; // a |
| + l += 3; |
| + } |
| + } |
| + } |
| + } |
| + } |
| + |
| + // XXX: qcms_modular_transform_data may return the lut data in either the src or |
| + // dest buffer so free src, dest, and lut with care. |
| + |
| + if (src && lut != src) |
| + free(src); |
| + if (dest && lut != dest) |
| + free(dest); |
| + |
| + if (lut) { |
| + free(lut); |
| + return true; |
| + } |
| + |
| + return false; |
| +} |
| + |
| #define NO_MEM_TRANSFORM NULL |
| qcms_transform* qcms_transform_create( |