aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2016-10-17 09:51:37 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-17 20:48:55 +0000
commit6c15cc7e9d65981ec0363a050d2248f96e21a5da (patch)
tree65bd13866f185596eb63a38a403e4c321183d525 /src/image
parenta73d76af31d8ad04716fb611d7987dfd1762f5e9 (diff)
Modify deferred texture image API's handling of gamma
This tries to match the behavior you would see if you rendered directly to a canvas without going through this round-trip. Specifically, mips are built in the same way that they would be according to the context's internal logic. To make things clearer, the user passes in the color space of the destination surface, not our (internal) enum. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3526 Change-Id: If8c61500d34ae712227da0284f3a80cacf84113a Reviewed-on: https://skia-review.googlesource.com/3526 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
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,