add MakeS32 helper to SkImageInfo, fix named-gamma constructor bug
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2035813003 Review-Url: https://codereview.chromium.org/2035813003
This commit is contained in:
parent
6cb7025182
commit
fbce71f1ae
@ -223,6 +223,11 @@ public:
|
||||
return MakeN32Premul(size.width(), size.height(), pt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an ImageInfo marked as SRGB with N32 swizzle.
|
||||
*/
|
||||
static SkImageInfo MakeS32(int width, int height, SkAlphaType at);
|
||||
|
||||
static SkImageInfo MakeA8(int width, int height) {
|
||||
return SkImageInfo(width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType,
|
||||
kLinear_SkColorProfileType, nullptr);
|
||||
|
@ -17,7 +17,7 @@ static bool color_space_almost_equal(float a, float b) {
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkColorSpace::SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50, Named named)
|
||||
: fGammaNamed(kNonStandard_GammaNamed)
|
||||
: fGammaNamed(gammaNamed)
|
||||
, fToXYZD50(toXYZD50)
|
||||
, fNamed(named)
|
||||
{}
|
||||
|
@ -35,6 +35,11 @@ SkImageInfo SkImageInfo::Make(int width, int height, SkColorType ct, SkAlphaType
|
||||
return SkImageInfo(width, height, ct, at, SkDefaultColorProfile(), std::move(cs));
|
||||
}
|
||||
|
||||
SkImageInfo SkImageInfo::MakeS32(int width, int height, SkAlphaType at) {
|
||||
return SkImageInfo(width, height, kN32_SkColorType, at, kSRGB_SkColorProfileType,
|
||||
SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named));
|
||||
}
|
||||
|
||||
void SkImageInfo::unflatten(SkReadBuffer& buffer) {
|
||||
fWidth = buffer.read32();
|
||||
fHeight = buffer.read32();
|
||||
|
@ -138,3 +138,26 @@ DEF_TEST(ColorSpaceWriteICC, r) {
|
||||
REPORTER_ASSERT(r, monitorSpace->xyz() == newMonitorSpace->xyz());
|
||||
REPORTER_ASSERT(r, as_CSB(monitorSpace)->gammas() == as_CSB(newMonitorSpace)->gammas());
|
||||
}
|
||||
|
||||
DEF_TEST(ColorSpace_Named, r) {
|
||||
const struct {
|
||||
SkColorSpace::Named fNamed;
|
||||
bool fExpectedToSucceed;
|
||||
} recs[] {
|
||||
{ SkColorSpace::kUnknown_Named, false },
|
||||
{ SkColorSpace::kSRGB_Named, true },
|
||||
{ SkColorSpace::kAdobeRGB_Named, true },
|
||||
};
|
||||
|
||||
for (auto rec : recs) {
|
||||
auto cs = SkColorSpace::NewNamed(rec.fNamed);
|
||||
REPORTER_ASSERT(r, !cs == !rec.fExpectedToSucceed);
|
||||
if (cs) {
|
||||
REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == cs->gammaNamed());
|
||||
}
|
||||
}
|
||||
|
||||
SkImageInfo info = SkImageInfo::MakeS32(10, 10, kPremul_SkAlphaType);
|
||||
REPORTER_ASSERT(r, kSRGB_SkColorProfileType == info.profileType());
|
||||
REPORTER_ASSERT(r, SkColorSpace::k2Dot2Curve_GammaNamed == info.colorSpace()->gammaNamed());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user