aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-05-12 08:38:02 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-12 13:05:39 +0000
commitf391f4e07d4424498ca81c8b4c328cc2049d5105 (patch)
treeef0d79509723d76b687d8ea4778e5fab50839be4
parent6cdc22cde8e6297d34fdaaa3ed5e69ae86c30a77 (diff)
Pass alphaType to append_gamut_transform() to inform the clamp
BUG=skia: Change-Id: I1a8aef36043d4091bffae95b0275fa7fa8a35c97 Reviewed-on: https://skia-review.googlesource.com/9441 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
-rw-r--r--src/core/SkConvertPixels.cpp3
-rw-r--r--src/core/SkPM4fPriv.h19
-rw-r--r--src/image/SkImageShader.cpp2
3 files changed, 15 insertions, 9 deletions
diff --git a/src/core/SkConvertPixels.cpp b/src/core/SkConvertPixels.cpp
index 2d0cf68830..99564e7222 100644
--- a/src/core/SkConvertPixels.cpp
+++ b/src/core/SkConvertPixels.cpp
@@ -320,7 +320,8 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size
float matrix[12];
if (isColorAware) {
- append_gamut_transform(&pipeline, matrix, srcInfo.colorSpace(), dstInfo.colorSpace());
+ append_gamut_transform(&pipeline, matrix, srcInfo.colorSpace(), dstInfo.colorSpace(),
+ premulState);
}
SkAlphaType dat = dstInfo.alphaType();
diff --git a/src/core/SkPM4fPriv.h b/src/core/SkPM4fPriv.h
index f4142737b5..795ff4cbf8 100644
--- a/src/core/SkPM4fPriv.h
+++ b/src/core/SkPM4fPriv.h
@@ -101,7 +101,8 @@ static inline void analyze_3x4_matrix(const float matrix[12],
// N.B. scratch_matrix_3x4 must live at least as long as p.
static inline void append_gamut_transform(SkRasterPipeline* p, float scratch_matrix_3x4[12],
- SkColorSpace* src, SkColorSpace* dst) {
+ SkColorSpace* src, SkColorSpace* dst,
+ SkAlphaType alphaType) {
if (src == dst) { return; } // That was easy.
if (!dst) { return; } // Legacy modes intentionally ignore color gamut.
if (!src) { return; } // A null src color space means linear gamma, dst gamut.
@@ -127,17 +128,21 @@ static inline void append_gamut_transform(SkRasterPipeline* p, float scratch_mat
*ptr++ = m44.get(0,2); *ptr++ = m44.get(1,2); *ptr++ = m44.get(2,2);
*ptr++ = m44.get(0,3); *ptr++ = m44.get(1,3); *ptr++ = m44.get(2,3);
- bool needs_clamp_0, needs_clamp_a;
- analyze_3x4_matrix(scratch_matrix_3x4, &needs_clamp_0, &needs_clamp_a);
+ bool needs_clamp_0, needs_clamp_1;
+ analyze_3x4_matrix(scratch_matrix_3x4, &needs_clamp_0, &needs_clamp_1);
p->append(SkRasterPipeline::matrix_3x4, scratch_matrix_3x4);
if (needs_clamp_0) { p->append(SkRasterPipeline::clamp_0); }
- if (needs_clamp_a) { p->append(SkRasterPipeline::clamp_a); }
+ if (needs_clamp_1) {
+ (kPremul_SkAlphaType == alphaType) ? p->append(SkRasterPipeline::clamp_a)
+ : p->append(SkRasterPipeline::clamp_1);
+ }
}
static inline void append_gamut_transform(SkRasterPipeline* p, SkArenaAlloc* scratch,
- SkColorSpace* src, SkColorSpace* dst) {
- append_gamut_transform(p, scratch->makeArrayDefault<float>(12), src, dst);
+ SkColorSpace* src, SkColorSpace* dst,
+ SkAlphaType alphaType) {
+ append_gamut_transform(p, scratch->makeArrayDefault<float>(12), src, dst, alphaType);
}
static inline SkColor4f to_colorspace(const SkColor4f& c, SkColorSpace* src, SkColorSpace* dst) {
@@ -149,7 +154,7 @@ static inline SkColor4f to_colorspace(const SkColor4f& c, SkColorSpace* src, SkC
SkRasterPipeline p;
p.append(SkRasterPipeline::constant_color, color4f_ptr);
- append_gamut_transform(&p, scratch_matrix_3x4, src, dst);
+ append_gamut_transform(&p, scratch_matrix_3x4, src, dst, kUnpremul_SkAlphaType);
p.append(SkRasterPipeline::store_f32, &color4f_ptr);
p.run(0,1);
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index 03897239d0..0dbf944948 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -385,6 +385,6 @@ bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dstCS, SkA
p->append(SkRasterPipeline::clamp_0);
p->append(SkRasterPipeline::clamp_a);
}
- append_gamut_transform(p, alloc, info.colorSpace(), dstCS);
+ append_gamut_transform(p, alloc, info.colorSpace(), dstCS, kPremul_SkAlphaType);
return true;
}