Convert Gray8 images to N32 before uploading. Previously, we were

treating them as Alpha8, which was wrong. Fixes incorrect images on the
filterbitmap_image_mandrill_64.png_g8 GM.

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

Review URL: https://codereview.chromium.org/1830973002
This commit is contained in:
brianosman 2016-03-24 06:56:32 -07:00 committed by Commit bot
parent 1215c6ac94
commit 85f9269d9b

View File

@ -243,7 +243,7 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud
if (caps->srgbSupport() && !GrPixelConfigIsSRGB(desc.fConfig) &&
kSRGB_SkColorProfileType == pixmap.info().profileType()) {
// We we supplied sRGB as the profile type, but we don't have a suitable pixel config.
// We were supplied sRGB as the profile type, but we don't have a suitable pixel config.
// Convert to 8888 sRGB so we can handle the data correctly. The raster backend doesn't
// handle sRGB Index8 -> sRGB 8888 correctly (yet), so lie about both the source and
// destination (claim they're linear):
@ -265,6 +265,24 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud
pmap = &tmpPixmap;
// must rebuild desc, since we've forced the info to be N32
desc = GrImageInfoToSurfaceDesc(pmap->info(), *caps);
} else if (kGray_8_SkColorType == pixmap.colorType()) {
// We don't have Gray8 support as a pixel config, so expand to 8888
// We should have converted sRGB Gray8 above (if we have sRGB support):
SkASSERT(!caps->srgbSupport() || kLinear_SkColorProfileType == pixmap.info().profileType());
SkImageInfo info = SkImageInfo::MakeN32(pixmap.width(), pixmap.height(),
kOpaque_SkAlphaType);
tmpBitmap.allocPixels(info);
if (!pixmap.readPixels(info, tmpBitmap.getPixels(), tmpBitmap.rowBytes())) {
return nullptr;
}
if (!tmpBitmap.peekPixels(&tmpPixmap)) {
return nullptr;
}
pmap = &tmpPixmap;
// must rebuild desc, since we've forced the info to be N32
desc = GrImageInfoToSurfaceDesc(pmap->info(), *caps);
} else if (kIndex_8_SkColorType == pixmap.colorType()) {
if (caps->isConfigTexturable(kIndex_8_GrPixelConfig)) {
size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig,