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

Unified Diff: src/gpu/SkGr.cpp

Issue 2069173002: Lots of progress switching to SkColorSpace rather than SkColorProfileType (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bad assert Created 4 years, 6 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 | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/SkGrPixelRef.cpp » ('j') | 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 c2e284154a584dea54f71f323114a4e7391b5b12..befdc83bb0b2ad36f6884a8552a8bcf78a36633e 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -243,8 +243,8 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *caps);
if (caps->srgbSupport() && !GrPixelConfigIsSRGB(desc.fConfig) &&
- kSRGB_SkColorProfileType == pixmap.info().profileType()) {
- // We were supplied sRGB as the profile type, but we don't have a suitable pixel config.
+ pixmap.info().colorSpace() && pixmap.info().colorSpace()->gammaCloseToSRGB()) {
+ // We were supplied an sRGB-like color space, 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):
@@ -252,8 +252,10 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud
pixmap.colorType(), pixmap.alphaType());
SkPixmap linSrcPixmap(linSrcInfo, pixmap.addr(), pixmap.rowBytes(), pixmap.ctable());
- SkImageInfo dstInfo = SkImageInfo::MakeN32Premul(pixmap.width(), pixmap.height(),
- kSRGB_SkColorProfileType);
+ SkImageInfo dstInfo = SkImageInfo::Make(pixmap.width(), pixmap.height(),
+ kN32_SkColorType, kPremul_SkAlphaType,
+ sk_ref_sp(pixmap.info().colorSpace()));
+
tmpBitmap.allocPixels(dstInfo);
SkImageInfo linDstInfo = SkImageInfo::MakeN32Premul(pixmap.width(), pixmap.height());
@@ -270,7 +272,8 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud
// 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());
+ SkASSERT(!caps->srgbSupport() || !pixmap.info().colorSpace() ||
+ !pixmap.info().colorSpace()->gammaCloseToSRGB());
SkImageInfo info = SkImageInfo::MakeN32(pixmap.width(), pixmap.height(),
kOpaque_SkAlphaType);
@@ -418,7 +421,7 @@ GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
// alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
// alpha info, that will be considered.
-GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProfileType pt,
+GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, const SkColorSpace* cs,
const GrCaps& caps) {
// We intentionally ignore profile type for non-8888 formats. Anything we can't support
// in hardware will be expanded to sRGB 8888 in GrUploadPixmapToTexture.
@@ -432,10 +435,10 @@ GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf
case kARGB_4444_SkColorType:
return kRGBA_4444_GrPixelConfig;
case kRGBA_8888_SkColorType:
- return (kSRGB_SkColorProfileType == pt && caps.srgbSupport())
+ return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB())
? kSRGBA_8888_GrPixelConfig : kRGBA_8888_GrPixelConfig;
case kBGRA_8888_SkColorType:
- return (kSRGB_SkColorProfileType == pt && caps.srgbSupport())
+ return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB())
? kSBGRA_8888_GrPixelConfig : kBGRA_8888_GrPixelConfig;
case kIndex_8_SkColorType:
return kIndex_8_GrPixelConfig;
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698