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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 return; | 131 return; |
132 } | 132 } |
133 sk_sp<SkColorSpace> monitorSpace = SkColorSpace::NewICC(monitorData->data(), | 133 sk_sp<SkColorSpace> monitorSpace = SkColorSpace::NewICC(monitorData->data(), |
134 monitorData->size())
; | 134 monitorData->size())
; |
135 sk_sp<SkData> newMonitorData = as_CSB(monitorSpace)->writeToICC(); | 135 sk_sp<SkData> newMonitorData = as_CSB(monitorSpace)->writeToICC(); |
136 sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->d
ata(), | 136 sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->d
ata(), |
137 newMonitorData->s
ize()); | 137 newMonitorData->s
ize()); |
138 REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz()); | 138 REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz()); |
139 REPORTER_ASSERT(r, as_CSB(monitorSpace)->gammas() == as_CSB(newMonitorSpace)
->gammas()); | 139 REPORTER_ASSERT(r, as_CSB(monitorSpace)->gammas() == as_CSB(newMonitorSpace)
->gammas()); |
140 } | 140 } |
| 141 |
| 142 DEF_TEST(ColorSpace_Named, r) { |
| 143 const struct { |
| 144 SkColorSpace::Named fNamed; |
| 145 bool fExpectedToSucceed; |
| 146 } recs[] { |
| 147 { SkColorSpace::kUnknown_Named, false }, |
| 148 { SkColorSpace::kSRGB_Named, true }, |
| 149 { SkColorSpace::kAdobeRGB_Named, true }, |
| 150 }; |
| 151 |
| 152 for (auto rec : recs) { |
| 153 auto cs = SkColorSpace::NewNamed(rec.fNamed); |
| 154 REPORTER_ASSERT(r, !cs == !rec.fExpectedToSucceed); |
| 155 if (cs) { |
| 156 REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == cs->gamma
Named()); |
| 157 } |
| 158 } |
| 159 |
| 160 SkImageInfo info = SkImageInfo::MakeS32(10, 10, kPremul_SkAlphaType); |
| 161 REPORTER_ASSERT(r, kSRGB_SkColorProfileType == info.profileType()); |
| 162 REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == info.colorSpace()
->gammaNamed()); |
| 163 } |
OLD | NEW |