| 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 "SkAtomics.h" | 8 #include "SkAtomics.h" |
| 9 #include "SkColorSpace.h" | 9 #include "SkColorSpace.h" |
| 10 #include "SkOncePtr.h" | 10 #include "SkOncePtr.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } else if (len < 12 + 2 * count) { | 315 } else if (len < 12 + 2 * count) { |
| 316 SkColorSpacePrintf("gamma tag is too small (%d bytes)", len)
; | 316 SkColorSpacePrintf("gamma tag is too small (%d bytes)", len)
; |
| 317 return false; | 317 return false; |
| 318 } | 318 } |
| 319 | 319 |
| 320 const uint16_t* table = (const uint16_t*) (src + 12); | 320 const uint16_t* table = (const uint16_t*) (src + 12); |
| 321 if (1 == count) { | 321 if (1 == count) { |
| 322 // The table entry is the gamma (with a bias of 256). | 322 // The table entry is the gamma (with a bias of 256). |
| 323 uint16_t value = read_big_endian_short((const uint8_t*) tabl
e); | 323 uint16_t value = read_big_endian_short((const uint8_t*) tabl
e); |
| 324 gammas[i].fValue = value / 256.0f; | 324 gammas[i].fValue = value / 256.0f; |
| 325 SkColorSpacePrintf("gamma %d %g\n", value, *gamma); | 325 SkColorSpacePrintf("gamma %d %g\n", value, gammas[i].fValue)
; |
| 326 break; | 326 break; |
| 327 } | 327 } |
| 328 | 328 |
| 329 // Fill in the interpolation table. | 329 // Fill in the interpolation table. |
| 330 // FIXME (msarett): | 330 // FIXME (msarett): |
| 331 // We should recognize commonly occurring tables and just set ga
mma to 2.2f. | 331 // We should recognize commonly occurring tables and just set ga
mma to 2.2f. |
| 332 gammas[i].fTableSize = count; | 332 gammas[i].fTableSize = count; |
| 333 gammas[i].fTable = std::unique_ptr<float[]>(new float[count]); | 333 gammas[i].fTable = std::unique_ptr<float[]>(new float[count]); |
| 334 for (uint32_t j = 0; j < count; j++) { | 334 for (uint32_t j = 0; j < count; j++) { |
| 335 gammas[i].fTable[j] = | 335 gammas[i].fTable[j] = |
| (...skipping 28 matching lines...) Expand all Loading... |
| 364 SkColorSpacePrintf("Invalid parametric curve type\n"); | 364 SkColorSpacePrintf("Invalid parametric curve type\n"); |
| 365 return false; | 365 return false; |
| 366 } | 366 } |
| 367 break; | 367 break; |
| 368 default: | 368 default: |
| 369 SkColorSpacePrintf("Unsupported gamma tag type %d\n", type); | 369 SkColorSpacePrintf("Unsupported gamma tag type %d\n", type); |
| 370 return false; | 370 return false; |
| 371 } | 371 } |
| 372 | 372 |
| 373 // Adjust src and len if there is another gamma curve to load. | 373 // Adjust src and len if there is another gamma curve to load. |
| 374 if (0 != numGammas) { | 374 if (i != numGammas - 1) { |
| 375 // Each curve is padded to 4-byte alignment. | 375 // Each curve is padded to 4-byte alignment. |
| 376 tagBytes = SkAlign4(tagBytes); | 376 tagBytes = SkAlign4(tagBytes); |
| 377 if (len < tagBytes) { | 377 if (len < tagBytes) { |
| 378 return false; | 378 return false; |
| 379 } | 379 } |
| 380 | 380 |
| 381 src += tagBytes; | 381 src += tagBytes; |
| 382 len -= tagBytes; | 382 len -= tagBytes; |
| 383 } | 383 } |
| 384 } | 384 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 toXYZ)); | 632 toXYZ)); |
| 633 } | 633 } |
| 634 | 634 |
| 635 } | 635 } |
| 636 default: | 636 default: |
| 637 break; | 637 break; |
| 638 } | 638 } |
| 639 | 639 |
| 640 return_null("ICC profile contains unsupported colorspace"); | 640 return_null("ICC profile contains unsupported colorspace"); |
| 641 } | 641 } |
| OLD | NEW |