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; | |
153 bool fIsSRGB; | 152 bool fIsSRGB; |
154 } recs[] { | 153 } recs[] { |
155 { SkColorSpace::kUnknown_Named, false, false }, | 154 { SkColorSpace::kSRGB_Named, true }, |
156 { SkColorSpace::kSRGB_Named, true, true }, | 155 { SkColorSpace::kAdobeRGB_Named, false }, |
157 { SkColorSpace::kAdobeRGB_Named, true, false }, | |
158 }; | 156 }; |
159 | 157 |
160 for (auto rec : recs) { | 158 for (auto rec : recs) { |
161 auto cs = SkColorSpace::NewNamed(rec.fNamed); | 159 auto cs = SkColorSpace::NewNamed(rec.fNamed); |
162 REPORTER_ASSERT(r, !cs == !rec.fExpectedToSucceed); | 160 REPORTER_ASSERT(r, cs); |
163 if (cs) { | 161 if (cs) { |
164 if (rec.fIsSRGB) { | 162 if (rec.fIsSRGB) { |
165 REPORTER_ASSERT(r, SkColorSpace::kSRGB_GammaNamed == cs->gammaNa
med()); | 163 REPORTER_ASSERT(r, SkColorSpace::kSRGB_GammaNamed == cs->gammaNa
med()); |
166 } else { | 164 } else { |
167 REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == cs->g
ammaNamed()); | 165 REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == cs->g
ammaNamed()); |
168 } | 166 } |
169 } | 167 } |
170 } | 168 } |
171 | 169 |
172 SkImageInfo info = SkImageInfo::MakeS32(10, 10, kPremul_SkAlphaType); | 170 SkImageInfo info = SkImageInfo::MakeS32(10, 10, kPremul_SkAlphaType); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 REPORTER_ASSERT(r, !SkColorSpace::Equals(srgb.get(), nullptr)); | 242 REPORTER_ASSERT(r, !SkColorSpace::Equals(srgb.get(), nullptr)); |
245 REPORTER_ASSERT(r, !SkColorSpace::Equals(adobe.get(), srgb.get())); | 243 REPORTER_ASSERT(r, !SkColorSpace::Equals(adobe.get(), srgb.get())); |
246 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), srgb.get())); | 244 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), srgb.get())); |
247 REPORTER_ASSERT(r, !SkColorSpace::Equals(z32.get(), z30.get())); | 245 REPORTER_ASSERT(r, !SkColorSpace::Equals(z32.get(), z30.get())); |
248 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), srgb.get())); | 246 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), srgb.get())); |
249 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), upperRight.get()))
; | 247 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), upperRight.get()))
; |
250 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), upperRight.get())); | 248 REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), upperRight.get())); |
251 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperRight.get(), adobe.get())); | 249 REPORTER_ASSERT(r, !SkColorSpace::Equals(upperRight.get(), adobe.get())); |
252 REPORTER_ASSERT(r, !SkColorSpace::Equals(rgb1.get(), rgb2.get())); | 250 REPORTER_ASSERT(r, !SkColorSpace::Equals(rgb1.get(), rgb2.get())); |
253 } | 251 } |
OLD | NEW |