diff options
author | Mike Klein <mtklein@chromium.org> | 2017-05-08 21:56:55 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-09 18:16:51 +0000 |
commit | ee2d9df087c5225c9f3ba0fb98d237905f2d650c (patch) | |
tree | c38db3fb1ffe90ccf6f1e56780cbd4f82a93471c /src/core/SkPM4fPriv.h | |
parent | 31ec1442270fdb8b8fca9ac17eb75ae74327d08d (diff) |
make append_gamut_tranform() never fail
The only way it could ostensibly fail is if we get non-XYZ color
spaces, which should just not happen. Assert that doesn't happen
and safely do nothing instead of failing.
This is one of the leaf nodes to getting SkCreateRasterPipelineBlitter
to never fail. Next come SkColorFilter:: and SkShader::appendStages().
Change-Id: I5c7a8c63d0a9837e2e55208e1674796d86f45307
Reviewed-on: https://skia-review.googlesource.com/16002
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/core/SkPM4fPriv.h')
-rw-r--r-- | src/core/SkPM4fPriv.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/core/SkPM4fPriv.h b/src/core/SkPM4fPriv.h index 821c8822cb..f4142737b5 100644 --- a/src/core/SkPM4fPriv.h +++ b/src/core/SkPM4fPriv.h @@ -100,17 +100,23 @@ 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 bool append_gamut_transform(SkRasterPipeline* p, float scratch_matrix_3x4[12], +static inline void append_gamut_transform(SkRasterPipeline* p, float scratch_matrix_3x4[12], SkColorSpace* src, SkColorSpace* dst) { - if (src == dst) { return true; } - if (!dst) { return true; } // Legacy modes intentionally ignore color gamut. - if (!src) { return true; } // A null src color space means linear gamma, dst gamut. + 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. auto toXYZ = as_CSB(src)-> toXYZD50(), fromXYZ = as_CSB(dst)->fromXYZD50(); - if (!toXYZ || !fromXYZ) { return false; } // Unsupported color space type. + if (!toXYZ || !fromXYZ) { + SkASSERT(false); // We really don't want to get here with a weird colorspace. + return; + } - if (as_CSB(src)->toXYZD50Hash() == as_CSB(dst)->toXYZD50Hash()) { return true; } + // Slightly more sophisticated version of if (src == dst) + if (as_CSB(src)->toXYZD50Hash() == as_CSB(dst)->toXYZD50Hash()) { + return; + } SkMatrix44 m44(*fromXYZ, *toXYZ); @@ -127,12 +133,11 @@ static inline bool append_gamut_transform(SkRasterPipeline* p, float scratch_mat 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); } - return true; } -static inline bool append_gamut_transform(SkRasterPipeline* p, SkArenaAlloc* scratch, +static inline void append_gamut_transform(SkRasterPipeline* p, SkArenaAlloc* scratch, SkColorSpace* src, SkColorSpace* dst) { - return append_gamut_transform(p, scratch->makeArrayDefault<float>(12), src, dst); + append_gamut_transform(p, scratch->makeArrayDefault<float>(12), src, dst); } static inline SkColor4f to_colorspace(const SkColor4f& c, SkColorSpace* src, SkColorSpace* dst) { |