aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2018-07-12 14:44:27 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-12 20:54:14 +0000
commitb62f50cf763279fa0d0aa2f80624de02c7a1c2fb (patch)
treea4aba5466ff7e3136bd97c35718a678354b430ea /src
parent5bc4fc8f3f26e9e14cccee4d200309e4b500b8d3 (diff)
Replace nearly all kRespect with kIgnore
- Encoders and decoders always assume kIgnore. - They are less opinionated about F16 and color space, we just trust the color space that's passed in, and put that directly in the image (no sRGB encoding). - SkBitmap and SkPixmap read/write pixels functions were defaulting to kResepct, those are now always kIgnore. - Many other bits of plumbing are simplified, and I added a default of kIgnore to SkImage::makeColorSpace, so we can phase out that argument entirely. - Still need to add defaults to other public APIs that take SkTransferFunctionBehavior. - This makes gold think that we've dramatically changed the contents of all F16 images, but that's because it doesn't understand the (now linear) color space that's embedded. Once we triage them all once, they will work fine (and they'll look perfect in the browser). Bug: skia: Change-Id: I62fa090f96cae1b67d181ce14bd91f34ff2ed747 Reviewed-on: https://skia-review.googlesource.com/140570 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/codec/SkCodec.cpp18
-rw-r--r--src/codec/SkCodecImageGenerator.cpp4
-rw-r--r--src/codec/SkCodecPriv.h8
-rw-r--r--src/codec/SkSampledCodec.cpp2
-rw-r--r--src/codec/SkWebpAdapterCodec.cpp1
-rw-r--r--src/codec/SkWebpCodec.cpp8
-rw-r--r--src/core/SkBitmap.cpp9
-rw-r--r--src/core/SkColorSpaceXform.cpp23
-rw-r--r--src/core/SkColorSpaceXformPriv.h8
-rw-r--r--src/core/SkColorSpaceXformer.cpp6
-rw-r--r--src/core/SkConvertPixels.cpp42
-rw-r--r--src/core/SkConvertPixels.h3
-rw-r--r--src/core/SkPixmap.cpp5
-rw-r--r--src/image/SkImage.cpp8
-rw-r--r--src/image/SkImage_Base.h3
-rw-r--r--src/image/SkImage_Gpu.cpp8
-rw-r--r--src/image/SkImage_Gpu.h3
-rw-r--r--src/image/SkImage_Lazy.cpp6
-rw-r--r--src/image/SkImage_Raster.cpp8
-rw-r--r--src/images/SkImageEncoder.cpp3
-rw-r--r--src/images/SkImageEncoderFns.h65
-rw-r--r--src/images/SkJpegEncoder.cpp13
-rw-r--r--src/images/SkPngEncoder.cpp20
-rw-r--r--src/images/SkWebpEncoder.cpp13
-rw-r--r--src/shaders/SkPictureShader.cpp2
25 files changed, 67 insertions, 222 deletions
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index d9992c0cd9..130fcd194f 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -174,7 +174,7 @@ bool SkCodec::conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
return srcIsOpaque;
case kGray_8_SkColorType:
return kGray_8_SkColorType == srcColor && srcIsOpaque &&
- !needs_color_xform(dst, srcCS, false);
+ !needs_color_xform(dst, srcCS);
case kAlpha_8_SkColorType:
// conceptually we can convert anything into alpha_8, but we haven't actually coded
// all of those other conversions yet, so only return true for the case we have codec.
@@ -247,7 +247,7 @@ SkCodec::Result SkCodec::handleFrameIndex(const SkImageInfo& info, void* pixels,
if (0 == index) {
if (!this->conversionSupported(info, fSrcInfo.colorType(), fEncodedInfo.opaque(),
fSrcInfo.colorSpace())
- || !this->initializeColorXform(info, fEncodedInfo.alpha(), options.fPremulBehavior))
+ || !this->initializeColorXform(info, fEncodedInfo.alpha()))
{
return kInvalidConversion;
}
@@ -324,8 +324,7 @@ SkCodec::Result SkCodec::handleFrameIndex(const SkImageInfo& info, void* pixels,
}
}
- return this->initializeColorXform(info, frame->reportedAlpha(), options.fPremulBehavior)
- ? kSuccess : kInvalidConversion;
+ return this->initializeColorXform(info, frame->reportedAlpha()) ? kSuccess : kInvalidConversion;
}
SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
@@ -648,8 +647,7 @@ static inline SkColorSpaceXform::ColorFormat select_xform_format_ct(SkColorType
}
}
-bool SkCodec::initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Alpha encodedAlpha,
- SkTransferFunctionBehavior premulBehavior) {
+bool SkCodec::initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Alpha encodedAlpha) {
fColorXform = nullptr;
fXformOnDecode = false;
if (!this->usesColorXform()) {
@@ -659,12 +657,8 @@ bool SkCodec::initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Al
// a colorXform to do a color correct premul, since the blend step will handle
// premultiplication. But there is no way to know whether we need to blend from
// inside this call.
- bool needsColorCorrectPremul = needs_premul(dstInfo.alphaType(), encodedAlpha) &&
- SkTransferFunctionBehavior::kRespect == premulBehavior;
- if (needs_color_xform(dstInfo, fSrcInfo.colorSpace(), needsColorCorrectPremul)) {
- fColorXform = SkMakeColorSpaceXform(fSrcInfo.colorSpace(),
- dstInfo.colorSpace(),
- premulBehavior);
+ if (needs_color_xform(dstInfo, fSrcInfo.colorSpace())) {
+ fColorXform = SkMakeColorSpaceXform(fSrcInfo.colorSpace(), dstInfo.colorSpace());
if (!fColorXform) {
return false;
}
diff --git a/src/codec/SkCodecImageGenerator.cpp b/src/codec/SkCodecImageGenerator.cpp
index 6727dcf076..55a6575051 100644
--- a/src/codec/SkCodecImageGenerator.cpp
+++ b/src/codec/SkCodecImageGenerator.cpp
@@ -44,9 +44,7 @@ bool SkCodecImageGenerator::onGetPixels(const SkImageInfo& requestInfo, void* re
SkPixmap dst(requestInfo, requestPixels, requestRowBytes);
auto decode = [this](const SkPixmap& pm) {
- SkCodec::Options codecOpts;
- codecOpts.fPremulBehavior = SkTransferFunctionBehavior::kIgnore;
- SkCodec::Result result = fCodec->getPixels(pm, &codecOpts);
+ SkCodec::Result result = fCodec->getPixels(pm);
switch (result) {
case SkCodec::kSuccess:
case SkCodec::kIncompleteInput:
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index 1251d8d73c..65d457539e 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -276,20 +276,20 @@ static inline bool needs_premul(SkAlphaType dstAT, SkEncodedInfo::Alpha encodedA
return kPremul_SkAlphaType == dstAT && SkEncodedInfo::kUnpremul_Alpha == encodedAlpha;
}
-static inline bool needs_color_xform(const SkImageInfo& dstInfo, const SkColorSpace* srcCS,
- bool needsColorCorrectPremul) {
+static inline bool needs_color_xform(const SkImageInfo& dstInfo, const SkColorSpace* srcCS) {
// We never perform a color xform in legacy mode.
if (!dstInfo.colorSpace()) {
return false;
}
- // F16 is by definition a linear space, so we always must perform a color xform.
+ // None of the codecs we have output F16 natively, so if we're trying to decode to F16,
+ // we'll have to use SkColorSpaceXform to get there.
bool isF16 = kRGBA_F16_SkColorType == dstInfo.colorType();
// Need a color xform when dst space does not match the src.
bool srcDstNotEqual = !SkColorSpace::Equals(srcCS, dstInfo.colorSpace());
- return needsColorCorrectPremul || isF16 || srcDstNotEqual;
+ return isF16 || srcDstNotEqual;
}
static inline SkAlphaType select_xform_alpha(SkAlphaType dstAlphaType, SkAlphaType srcAlphaType) {
diff --git a/src/codec/SkSampledCodec.cpp b/src/codec/SkSampledCodec.cpp
index ac0539fc74..cf97b0b23f 100644
--- a/src/codec/SkSampledCodec.cpp
+++ b/src/codec/SkSampledCodec.cpp
@@ -75,7 +75,6 @@ SkCodec::Result SkSampledCodec::onGetAndroidPixels(const SkImageInfo& info, void
// Create an Options struct for the codec.
SkCodec::Options codecOptions;
codecOptions.fZeroInitialized = options.fZeroInitialized;
- codecOptions.fPremulBehavior = SkTransferFunctionBehavior::kIgnore;
SkIRect* subset = options.fSubset;
if (!subset || subset->size() == this->codec()->getInfo().dimensions()) {
@@ -170,7 +169,6 @@ SkCodec::Result SkSampledCodec::sampledDecode(const SkImageInfo& info, void* pix
// Create options struct for the codec.
SkCodec::Options sampledOptions;
sampledOptions.fZeroInitialized = options.fZeroInitialized;
- sampledOptions.fPremulBehavior = SkTransferFunctionBehavior::kIgnore;
// FIXME: This was already called by onGetAndroidPixels. Can we reduce that?
int sampleSize = options.fSampleSize;
diff --git a/src/codec/SkWebpAdapterCodec.cpp b/src/codec/SkWebpAdapterCodec.cpp
index 81011d017b..79a99a72f0 100644
--- a/src/codec/SkWebpAdapterCodec.cpp
+++ b/src/codec/SkWebpAdapterCodec.cpp
@@ -27,6 +27,5 @@ SkCodec::Result SkWebpAdapterCodec::onGetAndroidPixels(const SkImageInfo& info,
SkCodec::Options codecOptions;
codecOptions.fZeroInitialized = options.fZeroInitialized;
codecOptions.fSubset = options.fSubset;
- codecOptions.fPremulBehavior = SkTransferFunctionBehavior::kIgnore;
return this->codec()->getPixels(info, pixels, rowBytes, &codecOptions);
}
diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp
index b6485b1b9c..bb6e430790 100644
--- a/src/codec/SkWebpCodec.cpp
+++ b/src/codec/SkWebpCodec.cpp
@@ -514,14 +514,6 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
const bool blendWithPrevFrame = !independent && frame.blend_method == WEBP_MUX_BLEND
&& frame.has_alpha;
- if (blendWithPrevFrame && options.fPremulBehavior == SkTransferFunctionBehavior::kRespect) {
- // Blending is done with SkRasterPipeline, which requires a color space that is valid for
- // rendering.
- const auto* cs = dstInfo.colorSpace();
- if (!cs || (!cs->gammaCloseToSRGB() && !cs->gammaIsLinear())) {
- return kInvalidConversion;
- }
- }
SkBitmap webpDst;
auto webpInfo = dstInfo;
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 4ef7abf95c..6d936f9436 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -494,8 +494,7 @@ bool SkBitmap::readPixels(const SkPixmap& dst, int srcX, int srcY) const {
return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(), srcX, srcY);
}
-bool SkBitmap::writePixels(const SkPixmap& src, int dstX, int dstY,
- SkTransferFunctionBehavior behavior) {
+bool SkBitmap::writePixels(const SkPixmap& src, int dstX, int dstY, SkTransferFunctionBehavior) {
if (!SkImageInfoValidConversion(this->info(), src.info())) {
return false;
}
@@ -507,8 +506,7 @@ bool SkBitmap::writePixels(const SkPixmap& src, int dstX, int dstY,
void* dstPixels = this->getAddr(rec.fX, rec.fY);
const SkImageInfo dstInfo = this->info().makeWH(rec.fInfo.width(), rec.fInfo.height());
- SkConvertPixels(dstInfo, dstPixels, this->rowBytes(), rec.fInfo, rec.fPixels, rec.fRowBytes,
- behavior);
+ SkConvertPixels(dstInfo, dstPixels, this->rowBytes(), rec.fInfo, rec.fPixels, rec.fRowBytes);
this->notifyPixelsChanged();
return true;
}
@@ -528,8 +526,7 @@ static bool GetBitmapAlpha(const SkBitmap& src, uint8_t* SK_RESTRICT alpha, int
return false;
}
SkConvertPixels(SkImageInfo::MakeA8(pmap.width(), pmap.height()), alpha, alphaRowBytes,
- pmap.info(), pmap.addr(), pmap.rowBytes(),
- SkTransferFunctionBehavior::kRespect);
+ pmap.info(), pmap.addr(), pmap.rowBytes());
return true;
}
diff --git a/src/core/SkColorSpaceXform.cpp b/src/core/SkColorSpaceXform.cpp
index 213e5b501e..5418c588fd 100644
--- a/src/core/SkColorSpaceXform.cpp
+++ b/src/core/SkColorSpaceXform.cpp
@@ -12,7 +12,7 @@
#include "../../third_party/skcms/skcms.h"
std::unique_ptr<SkColorSpaceXform> SkColorSpaceXform::New(SkColorSpace* src, SkColorSpace* dst) {
- return SkMakeColorSpaceXform(src, dst, SkTransferFunctionBehavior::kRespect);
+ return SkMakeColorSpaceXform(src, dst);
}
bool SkColorSpaceXform::Apply(SkColorSpace* dstCS, ColorFormat dstFormat, void* dst,
@@ -30,11 +30,9 @@ bool SkColorSpaceXform::Apply(SkColorSpace* dstCS, ColorFormat dstFormat, void*
class SkColorSpaceXform_skcms : public SkColorSpaceXform {
public:
SkColorSpaceXform_skcms(const skcms_ICCProfile& srcProfile,
- const skcms_ICCProfile& dstProfile,
- skcms_AlphaFormat premulFormat)
+ const skcms_ICCProfile& dstProfile)
: fSrcProfile(srcProfile)
- , fDstProfile(dstProfile)
- , fPremulFormat(premulFormat) {
+ , fDstProfile(dstProfile) {
}
bool apply(ColorFormat, void*, ColorFormat, const void*, int, SkAlphaType) const override;
@@ -42,7 +40,6 @@ public:
private:
skcms_ICCProfile fSrcProfile;
skcms_ICCProfile fDstProfile;
- skcms_AlphaFormat fPremulFormat;
};
static skcms_PixelFormat get_skcms_format(SkColorSpaceXform::ColorFormat fmt) {
@@ -71,7 +68,8 @@ bool SkColorSpaceXform_skcms::apply(ColorFormat dstFormat, void* dst,
ColorFormat srcFormat, const void* src,
int count, SkAlphaType alphaType) const {
skcms_AlphaFormat srcAlpha = skcms_AlphaFormat_Unpremul;
- skcms_AlphaFormat dstAlpha = kPremul_SkAlphaType == alphaType ? fPremulFormat
+ skcms_AlphaFormat dstAlpha = kPremul_SkAlphaType == alphaType
+ ? skcms_AlphaFormat_PremulAsEncoded
: skcms_AlphaFormat_Unpremul;
return skcms_Transform(src, get_skcms_format(srcFormat), srcAlpha, &fSrcProfile,
@@ -98,12 +96,10 @@ void SkColorSpace::toProfile(skcms_ICCProfile* profile) const {
}
}
-std::unique_ptr<SkColorSpaceXform> SkMakeColorSpaceXform(SkColorSpace* src, SkColorSpace* dst,
- SkTransferFunctionBehavior premul) {
+std::unique_ptr<SkColorSpaceXform> SkMakeColorSpaceXform(SkColorSpace* src, SkColorSpace* dst) {
if (src && dst && dst->toXYZD50()) {
// Construct skcms_ICCProfiles from each color space. For now, support A2B and XYZ.
- // Eventually, only need to support XYZ. Map premul to one of the two premul formats
- // in skcms.
+ // Eventually, only need to support XYZ.
skcms_ICCProfile srcProfile, dstProfile;
src->toProfile(&srcProfile);
@@ -113,10 +109,7 @@ std::unique_ptr<SkColorSpaceXform> SkMakeColorSpaceXform(SkColorSpace* src, SkCo
return nullptr;
}
- skcms_AlphaFormat premulFormat = SkTransferFunctionBehavior::kRespect == premul
- ? skcms_AlphaFormat_PremulLinear
- : skcms_AlphaFormat_PremulAsEncoded;
- return skstd::make_unique<SkColorSpaceXform_skcms>(srcProfile, dstProfile, premulFormat);
+ return skstd::make_unique<SkColorSpaceXform_skcms>(srcProfile, dstProfile);
}
return nullptr;
}
diff --git a/src/core/SkColorSpaceXformPriv.h b/src/core/SkColorSpaceXformPriv.h
index 301e741380..f75ebf438c 100644
--- a/src/core/SkColorSpaceXformPriv.h
+++ b/src/core/SkColorSpaceXformPriv.h
@@ -10,13 +10,7 @@
#include "SkColorSpaceXform.h"
-std::unique_ptr<SkColorSpaceXform> SkMakeColorSpaceXform(SkColorSpace* src,
- SkColorSpace* dst,
- SkTransferFunctionBehavior);
-
-std::unique_ptr<SkColorSpaceXform> SkMakeColorSpaceXform_skcms(SkColorSpace* src,
- SkColorSpace* dst,
- SkTransferFunctionBehavior);
+std::unique_ptr<SkColorSpaceXform> SkMakeColorSpaceXform(SkColorSpace* src, SkColorSpace* dst);
static inline SkColorSpaceXform::ColorFormat select_xform_format(SkColorType colorType) {
switch (colorType) {
diff --git a/src/core/SkColorSpaceXformer.cpp b/src/core/SkColorSpaceXformer.cpp
index 0b536ff8f4..5329294982 100644
--- a/src/core/SkColorSpaceXformer.cpp
+++ b/src/core/SkColorSpaceXformer.cpp
@@ -26,7 +26,7 @@ SkColorSpaceXformer::~SkColorSpaceXformer() {}
std::unique_ptr<SkColorSpaceXformer> SkColorSpaceXformer::Make(sk_sp<SkColorSpace> dst) {
std::unique_ptr<SkColorSpaceXform> fromSRGB = SkMakeColorSpaceXform(
- SkColorSpace::MakeSRGB().get(), dst.get(), SkTransferFunctionBehavior::kIgnore);
+ SkColorSpace::MakeSRGB().get(), dst.get());
return fromSRGB
? std::unique_ptr<SkColorSpaceXformer>(new SkColorSpaceXformer(std::move(dst),
@@ -98,7 +98,7 @@ sk_sp<SkImage> SkColorSpaceXformer::apply(const SkImage* src) {
const AutoCachePurge autoPurge(this);
return this->cachedApply<SkImage>(src, &fImageCache,
[](const SkImage* img, SkColorSpaceXformer* xformer) {
- return img->makeColorSpace(xformer->fDst, SkTransferFunctionBehavior::kIgnore);
+ return img->makeColorSpace(xformer->fDst);
});
}
@@ -109,7 +109,7 @@ sk_sp<SkImage> SkColorSpaceXformer::apply(const SkBitmap& src) {
return nullptr;
}
- sk_sp<SkImage> xformed = image->makeColorSpace(fDst, SkTransferFunctionBehavior::kIgnore);
+ sk_sp<SkImage> xformed = image->makeColorSpace(fDst);
// We want to be sure we don't let the kNever_SkCopyPixelsMode image escape this stack frame.
SkASSERT(xformed != image);
return xformed;
diff --git a/src/core/SkConvertPixels.cpp b/src/core/SkConvertPixels.cpp
index 0434b92c2e..ac96f20c86 100644
--- a/src/core/SkConvertPixels.cpp
+++ b/src/core/SkConvertPixels.cpp
@@ -87,13 +87,10 @@ void swizzle_and_multiply(const SkImageInfo& dstInfo, void* dstPixels, size_t ds
}
// Fast Path 3: Color space xform.
-static inline bool optimized_color_xform(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo,
- SkTransferFunctionBehavior behavior) {
+static inline bool optimized_color_xform(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo) {
// Unpremultiplication is unsupported by SkColorSpaceXform. Note that if |src| is non-linearly
// premultiplied, we're always going to have to unpremultiply before doing anything.
- if (kPremul_SkAlphaType == srcInfo.alphaType() &&
- (kUnpremul_SkAlphaType == dstInfo.alphaType() ||
- SkTransferFunctionBehavior::kIgnore == behavior)) {
+ if (kPremul_SkAlphaType == srcInfo.alphaType()) {
return false;
}
@@ -119,7 +116,7 @@ static inline bool optimized_color_xform(const SkImageInfo& dstInfo, const SkIma
static inline bool apply_color_xform(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
const SkImageInfo& srcInfo, const void* srcPixels,
- size_t srcRB, SkTransferFunctionBehavior behavior) {
+ size_t srcRB) {
SkColorSpaceXform::ColorFormat dstFormat = select_xform_format(dstInfo.colorType());
SkColorSpaceXform::ColorFormat srcFormat = select_xform_format(srcInfo.colorType());
SkAlphaType xformAlpha;
@@ -146,8 +143,8 @@ static inline bool apply_color_xform(const SkImageInfo& dstInfo, void* dstPixels
break;
}
- std::unique_ptr<SkColorSpaceXform> xform =
- SkMakeColorSpaceXform(srcInfo.colorSpace(), dstInfo.colorSpace(), behavior);
+ std::unique_ptr<SkColorSpaceXform> xform = SkMakeColorSpaceXform(srcInfo.colorSpace(),
+ dstInfo.colorSpace());
if (!xform) {
return false;
}
@@ -250,7 +247,7 @@ static void convert_to_alpha8(uint8_t* dst, size_t dstRB, const SkImageInfo& src
// Default: Use the pipeline.
static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size_t dstRB,
const SkImageInfo& srcInfo, const void* srcRow, size_t srcRB,
- bool isColorAware, SkTransferFunctionBehavior behavior) {
+ bool isColorAware) {
SkJumper_MemoryCtx src = { (void*)srcRow, (int)(srcRB / srcInfo.bytesPerPixel()) },
dst = { (void*)dstRow, (int)(dstRB / dstInfo.bytesPerPixel()) };
@@ -295,7 +292,7 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size
}
SkAlphaType premulState = srcInfo.alphaType();
- if (kPremul_SkAlphaType == premulState && SkTransferFunctionBehavior::kIgnore == behavior) {
+ if (kPremul_SkAlphaType == premulState) {
pipeline.append(SkRasterPipeline::unpremul);
premulState = kUnpremul_SkAlphaType;
}
@@ -318,17 +315,6 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size
srcInfo.colorSpace(), dstInfo.colorSpace(), premulState);
}
- SkAlphaType dat = dstInfo.alphaType();
- if (SkTransferFunctionBehavior::kRespect == behavior) {
- if (kPremul_SkAlphaType == premulState && kUnpremul_SkAlphaType == dat) {
- pipeline.append(SkRasterPipeline::unpremul);
- premulState = kUnpremul_SkAlphaType;
- } else if (kUnpremul_SkAlphaType == premulState && kPremul_SkAlphaType == dat) {
- pipeline.append(SkRasterPipeline::premul);
- premulState = kPremul_SkAlphaType;
- }
- }
-
SkColorSpaceTransferFn dstFn;
if (isColorAware && dstInfo.gammaCloseToSRGB()) {
pipeline.append(SkRasterPipeline::to_srgb);
@@ -342,8 +328,8 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size
}
}
- if (kUnpremul_SkAlphaType == premulState && kPremul_SkAlphaType == dat &&
- SkTransferFunctionBehavior::kIgnore == behavior)
+ SkAlphaType dat = dstInfo.alphaType();
+ if (kUnpremul_SkAlphaType == premulState && kPremul_SkAlphaType == dat)
{
pipeline.append(SkRasterPipeline::premul);
premulState = kPremul_SkAlphaType;
@@ -415,8 +401,7 @@ static bool swizzle_and_multiply_color_type(SkColorType ct) {
}
void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
- const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRB,
- SkTransferFunctionBehavior behavior) {
+ const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRB) {
SkASSERT(dstInfo.dimensions() == srcInfo.dimensions());
SkASSERT(SkImageInfoValidConversion(dstInfo, srcInfo));
@@ -437,8 +422,8 @@ void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
}
// Fast Path 3: Color space xform.
- if (isColorAware && optimized_color_xform(dstInfo, srcInfo, behavior)) {
- if (apply_color_xform(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB, behavior)) {
+ if (isColorAware && optimized_color_xform(dstInfo, srcInfo)) {
+ if (apply_color_xform(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB)) {
return;
}
}
@@ -450,6 +435,5 @@ void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
}
// Default: Use the pipeline.
- convert_with_pipeline(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB, isColorAware,
- behavior);
+ convert_with_pipeline(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB, isColorAware);
}
diff --git a/src/core/SkConvertPixels.h b/src/core/SkConvertPixels.h
index 001052b7a8..ccd76c35a7 100644
--- a/src/core/SkConvertPixels.h
+++ b/src/core/SkConvertPixels.h
@@ -14,8 +14,7 @@
class SkColorTable;
void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
- const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes,
- SkTransferFunctionBehavior behavior);
+ const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes);
static inline void SkRectMemcpy(void* dst, size_t dstRB, const void* src, size_t srcRB,
size_t bytesPerRow, int rowCount) {
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp
index 77b174b154..d91b3cc9c1 100644
--- a/src/core/SkPixmap.cpp
+++ b/src/core/SkPixmap.cpp
@@ -81,7 +81,7 @@ bool SkPixmap::extractSubset(SkPixmap* result, const SkIRect& subset) const {
}
bool SkPixmap::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB, int x, int y,
- SkTransferFunctionBehavior behavior) const {
+ SkTransferFunctionBehavior) const {
if (!SkImageInfoValidConversion(dstInfo, fInfo)) {
return false;
}
@@ -93,8 +93,7 @@ bool SkPixmap::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t ds
const void* srcPixels = this->addr(rec.fX, rec.fY);
const SkImageInfo srcInfo = fInfo.makeWH(rec.fInfo.width(), rec.fInfo.height());
- SkConvertPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, srcInfo, srcPixels, this->rowBytes(),
- behavior);
+ SkConvertPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, srcInfo, srcPixels, this->rowBytes());
return true;
}
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 128e693ad2..53add0e9d3 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -295,7 +295,7 @@ bool SkImage::isAlphaOnly() const {
}
sk_sp<SkImage> SkImage::makeColorSpace(sk_sp<SkColorSpace> target,
- SkTransferFunctionBehavior premulBehavior) const {
+ SkTransferFunctionBehavior) const {
SkColorSpaceTransferFn fn;
if (!target || !target->isNumericalTransferFn(&fn)) {
return nullptr;
@@ -309,13 +309,11 @@ sk_sp<SkImage> SkImage::makeColorSpace(sk_sp<SkColorSpace> target,
return sk_ref_sp(const_cast<SkImage*>(this));
}
+ // TODO: Re-visit this! Keep existing color type?
SkColorType targetColorType = kN32_SkColorType;
- if (SkTransferFunctionBehavior::kRespect == premulBehavior && target->gammaIsLinear()) {
- targetColorType = kRGBA_F16_SkColorType;
- }
// TODO: We might consider making this a deferred conversion?
- return as_IB(this)->onMakeColorSpace(std::move(target), targetColorType, premulBehavior);
+ return as_IB(this)->onMakeColorSpace(std::move(target), targetColorType);
}
sk_sp<SkImage> SkImage::makeNonTextureImage() const {
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 0d54a39471..6a048ba51f 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -95,8 +95,7 @@ public:
virtual bool onPinAsTexture(GrContext*) const { return false; }
virtual void onUnpinAsTexture(GrContext*) const {}
- virtual sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType,
- SkTransferFunctionBehavior) const = 0;
+ virtual sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType) const = 0;
protected:
SkImage_Base(int width, int height, uint32_t uniqueID);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 359782f745..0fcc01f0f0 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -950,13 +950,7 @@ bool SkImage::MakeBackendTextureFromSkImage(GrContext* ctx,
///////////////////////////////////////////////////////////////////////////////////////////////////
-sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> target, SkColorType,
- SkTransferFunctionBehavior premulBehavior) const {
- if (SkTransferFunctionBehavior::kRespect == premulBehavior) {
- // TODO: Implement this.
- return nullptr;
- }
-
+sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> target, SkColorType) const {
sk_sp<SkColorSpace> srcSpace = fColorSpace;
if (!fColorSpace) {
if (target->isSRGB()) {
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index c79e5295be..57c38c10fd 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -60,8 +60,7 @@ public:
sk_sp<SkColorSpace> refColorSpace() { return fColorSpace; }
- sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType,
- SkTransferFunctionBehavior) const override;
+ sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType) const override;
typedef ReleaseContext TextureContext;
typedef void (*TextureFulfillProc)(TextureContext textureContext, GrBackendTexture* outTexture);
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index 8d8e95219d..402acf5d73 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -94,8 +94,7 @@ public:
bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override;
bool onIsLazyGenerated() const override { return true; }
bool onCanLazyGenerateOnGPU() const override;
- sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType,
- SkTransferFunctionBehavior) const override;
+ sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType) const override;
bool onIsValid(GrContext*) const override;
@@ -451,8 +450,7 @@ sk_sp<SkImage> SkImage_Lazy::onMakeSubset(const SkIRect& subset) const {
}
sk_sp<SkImage> SkImage_Lazy::onMakeColorSpace(sk_sp<SkColorSpace> target,
- SkColorType targetColorType,
- SkTransferFunctionBehavior premulBehavior) const {
+ SkColorType targetColorType) const {
SkAutoExclusive autoAquire(fOnMakeColorSpaceMutex);
if (target && fOnMakeColorSpaceTarget &&
SkColorSpace::Equals(target.get(), fOnMakeColorSpaceTarget.get())) {
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index ca01780d36..859014f398 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -110,8 +110,7 @@ public:
SkASSERT(bitmapMayBeMutable || fBitmap.isImmutable());
}
- sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType,
- SkTransferFunctionBehavior) const override;
+ sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType) const override;
bool onIsValid(GrContext* context) const override { return true; }
@@ -343,8 +342,7 @@ bool SkImage_Raster::onAsLegacyBitmap(SkBitmap* bitmap) const {
///////////////////////////////////////////////////////////////////////////////
sk_sp<SkImage> SkImage_Raster::onMakeColorSpace(sk_sp<SkColorSpace> target,
- SkColorType targetColorType,
- SkTransferFunctionBehavior premulBehavior) const {
+ SkColorType targetColorType) const {
SkPixmap src;
SkAssertResult(fBitmap.peekPixels(&src));
@@ -361,7 +359,7 @@ sk_sp<SkImage> SkImage_Raster::onMakeColorSpace(sk_sp<SkColorSpace> target,
SkBitmap dst;
dst.allocPixels(dstInfo);
- SkAssertResult(dst.writePixels(src, 0, 0, premulBehavior));
+ SkAssertResult(dst.writePixels(src, 0, 0));
dst.setImmutable();
return SkImage::MakeFromBitmap(dst);
}
diff --git a/src/images/SkImageEncoder.cpp b/src/images/SkImageEncoder.cpp
index 7472a02f51..946a67f231 100644
--- a/src/images/SkImageEncoder.cpp
+++ b/src/images/SkImageEncoder.cpp
@@ -40,19 +40,16 @@ bool SkEncodeImage(SkWStream* dst, const SkPixmap& src,
case SkEncodedImageFormat::kJPEG: {
SkJpegEncoder::Options opts;
opts.fQuality = quality;
- opts.fBlendBehavior = SkTransferFunctionBehavior::kIgnore;
return SkJpegEncoder::Encode(dst, src, opts);
}
case SkEncodedImageFormat::kPNG: {
SkPngEncoder::Options opts;
- opts.fUnpremulBehavior = SkTransferFunctionBehavior::kIgnore;
return SkPngEncoder::Encode(dst, src, opts);
}
case SkEncodedImageFormat::kWEBP: {
SkWebpEncoder::Options opts;
opts.fCompression = SkWebpEncoder::Compression::kLossy;
opts.fQuality = quality;
- opts.fUnpremulBehavior = SkTransferFunctionBehavior::kIgnore;
return SkWebpEncoder::Encode(dst, src, opts);
}
default:
diff --git a/src/images/SkImageEncoderFns.h b/src/images/SkImageEncoderFns.h
index 6bf0081b26..cd9972952d 100644
--- a/src/images/SkImageEncoderFns.h
+++ b/src/images/SkImageEncoderFns.h
@@ -163,24 +163,6 @@ static inline void transform_scanline_bgrA(char* SK_RESTRICT dst, const char* SK
SkUnpremultiplyRow<true>((uint32_t*) dst, (const uint32_t*) src, width);
}
-template <bool kIsRGBA>
-static inline void transform_scanline_unpremultiply_sRGB(void* dst, const void* src, int width) {
- SkJumper_MemoryCtx src_ctx = { (void*)src, 0 },
- dst_ctx = { (void*)dst, 0 };
- SkRasterPipeline_<256> p;
- if (kIsRGBA) {
- p.append(SkRasterPipeline::load_8888, &src_ctx);
- } else {
- p.append(SkRasterPipeline::load_bgra, &src_ctx);
- }
-
- p.append(SkRasterPipeline::from_srgb);
- p.append(SkRasterPipeline::unpremul);
- p.append(SkRasterPipeline::to_srgb);
- p.append(SkRasterPipeline::store_8888, &dst_ctx);
- p.run(0,0, width,1);
-}
-
/**
* Premultiply RGBA to rgbA.
*/
@@ -191,39 +173,6 @@ static inline void transform_scanline_to_premul_legacy(char* SK_RESTRICT dst,
}
/**
- * Premultiply RGBA to rgbA linearly.
- */
-static inline void transform_scanline_to_premul_linear(char* SK_RESTRICT dst,
- const char* SK_RESTRICT src,
- int width, int, const SkPMColor*) {
- SkJumper_MemoryCtx src_ctx = { (void*)src, 0 },
- dst_ctx = { (void*)dst, 0 };
- SkRasterPipeline_<256> p;
- p.append(SkRasterPipeline::load_8888, &src_ctx);
- p.append(SkRasterPipeline::from_srgb);
- p.append(SkRasterPipeline::premul);
- p.append(SkRasterPipeline::to_srgb);
- p.append(SkRasterPipeline::store_8888, &dst_ctx);
- p.run(0,0, width,1);
-}
-
-/**
- * Transform from kPremul, kRGBA_8888_SkColorType to 4-bytes-per-pixel unpremultiplied RGBA.
- */
-static inline void transform_scanline_srgbA(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
- int width, int, const SkPMColor*) {
- transform_scanline_unpremultiply_sRGB<true>(dst, src, width);
-}
-
-/**
- * Transform from kPremul, kBGRA_8888_SkColorType to 4-bytes-per-pixel unpremultiplied RGBA.
- */
-static inline void transform_scanline_sbgrA(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
- int width, int, const SkPMColor*) {
- transform_scanline_unpremultiply_sRGB<false>(dst, src, width);
-}
-
-/**
* Transform from kUnpremul, kBGRA_8888_SkColorType to 4-bytes-per-pixel unpremultiplied RGBA.
*/
static inline void transform_scanline_BGRA(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
@@ -336,7 +285,6 @@ static inline void transform_scanline_F16(char* SK_RESTRICT dst, const char* SK_
p.append(SkRasterPipeline::load_f16, &src_ctx);
p.append(SkRasterPipeline::clamp_0); // F16 values may be out of [0,1] range, so clamp.
p.append(SkRasterPipeline::clamp_1);
- p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_u16_be, &dst_ctx);
p.run(0,0, width,1);
}
@@ -353,7 +301,6 @@ static inline void transform_scanline_F16_premul(char* SK_RESTRICT dst, const ch
p.append(SkRasterPipeline::unpremul);
p.append(SkRasterPipeline::clamp_0); // F16 values may be out of [0,1] range, so clamp.
p.append(SkRasterPipeline::clamp_1);
- p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_u16_be, &dst_ctx);
p.run(0,0, width,1);
}
@@ -370,7 +317,6 @@ static inline void transform_scanline_F16_to_8888(char* SK_RESTRICT dst,
p.append(SkRasterPipeline::load_f16, &src_ctx);
p.append(SkRasterPipeline::clamp_0); // F16 values may be out of [0,1] range, so clamp.
p.append(SkRasterPipeline::clamp_1);
- p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_8888, &dst_ctx);
p.run(0,0, width,1);
}
@@ -388,7 +334,6 @@ static inline void transform_scanline_F16_premul_to_8888(char* SK_RESTRICT dst,
p.append(SkRasterPipeline::unpremul);
p.append(SkRasterPipeline::clamp_0); // F16 values may be out of [0,1] range, so clamp.
p.append(SkRasterPipeline::clamp_1);
- p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_8888, &dst_ctx);
p.run(0,0, width,1);
}
@@ -405,7 +350,6 @@ static inline void transform_scanline_F16_to_premul_8888(char* SK_RESTRICT dst,
p.append(SkRasterPipeline::clamp_0); // F16 values may be out of [0,1] range, so clamp.
p.append(SkRasterPipeline::clamp_1);
p.append(SkRasterPipeline::premul);
- p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_8888, &dst_ctx);
p.run(0,0, width,1);
}
@@ -421,7 +365,6 @@ static inline void transform_scanline_F32(char* SK_RESTRICT dst, const char* SK_
p.append(SkRasterPipeline::load_f32, &src_ctx);
p.append(SkRasterPipeline::clamp_0); // F32 values may be out of [0,1] range, so clamp.
p.append(SkRasterPipeline::clamp_1);
- p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_u16_be, &dst_ctx);
p.run(0,0, width,1);
}
@@ -438,7 +381,6 @@ static inline void transform_scanline_F32_premul(char* SK_RESTRICT dst, const ch
p.append(SkRasterPipeline::unpremul);
p.append(SkRasterPipeline::clamp_0); // F32 values may be out of [0,1] range, so clamp.
p.append(SkRasterPipeline::clamp_1);
- p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_u16_be, &dst_ctx);
p.run(0,0, width,1);
}
@@ -449,13 +391,6 @@ static inline sk_sp<SkData> icc_from_color_space(const SkImageInfo& info) {
return nullptr;
}
- sk_sp<SkColorSpace> owned;
- if (kRGBA_F16_SkColorType == info.colorType() ||
- kRGBA_F32_SkColorType == info.colorType()) {
- owned = cs->makeSRGBGamma();
- cs = owned.get();
- }
-
SkColorSpaceTransferFn fn;
SkMatrix44 toXYZD50(SkMatrix44::kUninitialized_Constructor);
if (cs->isNumericalTransferFn(&fn) && cs->toXYZD50(&toXYZD50)) {
diff --git a/src/images/SkJpegEncoder.cpp b/src/images/SkJpegEncoder.cpp
index 9c139f707b..1c1fb15e2e 100644
--- a/src/images/SkJpegEncoder.cpp
+++ b/src/images/SkJpegEncoder.cpp
@@ -74,15 +74,7 @@ bool SkJpegEncoderMgr::setParams(const SkImageInfo& srcInfo, const SkJpegEncoder
return (transform_scanline_proc) nullptr;
}
- // Note that kRespect mode is only supported with sRGB or linear transfer functions.
- // The legacy code path is incidentally correct when the transfer function is linear.
- const bool isSRGBTransferFn = srcInfo.gammaCloseToSRGB() &&
- (SkTransferFunctionBehavior::kRespect == options.fBlendBehavior);
- if (isSRGBTransferFn) {
- return transform_scanline_to_premul_linear;
- } else {
- return transform_scanline_to_premul_legacy;
- }
+ return transform_scanline_to_premul_legacy;
};
J_COLOR_SPACE jpegColorType = JCS_EXT_RGBA;
@@ -118,8 +110,7 @@ bool SkJpegEncoderMgr::setParams(const SkImageInfo& srcInfo, const SkJpegEncoder
numComponents = 1;
break;
case kRGBA_F16_SkColorType:
- if (!srcInfo.colorSpace() ||
- SkTransferFunctionBehavior::kRespect != options.fBlendBehavior) {
+ if (!srcInfo.colorSpace()) {
return false;
}
diff --git a/src/images/SkPngEncoder.cpp b/src/images/SkPngEncoder.cpp
index 7520b9044d..0ca2551735 100644
--- a/src/images/SkPngEncoder.cpp
+++ b/src/images/SkPngEncoder.cpp
@@ -55,7 +55,7 @@ public:
bool setHeader(const SkImageInfo& srcInfo, const SkPngEncoder::Options& options);
bool setColorSpace(const SkImageInfo& info);
bool writeInfo(const SkImageInfo& srcInfo);
- void chooseProc(const SkImageInfo& srcInfo, SkTransferFunctionBehavior unpremulBehavior);
+ void chooseProc(const SkImageInfo& srcInfo);
png_structp pngPtr() { return fPngPtr; }
png_infop infoPtr() { return fInfoPtr; }
@@ -230,10 +230,7 @@ bool SkPngEncoderMgr::setHeader(const SkImageInfo& srcInfo, const SkPngEncoder::
return true;
}
-static transform_scanline_proc choose_proc(const SkImageInfo& info,
- SkTransferFunctionBehavior unpremulBehavior) {
- const bool isSRGBTransferFn =
- (SkTransferFunctionBehavior::kRespect == unpremulBehavior) && info.gammaCloseToSRGB();
+static transform_scanline_proc choose_proc(const SkImageInfo& info) {
switch (info.colorType()) {
case kRGBA_8888_SkColorType:
switch (info.alphaType()) {
@@ -242,8 +239,7 @@ static transform_scanline_proc choose_proc(const SkImageInfo& info,
case kUnpremul_SkAlphaType:
return transform_scanline_memcpy;
case kPremul_SkAlphaType:
- return isSRGBTransferFn ? transform_scanline_srgbA :
- transform_scanline_rgbA;
+ return transform_scanline_rgbA;
default:
SkASSERT(false);
return nullptr;
@@ -255,8 +251,7 @@ static transform_scanline_proc choose_proc(const SkImageInfo& info,
case kUnpremul_SkAlphaType:
return transform_scanline_BGRA;
case kPremul_SkAlphaType:
- return isSRGBTransferFn ? transform_scanline_sbgrA :
- transform_scanline_bgrA;
+ return transform_scanline_bgrA;
default:
SkASSERT(false);
return nullptr;
@@ -369,9 +364,8 @@ bool SkPngEncoderMgr::writeInfo(const SkImageInfo& srcInfo) {
return true;
}
-void SkPngEncoderMgr::chooseProc(const SkImageInfo& srcInfo,
- SkTransferFunctionBehavior unpremulBehavior) {
- fProc = choose_proc(srcInfo, unpremulBehavior);
+void SkPngEncoderMgr::chooseProc(const SkImageInfo& srcInfo) {
+ fProc = choose_proc(srcInfo);
}
std::unique_ptr<SkEncoder> SkPngEncoder::Make(SkWStream* dst, const SkPixmap& src,
@@ -397,7 +391,7 @@ std::unique_ptr<SkEncoder> SkPngEncoder::Make(SkWStream* dst, const SkPixmap& sr
return nullptr;
}
- encoderMgr->chooseProc(src.info(), options.fUnpremulBehavior);
+ encoderMgr->chooseProc(src.info());
return std::unique_ptr<SkPngEncoder>(new SkPngEncoder(std::move(encoderMgr), src));
}
diff --git a/src/images/SkWebpEncoder.cpp b/src/images/SkWebpEncoder.cpp
index 2cb55d2f04..bda34dcb01 100644
--- a/src/images/SkWebpEncoder.cpp
+++ b/src/images/SkWebpEncoder.cpp
@@ -41,10 +41,7 @@ extern "C" {
#include "webp/mux.h"
}
-static transform_scanline_proc choose_proc(const SkImageInfo& info,
- SkTransferFunctionBehavior unpremulBehavior) {
- const bool isSRGBTransferFn =
- (SkTransferFunctionBehavior::kRespect == unpremulBehavior) && info.gammaCloseToSRGB();
+static transform_scanline_proc choose_proc(const SkImageInfo& info) {
switch (info.colorType()) {
case kRGBA_8888_SkColorType:
switch (info.alphaType()) {
@@ -53,8 +50,7 @@ static transform_scanline_proc choose_proc(const SkImageInfo& info,
case kUnpremul_SkAlphaType:
return transform_scanline_memcpy;
case kPremul_SkAlphaType:
- return isSRGBTransferFn ? transform_scanline_srgbA :
- transform_scanline_rgbA;
+ return transform_scanline_rgbA;
default:
return nullptr;
}
@@ -65,8 +61,7 @@ static transform_scanline_proc choose_proc(const SkImageInfo& info,
case kUnpremul_SkAlphaType:
return transform_scanline_BGRA;
case kPremul_SkAlphaType:
- return isSRGBTransferFn ? transform_scanline_sbgrA :
- transform_scanline_bgrA;
+ return transform_scanline_bgrA;
default:
return nullptr;
}
@@ -113,7 +108,7 @@ bool SkWebpEncoder::Encode(SkWStream* stream, const SkPixmap& pixmap, const Opti
return false;
}
- const transform_scanline_proc proc = choose_proc(pixmap.info(), opts.fUnpremulBehavior);
+ const transform_scanline_proc proc = choose_proc(pixmap.info());
if (!proc) {
return false;
}
diff --git a/src/shaders/SkPictureShader.cpp b/src/shaders/SkPictureShader.cpp
index 6ff4a0eb12..5549de240d 100644
--- a/src/shaders/SkPictureShader.cpp
+++ b/src/shaders/SkPictureShader.cpp
@@ -253,7 +253,7 @@ sk_sp<SkShader> SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix,
}
if (fColorSpace) {
- tileImage = tileImage->makeColorSpace(fColorSpace, SkTransferFunctionBehavior::kIgnore);
+ tileImage = tileImage->makeColorSpace(fColorSpace);
}
tileShader = tileImage->makeShader(fTmx, fTmy);