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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 sk_sp<SkData> newMonitorData = ColorSpaceTest::WriteToICC(monitorSpace.get()
); | 142 sk_sp<SkData> newMonitorData = ColorSpaceTest::WriteToICC(monitorSpace.get()
); |
143 sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->d
ata(), | 143 sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->d
ata(), |
144 newMonitorData->s
ize()); | 144 newMonitorData->s
ize()); |
145 REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz()); | 145 REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz()); |
146 REPORTER_ASSERT(r, monitorSpace->gammaNamed() == newMonitorSpace->gammaNamed
()); | 146 REPORTER_ASSERT(r, monitorSpace->gammaNamed() == newMonitorSpace->gammaNamed
()); |
147 } | 147 } |
148 | 148 |
149 DEF_TEST(ColorSpace_Named, r) { | 149 DEF_TEST(ColorSpace_Named, r) { |
150 const struct { | 150 const struct { |
151 SkColorSpace::Named fNamed; | 151 SkColorSpace::Named fNamed; |
| 152 bool fExpectedToSucceed; |
152 bool fIsSRGB; | 153 bool fIsSRGB; |
153 } recs[] { | 154 } recs[] { |
154 { SkColorSpace::kSRGB_Named, true }, | 155 { SkColorSpace::kUnknown_Named, false, false }, |
155 { SkColorSpace::kAdobeRGB_Named, false }, | 156 { SkColorSpace::kSRGB_Named, true, true }, |
| 157 { SkColorSpace::kAdobeRGB_Named, true, false }, |
156 }; | 158 }; |
157 | 159 |
158 for (auto rec : recs) { | 160 for (auto rec : recs) { |
159 auto cs = SkColorSpace::NewNamed(rec.fNamed); | 161 auto cs = SkColorSpace::NewNamed(rec.fNamed); |
160 REPORTER_ASSERT(r, cs); | 162 REPORTER_ASSERT(r, !cs == !rec.fExpectedToSucceed); |
161 if (cs) { | 163 if (cs) { |
162 if (rec.fIsSRGB) { | 164 if (rec.fIsSRGB) { |
163 REPORTER_ASSERT(r, SkColorSpace::kSRGB_GammaNamed == cs->gammaNa
med()); | 165 REPORTER_ASSERT(r, SkColorSpace::kSRGB_GammaNamed == cs->gammaNa
med()); |
164 } else { | 166 } else { |
165 REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == cs->g
ammaNamed()); | 167 REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == cs->g
ammaNamed()); |
166 } | 168 } |
167 } | 169 } |
168 } | 170 } |
169 | 171 |
170 SkImageInfo info = SkImageInfo::MakeS32(10, 10, kPremul_SkAlphaType); | 172 SkImageInfo info = SkImageInfo::MakeS32(10, 10, kPremul_SkAlphaType); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 REPORTER_ASSERT(r, !SkColorSpace::Equals(srgb.get(), nullptr)); | 244 REPORTER_ASSERT(r, !SkColorSpace::Equals(srgb.get(), nullptr)); |
243 REPORTER_ASSERT(r, !SkColorSpace::Equals(adobe.get(), srgb.get())); | 245 REPORTER_ASSERT(r, !SkColorSpace::Equals(adobe.get(), srgb.get())); |
244 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), srgb.get())); | 246 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), srgb.get())); |
245 REPORTER_ASSERT(r, !SkColorSpace::Equals(z32.get(), z30.get())); | 247 REPORTER_ASSERT(r, !SkColorSpace::Equals(z32.get(), z30.get())); |
246 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), srgb.get())); | 248 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), srgb.get())); |
247 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), upperRight.get()))
; | 249 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), upperRight.get()))
; |
248 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), upperRight.get())); | 250 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), upperRight.get())); |
249 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperRight.get(), adobe.get())); | 251 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperRight.get(), adobe.get())); |
250 REPORTER_ASSERT(r, !SkColorSpace::Equals(rgb1.get(), rgb2.get())); | 252 REPORTER_ASSERT(r, !SkColorSpace::Equals(rgb1.get(), rgb2.get())); |
251 } | 253 } |
OLD | NEW |