aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-12-14 03:35:13 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-14 04:24:08 +0000
commit2e018f548d76b0688f9873c683cffc681fec40ec (patch)
tree9e98ad62d7e5f334d3a310a7344d452fdaa40485
parent8ba64d1996ba6c9ecfb12132cdab7d5d99af7456 (diff)
Revert "clamp to premul when reading premul sRGB"
This reverts commit 04e10da8362a0dcabd795a4ad53f617719ca0d20. Reason for revert: roll? Change-Id: Id0a8dcd62763bd6eddde120c513ca97e098a4268 Reviewed-on: https://skia-review.googlesource.com/6022 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
-rw-r--r--bench/SkRasterPipelineBench.cpp4
-rw-r--r--src/core/SkConfig8888.cpp2
-rw-r--r--src/core/SkRasterPipeline.cpp34
-rw-r--r--src/core/SkRasterPipeline.h8
-rw-r--r--src/core/SkRasterPipelineBlitter.cpp2
-rw-r--r--src/image/SkImageShader.cpp2
-rw-r--r--src/opts/SkRasterPipeline_opts.h16
7 files changed, 11 insertions, 57 deletions
diff --git a/bench/SkRasterPipelineBench.cpp b/bench/SkRasterPipelineBench.cpp
index 16dea8aa66..64e59c8b54 100644
--- a/bench/SkRasterPipelineBench.cpp
+++ b/bench/SkRasterPipelineBench.cpp
@@ -38,13 +38,13 @@ public:
SkRasterPipeline 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);
if (kF16) {
p.append(SkRasterPipeline::load_f16_d, &dst_ctx);
} else {
p.append(SkRasterPipeline::load_8888_d, &dst_ctx);
- p.append_from_srgb_d(kPremul_SkAlphaType);
+ p.append(SkRasterPipeline::from_srgb_d);
}
p.append(SkRasterPipeline::srcover);
if (kF16) {
diff --git a/src/core/SkConfig8888.cpp b/src/core/SkConfig8888.cpp
index 08635a2b84..3906a9a1ef 100644
--- a/src/core/SkConfig8888.cpp
+++ b/src/core/SkConfig8888.cpp
@@ -47,7 +47,7 @@ static bool copy_pipeline_pixels(const SkImageInfo& dstInfo, void* dstRow, size_
case kBGRA_8888_SkColorType:
pipeline.append(SkRasterPipeline::load_8888, &srcRow);
if (src_srgb) {
- pipeline.append_from_srgb(srcInfo.alphaType());
+ pipeline.append(SkRasterPipeline::from_srgb);
}
if (swap_rb) {
pipeline.append(SkRasterPipeline::swap_rb);
diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp
index 00ba81e6f3..4c1dbc762e 100644
--- a/src/core/SkRasterPipeline.cpp
+++ b/src/core/SkRasterPipeline.cpp
@@ -11,14 +11,6 @@
SkRasterPipeline::SkRasterPipeline() {}
void SkRasterPipeline::append(StockStage stage, void* ctx) {
-#ifdef SK_DEBUG
- switch (stage) {
- case from_srgb:
- case from_srgb_d:
- SkDEBUGFAIL("Please use append_srgb[_d]() instead.");
- default: break;
- }
-#endif
fStages.push_back({stage, ctx});
}
@@ -50,29 +42,3 @@ void SkRasterPipeline::dump() const {
}
SkDebugf("\n");
}
-
-// It's pretty easy to start with sound premultiplied linear floats, pack those
-// to sRGB encoded bytes, then read them back to linear floats and find them not
-// quite premultiplied, with a color channel just a smidge greater than the alpha
-// channel. This can happen basically any time we have different transfer
-// functions for alpha and colors... sRGB being the only one we draw into.
-
-// This is an annoying problem with no known good solution. So apply the clamp hammer.
-
-void SkRasterPipeline::append_from_srgb(SkAlphaType at) {
- //this->append(from_srgb);
- fStages.push_back({from_srgb, nullptr});
-
- if (at == kPremul_SkAlphaType) {
- this->append(SkRasterPipeline::clamp_a);
- }
-}
-
-void SkRasterPipeline::append_from_srgb_d(SkAlphaType at) {
- //this->append(from_srgb_d);
- fStages.push_back({from_srgb_d, nullptr});
-
- if (at == kPremul_SkAlphaType) {
- this->append(SkRasterPipeline::clamp_a_d);
- }
-}
diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h
index 0486bb3e34..b3f513d69e 100644
--- a/src/core/SkRasterPipeline.h
+++ b/src/core/SkRasterPipeline.h
@@ -8,7 +8,6 @@
#ifndef SkRasterPipeline_DEFINED
#define SkRasterPipeline_DEFINED
-#include "SkImageInfo.h"
#include "SkNx.h"
#include "SkTArray.h"
#include "SkTypes.h"
@@ -59,7 +58,7 @@
#define SK_RASTER_PIPELINE_STAGES(M) \
M(trace) M(registers) \
M(move_src_dst) M(move_dst_src) M(swap_rb) M(swap_rb_d) \
- M(clamp_0) M(clamp_1) M(clamp_a) M(clamp_a_d) \
+ M(clamp_0) M(clamp_a) M(clamp_1) \
M(unpremul) M(premul) \
M(set_rgb) \
M(from_srgb) M(from_srgb_d) M(to_srgb) \
@@ -120,11 +119,6 @@ public:
void* ctx;
};
- // 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_d(SkAlphaType);
-
private:
std::vector<Stage> fStages;
};
diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp
index cbdb09faa4..d2a0b3d4c1 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -197,7 +197,7 @@ void SkRasterPipelineBlitter::append_load_d(SkRasterPipeline* p) const {
p->append(SkRasterPipeline::swap_rb_d);
}
if (fDst.info().gammaCloseToSRGB()) {
- p->append_from_srgb_d(fDst.info().alphaType());
+ p->append(SkRasterPipeline::from_srgb_d);
}
}
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index e009b4a849..ce9cbadbbc 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -350,7 +350,7 @@ bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkFal
default: SkASSERT(false);
}
if (info.gammaCloseToSRGB() && dst != nullptr) {
- p->append_from_srgb(info.alphaType());
+ p->append(SkRasterPipeline::from_srgb);
}
};
diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h
index 135d927b85..3cc3f2f01a 100644
--- a/src/opts/SkRasterPipeline_opts.h
+++ b/src/opts/SkRasterPipeline_opts.h
@@ -301,23 +301,17 @@ STAGE(clamp_0) {
g = SkNf::Max(g, 0.0f);
b = SkNf::Max(b, 0.0f);
}
-STAGE(clamp_1) {
- a = SkNf::Min(a, 1.0f);
- r = SkNf::Min(r, 1.0f);
- g = SkNf::Min(g, 1.0f);
- b = SkNf::Min(b, 1.0f);
-}
STAGE(clamp_a) {
a = SkNf::Min(a, 1.0f);
r = SkNf::Min(r, a);
g = SkNf::Min(g, a);
b = SkNf::Min(b, a);
}
-STAGE(clamp_a_d) {
- da = SkNf::Min(da, 1.0f);
- dr = SkNf::Min(dr, da);
- dg = SkNf::Min(dg, da);
- db = SkNf::Min(db, da);
+STAGE(clamp_1) {
+ a = SkNf::Min(a, 1.0f);
+ r = SkNf::Min(r, 1.0f);
+ g = SkNf::Min(g, 1.0f);
+ b = SkNf::Min(b, 1.0f);
}
STAGE(unpremul) {