aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/image')
-rw-r--r--src/image/SkImage.cpp2
-rw-r--r--src/image/SkImage_Gpu.cpp11
2 files changed, 11 insertions, 2 deletions
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 67779ba146..6c75619744 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -399,7 +399,7 @@ sk_sp<SkImage> SkImage::MakeFromTexture(GrContext*, const GrBackendTextureDesc&,
size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy&,
const DeferredTextureImageUsageParams[],
int paramCnt, void* buffer,
- SkSourceGammaTreatment treatment) const {
+ SkColorSpace* dstColorSpace) const {
return 0;
}
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index af16681933..c9315bb14d 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -430,7 +430,7 @@ private:
size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& proxy,
const DeferredTextureImageUsageParams params[],
int paramCnt, void* buffer,
- SkSourceGammaTreatment gammaTreatment) const {
+ SkColorSpace* dstColorSpace) const {
// Extract relevant min/max values from the params array.
int lowestPreScaleMipLevel = params[0].fPreScaleMipLevel;
SkFilterQuality highestFilterQuality = params[0].fQuality;
@@ -565,6 +565,15 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
memcpy(ct, pixmap.ctable()->readColors(), ctSize);
}
+ // If the context has sRGB support, and we're intending to render to a surface with an attached
+ // color space, and the image has an sRGB-like color space attached, then use our gamma (sRGB)
+ // aware mip-mapping.
+ SkSourceGammaTreatment gammaTreatment = SkSourceGammaTreatment::kIgnore;
+ if (proxy.fCaps->srgbSupport() && SkToBool(dstColorSpace) &&
+ info.colorSpace() && info.colorSpace()->gammaCloseToSRGB()) {
+ gammaTreatment = SkSourceGammaTreatment::kRespect;
+ }
+
SkASSERT(info == pixmap.info());
size_t rowBytes = pixmap.rowBytes();
static_assert(std::is_standard_layout<DeferredTextureImage>::value,