Delete SkColorSpace::gammaNamed() from public API
Move fGammaNamed to SkColorSpace_Base. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2318663003 Review-Url: https://codereview.chromium.org/2318663003
This commit is contained in:
parent
720dc71cfe
commit
600c737b64
@ -37,22 +37,10 @@ public:
|
|||||||
kLinear_GammaNamed,
|
kLinear_GammaNamed,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gamma curve is a close match to the canonical sRGB curve, which has
|
* Transfer function is the canonical sRGB curve, which has a short linear segment
|
||||||
* a short linear segment followed by a 2.4f exponential.
|
* followed by a 2.4f exponential.
|
||||||
*/
|
*/
|
||||||
kSRGB_GammaNamed,
|
kSRGB_GammaNamed,
|
||||||
|
|
||||||
/**
|
|
||||||
* Gamma curve is a close match to the 2.2f exponential curve. This is
|
|
||||||
* used by Adobe RGB profiles and is common on monitors as well.
|
|
||||||
*/
|
|
||||||
k2Dot2Curve_GammaNamed,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gamma is represented by a look-up table, a parametric curve, or an uncommon
|
|
||||||
* exponential curve. Or the R, G, and B gammas do not match.
|
|
||||||
*/
|
|
||||||
kNonStandard_GammaNamed,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,11 +63,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
sk_sp<SkColorSpace> makeLinearGamma();
|
sk_sp<SkColorSpace> makeLinearGamma();
|
||||||
|
|
||||||
/**
|
|
||||||
* DO NOT USE: Will be deleted.
|
|
||||||
*/
|
|
||||||
GammaNamed gammaNamed() const { return fGammaNamed; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the matrix used to transform src gamut to XYZ D50.
|
* Returns the matrix used to transform src gamut to XYZ D50.
|
||||||
*/
|
*/
|
||||||
@ -88,16 +71,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Returns true if the color space gamma is near enough to be approximated as sRGB.
|
* Returns true if the color space gamma is near enough to be approximated as sRGB.
|
||||||
*/
|
*/
|
||||||
bool gammaCloseToSRGB() const {
|
bool gammaCloseToSRGB() const;
|
||||||
return kSRGB_GammaNamed == fGammaNamed || k2Dot2Curve_GammaNamed == fGammaNamed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the color space gamma is linear.
|
* Returns true if the color space gamma is linear.
|
||||||
*/
|
*/
|
||||||
bool gammaIsLinear() const {
|
bool gammaIsLinear() const;
|
||||||
return kLinear_GammaNamed == fGammaNamed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns nullptr on failure. Fails when we fallback to serializing ICC data and
|
* Returns nullptr on failure. Fails when we fallback to serializing ICC data and
|
||||||
@ -120,9 +99,8 @@ public:
|
|||||||
static bool Equals(const SkColorSpace* src, const SkColorSpace* dst);
|
static bool Equals(const SkColorSpace* src, const SkColorSpace* dst);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50);
|
SkColorSpace(const SkMatrix44& toXYZD50);
|
||||||
|
|
||||||
const GammaNamed fGammaNamed;
|
|
||||||
const SkMatrix44 fToXYZD50;
|
const SkMatrix44 fToXYZD50;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,22 +10,23 @@
|
|||||||
#include "SkColorSpacePriv.h"
|
#include "SkColorSpacePriv.h"
|
||||||
#include "SkOnce.h"
|
#include "SkOnce.h"
|
||||||
|
|
||||||
SkColorSpace::SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50)
|
SkColorSpace::SkColorSpace(const SkMatrix44& toXYZD50)
|
||||||
: fGammaNamed(gammaNamed)
|
: fToXYZD50(toXYZD50)
|
||||||
, fToXYZD50(toXYZD50)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SkColorSpace_Base::SkColorSpace_Base(GammaNamed gammaNamed, const SkMatrix44& toXYZD50)
|
SkColorSpace_Base::SkColorSpace_Base(SkGammaNamed gammaNamed, const SkMatrix44& toXYZD50)
|
||||||
: INHERITED(gammaNamed, toXYZD50)
|
: INHERITED(toXYZD50)
|
||||||
|
, fGammaNamed(gammaNamed)
|
||||||
, fGammas(nullptr)
|
, fGammas(nullptr)
|
||||||
, fProfileData(nullptr)
|
, fProfileData(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SkColorSpace_Base::SkColorSpace_Base(sk_sp<SkColorLookUpTable> colorLUT, GammaNamed gammaNamed,
|
SkColorSpace_Base::SkColorSpace_Base(sk_sp<SkColorLookUpTable> colorLUT, SkGammaNamed gammaNamed,
|
||||||
sk_sp<SkGammas> gammas, const SkMatrix44& toXYZD50,
|
sk_sp<SkGammas> gammas, const SkMatrix44& toXYZD50,
|
||||||
sk_sp<SkData> profileData)
|
sk_sp<SkData> profileData)
|
||||||
: INHERITED(gammaNamed, toXYZD50)
|
: INHERITED(toXYZD50)
|
||||||
, fColorLUT(std::move(colorLUT))
|
, fColorLUT(std::move(colorLUT))
|
||||||
|
, fGammaNamed(gammaNamed)
|
||||||
, fGammas(std::move(gammas))
|
, fGammas(std::move(gammas))
|
||||||
, fProfileData(std::move(profileData))
|
, fProfileData(std::move(profileData))
|
||||||
{}
|
{}
|
||||||
@ -72,18 +73,18 @@ sk_sp<SkColorSpace> SkColorSpace_Base::NewRGB(const float values[3], const SkMat
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GammaNamed gammaNamed = kNonStandard_GammaNamed;
|
SkGammaNamed gammaNamed = kNonStandard_SkGammaNamed;
|
||||||
if (color_space_almost_equal(2.2f, values[0]) &&
|
if (color_space_almost_equal(2.2f, values[0]) &&
|
||||||
color_space_almost_equal(2.2f, values[1]) &&
|
color_space_almost_equal(2.2f, values[1]) &&
|
||||||
color_space_almost_equal(2.2f, values[2])) {
|
color_space_almost_equal(2.2f, values[2])) {
|
||||||
gammaNamed = k2Dot2Curve_GammaNamed;
|
gammaNamed = k2Dot2Curve_SkGammaNamed;
|
||||||
} else if (color_space_almost_equal(1.0f, values[0]) &&
|
} else if (color_space_almost_equal(1.0f, values[0]) &&
|
||||||
color_space_almost_equal(1.0f, values[1]) &&
|
color_space_almost_equal(1.0f, values[1]) &&
|
||||||
color_space_almost_equal(1.0f, values[2])) {
|
color_space_almost_equal(1.0f, values[2])) {
|
||||||
gammaNamed = kLinear_GammaNamed;
|
gammaNamed = kLinear_SkGammaNamed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kNonStandard_GammaNamed == gammaNamed) {
|
if (kNonStandard_SkGammaNamed == gammaNamed) {
|
||||||
sk_sp<SkGammas> gammas = sk_sp<SkGammas>(new SkGammas());
|
sk_sp<SkGammas> gammas = sk_sp<SkGammas>(new SkGammas());
|
||||||
gammas->fRedType = SkGammas::Type::kValue_Type;
|
gammas->fRedType = SkGammas::Type::kValue_Type;
|
||||||
gammas->fGreenType = SkGammas::Type::kValue_Type;
|
gammas->fGreenType = SkGammas::Type::kValue_Type;
|
||||||
@ -91,26 +92,26 @@ sk_sp<SkColorSpace> SkColorSpace_Base::NewRGB(const float values[3], const SkMat
|
|||||||
gammas->fRedData.fValue = values[0];
|
gammas->fRedData.fValue = values[0];
|
||||||
gammas->fGreenData.fValue = values[1];
|
gammas->fGreenData.fValue = values[1];
|
||||||
gammas->fBlueData.fValue = values[2];
|
gammas->fBlueData.fValue = values[2];
|
||||||
return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr, kNonStandard_GammaNamed, gammas,
|
return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr, kNonStandard_SkGammaNamed, gammas,
|
||||||
toXYZD50, nullptr));
|
toXYZD50, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
return SkColorSpace_Base::NewRGB(gammaNamed, toXYZD50);
|
return SkColorSpace_Base::NewRGB(gammaNamed, toXYZD50);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkColorSpace> SkColorSpace_Base::NewRGB(GammaNamed gammaNamed, const SkMatrix44& toXYZD50) {
|
sk_sp<SkColorSpace> SkColorSpace_Base::NewRGB(SkGammaNamed gammaNamed, const SkMatrix44& toXYZD50) {
|
||||||
switch (gammaNamed) {
|
switch (gammaNamed) {
|
||||||
case kSRGB_GammaNamed:
|
case kSRGB_SkGammaNamed:
|
||||||
if (xyz_almost_equal(toXYZD50, gSRGB_toXYZD50)) {
|
if (xyz_almost_equal(toXYZD50, gSRGB_toXYZD50)) {
|
||||||
return SkColorSpace::NewNamed(kSRGB_Named);
|
return SkColorSpace::NewNamed(kSRGB_Named);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case k2Dot2Curve_GammaNamed:
|
case k2Dot2Curve_SkGammaNamed:
|
||||||
if (xyz_almost_equal(toXYZD50, gAdobeRGB_toXYZD50)) {
|
if (xyz_almost_equal(toXYZD50, gAdobeRGB_toXYZD50)) {
|
||||||
return SkColorSpace::NewNamed(kAdobeRGB_Named);
|
return SkColorSpace::NewNamed(kAdobeRGB_Named);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kNonStandard_GammaNamed:
|
case kNonStandard_SkGammaNamed:
|
||||||
// This is not allowed.
|
// This is not allowed.
|
||||||
return nullptr;
|
return nullptr;
|
||||||
default:
|
default:
|
||||||
@ -121,7 +122,14 @@ sk_sp<SkColorSpace> SkColorSpace_Base::NewRGB(GammaNamed gammaNamed, const SkMat
|
|||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkColorSpace> SkColorSpace::NewRGB(GammaNamed gammaNamed, const SkMatrix44& toXYZD50) {
|
sk_sp<SkColorSpace> SkColorSpace::NewRGB(GammaNamed gammaNamed, const SkMatrix44& toXYZD50) {
|
||||||
return SkColorSpace_Base::NewRGB(gammaNamed, toXYZD50);
|
switch (gammaNamed) {
|
||||||
|
case kLinear_GammaNamed:
|
||||||
|
return SkColorSpace_Base::NewRGB(kLinear_SkGammaNamed, toXYZD50);
|
||||||
|
case kSRGB_GammaNamed:
|
||||||
|
return SkColorSpace_Base::NewRGB(kSRGB_SkGammaNamed, toXYZD50);
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SkColorSpace* gAdobeRGB;
|
static SkColorSpace* gAdobeRGB;
|
||||||
@ -139,7 +147,7 @@ sk_sp<SkColorSpace> SkColorSpace::NewNamed(Named named) {
|
|||||||
|
|
||||||
// Force the mutable type mask to be computed. This avoids races.
|
// Force the mutable type mask to be computed. This avoids races.
|
||||||
(void)srgbToxyzD50.getType();
|
(void)srgbToxyzD50.getType();
|
||||||
gSRGB = new SkColorSpace_Base(kSRGB_GammaNamed, srgbToxyzD50);
|
gSRGB = new SkColorSpace_Base(kSRGB_SkGammaNamed, srgbToxyzD50);
|
||||||
});
|
});
|
||||||
return sk_ref_sp<SkColorSpace>(gSRGB);
|
return sk_ref_sp<SkColorSpace>(gSRGB);
|
||||||
}
|
}
|
||||||
@ -150,7 +158,7 @@ sk_sp<SkColorSpace> SkColorSpace::NewNamed(Named named) {
|
|||||||
|
|
||||||
// Force the mutable type mask to be computed. This avoids races.
|
// Force the mutable type mask to be computed. This avoids races.
|
||||||
(void)adobergbToxyzD50.getType();
|
(void)adobergbToxyzD50.getType();
|
||||||
gAdobeRGB = new SkColorSpace_Base(k2Dot2Curve_GammaNamed, adobergbToxyzD50);
|
gAdobeRGB = new SkColorSpace_Base(k2Dot2Curve_SkGammaNamed, adobergbToxyzD50);
|
||||||
});
|
});
|
||||||
return sk_ref_sp<SkColorSpace>(gAdobeRGB);
|
return sk_ref_sp<SkColorSpace>(gAdobeRGB);
|
||||||
}
|
}
|
||||||
@ -161,7 +169,17 @@ sk_sp<SkColorSpace> SkColorSpace::NewNamed(Named named) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkColorSpace> SkColorSpace::makeLinearGamma() {
|
sk_sp<SkColorSpace> SkColorSpace::makeLinearGamma() {
|
||||||
return SkColorSpace_Base::NewRGB(kLinear_GammaNamed, fToXYZD50);
|
return SkColorSpace_Base::NewRGB(kLinear_SkGammaNamed, fToXYZD50);
|
||||||
|
}
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool SkColorSpace::gammaCloseToSRGB() const {
|
||||||
|
return kSRGB_SkGammaNamed == as_CSB(this)->fGammaNamed ||
|
||||||
|
k2Dot2Curve_SkGammaNamed == as_CSB(this)->fGammaNamed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SkColorSpace::gammaIsLinear() const {
|
||||||
|
return kLinear_SkGammaNamed == as_CSB(this)->fGammaNamed;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -203,7 +221,7 @@ struct ColorSpaceHeader {
|
|||||||
SkASSERT(named <= SkColorSpace::kAdobeRGB_Named);
|
SkASSERT(named <= SkColorSpace::kAdobeRGB_Named);
|
||||||
header.fNamed = (uint8_t) named;
|
header.fNamed = (uint8_t) named;
|
||||||
|
|
||||||
SkASSERT(gammaNamed <= SkColorSpace::kNonStandard_GammaNamed);
|
SkASSERT(gammaNamed <= kNonStandard_SkGammaNamed);
|
||||||
header.fGammaNamed = (uint8_t) gammaNamed;
|
header.fGammaNamed = (uint8_t) gammaNamed;
|
||||||
|
|
||||||
SkASSERT(flags <= kFloatGamma_Flag);
|
SkASSERT(flags <= kFloatGamma_Flag);
|
||||||
@ -213,7 +231,7 @@ struct ColorSpaceHeader {
|
|||||||
|
|
||||||
uint8_t fVersion; // Always zero
|
uint8_t fVersion; // Always zero
|
||||||
uint8_t fNamed; // Must be a SkColorSpace::Named
|
uint8_t fNamed; // Must be a SkColorSpace::Named
|
||||||
uint8_t fGammaNamed; // Must be a SkColorSpace::GammaNamed
|
uint8_t fGammaNamed; // Must be a SkGammaNamed
|
||||||
uint8_t fFlags; // Some combination of the flags listed above
|
uint8_t fFlags; // Some combination of the flags listed above
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -225,24 +243,26 @@ size_t SkColorSpace::writeToMemory(void* memory) const {
|
|||||||
if (this == gSRGB) {
|
if (this == gSRGB) {
|
||||||
if (memory) {
|
if (memory) {
|
||||||
*((ColorSpaceHeader*) memory) =
|
*((ColorSpaceHeader*) memory) =
|
||||||
ColorSpaceHeader::Pack(k0_Version, kSRGB_Named, fGammaNamed, 0);
|
ColorSpaceHeader::Pack(k0_Version, kSRGB_Named,
|
||||||
|
as_CSB(this)->fGammaNamed, 0);
|
||||||
}
|
}
|
||||||
return sizeof(ColorSpaceHeader);
|
return sizeof(ColorSpaceHeader);
|
||||||
} else if (this == gAdobeRGB) {
|
} else if (this == gAdobeRGB) {
|
||||||
if (memory) {
|
if (memory) {
|
||||||
*((ColorSpaceHeader*) memory) =
|
*((ColorSpaceHeader*) memory) =
|
||||||
ColorSpaceHeader::Pack(k0_Version, kAdobeRGB_Named, fGammaNamed, 0);
|
ColorSpaceHeader::Pack(k0_Version, kAdobeRGB_Named,
|
||||||
|
as_CSB(this)->fGammaNamed, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a named gamma, write the enum and the matrix.
|
// If we have a named gamma, write the enum and the matrix.
|
||||||
switch (fGammaNamed) {
|
switch (as_CSB(this)->fGammaNamed) {
|
||||||
case kSRGB_GammaNamed:
|
case kSRGB_SkGammaNamed:
|
||||||
case k2Dot2Curve_GammaNamed:
|
case k2Dot2Curve_SkGammaNamed:
|
||||||
case kLinear_GammaNamed: {
|
case kLinear_SkGammaNamed: {
|
||||||
if (memory) {
|
if (memory) {
|
||||||
*((ColorSpaceHeader*) memory) =
|
*((ColorSpaceHeader*) memory) =
|
||||||
ColorSpaceHeader::Pack(k0_Version, 0, fGammaNamed,
|
ColorSpaceHeader::Pack(k0_Version, 0, as_CSB(this)->fGammaNamed,
|
||||||
ColorSpaceHeader::kMatrix_Flag);
|
ColorSpaceHeader::kMatrix_Flag);
|
||||||
memory = SkTAddOffset<void>(memory, sizeof(ColorSpaceHeader));
|
memory = SkTAddOffset<void>(memory, sizeof(ColorSpaceHeader));
|
||||||
fToXYZD50.as4x3ColMajorf((float*) memory);
|
fToXYZD50.as4x3ColMajorf((float*) memory);
|
||||||
@ -253,7 +273,7 @@ size_t SkColorSpace::writeToMemory(void* memory) const {
|
|||||||
// Otherwise, write the gamma values and the matrix.
|
// Otherwise, write the gamma values and the matrix.
|
||||||
if (memory) {
|
if (memory) {
|
||||||
*((ColorSpaceHeader*) memory) =
|
*((ColorSpaceHeader*) memory) =
|
||||||
ColorSpaceHeader::Pack(k0_Version, 0, fGammaNamed,
|
ColorSpaceHeader::Pack(k0_Version, 0, as_CSB(this)->fGammaNamed,
|
||||||
ColorSpaceHeader::kFloatGamma_Flag);
|
ColorSpaceHeader::kFloatGamma_Flag);
|
||||||
memory = SkTAddOffset<void>(memory, sizeof(ColorSpaceHeader));
|
memory = SkTAddOffset<void>(memory, sizeof(ColorSpaceHeader));
|
||||||
|
|
||||||
@ -281,7 +301,7 @@ size_t SkColorSpace::writeToMemory(void* memory) const {
|
|||||||
|
|
||||||
if (memory) {
|
if (memory) {
|
||||||
*((ColorSpaceHeader*) memory) = ColorSpaceHeader::Pack(k0_Version, 0,
|
*((ColorSpaceHeader*) memory) = ColorSpaceHeader::Pack(k0_Version, 0,
|
||||||
kNonStandard_GammaNamed,
|
kNonStandard_SkGammaNamed,
|
||||||
ColorSpaceHeader::kICC_Flag);
|
ColorSpaceHeader::kICC_Flag);
|
||||||
memory = SkTAddOffset<void>(memory, sizeof(ColorSpaceHeader));
|
memory = SkTAddOffset<void>(memory, sizeof(ColorSpaceHeader));
|
||||||
|
|
||||||
@ -317,17 +337,17 @@ sk_sp<SkColorSpace> SkColorSpace::Deserialize(const void* data, size_t length) {
|
|||||||
return NewNamed((Named) header.fNamed);
|
return NewNamed((Named) header.fNamed);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ((GammaNamed) header.fGammaNamed) {
|
switch ((SkGammaNamed) header.fGammaNamed) {
|
||||||
case kSRGB_GammaNamed:
|
case kSRGB_SkGammaNamed:
|
||||||
case k2Dot2Curve_GammaNamed:
|
case k2Dot2Curve_SkGammaNamed:
|
||||||
case kLinear_GammaNamed: {
|
case kLinear_SkGammaNamed: {
|
||||||
if (ColorSpaceHeader::kMatrix_Flag != header.fFlags || length < 12 * sizeof(float)) {
|
if (ColorSpaceHeader::kMatrix_Flag != header.fFlags || length < 12 * sizeof(float)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkMatrix44 toXYZ(SkMatrix44::kUninitialized_Constructor);
|
SkMatrix44 toXYZ(SkMatrix44::kUninitialized_Constructor);
|
||||||
toXYZ.set4x3ColMajorf((const float*) data);
|
toXYZ.set4x3ColMajorf((const float*) data);
|
||||||
return NewRGB((GammaNamed) header.fGammaNamed, toXYZ);
|
return SkColorSpace_Base::NewRGB((SkGammaNamed) header.fGammaNamed, toXYZ);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -390,13 +410,14 @@ bool SkColorSpace::Equals(const SkColorSpace* src, const SkColorSpace* dst) {
|
|||||||
|
|
||||||
// It's important to check fProfileData before named gammas. Some profiles may have named
|
// It's important to check fProfileData before named gammas. Some profiles may have named
|
||||||
// gammas, but also include other wacky features that cause us to save the data.
|
// gammas, but also include other wacky features that cause us to save the data.
|
||||||
switch (src->fGammaNamed) {
|
switch (as_CSB(src)->fGammaNamed) {
|
||||||
case kSRGB_GammaNamed:
|
case kSRGB_SkGammaNamed:
|
||||||
case k2Dot2Curve_GammaNamed:
|
case k2Dot2Curve_SkGammaNamed:
|
||||||
case kLinear_GammaNamed:
|
case kLinear_SkGammaNamed:
|
||||||
return (src->fGammaNamed == dst->fGammaNamed) && (src->fToXYZD50 == dst->fToXYZD50);
|
return (as_CSB(src)->fGammaNamed == as_CSB(dst)->fGammaNamed) &&
|
||||||
|
(src->fToXYZD50 == dst->fToXYZD50);
|
||||||
default:
|
default:
|
||||||
if (src->fGammaNamed != dst->fGammaNamed) {
|
if (as_CSB(src)->fGammaNamed != as_CSB(dst)->fGammaNamed) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ static uint8_t clamp_normalized_float_to_byte(float v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const int kDstGammaTableSize =
|
static const int kDstGammaTableSize =
|
||||||
SkColorSpaceXform_Base<SkColorSpace::kNonStandard_GammaNamed, kNone_ColorSpaceMatch>
|
SkColorSpaceXform_Base<kNonStandard_SkGammaNamed, kNone_ColorSpaceMatch>
|
||||||
::kDstGammaTableSize;
|
::kDstGammaTableSize;
|
||||||
|
|
||||||
static void build_table_linear_to_gamma(uint8_t* outTable, float exponent) {
|
static void build_table_linear_to_gamma(uint8_t* outTable, float exponent) {
|
||||||
@ -380,14 +380,14 @@ static const GammaFns<uint8_t> kFromLinear {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
static void build_gamma_tables(const T* outGammaTables[3], T* gammaTableStorage, int gammaTableSize,
|
static void build_gamma_tables(const T* outGammaTables[3], T* gammaTableStorage, int gammaTableSize,
|
||||||
const sk_sp<SkColorSpace>& space, const GammaFns<T>& fns) {
|
const sk_sp<SkColorSpace>& space, const GammaFns<T>& fns) {
|
||||||
switch (space->gammaNamed()) {
|
switch (as_CSB(space)->gammaNamed()) {
|
||||||
case SkColorSpace::kSRGB_GammaNamed:
|
case kSRGB_SkGammaNamed:
|
||||||
outGammaTables[0] = outGammaTables[1] = outGammaTables[2] = fns.fSRGBTable;
|
outGammaTables[0] = outGammaTables[1] = outGammaTables[2] = fns.fSRGBTable;
|
||||||
break;
|
break;
|
||||||
case SkColorSpace::k2Dot2Curve_GammaNamed:
|
case k2Dot2Curve_SkGammaNamed:
|
||||||
outGammaTables[0] = outGammaTables[1] = outGammaTables[2] = fns.f2Dot2Table;
|
outGammaTables[0] = outGammaTables[1] = outGammaTables[2] = fns.f2Dot2Table;
|
||||||
break;
|
break;
|
||||||
case SkColorSpace::kLinear_GammaNamed:
|
case kLinear_SkGammaNamed:
|
||||||
(*fns.fBuildFromValue)(gammaTableStorage, 1.0f);
|
(*fns.fBuildFromValue)(gammaTableStorage, 1.0f);
|
||||||
outGammaTables[0] = outGammaTables[1] = outGammaTables[2] = gammaTableStorage;
|
outGammaTables[0] = outGammaTables[1] = outGammaTables[2] = gammaTableStorage;
|
||||||
break;
|
break;
|
||||||
@ -409,13 +409,13 @@ static void build_gamma_tables(const T* outGammaTables[3], T* gammaTableStorage,
|
|||||||
|
|
||||||
if (gammas->isNamed(i)) {
|
if (gammas->isNamed(i)) {
|
||||||
switch (gammas->data(i).fNamed) {
|
switch (gammas->data(i).fNamed) {
|
||||||
case SkColorSpace::kSRGB_GammaNamed:
|
case kSRGB_SkGammaNamed:
|
||||||
outGammaTables[i] = fns.fSRGBTable;
|
outGammaTables[i] = fns.fSRGBTable;
|
||||||
break;
|
break;
|
||||||
case SkColorSpace::k2Dot2Curve_GammaNamed:
|
case k2Dot2Curve_SkGammaNamed:
|
||||||
outGammaTables[i] = fns.f2Dot2Table;
|
outGammaTables[i] = fns.f2Dot2Table;
|
||||||
break;
|
break;
|
||||||
case SkColorSpace::kLinear_GammaNamed:
|
case kLinear_SkGammaNamed:
|
||||||
(*fns.fBuildFromValue)(&gammaTableStorage[i * gammaTableSize], 1.0f);
|
(*fns.fBuildFromValue)(&gammaTableStorage[i * gammaTableSize], 1.0f);
|
||||||
outGammaTables[i] = &gammaTableStorage[i * gammaTableSize];
|
outGammaTables[i] = &gammaTableStorage[i * gammaTableSize];
|
||||||
break;
|
break;
|
||||||
@ -491,48 +491,48 @@ std::unique_ptr<SkColorSpaceXform> SkColorSpaceXform::New(const sk_sp<SkColorSpa
|
|||||||
|
|
||||||
switch (csm) {
|
switch (csm) {
|
||||||
case kNone_ColorSpaceMatch:
|
case kNone_ColorSpaceMatch:
|
||||||
switch (dstSpace->gammaNamed()) {
|
switch (as_CSB(dstSpace)->gammaNamed()) {
|
||||||
case SkColorSpace::kSRGB_GammaNamed:
|
case kSRGB_SkGammaNamed:
|
||||||
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
||||||
<SkColorSpace::kSRGB_GammaNamed, kNone_ColorSpaceMatch>
|
<kSRGB_SkGammaNamed, kNone_ColorSpaceMatch>
|
||||||
(srcSpace, srcToDst, dstSpace));
|
(srcSpace, srcToDst, dstSpace));
|
||||||
case SkColorSpace::k2Dot2Curve_GammaNamed:
|
case k2Dot2Curve_SkGammaNamed:
|
||||||
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
||||||
<SkColorSpace::k2Dot2Curve_GammaNamed, kNone_ColorSpaceMatch>
|
<k2Dot2Curve_SkGammaNamed, kNone_ColorSpaceMatch>
|
||||||
(srcSpace, srcToDst, dstSpace));
|
(srcSpace, srcToDst, dstSpace));
|
||||||
default:
|
default:
|
||||||
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
||||||
<SkColorSpace::kNonStandard_GammaNamed, kNone_ColorSpaceMatch>
|
<kNonStandard_SkGammaNamed, kNone_ColorSpaceMatch>
|
||||||
(srcSpace, srcToDst, dstSpace));
|
(srcSpace, srcToDst, dstSpace));
|
||||||
}
|
}
|
||||||
case kGamut_ColorSpaceMatch:
|
case kGamut_ColorSpaceMatch:
|
||||||
switch (dstSpace->gammaNamed()) {
|
switch (as_CSB(dstSpace)->gammaNamed()) {
|
||||||
case SkColorSpace::kSRGB_GammaNamed:
|
case kSRGB_SkGammaNamed:
|
||||||
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
||||||
<SkColorSpace::kSRGB_GammaNamed, kGamut_ColorSpaceMatch>
|
<kSRGB_SkGammaNamed, kGamut_ColorSpaceMatch>
|
||||||
(srcSpace, srcToDst, dstSpace));
|
(srcSpace, srcToDst, dstSpace));
|
||||||
case SkColorSpace::k2Dot2Curve_GammaNamed:
|
case k2Dot2Curve_SkGammaNamed:
|
||||||
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
||||||
<SkColorSpace::k2Dot2Curve_GammaNamed, kGamut_ColorSpaceMatch>
|
<k2Dot2Curve_SkGammaNamed, kGamut_ColorSpaceMatch>
|
||||||
(srcSpace, srcToDst, dstSpace));
|
(srcSpace, srcToDst, dstSpace));
|
||||||
default:
|
default:
|
||||||
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
||||||
<SkColorSpace::kNonStandard_GammaNamed, kGamut_ColorSpaceMatch>
|
<kNonStandard_SkGammaNamed, kGamut_ColorSpaceMatch>
|
||||||
(srcSpace, srcToDst, dstSpace));
|
(srcSpace, srcToDst, dstSpace));
|
||||||
}
|
}
|
||||||
case kFull_ColorSpaceMatch:
|
case kFull_ColorSpaceMatch:
|
||||||
switch (dstSpace->gammaNamed()) {
|
switch (as_CSB(dstSpace)->gammaNamed()) {
|
||||||
case SkColorSpace::kSRGB_GammaNamed:
|
case kSRGB_SkGammaNamed:
|
||||||
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
||||||
<SkColorSpace::kSRGB_GammaNamed, kFull_ColorSpaceMatch>
|
<kSRGB_SkGammaNamed, kFull_ColorSpaceMatch>
|
||||||
(srcSpace, srcToDst, dstSpace));
|
(srcSpace, srcToDst, dstSpace));
|
||||||
case SkColorSpace::k2Dot2Curve_GammaNamed:
|
case k2Dot2Curve_SkGammaNamed:
|
||||||
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
||||||
<SkColorSpace::k2Dot2Curve_GammaNamed, kFull_ColorSpaceMatch>
|
<k2Dot2Curve_SkGammaNamed, kFull_ColorSpaceMatch>
|
||||||
(srcSpace, srcToDst, dstSpace));
|
(srcSpace, srcToDst, dstSpace));
|
||||||
default:
|
default:
|
||||||
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
||||||
<SkColorSpace::kNonStandard_GammaNamed, kFull_ColorSpaceMatch>
|
<kNonStandard_SkGammaNamed, kFull_ColorSpaceMatch>
|
||||||
(srcSpace, srcToDst, dstSpace));
|
(srcSpace, srcToDst, dstSpace));
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -968,7 +968,7 @@ static inline void store_generic_1(void* dst, const uint32_t* src,
|
|||||||
| (*src & 0xFF000000);
|
| (*src & 0xFF000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SkColorSpace::GammaNamed kDstGamma,
|
template <SkGammaNamed kDstGamma,
|
||||||
ColorSpaceMatch kCSM,
|
ColorSpaceMatch kCSM,
|
||||||
SkAlphaType kAlphaType,
|
SkAlphaType kAlphaType,
|
||||||
SwapRB kSwapRB>
|
SwapRB kSwapRB>
|
||||||
@ -981,7 +981,7 @@ static void color_xform_RGBA(void* dst, const uint32_t* src, int len,
|
|||||||
decltype(load_rgb_from_tables_1)* load_1;
|
decltype(load_rgb_from_tables_1)* load_1;
|
||||||
size_t sizeOfDstPixel;
|
size_t sizeOfDstPixel;
|
||||||
switch (kDstGamma) {
|
switch (kDstGamma) {
|
||||||
case SkColorSpace::kSRGB_GammaNamed:
|
case kSRGB_SkGammaNamed:
|
||||||
load = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables :
|
load = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables :
|
||||||
load_rgb_from_tables;
|
load_rgb_from_tables;
|
||||||
load_1 = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables_1 :
|
load_1 = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables_1 :
|
||||||
@ -990,7 +990,7 @@ static void color_xform_RGBA(void* dst, const uint32_t* src, int len,
|
|||||||
store_1 = store_srgb_1;
|
store_1 = store_srgb_1;
|
||||||
sizeOfDstPixel = 4;
|
sizeOfDstPixel = 4;
|
||||||
break;
|
break;
|
||||||
case SkColorSpace::k2Dot2Curve_GammaNamed:
|
case k2Dot2Curve_SkGammaNamed:
|
||||||
load = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables :
|
load = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables :
|
||||||
load_rgb_from_tables;
|
load_rgb_from_tables;
|
||||||
load_1 = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables_1 :
|
load_1 = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables_1 :
|
||||||
@ -999,7 +999,7 @@ static void color_xform_RGBA(void* dst, const uint32_t* src, int len,
|
|||||||
store_1 = store_2dot2_1;
|
store_1 = store_2dot2_1;
|
||||||
sizeOfDstPixel = 4;
|
sizeOfDstPixel = 4;
|
||||||
break;
|
break;
|
||||||
case SkColorSpace::kLinear_GammaNamed:
|
case kLinear_SkGammaNamed:
|
||||||
load = load_rgba_from_tables;
|
load = load_rgba_from_tables;
|
||||||
load_1 = load_rgba_from_tables_1;
|
load_1 = load_rgba_from_tables_1;
|
||||||
store = (kOpaque_SkAlphaType == kAlphaType) ? store_f16_opaque :
|
store = (kOpaque_SkAlphaType == kAlphaType) ? store_f16_opaque :
|
||||||
@ -1008,7 +1008,7 @@ static void color_xform_RGBA(void* dst, const uint32_t* src, int len,
|
|||||||
store_f16_1;
|
store_f16_1;
|
||||||
sizeOfDstPixel = 8;
|
sizeOfDstPixel = 8;
|
||||||
break;
|
break;
|
||||||
case SkColorSpace::kNonStandard_GammaNamed:
|
case kNonStandard_SkGammaNamed:
|
||||||
load = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables :
|
load = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables :
|
||||||
load_rgb_from_tables;
|
load_rgb_from_tables;
|
||||||
load_1 = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables_1 :
|
load_1 = (kPremul_SkAlphaType == kAlphaType) ? load_rgba_from_tables_1 :
|
||||||
@ -1098,7 +1098,7 @@ static void color_xform_RGBA(void* dst, const uint32_t* src, int len,
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template <SkColorSpace::GammaNamed kDst, ColorSpaceMatch kCSM>
|
template <SkGammaNamed kDst, ColorSpaceMatch kCSM>
|
||||||
SkColorSpaceXform_Base<kDst, kCSM>::SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace,
|
SkColorSpaceXform_Base<kDst, kCSM>::SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace,
|
||||||
const SkMatrix44& srcToDst,
|
const SkMatrix44& srcToDst,
|
||||||
const sk_sp<SkColorSpace>& dstSpace)
|
const sk_sp<SkColorSpace>& dstSpace)
|
||||||
@ -1110,7 +1110,7 @@ SkColorSpaceXform_Base<kDst, kCSM>::SkColorSpaceXform_Base(const sk_sp<SkColorSp
|
|||||||
kFromLinear);
|
kFromLinear);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SkColorSpace::GammaNamed kDst, ColorSpaceMatch kCSM>
|
template <SkGammaNamed kDst, ColorSpaceMatch kCSM>
|
||||||
void SkColorSpaceXform_Base<kDst, kCSM>
|
void SkColorSpaceXform_Base<kDst, kCSM>
|
||||||
::apply(void* dst, const uint32_t* src, int len, SkColorType dstColorType, SkAlphaType dstAlphaType)
|
::apply(void* dst, const uint32_t* src, int len, SkColorType dstColorType, SkAlphaType dstAlphaType)
|
||||||
const
|
const
|
||||||
@ -1160,7 +1160,7 @@ const
|
|||||||
return color_xform_RGBA<kDst, kCSM, kPremul_SkAlphaType, kYes_SwapRB>
|
return color_xform_RGBA<kDst, kCSM, kPremul_SkAlphaType, kYes_SwapRB>
|
||||||
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
||||||
case kRGBA_F16_SkColorType:
|
case kRGBA_F16_SkColorType:
|
||||||
return color_xform_RGBA<SkColorSpace::kLinear_GammaNamed, kCSM,
|
return color_xform_RGBA<kLinear_SkGammaNamed, kCSM,
|
||||||
kPremul_SkAlphaType, kNo_SwapRB>
|
kPremul_SkAlphaType, kNo_SwapRB>
|
||||||
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
||||||
default:
|
default:
|
||||||
@ -1177,7 +1177,7 @@ const
|
|||||||
return color_xform_RGBA<kDst, kCSM, kUnpremul_SkAlphaType, kYes_SwapRB>
|
return color_xform_RGBA<kDst, kCSM, kUnpremul_SkAlphaType, kYes_SwapRB>
|
||||||
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
||||||
case kRGBA_F16_SkColorType:
|
case kRGBA_F16_SkColorType:
|
||||||
return color_xform_RGBA<SkColorSpace::kLinear_GammaNamed, kCSM,
|
return color_xform_RGBA<kLinear_SkGammaNamed, kCSM,
|
||||||
kUnpremul_SkAlphaType, kNo_SwapRB>
|
kUnpremul_SkAlphaType, kNo_SwapRB>
|
||||||
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
||||||
default:
|
default:
|
||||||
@ -1193,7 +1193,7 @@ const
|
|||||||
return color_xform_RGBA<kDst, kCSM, kOpaque_SkAlphaType, kYes_SwapRB>
|
return color_xform_RGBA<kDst, kCSM, kOpaque_SkAlphaType, kYes_SwapRB>
|
||||||
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
||||||
case kRGBA_F16_SkColorType:
|
case kRGBA_F16_SkColorType:
|
||||||
return color_xform_RGBA<SkColorSpace::kLinear_GammaNamed, kCSM,
|
return color_xform_RGBA<kLinear_SkGammaNamed, kCSM,
|
||||||
kOpaque_SkAlphaType, kNo_SwapRB>
|
kOpaque_SkAlphaType, kNo_SwapRB>
|
||||||
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
(dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
|
||||||
default:
|
default:
|
||||||
@ -1208,6 +1208,6 @@ const
|
|||||||
|
|
||||||
std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(const sk_sp<SkColorSpace>& space) {
|
std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(const sk_sp<SkColorSpace>& space) {
|
||||||
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
return std::unique_ptr<SkColorSpaceXform>(new SkColorSpaceXform_Base
|
||||||
<SkColorSpace::kNonStandard_GammaNamed, kNone_ColorSpaceMatch>
|
<kNonStandard_SkGammaNamed, kNone_ColorSpaceMatch>
|
||||||
(space, SkMatrix::I(), space));
|
(space, SkMatrix::I(), space));
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ enum ColorSpaceMatch {
|
|||||||
kFull_ColorSpaceMatch,
|
kFull_ColorSpaceMatch,
|
||||||
};
|
};
|
||||||
|
|
||||||
template <SkColorSpace::GammaNamed kDst, ColorSpaceMatch kCSM>
|
template <SkGammaNamed kDst, ColorSpaceMatch kCSM>
|
||||||
class SkColorSpaceXform_Base : public SkColorSpaceXform {
|
class SkColorSpaceXform_Base : public SkColorSpaceXform {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -12,6 +12,13 @@
|
|||||||
#include "SkData.h"
|
#include "SkData.h"
|
||||||
#include "SkTemplates.h"
|
#include "SkTemplates.h"
|
||||||
|
|
||||||
|
enum SkGammaNamed : uint8_t {
|
||||||
|
kLinear_SkGammaNamed,
|
||||||
|
kSRGB_SkGammaNamed,
|
||||||
|
k2Dot2Curve_SkGammaNamed,
|
||||||
|
kNonStandard_SkGammaNamed,
|
||||||
|
};
|
||||||
|
|
||||||
struct SkGammas : SkRefCnt {
|
struct SkGammas : SkRefCnt {
|
||||||
|
|
||||||
// There are four possible representations for gamma curves. kNone_Type is used
|
// There are four possible representations for gamma curves. kNone_Type is used
|
||||||
@ -59,7 +66,7 @@ struct SkGammas : SkRefCnt {
|
|||||||
this->fTable.fSize == that.fTable.fSize;
|
this->fTable.fSize == that.fTable.fSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkColorSpace::GammaNamed fNamed;
|
SkGammaNamed fNamed;
|
||||||
float fValue;
|
float fValue;
|
||||||
Table fTable;
|
Table fTable;
|
||||||
size_t fParamOffset;
|
size_t fParamOffset;
|
||||||
@ -176,6 +183,7 @@ public:
|
|||||||
|
|
||||||
static sk_sp<SkColorSpace> NewRGB(const float gammas[3], const SkMatrix44& toXYZD50);
|
static sk_sp<SkColorSpace> NewRGB(const float gammas[3], const SkMatrix44& toXYZD50);
|
||||||
|
|
||||||
|
SkGammaNamed gammaNamed() const { return fGammaNamed; }
|
||||||
const SkGammas* gammas() const { return fGammas.get(); }
|
const SkGammas* gammas() const { return fGammas.get(); }
|
||||||
|
|
||||||
const SkColorLookUpTable* colorLUT() const { return fColorLUT.get(); }
|
const SkColorLookUpTable* colorLUT() const { return fColorLUT.get(); }
|
||||||
@ -191,14 +199,15 @@ private:
|
|||||||
*/
|
*/
|
||||||
sk_sp<SkData> writeToICC() const;
|
sk_sp<SkData> writeToICC() const;
|
||||||
|
|
||||||
static sk_sp<SkColorSpace> NewRGB(GammaNamed gammaNamed, const SkMatrix44& toXYZD50);
|
static sk_sp<SkColorSpace> NewRGB(SkGammaNamed gammaNamed, const SkMatrix44& toXYZD50);
|
||||||
|
|
||||||
SkColorSpace_Base(GammaNamed gammaNamed, const SkMatrix44& toXYZ);
|
SkColorSpace_Base(SkGammaNamed gammaNamed, const SkMatrix44& toXYZ);
|
||||||
|
|
||||||
SkColorSpace_Base(sk_sp<SkColorLookUpTable> colorLUT, GammaNamed gammaNamed,
|
SkColorSpace_Base(sk_sp<SkColorLookUpTable> colorLUT, SkGammaNamed gammaNamed,
|
||||||
sk_sp<SkGammas> gammas, const SkMatrix44& toXYZ, sk_sp<SkData> profileData);
|
sk_sp<SkGammas> gammas, const SkMatrix44& toXYZ, sk_sp<SkData> profileData);
|
||||||
|
|
||||||
sk_sp<SkColorLookUpTable> fColorLUT;
|
sk_sp<SkColorLookUpTable> fColorLUT;
|
||||||
|
const SkGammaNamed fGammaNamed;
|
||||||
sk_sp<SkGammas> fGammas;
|
sk_sp<SkGammas> fGammas;
|
||||||
sk_sp<SkData> fProfileData;
|
sk_sp<SkData> fProfileData;
|
||||||
|
|
||||||
|
@ -240,12 +240,12 @@ static constexpr uint32_t kTAG_ParaCurveType = SkSetFourByteTag('p', 'a', 'r', '
|
|||||||
|
|
||||||
static SkGammas::Type set_gamma_value(SkGammas::Data* data, float value) {
|
static SkGammas::Type set_gamma_value(SkGammas::Data* data, float value) {
|
||||||
if (color_space_almost_equal(2.2f, value)) {
|
if (color_space_almost_equal(2.2f, value)) {
|
||||||
data->fNamed = SkColorSpace::k2Dot2Curve_GammaNamed;
|
data->fNamed = k2Dot2Curve_SkGammaNamed;
|
||||||
return SkGammas::Type::kNamed_Type;
|
return SkGammas::Type::kNamed_Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color_space_almost_equal(1.0f, value)) {
|
if (color_space_almost_equal(1.0f, value)) {
|
||||||
data->fNamed = SkColorSpace::kLinear_GammaNamed;
|
data->fNamed = kLinear_SkGammaNamed;
|
||||||
return SkGammas::Type::kNamed_Type;
|
return SkGammas::Type::kNamed_Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ static SkGammas::Type parse_gamma(SkGammas::Data* outData, SkGammas::Params* out
|
|||||||
// Some tags require a gamma curve, but the author doesn't actually want
|
// Some tags require a gamma curve, but the author doesn't actually want
|
||||||
// to transform the data. In this case, it is common to see a curve with
|
// to transform the data. In this case, it is common to see a curve with
|
||||||
// a count of 0.
|
// a count of 0.
|
||||||
outData->fNamed = SkColorSpace::kLinear_GammaNamed;
|
outData->fNamed = kLinear_SkGammaNamed;
|
||||||
return SkGammas::Type::kNamed_Type;
|
return SkGammas::Type::kNamed_Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ static SkGammas::Type parse_gamma(SkGammas::Data* outData, SkGammas::Params* out
|
|||||||
14116 == read_big_endian_u16((const uint8_t*) &table[513]) &&
|
14116 == read_big_endian_u16((const uint8_t*) &table[513]) &&
|
||||||
34318 == read_big_endian_u16((const uint8_t*) &table[768]) &&
|
34318 == read_big_endian_u16((const uint8_t*) &table[768]) &&
|
||||||
65535 == read_big_endian_u16((const uint8_t*) &table[1023])) {
|
65535 == read_big_endian_u16((const uint8_t*) &table[1023])) {
|
||||||
outData->fNamed = SkColorSpace::kSRGB_GammaNamed;
|
outData->fNamed = kSRGB_SkGammaNamed;
|
||||||
return SkGammas::Type::kNamed_Type;
|
return SkGammas::Type::kNamed_Type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ static SkGammas::Type parse_gamma(SkGammas::Data* outData, SkGammas::Params* out
|
|||||||
12824 == read_big_endian_u16((const uint8_t*) &table[12]) &&
|
12824 == read_big_endian_u16((const uint8_t*) &table[12]) &&
|
||||||
31237 == read_big_endian_u16((const uint8_t*) &table[18]) &&
|
31237 == read_big_endian_u16((const uint8_t*) &table[18]) &&
|
||||||
65535 == read_big_endian_u16((const uint8_t*) &table[25])) {
|
65535 == read_big_endian_u16((const uint8_t*) &table[25])) {
|
||||||
outData->fNamed = SkColorSpace::kSRGB_GammaNamed;
|
outData->fNamed = kSRGB_SkGammaNamed;
|
||||||
return SkGammas::Type::kNamed_Type;
|
return SkGammas::Type::kNamed_Type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -365,7 +365,7 @@ static SkGammas::Type parse_gamma(SkGammas::Data* outData, SkGammas::Params* out
|
|||||||
3342 == read_big_endian_u16((const uint8_t*) &table[1025]) &&
|
3342 == read_big_endian_u16((const uint8_t*) &table[1025]) &&
|
||||||
14079 == read_big_endian_u16((const uint8_t*) &table[2051]) &&
|
14079 == read_big_endian_u16((const uint8_t*) &table[2051]) &&
|
||||||
65535 == read_big_endian_u16((const uint8_t*) &table[4095])) {
|
65535 == read_big_endian_u16((const uint8_t*) &table[4095])) {
|
||||||
outData->fNamed = SkColorSpace::kSRGB_GammaNamed;
|
outData->fNamed = kSRGB_SkGammaNamed;
|
||||||
return SkGammas::Type::kNamed_Type;
|
return SkGammas::Type::kNamed_Type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -486,7 +486,7 @@ static SkGammas::Type parse_gamma(SkGammas::Data* outData, SkGammas::Params* out
|
|||||||
color_space_almost_equal(0.0774f, e) &&
|
color_space_almost_equal(0.0774f, e) &&
|
||||||
color_space_almost_equal(0.0000f, f) &&
|
color_space_almost_equal(0.0000f, f) &&
|
||||||
color_space_almost_equal(2.4000f, g)) {
|
color_space_almost_equal(2.4000f, g)) {
|
||||||
outData->fNamed = SkColorSpace::kSRGB_GammaNamed;
|
outData->fNamed = kSRGB_SkGammaNamed;
|
||||||
return SkGammas::Type::kNamed_Type;
|
return SkGammas::Type::kNamed_Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,7 +562,7 @@ static void handle_invalid_gamma(SkGammas::Type* type, SkGammas::Data* data) {
|
|||||||
*type = SkGammas::Type::kNamed_Type;
|
*type = SkGammas::Type::kNamed_Type;
|
||||||
|
|
||||||
// Guess sRGB in the case of a malformed transfer function.
|
// Guess sRGB in the case of a malformed transfer function.
|
||||||
data->fNamed = SkColorSpace::kSRGB_GammaNamed;
|
data->fNamed = kSRGB_SkGammaNamed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -718,7 +718,7 @@ static bool load_matrix(SkMatrix44* toXYZ, const uint8_t* src, size_t len) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline SkColorSpace::GammaNamed is_named(const sk_sp<SkGammas>& gammas) {
|
static inline SkGammaNamed is_named(const sk_sp<SkGammas>& gammas) {
|
||||||
if (gammas->isNamed(0) && gammas->isNamed(1) && gammas->isNamed(2) &&
|
if (gammas->isNamed(0) && gammas->isNamed(1) && gammas->isNamed(2) &&
|
||||||
gammas->fRedData.fNamed == gammas->fGreenData.fNamed &&
|
gammas->fRedData.fNamed == gammas->fGreenData.fNamed &&
|
||||||
gammas->fRedData.fNamed == gammas->fBlueData.fNamed)
|
gammas->fRedData.fNamed == gammas->fBlueData.fNamed)
|
||||||
@ -726,11 +726,11 @@ static inline SkColorSpace::GammaNamed is_named(const sk_sp<SkGammas>& gammas) {
|
|||||||
return gammas->fRedData.fNamed;
|
return gammas->fRedData.fNamed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SkColorSpace::kNonStandard_GammaNamed;
|
return kNonStandard_SkGammaNamed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool load_a2b0(sk_sp<SkColorLookUpTable>* colorLUT, SkColorSpace::GammaNamed* gammaNamed,
|
static bool load_a2b0(sk_sp<SkColorLookUpTable>* colorLUT, SkGammaNamed* gammaNamed,
|
||||||
sk_sp<SkGammas>* gammas, SkMatrix44* toXYZ, const uint8_t* src, size_t len) {
|
sk_sp<SkGammas>* gammas, SkMatrix44* toXYZ, const uint8_t* src, size_t len) {
|
||||||
if (len < 32) {
|
if (len < 32) {
|
||||||
SkColorSpacePrintf("A to B tag is too small (%d bytes).", len);
|
SkColorSpacePrintf("A to B tag is too small (%d bytes).", len);
|
||||||
@ -861,12 +861,12 @@ static bool load_a2b0(sk_sp<SkColorLookUpTable>* colorLUT, SkColorSpace::GammaNa
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Guess sRGB if the chunk is missing a transfer function.
|
// Guess sRGB if the chunk is missing a transfer function.
|
||||||
*gammaNamed = SkColorSpace::kSRGB_GammaNamed;
|
*gammaNamed = kSRGB_SkGammaNamed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SkColorSpace::kNonStandard_GammaNamed == *gammaNamed) {
|
if (kNonStandard_SkGammaNamed == *gammaNamed) {
|
||||||
*gammaNamed = is_named(*gammas);
|
*gammaNamed = is_named(*gammas);
|
||||||
if (SkColorSpace::kNonStandard_GammaNamed != *gammaNamed) {
|
if (kNonStandard_SkGammaNamed != *gammaNamed) {
|
||||||
// No need to keep the gammas struct, the enum is enough.
|
// No need to keep the gammas struct, the enum is enough.
|
||||||
*gammas = nullptr;
|
*gammas = nullptr;
|
||||||
}
|
}
|
||||||
@ -985,7 +985,7 @@ sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* input, size_t len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GammaNamed gammaNamed = kNonStandard_GammaNamed;
|
SkGammaNamed gammaNamed = kNonStandard_SkGammaNamed;
|
||||||
sk_sp<SkGammas> gammas = nullptr;
|
sk_sp<SkGammas> gammas = nullptr;
|
||||||
size_t tagBytes;
|
size_t tagBytes;
|
||||||
if (r && g && b) {
|
if (r && g && b) {
|
||||||
@ -1062,14 +1062,14 @@ sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* input, size_t len) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Guess sRGB if the profile is missing transfer functions.
|
// Guess sRGB if the profile is missing transfer functions.
|
||||||
gammaNamed = kSRGB_GammaNamed;
|
gammaNamed = kSRGB_SkGammaNamed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kNonStandard_GammaNamed == gammaNamed) {
|
if (kNonStandard_SkGammaNamed == gammaNamed) {
|
||||||
// It's possible that we'll initially detect non-matching gammas, only for
|
// It's possible that we'll initially detect non-matching gammas, only for
|
||||||
// them to evaluate to the same named gamma curve.
|
// them to evaluate to the same named gamma curve.
|
||||||
gammaNamed = is_named(gammas);
|
gammaNamed = is_named(gammas);
|
||||||
if (kNonStandard_GammaNamed == gammaNamed) {
|
if (kNonStandard_SkGammaNamed == gammaNamed) {
|
||||||
return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr, gammaNamed,
|
return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr, gammaNamed,
|
||||||
std::move(gammas), mat,
|
std::move(gammas), mat,
|
||||||
std::move(data)));
|
std::move(data)));
|
||||||
@ -1082,7 +1082,7 @@ sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* input, size_t len) {
|
|||||||
// Recognize color profile specified by A2B0 tag.
|
// Recognize color profile specified by A2B0 tag.
|
||||||
const ICCTag* a2b0 = ICCTag::Find(tags.get(), tagCount, kTAG_A2B0);
|
const ICCTag* a2b0 = ICCTag::Find(tags.get(), tagCount, kTAG_A2B0);
|
||||||
if (a2b0) {
|
if (a2b0) {
|
||||||
GammaNamed gammaNamed = kNonStandard_GammaNamed;
|
SkGammaNamed gammaNamed = kNonStandard_SkGammaNamed;
|
||||||
sk_sp<SkGammas> gammas = nullptr;
|
sk_sp<SkGammas> gammas = nullptr;
|
||||||
sk_sp<SkColorLookUpTable> colorLUT = nullptr;
|
sk_sp<SkColorLookUpTable> colorLUT = nullptr;
|
||||||
SkMatrix44 toXYZ(SkMatrix44::kUninitialized_Constructor);
|
SkMatrix44 toXYZ(SkMatrix44::kUninitialized_Constructor);
|
||||||
@ -1091,7 +1091,7 @@ sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* input, size_t len) {
|
|||||||
return_null("Failed to parse A2B0 tag");
|
return_null("Failed to parse A2B0 tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colorLUT || kNonStandard_GammaNamed == gammaNamed) {
|
if (colorLUT || kNonStandard_SkGammaNamed == gammaNamed) {
|
||||||
return sk_sp<SkColorSpace>(new SkColorSpace_Base(std::move(colorLUT),
|
return sk_sp<SkColorSpace>(new SkColorSpace_Base(std::move(colorLUT),
|
||||||
gammaNamed, std::move(gammas),
|
gammaNamed, std::move(gammas),
|
||||||
toXYZ, std::move(data)));
|
toXYZ, std::move(data)));
|
||||||
@ -1277,8 +1277,8 @@ sk_sp<SkData> SkColorSpace_Base::writeToICC() const {
|
|||||||
ptr += kTAG_XYZ_Bytes;
|
ptr += kTAG_XYZ_Bytes;
|
||||||
|
|
||||||
// Write TRC tags
|
// Write TRC tags
|
||||||
GammaNamed gammaNamed = this->gammaNamed();
|
SkGammaNamed gammaNamed = this->gammaNamed();
|
||||||
if (kNonStandard_GammaNamed == gammaNamed) {
|
if (kNonStandard_SkGammaNamed == gammaNamed) {
|
||||||
// FIXME (msarett):
|
// FIXME (msarett):
|
||||||
// Write the correct gamma representation rather than 2.2f.
|
// Write the correct gamma representation rather than 2.2f.
|
||||||
write_trc_tag((uint32_t*) ptr, 2.2f);
|
write_trc_tag((uint32_t*) ptr, 2.2f);
|
||||||
@ -1289,12 +1289,12 @@ sk_sp<SkData> SkColorSpace_Base::writeToICC() const {
|
|||||||
ptr += SkAlign4(kTAG_TRC_Bytes);
|
ptr += SkAlign4(kTAG_TRC_Bytes);
|
||||||
} else {
|
} else {
|
||||||
switch (gammaNamed) {
|
switch (gammaNamed) {
|
||||||
case SkColorSpace::kSRGB_GammaNamed:
|
case kSRGB_SkGammaNamed:
|
||||||
// FIXME (msarett):
|
// FIXME (msarett):
|
||||||
// kSRGB cannot be represented by a value. Here we fall through to 2.2f,
|
// kSRGB cannot be represented by a value. Here we fall through to 2.2f,
|
||||||
// which is a close guess. To be more accurate, we need to represent sRGB
|
// which is a close guess. To be more accurate, we need to represent sRGB
|
||||||
// gamma with a parametric curve.
|
// gamma with a parametric curve.
|
||||||
case SkColorSpace::k2Dot2Curve_GammaNamed:
|
case k2Dot2Curve_SkGammaNamed:
|
||||||
write_trc_tag((uint32_t*) ptr, 2.2f);
|
write_trc_tag((uint32_t*) ptr, 2.2f);
|
||||||
ptr += SkAlign4(kTAG_TRC_Bytes);
|
ptr += SkAlign4(kTAG_TRC_Bytes);
|
||||||
write_trc_tag((uint32_t*) ptr, 2.2f);
|
write_trc_tag((uint32_t*) ptr, 2.2f);
|
||||||
@ -1302,7 +1302,7 @@ sk_sp<SkData> SkColorSpace_Base::writeToICC() const {
|
|||||||
write_trc_tag((uint32_t*) ptr, 2.2f);
|
write_trc_tag((uint32_t*) ptr, 2.2f);
|
||||||
ptr += SkAlign4(kTAG_TRC_Bytes);
|
ptr += SkAlign4(kTAG_TRC_Bytes);
|
||||||
break;
|
break;
|
||||||
case SkColorSpace::kLinear_GammaNamed:
|
case kLinear_SkGammaNamed:
|
||||||
write_trc_tag((uint32_t*) ptr, 1.0f);
|
write_trc_tag((uint32_t*) ptr, 1.0f);
|
||||||
ptr += SkAlign4(kTAG_TRC_Bytes);
|
ptr += SkAlign4(kTAG_TRC_Bytes);
|
||||||
write_trc_tag((uint32_t*) ptr, 1.0f);
|
write_trc_tag((uint32_t*) ptr, 1.0f);
|
||||||
|
@ -136,8 +136,7 @@ void SkSurface_Gpu::onPrepareForExternalIO() {
|
|||||||
bool SkSurface_Gpu::Valid(const SkImageInfo& info) {
|
bool SkSurface_Gpu::Valid(const SkImageInfo& info) {
|
||||||
switch (info.colorType()) {
|
switch (info.colorType()) {
|
||||||
case kRGBA_F16_SkColorType:
|
case kRGBA_F16_SkColorType:
|
||||||
return info.colorSpace() &&
|
return info.colorSpace() && info.colorSpace()->gammaIsLinear();
|
||||||
SkColorSpace::kLinear_GammaNamed == info.colorSpace()->gammaNamed();
|
|
||||||
case kRGBA_8888_SkColorType:
|
case kRGBA_8888_SkColorType:
|
||||||
case kBGRA_8888_SkColorType:
|
case kBGRA_8888_SkColorType:
|
||||||
return !info.colorSpace() || info.colorSpace()->gammaCloseToSRGB();
|
return !info.colorSpace() || info.colorSpace()->gammaCloseToSRGB();
|
||||||
@ -149,7 +148,7 @@ bool SkSurface_Gpu::Valid(const SkImageInfo& info) {
|
|||||||
bool SkSurface_Gpu::Valid(GrContext* context, GrPixelConfig config, SkColorSpace* colorSpace) {
|
bool SkSurface_Gpu::Valid(GrContext* context, GrPixelConfig config, SkColorSpace* colorSpace) {
|
||||||
switch (config) {
|
switch (config) {
|
||||||
case kRGBA_half_GrPixelConfig:
|
case kRGBA_half_GrPixelConfig:
|
||||||
return colorSpace && SkColorSpace::kLinear_GammaNamed == colorSpace->gammaNamed();
|
return colorSpace && colorSpace->gammaIsLinear();
|
||||||
case kSRGBA_8888_GrPixelConfig:
|
case kSRGBA_8888_GrPixelConfig:
|
||||||
case kSBGRA_8888_GrPixelConfig:
|
case kSBGRA_8888_GrPixelConfig:
|
||||||
return context->caps()->srgbSupport() && colorSpace && colorSpace->gammaCloseToSRGB();
|
return context->caps()->srgbSupport() && colorSpace && colorSpace->gammaCloseToSRGB();
|
||||||
|
@ -67,8 +67,7 @@ bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) {
|
|||||||
shift = 2;
|
shift = 2;
|
||||||
break;
|
break;
|
||||||
case kRGBA_F16_SkColorType:
|
case kRGBA_F16_SkColorType:
|
||||||
if (!info.colorSpace() ||
|
if (!info.colorSpace() || !info.colorSpace()->gammaIsLinear()) {
|
||||||
SkColorSpace::kLinear_GammaNamed != info.colorSpace()->gammaNamed()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
shift = 3;
|
shift = 3;
|
||||||
|
@ -19,10 +19,10 @@ static bool almost_equal(float a, float b) {
|
|||||||
|
|
||||||
static void test_space(skiatest::Reporter* r, SkColorSpace* space,
|
static void test_space(skiatest::Reporter* r, SkColorSpace* space,
|
||||||
const float red[], const float green[], const float blue[],
|
const float red[], const float green[], const float blue[],
|
||||||
const SkColorSpace::GammaNamed expectedGamma) {
|
const SkGammaNamed expectedGamma) {
|
||||||
|
|
||||||
REPORTER_ASSERT(r, nullptr != space);
|
REPORTER_ASSERT(r, nullptr != space);
|
||||||
REPORTER_ASSERT(r, expectedGamma == space->gammaNamed());
|
REPORTER_ASSERT(r, expectedGamma == as_CSB(space)->gammaNamed());
|
||||||
|
|
||||||
const SkMatrix44& mat = space->xyz();
|
const SkMatrix44& mat = space->xyz();
|
||||||
const float src[] = {
|
const float src[] = {
|
||||||
@ -46,7 +46,7 @@ static SkStreamAsset* resource(const char path[]) {
|
|||||||
|
|
||||||
static void test_path(skiatest::Reporter* r, const char* path,
|
static void test_path(skiatest::Reporter* r, const char* path,
|
||||||
const float red[], const float green[], const float blue[],
|
const float red[], const float green[], const float blue[],
|
||||||
const SkColorSpace::GammaNamed expectedGamma) {
|
const SkGammaNamed expectedGamma) {
|
||||||
SkAutoTDelete<SkStream> stream(resource(path));
|
SkAutoTDelete<SkStream> stream(resource(path));
|
||||||
REPORTER_ASSERT(r, nullptr != stream);
|
REPORTER_ASSERT(r, nullptr != stream);
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
@ -69,7 +69,7 @@ const float g_sRGB_XYZ[] = { 0.4358f, 0.2224f, 0.0139f, // R
|
|||||||
|
|
||||||
DEF_TEST(ColorSpace_sRGB, r) {
|
DEF_TEST(ColorSpace_sRGB, r) {
|
||||||
test_space(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(),
|
test_space(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(),
|
||||||
g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], SkColorSpace::kSRGB_GammaNamed);
|
g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], kSRGB_SkGammaNamed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,22 +77,22 @@ DEF_TEST(ColorSpaceParseICCProfiles, r) {
|
|||||||
|
|
||||||
#if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 6)
|
#if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 6)
|
||||||
test_path(r, "color_wheel_with_profile.png", &g_sRGB_XYZ[0], &g_sRGB_XYZ[3], &g_sRGB_XYZ[6],
|
test_path(r, "color_wheel_with_profile.png", &g_sRGB_XYZ[0], &g_sRGB_XYZ[3], &g_sRGB_XYZ[6],
|
||||||
SkColorSpace::kSRGB_GammaNamed);
|
kSRGB_SkGammaNamed);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const float red[] = { 0.385117f, 0.716904f, 0.0970612f };
|
const float red[] = { 0.385117f, 0.716904f, 0.0970612f };
|
||||||
const float green[] = { 0.143051f, 0.0606079f, 0.713913f };
|
const float green[] = { 0.143051f, 0.0606079f, 0.713913f };
|
||||||
const float blue[] = { 0.436035f, 0.222488f, 0.013916f };
|
const float blue[] = { 0.436035f, 0.222488f, 0.013916f };
|
||||||
test_path(r, "icc-v2-gbr.jpg", red, green, blue, SkColorSpace::k2Dot2Curve_GammaNamed);
|
test_path(r, "icc-v2-gbr.jpg", red, green, blue, k2Dot2Curve_SkGammaNamed);
|
||||||
|
|
||||||
test_path(r, "webp-color-profile-crash.webp",
|
test_path(r, "webp-color-profile-crash.webp",
|
||||||
red, green, blue, SkColorSpace::kNonStandard_GammaNamed);
|
red, green, blue, kNonStandard_SkGammaNamed);
|
||||||
test_path(r, "webp-color-profile-lossless.webp",
|
test_path(r, "webp-color-profile-lossless.webp",
|
||||||
red, green, blue, SkColorSpace::kNonStandard_GammaNamed);
|
red, green, blue, kNonStandard_SkGammaNamed);
|
||||||
test_path(r, "webp-color-profile-lossy.webp",
|
test_path(r, "webp-color-profile-lossy.webp",
|
||||||
red, green, blue, SkColorSpace::kNonStandard_GammaNamed);
|
red, green, blue, kNonStandard_SkGammaNamed);
|
||||||
test_path(r, "webp-color-profile-lossy-alpha.webp",
|
test_path(r, "webp-color-profile-lossy-alpha.webp",
|
||||||
red, green, blue, SkColorSpace::kNonStandard_GammaNamed);
|
red, green, blue, kNonStandard_SkGammaNamed);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_TEST(ColorSpaceSRGBCompare, r) {
|
DEF_TEST(ColorSpaceSRGBCompare, r) {
|
||||||
@ -126,7 +126,7 @@ DEF_TEST(ColorSpaceWriteICC, r) {
|
|||||||
sk_sp<SkData> namedData = ColorSpaceTest::WriteToICC(namedColorSpace.get());
|
sk_sp<SkData> namedData = ColorSpaceTest::WriteToICC(namedColorSpace.get());
|
||||||
sk_sp<SkColorSpace> iccColorSpace = SkColorSpace::NewICC(namedData->data(), namedData->size());
|
sk_sp<SkColorSpace> iccColorSpace = SkColorSpace::NewICC(namedData->data(), namedData->size());
|
||||||
test_space(r, iccColorSpace.get(), g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6],
|
test_space(r, iccColorSpace.get(), g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6],
|
||||||
SkColorSpace::k2Dot2Curve_GammaNamed);
|
k2Dot2Curve_SkGammaNamed);
|
||||||
// FIXME (msarett): Test disabled. sRGB profiles are written approximately as 2.2f curves.
|
// FIXME (msarett): Test disabled. sRGB profiles are written approximately as 2.2f curves.
|
||||||
// REPORTER_ASSERT(r, iccColorSpace == namedColorSpace);
|
// REPORTER_ASSERT(r, iccColorSpace == namedColorSpace);
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ DEF_TEST(ColorSpaceWriteICC, r) {
|
|||||||
sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->data(),
|
sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->data(),
|
||||||
newMonitorData->size());
|
newMonitorData->size());
|
||||||
REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz());
|
REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz());
|
||||||
REPORTER_ASSERT(r, monitorSpace->gammaNamed() == newMonitorSpace->gammaNamed());
|
REPORTER_ASSERT(r, as_CSB(monitorSpace)->gammaNamed() == as_CSB(newMonitorSpace)->gammaNamed());
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_TEST(ColorSpace_Named, r) {
|
DEF_TEST(ColorSpace_Named, r) {
|
||||||
@ -160,9 +160,9 @@ DEF_TEST(ColorSpace_Named, r) {
|
|||||||
REPORTER_ASSERT(r, cs);
|
REPORTER_ASSERT(r, cs);
|
||||||
if (cs) {
|
if (cs) {
|
||||||
if (rec.fIsSRGB) {
|
if (rec.fIsSRGB) {
|
||||||
REPORTER_ASSERT(r, SkColorSpace::kSRGB_GammaNamed == cs->gammaNamed());
|
REPORTER_ASSERT(r, kSRGB_SkGammaNamed == as_CSB(cs)->gammaNamed());
|
||||||
} else {
|
} else {
|
||||||
REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == cs->gammaNamed());
|
REPORTER_ASSERT(r, k2Dot2Curve_SkGammaNamed == as_CSB(cs)->gammaNamed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public:
|
|||||||
static std::unique_ptr<SkColorSpaceXform> CreateIdentityXform(const sk_sp<SkGammas>& gammas) {
|
static std::unique_ptr<SkColorSpaceXform> CreateIdentityXform(const sk_sp<SkGammas>& gammas) {
|
||||||
// Logically we can pass any matrix here. For simplicty, pass I(), i.e. D50 XYZ gamut.
|
// Logically we can pass any matrix here. For simplicty, pass I(), i.e. D50 XYZ gamut.
|
||||||
sk_sp<SkColorSpace> space(new SkColorSpace_Base(
|
sk_sp<SkColorSpace> space(new SkColorSpace_Base(
|
||||||
nullptr, SkColorSpace::kNonStandard_GammaNamed, gammas, SkMatrix::I(), nullptr));
|
nullptr, kNonStandard_SkGammaNamed, gammas, SkMatrix::I(), nullptr));
|
||||||
|
|
||||||
// Use special testing entry point, so we don't skip the xform, even though src == dst.
|
// Use special testing entry point, so we don't skip the xform, even though src == dst.
|
||||||
return SlowIdentityXform(space);
|
return SlowIdentityXform(space);
|
||||||
|
@ -124,8 +124,7 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
|
|||||||
REPORTER_ASSERT(reporter, !configs[24]->asConfigGpu());
|
REPORTER_ASSERT(reporter, !configs[24]->asConfigGpu());
|
||||||
REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorType() == kRGBA_F16_SkColorType);
|
REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorType() == kRGBA_F16_SkColorType);
|
||||||
REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorSpace());
|
REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorSpace());
|
||||||
REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorSpace()->gammaNamed() ==
|
REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorSpace()->gammaIsLinear());
|
||||||
SkColorSpace::kLinear_GammaNamed);
|
|
||||||
REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorSpace()->xyz() ==
|
REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorSpace()->xyz() ==
|
||||||
srgbColorSpace->xyz());
|
srgbColorSpace->xyz());
|
||||||
REPORTER_ASSERT(reporter, configs[26]->asConfigGpu()->getColorType() == kN32_SkColorType);
|
REPORTER_ASSERT(reporter, configs[26]->asConfigGpu()->getColorType() == kN32_SkColorType);
|
||||||
|
Loading…
Reference in New Issue
Block a user