| 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 // So we expect the gamma value to be zero. |
| 40 SkFloat3 gammas = colorSpace->gamma(); | 40 const SkColorSpace::SkGammas& gammas = colorSpace->gammas(); |
| 41 REPORTER_ASSERT(r, 2.2f == gammas.fVec[0]); | 41 REPORTER_ASSERT(r, 0.0f == gammas.red()); |
| 42 REPORTER_ASSERT(r, 2.2f == gammas.fVec[1]); | 42 REPORTER_ASSERT(r, 0.0f == gammas.green()); |
| 43 REPORTER_ASSERT(r, 2.2f == gammas.fVec[2]); | 43 REPORTER_ASSERT(r, 0.0f == gammas.blue()); |
| 44 | 44 |
| 45 // These nine values were extracted from the color profile in isolation (bef
ore | 45 // 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. | 46 // we embedded it in the png). Here we check that we still extract the same
values. |
| 47 SkFloat3x3 xyz = colorSpace->xyz(); | 47 SkFloat3x3 xyz = colorSpace->xyz(); |
| 48 REPORTER_ASSERT(r, almost_equal(0.436066f, xyz.fMat[0])); | 48 REPORTER_ASSERT(r, almost_equal(0.436066f, xyz.fMat[0])); |
| 49 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[1])); | 49 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[1])); |
| 50 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[2])); | 50 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[2])); |
| 51 REPORTER_ASSERT(r, almost_equal(0.385147f, xyz.fMat[3])); | 51 REPORTER_ASSERT(r, almost_equal(0.385147f, xyz.fMat[3])); |
| 52 REPORTER_ASSERT(r, almost_equal(0.716873f, xyz.fMat[4])); | 52 REPORTER_ASSERT(r, almost_equal(0.716873f, xyz.fMat[4])); |
| 53 REPORTER_ASSERT(r, almost_equal(0.0970764f, xyz.fMat[5])); | 53 REPORTER_ASSERT(r, almost_equal(0.0970764f, xyz.fMat[5])); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 68 REPORTER_ASSERT(r, nullptr != codec); | 68 REPORTER_ASSERT(r, nullptr != codec); |
| 69 if (!codec) { | 69 if (!codec) { |
| 70 return; | 70 return; |
| 71 } | 71 } |
| 72 | 72 |
| 73 SkColorSpace* colorSpace = codec->getColorSpace(); | 73 SkColorSpace* colorSpace = codec->getColorSpace(); |
| 74 REPORTER_ASSERT(r, nullptr != colorSpace); | 74 REPORTER_ASSERT(r, nullptr != colorSpace); |
| 75 | 75 |
| 76 // It's important to use almost equal here. This profile sets gamma as | 76 // It's important to use almost equal here. This profile sets gamma as |
| 77 // 563 / 256, which actually comes out to about 2.19922. | 77 // 563 / 256, which actually comes out to about 2.19922. |
| 78 SkFloat3 gammas = colorSpace->gamma(); | 78 const SkColorSpace::SkGammas& gammas = colorSpace->gammas(); |
| 79 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[0])); | 79 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.red())); |
| 80 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[1])); | 80 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.green())); |
| 81 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[2])); | 81 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.blue())); |
| 82 | 82 |
| 83 // These nine values were extracted from the color profile. Until we know a
ny | 83 // 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 | 84 // better, we'll assume these are the right values and test that we continue |
| 85 // to extract them properly. | 85 // to extract them properly. |
| 86 SkFloat3x3 xyz = colorSpace->xyz(); | 86 SkFloat3x3 xyz = colorSpace->xyz(); |
| 87 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0])); | 87 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0])); |
| 88 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1])); | 88 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1])); |
| 89 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2])); | 89 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2])); |
| 90 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3])); | 90 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3])); |
| 91 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4])); | 91 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4])); |
| 92 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5])); | 92 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5])); |
| 93 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6])); | 93 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6])); |
| 94 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7])); | 94 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7])); |
| 95 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8])); | 95 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8])); |
| 96 } | 96 } |
| OLD | NEW |