aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkImage_Gpu.cpp
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/SkImage_Gpu.cpp
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/SkImage_Gpu.cpp')
-rw-r--r--src/image/SkImage_Gpu.cpp11
1 files changed, 10 insertions, 1 deletions
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,