| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 REPORTER_ASSERT(r, almost_equal(0.0970764f, xyz.fMat[5])); | 50 REPORTER_ASSERT(r, almost_equal(0.0970764f, xyz.fMat[5])); |
| 51 REPORTER_ASSERT(r, almost_equal(0.143066f, xyz.fMat[6])); | 51 REPORTER_ASSERT(r, almost_equal(0.143066f, xyz.fMat[6])); |
| 52 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[7])); | 52 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[7])); |
| 53 REPORTER_ASSERT(r, almost_equal(0.714096f, xyz.fMat[8])); | 53 REPORTER_ASSERT(r, almost_equal(0.714096f, xyz.fMat[8])); |
| 54 #endif | 54 #endif |
| 55 } | 55 } |
| 56 | 56 |
| 57 DEF_TEST(ColorSpaceParseJpegICCProfile, r) { | 57 DEF_TEST(ColorSpaceParseJpegICCProfile, r) { |
| 58 SkAutoTDelete<SkStream> stream(resource("icc-v2-gbr.jpg")); | 58 SkAutoTDelete<SkStream> stream(resource("icc-v2-gbr.jpg")); |
| 59 REPORTER_ASSERT(r, nullptr != stream); | 59 REPORTER_ASSERT(r, nullptr != stream); |
| 60 if (!stream) { |
| 61 return; |
| 62 } |
| 60 | 63 |
| 61 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); | 64 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); |
| 62 REPORTER_ASSERT(r, nullptr != codec); | 65 REPORTER_ASSERT(r, nullptr != codec); |
| 66 if (!codec) { |
| 67 return; |
| 68 } |
| 63 | 69 |
| 64 SkColorSpace* colorSpace = codec->getColorSpace(); | 70 SkColorSpace* colorSpace = codec->getColorSpace(); |
| 65 REPORTER_ASSERT(r, nullptr != colorSpace); | 71 REPORTER_ASSERT(r, nullptr != colorSpace); |
| 66 | 72 |
| 67 // It's important to use almost equal here. This profile sets gamma as | 73 // It's important to use almost equal here. This profile sets gamma as |
| 68 // 563 / 256, which actually comes out to about 2.19922. | 74 // 563 / 256, which actually comes out to about 2.19922. |
| 69 SkFloat3 gammas = colorSpace->gamma(); | 75 SkFloat3 gammas = colorSpace->gamma(); |
| 70 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[0])); | 76 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[0])); |
| 71 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[1])); | 77 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[1])); |
| 72 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[2])); | 78 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[2])); |
| 73 | 79 |
| 74 // These nine values were extracted from the color profile. Until we know a
ny | 80 // These nine values were extracted from the color profile. Until we know a
ny |
| 75 // better, we'll assume these are the right values and test that we continue | 81 // better, we'll assume these are the right values and test that we continue |
| 76 // to extract them properly. | 82 // to extract them properly. |
| 77 SkFloat3x3 xyz = colorSpace->xyz(); | 83 SkFloat3x3 xyz = colorSpace->xyz(); |
| 78 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0])); | 84 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0])); |
| 79 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1])); | 85 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1])); |
| 80 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2])); | 86 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2])); |
| 81 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3])); | 87 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3])); |
| 82 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4])); | 88 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4])); |
| 83 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5])); | 89 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5])); |
| 84 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6])); | 90 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6])); |
| 85 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7])); | 91 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7])); |
| 86 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8])); | 92 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8])); |
| 87 } | 93 } |
| OLD | NEW |