Expose more gamma info for UMA statistics
TBR=reed@google.com BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2188633003 Review-Url: https://codereview.chromium.org/2188633003
This commit is contained in:
parent
34ee0c950e
commit
7b9b541af8
@ -42,10 +42,14 @@ public:
|
||||
|
||||
/**
|
||||
* Gamma is represented by a look-up table, a parametric curve, or an uncommon
|
||||
* exponential curve. Or there is an additional pre-processing step before the
|
||||
* applying the gamma.
|
||||
* exponential curve. Or the R, G, and B gammas do not match.
|
||||
*/
|
||||
kNonStandard_GammaNamed,
|
||||
|
||||
/**
|
||||
* To be used by UMA code only. ICC profiles lacks valid gamma representation.
|
||||
*/
|
||||
kInvalid_GammaNamed,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -77,6 +81,15 @@ public:
|
||||
return kSRGB_GammaNamed == fGammaNamed || k2Dot2Curve_GammaNamed == fGammaNamed;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be used only by UMA code.
|
||||
*/
|
||||
bool gammasAreMatching() const;
|
||||
bool gammasAreNamed() const;
|
||||
bool gammasAreValues() const;
|
||||
bool gammasAreTables() const;
|
||||
bool gammasAreParams() const;
|
||||
|
||||
/**
|
||||
* Returns nullptr on failure. Fails when we fallback to serializing ICC data and
|
||||
* the data is too large to serialize.
|
||||
|
@ -304,3 +304,41 @@ sk_sp<SkColorSpace> SkColorSpace::Deserialize(const void* data, size_t length) {
|
||||
|
||||
return NewICC(data, profileSize);
|
||||
}
|
||||
|
||||
bool SkColorSpace::gammasAreMatching() const {
|
||||
const SkGammas* gammas = as_CSB(this)->gammas();
|
||||
SkASSERT(gammas);
|
||||
return gammas->fRedData == gammas->fGreenData && gammas->fGreenData == gammas->fBlueData;
|
||||
}
|
||||
|
||||
bool SkColorSpace::gammasAreNamed() const {
|
||||
const SkGammas* gammas = as_CSB(this)->gammas();
|
||||
SkASSERT(gammas);
|
||||
return gammas->fRedType == SkGammas::Type::kNamed_Type &&
|
||||
gammas->fGreenType == SkGammas::Type::kNamed_Type &&
|
||||
gammas->fBlueType == SkGammas::Type::kNamed_Type;
|
||||
}
|
||||
|
||||
bool SkColorSpace::gammasAreValues() const {
|
||||
const SkGammas* gammas = as_CSB(this)->gammas();
|
||||
SkASSERT(gammas);
|
||||
return gammas->fRedType == SkGammas::Type::kValue_Type &&
|
||||
gammas->fGreenType == SkGammas::Type::kValue_Type &&
|
||||
gammas->fBlueType == SkGammas::Type::kValue_Type;
|
||||
}
|
||||
|
||||
bool SkColorSpace::gammasAreTables() const {
|
||||
const SkGammas* gammas = as_CSB(this)->gammas();
|
||||
SkASSERT(gammas);
|
||||
return gammas->fRedType == SkGammas::Type::kTable_Type &&
|
||||
gammas->fGreenType == SkGammas::Type::kTable_Type &&
|
||||
gammas->fBlueType == SkGammas::Type::kTable_Type;
|
||||
}
|
||||
|
||||
bool SkColorSpace::gammasAreParams() const {
|
||||
const SkGammas* gammas = as_CSB(this)->gammas();
|
||||
SkASSERT(gammas);
|
||||
return gammas->fRedType == SkGammas::Type::kParam_Type &&
|
||||
gammas->fGreenType == SkGammas::Type::kParam_Type &&
|
||||
gammas->fBlueType == SkGammas::Type::kParam_Type;
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ static size_t gamma_alloc_size(SkGammas::Type type, const SkGammas::Data& data)
|
||||
static void handle_invalid_gamma(SkGammas::Type* type, SkGammas::Data* data) {
|
||||
if (SkGammas::Type::kNone_Type == *type) {
|
||||
*type = SkGammas::Type::kNamed_Type;
|
||||
data->fNamed = SkColorSpace::kSRGB_GammaNamed;
|
||||
data->fNamed = SkColorSpace::kInvalid_GammaNamed;
|
||||
}
|
||||
}
|
||||
|
||||
@ -839,6 +839,8 @@ static bool load_a2b0(sk_sp<SkColorLookUpTable>* colorLUT, SkColorSpace::GammaNa
|
||||
(*gammas)->fGreenData = gData;
|
||||
(*gammas)->fBlueData = bData;
|
||||
}
|
||||
} else {
|
||||
*gammaNamed = SkColorSpace::kInvalid_GammaNamed;
|
||||
}
|
||||
|
||||
uint32_t offsetToMatrix = read_big_endian_i32(src + 16);
|
||||
@ -961,21 +963,21 @@ sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* input, size_t len) {
|
||||
if (tag_equals(r, g, base) && tag_equals(g, b, base)) {
|
||||
SkGammas::Data data;
|
||||
SkGammas::Params params;
|
||||
SkGammas::Type Type =
|
||||
SkGammas::Type type =
|
||||
parse_gamma(&data, ¶ms, &tagBytes, r->addr(base), r->fLength);
|
||||
handle_invalid_gamma(&Type, &data);
|
||||
handle_invalid_gamma(&type, &data);
|
||||
|
||||
if (SkGammas::Type::kNamed_Type == Type) {
|
||||
if (SkGammas::Type::kNamed_Type == type) {
|
||||
gammaNamed = data.fNamed;
|
||||
} else {
|
||||
size_t allocSize = sizeof(SkGammas) + gamma_alloc_size(Type, data);
|
||||
size_t allocSize = sizeof(SkGammas) + gamma_alloc_size(type, data);
|
||||
void* memory = sk_malloc_throw(allocSize);
|
||||
gammas = sk_sp<SkGammas>(new (memory) SkGammas());
|
||||
load_gammas(memory, 0, Type, &data, params, r->addr(base));
|
||||
load_gammas(memory, 0, type, &data, params, r->addr(base));
|
||||
|
||||
gammas->fRedType = Type;
|
||||
gammas->fGreenType = Type;
|
||||
gammas->fBlueType = Type;
|
||||
gammas->fRedType = type;
|
||||
gammas->fGreenType = type;
|
||||
gammas->fBlueType = type;
|
||||
|
||||
gammas->fRedData = data;
|
||||
gammas->fGreenData = data;
|
||||
@ -1023,7 +1025,7 @@ sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* input, size_t len) {
|
||||
gammas->fBlueData = bData;
|
||||
}
|
||||
} else {
|
||||
gammaNamed = kLinear_GammaNamed;
|
||||
gammaNamed = kInvalid_GammaNamed;
|
||||
}
|
||||
|
||||
if (kNonStandard_GammaNamed == gammaNamed) {
|
||||
|
Loading…
Reference in New Issue
Block a user