Set sRGB flag for PNGs with an sRGB chunk

BUG=skia:3471
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1667823004

Review URL: https://codereview.chromium.org/1667823004
This commit is contained in:
msarett 2016-02-04 15:37:58 -08:00 committed by Commit bot
parent 16aad78602
commit a87d6de6a5
2 changed files with 11 additions and 3 deletions

View File

@ -117,7 +117,12 @@ inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) {
* - otherwise match the src color type
*/
inline bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src) {
if (dst.profileType() != src.profileType()) {
// FIXME: skbug.com/4895
// Currently, we treat both kLinear and ksRGB encoded images as if they are kLinear.
// This makes sense while we do not have proper support for ksRGB. This is also
// the reason why we always allow the client to request kLinear.
if (dst.profileType() != src.profileType() &&
kLinear_SkColorProfileType != dst.profileType()) {
return false;
}

View File

@ -328,10 +328,13 @@ static bool read_header(SkStream* stream, SkPngChunkReader* chunkReader,
*numberPassesPtr = numberPasses;
}
// FIXME: Also need to check for sRGB ( https://bug.skia.org/3471 ).
SkColorProfileType profileType = kLinear_SkColorProfileType;
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sRGB)) {
profileType = kSRGB_SkColorProfileType;
}
if (imageInfo) {
*imageInfo = SkImageInfo::Make(origWidth, origHeight, colorType, alphaType);
*imageInfo = SkImageInfo::Make(origWidth, origHeight, colorType, alphaType, profileType);
}
autoClean.detach();
if (png_ptrp) {