diff options
author | Brian Osman <brianosman@google.com> | 2016-11-14 15:09:56 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-15 15:27:14 +0000 |
commit | c73a1ecbed64652b3d7aa8dc6face9a2205ce830 (patch) | |
tree | 59e66c879ca0d1ab68720ccae740cecb2d5660ef /src/image/SkImage_Gpu.cpp | |
parent | fd01ce05ef7902c49b0272b3524a389693c72b35 (diff) |
Support decoding images to multiple formats, depending on usage
Our codec generator will now preserve any asked-for color space, and
convert the encoded data to that representation. Cacherator now
allows decoding an image to both legacy (nullptr color space), and
color-correct formats. In color-correct mode, we choose the best
decoded format, based on the original properties, and our backend's
capabilities. Preference is given to the native format, when it's
already texturable (sRGB 8888 or F16 linear). Otherwise, we prefer
linear F16, and fall back to sRGB when that's not an option.
BUG=skia:5907
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4438
Change-Id: I847c243dcfb72d8c0f1f6fc73c09547adea933f0
Reviewed-on: https://skia-review.googlesource.com/4438
Reviewed-by: Matt Sarett <msarett@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 | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index a006e14ecf..0bcfbd2294 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -20,6 +20,7 @@ #include "SkBitmapCache.h" #include "SkGrPriv.h" #include "SkImage_Gpu.h" +#include "SkImageCacherator.h" #include "SkMipMap.h" #include "SkPixelRef.h" @@ -60,7 +61,8 @@ static SkImageInfo make_info(int w, int h, SkAlphaType at, sk_sp<SkColorSpace> c return SkImageInfo::MakeN32(w, h, at, std::move(colorSpace)); } -bool SkImage_Gpu::getROPixels(SkBitmap* dst, CachingHint chint) const { +bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkDestinationSurfaceColorMode, + CachingHint chint) const { if (SkBitmapCache::Find(this->uniqueID(), dst)) { SkASSERT(dst->getGenerationID() == this->uniqueID()); SkASSERT(dst->isImmutable()); @@ -494,7 +496,19 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox if (!data && !this->peekPixels(nullptr)) { return 0; } - info = as_IB(this)->onImageInfo().makeWH(scaledSize.width(), scaledSize.height()); + if (SkImageCacherator* cacher = as_IB(this)->peekCacherator()) { + // Generator backed image. Tweak info to trigger correct kind of decode. + SkDestinationSurfaceColorMode decodeColorMode = dstColorSpace + ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware + : SkDestinationSurfaceColorMode::kLegacy; + SkImageCacherator::CachedFormat cacheFormat = cacher->chooseCacheFormat( + decodeColorMode, proxy.fCaps.get()); + info = cacher->buildCacheInfo(cacheFormat).makeWH(scaledSize.width(), + scaledSize.height()); + + } else { + info = as_IB(this)->onImageInfo().makeWH(scaledSize.width(), scaledSize.height()); + } pixelSize = SkAlign8(SkAutoPixmapStorage::AllocSize(info, nullptr)); if (fillMode) { pixmap.alloc(info); |