Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: src/core/SkColorSpace_ICC.cpp

Issue 2306123002: Delete kInvalid_GammaNamed (part 2) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkColorSpace.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 return 0; 587 return 0;
588 } 588 }
589 } 589 }
590 590
591 /** 591 /**
592 * Sets invalid gamma to the default value. 592 * Sets invalid gamma to the default value.
593 */ 593 */
594 static void handle_invalid_gamma(SkGammas::Type* type, SkGammas::Data* data) { 594 static void handle_invalid_gamma(SkGammas::Type* type, SkGammas::Data* data) {
595 if (SkGammas::Type::kNone_Type == *type) { 595 if (SkGammas::Type::kNone_Type == *type) {
596 *type = SkGammas::Type::kNamed_Type; 596 *type = SkGammas::Type::kNamed_Type;
597 data->fNamed = SkColorSpace::kInvalid_GammaNamed; 597
598 // Guess sRGB in the case of a malformed transfer function.
599 data->fNamed = SkColorSpace::kSRGB_GammaNamed;
598 } 600 }
599 } 601 }
600 602
601 /** 603 /**
602 * Finish loading the gammas, now that we have allocated memory for the SkGamma s struct. 604 * Finish loading the gammas, now that we have allocated memory for the SkGamma s struct.
603 * 605 *
604 * There's nothing to do for the simple cases, but for table gammas we need to actually 606 * There's nothing to do for the simple cases, but for table gammas we need to actually
605 * read the table into heap memory. And for parametric gammas, we need to copy over the 607 * read the table into heap memory. And for parametric gammas, we need to copy over the
606 * parameter values. 608 * parameter values.
607 * 609 *
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 offset += load_gammas(memory, offset, gType, &gData, gParams, gTagPt r); 887 offset += load_gammas(memory, offset, gType, &gData, gParams, gTagPt r);
886 888
887 (*gammas)->fBlueType = bType; 889 (*gammas)->fBlueType = bType;
888 load_gammas(memory, offset, bType, &bData, bParams, bTagPtr); 890 load_gammas(memory, offset, bType, &bData, bParams, bTagPtr);
889 891
890 (*gammas)->fRedData = rData; 892 (*gammas)->fRedData = rData;
891 (*gammas)->fGreenData = gData; 893 (*gammas)->fGreenData = gData;
892 (*gammas)->fBlueData = bData; 894 (*gammas)->fBlueData = bData;
893 } 895 }
894 } else { 896 } else {
895 *gammaNamed = SkColorSpace::kInvalid_GammaNamed; 897 // Guess sRGB if the chunk is missing a transfer function.
898 *gammaNamed = SkColorSpace::kSRGB_GammaNamed;
896 } 899 }
897 900
898 if (SkColorSpace::kNonStandard_GammaNamed == *gammaNamed) { 901 if (SkColorSpace::kNonStandard_GammaNamed == *gammaNamed) {
899 *gammaNamed = is_named(*gammas); 902 *gammaNamed = is_named(*gammas);
900 if (SkColorSpace::kNonStandard_GammaNamed != *gammaNamed) { 903 if (SkColorSpace::kNonStandard_GammaNamed != *gammaNamed) {
901 // No need to keep the gammas struct, the enum is enough. 904 // No need to keep the gammas struct, the enum is enough.
902 *gammas = nullptr; 905 *gammas = nullptr;
903 } 906 }
904 } 907 }
905 908
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 g->addr(base)); 1088 g->addr(base));
1086 1089
1087 gammas->fBlueType = bType; 1090 gammas->fBlueType = bType;
1088 load_gammas(memory, offset, bType, &bData, bParams, b->a ddr(base)); 1091 load_gammas(memory, offset, bType, &bData, bParams, b->a ddr(base));
1089 1092
1090 gammas->fRedData = rData; 1093 gammas->fRedData = rData;
1091 gammas->fGreenData = gData; 1094 gammas->fGreenData = gData;
1092 gammas->fBlueData = bData; 1095 gammas->fBlueData = bData;
1093 } 1096 }
1094 } else { 1097 } else {
1095 gammaNamed = kInvalid_GammaNamed; 1098 // Guess sRGB if the profile is missing transfer functions.
1099 gammaNamed = kSRGB_GammaNamed;
1096 } 1100 }
1097 1101
1098 if (kNonStandard_GammaNamed == gammaNamed) { 1102 if (kNonStandard_GammaNamed == gammaNamed) {
1099 // It's possible that we'll initially detect non-matching ga mmas, only for 1103 // It's possible that we'll initially detect non-matching ga mmas, only for
1100 // them to evaluate to the same named gamma curve. 1104 // them to evaluate to the same named gamma curve.
1101 gammaNamed = is_named(gammas); 1105 gammaNamed = is_named(gammas);
1102 if (kNonStandard_GammaNamed == gammaNamed) { 1106 if (kNonStandard_GammaNamed == gammaNamed) {
1103 return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr , gammaNamed, 1107 return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr , gammaNamed,
1104 std::mo ve(gammas), mat, 1108 std::mo ve(gammas), mat,
1105 std::mo ve(data))); 1109 std::mo ve(data)));
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 ptr32[4] = SkEndian_SwapBE32(0x000116cc); 1361 ptr32[4] = SkEndian_SwapBE32(0x000116cc);
1358 ptr += kTAG_XYZ_Bytes; 1362 ptr += kTAG_XYZ_Bytes;
1359 1363
1360 // Write copyright tag 1364 // Write copyright tag
1361 memcpy(ptr, gEmptyTextTag, sizeof(gEmptyTextTag)); 1365 memcpy(ptr, gEmptyTextTag, sizeof(gEmptyTextTag));
1362 1366
1363 // TODO (msarett): Should we try to hold onto the data so we can return imme diately if 1367 // TODO (msarett): Should we try to hold onto the data so we can return imme diately if
1364 // the client calls again? 1368 // the client calls again?
1365 return SkData::MakeFromMalloc(profile.release(), kICCProfileSize); 1369 return SkData::MakeFromMalloc(profile.release(), kICCProfileSize);
1366 } 1370 }
OLDNEW
« no previous file with comments | « include/core/SkColorSpace.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698