Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2015 Google Inc. | |
|
scroggo
2016/03/01 14:42:29
nit: 2016
msarett
2016/03/01 21:01:59
Done.
| |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #include "Resources.h" | |
| 9 #include "SkCodec.h" | |
| 10 #include "SkColorSpace.h" | |
| 11 #include "Test.h" | |
| 12 | |
| 13 static SkStreamAsset* resource(const char path[]) { | |
| 14 SkString fullPath = GetResourcePath(path); | |
| 15 return SkStream::NewFromFile(fullPath.c_str()); | |
| 16 } | |
| 17 | |
| 18 bool almost_equal(float a, float b) { | |
|
scroggo
2016/03/01 14:42:29
I wanted to suggest you use SkScalarNearlyEqual, b
msarett
2016/03/01 21:01:59
Made this static.
| |
| 19 return SkTAbs(a - b) < 0.0001f; | |
| 20 } | |
| 21 | |
| 22 DEF_TEST(ColorSpaceParseICCProfile, r) { | |
| 23 SkAutoTDelete<SkStream> stream(resource("color_wheel_with_profile.png")); | |
| 24 REPORTER_ASSERT(r, nullptr != stream); | |
| 25 | |
| 26 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); | |
| 27 REPORTER_ASSERT(r, nullptr != codec); | |
| 28 | |
| 29 SkColorSpace* colorSpace = codec->getColorSpace(); | |
| 30 REPORTER_ASSERT(r, nullptr != colorSpace); | |
| 31 | |
| 32 SkFloat3 gammas = colorSpace->gamma(); | |
| 33 REPORTER_ASSERT(r, 2.2f == gammas.fVec[0]); | |
| 34 REPORTER_ASSERT(r, 2.2f == gammas.fVec[1]); | |
| 35 REPORTER_ASSERT(r, 2.2f == gammas.fVec[2]); | |
| 36 | |
| 37 SkFloat3x3 xyz = colorSpace->xyz(); | |
| 38 REPORTER_ASSERT(r, almost_equal(0.436066f, xyz.fMat[0])); | |
| 39 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[1])); | |
| 40 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[2])); | |
| 41 REPORTER_ASSERT(r, almost_equal(0.385147f, xyz.fMat[3])); | |
| 42 REPORTER_ASSERT(r, almost_equal(0.716873f, xyz.fMat[4])); | |
| 43 REPORTER_ASSERT(r, almost_equal(0.0970764f, xyz.fMat[5])); | |
| 44 REPORTER_ASSERT(r, almost_equal(0.143066f, xyz.fMat[6])); | |
| 45 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[7])); | |
| 46 REPORTER_ASSERT(r, almost_equal(0.714096f, xyz.fMat[8])); | |
| 47 } | |
| OLD | NEW |