aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-12-18 14:07:31 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-18 19:48:43 +0000
commitf1f1162273b382db99f8609e5bbfff24f5594821 (patch)
treeb14638cf3acb809b5337d1628375bb01f75b4ae0
parent95152e1c836e8736704137bcea59ccc23ce90f29 (diff)
remove append_from_srgb()
It's now no different than append(from_srgb). Bug: skia:7419 Change-Id: I97c59b6987f033ec2f1859db40ca3056b87b370a Reviewed-on: https://skia-review.googlesource.com/86741 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
-rw-r--r--bench/SkRasterPipelineBench.cpp4
-rw-r--r--src/codec/SkWebpCodec.cpp4
-rw-r--r--src/core/SkBlitter_Sprite.cpp2
-rw-r--r--src/core/SkColorFilter.cpp2
-rw-r--r--src/core/SkColorSpaceXform.cpp4
-rw-r--r--src/core/SkColorSpaceXform_A2B.cpp3
-rw-r--r--src/core/SkColorSpace_New.cpp20
-rw-r--r--src/core/SkColorSpace_New.h6
-rw-r--r--src/core/SkConvertPixels.cpp2
-rw-r--r--src/core/SkRasterPipeline.cpp10
-rw-r--r--src/core/SkRasterPipeline.h5
-rw-r--r--src/core/SkRasterPipelineBlitter.cpp2
-rw-r--r--src/effects/SkToSRGBColorFilter.cpp3
-rw-r--r--src/images/SkImageEncoderFns.h4
-rw-r--r--src/shaders/SkImageShader.cpp2
-rw-r--r--tests/SRGBTest.cpp2
-rw-r--r--tests/SkColorSpace_NewTest.cpp4
-rw-r--r--tools/picture_utils.cpp2
18 files changed, 31 insertions, 50 deletions
diff --git a/bench/SkRasterPipelineBench.cpp b/bench/SkRasterPipelineBench.cpp
index baff258409..5ddf43dd21 100644
--- a/bench/SkRasterPipelineBench.cpp
+++ b/bench/SkRasterPipelineBench.cpp
@@ -42,14 +42,14 @@ public:
SkRasterPipeline_<256> p;
p.append(SkRasterPipeline::load_8888, &src_ctx);
- p.append_from_srgb(kUnpremul_SkAlphaType);
+ p.append(SkRasterPipeline::from_srgb);
p.append(SkRasterPipeline::scale_u8, &mask_ctx);
p.append(SkRasterPipeline::move_src_dst);
if (kF16) {
p.append(SkRasterPipeline::load_f16, &dst_ctx);
} else {
p.append(SkRasterPipeline::load_8888, &dst_ctx);
- p.append_from_srgb(kPremul_SkAlphaType);
+ p.append(SkRasterPipeline::from_srgb);
}
p.append(SkRasterPipeline::dstover);
if (kF16) {
diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp
index 2ff4681337..ca63349c0e 100644
--- a/src/codec/SkWebpCodec.cpp
+++ b/src/codec/SkWebpCodec.cpp
@@ -364,7 +364,7 @@ static void blend_line(SkColorType dstCT, void* dst,
// Load the final dst.
p.append(load_dst, &dst_ctx);
if (needsSrgbToLinear) {
- p.append_from_srgb(dstAt);
+ p.append(SkRasterPipeline::from_srgb);
}
if (kUnpremul_SkAlphaType == dstAt) {
p.append(SkRasterPipeline::premul);
@@ -376,7 +376,7 @@ static void blend_line(SkColorType dstCT, void* dst,
pick_memory_stages(srcCT, &load_src, nullptr);
p.append(load_src, &src_ctx);
if (needsSrgbToLinear) {
- p.append_from_srgb(kUnpremul_SkAlphaType);
+ p.append(SkRasterPipeline::from_srgb);
}
if (srcHasAlpha) {
p.append(SkRasterPipeline::premul);
diff --git a/src/core/SkBlitter_Sprite.cpp b/src/core/SkBlitter_Sprite.cpp
index eddb42b25b..3537beaea8 100644
--- a/src/core/SkBlitter_Sprite.cpp
+++ b/src/core/SkBlitter_Sprite.cpp
@@ -125,7 +125,7 @@ public:
}
if (fDst.colorSpace() &&
(!fSource.colorSpace() || fSource.colorSpace()->gammaCloseToSRGB())) {
- p.append_from_srgb(fSource.alphaType());
+ p.append(SkRasterPipeline::from_srgb);
}
if (fSource.colorType() == kAlpha_8_SkColorType) {
p.append(SkRasterPipeline::set_rgb, &fPaintColor);
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index 9a8b399b9e..3c6beea794 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -244,7 +244,7 @@ public:
p->append(SkRasterPipeline::to_srgb);
break;
case Direction::kSRGBToLinear:
- p->append_from_srgb(shaderIsOpaque ? kOpaque_SkAlphaType : kUnpremul_SkAlphaType);
+ p->append(SkRasterPipeline::from_srgb);
break;
}
if (!shaderIsOpaque) {
diff --git a/src/core/SkColorSpaceXform.cpp b/src/core/SkColorSpaceXform.cpp
index 0792ec894e..9494e249c1 100644
--- a/src/core/SkColorSpaceXform.cpp
+++ b/src/core/SkColorSpaceXform.cpp
@@ -485,7 +485,7 @@ bool SkColorSpaceXform_XYZ::onApply(ColorFormat dstColorFormat, void* dst,
break;
case kSRGB_SrcGamma:
pipeline.append(SkRasterPipeline::load_u16_be, &src_ctx);
- pipeline.append_from_srgb(kUnpremul_SkAlphaType);
+ pipeline.append(SkRasterPipeline::from_srgb);
break;
case kTable_SrcGamma:
loadTables.fSrc = src;
@@ -503,7 +503,7 @@ bool SkColorSpaceXform_XYZ::onApply(ColorFormat dstColorFormat, void* dst,
break;
case kSRGB_SrcGamma:
pipeline.append(SkRasterPipeline::load_rgb_u16_be, &src_ctx);
- pipeline.append_from_srgb(kUnpremul_SkAlphaType);
+ pipeline.append(SkRasterPipeline::from_srgb);
break;
case kTable_SrcGamma:
loadTables.fSrc = src;
diff --git a/src/core/SkColorSpaceXform_A2B.cpp b/src/core/SkColorSpaceXform_A2B.cpp
index 3543ba40a3..9470247a8d 100644
--- a/src/core/SkColorSpaceXform_A2B.cpp
+++ b/src/core/SkColorSpaceXform_A2B.cpp
@@ -140,8 +140,7 @@ SkColorSpaceXform_A2B::SkColorSpaceXform_A2B(SkColorSpace_A2B* srcSpace,
// Take the fast path for ordinary sRGB.
if (3 == currentChannels && kSRGB_SkGammaNamed == e.gammaNamed()) {
SkCSXformPrintf("fast path from sRGB\n");
- // Images should always start the pipeline as unpremul
- fElementsPipeline.append_from_srgb(kUnpremul_SkAlphaType);
+ fElementsPipeline.append(SkRasterPipeline::from_srgb);
break;
}
diff --git a/src/core/SkColorSpace_New.cpp b/src/core/SkColorSpace_New.cpp
index 0d020c51ed..5db388d07a 100644
--- a/src/core/SkColorSpace_New.cpp
+++ b/src/core/SkColorSpace_New.cpp
@@ -18,9 +18,9 @@ namespace {
return { 1,1, 0,0,0,0,0 };
}
- void linearizeDst(SkRasterPipeline*, SkAlphaType) const override {}
- void linearizeSrc(SkRasterPipeline*, SkAlphaType) const override {}
- void encodeSrc(SkRasterPipeline* ) const override {}
+ void linearizeDst(SkRasterPipeline*) const override {}
+ void linearizeSrc(SkRasterPipeline*) const override {}
+ void encodeSrc(SkRasterPipeline*) const override {}
};
struct SRGBTransferFn : public SkColorSpace_New::TransferFn {
@@ -28,11 +28,11 @@ namespace {
return { 2.4f, 1/1.055f, 0.055f/1.055f, 1/12.92f, 0.04045f, 0, 0 };
}
- void linearizeDst(SkRasterPipeline* p, SkAlphaType at) const override {
- p->append_from_srgb_dst(at);
+ void linearizeDst(SkRasterPipeline* p) const override {
+ p->append(SkRasterPipeline::from_srgb_dst);
}
- void linearizeSrc(SkRasterPipeline* p, SkAlphaType at) const override {
- p->append_from_srgb(at);
+ void linearizeSrc(SkRasterPipeline* p) const override {
+ p->append(SkRasterPipeline::from_srgb);
}
void encodeSrc(SkRasterPipeline* p) const override {
p->append(SkRasterPipeline::to_srgb);
@@ -49,13 +49,11 @@ namespace {
return { fGamma, 1, 0,0,0,0,0 };
}
- void linearizeDst(SkRasterPipeline* p, SkAlphaType) const override {
+ void linearizeDst(SkRasterPipeline* p) const override {
p->append(SkRasterPipeline::gamma_dst, &fGamma);
- // TODO: use SkAlphaType to clamp like SRGBTransferFn does?
}
- void linearizeSrc(SkRasterPipeline* p, SkAlphaType) const override {
+ void linearizeSrc(SkRasterPipeline* p) const override {
p->append(SkRasterPipeline::gamma, &fGamma);
- // TODO: use SkAlphaType to clamp like SRGBTransferFn does?
}
void encodeSrc(SkRasterPipeline* p) const override {
p->append(SkRasterPipeline::gamma, &fInv);
diff --git a/src/core/SkColorSpace_New.h b/src/core/SkColorSpace_New.h
index 42d5a9e55f..6f26c3bf4b 100644
--- a/src/core/SkColorSpace_New.h
+++ b/src/core/SkColorSpace_New.h
@@ -26,9 +26,9 @@ public:
virtual SkColorSpaceTransferFn parameterize() const = 0;
// Append stages to use this transfer function with SkRasterPipeline-based rendering.
- virtual void linearizeDst(SkRasterPipeline*, SkAlphaType) const = 0;
- virtual void linearizeSrc(SkRasterPipeline*, SkAlphaType) const = 0;
- virtual void encodeSrc(SkRasterPipeline* ) const = 0;
+ virtual void linearizeDst(SkRasterPipeline*) const = 0;
+ virtual void linearizeSrc(SkRasterPipeline*) const = 0;
+ virtual void encodeSrc(SkRasterPipeline*) const = 0;
// TODO: Ganesh hooks.
diff --git a/src/core/SkConvertPixels.cpp b/src/core/SkConvertPixels.cpp
index 2175c8bb8e..725730a1e4 100644
--- a/src/core/SkConvertPixels.cpp
+++ b/src/core/SkConvertPixels.cpp
@@ -253,7 +253,7 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size
SkColorSpaceTransferFn srcFn;
if (isColorAware && srcInfo.gammaCloseToSRGB()) {
- pipeline.append_from_srgb(premulState);
+ pipeline.append(SkRasterPipeline::from_srgb);
} else if (isColorAware && !srcInfo.colorSpace()->gammaIsLinear()) {
SkAssertResult(srcInfo.colorSpace()->isNumericalTransferFn(&srcFn));
if (is_just_gamma(srcFn)) {
diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp
index 1134bd2acd..c7a0427b1f 100644
--- a/src/core/SkRasterPipeline.cpp
+++ b/src/core/SkRasterPipeline.cpp
@@ -21,7 +21,6 @@ void SkRasterPipeline::reset() {
}
void SkRasterPipeline::append(StockStage stage, void* ctx) {
- SkASSERT(stage != from_srgb); // Please use append_from_srgb().
SkASSERT(stage != uniform_color); // Please use append_constant_color().
SkASSERT(stage != seed_shader); // Please use append_seed_shader().
this->unchecked_append(stage, ctx);
@@ -123,15 +122,6 @@ void SkRasterPipeline::append_constant_color(SkArenaAlloc* alloc, const float rg
#undef INC_WHITE
#undef INC_COLOR
-// TODO: we used to clamp to [0,a]] here if at == kPremul, but don't anymore.
-// These should no longer need to be special append() methods.
-void SkRasterPipeline::append_from_srgb(SkAlphaType) {
- this->unchecked_append(from_srgb, nullptr);
-}
-void SkRasterPipeline::append_from_srgb_dst(SkAlphaType) {
- this->unchecked_append(from_srgb_dst, nullptr);
-}
-
//static int gCounts[5] = { 0, 0, 0, 0, 0 };
void SkRasterPipeline::append_matrix(SkArenaAlloc* alloc, const SkMatrix& matrix) {
diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h
index 005c3dd7ab..ad9fd77a84 100644
--- a/src/core/SkRasterPipeline.h
+++ b/src/core/SkRasterPipeline.h
@@ -125,11 +125,6 @@ public:
void dump() const;
- // Conversion from sRGB can be subtly tricky when premultiplication is involved.
- // Use these helpers to keep things sane.
- void append_from_srgb(SkAlphaType);
- void append_from_srgb_dst(SkAlphaType);
-
// Appends a stage for the specified matrix.
// Tries to optimize the stage by analyzing the type of matrix.
void append_matrix(SkArenaAlloc*, const SkMatrix&);
diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp
index 098dab8b09..ac8cdd99ad 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -238,7 +238,7 @@ void SkRasterPipelineBlitter::append_load_dst(SkRasterPipeline* p) const {
default: break;
}
if (fDst.info().gammaCloseToSRGB()) {
- p->append_from_srgb_dst(fDst.info().alphaType());
+ p->append(SkRasterPipeline::from_srgb_dst);
}
if (fDst.info().alphaType() == kUnpremul_SkAlphaType) {
p->append(SkRasterPipeline::premul_dst);
diff --git a/src/effects/SkToSRGBColorFilter.cpp b/src/effects/SkToSRGBColorFilter.cpp
index 057ea075b3..b20f3883e6 100644
--- a/src/effects/SkToSRGBColorFilter.cpp
+++ b/src/effects/SkToSRGBColorFilter.cpp
@@ -27,8 +27,7 @@ void SkToSRGBColorFilter::onAppendStages(SkRasterPipeline* p,
if (fSrcColorSpace->gammaIsLinear()) {
// Nothing to do.
} else if (fSrcColorSpace->gammaCloseToSRGB()) {
- p->append_from_srgb(shaderIsOpaque ? kOpaque_SkAlphaType
- : kPremul_SkAlphaType);
+ p->append(SkRasterPipeline::from_srgb);
} else if (fSrcColorSpace->isNumericalTransferFn(&srcFn)) {
auto copy = alloc->make<SkColorSpaceTransferFn>(srcFn);
p->append(SkRasterPipeline::parametric_r, copy);
diff --git a/src/images/SkImageEncoderFns.h b/src/images/SkImageEncoderFns.h
index 8e44ff222e..6425b8fde8 100644
--- a/src/images/SkImageEncoderFns.h
+++ b/src/images/SkImageEncoderFns.h
@@ -175,7 +175,7 @@ static inline void transform_scanline_unpremultiply_sRGB(void* dst, const void*
p.append(SkRasterPipeline::load_bgra, &src_ctx);
}
- p.append_from_srgb(kPremul_SkAlphaType);
+ p.append(SkRasterPipeline::from_srgb);
p.append(SkRasterPipeline::unpremul);
p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_8888, &dst_ctx);
@@ -201,7 +201,7 @@ static inline void transform_scanline_to_premul_linear(char* SK_RESTRICT dst,
dst_ctx = { (void*)dst, 0 };
SkRasterPipeline_<256> p;
p.append(SkRasterPipeline::load_8888, &src_ctx);
- p.append_from_srgb(kUnpremul_SkAlphaType);
+ p.append(SkRasterPipeline::from_srgb);
p.append(SkRasterPipeline::premul);
p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_8888, &dst_ctx);
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index fff59c7bc3..ef13498ece 100644
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -347,7 +347,7 @@ bool SkImageShader::onAppendStages(const StageRec& rec) const {
default: SkASSERT(false);
}
if (rec.fDstCS && (!info.colorSpace() || info.gammaCloseToSRGB())) {
- p->append_from_srgb(info.alphaType());
+ p->append(SkRasterPipeline::from_srgb);
}
};
diff --git a/tests/SRGBTest.cpp b/tests/SRGBTest.cpp
index cda6fc410a..44daeda34a 100644
--- a/tests/SRGBTest.cpp
+++ b/tests/SRGBTest.cpp
@@ -51,7 +51,7 @@ DEF_TEST(sk_pipeline_srgb_roundtrip, r) {
SkRasterPipeline_<256> p;
p.append(SkRasterPipeline::load_8888, &ptr);
- p.append_from_srgb(kUnpremul_SkAlphaType);
+ p.append(SkRasterPipeline::from_srgb);
p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_8888, &ptr);
diff --git a/tests/SkColorSpace_NewTest.cpp b/tests/SkColorSpace_NewTest.cpp
index a301a06f44..31a5da6c50 100644
--- a/tests/SkColorSpace_NewTest.cpp
+++ b/tests/SkColorSpace_NewTest.cpp
@@ -62,11 +62,11 @@ DEF_TEST(SkColorSpace_New_TransferFnStages, r) {
SkRasterPipeline_<256> p;
p.append(SkRasterPipeline::load_8888, &src_ctx);
- cs->transferFn().linearizeSrc(&p, kUnpremul_SkAlphaType);
+ cs->transferFn().linearizeSrc(&p);
p.append(SkRasterPipeline::premul);
p.append(SkRasterPipeline::load_8888_dst, &dst_ctx);
- cs->transferFn().linearizeDst(&p, kUnpremul_SkAlphaType);
+ cs->transferFn().linearizeDst(&p);
p.append(SkRasterPipeline::premul_dst);
p.append(SkRasterPipeline::srcover);
diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp
index f476c0dbc0..d0d2198f62 100644
--- a/tools/picture_utils.cpp
+++ b/tools/picture_utils.cpp
@@ -95,7 +95,7 @@ namespace sk_tools {
default: SkASSERT(false); // DM doesn't support any other formats, does it?
}
if (bitmap.info().gammaCloseToSRGB()) {
- p.append_from_srgb(kUnpremul_SkAlphaType);
+ p.append(SkRasterPipeline::from_srgb);
}
p.append(SkRasterPipeline::unpremul);
p.append(SkRasterPipeline::clamp_0);