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

Side by Side Diff: tests/ColorSpaceTest.cpp

Issue 2277463002: Make singleton SkColorSpaces thread safe (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use getType() to force compute of type mask Created 4 years, 3 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 | « src/core/SkColorSpace.cpp ('k') | no next file » | 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 "SkColorSpace_Base.h" 11 #include "SkColorSpace_Base.h"
12 #include "Test.h" 12 #include "Test.h"
13 13
14 #include "png.h" 14 #include "png.h"
15 15
16 static bool almost_equal(float a, float b) { 16 static bool almost_equal(float a, float b) {
17 return SkTAbs(a - b) < 0.001f; 17 return SkTAbs(a - b) < 0.001f;
18 } 18 }
19 19
20 static void test_space(skiatest::Reporter* r, SkColorSpace* space, 20 static void test_space(skiatest::Reporter* r, SkColorSpace* space,
21 const float red[], const float green[], const float blue[ ], 21 const float red[], const float green[], const float blue[ ],
22 const SkColorSpace::GammaNamed expectedGamma) { 22 const SkColorSpace::GammaNamed expectedGamma) {
23 23
24 REPORTER_ASSERT(r, expectedGamma == space->gammaNamed()); 24 REPORTER_ASSERT(r, expectedGamma == space->gammaNamed());
25 25
26 26
27 SkMatrix44 mat = space->xyz(); 27 const SkMatrix44& mat = space->xyz();
28 const float src[] = { 28 const float src[] = {
29 1, 0, 0, 1, 29 1, 0, 0, 1,
30 0, 1, 0, 1, 30 0, 1, 0, 1,
31 0, 0, 1, 1, 31 0, 0, 1, 1,
32 }; 32 };
33 float dst[4]; 33 float dst[4];
34 for (int i = 0; i < 3; ++i) { 34 for (int i = 0; i < 3; ++i) {
35 mat.mapScalars(&src[i*4], dst); 35 mat.mapScalars(&src[i*4], dst);
36 REPORTER_ASSERT(r, almost_equal(red[i], dst[0])); 36 REPORTER_ASSERT(r, almost_equal(red[i], dst[0]));
37 REPORTER_ASSERT(r, almost_equal(green[i], dst[1])); 37 REPORTER_ASSERT(r, almost_equal(green[i], dst[1]));
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 REPORTER_ASSERT(r, !SkColorSpace::Equals(nullptr, srgb.get())); 252 REPORTER_ASSERT(r, !SkColorSpace::Equals(nullptr, srgb.get()));
253 REPORTER_ASSERT(r, !SkColorSpace::Equals(srgb.get(), nullptr)); 253 REPORTER_ASSERT(r, !SkColorSpace::Equals(srgb.get(), nullptr));
254 REPORTER_ASSERT(r, !SkColorSpace::Equals(adobe.get(), srgb.get())); 254 REPORTER_ASSERT(r, !SkColorSpace::Equals(adobe.get(), srgb.get()));
255 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), srgb.get())); 255 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), srgb.get()));
256 REPORTER_ASSERT(r, !SkColorSpace::Equals(z32.get(), z30.get())); 256 REPORTER_ASSERT(r, !SkColorSpace::Equals(z32.get(), z30.get()));
257 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), srgb.get())); 257 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), srgb.get()));
258 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), upperRight.get())) ; 258 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), upperRight.get())) ;
259 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), upperRight.get())); 259 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), upperRight.get()));
260 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperRight.get(), adobe.get())); 260 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperRight.get(), adobe.get()));
261 } 261 }
OLDNEW
« no previous file with comments | « src/core/SkColorSpace.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698