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" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 uint32_t profileSize = *((uint32_t*) data); | 309 uint32_t profileSize = *((uint32_t*) data); |
310 data = SkTAddOffset<const void>(data, sizeof(uint32_t)); | 310 data = SkTAddOffset<const void>(data, sizeof(uint32_t)); |
311 length -= sizeof(uint32_t); | 311 length -= sizeof(uint32_t); |
312 if (length < profileSize) { | 312 if (length < profileSize) { |
313 return nullptr; | 313 return nullptr; |
314 } | 314 } |
315 | 315 |
316 return NewICC(data, profileSize); | 316 return NewICC(data, profileSize); |
317 } | 317 } |
318 | 318 |
| 319 bool SkColorSpace::Equals(const SkColorSpace* src, const SkColorSpace* dst) { |
| 320 if (src == dst) { |
| 321 return true; |
| 322 } |
| 323 |
| 324 if (!src || !dst) { |
| 325 return false; |
| 326 } |
| 327 |
| 328 switch (src->fNamed) { |
| 329 case kSRGB_Named: |
| 330 case kAdobeRGB_Named: |
| 331 return src->fNamed == dst->fNamed; |
| 332 case kUnknown_Named: |
| 333 if (kUnknown_Named != dst->fNamed) { |
| 334 return false; |
| 335 } |
| 336 break; |
| 337 } |
| 338 |
| 339 SkData* srcData = as_CSB(src)->fProfileData.get(); |
| 340 SkData* dstData = as_CSB(dst)->fProfileData.get(); |
| 341 if (srcData || dstData) { |
| 342 if (srcData && dstData) { |
| 343 return srcData->size() == dstData->size() && |
| 344 0 == memcmp(srcData->data(), dstData->data(), srcData->size()
); |
| 345 } |
| 346 |
| 347 return false; |
| 348 } |
| 349 |
| 350 // It's important to check fProfileData before named gammas. Some profiles
may have named |
| 351 // gammas, but also include other wacky features that cause us to save the d
ata. |
| 352 switch (src->fGammaNamed) { |
| 353 case kSRGB_GammaNamed: |
| 354 case k2Dot2Curve_GammaNamed: |
| 355 case kLinear_GammaNamed: |
| 356 return (src->fGammaNamed == dst->fGammaNamed) && (src->fToXYZD50 ==
dst->fToXYZD50); |
| 357 default: |
| 358 // If |src| does not have a named gamma, fProfileData should be non-
null. |
| 359 SkASSERT(false); |
| 360 return false; |
| 361 } |
| 362 } |
| 363 |
319 bool SkColorSpace::gammasAreMatching() const { | 364 bool SkColorSpace::gammasAreMatching() const { |
320 const SkGammas* gammas = as_CSB(this)->gammas(); | 365 const SkGammas* gammas = as_CSB(this)->gammas(); |
321 SkASSERT(gammas); | 366 SkASSERT(gammas); |
322 return gammas->fRedType == gammas->fGreenType && gammas->fGreenType == gamma
s->fBlueType && | 367 return gammas->fRedType == gammas->fGreenType && gammas->fGreenType == gamma
s->fBlueType && |
323 gammas->fRedData == gammas->fGreenData && gammas->fGreenData == gamma
s->fBlueData; | 368 gammas->fRedData == gammas->fGreenData && gammas->fGreenData == gamma
s->fBlueData; |
324 } | 369 } |
325 | 370 |
326 bool SkColorSpace::gammasAreNamed() const { | 371 bool SkColorSpace::gammasAreNamed() const { |
327 const SkGammas* gammas = as_CSB(this)->gammas(); | 372 const SkGammas* gammas = as_CSB(this)->gammas(); |
328 SkASSERT(gammas); | 373 SkASSERT(gammas); |
(...skipping 18 matching lines...) Expand all Loading... |
347 gammas->fBlueType == SkGammas::Type::kTable_Type; | 392 gammas->fBlueType == SkGammas::Type::kTable_Type; |
348 } | 393 } |
349 | 394 |
350 bool SkColorSpace::gammasAreParams() const { | 395 bool SkColorSpace::gammasAreParams() const { |
351 const SkGammas* gammas = as_CSB(this)->gammas(); | 396 const SkGammas* gammas = as_CSB(this)->gammas(); |
352 SkASSERT(gammas); | 397 SkASSERT(gammas); |
353 return gammas->fRedType == SkGammas::Type::kParam_Type && | 398 return gammas->fRedType == SkGammas::Type::kParam_Type && |
354 gammas->fGreenType == SkGammas::Type::kParam_Type && | 399 gammas->fGreenType == SkGammas::Type::kParam_Type && |
355 gammas->fBlueType == SkGammas::Type::kParam_Type; | 400 gammas->fBlueType == SkGammas::Type::kParam_Type; |
356 } | 401 } |
OLD | NEW |