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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::k
SRGB_Named); | 118 sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::k
SRGB_Named); |
119 sk_sp<SkData> namedData = as_CSB(namedColorSpace)->writeToICC(); | 119 sk_sp<SkData> namedData = as_CSB(namedColorSpace)->writeToICC(); |
120 sk_sp<SkColorSpace> iccColorSpace = SkColorSpace::NewICC(namedData->data(),
namedData->size()); | 120 sk_sp<SkColorSpace> iccColorSpace = SkColorSpace::NewICC(namedData->data(),
namedData->size()); |
121 test_space(r, iccColorSpace.get(), g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6
], | 121 test_space(r, iccColorSpace.get(), g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6
], |
122 SkColorSpace::k2Dot2Curve_GammaNamed); | 122 SkColorSpace::k2Dot2Curve_GammaNamed); |
123 // FIXME (msarett): Test disabled. sRGB profiles are written approximately
as 2.2f curves. | 123 // FIXME (msarett): Test disabled. sRGB profiles are written approximately
as 2.2f curves. |
124 // REPORTER_ASSERT(r, iccColorSpace == namedColorSpace); | 124 // REPORTER_ASSERT(r, iccColorSpace == namedColorSpace); |
125 | 125 |
126 // Test saving the original ICC data | 126 // Test saving the original ICC data |
127 sk_sp<SkData> monitorData = SkData::MakeFromFileName( | 127 sk_sp<SkData> monitorData = SkData::MakeFromFileName( |
128 GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str()); | 128 GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); |
129 REPORTER_ASSERT(r, monitorData); | 129 REPORTER_ASSERT(r, monitorData); |
130 if (!monitorData) { | 130 if (!monitorData) { |
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()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 matrix_equals(r, space, newSpace1.get()); | 204 matrix_equals(r, space, newSpace1.get()); |
205 matrix_equals(r, space, newSpace2.get()); | 205 matrix_equals(r, space, newSpace2.get()); |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 DEF_TEST(ColorSpace_Serialize, r) { | 209 DEF_TEST(ColorSpace_Serialize, r) { |
210 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(), t
rue); | 210 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(), t
rue); |
211 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named).get(
), true); | 211 test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named).get(
), true); |
212 | 212 |
213 sk_sp<SkData> monitorData = SkData::MakeFromFileName( | 213 sk_sp<SkData> monitorData = SkData::MakeFromFileName( |
214 GetResourcePath("monitor_profiles/HP_ZR30w.icc").c_str()); | 214 GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); |
| 215 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz
e()).get(), false); |
| 216 monitorData = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32
x.icc").c_str()); |
| 217 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz
e()).get(), false); |
| 218 monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLe
ft.icc").c_str()); |
| 219 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz
e()).get(), false); |
| 220 monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRi
ght.icc").c_str()); |
215 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz
e()).get(), false); | 221 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz
e()).get(), false); |
216 } | 222 } |
217 | 223 |
OLD | NEW |