Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(656)

Unified Diff: src/gpu/SkGr.cpp

Issue 1830973002: Convert Gray8 images to N32 before uploading. Previously, we were (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGr.cpp
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 61ab4b402a67f020a48658a5297b2d62d31a1ff3..701e763b1e65d19904c22a9c3a73a80a0f6ca91e 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698