add a test that sRGB stages round trip

Change-Id: Ide8303f6fc162f3703f7db298fe210d47225a580
Reviewed-on: https://skia-review.googlesource.com/16988
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Mike Klein 2017-05-15 18:03:52 -04:00 committed by Skia Commit-Bot
parent f82b3cd6b5
commit ca2194b38e

View File

@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
#include "SkRasterPipeline.h"
#include "SkSRGB.h"
#include "SkTypes.h"
#include "Test.h"
@ -37,3 +38,26 @@ DEF_TEST(sk_linear_to_srgb, r) {
f = pun.flt;
}
}
DEF_TEST(sk_pipeline_srgb_roundtrip, r) {
uint32_t reds[256];
for (int i = 0; i < 256; i++) {
reds[i] = i;
}
auto ptr = (void*)reds;
SkRasterPipeline p;
p.append(SkRasterPipeline::load_8888, &ptr);
p.append_from_srgb(kUnpremul_SkAlphaType);
p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_8888, &ptr);
p.run(0,256);
for (int i = 0; i < 256; i++) {
if (reds[i] != (uint32_t)i) {
ERRORF(r, "%d doesn't round trip, %d", i, reds[i]);
}
}
}