Keep SkColorSpace and SkColorProfileType in sync

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2068743003

Review-Url: https://codereview.chromium.org/2068743003
This commit is contained in:
msarett 2016-06-15 12:12:48 -07:00 committed by Commit bot
parent a7d1e2a57a
commit 04d35bd80d
2 changed files with 13 additions and 4 deletions

View File

@ -198,7 +198,9 @@ public:
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
SkColorProfileType pt = kLinear_SkColorProfileType) {
return SkImageInfo(width, height, ct, at, pt, nullptr);
sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ?
SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr;
return SkImageInfo(width, height, ct, at, pt, cs);
}
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
@ -209,7 +211,9 @@ public:
*/
static SkImageInfo MakeN32(int width, int height, SkAlphaType at,
SkColorProfileType pt = kLinear_SkColorProfileType) {
return SkImageInfo(width, height, kN32_SkColorType, at, pt, nullptr);
sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ?
SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr;
return SkImageInfo(width, height, kN32_SkColorType, at, pt, cs);
}
/**
@ -217,7 +221,9 @@ public:
*/
static SkImageInfo MakeN32Premul(int width, int height,
SkColorProfileType pt = kLinear_SkColorProfileType) {
return SkImageInfo(width, height, kN32_SkColorType, kPremul_SkAlphaType, pt, nullptr);
sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ?
SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr;
return SkImageInfo(width, height, kN32_SkColorType, kPremul_SkAlphaType, pt, cs);
}
/**

View File

@ -31,7 +31,10 @@ static void test_flatten(skiatest::Reporter* reporter, const SkImageInfo& info)
info2.unflatten(rb);
REPORTER_ASSERT(reporter, rb.offset() == wb.bytesWritten());
REPORTER_ASSERT(reporter, info == info2);
// FIXME (msarett):
// Support flatten/unflatten of SkColorSpace objects.
REPORTER_ASSERT(reporter, info.makeColorSpace(nullptr) == info2.makeColorSpace(nullptr));
}
DEF_TEST(ImageInfo_flattening, reporter) {