aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkImage_Lazy.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-09-07 10:19:08 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-07 15:34:21 +0000
commita8ac92418807e3d46a45413459e6895160134c1d (patch)
treed1ac55f13ab8a7c90f92d7512b02e4d2c1e22b62 /src/image/SkImage_Lazy.cpp
parentda669f150690e5e3d54099b18adb75420068582e (diff)
Make SkImage_Lazy always report the color space of its data
Legacy clients are likely to ignore this information, but there are cases (using SkColorSpaceXformCanvas) where getting accurate information is important. Bug: skia: Change-Id: Ia56170559c82299375021c813424098ffc627b02 Reviewed-on: https://skia-review.googlesource.com/43562 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/image/SkImage_Lazy.cpp')
-rw-r--r--src/image/SkImage_Lazy.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index aff19f8d79..14c8e199be 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -703,12 +703,16 @@ static void set_key_on_proxy(GrResourceProvider* resourceProvider,
}
sk_sp<SkColorSpace> SkImage_Lazy::getColorSpace(GrContext* ctx, SkColorSpace* dstColorSpace) {
- // TODO: This isn't always correct. Picture generator currently produces textures in N32,
- // and will (soon) emit them in an arbitrary (destination) space. We will need to stash that
- // information in/on the key so we can return the correct space in case #1 of lockTexture.
- CachedFormat format = this->chooseCacheFormat(dstColorSpace, ctx->caps());
- SkImageInfo cacheInfo = this->buildCacheInfo(format);
- return sk_ref_sp(cacheInfo.colorSpace());
+ if (!dstColorSpace) {
+ // In legacy mode, we do no modification to the image's color space or encoding.
+ // Subsequent legacy drawing is likely to ignore the color space, but some clients
+ // may want to know what space the image data is in, so return it.
+ return fInfo.refColorSpace();
+ } else {
+ CachedFormat format = this->chooseCacheFormat(dstColorSpace, ctx->caps());
+ SkImageInfo cacheInfo = this->buildCacheInfo(format);
+ return cacheInfo.refColorSpace();
+ }
}
/*