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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 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); |
222 monitorData = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32
x.icc").c_str()); | 222 monitorData = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32
x.icc").c_str()); |
223 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz
e()).get(), false); | 223 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz
e()).get(), false); |
224 monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLe
ft.icc").c_str()); | 224 monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLe
ft.icc").c_str()); |
225 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz
e()).get(), false); | 225 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz
e()).get(), false); |
226 monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRi
ght.icc").c_str()); | 226 monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRi
ght.icc").c_str()); |
227 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz
e()).get(), false); | 227 test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->siz
e()).get(), false); |
228 | 228 |
229 const float gammas[] = { 1.1f, 1.2f, 1.7f, }; | 229 const float gammas[] = { 1.1f, 1.2f, 1.7f, }; |
230 SkMatrix44 toXYZ(SkMatrix44::kIdentity_Constructor); | 230 SkMatrix44 toXYZ(SkMatrix44::kIdentity_Constructor); |
231 test_serialize(r, SkColorSpace_Base::NewRGB(gammas, toXYZ).get(), false); | 231 test_serialize(r, SkColorSpace::NewRGB(gammas, toXYZ).get(), false); |
232 | 232 |
233 SkColorSpaceTransferFn fn; | 233 SkColorSpaceTransferFn fn; |
234 fn.fA = 1.0f; | 234 fn.fA = 1.0f; |
235 fn.fB = 0.0f; | 235 fn.fB = 0.0f; |
236 fn.fC = 0.0f; | 236 fn.fC = 0.0f; |
237 fn.fD = 0.5f; | 237 fn.fD = 0.5f; |
238 fn.fE = 1.0f; | 238 fn.fE = 1.0f; |
239 fn.fF = 0.0f; | 239 fn.fF = 0.0f; |
240 fn.fG = 1.0f; | 240 fn.fG = 1.0f; |
241 test_serialize(r, SkColorSpace::NewRGB(fn, toXYZ).get(), false); | 241 test_serialize(r, SkColorSpace::NewRGB(fn, toXYZ).get(), false); |
242 } | 242 } |
243 | 243 |
244 DEF_TEST(ColorSpace_Equals, r) { | 244 DEF_TEST(ColorSpace_Equals, r) { |
245 sk_sp<SkColorSpace> srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)
; | 245 sk_sp<SkColorSpace> srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)
; |
246 sk_sp<SkColorSpace> adobe = SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_N
amed); | 246 sk_sp<SkColorSpace> adobe = SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_N
amed); |
247 sk_sp<SkData> data = SkData::MakeFromFileName( | 247 sk_sp<SkData> data = SkData::MakeFromFileName( |
248 GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); | 248 GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); |
249 sk_sp<SkColorSpace> z30 = SkColorSpace::NewICC(data->data(), data->size()); | 249 sk_sp<SkColorSpace> z30 = SkColorSpace::NewICC(data->data(), data->size()); |
250 data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32x.icc")
.c_str()); | 250 data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32x.icc")
.c_str()); |
251 sk_sp<SkColorSpace> z32 = SkColorSpace::NewICC(data->data(), data->size()); | 251 sk_sp<SkColorSpace> z32 = SkColorSpace::NewICC(data->data(), data->size()); |
252 data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLeft.icc"
).c_str()); | 252 data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLeft.icc"
).c_str()); |
253 sk_sp<SkColorSpace> upperLeft = SkColorSpace::NewICC(data->data(), data->siz
e()); | 253 sk_sp<SkColorSpace> upperLeft = SkColorSpace::NewICC(data->data(), data->siz
e()); |
254 data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc
").c_str()); | 254 data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc
").c_str()); |
255 sk_sp<SkColorSpace> upperRight = SkColorSpace::NewICC(data->data(), data->si
ze()); | 255 sk_sp<SkColorSpace> upperRight = SkColorSpace::NewICC(data->data(), data->si
ze()); |
256 const float gammas1[] = { 1.1f, 1.2f, 1.3f, }; | 256 const float gammas1[] = { 1.1f, 1.2f, 1.3f, }; |
257 const float gammas2[] = { 1.1f, 1.2f, 1.7f, }; | 257 const float gammas2[] = { 1.1f, 1.2f, 1.7f, }; |
258 SkMatrix44 toXYZ(SkMatrix44::kIdentity_Constructor); | 258 SkMatrix44 toXYZ(SkMatrix44::kIdentity_Constructor); |
259 sk_sp<SkColorSpace> rgb1 = SkColorSpace_Base::NewRGB(gammas1, toXYZ); | 259 sk_sp<SkColorSpace> rgb1 = SkColorSpace::NewRGB(gammas1, toXYZ); |
260 sk_sp<SkColorSpace> rgb2 = SkColorSpace_Base::NewRGB(gammas2, toXYZ); | 260 sk_sp<SkColorSpace> rgb2 = SkColorSpace::NewRGB(gammas2, toXYZ); |
261 sk_sp<SkColorSpace> rgb3 = SkColorSpace_Base::NewRGB(gammas1, toXYZ); | 261 sk_sp<SkColorSpace> rgb3 = SkColorSpace::NewRGB(gammas1, toXYZ); |
262 | 262 |
263 SkColorSpaceTransferFn fn; | 263 SkColorSpaceTransferFn fn; |
264 fn.fA = 1.0f; | 264 fn.fA = 1.0f; |
265 fn.fB = 0.0f; | 265 fn.fB = 0.0f; |
266 fn.fC = 0.0f; | 266 fn.fC = 0.0f; |
267 fn.fD = 0.5f; | 267 fn.fD = 0.5f; |
268 fn.fE = 1.0f; | 268 fn.fE = 1.0f; |
269 fn.fF = 0.0f; | 269 fn.fF = 0.0f; |
270 fn.fG = 1.0f; | 270 fn.fG = 1.0f; |
271 sk_sp<SkColorSpace> rgb4 = SkColorSpace::NewRGB(fn, toXYZ); | 271 sk_sp<SkColorSpace> rgb4 = SkColorSpace::NewRGB(fn, toXYZ); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 primaries.fWX = 0.3127f; | 306 primaries.fWX = 0.3127f; |
307 primaries.fWY = 0.3290f; | 307 primaries.fWY = 0.3290f; |
308 | 308 |
309 SkMatrix44 toXYZ(SkMatrix44::kUninitialized_Constructor); | 309 SkMatrix44 toXYZ(SkMatrix44::kUninitialized_Constructor); |
310 bool result = primaries.toXYZD50(&toXYZ); | 310 bool result = primaries.toXYZD50(&toXYZ); |
311 REPORTER_ASSERT(r, result); | 311 REPORTER_ASSERT(r, result); |
312 | 312 |
313 sk_sp<SkColorSpace> space = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderT
argetGamma, toXYZ); | 313 sk_sp<SkColorSpace> space = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderT
argetGamma, toXYZ); |
314 REPORTER_ASSERT(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) == spac
e); | 314 REPORTER_ASSERT(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) == spac
e); |
315 } | 315 } |
OLD | NEW |