diff options
author | 2016-11-15 18:07:26 +0000 | |
---|---|---|
committer | 2016-11-15 18:07:40 +0000 | |
commit | 57ae6cfe01b811aaead80872ed9e5e1d30f35f81 (patch) | |
tree | 12dd094a0ba392e374f906cb62426df5d5213d60 /src/image/SkImage.cpp | |
parent | d6010879c6271b66acd4498e892a24de0ffaf15e (diff) |
Revert "Support decoding images to multiple formats, depending on usage"
This reverts commit c73a1ecbed64652b3d7aa8dc6face9a2205ce830.
Reason for revert: ANGLE and CommandBuffer failures
Original change's description:
> 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>
>
TBR=mtklein@google.com,bsalomon@google.com,msarett@google.com,brianosman@google.com,reed@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I1818f937464573d601f64e5a1f1eb43f5a778f4e
Reviewed-on: https://skia-review.googlesource.com/4832
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/image/SkImage.cpp')
-rw-r--r-- | src/image/SkImage.cpp | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index f976242eca..4d76638cbd 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -65,11 +65,8 @@ bool SkImage::scalePixels(const SkPixmap& dst, SkFilterQuality quality, CachingH // Idea: If/when SkImageGenerator supports a native-scaling API (where the generator itself // can scale more efficiently) we should take advantage of it here. // - SkDestinationSurfaceColorMode decodeColorMode = dst.info().colorSpace() - ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware - : SkDestinationSurfaceColorMode::kLegacy; SkBitmap bm; - if (as_IB(this)->getROPixels(&bm, decodeColorMode, chint)) { + if (as_IB(this)->getROPixels(&bm, chint)) { bm.lockPixels(); SkPixmap pmap; // Note: By calling the pixmap scaler, we never cache the final result, so the chint @@ -86,7 +83,7 @@ void SkImage::preroll(GrContext* ctx) const { // to produce a cached raster-bitmap form, so that drawing to a raster canvas should be fast. // SkBitmap bm; - if (as_IB(this)->getROPixels(&bm, SkDestinationSurfaceColorMode::kLegacy)) { + if (as_IB(this)->getROPixels(&bm)) { bm.lockPixels(); bm.unlockPixels(); } @@ -105,10 +102,7 @@ sk_sp<SkShader> SkImage::makeShader(SkShader::TileMode tileX, SkShader::TileMode SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const { SkBitmap bm; - // TODO: Right now, the encoders don't handle F16 or linearly premultiplied data. Once they do, - // we should decode in "color space aware" mode, then re-encode that. For now, work around this - // by asking for a legacy decode (which gives us the raw data in N32). - if (as_IB(this)->getROPixels(&bm, SkDestinationSurfaceColorMode::kLegacy)) { + if (as_IB(this)->getROPixels(&bm)) { return SkImageEncoder::EncodeData(bm, type, quality); } return nullptr; @@ -129,11 +123,7 @@ SkData* SkImage::encode(SkPixelSerializer* serializer) const { SkBitmap bm; SkAutoPixmapUnlock apu; - // TODO: Right now, the encoders don't handle F16 or linearly premultiplied data. Once they do, - // we should decode in "color space aware" mode, then re-encode that. For now, work around this - // by asking for a legacy decode (which gives us the raw data in N32). - if (as_IB(this)->getROPixels(&bm, SkDestinationSurfaceColorMode::kLegacy) && - bm.requestLock(&apu)) { + if (as_IB(this)->getROPixels(&bm) && bm.requestLock(&apu)) { return effectiveSerializer->encode(apu.pixmap()); } @@ -294,7 +284,8 @@ bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { bool SkImage_Base::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { // As the base-class, all we can do is make a copy (regardless of mode). // Subclasses that want to be more optimal should override. - SkImageInfo info = this->onImageInfo().makeColorType(kN32_SkColorType).makeColorSpace(nullptr); + SkImageInfo info = this->onImageInfo().makeColorType(kN32_SkColorType) + .makeAlphaType(this->alphaType()); if (!bitmap->tryAllocPixels(info)) { return false; } @@ -324,19 +315,15 @@ sk_sp<SkImage> SkImage::makeWithFilter(const SkImageFilter* filter, const SkIRec if (!filter || !outSubset || !offset || !this->bounds().contains(subset)) { return nullptr; } - SkColorSpace* colorSpace = as_IB(this)->onImageInfo().colorSpace(); - SkDestinationSurfaceColorMode decodeColorMode = colorSpace - ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware - : SkDestinationSurfaceColorMode::kLegacy; sk_sp<SkSpecialImage> srcSpecialImage = SkSpecialImage::MakeFromImage( - subset, sk_ref_sp(const_cast<SkImage*>(this)), decodeColorMode); + subset, sk_ref_sp(const_cast<SkImage*>(this))); if (!srcSpecialImage) { return nullptr; } sk_sp<SkImageFilterCache> cache( SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize)); - SkImageFilter::OutputProperties outputProperties(colorSpace); + SkImageFilter::OutputProperties outputProperties(as_IB(this)->onImageInfo().colorSpace()); SkImageFilter::Context context(SkMatrix::I(), clipBounds, cache.get(), outputProperties); sk_sp<SkSpecialImage> result = |