Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: tests/ColorSpaceTest.cpp

Issue 1809733002: detach -> release (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: (C) Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/CodexTest.cpp ('k') | tests/FontHostStreamTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_M INOR >= 6) 20 #if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_M INOR >= 6)
21 static bool almost_equal(float a, float b) { 21 static bool almost_equal(float a, float b) {
22 return SkTAbs(a - b) < 0.0001f; 22 return SkTAbs(a - b) < 0.0001f;
23 } 23 }
24 #endif 24 #endif
25 25
26 DEF_TEST(ColorSpaceParseICCProfile, r) { 26 DEF_TEST(ColorSpaceParseICCProfile, r) {
27 SkAutoTDelete<SkStream> stream(resource("color_wheel_with_profile.png")); 27 SkAutoTDelete<SkStream> stream(resource("color_wheel_with_profile.png"));
28 REPORTER_ASSERT(r, nullptr != stream); 28 REPORTER_ASSERT(r, nullptr != stream);
29 29
30 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); 30 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
31 REPORTER_ASSERT(r, nullptr != codec); 31 REPORTER_ASSERT(r, nullptr != codec);
32 32
33 #if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_M INOR >= 6) 33 #if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_M INOR >= 6)
34 SkColorSpace* colorSpace = codec->getColorSpace(); 34 SkColorSpace* colorSpace = codec->getColorSpace();
35 REPORTER_ASSERT(r, nullptr != colorSpace); 35 REPORTER_ASSERT(r, nullptr != colorSpace);
36 36
37 // No need to use almost equal here. The color profile that we have extract ed 37 // No need to use almost equal here. The color profile that we have extract ed
38 // actually has a table of gammas. And our current implementation guesses 2 .2f. 38 // actually has a table of gammas. And our current implementation guesses 2 .2f.
39 SkFloat3 gammas = colorSpace->gamma(); 39 SkFloat3 gammas = colorSpace->gamma();
40 REPORTER_ASSERT(r, 2.2f == gammas.fVec[0]); 40 REPORTER_ASSERT(r, 2.2f == gammas.fVec[0]);
41 REPORTER_ASSERT(r, 2.2f == gammas.fVec[1]); 41 REPORTER_ASSERT(r, 2.2f == gammas.fVec[1]);
42 REPORTER_ASSERT(r, 2.2f == gammas.fVec[2]); 42 REPORTER_ASSERT(r, 2.2f == gammas.fVec[2]);
43 43
44 // These nine values were extracted from the color profile in isolation (bef ore 44 // These nine values were extracted from the color profile in isolation (bef ore
45 // we embedded it in the png). Here we check that we still extract the same values. 45 // we embedded it in the png). Here we check that we still extract the same values.
46 SkFloat3x3 xyz = colorSpace->xyz(); 46 SkFloat3x3 xyz = colorSpace->xyz();
47 REPORTER_ASSERT(r, almost_equal(0.436066f, xyz.fMat[0])); 47 REPORTER_ASSERT(r, almost_equal(0.436066f, xyz.fMat[0]));
48 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[1])); 48 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[1]));
49 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[2])); 49 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[2]));
50 REPORTER_ASSERT(r, almost_equal(0.385147f, xyz.fMat[3])); 50 REPORTER_ASSERT(r, almost_equal(0.385147f, xyz.fMat[3]));
51 REPORTER_ASSERT(r, almost_equal(0.716873f, xyz.fMat[4])); 51 REPORTER_ASSERT(r, almost_equal(0.716873f, xyz.fMat[4]));
52 REPORTER_ASSERT(r, almost_equal(0.0970764f, xyz.fMat[5])); 52 REPORTER_ASSERT(r, almost_equal(0.0970764f, xyz.fMat[5]));
53 REPORTER_ASSERT(r, almost_equal(0.143066f, xyz.fMat[6])); 53 REPORTER_ASSERT(r, almost_equal(0.143066f, xyz.fMat[6]));
54 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[7])); 54 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[7]));
55 REPORTER_ASSERT(r, almost_equal(0.714096f, xyz.fMat[8])); 55 REPORTER_ASSERT(r, almost_equal(0.714096f, xyz.fMat[8]));
56 #endif 56 #endif
57 } 57 }
OLDNEW
« no previous file with comments | « tests/CodexTest.cpp ('k') | tests/FontHostStreamTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698