| 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 "Resources.h" | 8 #include "Resources.h" |
| 9 #include "SkCodec.h" | 9 #include "SkCodec.h" |
| 10 #include "SkColorSpace.h" | 10 #include "SkColorSpace.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 return; | 28 return; |
| 29 } | 29 } |
| 30 | 30 |
| 31 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); | 31 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); |
| 32 REPORTER_ASSERT(r, nullptr != codec); | 32 REPORTER_ASSERT(r, nullptr != codec); |
| 33 | 33 |
| 34 #if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_M
INOR >= 6) | 34 #if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_M
INOR >= 6) |
| 35 SkColorSpace* colorSpace = codec->getColorSpace(); | 35 SkColorSpace* colorSpace = codec->getColorSpace(); |
| 36 REPORTER_ASSERT(r, nullptr != colorSpace); | 36 REPORTER_ASSERT(r, nullptr != colorSpace); |
| 37 | 37 |
| 38 // No need to use almost equal here. The color profile that we have extract
ed | 38 // The color profile that we have extracted has represents gamma with a look
up table. |
| 39 // actually has a table of gammas. And our current implementation guesses 2
.2f. | 39 const SkGammas& gammas = colorSpace->gammas(); |
| 40 SkFloat3 gammas = colorSpace->gamma(); | 40 REPORTER_ASSERT(r, gammas.fRed.isTable()); |
| 41 REPORTER_ASSERT(r, 2.2f == gammas.fVec[0]); | 41 REPORTER_ASSERT(r, gammas.fGreen.isTable()); |
| 42 REPORTER_ASSERT(r, 2.2f == gammas.fVec[1]); | 42 REPORTER_ASSERT(r, gammas.fBlue.isTable()); |
| 43 REPORTER_ASSERT(r, 2.2f == gammas.fVec[2]); | 43 REPORTER_ASSERT(r, 1024 == gammas.fRed.fTableSize); |
| 44 REPORTER_ASSERT(r, 1024 == gammas.fGreen.fTableSize); |
| 45 REPORTER_ASSERT(r, 1024 == gammas.fBlue.fTableSize); |
| 44 | 46 |
| 45 // These nine values were extracted from the color profile in isolation (bef
ore | 47 // These nine values were extracted from the color profile in isolation (bef
ore |
| 46 // we embedded it in the png). Here we check that we still extract the same
values. | 48 // we embedded it in the png). Here we check that we still extract the same
values. |
| 47 SkFloat3x3 xyz = colorSpace->xyz(); | 49 SkFloat3x3 xyz = colorSpace->xyz(); |
| 48 REPORTER_ASSERT(r, almost_equal(0.436066f, xyz.fMat[0])); | 50 REPORTER_ASSERT(r, almost_equal(0.436066f, xyz.fMat[0])); |
| 49 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[1])); | 51 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[1])); |
| 50 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[2])); | 52 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[2])); |
| 51 REPORTER_ASSERT(r, almost_equal(0.385147f, xyz.fMat[3])); | 53 REPORTER_ASSERT(r, almost_equal(0.385147f, xyz.fMat[3])); |
| 52 REPORTER_ASSERT(r, almost_equal(0.716873f, xyz.fMat[4])); | 54 REPORTER_ASSERT(r, almost_equal(0.716873f, xyz.fMat[4])); |
| 53 REPORTER_ASSERT(r, almost_equal(0.0970764f, xyz.fMat[5])); | 55 REPORTER_ASSERT(r, almost_equal(0.0970764f, xyz.fMat[5])); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 68 REPORTER_ASSERT(r, nullptr != codec); | 70 REPORTER_ASSERT(r, nullptr != codec); |
| 69 if (!codec) { | 71 if (!codec) { |
| 70 return; | 72 return; |
| 71 } | 73 } |
| 72 | 74 |
| 73 SkColorSpace* colorSpace = codec->getColorSpace(); | 75 SkColorSpace* colorSpace = codec->getColorSpace(); |
| 74 REPORTER_ASSERT(r, nullptr != colorSpace); | 76 REPORTER_ASSERT(r, nullptr != colorSpace); |
| 75 | 77 |
| 76 // It's important to use almost equal here. This profile sets gamma as | 78 // It's important to use almost equal here. This profile sets gamma as |
| 77 // 563 / 256, which actually comes out to about 2.19922. | 79 // 563 / 256, which actually comes out to about 2.19922. |
| 78 SkFloat3 gammas = colorSpace->gamma(); | 80 const SkGammas& gammas = colorSpace->gammas(); |
| 79 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[0])); | 81 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fRed.fValue)); |
| 80 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[1])); | 82 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fGreen.fValue)); |
| 81 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[2])); | 83 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fBlue.fValue)); |
| 82 | 84 |
| 83 // These nine values were extracted from the color profile. Until we know a
ny | 85 // These nine values were extracted from the color profile. Until we know a
ny |
| 84 // better, we'll assume these are the right values and test that we continue | 86 // better, we'll assume these are the right values and test that we continue |
| 85 // to extract them properly. | 87 // to extract them properly. |
| 86 SkFloat3x3 xyz = colorSpace->xyz(); | 88 SkFloat3x3 xyz = colorSpace->xyz(); |
| 87 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0])); | 89 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0])); |
| 88 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1])); | 90 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1])); |
| 89 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2])); | 91 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2])); |
| 90 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3])); | 92 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3])); |
| 91 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4])); | 93 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4])); |
| 92 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5])); | 94 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5])); |
| 93 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6])); | 95 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6])); |
| 94 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7])); | 96 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7])); |
| 95 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8])); | 97 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8])); |
| 96 } | 98 } |
| OLD | NEW |