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

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

Issue 2188633003: Expose more gamma info for UMA statistics (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Track invalid gamma as well Created 4 years, 4 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 | « src/core/SkColorSpace.cpp ('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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 return 0; 553 return 0;
554 } 554 }
555 } 555 }
556 556
557 /** 557 /**
558 * Sets invalid gamma to the default value. 558 * Sets invalid gamma to the default value.
559 */ 559 */
560 static void handle_invalid_gamma(SkGammas::Type* type, SkGammas::Data* data) { 560 static void handle_invalid_gamma(SkGammas::Type* type, SkGammas::Data* data) {
561 if (SkGammas::Type::kNone_Type == *type) { 561 if (SkGammas::Type::kNone_Type == *type) {
562 *type = SkGammas::Type::kNamed_Type; 562 *type = SkGammas::Type::kNamed_Type;
563 data->fNamed = SkColorSpace::kSRGB_GammaNamed; 563 data->fNamed = SkColorSpace::kInvalid_GammaNamed;
564 } 564 }
565 } 565 }
566 566
567 /** 567 /**
568 * Finish loading the gammas, now that we have allocated memory for the SkGamma s struct. 568 * Finish loading the gammas, now that we have allocated memory for the SkGamma s struct.
569 * 569 *
570 * There's nothing to do for the simple cases, but for table gammas we need to actually 570 * There's nothing to do for the simple cases, but for table gammas we need to actually
571 * read the table into heap memory. And for parametric gammas, we need to copy over the 571 * read the table into heap memory. And for parametric gammas, we need to copy over the
572 * parameter values. 572 * parameter values.
573 * 573 *
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 (*gammas)->fGreenType = gType; 832 (*gammas)->fGreenType = gType;
833 offset += load_gammas(memory, offset, gType, &gData, gParams, gTagPt r); 833 offset += load_gammas(memory, offset, gType, &gData, gParams, gTagPt r);
834 834
835 (*gammas)->fBlueType = bType; 835 (*gammas)->fBlueType = bType;
836 load_gammas(memory, offset, bType, &bData, bParams, bTagPtr); 836 load_gammas(memory, offset, bType, &bData, bParams, bTagPtr);
837 837
838 (*gammas)->fRedData = rData; 838 (*gammas)->fRedData = rData;
839 (*gammas)->fGreenData = gData; 839 (*gammas)->fGreenData = gData;
840 (*gammas)->fBlueData = bData; 840 (*gammas)->fBlueData = bData;
841 } 841 }
842 } else {
843 *gammaNamed = SkColorSpace::kInvalid_GammaNamed;
842 } 844 }
843 845
844 uint32_t offsetToMatrix = read_big_endian_i32(src + 16); 846 uint32_t offsetToMatrix = read_big_endian_i32(src + 16);
845 if (0 != offsetToMatrix && offsetToMatrix < len) { 847 if (0 != offsetToMatrix && offsetToMatrix < len) {
846 if (!load_matrix(toXYZ, src + offsetToMatrix, len - offsetToMatrix)) { 848 if (!load_matrix(toXYZ, src + offsetToMatrix, len - offsetToMatrix)) {
847 SkColorSpacePrintf("Failed to read matrix from A to B tag.\n"); 849 SkColorSpacePrintf("Failed to read matrix from A to B tag.\n");
848 toXYZ->setIdentity(); 850 toXYZ->setIdentity();
849 } 851 }
850 } 852 }
851 853
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 } 956 }
955 } 957 }
956 958
957 GammaNamed gammaNamed = kNonStandard_GammaNamed; 959 GammaNamed gammaNamed = kNonStandard_GammaNamed;
958 sk_sp<SkGammas> gammas = nullptr; 960 sk_sp<SkGammas> gammas = nullptr;
959 size_t tagBytes; 961 size_t tagBytes;
960 if (r && g && b) { 962 if (r && g && b) {
961 if (tag_equals(r, g, base) && tag_equals(g, b, base)) { 963 if (tag_equals(r, g, base) && tag_equals(g, b, base)) {
962 SkGammas::Data data; 964 SkGammas::Data data;
963 SkGammas::Params params; 965 SkGammas::Params params;
964 SkGammas::Type Type = 966 SkGammas::Type type =
965 parse_gamma(&data, &params, &tagBytes, r->addr(b ase), r->fLength); 967 parse_gamma(&data, &params, &tagBytes, r->addr(b ase), r->fLength);
966 handle_invalid_gamma(&Type, &data); 968 handle_invalid_gamma(&type, &data);
967 969
968 if (SkGammas::Type::kNamed_Type == Type) { 970 if (SkGammas::Type::kNamed_Type == type) {
969 gammaNamed = data.fNamed; 971 gammaNamed = data.fNamed;
970 } else { 972 } else {
971 size_t allocSize = sizeof(SkGammas) + gamma_alloc_si ze(Type, data); 973 size_t allocSize = sizeof(SkGammas) + gamma_alloc_si ze(type, data);
972 void* memory = sk_malloc_throw(allocSize); 974 void* memory = sk_malloc_throw(allocSize);
973 gammas = sk_sp<SkGammas>(new (memory) SkGammas()); 975 gammas = sk_sp<SkGammas>(new (memory) SkGammas());
974 load_gammas(memory, 0, Type, &data, params, r->addr( base)); 976 load_gammas(memory, 0, type, &data, params, r->addr( base));
975 977
976 gammas->fRedType = Type; 978 gammas->fRedType = type;
977 gammas->fGreenType = Type; 979 gammas->fGreenType = type;
978 gammas->fBlueType = Type; 980 gammas->fBlueType = type;
979 981
980 gammas->fRedData = data; 982 gammas->fRedData = data;
981 gammas->fGreenData = data; 983 gammas->fGreenData = data;
982 gammas->fBlueData = data; 984 gammas->fBlueData = data;
983 } 985 }
984 } else { 986 } else {
985 SkGammas::Data rData; 987 SkGammas::Data rData;
986 SkGammas::Params rParams; 988 SkGammas::Params rParams;
987 SkGammas::Type rType = 989 SkGammas::Type rType =
988 parse_gamma(&rData, &rParams, &tagBytes, r->addr (base), r->fLength); 990 parse_gamma(&rData, &rParams, &tagBytes, r->addr (base), r->fLength);
(...skipping 27 matching lines...) Expand all
1016 g->addr(base)); 1018 g->addr(base));
1017 1019
1018 gammas->fBlueType = bType; 1020 gammas->fBlueType = bType;
1019 load_gammas(memory, offset, bType, &bData, bParams, b->a ddr(base)); 1021 load_gammas(memory, offset, bType, &bData, bParams, b->a ddr(base));
1020 1022
1021 gammas->fRedData = rData; 1023 gammas->fRedData = rData;
1022 gammas->fGreenData = gData; 1024 gammas->fGreenData = gData;
1023 gammas->fBlueData = bData; 1025 gammas->fBlueData = bData;
1024 } 1026 }
1025 } else { 1027 } else {
1026 gammaNamed = kLinear_GammaNamed; 1028 gammaNamed = kInvalid_GammaNamed;
1027 } 1029 }
1028 1030
1029 if (kNonStandard_GammaNamed == gammaNamed) { 1031 if (kNonStandard_GammaNamed == gammaNamed) {
1030 return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr, ga mmaNamed, 1032 return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr, ga mmaNamed,
1031 std::move(g ammas), mat, 1033 std::move(g ammas), mat,
1032 std::move(d ata))); 1034 std::move(d ata)));
1033 } else { 1035 } else {
1034 return SkColorSpace_Base::NewRGB(gammaNamed, mat); 1036 return SkColorSpace_Base::NewRGB(gammaNamed, mat);
1035 } 1037 }
1036 } 1038 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 ptr32[4] = SkEndian_SwapBE32(0x000116cc); 1285 ptr32[4] = SkEndian_SwapBE32(0x000116cc);
1284 ptr += kTAG_XYZ_Bytes; 1286 ptr += kTAG_XYZ_Bytes;
1285 1287
1286 // Write copyright tag 1288 // Write copyright tag
1287 memcpy(ptr, gEmptyTextTag, sizeof(gEmptyTextTag)); 1289 memcpy(ptr, gEmptyTextTag, sizeof(gEmptyTextTag));
1288 1290
1289 // TODO (msarett): Should we try to hold onto the data so we can return imme diately if 1291 // TODO (msarett): Should we try to hold onto the data so we can return imme diately if
1290 // the client calls again? 1292 // the client calls again?
1291 return SkData::MakeFromMalloc(profile.release(), kICCProfileSize); 1293 return SkData::MakeFromMalloc(profile.release(), kICCProfileSize);
1292 } 1294 }
OLDNEW
« no previous file with comments | « src/core/SkColorSpace.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698