OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkColorSpace.h" | 8 #include "SkColorSpace.h" |
9 #include "SkColorSpace_Base.h" | 9 #include "SkColorSpace_Base.h" |
10 #include "SkEndian.h" | 10 #include "SkEndian.h" |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 | 668 |
669 return true; | 669 return true; |
670 } | 670 } |
671 | 671 |
672 bool load_matrix(SkMatrix44* toXYZ, const uint8_t* src, size_t len) { | 672 bool load_matrix(SkMatrix44* toXYZ, const uint8_t* src, size_t len) { |
673 if (len < 48) { | 673 if (len < 48) { |
674 SkColorSpacePrintf("Matrix tag is too small (%d bytes).", len); | 674 SkColorSpacePrintf("Matrix tag is too small (%d bytes).", len); |
675 return false; | 675 return false; |
676 } | 676 } |
677 | 677 |
| 678 // For this matrix to behave like our "to XYZ D50" matrices, it needs to be
scaled. |
| 679 constexpr float scale = 65535.0 / 32768.0; |
678 float array[16]; | 680 float array[16]; |
679 array[ 0] = SkFixedToFloat(read_big_endian_int(src)); | 681 array[ 0] = scale * SkFixedToFloat(read_big_endian_int(src)); |
680 array[ 1] = SkFixedToFloat(read_big_endian_int(src + 4)); | 682 array[ 1] = scale * SkFixedToFloat(read_big_endian_int(src + 4)); |
681 array[ 2] = SkFixedToFloat(read_big_endian_int(src + 8)); | 683 array[ 2] = scale * SkFixedToFloat(read_big_endian_int(src + 8)); |
682 array[ 3] = SkFixedToFloat(read_big_endian_int(src + 36)); // translate R | 684 array[ 3] = scale * SkFixedToFloat(read_big_endian_int(src + 36)); // transl
ate R |
683 array[ 4] = SkFixedToFloat(read_big_endian_int(src + 12)); | 685 array[ 4] = scale * SkFixedToFloat(read_big_endian_int(src + 12)); |
684 array[ 5] = SkFixedToFloat(read_big_endian_int(src + 16)); | 686 array[ 5] = scale * SkFixedToFloat(read_big_endian_int(src + 16)); |
685 array[ 6] = SkFixedToFloat(read_big_endian_int(src + 20)); | 687 array[ 6] = scale * SkFixedToFloat(read_big_endian_int(src + 20)); |
686 array[ 7] = SkFixedToFloat(read_big_endian_int(src + 40)); // translate G | 688 array[ 7] = scale * SkFixedToFloat(read_big_endian_int(src + 40)); // transl
ate G |
687 array[ 8] = SkFixedToFloat(read_big_endian_int(src + 24)); | 689 array[ 8] = scale * SkFixedToFloat(read_big_endian_int(src + 24)); |
688 array[ 9] = SkFixedToFloat(read_big_endian_int(src + 28)); | 690 array[ 9] = scale * SkFixedToFloat(read_big_endian_int(src + 28)); |
689 array[10] = SkFixedToFloat(read_big_endian_int(src + 32)); | 691 array[10] = scale * SkFixedToFloat(read_big_endian_int(src + 32)); |
690 array[11] = SkFixedToFloat(read_big_endian_int(src + 44)); // translate B | 692 array[11] = scale * SkFixedToFloat(read_big_endian_int(src + 44)); // transl
ate B |
691 array[12] = 0.0f; | 693 array[12] = 0.0f; |
692 array[13] = 0.0f; | 694 array[13] = 0.0f; |
693 array[14] = 0.0f; | 695 array[14] = 0.0f; |
694 array[15] = 1.0f; | 696 array[15] = 1.0f; |
695 toXYZ->setColMajorf(array); | 697 toXYZ->setColMajorf(array); |
696 return true; | 698 return true; |
697 } | 699 } |
698 | 700 |
699 bool load_a2b0(SkColorLookUpTable* colorLUT, SkGammaCurve* gammas, SkMatrix44* t
oXYZ, | 701 bool load_a2b0(SkColorLookUpTable* colorLUT, SkGammaCurve* gammas, SkMatrix44* t
oXYZ, |
700 const uint8_t* src, size_t len) { | 702 const uint8_t* src, size_t len) { |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 ptr32[4] = SkEndian_SwapBE32(0x000116cc); | 1094 ptr32[4] = SkEndian_SwapBE32(0x000116cc); |
1093 ptr += kTAG_XYZ_Bytes; | 1095 ptr += kTAG_XYZ_Bytes; |
1094 | 1096 |
1095 // Write copyright tag | 1097 // Write copyright tag |
1096 memcpy(ptr, gEmptyTextTag, sizeof(gEmptyTextTag)); | 1098 memcpy(ptr, gEmptyTextTag, sizeof(gEmptyTextTag)); |
1097 | 1099 |
1098 // TODO (msarett): Should we try to hold onto the data so we can return imme
diately if | 1100 // TODO (msarett): Should we try to hold onto the data so we can return imme
diately if |
1099 // the client calls again? | 1101 // the client calls again? |
1100 return SkData::MakeFromMalloc(profile.release(), kICCProfileSize); | 1102 return SkData::MakeFromMalloc(profile.release(), kICCProfileSize); |
1101 } | 1103 } |
OLD | NEW |