Plumb dst color space in many places, rather than "mode"
This is less to type in most cases, and gives us more information
(for things like picture-backed images, where we need to know all
about the destination surface).
Additionally, strip out the plumbing entirely for bitmap sources,
where we don't need to know anything.
BUG=skia:
Change-Id: I4deff6c7c345fcf62eb08b2aff0560adae4313da
Reviewed-on: https://skia-review.googlesource.com/5748
Reviewed-by: Mike Klein <mtklein@chromium.org>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index baabd56..21523fd 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -66,11 +66,8 @@
// 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, dst.info().colorSpace(), chint)) {
bm.lockPixels();
SkPixmap pmap;
// Note: By calling the pixmap scaler, we never cache the final result, so the chint
@@ -87,7 +84,8 @@
// 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)) {
+ SkColorSpace* legacyColorSpace = nullptr;
+ if (as_IB(this)->getROPixels(&bm, legacyColorSpace)) {
bm.lockPixels();
bm.unlockPixels();
}
@@ -109,7 +107,8 @@
// 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)) {
+ SkColorSpace* legacyColorSpace = nullptr;
+ if (as_IB(this)->getROPixels(&bm, legacyColorSpace)) {
SkDynamicMemoryWStream buf;
return SkEncodeImage(&buf, bm, type, quality) ? buf.detachAsData().release() : nullptr;
}
@@ -128,7 +127,8 @@
// 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) &&
+ SkColorSpace* legacyColorSpace = nullptr;
+ if (as_IB(this)->getROPixels(&bm, legacyColorSpace) &&
bm.requestLock(&apu)) {
if (serializer) {
return serializer->encode(apu.pixmap());
@@ -327,11 +327,8 @@
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)), colorSpace);
if (!srcSpecialImage) {
return nullptr;
}