diff options
Diffstat (limited to 'tests/SRGBTest.cpp')
-rw-r--r-- | tests/SRGBTest.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/SRGBTest.cpp b/tests/SRGBTest.cpp index 78855a34c8..b1e4570f50 100644 --- a/tests/SRGBTest.cpp +++ b/tests/SRGBTest.cpp @@ -5,6 +5,7 @@ * found in the LICENSE file. */ +#include "SkPM4f.h" #include "SkRasterPipeline.h" #include "SkSRGB.h" #include "SkTypes.h" @@ -61,3 +62,26 @@ DEF_TEST(sk_pipeline_srgb_roundtrip, r) { } } } + +DEF_TEST(sk_pipeline_srgb_edge_cases, r) { + // We need to run at least 4 pixels to make sure we hit all specializations. + SkPM4f colors[4] = { {{0,1,1,1}}, {{0,0,0,0}}, {{0,0,0,0}}, {{0,0,0,0}} }; + auto& color = colors[0]; + void* dst = &color; + + SkRasterPipeline_<256> p; + p.append(SkRasterPipeline::constant_color, &color); + p.append(SkRasterPipeline::to_srgb); + p.append(SkRasterPipeline::store_f32, &dst); + p.run(0,4); + + if (color.r() != 0.0f) { + ERRORF(r, "expected to_srgb() to map 0.0f to 0.0f, got %f", color.r()); + } + if (color.g() != 1.0f) { + float f = color.g(); + uint32_t x; + memcpy(&x, &f, 4); + ERRORF(r, "expected to_srgb() to map 1.0f to 1.0f, got %f (%08x)", color.g(), x); + } +} |