| 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" |
| 11 #include "Test.h" | 11 #include "Test.h" |
| 12 | 12 |
| 13 #include "png.h" | 13 #include "png.h" |
| 14 | 14 |
| 15 static SkStreamAsset* resource(const char path[]) { | 15 static SkStreamAsset* resource(const char path[]) { |
| 16 SkString fullPath = GetResourcePath(path); | 16 SkString fullPath = GetResourcePath(path); |
| 17 return SkStream::NewFromFile(fullPath.c_str()); | 17 return SkStream::NewFromFile(fullPath.c_str()); |
| 18 } | 18 } |
| 19 | 19 |
| 20 static bool almost_equal(float a, float b) { | 20 static bool almost_equal(float a, float b) { |
| 21 return SkTAbs(a - b) < 0.001f; | 21 return SkTAbs(a - b) < 0.001f; |
| 22 } | 22 } |
| 23 | 23 |
| 24 DEF_TEST(ColorSpaceParsePngICCProfile, r) { | 24 DEF_TEST(ColorSpaceParsePngICCProfile, r) { |
| 25 SkAutoTDelete<SkStream> stream(resource("color_wheel_with_profile.png")); | 25 SkAutoTDelete<SkStream> stream(resource("color_wheel_with_profile.png")); |
| 26 REPORTER_ASSERT(r, nullptr != stream); | 26 REPORTER_ASSERT(r, nullptr != stream); |
| 27 if (!stream) { |
| 28 return; |
| 29 } |
| 27 | 30 |
| 28 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); | 31 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); |
| 29 REPORTER_ASSERT(r, nullptr != codec); | 32 REPORTER_ASSERT(r, nullptr != codec); |
| 30 | 33 |
| 31 #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) |
| 32 SkColorSpace* colorSpace = codec->getColorSpace(); | 35 SkColorSpace* colorSpace = codec->getColorSpace(); |
| 33 REPORTER_ASSERT(r, nullptr != colorSpace); | 36 REPORTER_ASSERT(r, nullptr != colorSpace); |
| 34 | 37 |
| 35 // No need to use almost equal here. The color profile that we have extract
ed | 38 // No need to use almost equal here. The color profile that we have extract
ed |
| 36 // actually has a table of gammas. And our current implementation guesses 2
.2f. | 39 // actually has a table of gammas. And our current implementation guesses 2
.2f. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0])); | 87 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0])); |
| 85 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1])); | 88 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1])); |
| 86 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2])); | 89 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2])); |
| 87 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3])); | 90 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3])); |
| 88 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4])); | 91 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4])); |
| 89 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5])); | 92 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5])); |
| 90 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6])); | 93 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6])); |
| 91 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7])); | 94 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7])); |
| 92 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8])); | 95 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8])); |
| 93 } | 96 } |
| OLD | NEW |