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 "SkColorSpace.h" | 8 #include "SkColorSpace.h" |
9 #include "SkColorSpace_Base.h" | 9 #include "SkColorSpace_Base.h" |
10 #include "SkColorSpacePriv.h" | 10 #include "SkColorSpacePriv.h" |
| 11 #include "SkColorSpaceXform_Base.h" |
11 #include "SkOnce.h" | 12 #include "SkOnce.h" |
12 #include "SkPoint3.h" | 13 #include "SkPoint3.h" |
13 | 14 |
14 bool SkColorSpacePrimaries::toXYZD50(SkMatrix44* toXYZ_D50) const { | 15 bool SkColorSpacePrimaries::toXYZD50(SkMatrix44* toXYZ_D50) const { |
15 if (!is_zero_to_one(fRX) || !is_zero_to_one(fRY) || | 16 if (!is_zero_to_one(fRX) || !is_zero_to_one(fRY) || |
16 !is_zero_to_one(fGX) || !is_zero_to_one(fGY) || | 17 !is_zero_to_one(fGX) || !is_zero_to_one(fGY) || |
17 !is_zero_to_one(fBX) || !is_zero_to_one(fBY) || | 18 !is_zero_to_one(fBX) || !is_zero_to_one(fBY) || |
18 !is_zero_to_one(fWX) || !is_zero_to_one(fWY)) | 19 !is_zero_to_one(fWX) || !is_zero_to_one(fWY)) |
19 { | 20 { |
20 return false; | 21 return false; |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // simply give them back a transform to sRGB gamut. | 313 // simply give them back a transform to sRGB gamut. |
313 SkDEBUGFAIL("Non-invertible XYZ matrix, defaulting to sRGB"); | 314 SkDEBUGFAIL("Non-invertible XYZ matrix, defaulting to sRGB"); |
314 SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor); | 315 SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor); |
315 srgbToxyzD50.set3x3RowMajorf(gSRGB_toXYZD50); | 316 srgbToxyzD50.set3x3RowMajorf(gSRGB_toXYZD50); |
316 srgbToxyzD50.invert(&fFromXYZD50); | 317 srgbToxyzD50.invert(&fFromXYZD50); |
317 } | 318 } |
318 }); | 319 }); |
319 return fFromXYZD50; | 320 return fFromXYZD50; |
320 } | 321 } |
321 | 322 |
| 323 void SkColorSpace_Base::toDstGammaTables(const uint8_t* tables[3], sk_sp<SkData>
* storage, |
| 324 int numTables) const { |
| 325 fToDstGammaOnce([this, numTables] { |
| 326 const bool gammasAreMatching = numTables <= 1; |
| 327 fDstStorage = |
| 328 SkData::MakeUninitialized(numTables * SkColorSpaceXform_Base::kD
stGammaTableSize); |
| 329 SkColorSpaceXform_Base::BuildDstGammaTables(fToDstGammaTables, |
| 330 (uint8_t*) fDstStorage->writ
able_data(), this, |
| 331 gammasAreMatching); |
| 332 }); |
| 333 |
| 334 *storage = fDstStorage; |
| 335 tables[0] = fToDstGammaTables[0]; |
| 336 tables[1] = fToDstGammaTables[1]; |
| 337 tables[2] = fToDstGammaTables[2]; |
| 338 } |
| 339 |
322 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 340 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
323 | 341 |
324 enum Version { | 342 enum Version { |
325 k0_Version, // Initial version, header + flags for matrix and profile | 343 k0_Version, // Initial version, header + flags for matrix and profile |
326 }; | 344 }; |
327 | 345 |
328 struct ColorSpaceHeader { | 346 struct ColorSpaceHeader { |
329 /** | 347 /** |
330 * It is only valid to set zero or one flags. | 348 * It is only valid to set zero or one flags. |
331 * Setting multiple flags is invalid. | 349 * Setting multiple flags is invalid. |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 return false; | 637 return false; |
620 } | 638 } |
621 | 639 |
622 // It is unlikely that we will reach this case. | 640 // It is unlikely that we will reach this case. |
623 sk_sp<SkData> srcData = src->serialize(); | 641 sk_sp<SkData> srcData = src->serialize(); |
624 sk_sp<SkData> dstData = dst->serialize(); | 642 sk_sp<SkData> dstData = dst->serialize(); |
625 return srcData->size() == dstData->size() && | 643 return srcData->size() == dstData->size() && |
626 0 == memcmp(srcData->data(), dstData->data(), srcData->size()
); | 644 0 == memcmp(srcData->data(), dstData->data(), srcData->size()
); |
627 } | 645 } |
628 } | 646 } |
OLD | NEW |