diff options
author | 2017-09-07 10:19:08 -0400 | |
---|---|---|
committer | 2017-09-07 15:34:21 +0000 | |
commit | a8ac92418807e3d46a45413459e6895160134c1d (patch) | |
tree | d1ac55f13ab8a7c90f92d7512b02e4d2c1e22b62 /src/image/SkImage_Gpu.cpp | |
parent | da669f150690e5e3d54099b18adb75420068582e (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_Gpu.cpp')
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index d5dc4a2e32..3458075321 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -203,9 +203,19 @@ bool SkImage_Gpu::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size flags = GrContextPriv::kUnpremul_PixelOpsFlag; } + // This hack allows us to call makeNonTextureImage on images with arbitrary color spaces. + // Otherwise, we'll be unable to create a render target context. + // TODO: This shouldn't be necessary - we need more robust support for images (and surfaces) + // with arbitrary color spaces. Unfortunately, this is one spot where we go from image to + // surface (rather than the opposite), and our lenient image rules break our (currently) more + // strict surface rules. + sk_sp<SkColorSpace> surfaceColorSpace = fColorSpace; + if (!flags && SkColorSpace::Equals(fColorSpace.get(), dstInfo.colorSpace())) { + surfaceColorSpace = nullptr; + } + sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeWrappedSurfaceContext( - fProxy, - fColorSpace); + fProxy, surfaceColorSpace); if (!sContext) { return false; } |